mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 23:09:44 -04:00
qt, refactor: Convert uint256 to Txid in the GUI
Switch all instances of a transaction from a uint256 to the Txid type. The added implicit conversion in transaction_identifier.h is only temporary to allow for commits to be split up neatly, versus doing the type conversion for the entire wallet, GUI, and interfaces in a single commit.
This commit is contained in:
parent
e1dfa4faeb
commit
cf6f102cd3
12 changed files with 28 additions and 23 deletions
|
@ -306,7 +306,7 @@ public:
|
||||||
virtual std::unique_ptr<Handler> handleAddressBookChanged(AddressBookChangedFn fn) = 0;
|
virtual std::unique_ptr<Handler> handleAddressBookChanged(AddressBookChangedFn fn) = 0;
|
||||||
|
|
||||||
//! Register handler for transaction changed messages.
|
//! 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;
|
virtual std::unique_ptr<Handler> handleTransactionChanged(TransactionChangedFn fn) = 0;
|
||||||
|
|
||||||
//! Register handler for watchonly changed messages.
|
//! Register handler for watchonly changed messages.
|
||||||
|
|
|
@ -61,7 +61,7 @@ public Q_SLOTS:
|
||||||
void setBalance(const interfaces::WalletBalances& balances);
|
void setBalance(const interfaces::WalletBalances& balances);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void coinsSent(const uint256& txid);
|
void coinsSent(const Txid& txid);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::SendCoinsDialog *ui;
|
Ui::SendCoinsDialog *ui;
|
||||||
|
|
|
@ -37,7 +37,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const interface
|
||||||
CAmount nCredit = wtx.credit;
|
CAmount nCredit = wtx.credit;
|
||||||
CAmount nDebit = wtx.debit;
|
CAmount nDebit = wtx.debit;
|
||||||
CAmount nNet = nCredit - nDebit;
|
CAmount nNet = nCredit - nDebit;
|
||||||
uint256 hash = wtx.tx->GetHash();
|
Txid hash = wtx.tx->GetHash();
|
||||||
std::map<std::string, std::string> mapValue = wtx.value_map;
|
std::map<std::string, std::string> mapValue = wtx.value_map;
|
||||||
|
|
||||||
bool involvesWatchAddress = false;
|
bool involvesWatchAddress = false;
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#include <consensus/amount.h>
|
#include <consensus/amount.h>
|
||||||
#include <uint256.h>
|
#include <uint256.h>
|
||||||
|
#include <util/transaction_identifier.h>
|
||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QString>
|
#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),
|
hash(_hash), time(_time), type(Other), debit(0),
|
||||||
credit(0), idx(0)
|
credit(0), idx(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionRecord(uint256 _hash, qint64 _time,
|
TransactionRecord(Txid _hash, qint64 _time,
|
||||||
Type _type, const std::string &_address,
|
Type _type, const std::string &_address,
|
||||||
const CAmount& _debit, const CAmount& _credit):
|
const CAmount& _debit, const CAmount& _credit):
|
||||||
hash(_hash), time(_time), type(_type), address(_address), debit(_debit), credit(_credit),
|
hash(_hash), time(_time), type(_type), address(_address), debit(_debit), credit(_credit),
|
||||||
|
@ -100,7 +101,7 @@ public:
|
||||||
|
|
||||||
/** @name Immutable transaction attributes
|
/** @name Immutable transaction attributes
|
||||||
@{*/
|
@{*/
|
||||||
uint256 hash;
|
Txid hash;
|
||||||
qint64 time;
|
qint64 time;
|
||||||
Type type;
|
Type type;
|
||||||
std::string address;
|
std::string address;
|
||||||
|
|
|
@ -49,11 +49,11 @@ struct TxLessThan
|
||||||
{
|
{
|
||||||
return a.hash < b.hash;
|
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;
|
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;
|
return a < b.hash;
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ struct TransactionNotification
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TransactionNotification() = default;
|
TransactionNotification() = default;
|
||||||
TransactionNotification(uint256 _hash, ChangeType _status, bool _showTransaction):
|
TransactionNotification(Txid _hash, ChangeType _status, bool _showTransaction):
|
||||||
hash(_hash), status(_status), showTransaction(_showTransaction) {}
|
hash(_hash), status(_status), showTransaction(_showTransaction) {}
|
||||||
|
|
||||||
void invoke(QObject *ttm)
|
void invoke(QObject *ttm)
|
||||||
|
@ -78,7 +78,7 @@ public:
|
||||||
assert(invoked);
|
assert(invoked);
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
uint256 hash;
|
Txid hash;
|
||||||
ChangeType status;
|
ChangeType status;
|
||||||
bool showTransaction;
|
bool showTransaction;
|
||||||
};
|
};
|
||||||
|
@ -103,7 +103,7 @@ public:
|
||||||
bool m_loading = false;
|
bool m_loading = false;
|
||||||
std::vector< TransactionNotification > vQueueNotifications;
|
std::vector< TransactionNotification > vQueueNotifications;
|
||||||
|
|
||||||
void NotifyTransactionChanged(const uint256 &hash, ChangeType status);
|
void NotifyTransactionChanged(const Txid& hash, ChangeType status);
|
||||||
void DispatchNotifications();
|
void DispatchNotifications();
|
||||||
|
|
||||||
/* Query entire wallet anew from core.
|
/* Query entire wallet anew from core.
|
||||||
|
@ -127,7 +127,7 @@ public:
|
||||||
|
|
||||||
Call with transaction that was added, removed or changed.
|
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);
|
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));
|
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
|
// Find transaction in wallet
|
||||||
// Determine whether to show transaction or not (determine this here so that no relocking is needed in GUI thread)
|
// 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
|
// Double-clicking on a transaction on the transaction history page shows details
|
||||||
connect(this, &TransactionView::doubleClicked, this, &TransactionView::showDetails);
|
connect(this, &TransactionView::doubleClicked, this, &TransactionView::showDetails);
|
||||||
// Highlight transaction after fee bump
|
// Highlight transaction after fee bump
|
||||||
connect(this, &TransactionView::bumpedFee, [this](const uint256& txid) {
|
connect(this, &TransactionView::bumpedFee, [this](const Txid& txid) {
|
||||||
focusTransaction(txid);
|
focusTransaction(txid);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -436,7 +436,7 @@ void TransactionView::bumpFee([[maybe_unused]] bool checked)
|
||||||
Txid hash = Txid::FromHex(hashQStr.toStdString()).value();
|
Txid hash = Txid::FromHex(hashQStr.toStdString()).value();
|
||||||
|
|
||||||
// Bump tx fee over the walletModel
|
// Bump tx fee over the walletModel
|
||||||
uint256 newHash;
|
Txid newHash;
|
||||||
if (model->bumpFee(hash, newHash)) {
|
if (model->bumpFee(hash, newHash)) {
|
||||||
// Update the table
|
// Update the table
|
||||||
transactionView->selectionModel()->clearSelection();
|
transactionView->selectionModel()->clearSelection();
|
||||||
|
@ -604,7 +604,7 @@ void TransactionView::focusTransaction(const QModelIndex &idx)
|
||||||
transactionView->setFocus();
|
transactionView->setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransactionView::focusTransaction(const uint256& txid)
|
void TransactionView::focusTransaction(const Txid& txid)
|
||||||
{
|
{
|
||||||
if (!transactionProxyModel)
|
if (!transactionProxyModel)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -115,7 +115,7 @@ Q_SIGNALS:
|
||||||
/** Fired when a message should be reported to the user */
|
/** Fired when a message should be reported to the user */
|
||||||
void message(const QString &title, const QString &message, unsigned int style);
|
void message(const QString &title, const QString &message, unsigned int style);
|
||||||
|
|
||||||
void bumpedFee(const uint256& txid);
|
void bumpedFee(const Txid& txid);
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void chooseDate(int idx);
|
void chooseDate(int idx);
|
||||||
|
@ -126,7 +126,7 @@ public Q_SLOTS:
|
||||||
void exportClicked();
|
void exportClicked();
|
||||||
void closeOpenedDialogs();
|
void closeOpenedDialogs();
|
||||||
void focusTransaction(const QModelIndex&);
|
void focusTransaction(const QModelIndex&);
|
||||||
void focusTransaction(const uint256& txid);
|
void focusTransaction(const Txid& txid);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BITCOIN_QT_TRANSACTIONVIEW_H
|
#endif // BITCOIN_QT_TRANSACTIONVIEW_H
|
||||||
|
|
|
@ -388,7 +388,7 @@ static void NotifyAddressBookChanged(WalletModel *walletmodel,
|
||||||
assert(invoked);
|
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(hash);
|
||||||
Q_UNUSED(status);
|
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;
|
CCoinControl coin_control;
|
||||||
coin_control.m_signal_bip125_rbf = true;
|
coin_control.m_signal_bip125_rbf = true;
|
||||||
|
|
|
@ -129,7 +129,7 @@ public:
|
||||||
|
|
||||||
UnlockContext requestUnlock();
|
UnlockContext requestUnlock();
|
||||||
|
|
||||||
bool bumpFee(uint256 hash, uint256& new_hash);
|
bool bumpFee(Txid hash, Txid& new_hash);
|
||||||
void displayAddress(std::string sAddress) const;
|
void displayAddress(std::string sAddress) const;
|
||||||
|
|
||||||
static bool isWalletEnabled();
|
static bool isWalletEnabled();
|
||||||
|
|
|
@ -82,7 +82,7 @@ WalletView::WalletView(WalletModel* wallet_model, const PlatformStyle* _platform
|
||||||
|
|
||||||
connect(sendCoinsPage, &SendCoinsDialog::coinsSent, this, &WalletView::coinsSent);
|
connect(sendCoinsPage, &SendCoinsDialog::coinsSent, this, &WalletView::coinsSent);
|
||||||
// Highlight transaction after send
|
// 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
|
// Clicking on "Export" allows to export the transaction list
|
||||||
connect(exportButton, &QPushButton::clicked, transactionView, &TransactionView::exportClicked);
|
connect(exportButton, &QPushButton::clicked, transactionView, &TransactionView::exportClicked);
|
||||||
|
|
|
@ -65,6 +65,10 @@ public:
|
||||||
* to using the Txid and Wtxid types. Until then it makes for a smoother
|
* to using the Txid and Wtxid types. Until then it makes for a smoother
|
||||||
* transition to allow this conversion. */
|
* transition to allow this conversion. */
|
||||||
operator const uint256&() const LIFETIMEBOUND { return m_wrapped; }
|
operator const uint256&() const LIFETIMEBOUND { return m_wrapped; }
|
||||||
|
|
||||||
|
// TODO: This should never go into master. It's only used for intermediate
|
||||||
|
// commits so that each conceptual chunk can be built.
|
||||||
|
operator uint256&() LIFETIMEBOUND { return m_wrapped; }
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Txid commits to all transaction fields except the witness. */
|
/** Txid commits to all transaction fields except the witness. */
|
||||||
|
|
|
@ -548,7 +548,7 @@ public:
|
||||||
std::unique_ptr<Handler> handleTransactionChanged(TransactionChangedFn fn) override
|
std::unique_ptr<Handler> handleTransactionChanged(TransactionChangedFn fn) override
|
||||||
{
|
{
|
||||||
return MakeSignalHandler(m_wallet->NotifyTransactionChanged.connect(
|
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
|
std::unique_ptr<Handler> handleWatchOnlyChanged(WatchOnlyChangedFn fn) override
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue