Skip to content

Commit 51be79c

Browse files
committed
Merge bitcoin/bitcoin#32238: qt, wallet: Convert uint256 to Txid
0671d66 wallet, refactor: Convert uint256 to Txid in wallet (marcofleon) c8ed51e wallet, refactor: Convert uint256 to Txid in wallet interfaces (marcofleon) b3214ce qt, refactor: Convert uint256 to Txid in the GUI (marcofleon) Pull request description: This is part of bitcoin/bitcoin#32189. Converts all instances of transactions from `uint256` to `Txid` in the wallet, GUI, and related interfaces. ACKs for top commit: stickies-v: re-ACK 0671d66, no changes since 65fcfbb2b38bef20a58daa6c828c51890180611d except rebase. achow101: ACK 0671d66 furszy: Code review ACK 0671d66 Tree-SHA512: 9fd4675db63195c4eed2d14c25015a1821fb597f51404674e4879a44a9cf18f475021a97c5f62f3926b7783ade5a38567386f663acba9f5861f1f59c1309ed60
2 parents f96ae94 + 0671d66 commit 51be79c

28 files changed

+155
-150
lines changed

src/interfaces/wallet.h

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <support/allocators/secure.h>
1515
#include <util/fs.h>
1616
#include <util/result.h>
17+
#include <util/transaction_identifier.h>
1718
#include <util/ui_change_type.h>
1819

1920
#include <cstdint>
@@ -156,16 +157,16 @@ class Wallet
156157
WalletOrderForm order_form) = 0;
157158

158159
//! Return whether transaction can be abandoned.
159-
virtual bool transactionCanBeAbandoned(const uint256& txid) = 0;
160+
virtual bool transactionCanBeAbandoned(const Txid& txid) = 0;
160161

161162
//! Abandon transaction.
162-
virtual bool abandonTransaction(const uint256& txid) = 0;
163+
virtual bool abandonTransaction(const Txid& txid) = 0;
163164

164165
//! Return whether transaction can be bumped.
165-
virtual bool transactionCanBeBumped(const uint256& txid) = 0;
166+
virtual bool transactionCanBeBumped(const Txid& txid) = 0;
166167

