mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
Rename account to label where appropriate
This change only updates strings and adds RPC aliases, but should simplify the implementation of address labels in https://github.com/bitcoin/bitcoin/pull/7729, by getting renaming out of the way and letting it focus on semantics. The difference between accounts and labels is that labels apply only to addresses, while accounts apply to both addresses and transactions (transactions have "from" and "to" accounts). The code associating accounts with transactions is clumsy and unreliable so we would like get rid of it.
This commit is contained in:
@@ -809,12 +809,12 @@ bool CWallet::AccountMove(std::string strFrom, std::string strTo, CAmount nAmoun
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CWallet::GetAccountDestination(CTxDestination &dest, std::string strAccount, bool bForceNew)
|
||||
bool CWallet::GetLabelDestination(CTxDestination &dest, const std::string& label, bool bForceNew)
|
||||
{
|
||||
CWalletDB walletdb(*dbw);
|
||||
|
||||
CAccount account;
|
||||
walletdb.ReadAccount(strAccount, account);
|
||||
walletdb.ReadAccount(label, account);
|
||||
|
||||
if (!bForceNew) {
|
||||
if (!account.vchPubKey.IsValid())
|
||||
@@ -840,8 +840,8 @@ bool CWallet::GetAccountDestination(CTxDestination &dest, std::string strAccount
|
||||
|
||||
LearnRelatedScripts(account.vchPubKey, m_default_address_type);
|
||||
dest = GetDestinationForKey(account.vchPubKey, m_default_address_type);
|
||||
SetAddressBook(dest, strAccount, "receive");
|
||||
walletdb.WriteAccount(strAccount, account);
|
||||
SetAddressBook(dest, label, "receive");
|
||||
walletdb.WriteAccount(label, account);
|
||||
} else {
|
||||
dest = GetDestinationForKey(account.vchPubKey, m_default_address_type);
|
||||
}
|
||||
@@ -2220,7 +2220,7 @@ CAmount CWallet::GetLegacyBalance(const isminefilter& filter, int minDepth, cons
|
||||
for (const CTxOut& out : wtx.tx->vout) {
|
||||
if (outgoing && IsChange(out)) {
|
||||
debit -= out.nValue;
|
||||
} else if (IsMine(out) & filter && depth >= minDepth && (!account || *account == GetAccountName(out.scriptPubKey))) {
|
||||
} else if (IsMine(out) & filter && depth >= minDepth && (!account || *account == GetLabelName(out.scriptPubKey))) {
|
||||
balance += out.nValue;
|
||||
}
|
||||
}
|
||||
@@ -3251,7 +3251,7 @@ bool CWallet::DelAddressBook(const CTxDestination& address)
|
||||
return CWalletDB(*dbw).EraseName(EncodeDestination(address));
|
||||
}
|
||||
|
||||
const std::string& CWallet::GetAccountName(const CScript& scriptPubKey) const
|
||||
const std::string& CWallet::GetLabelName(const CScript& scriptPubKey) const
|
||||
{
|
||||
CTxDestination address;
|
||||
if (ExtractDestination(scriptPubKey, address) && !scriptPubKey.IsUnspendable()) {
|
||||
@@ -3261,9 +3261,9 @@ const std::string& CWallet::GetAccountName(const CScript& scriptPubKey) const
|
||||
}
|
||||
}
|
||||
// A scriptPubKey that doesn't have an entry in the address book is
|
||||
// associated with the default account ("").
|
||||
const static std::string DEFAULT_ACCOUNT_NAME;
|
||||
return DEFAULT_ACCOUNT_NAME;
|
||||
// associated with the default label ("").
|
||||
const static std::string DEFAULT_LABEL_NAME;
|
||||
return DEFAULT_LABEL_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3619,7 +3619,7 @@ std::set< std::set<CTxDestination> > CWallet::GetAddressGroupings()
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::set<CTxDestination> CWallet::GetAccountAddresses(const std::string& strAccount) const
|
||||
std::set<CTxDestination> CWallet::GetLabelAddresses(const std::string& label) const
|
||||
{
|
||||
LOCK(cs_wallet);
|
||||
std::set<CTxDestination> result;
|
||||
@@ -3627,7 +3627,7 @@ std::set<CTxDestination> CWallet::GetAccountAddresses(const std::string& strAcco
|
||||
{
|
||||
const CTxDestination& address = item.first;
|
||||
const std::string& strName = item.second.name;
|
||||
if (strName == strAccount)
|
||||
if (strName == label)
|
||||
result.insert(address);
|
||||
}
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user