mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
qt, refactor: Convert uint256 to Txid in the GUI
Switch all instances of a transaction from a uint256 to the Txid type.
This commit is contained in:
parent
e1dfa4faeb
commit
417da2f72d
11 changed files with 33 additions and 24 deletions
|
@ -14,6 +14,7 @@
|
|||
#include <support/allocators/secure.h>
|
||||
#include <util/fs.h>
|
||||
#include <util/result.h>
|
||||
#include <util/transaction_identifier.h>
|
||||
#include <util/ui_change_type.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
@ -306,7 +307,7 @@ public:
|
|||
virtual std::unique_ptr<Handler> handleAddressBookChanged(AddressBookChangedFn fn) = 0;
|
||||
|
||||
//! Register handler for transaction changed messages.
|
||||
using TransactionChangedFn = std::function<void(const uint256& txid, ChangeType status)>;
|
||||
using TransactionChangedFn = std::function<void(const Txid& txid, ChangeType status)>;
|
||||
virtual std::unique_ptr<Handler> handleTransactionChanged(TransactionChangedFn fn) = 0;
|
||||
|
||||
//! Register handler for watchonly changed messages.
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
@ -436,7 +436,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();
|
||||
|
@ -604,7 +604,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
|
||||
|
|
|
@ -388,7 +388,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);
|
||||
|
@ -479,7 +479,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;
|
||||
|
@ -561,11 +561,15 @@ bool WalletModel::bumpFee(uint256 hash, uint256& new_hash)
|
|||
return false;
|
||||
}
|
||||
// commit the bumped transaction
|
||||
if(!m_wallet->commitBumpTransaction(hash, std::move(mtx), errors, new_hash)) {
|
||||
// Temporary uint256 variable needed for commitBumpTransaction out parameter.
|
||||
uint256 bumped_txid_result;
|
||||
if(!m_wallet->commitBumpTransaction(hash, std::move(mtx), errors, bumped_txid_result)) {
|
||||
QMessageBox::critical(nullptr, tr("Fee bump error"), tr("Could not commit transaction") + "<br />(" +
|
||||
QString::fromStdString(errors[0].translated)+")");
|
||||
return false;
|
||||
}
|
||||
// Assign the received txid back to the new_hash.
|
||||
new_hash = Txid::FromUint256(bumped_txid_result);
|
||||
return 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);
|
||||
|
|
|
@ -548,7 +548,7 @@ public:
|
|||
std::unique_ptr<Handler> handleTransactionChanged(TransactionChangedFn fn) override
|
||||
{
|
||||
return MakeSignalHandler(m_wallet->NotifyTransactionChanged.connect(
|
||||
[fn](const uint256& txid, ChangeType status) { fn(txid, status); }));
|
||||
[fn](const uint256& txid, ChangeType status) { fn(Txid::FromUint256(txid), status); }));
|
||||
}
|
||||
std::unique_ptr<Handler> handleWatchOnlyChanged(WatchOnlyChangedFn fn) override
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue