From 815c4b9ced0c58ddf7a7e266ca29b2273ef15dc7 Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Mon, 26 Jan 2015 14:55:19 +0100 Subject: [PATCH] Add current-receive-addr action to wallet-tool. --- tools/src/main/java/org/bitcoinj/tools/WalletTool.java | 7 +++++++ .../main/resources/org/bitcoinj/tools/wallet-tool-help.txt | 2 ++ 2 files changed, 9 insertions(+) diff --git a/tools/src/main/java/org/bitcoinj/tools/WalletTool.java b/tools/src/main/java/org/bitcoinj/tools/WalletTool.java index 1e16abff..02114bc5 100644 --- a/tools/src/main/java/org/bitcoinj/tools/WalletTool.java +++ b/tools/src/main/java/org/bitcoinj/tools/WalletTool.java @@ -166,6 +166,7 @@ public class WalletTool { ADD_KEY, ADD_ADDR, DELETE_KEY, + CURRENT_RECEIVE_ADDR, SYNC, RESET, SEND, @@ -342,6 +343,7 @@ public class WalletTool { case ADD_KEY: addKey(); break; case ADD_ADDR: addAddr(); break; case DELETE_KEY: deleteKey(); break; + case CURRENT_RECEIVE_ADDR: currentReceiveAddr(); break; case RESET: reset(); break; case SYNC: syncChain(); break; case SEND: @@ -1074,6 +1076,11 @@ public class WalletTool { wallet.removeKey(key); } + private static void currentReceiveAddr() { + ECKey key = wallet.currentReceiveKey(); + System.out.println(key.toAddress(params) + " " + key); + } + private static void dumpWallet() throws BlockStoreException { // Setup to get the chain height so we can estimate lock times, but don't wipe the transactions if it's not // there just for the dump case. diff --git a/tools/src/main/resources/org/bitcoinj/tools/wallet-tool-help.txt b/tools/src/main/resources/org/bitcoinj/tools/wallet-tool-help.txt index 662fe181..f16b011b 100644 --- a/tools/src/main/resources/org/bitcoinj/tools/wallet-tool-help.txt +++ b/tools/src/main/resources/org/bitcoinj/tools/wallet-tool-help.txt @@ -21,6 +21,8 @@ Usage: wallet-tool --flags action-name If --lookahead-size is specified, pre-generate at least this many keys ahead of where we are. add-addr Requires --addr to be specified, and adds it as a watching address. delete-key Removes the key specified by --pubkey or --addr from the wallet. + current-receive-addr Prints the current receive address, deriving one if needed. Addresses derived with this action are + independent of addresses derived with the add-key action. sync Sync the wallet with the latest block chain (download new transactions). If the chain file does not exist this will RESET the wallet. reset Deletes all transactions from the wallet, for if you want to replay the chain.