3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-14 19:25:51 +00:00

WalletTool: New option --fee-sat-per-byte to set network fee in satoshi per byte.

This commit is contained in:
Andreas Schildbach 2018-01-25 12:02:50 +01:00
parent d3dca96a3c
commit 9dd8e5ab92
2 changed files with 28 additions and 4 deletions

View File

@ -224,6 +224,7 @@ public class WalletTool {
OptionSpec<String> outputFlag = parser.accepts("output").withRequiredArg(); OptionSpec<String> outputFlag = parser.accepts("output").withRequiredArg();
parser.accepts("value").withRequiredArg(); parser.accepts("value").withRequiredArg();
OptionSpec<String> feePerKbOption = parser.accepts("fee-per-kb").withRequiredArg(); OptionSpec<String> feePerKbOption = parser.accepts("fee-per-kb").withRequiredArg();
OptionSpec<String> feeSatPerByteOption = parser.accepts("fee-sat-per-byte").withRequiredArg();
unixtimeFlag = parser.accepts("unixtime").withRequiredArg().ofType(Long.class); unixtimeFlag = parser.accepts("unixtime").withRequiredArg().ofType(Long.class);
OptionSpec<String> conditionFlag = parser.accepts("condition").withRequiredArg(); OptionSpec<String> conditionFlag = parser.accepts("condition").withRequiredArg();
parser.accepts("locktime").withRequiredArg(); parser.accepts("locktime").withRequiredArg();
@ -359,10 +360,15 @@ public class WalletTool {
if (options.has(paymentRequestLocation) && options.has(outputFlag)) { if (options.has(paymentRequestLocation) && options.has(outputFlag)) {
System.err.println("--payment-request and --output cannot be used together."); System.err.println("--payment-request and --output cannot be used together.");
return; return;
} else if (options.has(feePerKbOption) && options.has(feeSatPerByteOption)) {
System.err.println("--fee-per-kb and --fee-sat-per-byte cannot be used together.");
return;
} else if (options.has(outputFlag)) { } else if (options.has(outputFlag)) {
Coin feePerKb = null; Coin feePerKb = null;
if (options.has(feePerKbOption)) if (options.has(feePerKbOption))
feePerKb = parseCoin((String) options.valueOf(feePerKbOption)); feePerKb = parseCoin((String) options.valueOf(feePerKbOption));
if (options.has(feeSatPerByteOption))
feePerKb = Coin.valueOf(Long.parseLong(options.valueOf(feeSatPerByteOption)) * 1000);
String lockTime = null; String lockTime = null;
if (options.has("locktime")) { if (options.has("locktime")) {
lockTime = (String) options.valueOf("locktime"); lockTime = (String) options.valueOf("locktime");
@ -377,6 +383,10 @@ public class WalletTool {
} }
break; break;
case SEND_CLTVPAYMENTCHANNEL: { case SEND_CLTVPAYMENTCHANNEL: {
if (options.has(feePerKbOption) && options.has(feeSatPerByteOption)) {
System.err.println("--fee-per-kb and --fee-sat-per-byte cannot be used together.");
return;
}
if (!options.has(outputFlag)) { if (!options.has(outputFlag)) {
System.err.println("You must specify a --output=addr:value"); System.err.println("You must specify a --output=addr:value");
return; return;
@ -384,6 +394,8 @@ public class WalletTool {
Coin feePerKb = null; Coin feePerKb = null;
if (options.has(feePerKbOption)) if (options.has(feePerKbOption))
feePerKb = parseCoin((String) options.valueOf(feePerKbOption)); feePerKb = parseCoin((String) options.valueOf(feePerKbOption));
if (options.has(feeSatPerByteOption))
feePerKb = Coin.valueOf(Long.parseLong(options.valueOf(feeSatPerByteOption)) * 1000);
if (!options.has("locktime")) { if (!options.has("locktime")) {
System.err.println("You must specify a --locktime"); System.err.println("You must specify a --locktime");
return; return;
@ -397,6 +409,10 @@ public class WalletTool {
sendCLTVPaymentChannel(refundFlag.value(options), outputFlag.value(options), feePerKb, lockTime, allowUnconfirmed); sendCLTVPaymentChannel(refundFlag.value(options), outputFlag.value(options), feePerKb, lockTime, allowUnconfirmed);
} break; } break;
case SETTLE_CLTVPAYMENTCHANNEL: { case SETTLE_CLTVPAYMENTCHANNEL: {
if (options.has(feePerKbOption) && options.has(feeSatPerByteOption)) {
System.err.println("--fee-per-kb and --fee-sat-per-byte cannot be used together.");
return;
}
if (!options.has(outputFlag)) { if (!options.has(outputFlag)) {
System.err.println("You must specify a --output=addr:value"); System.err.println("You must specify a --output=addr:value");
return; return;
@ -404,6 +420,8 @@ public class WalletTool {
Coin feePerKb = null; Coin feePerKb = null;
if (options.has(feePerKbOption)) if (options.has(feePerKbOption))
feePerKb = parseCoin((String) options.valueOf(feePerKbOption)); feePerKb = parseCoin((String) options.valueOf(feePerKbOption));
if (options.has(feeSatPerByteOption))
feePerKb = Coin.valueOf(Long.parseLong(options.valueOf(feeSatPerByteOption)) * 1000);
boolean allowUnconfirmed = options.has("allow-unconfirmed"); boolean allowUnconfirmed = options.has("allow-unconfirmed");
if (!options.has(txHashFlag)) { if (!options.has(txHashFlag)) {
System.err.println("You must specify the transaction to spend: --txhash=tx-hash"); System.err.println("You must specify the transaction to spend: --txhash=tx-hash");
@ -412,6 +430,10 @@ public class WalletTool {
settleCLTVPaymentChannel(txHashFlag.value(options), outputFlag.value(options), feePerKb, allowUnconfirmed); settleCLTVPaymentChannel(txHashFlag.value(options), outputFlag.value(options), feePerKb, allowUnconfirmed);
} break; } break;
case REFUND_CLTVPAYMENTCHANNEL: { case REFUND_CLTVPAYMENTCHANNEL: {
if (options.has(feePerKbOption) && options.has(feeSatPerByteOption)) {
System.err.println("--fee-per-kb and --fee-sat-per-byte cannot be used together.");
return;
}
if (!options.has(outputFlag)) { if (!options.has(outputFlag)) {
System.err.println("You must specify a --output=addr:value"); System.err.println("You must specify a --output=addr:value");
return; return;
@ -419,6 +441,8 @@ public class WalletTool {
Coin feePerKb = null; Coin feePerKb = null;
if (options.has(feePerKbOption)) if (options.has(feePerKbOption))
feePerKb = parseCoin((String) options.valueOf(feePerKbOption)); feePerKb = parseCoin((String) options.valueOf(feePerKbOption));
if (options.has(feeSatPerByteOption))
feePerKb = Coin.valueOf(Long.parseLong(options.valueOf(feeSatPerByteOption)) * 1000);
boolean allowUnconfirmed = options.has("allow-unconfirmed"); boolean allowUnconfirmed = options.has("allow-unconfirmed");
if (!options.has(txHashFlag)) { if (!options.has(txHashFlag)) {
System.err.println("You must specify the transaction to spend: --txhash=tx-hash"); System.err.println("You must specify the transaction to spend: --txhash=tx-hash");

View File

@ -49,7 +49,7 @@ Usage: wallet-tool --flags action-name
--payment-request=http://merchant.com/pay.php?123 --payment-request=http://merchant.com/pay.php?123
Other options include: Other options include:
--fee-per-kb=0.0005 sets the tx fee --fee-per-kb=0.0005 or --fee-sat-per-byte=50 sets the network fee
--locktime=1234 sets the lock time to block 1234 --locktime=1234 sets the lock time to block 1234
--locktime=2013/01/01 sets the lock time to 1st Jan 2013 --locktime=2013/01/01 sets the lock time to 1st Jan 2013
--allow-unconfirmed will let you create spends of pending non-change outputs. --allow-unconfirmed will let you create spends of pending non-change outputs.
@ -73,14 +73,14 @@ Usage: wallet-tool --flags action-name
Options: Options:
--output=pubkey:value sets the amount to lock and the recipient --output=pubkey:value sets the amount to lock and the recipient
--refund-to=pubkey sets "our" public key --refund-to=pubkey sets "our" public key
--fee-per-kb=value sets the network fee --fee-per-kb=0.0005 or --fee-sat-per-byte=50 sets the network fee
--locktime=YYYY/MM/DD sets the expiry time for the channel --locktime=YYYY/MM/DD sets the expiry time for the channel
settle-cltvpaymentchannel settle-cltvpaymentchannel
Creates and broadcasts a transaction settling a previous micropayment channel. Creates and broadcasts a transaction settling a previous micropayment channel.
This tool, for testing, requires the presence of both private keys. This tool, for testing, requires the presence of both private keys.
Options: Options:
--output=pubkey:value sets the destination for the money --output=pubkey:value sets the destination for the money
--fee-per-kb=value sets the network fee --fee-per-kb=0.0005 or --fee-sat-per-byte=50 sets the network fee
--txhash=hash sets the transaction to spend --txhash=hash sets the transaction to spend
refund-cltvpaymentchannel refund-cltvpaymentchannel
Creates and broadcasts a transaction refunding a previous micropayment channel. Creates and broadcasts a transaction refunding a previous micropayment channel.
@ -88,7 +88,7 @@ Usage: wallet-tool --flags action-name
the created transaction won't be accepted into the mempool until that point. the created transaction won't be accepted into the mempool until that point.
Options: Options:
--output=pubkey:value sets the destination for the money --output=pubkey:value sets the destination for the money
--fee-per-kb=value sets the network fee --fee-per-kb=0.0005 or --fee-sat-per-byte=50 sets the network fee
--txhash=hash sets the transaction to spend --txhash=hash sets the transaction to spend
>>> GENERAL OPTIONS >>> GENERAL OPTIONS