81 for (
const auto& address :
wallet.getAddresses())
83 if (pk_hash_only && !std::holds_alternative<PKHash>(address.dest)) {
87 address.purpose, address.is_mine);
89 QString::fromStdString(address.name),
102 QList<AddressTableEntry>::iterator lower = std::lower_bound(
104 QList<AddressTableEntry>::iterator upper = std::upper_bound(
108 bool inModel = (lower != upper);
116 qWarning() <<
"AddressTablePriv::updateEntry: Warning: Got CT_NEW, but entry is already in model";
119 parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex);
126 qWarning() <<
"AddressTablePriv::updateEntry: Warning: Got CT_UPDATED, but entry is not in model";
129 lower->type = newEntryType;
130 lower->label = label;
136 qWarning() <<
"AddressTablePriv::updateEntry: Warning: Got CT_DELETED, but entry is not in model";
139 parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1);
165 QAbstractTableModel(parent), walletModel(parent)
167 columns << tr(
"Label") << tr(
"Address");
179 if (parent.isValid()) {
187 if (parent.isValid()) {
201 if (role == Qt::DisplayRole || role == Qt::EditRole) {
204 if (rec->
label.isEmpty() && role == Qt::DisplayRole) {
205 return tr(
"(no label)");
213 }
else if (role == Qt::FontRole) {
244 if(role == Qt::EditRole)
250 if(rec->
label == value.toString())
259 if(std::get_if<CNoDestination>(&newAddress))
265 else if(newAddress == curAddress)
273 newAddress,
nullptr,
nullptr,
nullptr))
294 if(orientation == Qt::Horizontal)
296 if(role == Qt::DisplayRole && section <
columns.size())
306 if (!
index.isValid())
return Qt::NoItemFlags;
310 Qt::ItemFlags retval = Qt::ItemIsSelectable | Qt::ItemIsEnabled;
316 retval |= Qt::ItemIsEditable;
327 return createIndex(row, column,
priv->
index(row));
331 return QModelIndex();
344 std::string strLabel = label.toStdString();
345 std::string strAddress = address.toStdString();
375 if (!ctx.isValid()) {
392 return QString::fromStdString(strAddress);
413 return QString::fromStdString(
name);
436 QModelIndexList lst = match(
index(0,
Address, QModelIndex()),
437 Qt::EditRole, address, 1, Qt::MatchExactly);
444 return lst.at(0).row();
452 Q_EMIT dataChanged(
index(idx, 0, QModelIndex()),
index(idx,
columns.length()-1, QModelIndex()));
QVariant data(const QModelIndex &index, int role) const override
Generating a new public key for a receiving address failed.
interfaces::Wallet & wallet() const
bool operator()(const QString &a, const AddressTableEntry &b) const
int lookupAddress(const QString &address) const
Never set in current code may be present in older wallet databases.
virtual OutputType getDefaultAddressType()=0
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
AddressTableEntry()=default
constexpr AddressTableEntry::Type translateTransactionType(wallet::AddressPurpose purpose, bool isMine)
UnlockContext requestUnlock()
AddressTableEntry * index(int idx)
Address already in address book.
int rowCount(const QModelIndex &parent) const override
bool validateAddress(const QString &address) const
QFont fixedPitchFont(bool use_embedded_font)
QString addRow(const QString &type, const QString &label, const QString &address, const OutputType address_type)
static const QString Send
Specifies send address.
void updateEntry(const QString &address, const QString &label, bool isMine, wallet::AddressPurpose purpose, int status)
bool operator()(const AddressTableEntry &a, const AddressTableEntry &b) const
int columnCount(const QModelIndex &parent) const override
bool setData(const QModelIndex &index, const QVariant &value, int role) override
AddressPurpose
Address purpose field that has been been stored with wallet sending and receiving addresses since BIP...
Wallet could not be unlocked to create new receiving address.
QList< AddressTableEntry > cachedAddressTable
Qt::ItemFlags flags(const QModelIndex &index) const override
virtual util::Result< CTxDestination > getNewDestination(const OutputType type, const std::string &label)=0
QString labelForAddress(const QString &address) const
Look up label for address in address book, if not found return empty string.
Interface for accessing a wallet.
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
AddressTableModel * parent
WalletModel *const walletModel
std::optional< wallet::AddressPurpose > purposeForAddress(const QString &address) const
Look up purpose for address in address book, if not found return empty string.
Qt model of the address book in the core.
void updateEntry(const QString &address, const QString &label, bool isMine, wallet::AddressPurpose purpose, int status)
AddressTablePriv(AddressTableModel *_parent)
AddressTableEntry(Type _type, const QString &_label, const QString &_address)
OutputType GetDefaultAddressType() const
std::variant< CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script categorized into standard templates.
QString GetWalletDisplayName() const
bool operator()(const AddressTableEntry &a, const QString &b) const
virtual bool delAddressBook(const CTxDestination &dest)=0
Interface to Bitcoin wallet from Qt view code.
static const QString Receive
Specifies receive address.
void emitDataChanged(int index)
Notify listeners that data changed.
bool getAddressData(const QString &address, std::string *name, wallet::AddressPurpose *purpose) const
Look up address book data given an address string.
void refreshAddressTable(interfaces::Wallet &wallet, bool pk_hash_only=false)
std::string EncodeDestination(const CTxDestination &dest)
QString getDisplayName() const
virtual bool setAddressBook(const CTxDestination &dest, const std::string &name, const std::optional< wallet::AddressPurpose > &purpose)=0
Add or update address.
No changes were made during edit operation.
CTxDestination DecodeDestination(const std::string &str, std::string &error_msg, std::vector< int > *error_locations)
friend class AddressTablePriv
QModelIndex index(int row, int column, const QModelIndex &parent) const override
virtual bool getAddress(const CTxDestination &dest, std::string *name, wallet::isminetype *is_mine, wallet::AddressPurpose *purpose)=0
Look up address in wallet, return whether exists.
AddressTableModel(WalletModel *parent=nullptr, bool pk_hash_only=false)
Type of address (Send or Receive)