Merge bitcoin/bitcoin#32238: qt, wallet: Convert uint256 to Txid
0671d66a8ewallet, refactor: Convert uint256 to Txid in wallet (marcofleon)c8ed51e62bwallet, refactor: Convert uint256 to Txid in wallet interfaces (marcofleon)b3214cefe6qt, refactor: Convert uint256 to Txid in the GUI (marcofleon) Pull request description: This is part of https://github.com/bitcoin/bitcoin/pull/32189. Converts all instances of transactions from `uint256` to `Txid` in the wallet, GUI, and related interfaces. ACKs for top commit: stickies-v: re-ACK0671d66a8e, no changes since 65fcfbb2b38bef20a58daa6c828c51890180611d except rebase. achow101: ACK0671d66a8efurszy: Code review ACK0671d66a8eTree-SHA512: 9fd4675db63195c4eed2d14c25015a1821fb597f51404674e4879a44a9cf18f475021a97c5f62f3926b7783ade5a38567386f663acba9f5861f1f59c1309ed60
This commit is contained in:
28 files changed
+155
-150
No files matched your search
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <qt/clientmodel.h>
|
||||
#include <qt/walletmodel.h>
|
||||
#include <util/transaction_identifier.h>
|
||||
|
||||
#include <QDialog>
|
||||
#include <QMessageBox>
|
||||
@@ -61,7 +62,7 @@ public Q_SLOTS:
|
||||
void setBalance(const interfaces::WalletBalances& balances);
|
||||
|
||||
Q_SIGNALS:
|
||||
void coinsSent(const uint256& txid);
|
||||
void coinsSent(const Txid& txid);
|
||||
|
||||
private:
|
||||
Ui::SendCoinsDialog *ui;
|
||||
|
||||
@@ -75,7 +75,7 @@ void ConfirmSend(QString* text = nullptr, QMessageBox::StandardButton confirm_ty
|
||||
}
|
||||
|
||||
//! Send coins to address and return txid.
|
||||
uint256 SendCoins(CWallet& wallet, SendCoinsDialog& sendCoinsDialog, const CTxDestination& address, CAmount amount, bool rbf,
|
||||
Txid SendCoins(CWallet& wallet, SendCoinsDialog& sendCoinsDialog, const CTxDestination& address, CAmount amount, bool rbf,
|
||||
QMessageBox::StandardButton confirm_type = QMessageBox::Yes)
|
||||
{
|
||||
QVBoxLayout* entries = sendCoinsDialog.findChild<QVBoxLayout*>("entries");
|
||||
@@ -86,8 +86,8 @@ uint256 SendCoins(CWallet& wallet, SendCoinsDialog& sendCoinsDialog, const CTxDe
|
||||
->findChild<QFrame*>("frameFeeSelection")
|
||||
->findChild<QCheckBox*>("optInRBF")
|
||||
->setCheckState(rbf ? Qt::Checked : Qt::Unchecked);
|
||||
uint256 txid;
|
||||
boost::signals2::scoped_connection c(wallet.NotifyTransactionChanged.connect([&txid](const uint256& hash, ChangeType status) {
|
||||
Txid txid;
|
||||
boost::signals2::scoped_connection c(wallet.NotifyTransactionChanged.connect([&txid](const Txid& hash, ChangeType status) {
|
||||
if (status == CT_NEW) txid = hash;
|
||||
}));
|
||||
ConfirmSend(/*text=*/nullptr, confirm_type);
|
||||
@@ -97,7 +97,7 @@ uint256 SendCoins(CWallet& wallet, SendCoinsDialog& sendCoinsDialog, const CTxDe
|
||||
}
|
||||
|
||||
//! Find index of txid in transaction list.
|
||||
QModelIndex FindTx(const QAbstractItemModel& model, const uint256& txid)
|
||||
QModelIndex FindTx(const QAbstractItemModel& model, const Txid& txid)
|
||||
{
|
||||
QString hash = QString::fromStdString(txid.ToString());
|
||||
int rows = model.rowCount({});
|
||||
@@ -111,7 +111,7 @@ QModelIndex FindTx(const QAbstractItemModel& model, const uint256& txid)
|
||||
}
|
||||
|
||||
//! Invoke bumpfee on txid and check results.
|
||||
void BumpFee(TransactionView& view, const uint256& txid, bool expectDisabled, std::string expectError, bool cancel)
|
||||
void BumpFee(TransactionView& view, const Txid& txid, bool expectDisabled, std::string expectError, bool cancel)
|
||||
{
|
||||
QTableView* table = view.findChild<QTableView*>("transactionView");
|
||||
QModelIndex index = FindTx(*table->selectionModel()->model(), txid);
|
||||
@@ -285,8 +285,8 @@ void TestGUI(interfaces::Node& node, const std::shared_ptr<CWallet>& wallet)
|
||||
// Send two transactions, and verify they are added to transaction list.
|
||||
TransactionTableModel* transactionTableModel = walletModel.getTransactionTableModel();
|
||||
QCOMPARE(transactionTableModel->rowCount({}), 105);
|
||||
uint256 txid1 = SendCoins(*wallet.get(), sendCoinsDialog, PKHash(), 5 * COIN, /*rbf=*/false);
|
||||
uint256 txid2 = SendCoins(*wallet.get(), sendCoinsDialog, PKHash(), 10 * COIN, /*rbf=*/true);
|
||||
Txid txid1 = SendCoins(*wallet.get(), sendCoinsDialog, PKHash(), 5 * COIN, /*rbf=*/false);
|
||||
Txid txid2 = SendCoins(*wallet.get(), sendCoinsDialog, PKHash(), 10 * COIN, /*rbf=*/true);
|
||||
// Transaction table model updates on a QueuedConnection, so process events to ensure it's updated.
|
||||
qApp->processEvents();
|
||||
QCOMPARE(transactionTableModel->rowCount({}), 107);
|
||||
|
||||
@@ -37,7 +37,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const interface
|
||||
CAmount nCredit = wtx.credit;
|
||||
CAmount nDebit = wtx.debit;
|
||||
CAmount nNet = nCredit - nDebit;
|
||||
uint256 hash = wtx.tx->GetHash();
|
||||
Txid hash = wtx.tx->GetHash();
|
||||
std::map<std::string, std::string> mapValue = wtx.value_map;
|
||||
|
||||
bool involvesWatchAddress = false;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <consensus/amount.h>
|
||||
#include <uint256.h>
|
||||
#include <util/transaction_identifier.h>
|
||||
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
@@ -79,13 +80,13 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
TransactionRecord(uint256 _hash, qint64 _time):
|
||||
TransactionRecord(Txid _hash, qint64 _time):
|
||||
hash(_hash), time(_time), type(Other), debit(0),
|
||||
credit(0), idx(0)
|
||||
{
|
||||
}
|
||||
|
||||
TransactionRecord(uint256 _hash, qint64 _time,
|
||||
TransactionRecord(Txid _hash, qint64 _time,
|
||||
Type _type, const std::string &_address,
|
||||
const CAmount& _debit, const CAmount& _credit):
|
||||
hash(_hash), time(_time), type(_type), address(_address), debit(_debit), credit(_credit),
|
||||
@@ -100,7 +101,7 @@ public:
|
||||
|
||||
/** @name Immutable transaction attributes
|
||||
@{*/
|
||||
uint256 hash;
|
||||
Txid hash;
|
||||
qint64 time;
|
||||
Type type;
|
||||
std::string address;
|
||||
|
||||
@@ -49,11 +49,11 @@ struct TxLessThan
|
||||
{
|
||||
return a.hash < b.hash;
|
||||
}
|
||||
bool operator()(const TransactionRecord &a, const uint256 &b) const
|
||||
bool operator()(const TransactionRecord &a, const Txid &b) const
|
||||
{
|
||||
return a.hash < b;
|
||||
}
|
||||
bool operator()(const uint256 &a, const TransactionRecord &b) const
|
||||
bool operator()(const Txid &a, const TransactionRecord &b) const
|
||||
{
|
||||
return a < b.hash;
|
||||
}
|
||||
@@ -64,7 +64,7 @@ struct TransactionNotification
|
||||
{
|
||||
public:
|
||||
TransactionNotification() = default;
|
||||
TransactionNotification(uint256 _hash, ChangeType _status, bool _showTransaction):
|
||||
TransactionNotification(Txid _hash, ChangeType _status, bool _showTransaction):
|
||||
hash(_hash), status(_status), showTransaction(_showTransaction) {}
|
||||
|
||||
void invoke(QObject *ttm)
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
assert(invoked);
|
||||
}
|
||||
private:
|
||||
uint256 hash;
|
||||
Txid hash;
|
||||
ChangeType status;
|
||||
bool showTransaction;
|
||||
};
|
||||
@@ -103,7 +103,7 @@ public:
|
||||
bool m_loading = false;
|
||||
std::vector< TransactionNotification > vQueueNotifications;
|
||||
|
||||
void NotifyTransactionChanged(const uint256 &hash, ChangeType status);
|
||||
void NotifyTransactionChanged(const Txid& hash, ChangeType status);
|
||||
void DispatchNotifications();
|
||||
|
||||
/* Query entire wallet anew from core.
|
||||
@@ -127,7 +127,7 @@ public:
|
||||
|
||||
Call with transaction that was added, removed or changed.
|
||||
*/
|
||||
void updateWallet(interfaces::Wallet& wallet, const uint256 &hash, int status, bool showTransaction)
|
||||
void updateWallet(interfaces::Wallet& wallet, const Txid& hash, int status, bool showTransaction)
|
||||
{
|
||||
qDebug() << "TransactionTablePriv::updateWallet: " + QString::fromStdString(hash.ToString()) + " " + QString::number(status);
|
||||
|
||||
@@ -699,7 +699,7 @@ void TransactionTableModel::updateDisplayUnit()
|
||||
Q_EMIT dataChanged(index(0, Amount), index(priv->size()-1, Amount));
|
||||
}
|
||||
|
||||
void TransactionTablePriv::NotifyTransactionChanged(const uint256 &hash, ChangeType status)
|
||||
void TransactionTablePriv::NotifyTransactionChanged(const Txid& hash, ChangeType status)
|
||||
{
|
||||
// Find transaction in wallet
|
||||
// Determine whether to show transaction or not (determine this here so that no relocking is needed in GUI thread)
|
||||
|
||||
@@ -193,7 +193,7 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
|
||||
// Double-clicking on a transaction on the transaction history page shows details
|
||||
connect(this, &TransactionView::doubleClicked, this, &TransactionView::showDetails);
|
||||
// Highlight transaction after fee bump
|
||||
connect(this, &TransactionView::bumpedFee, [this](const uint256& txid) {
|
||||
connect(this, &TransactionView::bumpedFee, [this](const Txid& txid) {
|
||||
focusTransaction(txid);
|
||||
});
|
||||
}
|
||||
@@ -431,7 +431,7 @@ void TransactionView::bumpFee([[maybe_unused]] bool checked)
|
||||
Txid hash = Txid::FromHex(hashQStr.toStdString()).value();
|
||||
|
||||
// Bump tx fee over the walletModel
|
||||
uint256 newHash;
|
||||
Txid newHash;
|
||||
if (model->bumpFee(hash, newHash)) {
|
||||
// Update the table
|
||||
transactionView->selectionModel()->clearSelection();
|
||||
@@ -599,7 +599,7 @@ void TransactionView::focusTransaction(const QModelIndex &idx)
|
||||
transactionView->setFocus();
|
||||
}
|
||||
|
||||
void TransactionView::focusTransaction(const uint256& txid)
|
||||
void TransactionView::focusTransaction(const Txid& txid)
|
||||
{
|
||||
if (!transactionProxyModel)
|
||||
return;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <qt/guiutil.h>
|
||||
|
||||
#include <uint256.h>
|
||||
#include <util/transaction_identifier.h>
|
||||
|
||||
#include <QWidget>
|
||||
#include <QKeyEvent>
|
||||
@@ -115,7 +116,7 @@ Q_SIGNALS:
|
||||
/** Fired when a message should be reported to the user */
|
||||
void message(const QString &title, const QString &message, unsigned int style);
|
||||
|
||||
void bumpedFee(const uint256& txid);
|
||||
void bumpedFee(const Txid& txid);
|
||||
|
||||
public Q_SLOTS:
|
||||
void chooseDate(int idx);
|
||||
@@ -126,7 +127,7 @@ public Q_SLOTS:
|
||||
void exportClicked();
|
||||
void closeOpenedDialogs();
|
||||
void focusTransaction(const QModelIndex&);
|
||||
void focusTransaction(const uint256& txid);
|
||||
void focusTransaction(const Txid& txid);
|
||||
};
|
||||
|
||||
#endif // BITCOIN_QT_TRANSACTIONVIEW_H
|
||||
@@ -381,7 +381,7 @@ static void NotifyAddressBookChanged(WalletModel *walletmodel,
|
||||
assert(invoked);
|
||||
}
|
||||
|
||||
static void NotifyTransactionChanged(WalletModel *walletmodel, const uint256 &hash, ChangeType status)
|
||||
static void NotifyTransactionChanged(WalletModel *walletmodel, const Txid& hash, ChangeType status)
|
||||
{
|
||||
Q_UNUSED(hash);
|
||||
Q_UNUSED(status);
|
||||
@@ -463,7 +463,7 @@ WalletModel::UnlockContext::~UnlockContext()
|
||||
}
|
||||
}
|
||||
|
||||
bool WalletModel::bumpFee(uint256 hash, uint256& new_hash)
|
||||
bool WalletModel::bumpFee(Txid hash, Txid& new_hash)
|
||||
{
|
||||
CCoinControl coin_control;
|
||||
coin_control.m_signal_bip125_rbf = true;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include <interfaces/wallet.h>
|
||||
#include <support/allocators/secure.h>
|
||||
#include <util/transaction_identifier.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
@@ -129,7 +130,7 @@ public:
|
||||
|
||||
UnlockContext requestUnlock();
|
||||
|
||||
bool bumpFee(uint256 hash, uint256& new_hash);
|
||||
bool bumpFee(Txid hash, Txid& new_hash);
|
||||
void displayAddress(std::string sAddress) const;
|
||||
|
||||
static bool isWalletEnabled();
|
||||
|
||||
@@ -82,7 +82,7 @@ WalletView::WalletView(WalletModel* wallet_model, const PlatformStyle* _platform
|
||||
|
||||
connect(sendCoinsPage, &SendCoinsDialog::coinsSent, this, &WalletView::coinsSent);
|
||||
// Highlight transaction after send
|
||||
connect(sendCoinsPage, &SendCoinsDialog::coinsSent, transactionView, qOverload<const uint256&>(&TransactionView::focusTransaction));
|
||||
connect(sendCoinsPage, &SendCoinsDialog::coinsSent, transactionView, qOverload<const Txid&>(&TransactionView::focusTransaction));
|
||||
|
||||
// Clicking on "Export" allows to export the transaction list
|
||||
connect(exportButton, &QPushButton::clicked, transactionView, &TransactionView::exportClicked);
|
||||
|
||||
Reference in new issue
Block a user