mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-31 10:56:03 +02:00
Introduce wrappers around CBitcoinAddress
This patch removes the need for the intermediary Base58 type
CBitcoinAddress, by providing {Encode,Decode,IsValid}Destination
function that directly operate on the conversion between strings
and CTxDestination.
This commit is contained in:
@@ -307,7 +307,7 @@ bool CWallet::LoadCScript(const CScript& redeemScript)
|
||||
* these. Do not add them to the wallet and warn. */
|
||||
if (redeemScript.size() > MAX_SCRIPT_ELEMENT_SIZE)
|
||||
{
|
||||
std::string strAddr = CBitcoinAddress(CScriptID(redeemScript)).ToString();
|
||||
std::string strAddr = EncodeDestination(CScriptID(redeemScript));
|
||||
LogPrintf("%s: Warning: This wallet contains a redeemScript of size %i which exceeds maximum size %i thus can never be redeemed. Do not use address %s.\n",
|
||||
__func__, redeemScript.size(), MAX_SCRIPT_ELEMENT_SIZE, strAddr);
|
||||
return true;
|
||||
@@ -3072,9 +3072,9 @@ bool CWallet::SetAddressBook(const CTxDestination& address, const std::string& s
|
||||
}
|
||||
NotifyAddressBookChanged(this, address, strName, ::IsMine(*this, address) != ISMINE_NO,
|
||||
strPurpose, (fUpdated ? CT_UPDATED : CT_NEW) );
|
||||
if (!strPurpose.empty() && !CWalletDB(*dbw).WritePurpose(CBitcoinAddress(address).ToString(), strPurpose))
|
||||
if (!strPurpose.empty() && !CWalletDB(*dbw).WritePurpose(EncodeDestination(address), strPurpose))
|
||||
return false;
|
||||
return CWalletDB(*dbw).WriteName(CBitcoinAddress(address).ToString(), strName);
|
||||
return CWalletDB(*dbw).WriteName(EncodeDestination(address), strName);
|
||||
}
|
||||
|
||||
bool CWallet::DelAddressBook(const CTxDestination& address)
|
||||
@@ -3083,7 +3083,7 @@ bool CWallet::DelAddressBook(const CTxDestination& address)
|
||||
LOCK(cs_wallet); // mapAddressBook
|
||||
|
||||
// Delete destdata tuples associated with address
|
||||
std::string strAddress = CBitcoinAddress(address).ToString();
|
||||
std::string strAddress = EncodeDestination(address);
|
||||
for (const std::pair<std::string, std::string> &item : mapAddressBook[address].destdata)
|
||||
{
|
||||
CWalletDB(*dbw).EraseDestData(strAddress, item.first);
|
||||
@@ -3093,8 +3093,8 @@ bool CWallet::DelAddressBook(const CTxDestination& address)
|
||||
|
||||
NotifyAddressBookChanged(this, address, "", ::IsMine(*this, address) != ISMINE_NO, "", CT_DELETED);
|
||||
|
||||
CWalletDB(*dbw).ErasePurpose(CBitcoinAddress(address).ToString());
|
||||
return CWalletDB(*dbw).EraseName(CBitcoinAddress(address).ToString());
|
||||
CWalletDB(*dbw).ErasePurpose(EncodeDestination(address));
|
||||
return CWalletDB(*dbw).EraseName(EncodeDestination(address));
|
||||
}
|
||||
|
||||
const std::string& CWallet::GetAccountName(const CScript& scriptPubKey) const
|
||||
@@ -3711,14 +3711,14 @@ bool CWallet::AddDestData(const CTxDestination &dest, const std::string &key, co
|
||||
return false;
|
||||
|
||||
mapAddressBook[dest].destdata.insert(std::make_pair(key, value));
|
||||
return CWalletDB(*dbw).WriteDestData(CBitcoinAddress(dest).ToString(), key, value);
|
||||
return CWalletDB(*dbw).WriteDestData(EncodeDestination(dest), key, value);
|
||||
}
|
||||
|
||||
bool CWallet::EraseDestData(const CTxDestination &dest, const std::string &key)
|
||||
{
|
||||
if (!mapAddressBook[dest].destdata.erase(key))
|
||||
return false;
|
||||
return CWalletDB(*dbw).EraseDestData(CBitcoinAddress(dest).ToString(), key);
|
||||
return CWalletDB(*dbw).EraseDestData(EncodeDestination(dest), key);
|
||||
}
|
||||
|
||||
bool CWallet::LoadDestData(const CTxDestination &dest, const std::string &key, const std::string &value)
|
||||
|
||||
Reference in New Issue
Block a user