aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/wallet/rpcwallet.cpp14
-rw-r--r--src/wallet/wallet.cpp9
-rw-r--r--src/wallet/wallet.h2
3 files changed, 13 insertions, 12 deletions
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp
index 760777ca29..b366992dec 100644
--- a/src/wallet/rpcwallet.cpp
+++ b/src/wallet/rpcwallet.cpp
@@ -175,14 +175,14 @@ UniValue getnewaddress(const JSONRPCRequest& request)
}
-CTxDestination GetAccountAddress(CWallet* const pwallet, std::string strAccount, bool bForceNew=false)
+CTxDestination GetAccountDestination(CWallet* const pwallet, std::string strAccount, bool bForceNew=false)
{
- CPubKey pubKey;
- if (!pwallet->GetAccountPubkey(pubKey, strAccount, bForceNew)) {
+ CTxDestination dest;
+ if (!pwallet->GetAccountDestination(dest, strAccount, bForceNew)) {
throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, "Error: Keypool ran out, please call keypoolrefill first");
}
- return pubKey.GetID();
+ return dest;
}
UniValue getaccountaddress(const JSONRPCRequest& request)
@@ -214,7 +214,7 @@ UniValue getaccountaddress(const JSONRPCRequest& request)
UniValue ret(UniValue::VSTR);
- ret = EncodeDestination(GetAccountAddress(pwallet, strAccount));
+ ret = EncodeDestination(GetAccountDestination(pwallet, strAccount));
return ret;
}
@@ -292,8 +292,8 @@ UniValue setaccount(const JSONRPCRequest& request)
// Detect when changing the account of an address that is the 'unused current key' of another account:
if (pwallet->mapAddressBook.count(dest)) {
std::string strOldAccount = pwallet->mapAddressBook[dest].name;
- if (dest == GetAccountAddress(pwallet, strOldAccount)) {
- GetAccountAddress(pwallet, strOldAccount, true);
+ if (dest == GetAccountDestination(pwallet, strOldAccount)) {
+ GetAccountDestination(pwallet, strOldAccount, true);
}
}
pwallet->SetAddressBook(dest, strAccount, "receive");
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 873a8d855e..f73f787259 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -821,7 +821,7 @@ bool CWallet::AccountMove(std::string strFrom, std::string strTo, CAmount nAmoun
return true;
}
-bool CWallet::GetAccountPubkey(CPubKey &pubKey, std::string strAccount, bool bForceNew)
+bool CWallet::GetAccountDestination(CTxDestination &dest, std::string strAccount, bool bForceNew)
{
CWalletDB walletdb(*dbw);
@@ -850,12 +850,13 @@ bool CWallet::GetAccountPubkey(CPubKey &pubKey, std::string strAccount, bool bFo
if (!GetKeyFromPool(account.vchPubKey, false))
return false;
- SetAddressBook(account.vchPubKey.GetID(), strAccount, "receive");
+ dest = account.vchPubKey.GetID();
+ SetAddressBook(dest, strAccount, "receive");
walletdb.WriteAccount(strAccount, account);
+ } else {
+ dest = account.vchPubKey.GetID();
}
- pubKey = account.vchPubKey;
-
return true;
}
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
index 93d1857c7f..e64ea2534a 100644
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -923,7 +923,7 @@ public:
int64_t IncOrderPosNext(CWalletDB *pwalletdb = nullptr);
DBErrors ReorderTransactions();
bool AccountMove(std::string strFrom, std::string strTo, CAmount nAmount, std::string strComment = "");
- bool GetAccountPubkey(CPubKey &pubKey, std::string strAccount, bool bForceNew = false);
+ bool GetAccountDestination(CTxDestination &dest, std::string strAccount, bool bForceNew = false);
void MarkDirty();
bool AddToWallet(const CWalletTx& wtxIn, bool fFlushOnClose=true);