43 return a.address <
b.address;
81 for (
const auto &address :
wallet.getAddresses()) {
83 QString::fromStdString(address.purpose), address.is_mine);
98 const QString &purpose,
int status) {
100 QList<AddressTableEntry>::iterator
lower = std::lower_bound(
103 QList<AddressTableEntry>::iterator
upper = std::upper_bound(
115 qWarning() <<
"AddressTablePriv::updateEntry: Warning: Got "
116 "CT_NEW, but entry is already in model";
127 qWarning() <<
"AddressTablePriv::updateEntry: Warning: Got "
128 "CT_UPDATED, but entry is not in model";
132 lower->label = label;
137 qWarning() <<
"AddressTablePriv::updateEntry: Warning: Got "
138 "CT_DELETED, but entry is not in model";
161 : QAbstractTableModel(parent), walletModel(parent) {
182 if (!
index.isValid()) {
189 if (role == Qt::DisplayRole || role == Qt::EditRole) {
190 switch (
index.column()) {
192 if (
rec->label.isEmpty() && role == Qt::DisplayRole) {
193 return tr(
"(no label)");
200 }
else if (role == Qt::FontRole) {
221 if (!
index.isValid()) {
230 if (role == Qt::EditRole) {
235 if (
rec->label == value.toString()) {
245 if (std::get_if<CNoDestination>(&
newAddress)) {
288 if (!
index.isValid()) {
289 return Qt::NoItemFlags;
294 Qt::ItemFlags
retval = Qt::ItemIsSelectable | Qt::ItemIsEnabled;
300 retval |= Qt::ItemIsEditable;
318 const QString &purpose,
int status) {
326 std::string
strLabel = label.toStdString();
327 std::string
strAddress = address.toStdString();
354 if (!
ctx.isValid()) {
390 return QString::fromStdString(
name);
398 return QString::fromStdString(purpose);
405 std::string *purpose)
const {
414 address, 1, Qt::MatchExactly);
418 return lst.at(0).row();
static AddressTableEntry::Type translateTransactionType(const QString &strPurpose, bool isMine)
std::string EncodeCashAddr(const CTxDestination &dst, const CChainParams ¶ms)
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
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
AddressTableModel(WalletModel *parent=nullptr)
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)
AddressTableModel * parent
Interface to Bitcoin wallet from Qt view code.
bool validateAddress(const QString &address)
const CChainParams & getChainParams() const
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.
CTxDestination DecodeDestination(const std::string &addr, const CChainParams ¶ms)
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
std::variant< CNoDestination, PKHash, ScriptHash > 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