diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -195,16 +195,17 @@ return EncodeDestination(keyID); } -CTxDestination GetLabelAddress(CWallet *const pwallet, const std::string &label, - bool bForceNew = false) { - CPubKey pubKey; - if (!pwallet->GetLabelAddress(pubKey, label, bForceNew)) { +CTxDestination GetLabelDestination(CWallet *const pwallet, + const std::string &label, + bool bForceNew = false) { + CTxDestination dest; + if (!pwallet->GetLabelDestination(dest, label, bForceNew)) { throw JSONRPCError( RPC_WALLET_KEYPOOL_RAN_OUT, "Error: Keypool ran out, please call keypoolrefill first"); } - return pubKey.GetID(); + return dest; } UniValue getlabeladdress(const Config &config, const JSONRPCRequest &request) { @@ -239,7 +240,7 @@ UniValue ret(UniValue::VSTR); - ret = EncodeDestination(GetLabelAddress(pwallet, label)); + ret = EncodeDestination(GetLabelDestination(pwallet, label)); return ret; } @@ -326,8 +327,8 @@ // current key' of another label: if (pwallet->mapAddressBook.count(dest)) { std::string old_label = pwallet->mapAddressBook[dest].name; - if (dest == GetLabelAddress(pwallet, old_label)) { - GetLabelAddress(pwallet, old_label, true); + if (dest == GetLabelDestination(pwallet, old_label)) { + GetLabelDestination(pwallet, old_label, true); } } diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -970,8 +970,8 @@ DBErrors ReorderTransactions(); bool AccountMove(std::string strFrom, std::string strTo, const Amount nAmount, std::string strComment = ""); - bool GetLabelAddress(CPubKey &pubKey, const std::string &label, - bool bForceNew = false); + bool GetLabelDestination(CTxDestination &dest, const std::string &label, + bool bForceNew = false); void MarkDirty(); bool AddToWallet(const CWalletTx &wtxIn, bool fFlushOnClose = true); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -889,8 +889,8 @@ return walletdb.TxnCommit(); } -bool CWallet::GetLabelAddress(CPubKey &pubKey, const std::string &label, - bool bForceNew) { +bool CWallet::GetLabelDestination(CTxDestination &dest, + const std::string &label, bool bForceNew) { CWalletDB walletdb(*dbw); CAccount account; @@ -921,12 +921,13 @@ return false; } - SetAddressBook(account.vchPubKey.GetID(), label, "receive"); + dest = account.vchPubKey.GetID(); + SetAddressBook(dest, label, "receive"); walletdb.WriteAccount(label, account); + } else { + dest = account.vchPubKey.GetID(); } - pubKey = account.vchPubKey; - return true; }