 |
Bitcoin Core
22.99.0
P2P Digital Currency
|
Go to the documentation of this file.
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()));
Interface to Bitcoin wallet from Qt view code.
AddressTablePriv(AddressTableModel *_parent)
WalletModel *const walletModel
AddressTableModel(WalletModel *parent=nullptr, bool pk_hash_only=false)
Qt model of the address book in the core.
QString labelForAddress(const QString &address) const
Look up label for address in address book, if not found return empty string.
@ KEY_GENERATION_FAILURE
Generating a new public key for a receiving address failed.
static const QString Receive
Specifies receive address.
QVariant data(const QModelIndex &index, int role) const override
UnlockContext requestUnlock()
bool operator()(const AddressTableEntry &a, const QString &b) const
void emitDataChanged(int index)
Notify listeners that data changed.
bool operator()(const AddressTableEntry &a, const AddressTableEntry &b) const
interfaces::Wallet & wallet() const
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
bool validateAddress(const QString &address)
QString addRow(const QString &type, const QString &label, const QString &address, const OutputType address_type)
AddressTableEntry * index(int idx)
virtual bool getAddress(const CTxDestination &dest, std::string *name, wallet::isminetype *is_mine, std::string *purpose)=0
Look up address in wallet, return whether exists.
QModelIndex index(int row, int column, const QModelIndex &parent) const override
int rowCount(const QModelIndex &parent) const override
Qt::ItemFlags flags(const QModelIndex &index) const override
@ Label
User specified label.
virtual bool delAddressBook(const CTxDestination &dest)=0
Interface for accessing a wallet.
int columnCount(const QModelIndex &parent) const override
virtual bool getNewDestination(const OutputType type, const std::string label, CTxDestination &dest)=0
bool setData(const QModelIndex &index, const QVariant &value, int role) override
QFont fixedPitchFont(bool use_embedded_font)
int lookupAddress(const QString &address) const
AddressTableEntry(Type _type, const QString &_label, const QString &_address)
virtual OutputType getDefaultAddressType()=0
@ WALLET_UNLOCK_FAILURE
Wallet could not be unlocked to create new receiving address.
@ TypeRole
Type of address (Send or Receive)
QList< AddressTableEntry > cachedAddressTable
void refreshAddressTable(interfaces::Wallet &wallet, bool pk_hash_only=false)
CTxDestination DecodeDestination(const std::string &str, std::string &error_msg, std::vector< int > *error_locations)
@ INVALID_ADDRESS
Unparseable address.
@ NO_CHANGES
No changes were made during edit operation.
static const QString Send
Specifies send address.
void updateEntry(const QString &address, const QString &label, bool isMine, const QString &purpose, int status)
virtual bool setAddressBook(const CTxDestination &dest, const std::string &name, const std::string &purpose)=0
Add or update address.
void updateEntry(const QString &address, const QString &label, bool isMine, const QString &purpose, int status)
AddressTableModel * parent
OutputType GetDefaultAddressType() const
bool getAddressData(const QString &address, std::string *name, std::string *purpose) const
Look up address book data given an address string.
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
bool operator()(const QString &a, const AddressTableEntry &b) const
QString purposeForAddress(const QString &address) const
Look up purpose for address in address book, if not found return empty string.
@ DUPLICATE_ADDRESS
Address already in address book.
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
friend class AddressTablePriv
@ Address
Bitcoin address.
std::string EncodeDestination(const CTxDestination &dest)
static secp256k1_context * ctx
static AddressTableEntry::Type translateTransactionType(const QString &strPurpose, bool isMine)