WalletTool: magic --output value ALL for easier emptying of wallets.

This commit is contained in:
Andreas Schildbach 2014-11-07 13:21:46 +01:00
parent c2611b5345
commit 91e7fe6816
2 changed files with 9 additions and 2 deletions

View file

@ -18,6 +18,7 @@
package org.bitcoinj.tools;
import org.bitcoinj.core.*;
import org.bitcoinj.core.Wallet.BalanceType;
import org.bitcoinj.crypto.DeterministicKey;
import org.bitcoinj.crypto.KeyCrypterException;
import org.bitcoinj.crypto.MnemonicCode;
@ -517,7 +518,11 @@ public class WalletTool {
}
String destination = parts[0];
try {
Coin value = parseCoin(parts[1]);
Coin value;
if ("ALL".equalsIgnoreCase(parts[1]))
value = wallet.getBalance(BalanceType.ESTIMATED);
else
value = parseCoin(parts[1]);
if (destination.startsWith("0")) {
// Treat as a raw public key.
byte[] pubKey = new BigInteger(destination, 16).toByteArray();

View file

@ -27,9 +27,11 @@ Usage: wallet-tool --flags action-name
send Creates and broadcasts a transaction from the given wallet.
Requires either --output or --payment-request to be specified.
If --output is specified, a transaction is created from the provided output
from this wallet and broadcasted, eg:
from this wallet and broadcasted, e.g.:
--output=1GthXFQMktFLWdh5EPNGqbq3H6WdG8zsWj:1.245
You can repeat --output=address:value multiple times.
There is a magic value ALL which empties the wallet to that address, e.g.:
--output=1GthXFQMktFLWdh5EPNGqbq3H6WdG8zsWj:ALL
If the output destination starts with 04 and is 65 or 33 bytes long it will be
treated as a public key instead of an address and the send will use
<key> CHECKSIG as the script.