mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 22:50:59 +01: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:
@@ -82,14 +82,14 @@ public:
|
||||
LOCK(wallet->cs_wallet);
|
||||
for (const std::pair<CTxDestination, CAddressBookData>& item : wallet->mapAddressBook)
|
||||
{
|
||||
const CBitcoinAddress& address = item.first;
|
||||
bool fMine = IsMine(*wallet, address.Get());
|
||||
const CTxDestination& address = item.first;
|
||||
bool fMine = IsMine(*wallet, address);
|
||||
AddressTableEntry::Type addressType = translateTransactionType(
|
||||
QString::fromStdString(item.second.purpose), fMine);
|
||||
const std::string& strName = item.second.name;
|
||||
cachedAddressTable.append(AddressTableEntry(addressType,
|
||||
QString::fromStdString(strName),
|
||||
QString::fromStdString(address.ToString())));
|
||||
QString::fromStdString(EncodeDestination(address))));
|
||||
}
|
||||
}
|
||||
// qLowerBound() and qUpperBound() require our cachedAddressTable list to be sorted in asc order
|
||||
@@ -246,7 +246,7 @@ bool AddressTableModel::setData(const QModelIndex &index, const QVariant &value,
|
||||
if(role == Qt::EditRole)
|
||||
{
|
||||
LOCK(wallet->cs_wallet); /* For SetAddressBook / DelAddressBook */
|
||||
CTxDestination curAddress = CBitcoinAddress(rec->address.toStdString()).Get();
|
||||
CTxDestination curAddress = DecodeDestination(rec->address.toStdString());
|
||||
if(index.column() == Label)
|
||||
{
|
||||
// Do nothing, if old label == new label
|
||||
@@ -257,7 +257,7 @@ bool AddressTableModel::setData(const QModelIndex &index, const QVariant &value,
|
||||
}
|
||||
wallet->SetAddressBook(curAddress, value.toString().toStdString(), strPurpose);
|
||||
} else if(index.column() == Address) {
|
||||
CTxDestination newAddress = CBitcoinAddress(value.toString().toStdString()).Get();
|
||||
CTxDestination newAddress = DecodeDestination(value.toString().toStdString());
|
||||
// Refuse to set invalid address, set error status and return false
|
||||
if(boost::get<CNoDestination>(&newAddress))
|
||||
{
|
||||
@@ -358,7 +358,7 @@ QString AddressTableModel::addRow(const QString &type, const QString &label, con
|
||||
// Check for duplicate addresses
|
||||
{
|
||||
LOCK(wallet->cs_wallet);
|
||||
if(wallet->mapAddressBook.count(CBitcoinAddress(strAddress).Get()))
|
||||
if(wallet->mapAddressBook.count(DecodeDestination(strAddress)))
|
||||
{
|
||||
editStatus = DUPLICATE_ADDRESS;
|
||||
return QString();
|
||||
@@ -384,7 +384,7 @@ QString AddressTableModel::addRow(const QString &type, const QString &label, con
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
strAddress = CBitcoinAddress(newKey.GetID()).ToString();
|
||||
strAddress = EncodeDestination(newKey.GetID());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -394,7 +394,7 @@ QString AddressTableModel::addRow(const QString &type, const QString &label, con
|
||||
// Add entry
|
||||
{
|
||||
LOCK(wallet->cs_wallet);
|
||||
wallet->SetAddressBook(CBitcoinAddress(strAddress).Get(), strLabel,
|
||||
wallet->SetAddressBook(DecodeDestination(strAddress), strLabel,
|
||||
(type == Send ? "send" : "receive"));
|
||||
}
|
||||
return QString::fromStdString(strAddress);
|
||||
@@ -412,7 +412,7 @@ bool AddressTableModel::removeRows(int row, int count, const QModelIndex &parent
|
||||
}
|
||||
{
|
||||
LOCK(wallet->cs_wallet);
|
||||
wallet->DelAddressBook(CBitcoinAddress(rec->address.toStdString()).Get());
|
||||
wallet->DelAddressBook(DecodeDestination(rec->address.toStdString()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -423,8 +423,8 @@ QString AddressTableModel::labelForAddress(const QString &address) const
|
||||
{
|
||||
{
|
||||
LOCK(wallet->cs_wallet);
|
||||
CBitcoinAddress address_parsed(address.toStdString());
|
||||
std::map<CTxDestination, CAddressBookData>::iterator mi = wallet->mapAddressBook.find(address_parsed.Get());
|
||||
CTxDestination destination = DecodeDestination(address.toStdString());
|
||||
std::map<CTxDestination, CAddressBookData>::iterator mi = wallet->mapAddressBook.find(destination);
|
||||
if (mi != wallet->mapAddressBook.end())
|
||||
{
|
||||
return QString::fromStdString(mi->second.name);
|
||||
|
||||
Reference in New Issue
Block a user