100 else if (strPurpose ==
"unknown" || strPurpose ==
"")
109 return QObject::tr(
"Contact");
111 return QObject::tr(
"Receiving");
113 return QObject::tr(
"Delegator");
115 return QObject::tr(
"Delegable");
117 return QObject::tr(
"Cold Staking");
119 return QObject::tr(
"Cold Staking Contact");
121 return QObject::tr(
"Receiving Shielded");
123 return QObject::tr(
"Contact Shielded");
125 return QObject::tr(
"Hidden");
127 return QObject::tr(
"Unknown");
152 auto addrBookData = it.GetValue();
165 uint creationTime = 0;
166 if (addrBookData.isReceivePurpose() || addrBookData.isShieldedReceivePurpose()) {
171 QString::fromStdString(addrBookData.purpose), fMine);
172 const std::string& strName = addrBookData.name;
177 QString::fromStdString(strName),
207 if (var !=
nullptr) {
208 if (add) (*var)++;
else (*var)--;
212 void updateEntry(
const QString& address,
const QString& label,
bool isMine,
const QString& purpose,
int status)
215 QList<AddressTableEntry>::iterator lower = std::lower_bound(
217 QList<AddressTableEntry>::iterator upper = std::upper_bound(
221 bool inModel = (lower != upper);
227 qWarning() <<
"AddressTablePriv::updateEntry : Warning: Got CT_NEW, but entry is already in model";
230 uint creationTime = 0;
232 std::string stdPurpose = purpose.toStdString();
240 parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex);
247 qWarning() <<
"AddressTablePriv::updateEntry : Warning: Got CT_UPDATED, but entry is not in model";
250 lower->type = newEntryType;
251 lower->label = label;
257 qWarning() <<
"AddressTablePriv::updateEntry : Warning: Got CT_DELETED, but entry is not in model";
260 parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex - 1);
269 void updateEntry(
const QString &pubCoin,
const QString &isUsed,
int status)
272 QList<AddressTableEntry>::iterator lower = std::lower_bound(
274 QList<AddressTableEntry>::iterator upper = std::upper_bound(
277 bool inModel = (lower != upper);
284 qWarning() <<
"AddressTablePriv_ZC::updateEntry : Warning: Got CT_NEW, but entry is already in model";
286 parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex);
292 qWarning() <<
"AddressTablePriv_ZC::updateEntry : Warning: Got CT_UPDATED, but entry is not in model";
295 lower->type = newEntryType;
296 lower->label = isUsed;
322 columns << tr(
"Label") << tr(
"Address") << tr(
"Date") << tr(
"Type");
353 if (!
index.isValid())
358 if (role == Qt::DisplayRole || role == Qt::EditRole) {
359 switch (
index.column()) {
361 if (rec->
label.isEmpty() && role == Qt::DisplayRole) {
362 return tr(
"(no label)");
371 return translateTypeToString(rec->
type);
373 }
else if (role == Qt::FontRole) {
406 if (!
index.isValid())
414 if (role == Qt::EditRole) {
419 if (rec->
label == value.toString()) {
432 else if (newAddress == curAddress) {
457 if (orientation == Qt::Horizontal) {
458 if (role == Qt::DisplayRole && section <
columns.size()) {
467 if (!
index.isValid())
468 return Qt::NoItemFlags;
471 Qt::ItemFlags retval = Qt::ItemIsSelectable | Qt::ItemIsEnabled;
476 retval |= Qt::ItemIsEditable;
486 return createIndex(row, column,
priv->
index(row));
488 return QModelIndex();
493 const QString& label,
495 const QString& purpose,
513 std::string strLabel = label.toStdString();
514 std::string strAddress = address.toStdString();
557 return QString::fromStdString(strAddress);
581 if (!address.isEmpty()) {
597 QModelIndexList lst = match(
index(0,
Address, QModelIndex()),
598 Qt::EditRole, address, 1, Qt::MatchExactly);
602 return lst.at(0).row();
620 const auto addrData = it.GetValue();
624 const auto &address = *it.GetCTxDestKey();
631 const auto &address = *it.GetShieldedDestKey();
642 return (res) ? QString::fromStdString(res.
getObjResult()->ToString()) :
"";;
647 Q_EMIT dataChanged(
index(idx, 0, QModelIndex()),
index(idx,
columns.length() - 1, QModelIndex()));
652 int idx = _index.row();
bool IsValidPaymentAddress(const libzcash::PaymentAddress &zaddr)
Check whether a PaymentAddress is not an InvalidEncoding.
Qt model of the address book in the core.
@ TypeRole
Type of address (Send, Receive, ColdStaking, ColdStakingSend, Delegator, Delegable)
int lookupAddress(const QString &address) const
int columnCount(const QModelIndex &parent) const
static const QString Delegator
Specifies cold staking addresses which delegated tokens to this wallet and ARE being staked.
AddressTableModel(CWallet *wallet, WalletModel *parent=0)
QVariant headerData(int section, Qt::Orientation orientation, int role) const
static const QString ColdStakingSend
Specifies send cold staking addresses (simil 'contacts')
static const QString ShieldedSend
Specifies shielded receive address.
WalletModel * walletModel
@ WALLET_UNLOCK_FAILURE
Wallet could not be unlocked to create new receiving address.
@ NO_CHANGES
No changes were made during edit operation.
@ INVALID_ADDRESS
Unparsable 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.
@ Date
Address creation date.
std::string purposeForAddress(const std::string &address) const
static const QString ShieldedReceive
Specifies shielded send address.
Qt::ItemFlags flags(const QModelIndex &index) const
bool setData(const QModelIndex &index, const QVariant &value, int role)
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex())
QModelIndex index(int row, int column, const QModelIndex &parent) const
int sizeShieldedSend() const
QVariant data(const QModelIndex &index, int role) const
static const QString Send
Specifies send address.
bool isWhitelisted(const std::string &address) const
Checks if the address is whitelisted.
static const QString Zerocoin
Specifies stealth address.
void updateEntry(const QString &address, const QString &label, bool isMine, const QString &purpose, int status)
friend class AddressTablePriv
QString getAddressToShow(bool shielded=false) const
Return last unused address.
QString addRow(const QString &type, const QString &label, const QString &address)
static const QString Delegable
Specifies cold staking addresses which delegated tokens to this wallet.
void notifyChange(const QModelIndex &index)
static const QString Receive
Specifies receive address.
int rowCount(const QModelIndex &parent) const
static const QString ColdStaking
Specifies cold staking own addresses.
QString labelForAddress(const QString &address) const
void updateEntry(const QString &pubCoin, const QString &isUsed, int status)
QList< AddressTableEntry > cachedAddressTable
void updateEntry(const QString &address, const QString &label, bool isMine, const QString &purpose, int status)
AddressTableModel * parent
AddressTablePriv(CWallet *wallet, AddressTableModel *parent)
void refreshAddressTable()
AddressTableEntry * index(int idx)
void updatePurposeCachedCounted(std::string purpose, bool add)
An encapsulated public key.
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances,...
CAddressBookIterator NewAddressBookIterator()
const Optional< T > & getObjResult() const
Interface to PIVX wallet from Qt view code.
bool validateAddress(const QString &address)
CallResult< Destination > getNewAddress(const std::string &label="") const
CallResult< Destination > getNewShieldedAddress(std::string strLabel="")
Return a new shielded address.
UnlockContext requestUnlock()
boost::variant< CTxDestination, libzcash::SaplingPaymentAddress > CWDestination
bool DelAddressBook(const CWDestination &address, const CChainParams::Base58Type addrType=CChainParams::PUBKEY_ADDRESS)
std::string GetPurposeForAddressBookEntry(const CWDestination &address) const
bool GetKeyFromPool(CPubKey &key, const uint8_t &type=HDChain::ChangeType::EXTERNAL)
std::string GetNameForAddressBookEntry(const CWDestination &address) const
bool HasAddressBook(const CWDestination &address) const
bool SetAddressBook(const CWDestination &address, const std::string &strName, const std::string &purpose)
int64_t GetKeyCreationTime(const CWDestination &dest)
bool IsUsed(const CTxDestination address) const
isminetype IsMine(const CKeyStore &keystore, const CTxDestination &dest)
const std::string DELEGABLE
const std::string COLD_STAKING_SEND
const std::string DELEGATOR
const std::string SHIELDED_RECEIVE
const std::string SHIELDED_SEND
const std::string RECEIVE
const std::string COLD_STAKING
bool IsExchangePurpose(const std::string &purpose)
bool IsColdStakingPurpose(const std::string &purpose)
QFont bitcoinAddressFont()
std::string EncodePaymentAddress(const libzcash::PaymentAddress &zaddr)
bool IsValidDestination(const CWDestination &address)
std::string EncodeDestination(const CWDestination &address, const CChainParams::Base58Type addrType)
CWDestination DecodeDestination(const std::string &strAddress)
boost::variant< CNoDestination, CKeyID, CScriptID, CExchangeKeyID > CTxDestination
A txout script template with a specific destination.
AddressTableEntry(Type _type, const QString &_pubcoin)
AddressTableEntry(Type _type, const QString &_label, const QString &_address, const uint _creationTime)
AddressTableEntry()=delete
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