aboutsummaryrefslogtreecommitdiff
path: root/src/rpcwallet.cpp
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@bitpay.com>2013-08-28 16:29:52 -0400
committerJeff Garzik <jgarzik@bitpay.com>2013-08-28 16:29:52 -0400
commite5e9904c1c87fcdddf01e563ffe28cc56aea4f29 (patch)
tree30c0cc52e398b3c2899ff9e6b914e7337b7ad2b5 /src/rpcwallet.cpp
parentbb7d0fc12fcfbb2a91e39cb49f2a0873344dbae0 (diff)
downloadbitcoin-e5e9904c1c87fcdddf01e563ffe28cc56aea4f29.tar.xz
RPC: add getrawchangeaddress, for raw transaction change destinations
Diffstat (limited to 'src/rpcwallet.cpp')
-rw-r--r--src/rpcwallet.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp
index d07d3408b9..978c44e1a9 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)
{