mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 14:38:29 +01:00
[qt] Display more helpful message when adding a send address has failed
Addresses #12796. When we're unable to add a sending address to the address book because it already exists as a receiving address, display a message indicating as much. This should help avoid confusion about an address supposedly already in the book but which isn't currently visible in the interface.
This commit is contained in:
@@ -407,21 +407,31 @@ bool AddressTableModel::removeRows(int row, int count, const QModelIndex &parent
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Look up label for address in address book, if not found return empty string.
|
||||
*/
|
||||
QString AddressTableModel::labelForAddress(const QString &address) const
|
||||
{
|
||||
{
|
||||
CTxDestination destination = DecodeDestination(address.toStdString());
|
||||
std::string name;
|
||||
if (walletModel->wallet().getAddress(destination, &name))
|
||||
{
|
||||
return QString::fromStdString(name);
|
||||
}
|
||||
std::string name;
|
||||
if (getAddressData(address, &name, /* purpose= */ nullptr)) {
|
||||
return QString::fromStdString(name);
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString AddressTableModel::purposeForAddress(const QString &address) const
|
||||
{
|
||||
std::string purpose;
|
||||
if (getAddressData(address, /* name= */ nullptr, &purpose)) {
|
||||
return QString::fromStdString(purpose);
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool AddressTableModel::getAddressData(const QString &address,
|
||||
std::string* name,
|
||||
std::string* purpose) const {
|
||||
CTxDestination destination = DecodeDestination(address.toStdString());
|
||||
return walletModel->wallet().getAddress(destination, name, /* is_mine= */ nullptr, purpose);
|
||||
}
|
||||
|
||||
int AddressTableModel::lookupAddress(const QString &address) const
|
||||
{
|
||||
QModelIndexList lst = match(index(0, Address, QModelIndex()),
|
||||
|
||||
Reference in New Issue
Block a user