2020-12-31 18:50:11 +01:00
|
|
|
// Copyright (c) 2011-2020 The Bitcoin Core developers
|
2014-12-13 05:09:33 +01:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2013-11-04 16:20:43 +01:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2020-03-19 23:46:56 +01:00
|
|
|
#include <qt/transactiontablemodel.h>
|
2013-01-23 21:51:02 +01:00
|
|
|
|
2018-08-01 19:38:45 +02:00
|
|
|
#include <qt/clientmodel.h>
|
2020-03-19 23:46:56 +01:00
|
|
|
#include <qt/guiutil.h>
|
|
|
|
#include <qt/optionsmodel.h>
|
|
|
|
#include <qt/transactiondesc.h>
|
|
|
|
#include <qt/transactionrecord.h>
|
|
|
|
#include <qt/walletmodel.h>
|
2011-05-08 16:30:10 +02:00
|
|
|
|
2020-03-19 23:46:56 +01:00
|
|
|
#include <core_io.h>
|
2020-10-01 16:05:57 +02:00
|
|
|
#include <interfaces/handler.h>
|
2020-03-19 23:46:56 +01:00
|
|
|
#include <uint256.h>
|
2021-06-27 08:33:13 +02:00
|
|
|
#include <util/system.h>
|
2011-06-26 19:23:24 +02:00
|
|
|
|
Merge #16674: refactor: remove obsolete qt algorithm usage
153d9dd9acffa95bb97a4b1579bd20237fdc9c52 refactor: replace qLowerBound & qUpperBound with std:: upper_bound & lower_bound (fanquake)
59373e3e94015316bcaa03a7b9c2e6f442641720 refactor: replace qSort with std::sort (fanquake)
fea33cbbdfb4673033f3414bf1613591ff654aac refactor: replace qStableSort with std::stable_sort (fanquake)
Pull request description:
`qStablesort`, `qSort`, `qLowerBound` and `qUpperBound` have been marked as obsolete since at least Qt 5.9: [Obsolete Members for QtAlgorithms](https://doc.qt.io/qt-5.9/qtalgorithms-obsolete.html).
This pull request replaces their usage with the suggested `std::` replacements.
This also removes some warning spam when compiling against newer Qt (5.13.0 via brew):
```bash
CXX qt/libbitcoinqt_a-walletcontroller.o
qt/transactiontablemodel.cpp:96:52: warning: 'qLowerBound<QList<TransactionRecord>::iterator, uint256, TxLessThan>' is deprecated: Use std::lower_bound [-Wdeprecated-declarations]
QList<TransactionRecord>::iterator lower = qLowerBound(
qt/transactiontablemodel.cpp:98:52: warning: 'qUpperBound<QList<TransactionRecord>::iterator, uint256, TxLessThan>' is deprecated: Use std::upper_bound [-Wdeprecated-declarations]
QList<TransactionRecord>::iterator upper = qUpperBound(
```
```bash
CXX qt/libbitcoinqt_a-moc_walletcontroller.o
qt/bantablemodel.cpp:64:13: warning: 'qStableSort<QList<CCombinedBan>::iterator, BannedNodeLessThan>' is deprecated: Use std::stable_sort [-Wdeprecated-declarations]
qStableSort(cachedBanlist.begin(), cachedBanlist.end(), BannedNodeLessThan(sortColumn, sortOrder));
```
```bash
CXX qt/libbitcoinqt_a-sendcoinsentry.o
qt/recentrequeststablemodel.cpp:205:5: warning: 'qSort<QList<RecentRequestEntry>::iterator, RecentRequestEntryLessThan>' is deprecated: Use std::sort [-Wdeprecated-declarations]
qSort(list.begin(), list.end(), RecentRequestEntryLessThan(column, order));
```
ACKs for top commit:
hebasto:
ACK 153d9dd9acffa95bb97a4b1579bd20237fdc9c52
promag:
ACK 153d9dd9acffa95bb97a4b1579bd20237fdc9c52.
jonasschnelli:
utACK 153d9dd9acffa95bb97a4b1579bd20237fdc9c52
Tree-SHA512: 22f7290ed798ce8b0f5f313405377845d4c8e48dc8687be7464e27fff53363b451a40e9e18910a8c3b4b9d4dcc236a366c92e7d171fcb8576c48f149a1886c26
2019-08-22 11:52:34 +02:00
|
|
|
#include <algorithm>
|
2021-01-26 11:14:06 +01:00
|
|
|
#include <functional>
|
Merge #16674: refactor: remove obsolete qt algorithm usage
153d9dd9acffa95bb97a4b1579bd20237fdc9c52 refactor: replace qLowerBound & qUpperBound with std:: upper_bound & lower_bound (fanquake)
59373e3e94015316bcaa03a7b9c2e6f442641720 refactor: replace qSort with std::sort (fanquake)
fea33cbbdfb4673033f3414bf1613591ff654aac refactor: replace qStableSort with std::stable_sort (fanquake)
Pull request description:
`qStablesort`, `qSort`, `qLowerBound` and `qUpperBound` have been marked as obsolete since at least Qt 5.9: [Obsolete Members for QtAlgorithms](https://doc.qt.io/qt-5.9/qtalgorithms-obsolete.html).
This pull request replaces their usage with the suggested `std::` replacements.
This also removes some warning spam when compiling against newer Qt (5.13.0 via brew):
```bash
CXX qt/libbitcoinqt_a-walletcontroller.o
qt/transactiontablemodel.cpp:96:52: warning: 'qLowerBound<QList<TransactionRecord>::iterator, uint256, TxLessThan>' is deprecated: Use std::lower_bound [-Wdeprecated-declarations]
QList<TransactionRecord>::iterator lower = qLowerBound(
qt/transactiontablemodel.cpp:98:52: warning: 'qUpperBound<QList<TransactionRecord>::iterator, uint256, TxLessThan>' is deprecated: Use std::upper_bound [-Wdeprecated-declarations]
QList<TransactionRecord>::iterator upper = qUpperBound(
```
```bash
CXX qt/libbitcoinqt_a-moc_walletcontroller.o
qt/bantablemodel.cpp:64:13: warning: 'qStableSort<QList<CCombinedBan>::iterator, BannedNodeLessThan>' is deprecated: Use std::stable_sort [-Wdeprecated-declarations]
qStableSort(cachedBanlist.begin(), cachedBanlist.end(), BannedNodeLessThan(sortColumn, sortOrder));
```
```bash
CXX qt/libbitcoinqt_a-sendcoinsentry.o
qt/recentrequeststablemodel.cpp:205:5: warning: 'qSort<QList<RecentRequestEntry>::iterator, RecentRequestEntryLessThan>' is deprecated: Use std::sort [-Wdeprecated-declarations]
qSort(list.begin(), list.end(), RecentRequestEntryLessThan(column, order));
```
ACKs for top commit:
hebasto:
ACK 153d9dd9acffa95bb97a4b1579bd20237fdc9c52
promag:
ACK 153d9dd9acffa95bb97a4b1579bd20237fdc9c52.
jonasschnelli:
utACK 153d9dd9acffa95bb97a4b1579bd20237fdc9c52
Tree-SHA512: 22f7290ed798ce8b0f5f313405377845d4c8e48dc8687be7464e27fff53363b451a40e9e18910a8c3b4b9d4dcc236a366c92e7d171fcb8576c48f149a1886c26
2019-08-22 11:52:34 +02:00
|
|
|
|
2011-05-27 19:48:42 +02:00
|
|
|
#include <QColor>
|
2011-06-28 21:41:56 +02:00
|
|
|
#include <QDateTime>
|
2013-09-04 11:52:45 +02:00
|
|
|
#include <QDebug>
|
2013-04-13 07:13:08 +02:00
|
|
|
#include <QIcon>
|
|
|
|
#include <QList>
|
2023-06-28 18:00:18 +02:00
|
|
|
#include <QMessageBox>
|
2011-05-10 19:03:10 +02:00
|
|
|
|
2018-08-25 20:20:30 +02:00
|
|
|
|
2011-08-08 17:38:17 +02:00
|
|
|
// Amount column is right-aligned it contains numbers
|
2011-06-26 22:47:02 +02:00
|
|
|
static int column_alignments[] = {
|
2013-08-29 16:19:43 +02:00
|
|
|
Qt::AlignLeft|Qt::AlignVCenter, /* status */
|
2014-08-10 02:26:04 +02:00
|
|
|
Qt::AlignLeft|Qt::AlignVCenter, /* watchonly */
|
2013-08-29 16:19:43 +02:00
|
|
|
Qt::AlignLeft|Qt::AlignVCenter, /* date */
|
|
|
|
Qt::AlignLeft|Qt::AlignVCenter, /* type */
|
|
|
|
Qt::AlignLeft|Qt::AlignVCenter, /* address */
|
|
|
|
Qt::AlignRight|Qt::AlignVCenter /* amount */
|
2011-06-26 22:47:02 +02:00
|
|
|
};
|
|
|
|
|
2011-06-18 11:53:25 +02:00
|
|
|
// Comparison operator for sort/binary search of model tx list
|
2011-06-03 20:48:03 +02:00
|
|
|
struct TxLessThan
|
|
|
|
{
|
|
|
|
bool operator()(const TransactionRecord &a, const TransactionRecord &b) const
|
|
|
|
{
|
|
|
|
return a.hash < b.hash;
|
|
|
|
}
|
|
|
|
bool operator()(const TransactionRecord &a, const uint256 &b) const
|
|
|
|
{
|
|
|
|
return a.hash < b;
|
|
|
|
}
|
|
|
|
bool operator()(const uint256 &a, const TransactionRecord &b) const
|
|
|
|
{
|
|
|
|
return a < b.hash;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-11-12 12:23:51 +01:00
|
|
|
// queue notifications to show a non freezing progress dialog e.g. for rescan
|
|
|
|
struct TransactionNotification
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TransactionNotification() {}
|
|
|
|
TransactionNotification(uint256 _hash, ChangeType _status, bool _showTransaction):
|
|
|
|
hash(_hash), status(_status), showTransaction(_showTransaction) {}
|
|
|
|
|
|
|
|
void invoke(QObject *ttm)
|
|
|
|
{
|
|
|
|
QString strHash = QString::fromStdString(hash.GetHex());
|
|
|
|
qDebug() << "NotifyTransactionChanged: " + strHash + " status= " + QString::number(status);
|
|
|
|
bool invoked = QMetaObject::invokeMethod(ttm, "updateTransaction", Qt::QueuedConnection,
|
|
|
|
Q_ARG(QString, strHash),
|
|
|
|
Q_ARG(int, status),
|
|
|
|
Q_ARG(bool, showTransaction));
|
|
|
|
assert(invoked);
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
uint256 hash;
|
|
|
|
ChangeType status;
|
|
|
|
bool showTransaction;
|
|
|
|
};
|
|
|
|
|
2011-06-18 11:53:25 +02:00
|
|
|
// Private implementation
|
2012-04-15 12:31:56 +02:00
|
|
|
class TransactionTablePriv
|
2011-05-27 08:20:23 +02:00
|
|
|
{
|
2012-04-15 12:31:56 +02:00
|
|
|
public:
|
2018-08-27 19:32:59 +02:00
|
|
|
explicit TransactionTablePriv(TransactionTableModel *_parent) :
|
2016-09-23 12:44:09 +02:00
|
|
|
parent(_parent)
|
2011-06-03 20:48:03 +02:00
|
|
|
{
|
|
|
|
}
|
2013-08-24 15:07:17 +02:00
|
|
|
|
2011-06-03 20:48:03 +02:00
|
|
|
TransactionTableModel *parent;
|
|
|
|
|
2011-05-28 20:32:19 +02:00
|
|
|
/* Local cache of wallet.
|
|
|
|
* As it is in the same order as the CWallet, by definition
|
|
|
|
* this is sorted by sha256.
|
|
|
|
*/
|
2011-05-27 08:20:23 +02:00
|
|
|
QList<TransactionRecord> cachedWallet;
|
|
|
|
|
2020-11-12 12:23:51 +01:00
|
|
|
bool fQueueNotifications = false;
|
|
|
|
std::vector< TransactionNotification > vQueueNotifications;
|
|
|
|
|
|
|
|
void NotifyTransactionChanged(const uint256 &hash, ChangeType status);
|
|
|
|
void NotifyAddressBookChanged(const CTxDestination &address, const std::string &label, bool isMine, const std::string &purpose, ChangeType status);
|
|
|
|
void ShowProgress(const std::string &title, int nProgress);
|
|
|
|
|
2011-06-18 11:53:25 +02:00
|
|
|
/* Query entire wallet anew from core.
|
|
|
|
*/
|
2020-10-01 16:05:57 +02:00
|
|
|
void refreshWallet(interfaces::Wallet& wallet)
|
2011-05-27 08:20:23 +02:00
|
|
|
{
|
2013-09-04 11:52:45 +02:00
|
|
|
qDebug() << "TransactionTablePriv::refreshWallet";
|
2023-06-28 18:00:18 +02:00
|
|
|
parent->beginResetModel();
|
|
|
|
try {
|
|
|
|
cachedWallet.clear();
|
2017-04-18 22:42:30 +02:00
|
|
|
for (const auto& wtx : wallet.getWalletTxs()) {
|
|
|
|
if (TransactionRecord::showTransaction()) {
|
2021-02-15 00:27:28 +01:00
|
|
|
cachedWallet.append(TransactionRecord::decomposeTransaction(wallet, wtx));
|
2017-04-18 22:42:30 +02:00
|
|
|
}
|
2011-05-27 08:20:23 +02:00
|
|
|
}
|
2023-06-28 18:00:18 +02:00
|
|
|
} catch(const std::exception& e) {
|
|
|
|
QMessageBox::critical(nullptr, PACKAGE_NAME, QString("Failed to refresh wallet table: ") + QString::fromStdString(e.what()));
|
2011-05-27 08:20:23 +02:00
|
|
|
}
|
2023-06-28 18:00:18 +02:00
|
|
|
parent->endResetModel();
|
2011-05-27 08:20:23 +02:00
|
|
|
}
|
|
|
|
|
2011-06-18 11:53:25 +02:00
|
|
|
/* Update our model of the wallet incrementally, to synchronize our model of the wallet
|
|
|
|
with that of the core.
|
|
|
|
|
2012-05-05 16:07:14 +02:00
|
|
|
Call with transaction that was added, removed or changed.
|
2011-05-28 20:32:19 +02:00
|
|
|
*/
|
2020-10-01 16:05:57 +02:00
|
|
|
void updateWallet(interfaces::Wallet& wallet, const uint256 &hash, int status, bool showTransaction)
|
2011-05-28 20:32:19 +02:00
|
|
|
{
|
2015-01-08 11:44:25 +01:00
|
|
|
qDebug() << "TransactionTablePriv::updateWallet: " + QString::fromStdString(hash.ToString()) + " " + QString::number(status);
|
2012-05-05 16:07:14 +02:00
|
|
|
|
2015-02-10 14:24:05 +01:00
|
|
|
// Find bounds of this transaction in model
|
Merge #16674: refactor: remove obsolete qt algorithm usage
153d9dd9acffa95bb97a4b1579bd20237fdc9c52 refactor: replace qLowerBound & qUpperBound with std:: upper_bound & lower_bound (fanquake)
59373e3e94015316bcaa03a7b9c2e6f442641720 refactor: replace qSort with std::sort (fanquake)
fea33cbbdfb4673033f3414bf1613591ff654aac refactor: replace qStableSort with std::stable_sort (fanquake)
Pull request description:
`qStablesort`, `qSort`, `qLowerBound` and `qUpperBound` have been marked as obsolete since at least Qt 5.9: [Obsolete Members for QtAlgorithms](https://doc.qt.io/qt-5.9/qtalgorithms-obsolete.html).
This pull request replaces their usage with the suggested `std::` replacements.
This also removes some warning spam when compiling against newer Qt (5.13.0 via brew):
```bash
CXX qt/libbitcoinqt_a-walletcontroller.o
qt/transactiontablemodel.cpp:96:52: warning: 'qLowerBound<QList<TransactionRecord>::iterator, uint256, TxLessThan>' is deprecated: Use std::lower_bound [-Wdeprecated-declarations]
QList<TransactionRecord>::iterator lower = qLowerBound(
qt/transactiontablemodel.cpp:98:52: warning: 'qUpperBound<QList<TransactionRecord>::iterator, uint256, TxLessThan>' is deprecated: Use std::upper_bound [-Wdeprecated-declarations]
QList<TransactionRecord>::iterator upper = qUpperBound(
```
```bash
CXX qt/libbitcoinqt_a-moc_walletcontroller.o
qt/bantablemodel.cpp:64:13: warning: 'qStableSort<QList<CCombinedBan>::iterator, BannedNodeLessThan>' is deprecated: Use std::stable_sort [-Wdeprecated-declarations]
qStableSort(cachedBanlist.begin(), cachedBanlist.end(), BannedNodeLessThan(sortColumn, sortOrder));
```
```bash
CXX qt/libbitcoinqt_a-sendcoinsentry.o
qt/recentrequeststablemodel.cpp:205:5: warning: 'qSort<QList<RecentRequestEntry>::iterator, RecentRequestEntryLessThan>' is deprecated: Use std::sort [-Wdeprecated-declarations]
qSort(list.begin(), list.end(), RecentRequestEntryLessThan(column, order));
```
ACKs for top commit:
hebasto:
ACK 153d9dd9acffa95bb97a4b1579bd20237fdc9c52
promag:
ACK 153d9dd9acffa95bb97a4b1579bd20237fdc9c52.
jonasschnelli:
utACK 153d9dd9acffa95bb97a4b1579bd20237fdc9c52
Tree-SHA512: 22f7290ed798ce8b0f5f313405377845d4c8e48dc8687be7464e27fff53363b451a40e9e18910a8c3b4b9d4dcc236a366c92e7d171fcb8576c48f149a1886c26
2019-08-22 11:52:34 +02:00
|
|
|
QList<TransactionRecord>::iterator lower = std::lower_bound(
|
2015-02-10 14:24:05 +01:00
|
|
|
cachedWallet.begin(), cachedWallet.end(), hash, TxLessThan());
|
Merge #16674: refactor: remove obsolete qt algorithm usage
153d9dd9acffa95bb97a4b1579bd20237fdc9c52 refactor: replace qLowerBound & qUpperBound with std:: upper_bound & lower_bound (fanquake)
59373e3e94015316bcaa03a7b9c2e6f442641720 refactor: replace qSort with std::sort (fanquake)
fea33cbbdfb4673033f3414bf1613591ff654aac refactor: replace qStableSort with std::stable_sort (fanquake)
Pull request description:
`qStablesort`, `qSort`, `qLowerBound` and `qUpperBound` have been marked as obsolete since at least Qt 5.9: [Obsolete Members for QtAlgorithms](https://doc.qt.io/qt-5.9/qtalgorithms-obsolete.html).
This pull request replaces their usage with the suggested `std::` replacements.
This also removes some warning spam when compiling against newer Qt (5.13.0 via brew):
```bash
CXX qt/libbitcoinqt_a-walletcontroller.o
qt/transactiontablemodel.cpp:96:52: warning: 'qLowerBound<QList<TransactionRecord>::iterator, uint256, TxLessThan>' is deprecated: Use std::lower_bound [-Wdeprecated-declarations]
QList<TransactionRecord>::iterator lower = qLowerBound(
qt/transactiontablemodel.cpp:98:52: warning: 'qUpperBound<QList<TransactionRecord>::iterator, uint256, TxLessThan>' is deprecated: Use std::upper_bound [-Wdeprecated-declarations]
QList<TransactionRecord>::iterator upper = qUpperBound(
```
```bash
CXX qt/libbitcoinqt_a-moc_walletcontroller.o
qt/bantablemodel.cpp:64:13: warning: 'qStableSort<QList<CCombinedBan>::iterator, BannedNodeLessThan>' is deprecated: Use std::stable_sort [-Wdeprecated-declarations]
qStableSort(cachedBanlist.begin(), cachedBanlist.end(), BannedNodeLessThan(sortColumn, sortOrder));
```
```bash
CXX qt/libbitcoinqt_a-sendcoinsentry.o
qt/recentrequeststablemodel.cpp:205:5: warning: 'qSort<QList<RecentRequestEntry>::iterator, RecentRequestEntryLessThan>' is deprecated: Use std::sort [-Wdeprecated-declarations]
qSort(list.begin(), list.end(), RecentRequestEntryLessThan(column, order));
```
ACKs for top commit:
hebasto:
ACK 153d9dd9acffa95bb97a4b1579bd20237fdc9c52
promag:
ACK 153d9dd9acffa95bb97a4b1579bd20237fdc9c52.
jonasschnelli:
utACK 153d9dd9acffa95bb97a4b1579bd20237fdc9c52
Tree-SHA512: 22f7290ed798ce8b0f5f313405377845d4c8e48dc8687be7464e27fff53363b451a40e9e18910a8c3b4b9d4dcc236a366c92e7d171fcb8576c48f149a1886c26
2019-08-22 11:52:34 +02:00
|
|
|
QList<TransactionRecord>::iterator upper = std::upper_bound(
|
2015-02-10 14:24:05 +01:00
|
|
|
cachedWallet.begin(), cachedWallet.end(), hash, TxLessThan());
|
|
|
|
int lowerIndex = (lower - cachedWallet.begin());
|
|
|
|
int upperIndex = (upper - cachedWallet.begin());
|
|
|
|
bool inModel = (lower != upper);
|
2012-05-05 16:07:14 +02:00
|
|
|
|
2015-02-10 14:24:05 +01:00
|
|
|
if(status == CT_UPDATED)
|
|
|
|
{
|
|
|
|
if(showTransaction && !inModel)
|
|
|
|
status = CT_NEW; /* Not in model, but want to show, treat as new */
|
|
|
|
if(!showTransaction && inModel)
|
|
|
|
status = CT_DELETED; /* In model, but want to hide, treat as deleted */
|
|
|
|
}
|
2012-05-05 16:07:14 +02:00
|
|
|
|
2015-02-10 14:24:05 +01:00
|
|
|
qDebug() << " inModel=" + QString::number(inModel) +
|
|
|
|
" Index=" + QString::number(lowerIndex) + "-" + QString::number(upperIndex) +
|
|
|
|
" showTransaction=" + QString::number(showTransaction) + " derivedStatus=" + QString::number(status);
|
2012-05-05 16:07:14 +02:00
|
|
|
|
2015-02-10 14:24:05 +01:00
|
|
|
switch(status)
|
|
|
|
{
|
|
|
|
case CT_NEW:
|
|
|
|
if(inModel)
|
2011-06-03 20:48:03 +02:00
|
|
|
{
|
2015-01-08 11:44:25 +01:00
|
|
|
qWarning() << "TransactionTablePriv::updateWallet: Warning: Got CT_NEW, but transaction is already in model";
|
2015-02-10 14:24:05 +01:00
|
|
|
break;
|
2012-05-05 16:07:14 +02:00
|
|
|
}
|
2015-02-10 14:24:05 +01:00
|
|
|
if(showTransaction)
|
2012-05-05 16:07:14 +02:00
|
|
|
{
|
2015-02-10 14:24:05 +01:00
|
|
|
// Find transaction in wallet
|
2020-10-01 16:05:57 +02:00
|
|
|
interfaces::WalletTx wtx = wallet.getWalletTx(hash);
|
2017-04-18 22:42:30 +02:00
|
|
|
if(!wtx.tx)
|
2012-05-05 16:07:14 +02:00
|
|
|
{
|
2015-01-08 11:44:25 +01:00
|
|
|
qWarning() << "TransactionTablePriv::updateWallet: Warning: Got CT_NEW, but transaction is not in wallet";
|
2012-05-05 16:07:14 +02:00
|
|
|
break;
|
|
|
|
}
|
2015-02-10 14:24:05 +01:00
|
|
|
// Added -- insert at the right position
|
|
|
|
QList<TransactionRecord> toInsert =
|
2021-02-15 00:27:28 +01:00
|
|
|
TransactionRecord::decomposeTransaction(wallet, wtx);
|
2015-02-10 14:24:05 +01:00
|
|
|
if(!toInsert.isEmpty()) /* only if something to insert */
|
2011-06-03 20:48:03 +02:00
|
|
|
{
|
2015-02-10 14:24:05 +01:00
|
|
|
parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex+toInsert.size()-1);
|
|
|
|
int insert_idx = lowerIndex;
|
2019-07-05 09:07:45 +02:00
|
|
|
for (const TransactionRecord &rec : toInsert)
|
2011-06-03 20:48:03 +02:00
|
|
|
{
|
2015-02-10 14:24:05 +01:00
|
|
|
cachedWallet.insert(insert_idx, rec);
|
|
|
|
insert_idx += 1;
|
2011-06-03 20:48:03 +02:00
|
|
|
}
|
2015-02-10 14:24:05 +01:00
|
|
|
parent->endInsertRows();
|
2011-06-07 18:59:01 +02:00
|
|
|
}
|
2015-02-10 14:24:05 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CT_DELETED:
|
|
|
|
if(!inModel)
|
|
|
|
{
|
2015-01-08 11:44:25 +01:00
|
|
|
qWarning() << "TransactionTablePriv::updateWallet: Warning: Got CT_DELETED, but transaction is not in model";
|
2012-05-05 16:07:14 +02:00
|
|
|
break;
|
2011-06-03 20:48:03 +02:00
|
|
|
}
|
2015-02-10 14:24:05 +01:00
|
|
|
// Removed -- remove entire transaction from table
|
|
|
|
parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1);
|
|
|
|
cachedWallet.erase(lower, upper);
|
|
|
|
parent->endRemoveRows();
|
|
|
|
break;
|
|
|
|
case CT_UPDATED:
|
|
|
|
// Miscellaneous updates -- nothing to do, status update will take care of this, and is only computed for
|
|
|
|
// visible transactions.
|
2019-10-19 12:39:02 +02:00
|
|
|
for (int i = lowerIndex; i < upperIndex; i++) {
|
|
|
|
TransactionRecord *rec = &cachedWallet[i];
|
|
|
|
rec->status.needsUpdate = true;
|
|
|
|
}
|
|
|
|
Q_EMIT parent->dataChanged(parent->index(lowerIndex, TransactionTableModel::Status), parent->index(upperIndex, TransactionTableModel::Status));
|
2015-02-10 14:24:05 +01:00
|
|
|
break;
|
2011-05-28 20:32:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-15 00:27:28 +01:00
|
|
|
void updateAddressBook(interfaces::Wallet& wallet, const QString& address, const QString& label, bool isMine, const QString& purpose, int status)
|
2019-10-19 12:39:02 +02:00
|
|
|
{
|
|
|
|
std::string address2 = address.toStdString();
|
|
|
|
int index = 0;
|
|
|
|
for (auto& rec : cachedWallet) {
|
|
|
|
if (rec.strAddress == address2) {
|
2021-02-15 00:27:28 +01:00
|
|
|
rec.updateLabel(wallet);
|
2019-10-19 12:39:02 +02:00
|
|
|
Q_EMIT parent->dataChanged(parent->index(index, TransactionTableModel::ToAddress), parent->index(index, TransactionTableModel::ToAddress));
|
|
|
|
}
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-27 08:20:23 +02:00
|
|
|
int size()
|
|
|
|
{
|
|
|
|
return cachedWallet.size();
|
|
|
|
}
|
|
|
|
|
2023-04-10 22:02:17 +02:00
|
|
|
TransactionRecord* index(interfaces::Wallet& wallet, const uint256& cur_block_hash, const int idx)
|
2011-05-27 08:20:23 +02:00
|
|
|
{
|
2020-07-02 01:27:52 +02:00
|
|
|
if (idx >= 0 && idx < cachedWallet.size()) {
|
2011-06-04 21:41:31 +02:00
|
|
|
TransactionRecord *rec = &cachedWallet[idx];
|
|
|
|
|
2011-06-18 11:53:25 +02:00
|
|
|
// If a status update is needed (blocks came in since last check),
|
2020-07-02 01:27:52 +02:00
|
|
|
// try to update the status of this transaction from the wallet.
|
|
|
|
// Otherwise, simply re-use the cached status.
|
2020-10-01 16:05:57 +02:00
|
|
|
interfaces::WalletTxStatus wtx;
|
2023-04-10 22:02:17 +02:00
|
|
|
int numBlocks;
|
2019-01-15 17:25:14 +01:00
|
|
|
int64_t block_time;
|
2023-04-10 22:02:17 +02:00
|
|
|
if (!cur_block_hash.IsNull() && rec->statusUpdateNeeded(cur_block_hash, parent->getChainLockHeight()) && wallet.tryGetTxStatus(rec->hash, wtx, numBlocks, block_time)) {
|
|
|
|
rec->updateStatus(wtx, cur_block_hash, numBlocks, parent->getChainLockHeight(), block_time);
|
2011-06-04 21:41:31 +02:00
|
|
|
}
|
|
|
|
return rec;
|
2011-06-07 18:59:01 +02:00
|
|
|
}
|
2019-01-14 15:20:45 +01:00
|
|
|
return nullptr;
|
2011-05-27 08:20:23 +02:00
|
|
|
}
|
2011-05-28 20:32:19 +02:00
|
|
|
|
2020-10-01 16:05:57 +02:00
|
|
|
QString describe(interfaces::Node& node, interfaces::Wallet& wallet, TransactionRecord *rec, int unit)
|
2011-06-10 15:05:51 +02:00
|
|
|
{
|
2017-04-18 22:42:30 +02:00
|
|
|
return TransactionDesc::toHTML(node, wallet, rec, unit);
|
2011-06-10 15:05:51 +02:00
|
|
|
}
|
2015-11-17 11:17:09 +01:00
|
|
|
|
2020-10-01 16:05:57 +02:00
|
|
|
QString getTxHex(interfaces::Wallet& wallet, TransactionRecord *rec)
|
2015-11-17 11:17:09 +01:00
|
|
|
{
|
2017-04-18 22:42:30 +02:00
|
|
|
auto tx = wallet.getTx(rec->hash);
|
|
|
|
if (tx) {
|
|
|
|
std::string strHex = EncodeHexTx(*tx);
|
2015-11-17 11:17:09 +01:00
|
|
|
return QString::fromStdString(strHex);
|
|
|
|
}
|
|
|
|
return QString();
|
|
|
|
}
|
2011-05-27 08:20:23 +02:00
|
|
|
};
|
|
|
|
|
2017-04-18 22:42:30 +02:00
|
|
|
TransactionTableModel::TransactionTableModel(WalletModel *parent):
|
|
|
|
QAbstractTableModel(parent),
|
|
|
|
walletModel(parent),
|
|
|
|
priv(new TransactionTablePriv(this)),
|
2020-10-05 01:48:58 +02:00
|
|
|
fProcessingQueuedTransactions(false),
|
|
|
|
cachedChainLockHeight(-1)
|
2011-05-08 16:30:10 +02:00
|
|
|
{
|
2020-09-23 08:33:46 +02:00
|
|
|
columns << QString() << QString() << tr("Date") << tr("Type") << tr("Address / Label") << BitcoinUnits::getAmountColumnTitle(walletModel->getOptionsModel()->getDisplayUnit());
|
2017-04-18 22:42:30 +02:00
|
|
|
priv->refreshWallet(walletModel->wallet());
|
2011-05-28 20:32:19 +02:00
|
|
|
|
2018-08-21 10:54:43 +02:00
|
|
|
connect(walletModel->getOptionsModel(), &OptionsModel::displayUnitChanged, this, &TransactionTableModel::updateDisplayUnit);
|
2015-02-10 14:24:05 +01:00
|
|
|
|
|
|
|
subscribeToCoreSignals();
|
2011-05-27 08:20:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TransactionTableModel::~TransactionTableModel()
|
|
|
|
{
|
2015-02-10 14:24:05 +01:00
|
|
|
unsubscribeFromCoreSignals();
|
2011-06-01 15:33:33 +02:00
|
|
|
delete priv;
|
2011-05-08 16:30:10 +02:00
|
|
|
}
|
|
|
|
|
2023-06-28 18:00:18 +02:00
|
|
|
void TransactionTableModel::refreshWallet()
|
|
|
|
{
|
|
|
|
priv->refreshWallet(walletModel->wallet());
|
|
|
|
}
|
|
|
|
|
2014-06-07 08:20:22 +02:00
|
|
|
/** Updates the column title to "Amount (DisplayUnit)" and emits headerDataChanged() signal for table headers to react. */
|
|
|
|
void TransactionTableModel::updateAmountColumnTitle()
|
|
|
|
{
|
|
|
|
columns[Amount] = BitcoinUnits::getAmountColumnTitle(walletModel->getOptionsModel()->getDisplayUnit());
|
2015-07-14 13:59:05 +02:00
|
|
|
Q_EMIT headerDataChanged(Qt::Horizontal,Amount,Amount);
|
2014-06-07 08:20:22 +02:00
|
|
|
}
|
|
|
|
|
2015-02-10 14:24:05 +01:00
|
|
|
void TransactionTableModel::updateTransaction(const QString &hash, int status, bool showTransaction)
|
2011-05-27 21:24:17 +02:00
|
|
|
{
|
2012-05-05 16:07:14 +02:00
|
|
|
uint256 updated;
|
|
|
|
updated.SetHex(hash.toStdString());
|
2011-05-28 20:32:19 +02:00
|
|
|
|
2017-04-18 22:42:30 +02:00
|
|
|
priv->updateWallet(walletModel->wallet(), updated, status, showTransaction);
|
2012-05-05 16:07:14 +02:00
|
|
|
}
|
2011-05-28 20:32:19 +02:00
|
|
|
|
2019-10-19 12:39:02 +02:00
|
|
|
void TransactionTableModel::updateAddressBook(const QString& address, const QString& label, bool isMine,
|
|
|
|
const QString& purpose, int status)
|
|
|
|
{
|
2021-02-15 00:27:28 +01:00
|
|
|
priv->updateAddressBook(walletModel->wallet(), address, label, isMine, purpose, status);
|
2019-10-19 12:39:02 +02:00
|
|
|
}
|
|
|
|
|
2012-05-05 16:07:14 +02:00
|
|
|
void TransactionTableModel::updateConfirmations()
|
|
|
|
{
|
2014-04-15 17:38:25 +02:00
|
|
|
// Blocks came in since last poll.
|
|
|
|
// Invalidate status (number of confirmations) and (possibly) description
|
|
|
|
// for all rows. Qt is smart enough to only actually request the data for the
|
|
|
|
// visible rows.
|
2015-07-14 13:59:05 +02:00
|
|
|
Q_EMIT dataChanged(index(0, Status), index(priv->size()-1, Status));
|
2011-05-27 21:24:17 +02:00
|
|
|
}
|
2011-05-27 08:20:23 +02:00
|
|
|
|
2019-04-25 17:37:39 +02:00
|
|
|
|
|
|
|
void TransactionTableModel::updateChainLockHeight(int chainLockHeight)
|
|
|
|
{
|
|
|
|
cachedChainLockHeight = chainLockHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
int TransactionTableModel::getChainLockHeight() const
|
|
|
|
{
|
|
|
|
return cachedChainLockHeight;
|
|
|
|
}
|
|
|
|
|
2011-05-08 16:30:10 +02:00
|
|
|
int TransactionTableModel::rowCount(const QModelIndex &parent) const
|
|
|
|
{
|
2021-01-07 14:59:08 +01:00
|
|
|
if (parent.isValid()) {
|
|
|
|
return 0;
|
|
|
|
}
|
2011-06-01 15:33:33 +02:00
|
|
|
return priv->size();
|
2011-05-08 16:30:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int TransactionTableModel::columnCount(const QModelIndex &parent) const
|
|
|
|
{
|
2021-01-07 14:59:08 +01:00
|
|
|
if (parent.isValid()) {
|
|
|
|
return 0;
|
|
|
|
}
|
2011-05-08 16:30:10 +02:00
|
|
|
return columns.length();
|
|
|
|
}
|
|
|
|
|
2011-08-05 15:35:52 +02:00
|
|
|
QString TransactionTableModel::formatTxStatus(const TransactionRecord *wtx) const
|
2011-05-27 08:20:23 +02:00
|
|
|
{
|
2011-05-27 18:38:30 +02:00
|
|
|
QString status;
|
2011-05-27 20:36:58 +02:00
|
|
|
|
2014-02-20 14:09:09 +01:00
|
|
|
switch(wtx->status.status)
|
2011-07-07 10:29:07 +02:00
|
|
|
{
|
2014-02-20 14:09:09 +01:00
|
|
|
case TransactionStatus::OpenUntilBlock:
|
|
|
|
status = tr("Open for %n more block(s)","",wtx->status.open_for);
|
|
|
|
break;
|
|
|
|
case TransactionStatus::OpenUntilDate:
|
|
|
|
status = tr("Open until %1").arg(GUIUtil::dateTimeStr(wtx->status.open_for));
|
|
|
|
break;
|
|
|
|
case TransactionStatus::Unconfirmed:
|
|
|
|
status = tr("Unconfirmed");
|
|
|
|
break;
|
2017-09-09 09:04:02 +02:00
|
|
|
case TransactionStatus::Abandoned:
|
|
|
|
status = tr("Abandoned");
|
|
|
|
break;
|
2014-02-20 14:09:09 +01:00
|
|
|
case TransactionStatus::Confirming:
|
|
|
|
status = tr("Confirming (%1 of %2 recommended confirmations)").arg(wtx->status.depth).arg(TransactionRecord::RecommendedNumConfirmations);
|
|
|
|
break;
|
|
|
|
case TransactionStatus::Confirmed:
|
|
|
|
status = tr("Confirmed (%1 confirmations)").arg(wtx->status.depth);
|
|
|
|
break;
|
|
|
|
case TransactionStatus::Conflicted:
|
|
|
|
status = tr("Conflicted");
|
|
|
|
break;
|
|
|
|
case TransactionStatus::Immature:
|
|
|
|
status = tr("Immature (%1 confirmations, will be available after %2)").arg(wtx->status.depth).arg(wtx->status.depth + wtx->status.matures_in);
|
|
|
|
break;
|
|
|
|
case TransactionStatus::NotAccepted:
|
|
|
|
status = tr("Generated but not accepted");
|
|
|
|
break;
|
2011-07-07 10:29:07 +02:00
|
|
|
}
|
2011-05-27 18:38:30 +02:00
|
|
|
|
2020-09-23 08:33:46 +02:00
|
|
|
if (wtx->status.lockedByInstantSend) {
|
|
|
|
status += ", " + tr("verified via InstantSend");
|
|
|
|
}
|
|
|
|
if (wtx->status.lockedByChainLocks) {
|
|
|
|
status += ", " + tr("locked via ChainLocks");
|
|
|
|
}
|
|
|
|
|
2011-08-05 15:35:52 +02:00
|
|
|
return status;
|
2011-05-27 08:20:23 +02:00
|
|
|
}
|
|
|
|
|
2011-08-05 15:35:52 +02:00
|
|
|
QString TransactionTableModel::formatTxDate(const TransactionRecord *wtx) const
|
2011-05-27 08:20:23 +02:00
|
|
|
{
|
2011-05-27 18:38:30 +02:00
|
|
|
if(wtx->time)
|
|
|
|
{
|
2011-08-08 17:38:17 +02:00
|
|
|
return GUIUtil::dateTimeStr(wtx->time);
|
2011-06-07 18:59:01 +02:00
|
|
|
}
|
2014-08-09 15:29:55 +02:00
|
|
|
return QString();
|
2011-05-27 08:20:23 +02:00
|
|
|
}
|
|
|
|
|
2019-10-23 09:56:00 +02:00
|
|
|
/* If label is non-empty, return label (address)
|
2011-07-30 17:42:02 +02:00
|
|
|
otherwise just return (address)
|
2011-06-28 21:41:56 +02:00
|
|
|
*/
|
2019-10-23 09:56:00 +02:00
|
|
|
QString TransactionTableModel::formatAddressLabel(const std::string &address, const QString& label, bool tooltip) const
|
2011-06-28 21:41:56 +02:00
|
|
|
{
|
|
|
|
QString description;
|
2011-07-30 17:42:02 +02:00
|
|
|
if(!label.isEmpty())
|
2011-06-28 21:41:56 +02:00
|
|
|
{
|
2014-08-09 15:29:55 +02:00
|
|
|
description += label;
|
2011-06-28 21:41:56 +02:00
|
|
|
}
|
2014-07-31 09:05:13 +02:00
|
|
|
if(label.isEmpty() || tooltip)
|
2011-06-28 21:41:56 +02:00
|
|
|
{
|
2014-08-09 15:29:55 +02:00
|
|
|
description += QString(" (") + QString::fromStdString(address) + QString(")");
|
2011-06-28 21:41:56 +02:00
|
|
|
}
|
2011-05-27 20:36:58 +02:00
|
|
|
return description;
|
|
|
|
}
|
|
|
|
|
2011-07-31 17:05:34 +02:00
|
|
|
QString TransactionTableModel::formatTxType(const TransactionRecord *wtx) const
|
2011-05-27 08:20:23 +02:00
|
|
|
{
|
2011-05-27 19:48:42 +02:00
|
|
|
switch(wtx->type)
|
|
|
|
{
|
2011-05-28 22:31:27 +02:00
|
|
|
case TransactionRecord::RecvWithAddress:
|
2011-07-31 17:05:34 +02:00
|
|
|
return tr("Received with");
|
2011-12-28 11:14:05 +01:00
|
|
|
case TransactionRecord::RecvFromOther:
|
|
|
|
return tr("Received from");
|
2021-03-17 23:36:11 +01:00
|
|
|
case TransactionRecord::RecvWithCoinJoin:
|
2021-07-11 11:28:50 +02:00
|
|
|
return tr("Received via %1").arg(QString::fromStdString(gCoinJoinName));
|
2011-05-27 19:48:42 +02:00
|
|
|
case TransactionRecord::SendToAddress:
|
2011-12-28 11:14:05 +01:00
|
|
|
case TransactionRecord::SendToOther:
|
2011-07-31 17:05:34 +02:00
|
|
|
return tr("Sent to");
|
2011-05-27 19:48:42 +02:00
|
|
|
case TransactionRecord::SendToSelf:
|
2011-07-31 17:05:34 +02:00
|
|
|
return tr("Payment to yourself");
|
2011-06-26 22:47:02 +02:00
|
|
|
case TransactionRecord::Generated:
|
2011-07-31 17:05:34 +02:00
|
|
|
return tr("Mined");
|
2015-01-08 23:21:05 +01:00
|
|
|
|
2021-03-24 11:13:25 +01:00
|
|
|
case TransactionRecord::CoinJoinMixing:
|
2021-07-11 11:28:50 +02:00
|
|
|
return tr("%1 Mixing").arg(QString::fromStdString(gCoinJoinName));
|
2021-03-17 23:36:11 +01:00
|
|
|
case TransactionRecord::CoinJoinCollateralPayment:
|
2021-07-11 11:28:50 +02:00
|
|
|
return tr("%1 Collateral Payment").arg(QString::fromStdString(gCoinJoinName));
|
2021-03-17 23:36:11 +01:00
|
|
|
case TransactionRecord::CoinJoinMakeCollaterals:
|
2021-07-11 11:28:50 +02:00
|
|
|
return tr("%1 Make Collateral Inputs").arg(QString::fromStdString(gCoinJoinName));
|
2021-03-17 23:36:11 +01:00
|
|
|
case TransactionRecord::CoinJoinCreateDenominations:
|
2021-07-11 11:28:50 +02:00
|
|
|
return tr("%1 Create Denominations").arg(QString::fromStdString(gCoinJoinName));
|
2021-03-24 11:13:25 +01:00
|
|
|
case TransactionRecord::CoinJoinSend:
|
2021-07-11 11:28:50 +02:00
|
|
|
return tr("%1 Send").arg(QString::fromStdString(gCoinJoinName));
|
2015-01-08 23:21:05 +01:00
|
|
|
|
2011-07-31 17:05:34 +02:00
|
|
|
default:
|
|
|
|
return QString();
|
2011-06-26 22:47:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-31 17:05:34 +02:00
|
|
|
QVariant TransactionTableModel::txAddressDecoration(const TransactionRecord *wtx) const
|
2011-06-26 22:47:02 +02:00
|
|
|
{
|
2020-09-23 08:33:46 +02:00
|
|
|
if (wtx->status.lockedByInstantSend) {
|
2020-09-30 15:08:11 +02:00
|
|
|
return GUIUtil::getIcon("transaction_locked", GUIUtil::ThemedColor::BLUE);
|
2011-07-31 17:05:34 +02:00
|
|
|
}
|
2020-09-23 08:33:46 +02:00
|
|
|
return QVariant();
|
2011-07-31 17:05:34 +02:00
|
|
|
}
|
2011-06-26 22:47:02 +02:00
|
|
|
|
2011-07-31 17:05:34 +02:00
|
|
|
QString TransactionTableModel::formatTxToAddress(const TransactionRecord *wtx, bool tooltip) const
|
|
|
|
{
|
2014-08-28 23:20:46 +02:00
|
|
|
QString watchAddress;
|
|
|
|
if (tooltip) {
|
|
|
|
// Mark transactions involving watch-only addresses by adding " (watch-only)"
|
|
|
|
watchAddress = wtx->involvesWatchAddress ? QString(" (") + tr("watch-only") + QString(")") : "";
|
|
|
|
}
|
|
|
|
|
2011-06-26 22:47:02 +02:00
|
|
|
switch(wtx->type)
|
|
|
|
{
|
2011-12-28 11:14:05 +01:00
|
|
|
case TransactionRecord::RecvFromOther:
|
2019-10-19 12:39:02 +02:00
|
|
|
return QString::fromStdString(wtx->strAddress) + watchAddress;
|
2011-07-30 17:42:02 +02:00
|
|
|
case TransactionRecord::RecvWithAddress:
|
2021-03-17 23:36:11 +01:00
|
|
|
case TransactionRecord::RecvWithCoinJoin:
|
2011-06-26 22:47:02 +02:00
|
|
|
case TransactionRecord::SendToAddress:
|
2012-06-02 04:33:28 +02:00
|
|
|
case TransactionRecord::Generated:
|
2021-03-24 11:13:25 +01:00
|
|
|
case TransactionRecord::CoinJoinSend:
|
2021-02-15 00:27:28 +01:00
|
|
|
return formatAddressLabel(wtx->strAddress, wtx->label, tooltip) + watchAddress;
|
2011-12-28 11:14:05 +01:00
|
|
|
case TransactionRecord::SendToOther:
|
2019-10-19 12:39:02 +02:00
|
|
|
return QString::fromStdString(wtx->strAddress) + watchAddress;
|
2011-06-26 22:47:02 +02:00
|
|
|
case TransactionRecord::SendToSelf:
|
2019-10-09 20:16:38 +02:00
|
|
|
return formatAddressLabel(wtx->strAddress, wtx->label, tooltip) + watchAddress;
|
2011-07-31 17:05:34 +02:00
|
|
|
default:
|
2014-08-28 23:20:46 +02:00
|
|
|
return tr("(n/a)") + watchAddress;
|
2011-05-27 19:48:42 +02:00
|
|
|
}
|
2011-05-27 08:20:23 +02:00
|
|
|
}
|
|
|
|
|
2011-07-30 17:42:02 +02:00
|
|
|
QVariant TransactionTableModel::addressColor(const TransactionRecord *wtx) const
|
|
|
|
{
|
|
|
|
// Show addresses without label in a less visible color
|
|
|
|
switch(wtx->type)
|
|
|
|
{
|
|
|
|
case TransactionRecord::RecvWithAddress:
|
|
|
|
case TransactionRecord::SendToAddress:
|
2012-06-02 04:33:28 +02:00
|
|
|
case TransactionRecord::Generated:
|
2021-03-24 11:13:25 +01:00
|
|
|
case TransactionRecord::CoinJoinSend:
|
2021-03-17 23:36:11 +01:00
|
|
|
case TransactionRecord::RecvWithCoinJoin:
|
2011-07-30 17:42:02 +02:00
|
|
|
{
|
2021-02-15 00:27:28 +01:00
|
|
|
if (wtx->label.isEmpty()) {
|
2019-11-22 19:13:47 +01:00
|
|
|
return GUIUtil::getThemedQColor(GUIUtil::ThemedColor::BAREADDRESS);
|
2021-02-11 17:36:09 +01:00
|
|
|
}
|
2011-07-30 17:42:02 +02:00
|
|
|
} break;
|
2011-07-31 17:43:46 +02:00
|
|
|
case TransactionRecord::SendToSelf:
|
2021-03-17 23:36:11 +01:00
|
|
|
case TransactionRecord::CoinJoinCreateDenominations:
|
2021-03-24 11:13:25 +01:00
|
|
|
case TransactionRecord::CoinJoinMixing:
|
2021-03-17 23:36:11 +01:00
|
|
|
case TransactionRecord::CoinJoinMakeCollaterals:
|
|
|
|
case TransactionRecord::CoinJoinCollateralPayment:
|
2019-11-22 19:13:47 +01:00
|
|
|
return GUIUtil::getThemedQColor(GUIUtil::ThemedColor::BAREADDRESS);
|
2011-07-30 17:42:02 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2019-11-22 19:13:47 +01:00
|
|
|
return GUIUtil::getThemedQColor(GUIUtil::ThemedColor::DEFAULT);
|
2011-07-30 17:42:02 +02:00
|
|
|
}
|
|
|
|
|
2014-07-07 23:27:09 +02:00
|
|
|
QString TransactionTableModel::formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed, BitcoinUnits::SeparatorStyle separators) const
|
2011-05-27 08:20:23 +02:00
|
|
|
{
|
2014-07-07 23:27:09 +02:00
|
|
|
QString str = BitcoinUnits::format(walletModel->getOptionsModel()->getDisplayUnit(), wtx->credit + wtx->debit, false, separators);
|
2011-07-07 14:27:16 +02:00
|
|
|
if(showUnconfirmed)
|
2011-05-27 18:38:30 +02:00
|
|
|
{
|
2014-02-20 14:09:09 +01:00
|
|
|
if(!wtx->status.countsForBalance)
|
2011-07-07 14:27:16 +02:00
|
|
|
{
|
|
|
|
str = QString("[") + str + QString("]");
|
|
|
|
}
|
2011-05-27 18:38:30 +02:00
|
|
|
}
|
2011-08-05 15:35:52 +02:00
|
|
|
return QString(str);
|
2011-05-27 08:20:23 +02:00
|
|
|
}
|
|
|
|
|
2020-09-23 08:33:46 +02:00
|
|
|
QVariant TransactionTableModel::amountColor(const TransactionRecord *rec) const
|
|
|
|
{
|
|
|
|
switch (rec->type) {
|
|
|
|
case TransactionRecord::Generated:
|
2021-03-17 23:36:11 +01:00
|
|
|
case TransactionRecord::RecvWithCoinJoin:
|
2020-09-23 08:33:46 +02:00
|
|
|
case TransactionRecord::RecvWithAddress:
|
|
|
|
case TransactionRecord::RecvFromOther:
|
|
|
|
return GUIUtil::getThemedQColor(GUIUtil::ThemedColor::GREEN);
|
2021-03-24 11:13:25 +01:00
|
|
|
case TransactionRecord::CoinJoinSend:
|
2020-09-23 08:33:46 +02:00
|
|
|
case TransactionRecord::SendToAddress:
|
|
|
|
case TransactionRecord::SendToOther:
|
|
|
|
case TransactionRecord::Other:
|
|
|
|
return GUIUtil::getThemedQColor(GUIUtil::ThemedColor::RED);
|
|
|
|
case TransactionRecord::SendToSelf:
|
2021-03-24 11:13:25 +01:00
|
|
|
case TransactionRecord::CoinJoinMixing:
|
2021-03-17 23:36:11 +01:00
|
|
|
case TransactionRecord::CoinJoinCollateralPayment:
|
|
|
|
case TransactionRecord::CoinJoinMakeCollaterals:
|
|
|
|
case TransactionRecord::CoinJoinCreateDenominations:
|
2020-09-23 08:33:46 +02:00
|
|
|
return GUIUtil::getThemedQColor(GUIUtil::ThemedColor::ORANGE);
|
|
|
|
}
|
|
|
|
return GUIUtil::getThemedQColor(GUIUtil::ThemedColor::DEFAULT);
|
|
|
|
}
|
|
|
|
|
2011-08-05 15:35:52 +02:00
|
|
|
QVariant TransactionTableModel::txStatusDecoration(const TransactionRecord *wtx) const
|
2011-06-13 09:05:48 +02:00
|
|
|
{
|
2014-02-20 14:09:09 +01:00
|
|
|
switch(wtx->status.status)
|
2011-07-07 10:29:07 +02:00
|
|
|
{
|
2014-02-20 14:09:09 +01:00
|
|
|
case TransactionStatus::OpenUntilBlock:
|
|
|
|
case TransactionStatus::OpenUntilDate:
|
2019-11-22 19:13:47 +01:00
|
|
|
return GUIUtil::getThemedQColor(GUIUtil::ThemedColor::TX_STATUS_OPENUNTILDATE);
|
2014-02-20 14:09:09 +01:00
|
|
|
case TransactionStatus::Unconfirmed:
|
2020-09-10 18:28:05 +02:00
|
|
|
return GUIUtil::getIcon("transaction_0");
|
2017-09-09 09:04:02 +02:00
|
|
|
case TransactionStatus::Abandoned:
|
2020-09-23 08:33:46 +02:00
|
|
|
return GUIUtil::getIcon("transaction_abandoned", GUIUtil::ThemedColor::RED);
|
2014-02-20 14:09:09 +01:00
|
|
|
case TransactionStatus::Confirming:
|
|
|
|
switch(wtx->status.depth)
|
2011-07-07 10:29:07 +02:00
|
|
|
{
|
2020-09-23 08:33:46 +02:00
|
|
|
case 1: return GUIUtil::getIcon("transaction_1", GUIUtil::ThemedColor::ORANGE);
|
|
|
|
case 2: return GUIUtil::getIcon("transaction_2", GUIUtil::ThemedColor::ORANGE);
|
|
|
|
case 3: return GUIUtil::getIcon("transaction_3", GUIUtil::ThemedColor::ORANGE);
|
|
|
|
case 4: return GUIUtil::getIcon("transaction_4", GUIUtil::ThemedColor::ORANGE);
|
|
|
|
default: return GUIUtil::getIcon("transaction_5", GUIUtil::ThemedColor::ORANGE);
|
2014-02-20 14:09:09 +01:00
|
|
|
};
|
|
|
|
case TransactionStatus::Confirmed:
|
2020-09-23 08:33:46 +02:00
|
|
|
return GUIUtil::getIcon("synced", GUIUtil::ThemedColor::GREEN);
|
2014-02-20 14:09:09 +01:00
|
|
|
case TransactionStatus::Conflicted:
|
2020-09-23 08:33:46 +02:00
|
|
|
return GUIUtil::getIcon("transaction_0", GUIUtil::ThemedColor::RED, GUIUtil::ThemedColor::RED);
|
2014-02-20 14:09:09 +01:00
|
|
|
case TransactionStatus::Immature: {
|
|
|
|
int total = wtx->status.depth + wtx->status.matures_in;
|
2019-11-21 10:55:56 +01:00
|
|
|
int part = (wtx->status.depth * 5 / total) + 1;
|
2020-09-23 08:33:46 +02:00
|
|
|
return GUIUtil::getIcon(QString("transaction_%1").arg(part), GUIUtil::ThemedColor::ORANGE);
|
2011-07-07 10:29:07 +02:00
|
|
|
}
|
2014-02-20 14:09:09 +01:00
|
|
|
case TransactionStatus::NotAccepted:
|
2020-09-23 08:33:46 +02:00
|
|
|
return GUIUtil::getIcon("transaction_0", GUIUtil::ThemedColor::RED);
|
2014-08-09 15:26:40 +02:00
|
|
|
default:
|
2019-11-22 19:13:47 +01:00
|
|
|
return GUIUtil::getThemedQColor(GUIUtil::ThemedColor::DEFAULT);
|
2011-06-13 09:05:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-10 02:26:04 +02:00
|
|
|
QVariant TransactionTableModel::txWatchonlyDecoration(const TransactionRecord *wtx) const
|
|
|
|
{
|
|
|
|
if (wtx->involvesWatchAddress)
|
2020-09-10 18:28:05 +02:00
|
|
|
return GUIUtil::getIcon("eye");
|
2014-08-10 02:26:04 +02:00
|
|
|
else
|
|
|
|
return QVariant();
|
2011-06-13 09:05:48 +02:00
|
|
|
}
|
|
|
|
|
2011-08-05 15:35:52 +02:00
|
|
|
QString TransactionTableModel::formatTooltip(const TransactionRecord *rec) const
|
|
|
|
{
|
2011-08-06 18:37:41 +02:00
|
|
|
QString tooltip = formatTxStatus(rec) + QString("\n") + formatTxType(rec);
|
2011-12-28 11:14:05 +01:00
|
|
|
if(rec->type==TransactionRecord::RecvFromOther || rec->type==TransactionRecord::SendToOther ||
|
2011-08-05 15:35:52 +02:00
|
|
|
rec->type==TransactionRecord::SendToAddress || rec->type==TransactionRecord::RecvWithAddress)
|
|
|
|
{
|
|
|
|
tooltip += QString(" ") + formatTxToAddress(rec, true);
|
|
|
|
}
|
|
|
|
return tooltip;
|
|
|
|
}
|
|
|
|
|
2011-05-08 16:30:10 +02:00
|
|
|
QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
|
|
|
|
{
|
|
|
|
if(!index.isValid())
|
|
|
|
return QVariant();
|
2011-05-27 08:20:23 +02:00
|
|
|
TransactionRecord *rec = static_cast<TransactionRecord*>(index.internalPointer());
|
2011-05-08 16:30:10 +02:00
|
|
|
|
2020-12-25 21:17:37 +01:00
|
|
|
const auto column = static_cast<ColumnIndex>(index.column());
|
|
|
|
switch (role) {
|
2014-11-06 20:55:52 +01:00
|
|
|
case RawDecorationRole:
|
2020-12-25 21:17:37 +01:00
|
|
|
switch (column) {
|
2011-07-31 17:05:34 +02:00
|
|
|
case Status:
|
2011-08-05 15:35:52 +02:00
|
|
|
return txStatusDecoration(rec);
|
2014-08-10 02:26:04 +02:00
|
|
|
case Watchonly:
|
|
|
|
return txWatchonlyDecoration(rec);
|
2020-12-25 21:17:37 +01:00
|
|
|
case Date: return {};
|
|
|
|
case Type: return {};
|
2011-07-31 17:05:34 +02:00
|
|
|
case ToAddress:
|
|
|
|
return txAddressDecoration(rec);
|
2020-12-25 21:17:37 +01:00
|
|
|
case Amount: return {};
|
|
|
|
} // no default case, so the compiler can warn about missing cases
|
|
|
|
assert(false);
|
2014-11-06 20:55:52 +01:00
|
|
|
case Qt::DecorationRole:
|
|
|
|
{
|
2016-02-15 06:55:52 +01:00
|
|
|
return qvariant_cast<QIcon>(index.data(RawDecorationRole));
|
2014-11-06 20:55:52 +01:00
|
|
|
}
|
2011-08-06 18:37:41 +02:00
|
|
|
case Qt::DisplayRole:
|
2020-12-25 21:17:37 +01:00
|
|
|
switch (column) {
|
|
|
|
case Status: return {};
|
|
|
|
case Watchonly: return {};
|
2011-05-27 08:20:23 +02:00
|
|
|
case Date:
|
|
|
|
return formatTxDate(rec);
|
2011-06-26 22:47:02 +02:00
|
|
|
case Type:
|
|
|
|
return formatTxType(rec);
|
|
|
|
case ToAddress:
|
2011-07-30 17:42:02 +02:00
|
|
|
return formatTxToAddress(rec, false);
|
2011-06-26 22:47:02 +02:00
|
|
|
case Amount:
|
2020-06-18 18:59:20 +02:00
|
|
|
return formatTxAmount(rec, true, BitcoinUnits::SeparatorStyle::ALWAYS);
|
2020-12-25 21:17:37 +01:00
|
|
|
} // no default case, so the compiler can warn about missing cases
|
|
|
|
assert(false);
|
2011-08-06 18:37:41 +02:00
|
|
|
case Qt::EditRole:
|
|
|
|
// Edit role is used for sorting, so return the unformatted values
|
2020-12-25 21:17:37 +01:00
|
|
|
switch (column) {
|
2011-05-28 20:32:19 +02:00
|
|
|
case Status:
|
|
|
|
return QString::fromStdString(rec->status.sortKey);
|
|
|
|
case Date:
|
|
|
|
return rec->time;
|
2011-06-26 22:47:02 +02:00
|
|
|
case Type:
|
|
|
|
return formatTxType(rec);
|
2014-08-10 02:26:04 +02:00
|
|
|
case Watchonly:
|
|
|
|
return (rec->involvesWatchAddress ? 1 : 0);
|
2011-06-26 22:47:02 +02:00
|
|
|
case ToAddress:
|
2011-07-30 17:42:02 +02:00
|
|
|
return formatTxToAddress(rec, true);
|
2011-06-26 22:47:02 +02:00
|
|
|
case Amount:
|
2014-04-23 00:46:19 +02:00
|
|
|
return qint64(rec->credit + rec->debit);
|
2020-12-25 21:17:37 +01:00
|
|
|
} // no default case, so the compiler can warn about missing cases
|
|
|
|
assert(false);
|
2011-08-06 18:37:41 +02:00
|
|
|
case Qt::ToolTipRole:
|
|
|
|
return formatTooltip(rec);
|
|
|
|
case Qt::TextAlignmentRole:
|
2011-05-08 22:23:31 +02:00
|
|
|
return column_alignments[index.column()];
|
2011-08-06 18:37:41 +02:00
|
|
|
case Qt::ForegroundRole:
|
2014-02-20 14:09:09 +01:00
|
|
|
// Non-confirmed (but not immature) as transactions are grey
|
|
|
|
if(!rec->status.countsForBalance && rec->status.status != TransactionStatus::Immature)
|
2011-06-07 18:59:01 +02:00
|
|
|
{
|
2019-11-22 19:13:47 +01:00
|
|
|
return GUIUtil::getThemedQColor(GUIUtil::ThemedColor::UNCONFIRMED);
|
2011-05-27 19:48:42 +02:00
|
|
|
}
|
2020-09-23 08:33:46 +02:00
|
|
|
if (index.column() == Amount) {
|
|
|
|
return amountColor(rec);
|
2011-06-26 22:47:02 +02:00
|
|
|
}
|
2011-07-30 17:42:02 +02:00
|
|
|
if(index.column() == ToAddress)
|
|
|
|
{
|
|
|
|
return addressColor(rec);
|
|
|
|
}
|
2019-11-22 19:13:47 +01:00
|
|
|
return GUIUtil::getThemedQColor(GUIUtil::ThemedColor::DEFAULT);
|
2011-08-06 18:37:41 +02:00
|
|
|
case TypeRole:
|
2011-06-28 21:41:56 +02:00
|
|
|
return rec->type;
|
2011-08-06 18:37:41 +02:00
|
|
|
case DateRole:
|
2011-06-28 21:41:56 +02:00
|
|
|
return QDateTime::fromTime_t(static_cast<uint>(rec->time));
|
2019-10-19 12:39:02 +02:00
|
|
|
case DateRoleInt:
|
|
|
|
return qint64(rec->time);
|
2014-08-10 02:26:04 +02:00
|
|
|
case WatchonlyRole:
|
|
|
|
return rec->involvesWatchAddress;
|
|
|
|
case WatchonlyDecorationRole:
|
|
|
|
return txWatchonlyDecoration(rec);
|
2011-08-06 18:37:41 +02:00
|
|
|
case LongDescriptionRole:
|
2017-04-18 22:42:30 +02:00
|
|
|
return priv->describe(walletModel->node(), walletModel->wallet(), rec, walletModel->getOptionsModel()->getDisplayUnit());
|
2011-08-06 18:37:41 +02:00
|
|
|
case AddressRole:
|
2019-10-19 12:39:02 +02:00
|
|
|
return QString::fromStdString(rec->strAddress);
|
2011-08-06 18:37:41 +02:00
|
|
|
case LabelRole:
|
2021-02-15 00:27:28 +01:00
|
|
|
return rec->label;
|
2011-08-06 18:37:41 +02:00
|
|
|
case AmountRole:
|
2014-04-23 00:46:19 +02:00
|
|
|
return qint64(rec->credit + rec->debit);
|
2014-04-24 22:21:45 +02:00
|
|
|
case TxHashRole:
|
2018-03-07 16:48:09 +01:00
|
|
|
return rec->getTxHash();
|
2015-11-17 11:17:09 +01:00
|
|
|
case TxHexRole:
|
2017-04-18 22:42:30 +02:00
|
|
|
return priv->getTxHex(walletModel->wallet(), rec);
|
2017-09-07 17:59:00 +02:00
|
|
|
case TxPlainTextRole:
|
|
|
|
{
|
|
|
|
QString details;
|
2021-02-15 00:27:28 +01:00
|
|
|
QString txLabel = rec->label;
|
2017-09-07 17:59:00 +02:00
|
|
|
|
|
|
|
details.append(formatTxDate(rec));
|
|
|
|
details.append(" ");
|
|
|
|
details.append(formatTxStatus(rec));
|
|
|
|
details.append(". ");
|
|
|
|
if(!formatTxType(rec).isEmpty()) {
|
|
|
|
details.append(formatTxType(rec));
|
|
|
|
details.append(" ");
|
|
|
|
}
|
2019-10-19 12:39:02 +02:00
|
|
|
if(!rec->strAddress.empty()) {
|
2017-09-07 17:59:00 +02:00
|
|
|
if(txLabel.isEmpty())
|
|
|
|
details.append(tr("(no label)") + " ");
|
|
|
|
else {
|
|
|
|
details.append("(");
|
|
|
|
details.append(txLabel);
|
|
|
|
details.append(") ");
|
|
|
|
}
|
2019-10-19 12:39:02 +02:00
|
|
|
details.append(QString::fromStdString(rec->strAddress));
|
2017-09-07 17:59:00 +02:00
|
|
|
details.append(" ");
|
|
|
|
}
|
2020-06-18 18:59:20 +02:00
|
|
|
details.append(formatTxAmount(rec, false, BitcoinUnits::SeparatorStyle::NEVER));
|
2017-09-07 17:59:00 +02:00
|
|
|
return details;
|
|
|
|
}
|
2011-08-06 18:37:41 +02:00
|
|
|
case ConfirmedRole:
|
2020-05-29 14:42:42 +02:00
|
|
|
return rec->status.status == TransactionStatus::Status::Confirming || rec->status.status == TransactionStatus::Status::Confirmed;
|
2011-08-06 18:37:41 +02:00
|
|
|
case FormattedAmountRole:
|
2014-07-25 17:43:41 +02:00
|
|
|
// Used for copy/export, so don't include separators
|
2020-06-18 18:59:20 +02:00
|
|
|
return formatTxAmount(rec, false, BitcoinUnits::SeparatorStyle::NEVER);
|
2014-02-14 07:59:07 +01:00
|
|
|
case StatusRole:
|
|
|
|
return rec->status.status;
|
2011-07-07 14:27:16 +02:00
|
|
|
}
|
2011-05-08 16:30:10 +02:00
|
|
|
return QVariant();
|
|
|
|
}
|
|
|
|
|
|
|
|
QVariant TransactionTableModel::headerData(int section, Qt::Orientation orientation, int role) const
|
|
|
|
{
|
2011-05-28 16:09:23 +02:00
|
|
|
if(orientation == Qt::Horizontal)
|
2011-05-08 22:23:31 +02:00
|
|
|
{
|
2011-05-28 16:09:23 +02:00
|
|
|
if(role == Qt::DisplayRole)
|
2011-05-08 22:23:31 +02:00
|
|
|
{
|
|
|
|
return columns[section];
|
2011-06-07 18:59:01 +02:00
|
|
|
}
|
|
|
|
else if (role == Qt::TextAlignmentRole)
|
2011-05-28 16:09:23 +02:00
|
|
|
{
|
|
|
|
return column_alignments[section];
|
2011-06-14 21:06:00 +02:00
|
|
|
} else if (role == Qt::ToolTipRole)
|
|
|
|
{
|
|
|
|
switch(section)
|
|
|
|
{
|
|
|
|
case Status:
|
2011-06-24 21:45:33 +02:00
|
|
|
return tr("Transaction status. Hover over this field to show number of confirmations.");
|
2011-06-14 21:06:00 +02:00
|
|
|
case Date:
|
|
|
|
return tr("Date and time that the transaction was received.");
|
2011-06-26 22:47:02 +02:00
|
|
|
case Type:
|
|
|
|
return tr("Type of transaction.");
|
2014-08-10 02:26:04 +02:00
|
|
|
case Watchonly:
|
|
|
|
return tr("Whether or not a watch-only address is involved in this transaction.");
|
2011-06-26 22:47:02 +02:00
|
|
|
case ToAddress:
|
2015-02-26 21:14:34 +01:00
|
|
|
return tr("User-defined intent/purpose of the transaction.");
|
2011-06-26 22:47:02 +02:00
|
|
|
case Amount:
|
|
|
|
return tr("Amount removed from or added to balance.");
|
2011-06-14 21:06:00 +02:00
|
|
|
}
|
2011-05-08 22:23:31 +02:00
|
|
|
}
|
2011-05-08 16:30:10 +02:00
|
|
|
}
|
|
|
|
return QVariant();
|
|
|
|
}
|
|
|
|
|
2011-06-01 15:33:33 +02:00
|
|
|
QModelIndex TransactionTableModel::index(int row, int column, const QModelIndex &parent) const
|
2011-05-27 08:20:23 +02:00
|
|
|
{
|
|
|
|
Q_UNUSED(parent);
|
2023-04-10 22:02:17 +02:00
|
|
|
TransactionRecord *data = priv->index(walletModel->wallet(), walletModel->getLastBlockProcessed(), row);
|
2018-08-01 19:38:45 +02:00
|
|
|
if (data) {
|
|
|
|
return createIndex(row, column, data);
|
2011-06-07 18:59:01 +02:00
|
|
|
}
|
2014-08-09 15:29:55 +02:00
|
|
|
return QModelIndex();
|
2011-05-27 08:20:23 +02:00
|
|
|
}
|
|
|
|
|
2012-06-18 22:48:35 +02:00
|
|
|
void TransactionTableModel::updateDisplayUnit()
|
|
|
|
{
|
|
|
|
// emit dataChanged to update Amount column with the current unit
|
2014-06-07 08:20:22 +02:00
|
|
|
updateAmountColumnTitle();
|
2015-07-14 13:59:05 +02:00
|
|
|
Q_EMIT dataChanged(index(0, Amount), index(priv->size()-1, Amount));
|
2012-06-18 22:48:35 +02:00
|
|
|
}
|
2015-02-10 14:24:05 +01:00
|
|
|
|
2020-11-12 12:23:51 +01:00
|
|
|
void TransactionTablePriv::NotifyTransactionChanged(const uint256 &hash, ChangeType status)
|
2015-02-10 14:24:05 +01:00
|
|
|
{
|
|
|
|
// Find transaction in wallet
|
|
|
|
// Determine whether to show transaction or not (determine this here so that no relocking is needed in GUI thread)
|
2017-04-18 22:42:30 +02:00
|
|
|
bool showTransaction = TransactionRecord::showTransaction();
|
2015-02-10 14:24:05 +01:00
|
|
|
|
|
|
|
TransactionNotification notification(hash, status, showTransaction);
|
|
|
|
|
|
|
|
if (fQueueNotifications)
|
|
|
|
{
|
|
|
|
vQueueNotifications.push_back(notification);
|
|
|
|
return;
|
|
|
|
}
|
2020-11-12 12:23:51 +01:00
|
|
|
notification.invoke(parent);
|
2015-02-10 14:24:05 +01:00
|
|
|
}
|
|
|
|
|
2020-11-12 12:23:51 +01:00
|
|
|
void TransactionTablePriv::NotifyAddressBookChanged(const CTxDestination &address, const std::string &label, bool isMine, const std::string &purpose, ChangeType status)
|
2019-10-19 12:39:02 +02:00
|
|
|
{
|
2020-11-12 12:23:51 +01:00
|
|
|
bool invoked = QMetaObject::invokeMethod(parent, "updateAddressBook", Qt::QueuedConnection,
|
Merge #11117: Prepare for non-Base58 addresses (#3294)
* Merge #11117: Prepare for non-Base58 addresses
864cd2787 Move CBitcoinAddress to base58.cpp (Pieter Wuille)
5c8ff0d44 Introduce wrappers around CBitcoinAddress (Pieter Wuille)
Pull request description:
This patch removes the need for the intermediary Base58 type `CBitcoinAddress`, by providing {`Encode`,`Decode`,`IsValid`}`Destination` functions that directly operate on the conversion between `std::string`s and `CTxDestination`.
As a side, it also fixes a number of indentation issues, and removes probably several unnecessary implicit `CTxDestination`<->`CBitcoinAddress` conversions.
This change is far from complete. In follow-ups I'd like to:
* Split off the specific address and key encoding logic from base58.h, and move it to a address.h or so.
* Replace `CTxDestination` with a non-`boost::variant` version (which can be more efficient as `boost::variant` allocates everything on the heap, and remove the need for `boost::get<...>` and `IsValidDestination` calls everywhere).
* Do the same for `CBitcoinSecret`, `CBitcoinExtKey`, and `CBitcoinExtPubKey`.
However, I've tried to keep this patch to be minimally invasive, but still enough to support non-Base58 addresses. Perhaps a smaller patch is possible to hack Bech32 support into `CBitcoinAddress`, but I would consider that a move in the wrong direction.
Tree-SHA512: c2c77ffb57caeadf2429b1c2562ce60e8c7be8aa9f8e51b591f354b6b441162625b2efe14c023a1ae485cf2ed417263afa35c892891dfaa7844e7fbabccab85e
* CBitcoinAddress -> EncodeDestination in providertx.h
Signed-off-by: Pasta <pasta@dashboost.org>
* more CBitcoinAddress -> EncodeDestination in providertx.h
Signed-off-by: Pasta <pasta@dashboost.org>
* more CBitcoinAddress -> EncodeDestination in providertx.h
Signed-off-by: Pasta <pasta@dashboost.org>
* more CBitcoinAddress -> EncodeDestination in providertx.h
Signed-off-by: Pasta <pasta@dashboost.org>
* fix CBitcoinAddress GetKeyID check
Signed-off-by: Pasta <pasta@dashboost.org>
* fix providertx.cpp
Signed-off-by: Pasta <pasta@dashboost.org>
* hopefully fix governance-classes.cpp
Signed-off-by: Pasta <pasta@dashboost.org>
* partially fix governance-validators.cpp, unable to resolve "address.IsScript()"
Signed-off-by: Pasta <pasta@dashboost.org>
* partially fix governance-classes.cpp, unable to resolve "address.IsScript()"
Signed-off-by: Pasta <pasta@dashboost.org>
* fix governance-classes.h
Signed-off-by: Pasta <pasta@dashboost.org>
* DecodeTransaction -> DecodeDestination, fix governance-validators.cpp
Signed-off-by: Pasta <pasta@dashboost.org>
* More fixes for 3294
* Move GetIndexKey into rpc/misc.cpp near getAddressesFromParams
No need to have it in base58.cpp anymore as this is only used in getAddressesFromParams
Co-authored-by: Wladimir J. van der Laan <laanwj@gmail.com>
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
Co-authored-by: Alexander Block <ablock84@gmail.com>
2020-01-22 11:35:04 +01:00
|
|
|
Q_ARG(QString, QString::fromStdString(EncodeDestination(address))),
|
2019-10-19 12:39:02 +02:00
|
|
|
Q_ARG(QString, QString::fromStdString(label)),
|
|
|
|
Q_ARG(bool, isMine),
|
|
|
|
Q_ARG(QString, QString::fromStdString(purpose)),
|
|
|
|
Q_ARG(int, (int)status));
|
2019-07-09 11:47:55 +02:00
|
|
|
assert(invoked);
|
2019-10-19 12:39:02 +02:00
|
|
|
}
|
|
|
|
|
2020-11-12 12:23:51 +01:00
|
|
|
void TransactionTablePriv::ShowProgress(const std::string &title, int nProgress)
|
2015-02-10 14:24:05 +01:00
|
|
|
{
|
|
|
|
if (nProgress == 0)
|
|
|
|
fQueueNotifications = true;
|
|
|
|
|
|
|
|
if (nProgress == 100)
|
|
|
|
{
|
|
|
|
fQueueNotifications = false;
|
2023-06-28 18:00:18 +02:00
|
|
|
if (vQueueNotifications.size() < 10000) {
|
|
|
|
if (vQueueNotifications.size() > 10) { // prevent balloon spam, show maximum 10 balloons
|
2020-11-12 12:23:51 +01:00
|
|
|
bool invoked = QMetaObject::invokeMethod(parent, "setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(bool, true));
|
2019-07-09 11:47:55 +02:00
|
|
|
assert(invoked);
|
|
|
|
}
|
2023-06-28 18:00:18 +02:00
|
|
|
for (unsigned int i = 0; i < vQueueNotifications.size(); ++i)
|
|
|
|
{
|
|
|
|
if (vQueueNotifications.size() - i <= 10) {
|
2020-11-12 12:23:51 +01:00
|
|
|
bool invoked = QMetaObject::invokeMethod(parent, "setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(bool, false));
|
2023-06-28 18:00:18 +02:00
|
|
|
assert(invoked);
|
|
|
|
}
|
2015-02-10 14:24:05 +01:00
|
|
|
|
2020-11-12 12:23:51 +01:00
|
|
|
vQueueNotifications[i].invoke(parent);
|
2023-06-28 18:00:18 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// it's much faster to just refresh the whole thing instead
|
2020-11-12 12:23:51 +01:00
|
|
|
bool invoked = QMetaObject::invokeMethod(parent, "refreshWallet", Qt::QueuedConnection);
|
2023-06-28 18:00:18 +02:00
|
|
|
assert(invoked);
|
2015-02-10 14:24:05 +01:00
|
|
|
}
|
2020-11-12 12:23:51 +01:00
|
|
|
vQueueNotifications.clear();
|
2015-02-10 14:24:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TransactionTableModel::subscribeToCoreSignals()
|
|
|
|
{
|
|
|
|
// Connect signals to wallet
|
2020-11-12 12:23:51 +01:00
|
|
|
m_handler_transaction_changed = walletModel->wallet().handleTransactionChanged(std::bind(&TransactionTablePriv::NotifyTransactionChanged, priv, std::placeholders::_1, std::placeholders::_2));
|
|
|
|
m_handler_address_book_changed = walletModel->wallet().handleAddressBookChanged(std::bind(&TransactionTablePriv::NotifyAddressBookChanged, priv, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5));
|
|
|
|
m_handler_show_progress = walletModel->wallet().handleShowProgress(std::bind(&TransactionTablePriv::ShowProgress, priv, std::placeholders::_1, std::placeholders::_2));
|
2015-02-10 14:24:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void TransactionTableModel::unsubscribeFromCoreSignals()
|
|
|
|
{
|
|
|
|
// Disconnect signals from wallet
|
2017-04-18 22:42:30 +02:00
|
|
|
m_handler_transaction_changed->disconnect();
|
|
|
|
m_handler_address_book_changed->disconnect();
|
|
|
|
m_handler_show_progress->disconnect();
|
2015-02-10 14:24:05 +01:00
|
|
|
}
|