167168
//! Create bump transaction.
168-
virtual bool createBumpTransaction(const uint256& txid,
169+
virtual bool createBumpTransaction(const Txid& txid,
169170
const wallet::CCoinControl& coin_control,
170171
std::vector<bilingual_str>& errors,
171172
CAmount& old_fee,
@@ -176,28 +177,28 @@ class Wallet
176177
virtual bool signBumpTransaction(CMutableTransaction& mtx) = 0;
177178

178179
//! Commit bump transaction.
179-
virtual bool commitBumpTransaction(const uint256& txid,
180+
virtual bool commitBumpTransaction(const Txid& txid,
180181
CMutableTransaction&& mtx,
181182
std::vector<bilingual_str>& errors,
182-
uint256& bumped_txid) = 0;
183+
Txid& bumped_txid) = 0;
183184

184185
//! Get a transaction.
185-
virtual CTransactionRef getTx(const uint256& txid) = 0;
186+
virtual CTransactionRef getTx(const Txid& txid) = 0;
186187

187188
//! Get transaction information.
188-
virtual WalletTx getWalletTx(const uint256& txid) = 0;
189+
virtual WalletTx getWalletTx(const Txid& txid) = 0;
189190

190191
//! Get list of all wallet transactions.
191192
virtual std::set<WalletTx> getWalletTxs() = 0;
192193

193194
//! Try to get updated status for a particular transaction, if possible without blocking.
194-
virtual bool tryGetTxStatus(const uint256& txid,
195+
virtual bool tryGetTxStatus(const Txid& txid,
195196
WalletTxStatus& tx_status,
196197
int& num_blocks,
197198
int64_t& block_time) = 0;
198199

199200
//! Get transaction details.
200-
virtual WalletTx getWalletTxDetails(const uint256& txid,
201+
virtual WalletTx getWalletTxDetails(const Txid& txid,
201202
WalletTxStatus& tx_status,
202203
WalletOrderForm& order_form,
203204
bool& in_mempool,
@@ -300,7 +301,7 @@ class Wallet
300301
virtual std::unique_ptr<Handler> handleAddressBookChanged(AddressBookChangedFn fn) = 0;
301302

302303
//! Register handler for transaction changed messages.
303-
using TransactionChangedFn = std::function<void(const uint256& txid, ChangeType status)>;
304+
using TransactionChangedFn = std::function<void(const Txid& txid, ChangeType status)>;
304305
virtual std::unique_ptr<Handler> handleTransactionChanged(TransactionChangedFn fn) = 0;
305306

306307
//! Register handler for keypool changed messages.

src/qt/sendcoinsdialog.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <qt/clientmodel.h>
99
#include <qt/walletmodel.h>
10+
#include <util/transaction_identifier.h>
1011

1112
#include <QDialog>
1213
#include <QMessageBox>
@@ -61,7 +62,7 @@ public Q_SLOTS:
6162
void setBalance(const interfaces::WalletBalances& balances);
6263

6364
Q_SIGNALS:
64-
void coinsSent(const uint256& txid);
65+
void coinsSent(const Txid& txid);
6566

6667
private:
6768
Ui::SendCoinsDialog *ui;

src/qt/test/wallettests.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void ConfirmSend(QString* text = nullptr, QMessageBox::StandardButton confirm_ty
7575
}
7676

7777
//! Send coins to address and return txid.
78-
uint256 SendCoins(CWallet& wallet, SendCoinsDialog& sendCoinsDialog, const CTxDestination& address, CAmount amount, bool rbf,
78+
Txid SendCoins(CWallet& wallet, SendCoinsDialog& sendCoinsDialog, const CTxDestination& address, CAmount amount, bool rbf,
7979
QMessageBox::StandardButton confirm_type = QMessageBox::Yes)
8080
{
8181
QVBoxLayout* entries = sendCoinsDialog.findChild<QVBoxLayout*>("entries");
@@ -86,8 +86,8 @@ uint256 SendCoins(CWallet& wallet, SendCoinsDialog& sendCoinsDialog, const CTxDe
8686
->findChild<QFrame*>("frameFeeSelection")
8787
->findChild<QCheckBox*>("optInRBF")
8888
->setCheckState(rbf ? Qt::Checked : Qt::Unchecked);
89-
uint256 txid;
90-
boost::signals2::scoped_connection c(wallet.NotifyTransactionChanged.connect([&txid](const uint256& hash, ChangeType status) {
89+
Txid txid;
90+
boost::signals2::scoped_connection c(wallet.NotifyTransactionChanged.connect([&txid](const Txid& hash, ChangeType status) {
9191
if (status == CT_NEW) txid = hash;
9292
}));
9393
ConfirmSend(/*text=*/nullptr, confirm_type);
@@ -97,7 +97,7 @@ uint256 SendCoins(CWallet& wallet, SendCoinsDialog& sendCoinsDialog, const CTxDe
9797
}
9898

9999
//! Find index of txid in transaction list.
100-
QModelIndex FindTx(const QAbstractItemModel& model, const uint256& txid)
100+
QModelIndex FindTx(const QAbstractItemModel& model, const Txid& txid)
101101
{
102102
QString hash = QString::fromStdString(txid.ToString());
103103
int rows = model.rowCount({});
@@ -111,7 +111,7 @@ QModelIndex FindTx(const QAbstractItemModel& model, const uint256& txid)
111111
}
112112

113113
//! Invoke bumpfee on txid and check results.
114-
void BumpFee(TransactionView& view, const uint256& txid, bool expectDisabled, std::string expectError, bool cancel)
114+
void BumpFee(TransactionView& view, const Txid& txid, bool expectDisabled, std::string expectError, bool cancel)
115115
{
116116
QTableView* table = view.findChild<QTableView*>("transactionView");
117117
QModelIndex index = FindTx(*table->selectionModel()->model(), txid);
@@ -285,8 +285,8 @@ void TestGUI(interfaces::Node& node, const std::shared_ptr<CWallet>& wallet)
285285
// Send two transactions, and verify they are added to transaction list.
286286
TransactionTableModel* transactionTableModel = walletModel.getTransactionTableModel();
287287
QCOMPARE(transactionTableModel->rowCount({}), 105);
288-
uint256 txid1 = SendCoins(*wallet.get(), sendCoinsDialog, PKHash(), 5 * COIN, /*rbf=*/false);
289-
uint256 txid2 = SendCoins(*wallet.get(), sendCoinsDialog, PKHash(), 10 * COIN, /*rbf=*/true);
288+
Txid txid1 = SendCoins(*wallet.get(), sendCoinsDialog, PKHash(), 5 * COIN, /*rbf=*/false);
289+
Txid txid2 = SendCoins(*wallet.get(), sendCoinsDialog, PKHash(), 10 * COIN, /*rbf=*/true);
290290
// Transaction table model updates on a QueuedConnection, so process events to ensure it's updated.
291291
qApp->processEvents();
292292
QCOMPARE(transactionTableModel->rowCount({}), 107);

src/qt/transactionrecord.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const interface
3737
CAmount nCredit = wtx.credit;
3838
CAmount nDebit = wtx.debit;
3939
CAmount nNet = nCredit - nDebit;
40-
uint256 hash = wtx.tx->GetHash();
40+
Txid hash = wtx.tx->GetHash();
4141
std::map<std::string, std::string> mapValue = wtx.value_map;
4242

4343
bool involvesWatchAddress = false;

src/qt/transactionrecord.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <consensus/amount.h>
99
#include <uint256.h>
10+
#include <util/transaction_identifier.h>
1011

1112
#include <QList>
1213
#include <QString>
@@ -79,13 +80,13 @@ class TransactionRecord
7980
{
8081
}
8182

82-
TransactionRecord(uint256 _hash, qint64 _time):
83+
TransactionRecord(Txid _hash, qint64 _time):
8384
hash(_hash), time(_time), type(Other), debit(0),
8485
credit(0), idx(0)
8586
{
8687
}
8788

88-
TransactionRecord(uint256 _hash, qint64 _time,
89+
TransactionRecord(Txid _hash, qint64 _time,
8990
Type _type, const std::string &_address,
9091
const CAmount& _debit, const CAmount& _credit):
9192
hash(_hash), time(_time), type(_type), address(_address), debit(_debit), credit(_credit),
@@ -100,7 +101,7 @@ class TransactionRecord
100101

101102
/** @name Immutable transaction attributes
102103
@{*/
103-
uint256 hash;
104+
Txid hash;
104105
qint64 time;
105106
Type type;
106107
std::string address;

src/qt/transactiontablemodel.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ struct TxLessThan
4949
{
5050
return a.hash < b.hash;
5151
}
52-
bool operator()(const TransactionRecord &a, const uint256 &b) const
52+
bool operator()(const TransactionRecord &a, const Txid &b) const
5353
{
5454
return a.hash < b;
5555
}
56-
bool operator()(const uint256 &a, const TransactionRecord &b) const
56+
bool operator()(const Txid &a, const TransactionRecord &b) const
5757
{
5858
return a < b.hash;
5959
}
@@ -64,7 +64,7 @@ struct TransactionNotification
6464
{
6565
public:
6666
TransactionNotification() = default;
67-
TransactionNotification(uint256 _hash, ChangeType _status, bool _showTransaction):
67+
TransactionNotification(Txid _hash, ChangeType _status, bool _showTransaction):
6868
hash(_hash), status(_status), showTransaction(_showTransaction) {}
6969

7070
void invoke(QObject *ttm)
@@ -78,7 +78,7 @@ struct TransactionNotification
7878
assert(invoked);
7979
}
8080
private:
81-
uint256 hash;
81+
Txid hash;
8282
ChangeType status;
8383
bool showTransaction;
8484
};
@@ -103,7 +103,7 @@ class TransactionTablePriv
103103
bool m_loading = false;
104104
std::vector< TransactionNotification > vQueueNotifications;
105105

106-
void NotifyTransactionChanged(const uint256 &hash, ChangeType status);
106+
void NotifyTransactionChanged(const Txid& hash, ChangeType status);
107107
void DispatchNotifications();
108108

109109
/* Query entire wallet anew from core.
@@ -127,7 +127,7 @@ class TransactionTablePriv
127127
128128
Call with transaction that was added, removed or changed.
129129
*/
130-
void updateWallet(interfaces::Wallet& wallet, const uint256 &hash, int status, bool showTransaction)
130+
void updateWallet(interfaces::Wallet& wallet, const Txid& hash, int status, bool showTransaction)
131131
{
132132
qDebug() << "TransactionTablePriv::updateWallet: " + QString::fromStdString(hash.ToString()) + " " + QString::number(status);
133133

@@ -699,7 +699,7 @@ void TransactionTableModel::updateDisplayUnit()
699699
Q_EMIT dataChanged(index(0, Amount), index(priv->size()-1, Amount));
700700
}
701701

702-
void TransactionTablePriv::NotifyTransactionChanged(const uint256 &hash, ChangeType status)
702+
void TransactionTablePriv::NotifyTransactionChanged(const Txid& hash, ChangeType status)
703703
{
704704
// Find transaction in wallet
705705
// Determine whether to show transaction or not (determine this here so that no relocking is needed in GUI thread)

src/qt/transactionview.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
193193
// Double-clicking on a transaction on the transaction history page shows details
194194
connect(this, &TransactionView::doubleClicked, this, &TransactionView::showDetails);
195195
// Highlight transaction after fee bump
196-
connect(this, &TransactionView::bumpedFee, [this](const uint256& txid) {
196+
connect(this, &TransactionView::bumpedFee, [this](const Txid& txid) {
197197
focusTransaction(txid);
198198
});
199199
}
@@ -431,7 +431,7 @@ void TransactionView::bumpFee([[maybe_unused]] bool checked)
431431
Txid hash = Txid::FromHex(hashQStr.toStdString()).value();
432432

433433
// Bump tx fee over the walletModel
434-
uint256 newHash;
434+
Txid newHash;
435435
if (model->bumpFee(hash, newHash)) {
436436
// Update the table
437437
transactionView->selectionModel()->clearSelection();
@@ -599,7 +599,7 @@ void TransactionView::focusTransaction(const QModelIndex &idx)
599599
transactionView->setFocus();
600600
}
601601

602-
void TransactionView::focusTransaction(const uint256& txid)
602+
void TransactionView::focusTransaction(const Txid& txid)
603603
{
604604
if (!transactionProxyModel)
605605
return;

src/qt/transactionview.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <qt/guiutil.h>
99

1010
#include <uint256.h>
11+
#include <util/transaction_identifier.h>
1112

1213
#include <QWidget>
1314
#include <QKeyEvent>
@@ -115,7 +116,7 @@ private Q_SLOTS:
115116
/** Fired when a message should be reported to the user */
116117
void message(const QString &title, const QString &message, unsigned int style);
117118

118-
void bumpedFee(const uint256& txid);
119+
void bumpedFee(const Txid& txid);
119120

120121
public Q_SLOTS:
121122
void chooseDate(int idx);
@@ -126,7 +127,7 @@ public Q_SLOTS:
126127
void exportClicked();
127128
void closeOpenedDialogs();
128129
void focusTransaction(const QModelIndex&);
129-
void focusTransaction(const uint256& txid);
130+
void focusTransaction(const Txid& txid);
130131
};
131132

132133
#endif // BITCOIN_QT_TRANSACTIONVIEW_H

src/qt/walletmodel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ static void NotifyAddressBookChanged(WalletModel *walletmodel,
381381
assert(invoked);
382382
}
383383

384-
static void NotifyTransactionChanged(WalletModel *walletmodel, const uint256 &hash, ChangeType status)
384+
static void NotifyTransactionChanged(WalletModel *walletmodel, const Txid& hash, ChangeType status)
385385
{
386386
Q_UNUSED(hash);
387387
Q_UNUSED(status);
@@ -463,7 +463,7 @@ WalletModel::UnlockContext::~UnlockContext()
463463
}
464464
}
465465

466-
bool WalletModel::bumpFee(uint256 hash, uint256& new_hash)
466+
bool WalletModel::bumpFee(Txid hash, Txid& new_hash)
467467
{
468468
CCoinControl coin_control;
469469
coin_control.m_signal_bip125_rbf = true;

src/qt/walletmodel.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include <interfaces/wallet.h>
1313
#include <support/allocators/secure.h>
14+
#include <util/transaction_identifier.h>
1415

1516
#include <vector>
1617

@@ -129,7 +130,7 @@ class WalletModel : public QObject
129130

130131
UnlockContext requestUnlock();
131132

132-
bool bumpFee(uint256 hash, uint256& new_hash);
133+
bool bumpFee(Txid hash, Txid& new_hash);
133134
void displayAddress(std::string sAddress) const;
134135

135136
static bool isWalletEnabled();

0 commit comments

Comments
 (0)