diff options
author | Gregory Maxwell <greg@xiph.org> | 2013-09-02 20:29:02 -0700 |
---|---|---|
committer | Gregory Maxwell <greg@xiph.org> | 2013-09-02 20:29:02 -0700 |
commit | dd30937ce3d6c09bd6e435fab94286e0bea92a11 (patch) | |
tree | fde4daca3c447ab02f327d69aec766b8568b1038 /src/rpcwallet.cpp | |
parent | f4f048ee58b4ad8ecd0472f375e6d9bfdb629873 (diff) | |
parent | e5e9904c1c87fcdddf01e563ffe28cc56aea4f29 (diff) |
Merge pull request #2948 from jgarzik/changeaddr
RPC: add getrawchangeaddress, for raw transaction change destinations
Diffstat (limited to 'src/rpcwallet.cpp')
-rw-r--r-- | src/rpcwallet.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index 34bd4ffccf..14b4956a15 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -176,6 +176,29 @@ Value getaccountaddress(const Array& params, bool fHelp) } +Value getrawchangeaddress(const Array& params, bool fHelp) +{ + if (fHelp || params.size() > 1) + throw runtime_error( + "getrawchangeaddress\n" + "Returns a new Bitcoin address, for receiving change. " + "This is for use with raw transactions, NOT normal use."); + + if (!pwalletMain->IsLocked()) + pwalletMain->TopUpKeyPool(); + + CReserveKey reservekey(pwalletMain); + CPubKey vchPubKey; + if (!reservekey.GetReservedKey(vchPubKey)) + throw JSONRPCError(RPC_WALLET_ERROR, "Error: Unable to obtain key for change"); + + reservekey.KeepKey(); + + CKeyID keyID = vchPubKey.GetID(); + + return CBitcoinAddress(keyID).ToString(); +} + Value setaccount(const Array& params, bool fHelp) { |