58 if (strPurpose ==
"send")
60 else if (strPurpose ==
"receive")
62 else if (strPurpose ==
"unknown" || strPurpose ==
"")
84 QString::fromStdString(address.purpose), address.is_mine);
86 QString::fromStdString(address.name),
96 void updateEntry(
const QString &address,
const QString &label,
bool isMine,
const QString &purpose,
int status)
99 QList<AddressTableEntry>::iterator lower = qLowerBound(
101 QList<AddressTableEntry>::iterator upper = qUpperBound(
105 bool inModel = (lower != upper);
113 qWarning() <<
"AddressTablePriv::updateEntry: Warning: Got CT_NEW, but entry is already in model";
116 parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex);
123 qWarning() <<
"AddressTablePriv::updateEntry: Warning: Got CT_UPDATED, but entry is not in model";
126 lower->type = newEntryType;
127 lower->label = label;
133 qWarning() <<
"AddressTablePriv::updateEntry: Warning: Got CT_DELETED, but entry is not in model";
136 parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1);
162 QAbstractTableModel(parent), walletModel(parent)
164 columns << tr(
"Label") << tr(
"Address");
193 if(role == Qt::DisplayRole || role == Qt::EditRole)
195 switch(
index.column())
198 if(rec->
label.isEmpty() && role == Qt::DisplayRole)
200 return tr(
"(no label)");
210 else if (role == Qt::FontRole)
241 if(role == Qt::EditRole)
247 if(rec->
label == value.toString())
256 if(boost::get<CNoDestination>(&newAddress))
262 else if(newAddress == curAddress)
270 newAddress,
nullptr,
nullptr,
nullptr))
291 if(orientation == Qt::Horizontal)
293 if(role == Qt::DisplayRole && section <
columns.size())
307 Qt::ItemFlags retval = Qt::ItemIsSelectable | Qt::ItemIsEnabled;
313 retval |= Qt::ItemIsEditable;
324 return createIndex(row, column,
priv->
index(row));
328 return QModelIndex();
333 const QString &label,
bool isMine,
const QString &purpose,
int status)
341 std::string strLabel = label.toStdString();
342 std::string strAddress = address.toStdString();
392 (type ==
Send ?
"send" :
"receive"));
393 return QString::fromStdString(strAddress);
414 return QString::fromStdString(
name);
423 return QString::fromStdString(purpose);
430 std::string* purpose)
const {
437 QModelIndexList lst = match(
index(0,
Address, QModelIndex()),
438 Qt::EditRole, address, 1, Qt::MatchExactly);
445 return lst.at(0).row();
453 Q_EMIT dataChanged(
index(idx, 0, QModelIndex()),
index(idx,
columns.length()-1, QModelIndex()));
virtual bool getAddress(const CTxDestination &dest, std::string *name, isminetype *is_mine, std::string *purpose)=0
Look up address in wallet, return whether exists.
Generating a new public key for a receiving address failed.
void refreshAddressTable(interfaces::Wallet &wallet)
interfaces::Wallet & wallet() const
bool operator()(const QString &a, const AddressTableEntry &b) const
bool getAddressData(const QString &address, std::string *name, std::string *purpose) const
Look up address book data given an address string.
QModelIndex index(int row, int column, const QModelIndex &parent) const
int lookupAddress(const QString &address) const
Qt::ItemFlags flags(const QModelIndex &index) const
virtual OutputType getDefaultAddressType()=0
UnlockContext requestUnlock()
AddressTableEntry * index(int idx)
Address already in address book.
QVariant headerData(int section, Qt::Orientation orientation, int role) const
QString purposeForAddress(const QString &address) const
Look up purpose for address in address book, if not found return empty string.
QString addRow(const QString &type, const QString &label, const QString &address, const OutputType address_type)
static const QString Send
Specifies send address.
int rowCount(const QModelIndex &parent) const
int columnCount(const QModelIndex &parent) const
bool operator()(const AddressTableEntry &a, const AddressTableEntry &b) const
virtual bool getKeyFromPool(bool internal, CPubKey &pub_key)=0
Wallet could not be unlocked to create new receiving address.
QList< AddressTableEntry > cachedAddressTable
boost::variant< CNoDestination, CKeyID, CScriptID, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
An encapsulated public key.
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.
AddressTableModel * parent
WalletModel *const walletModel
Qt model of the address book in the core.
AddressTablePriv(AddressTableModel *_parent)
AddressTableEntry(Type _type, const QString &_label, const QString &_address)
OutputType GetDefaultAddressType() const
bool validateAddress(const QString &address)
CTxDestination DecodeDestination(const std::string &str)
virtual void learnRelatedScripts(const CPubKey &key, OutputType type)=0
Add scripts to key store so old so software versions opening the wallet database can detect payments ...
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex())
bool operator()(const AddressTableEntry &a, const QString &b) const
virtual bool delAddressBook(const CTxDestination &dest)=0
Interface to Bitcoin wallet from Qt view code.
void updateEntry(const QString &address, const QString &label, bool isMine, const QString &purpose, int status)
static const QString Receive
Specifies receive address.
void emitDataChanged(int index)
Notify listeners that data changed.
QVariant data(const QModelIndex &index, int role) const
virtual bool setAddressBook(const CTxDestination &dest, const std::string &name, const std::string &purpose)=0
Add or update address.
CTxDestination GetDestinationForKey(const CPubKey &key, OutputType type)
Get a destination of the requested type (if possible) to the specified key.
AddressTableModel(WalletModel *parent=0)
std::string EncodeDestination(const CTxDestination &dest)
bool setData(const QModelIndex &index, const QVariant &value, int role)
No changes were made during edit operation.
friend class AddressTablePriv
void updateEntry(const QString &address, const QString &label, bool isMine, const QString &purpose, int status)
Type of address (Send or Receive)
virtual std::vector< WalletAddress > getAddresses()=0
Get wallet address list.