15 QObject *parent) : QAbstractTableModel(parent), model(_model), tableModel(_tableModel), addressTableModel(_addressTableModel), cachedAmount(0){
21 QMetaObject::invokeMethod(
this,
"emitDataSetChanged", Qt::QueuedConnection);
34 std::vector<COutput> utxoList;
37 if (!utxoList.empty()) {
39 for (
const auto& utxo : utxoList) {
41 const auto *wtx = utxo.tx;
42 const QString txId = QString::fromStdString(wtx->GetHash().GetHex());
43 const CTxOut& out = wtx->tx->vout[utxo.i];
78 std::vector<CTxDestination> addresses;
82 return error(
"%s : Error extracting P2CS destinations for utxo: %s-%d",
83 __func__, txId.toStdString(), utxoIndex);
116 if (!index.isValid())
119 int row = index.row();
121 if (role == Qt::DisplayRole || role == Qt::EditRole) {
122 switch (index.column()) {
149 QString address = modelIndex.data(Qt::DisplayRole).toString();
151 return error(
"trying to whitelist already whitelisted address");
157 const int idx = modelIndex.row();
166 QString address = modelIndex.data(Qt::DisplayRole).toString();
168 return error(
"trying to blacklist already blacklisted address");
174 const int idx = modelIndex.row();
183 beginRemoveRows(QModelIndex(), idx, idx);
185 Q_EMIT dataChanged(index(idx, 0, QModelIndex()), index(idx,
COLUMN_COUNT, QModelIndex()) );
Qt model of the address book in the core.
std::string purposeForAddress(const std::string &address) const
bool isWhitelisted(const std::string &address) const
Checks if the address is whitelisted.
QString labelForAddress(const QString &address) const
std::string stakingAddress
QMap< QString, int > delegatedUtxo
Map of txId --> index num for stakeable utxo delegations.
CAmount cachedTotalAmount
An output of a transaction.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
int rowCount(const QModelIndex &parent=QModelIndex()) const override
QList< CSDelegation > cachedDelegations
List with all of the grouped delegations received by this wallet.
bool whitelist(const QModelIndex &modelIndex)
void removeRowAndEmitDataChanged(const int idx)
bool blacklist(const QModelIndex &index)
void emitDataSetChanged()
bool parseCSDelegation(const CTxOut &out, CSDelegation &ret, const QString &txId, const int utxoIndex)
ColdStakingModel(WalletModel *model, TransactionTableModel *_tableModel, AddressTableModel *_addressTableModel, QObject *parent=nullptr)
@ TOTAL_STACKEABLE_AMOUNT_STR
@ TOTAL_STACKEABLE_AMOUNT
int columnCount(const QModelIndex &parent=QModelIndex()) const override
AddressTableModel * addressTableModel
UI model for the transaction table of a wallet.
Interface to PIVX wallet from Qt view code.
void getAvailableP2CSCoins(std::vector< COutput > &vCoins) const
bool blacklistAddressFromColdStaking(const QString &address)
bool whitelistAddressFromColdStaking(const QString &addressStr)
const std::string DELEGATOR
QString formatBalance(CAmount amount, int nDisplayUnit, bool isZpiv)
std::string EncodeDestination(const CWDestination &address, const CChainParams::Base58Type addrType)
bool ExtractDestinations(const CScript &scriptPubKey, txnouttype &typeRet, std::vector< CTxDestination > &addressRet, int &nRequiredRet)
Parse a standard scriptPubKey with one or more destination addresses.
bool error(const char *fmt, const Args &... args)