Skip to content

Commit cbe1974

Browse files
committed
[refactor] GetAccount{PubKey,Address} -> GetAccountDestination
1 parent 0c8ea63 commit cbe1974

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

src/wallet/rpcwallet.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,14 @@ UniValue getnewaddress(const JSONRPCRequest& request)
175175
}
176176

177177

178-
CTxDestination GetAccountAddress(CWallet* const pwallet, std::string strAccount, bool bForceNew=false)
178+
CTxDestination GetAccountDestination(CWallet* const pwallet, std::string strAccount, bool bForceNew=false)
179179
{
180-
CPubKey pubKey;
181-
if (!pwallet->GetAccountPubkey(pubKey, strAccount, bForceNew)) {
180+
CTxDestination dest;
181+
if (!pwallet->GetAccountDestination(dest, strAccount, bForceNew)) {
182182
throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, "Error: Keypool ran out, please call keypoolrefill first");
183183
}
184184

185-
return pubKey.GetID();
185+
return dest;
186186
}
187187

188188
UniValue getaccountaddress(const JSONRPCRequest& request)
@@ -214,7 +214,7 @@ UniValue getaccountaddress(const JSONRPCRequest& request)
214214

215215
UniValue ret(UniValue::VSTR);
216216

217-
ret = EncodeDestination(GetAccountAddress(pwallet, strAccount));
217+
ret = EncodeDestination(GetAccountDestination(pwallet, strAccount));
218218
return ret;
219219
}
220220

@@ -292,8 +292,8 @@ UniValue setaccount(const JSONRPCRequest& request)
292292
// Detect when changing the account of an address that is the 'unused current key' of another account:
293293
if (pwallet->mapAddressBook.count(dest)) {
294294
std::string strOldAccount = pwallet->mapAddressBook[dest].name;
295-
if (dest == GetAccountAddress(pwallet, strOldAccount)) {
296-
GetAccountAddress(pwallet, strOldAccount, true);
295+
if (dest == GetAccountDestination(pwallet, strOldAccount)) {
296+
GetAccountDestination(pwallet, strOldAccount, true);
297297
}
298298
}
299299
pwallet->SetAddressBook(dest, strAccount, "receive");

src/wallet/wallet.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ bool CWallet::AccountMove(std::string strFrom, std::string strTo, CAmount nAmoun
821821
return true;
822822
}
823823

824-
bool CWallet::GetAccountPubkey(CPubKey &pubKey, std::string strAccount, bool bForceNew)
824+
bool CWallet::GetAccountDestination(CTxDestination &dest, std::string strAccount, bool bForceNew)
825825
{
826826
CWalletDB walletdb(*dbw);
827827

@@ -850,12 +850,13 @@ bool CWallet::GetAccountPubkey(CPubKey &pubKey, std::string strAccount, bool bFo
850850
if (!GetKeyFromPool(account.vchPubKey, false))
851851
return false;
852852

853-
SetAddressBook(account.vchPubKey.GetID(), strAccount, "receive");
853+
dest = account.vchPubKey.GetID();
854+
SetAddressBook(dest, strAccount, "receive");
854855
walletdb.WriteAccount(strAccount, account);
856+
} else {
857+
dest = account.vchPubKey.GetID();
855858
}
856859

857-
pubKey = account.vchPubKey;
858-
859860
return true;
860861
}
861862

src/wallet/wallet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@ class CWallet final : public CCryptoKeyStore, public CValidationInterface
923923
int64_t IncOrderPosNext(CWalletDB *pwalletdb = nullptr);
924924
DBErrors ReorderTransactions();
925925
bool AccountMove(std::string strFrom, std::string strTo, CAmount nAmount, std::string strComment = "");
926-
bool GetAccountPubkey(CPubKey &pubKey, std::string strAccount, bool bForceNew = false);
926+
bool GetAccountDestination(CTxDestination &dest, std::string strAccount, bool bForceNew = false);
927927

928928
void MarkDirty();
929929
bool AddToWallet(const CWalletTx& wtxIn, bool fFlushOnClose=true);

0 commit comments

Comments
 (0)