RPC: add getrawchangeaddress, for raw transaction change destinations
This commit is contained in:
parent
bb7d0fc12f
commit
e5e9904c1c
3 changed files with 25 additions and 0 deletions
|
@ -208,6 +208,7 @@ static const CRPCCommand vRPCCommands[] =
|
||||||
{ "getmininginfo", &getmininginfo, true, false },
|
{ "getmininginfo", &getmininginfo, true, false },
|
||||||
{ "getnewaddress", &getnewaddress, true, false },
|
{ "getnewaddress", &getnewaddress, true, false },
|
||||||
{ "getaccountaddress", &getaccountaddress, true, false },
|
{ "getaccountaddress", &getaccountaddress, true, false },
|
||||||
|
{ "getrawchangeaddress", &getrawchangeaddress, true, false },
|
||||||
{ "setaccount", &setaccount, true, false },
|
{ "setaccount", &setaccount, true, false },
|
||||||
{ "getaccount", &getaccount, false, false },
|
{ "getaccount", &getaccount, false, false },
|
||||||
{ "getaddressesbyaccount", &getaddressesbyaccount, true, false },
|
{ "getaddressesbyaccount", &getaddressesbyaccount, true, false },
|
||||||
|
|
|
@ -161,6 +161,7 @@ extern json_spirit::Value submitblock(const json_spirit::Array& params, bool fHe
|
||||||
|
|
||||||
extern json_spirit::Value getnewaddress(const json_spirit::Array& params, bool fHelp); // in rpcwallet.cpp
|
extern json_spirit::Value getnewaddress(const json_spirit::Array& params, bool fHelp); // in rpcwallet.cpp
|
||||||
extern json_spirit::Value getaccountaddress(const json_spirit::Array& params, bool fHelp);
|
extern json_spirit::Value getaccountaddress(const json_spirit::Array& params, bool fHelp);
|
||||||
|
extern json_spirit::Value getrawchangeaddress(const json_spirit::Array& params, bool fHelp);
|
||||||
extern json_spirit::Value setaccount(const json_spirit::Array& params, bool fHelp);
|
extern json_spirit::Value setaccount(const json_spirit::Array& params, bool fHelp);
|
||||||
extern json_spirit::Value getaccount(const json_spirit::Array& params, bool fHelp);
|
extern json_spirit::Value getaccount(const json_spirit::Array& params, bool fHelp);
|
||||||
extern json_spirit::Value getaddressesbyaccount(const json_spirit::Array& params, bool fHelp);
|
extern json_spirit::Value getaddressesbyaccount(const json_spirit::Array& params, bool fHelp);
|
||||||
|
|
|
@ -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)
|
Value setaccount(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue