Add CashAddr Address Format
Ported from Bitcoin Unlimited, Bitcoin ABC
This commit is contained in:
@@ -5,12 +5,12 @@
|
||||
|
||||
#include "wallet/wallet.h"
|
||||
|
||||
#include "base58.h"
|
||||
#include "checkpoints.h"
|
||||
#include "chain.h"
|
||||
#include "checkpoints.h"
|
||||
#include "coincontrol.h"
|
||||
#include "consensus/consensus.h"
|
||||
#include "consensus/validation.h"
|
||||
#include "dstencode.h"
|
||||
#include "key.h"
|
||||
#include "keystore.h"
|
||||
#include "main.h"
|
||||
@@ -233,16 +233,19 @@ bool CWallet::AddCScript(const CScript& redeemScript)
|
||||
return CWalletDB(strWalletFile).WriteCScript(Hash160(redeemScript), redeemScript);
|
||||
}
|
||||
|
||||
bool CWallet::LoadCScript(const CScript& redeemScript)
|
||||
{
|
||||
/* A sanity check was added in pull #3843 to avoid adding redeemScripts
|
||||
* that never can be redeemed. However, old wallets may still contain
|
||||
* these. Do not add them to the wallet and warn. */
|
||||
if (redeemScript.size() > MAX_SCRIPT_ELEMENT_SIZE)
|
||||
{
|
||||
std::string strAddr = CBitcoinAddress(CScriptID(redeemScript)).ToString();
|
||||
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);
|
||||
bool CWallet::LoadCScript(const CScript &redeemScript) {
|
||||
/**
|
||||
* A sanity check was added in pull #3843 to avoid adding redeemScripts that
|
||||
* never can be redeemed. However, old wallets may still contain these. Do
|
||||
* not add them to the wallet and warn.
|
||||
*/
|
||||
if (redeemScript.size() > MAX_SCRIPT_ELEMENT_SIZE) {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -1467,6 +1470,11 @@ CAmount CWallet::GetDebit(const CTxIn &txin, const isminefilter& filter) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
isminetype CWallet::IsMine(const CTxDestination &dest) const
|
||||
{
|
||||
return ::IsMine(*this, dest);
|
||||
}
|
||||
|
||||
isminetype CWallet::IsMine(const CTxOut& txout) const
|
||||
{
|
||||
return ::IsMine(*this, txout.scriptPubKey);
|
||||
@@ -3028,9 +3036,13 @@ bool CWallet::SetAddressBook(const CTxDestination& address, const string& strNam
|
||||
strPurpose, (fUpdated ? CT_UPDATED : CT_NEW) );
|
||||
if (!fFileBacked)
|
||||
return false;
|
||||
if (!strPurpose.empty() && !CWalletDB(strWalletFile).WritePurpose(CBitcoinAddress(address).ToString(), strPurpose))
|
||||
|
||||
if (!strPurpose.empty() && !CWalletDB(strWalletFile).WritePurpose(address, strPurpose))
|
||||
{
|
||||
return false;
|
||||
return CWalletDB(strWalletFile).WriteName(CBitcoinAddress(address).ToString(), strName);
|
||||
}
|
||||
|
||||
return CWalletDB(strWalletFile).WriteName(address, strName);
|
||||
}
|
||||
|
||||
bool CWallet::DelAddressBook(const CTxDestination& address)
|
||||
@@ -3038,13 +3050,11 @@ bool CWallet::DelAddressBook(const CTxDestination& address)
|
||||
{
|
||||
LOCK(cs_wallet); // mapAddressBook
|
||||
|
||||
if(fFileBacked)
|
||||
{
|
||||
// Delete destdata tuples associated with address
|
||||
std::string strAddress = CBitcoinAddress(address).ToString();
|
||||
BOOST_FOREACH(const PAIRTYPE(string, string) &item, mapAddressBook[address].destdata)
|
||||
{
|
||||
CWalletDB(strWalletFile).EraseDestData(strAddress, item.first);
|
||||
if (fFileBacked) {
|
||||
// Delete destdata tuples associated with address.
|
||||
for (const std::pair<std::string, std::string> &item :
|
||||
mapAddressBook[address].destdata) {
|
||||
CWalletDB(strWalletFile).EraseDestData(address, item.first);
|
||||
}
|
||||
}
|
||||
mapAddressBook.erase(address);
|
||||
@@ -3054,8 +3064,9 @@ bool CWallet::DelAddressBook(const CTxDestination& address)
|
||||
|
||||
if (!fFileBacked)
|
||||
return false;
|
||||
CWalletDB(strWalletFile).ErasePurpose(CBitcoinAddress(address).ToString());
|
||||
return CWalletDB(strWalletFile).EraseName(CBitcoinAddress(address).ToString());
|
||||
|
||||
CWalletDB(strWalletFile).ErasePurpose(address);
|
||||
return CWalletDB(strWalletFile).EraseName(address);
|
||||
}
|
||||
|
||||
bool CWallet::SetDefaultKey(const CPubKey &vchPubKey)
|
||||
@@ -3645,7 +3656,8 @@ bool CWallet::AddDestData(const CTxDestination &dest, const std::string &key, co
|
||||
mapAddressBook[dest].destdata.insert(std::make_pair(key, value));
|
||||
if (!fFileBacked)
|
||||
return true;
|
||||
return CWalletDB(strWalletFile).WriteDestData(CBitcoinAddress(dest).ToString(), key, value);
|
||||
|
||||
return CWalletDB(strWalletFile).WriteDestData(dest, key, value);
|
||||
}
|
||||
|
||||
bool CWallet::EraseDestData(const CTxDestination &dest, const std::string &key)
|
||||
@@ -3654,7 +3666,8 @@ bool CWallet::EraseDestData(const CTxDestination &dest, const std::string &key)
|
||||
return false;
|
||||
if (!fFileBacked)
|
||||
return true;
|
||||
return CWalletDB(strWalletFile).EraseDestData(CBitcoinAddress(dest).ToString(), key);
|
||||
|
||||
return CWalletDB(strWalletFile).EraseDestData(dest, key);
|
||||
}
|
||||
|
||||
bool CWallet::LoadDestData(const CTxDestination &dest, const std::string &key, const std::string &value)
|
||||
|
||||
Reference in New Issue
Block a user