59    if (strPurpose == 
"send")
 
   61    else if (strPurpose == 
"receive")
 
   63    else if (strPurpose == 
"unknown" || strPurpose == 
"") 
 
   82            for (
const auto& address : 
wallet.getAddresses())
 
   84                if (pk_hash_only && !std::holds_alternative<PKHash>(address.dest)) {
 
   88                        QString::fromStdString(address.purpose), address.is_mine);
 
   90                                  QString::fromStdString(address.name),
 
  100    void updateEntry(
const QString &address, 
const QString &label, 
bool isMine, 
const QString &purpose, 
int status)
 
  103        QList<AddressTableEntry>::iterator lower = std::lower_bound(
 
  105        QList<AddressTableEntry>::iterator upper = std::upper_bound(
 
  109        bool inModel = (lower != upper);
 
  117                qWarning() << 
"AddressTablePriv::updateEntry: Warning: Got CT_NEW, but entry is already in model";
 
  120            parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex);
 
  127                qWarning() << 
"AddressTablePriv::updateEntry: Warning: Got CT_UPDATED, but entry is not in model";
 
  130            lower->type = newEntryType;
 
  131            lower->label = label;
 
  137                qWarning() << 
"AddressTablePriv::updateEntry: Warning: Got CT_DELETED, but entry is not in model";
 
  140            parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1);
 
  166    QAbstractTableModel(parent), walletModel(parent)
 
  168    columns << tr(
"Label") << tr(
"Address");
 
  180    if (parent.isValid()) {
 
  188    if (parent.isValid()) {
 
  202    if (role == Qt::DisplayRole || role == Qt::EditRole) {
 
  205            if (rec->
label.isEmpty() && role == Qt::DisplayRole) {
 
  206                return tr(
"(no label)");
 
  214    } 
else if (role == Qt::FontRole) {
 
  245    if(role == Qt::EditRole)
 
  251            if(rec->
label == value.toString())
 
  260            if(std::get_if<CNoDestination>(&newAddress))
 
  266            else if(newAddress == curAddress)
 
  274                    newAddress,  
nullptr,  
nullptr,  
nullptr))
 
  295    if(orientation == Qt::Horizontal)
 
  297        if(role == Qt::DisplayRole && section < 
columns.size())
 
  307    if (!
index.isValid()) 
return Qt::NoItemFlags;
 
  311    Qt::ItemFlags retval = Qt::ItemIsSelectable | Qt::ItemIsEnabled;
 
  317        retval |= Qt::ItemIsEditable;
 
  328        return createIndex(row, column, 
priv->
index(row));
 
  332        return QModelIndex();
 
  337        const QString &label, 
bool isMine, 
const QString &purpose, 
int status)
 
  345    std::string strLabel = label.toStdString();
 
  346    std::string strAddress = address.toStdString();
 
  395    return QString::fromStdString(strAddress);
 
  416        return QString::fromStdString(
name);
 
  425        return QString::fromStdString(purpose);
 
  432        std::string* purpose)
 const {
 
  439    QModelIndexList lst = match(
index(0, 
Address, QModelIndex()),
 
  440                                Qt::EditRole, address, 1, Qt::MatchExactly);
 
  447        return lst.at(0).row();
 
  455    Q_EMIT dataChanged(
index(idx, 0, QModelIndex()), 
index(idx, 
columns.length()-1, QModelIndex()));
 
static AddressTableEntry::Type translateTransactionType(const QString &strPurpose, bool isMine)
Qt model of the address book in the core.
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
@ TypeRole
Type of address (Send or Receive)
int lookupAddress(const QString &address) const
OutputType GetDefaultAddressType() const
@ WALLET_UNLOCK_FAILURE
Wallet could not be unlocked to create new receiving address.
@ NO_CHANGES
No changes were made during edit operation.
@ INVALID_ADDRESS
Unparseable address.
@ KEY_GENERATION_FAILURE
Generating a new public key for a receiving address failed.
@ DUPLICATE_ADDRESS
Address already in address book.
void emitDataChanged(int index)
Notify listeners that data changed.
@ Address
Bitcoin address.
@ Label
User specified label.
QVariant data(const QModelIndex &index, int role) const override
QModelIndex index(int row, int column, const QModelIndex &parent) const override
AddressTableModel(WalletModel *parent=nullptr, bool pk_hash_only=false)
int columnCount(const QModelIndex &parent) const override
bool setData(const QModelIndex &index, const QVariant &value, int role) override
static const QString Send
Specifies send address.
QString addRow(const QString &type, const QString &label, const QString &address, const OutputType address_type)
void updateEntry(const QString &address, const QString &label, bool isMine, const QString &purpose, int status)
friend class AddressTablePriv
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
Qt::ItemFlags flags(const QModelIndex &index) const override
static const QString Receive
Specifies receive address.
int rowCount(const QModelIndex &parent) const override
WalletModel *const walletModel
QString purposeForAddress(const QString &address) const
Look up purpose for address in address book, if not found return empty string.
QString labelForAddress(const QString &address) const
Look up label for address in address book, if not found return empty string.
bool getAddressData(const QString &address, std::string *name, std::string *purpose) const
Look up address book data given an address string.
QList< AddressTableEntry > cachedAddressTable
AddressTablePriv(AddressTableModel *_parent)
void updateEntry(const QString &address, const QString &label, bool isMine, const QString &purpose, int status)
AddressTableEntry * index(int idx)
void refreshAddressTable(interfaces::Wallet &wallet, bool pk_hash_only=false)
AddressTableModel * parent
Interface to Bitcoin wallet from Qt view code.
bool validateAddress(const QString &address)
interfaces::Wallet & wallet() const
UnlockContext requestUnlock()
Interface for accessing a wallet.
virtual bool getNewDestination(const OutputType type, const std::string label, CTxDestination &dest)=0
virtual bool setAddressBook(const CTxDestination &dest, const std::string &name, const std::string &purpose)=0
Add or update address.
virtual OutputType getDefaultAddressType()=0
virtual bool delAddressBook(const CTxDestination &dest)=0
virtual bool getAddress(const CTxDestination &dest, std::string *name, isminetype *is_mine, std::string *purpose)=0
Look up address in wallet, return whether exists.
std::string EncodeDestination(const CTxDestination &dest)
CTxDestination DecodeDestination(const std::string &str, std::string &error_msg)
QFont fixedPitchFont(bool use_embedded_font)
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
AddressTableEntry(Type _type, const QString &_label, const QString &_address)
bool operator()(const AddressTableEntry &a, const AddressTableEntry &b) const
bool operator()(const QString &a, const AddressTableEntry &b) const
bool operator()(const AddressTableEntry &a, const QString &b) const
static secp256k1_context * ctx