mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 23:09:44 -04:00
wallet, refactor: Convert uint256 to Txid in wallet interfaces
In most cases throughout the wallet, the implicit conversion from `Txid` to `const uint256&` works. However, `commitBumpTransaction` requires a `uint256&` out parameter, so `bumped_txid` in `feebumper::CommitTransaction` is also updated here to use `Txid`.
This commit is contained in:
parent
417da2f72d
commit
f39bf09031
6 changed files with 24 additions and 28 deletions
|
@ -160,16 +160,16 @@ public:
|
||||||
WalletOrderForm order_form) = 0;
|
WalletOrderForm order_form) = 0;
|
||||||
|
|
||||||
//! Return whether transaction can be abandoned.
|
//! Return whether transaction can be abandoned.
|
||||||
virtual bool transactionCanBeAbandoned(const uint256& txid) = 0;
|
virtual bool transactionCanBeAbandoned(const Txid& txid) = 0;
|
||||||
|
|
||||||
//! Abandon transaction.
|
//! Abandon transaction.
|
||||||
virtual bool abandonTransaction(const uint256& txid) = 0;
|
virtual bool abandonTransaction(const Txid& txid) = 0;
|
||||||
|
|
||||||
//! Return whether transaction can be bumped.
|
//! Return whether transaction can be bumped.
|
||||||
virtual bool transactionCanBeBumped(const uint256& txid) = 0;
|
virtual bool transactionCanBeBumped(const Txid& txid) = 0;
|
||||||
|
|
||||||
//! Create bump transaction.
|
//! Create bump transaction.
|
||||||
virtual bool createBumpTransaction(const uint256& txid,
|
virtual bool createBumpTransaction(const Txid& txid,
|
||||||
const wallet::CCoinControl& coin_control,
|
const wallet::CCoinControl& coin_control,
|
||||||
std::vector<bilingual_str>& errors,
|
std::vector<bilingual_str>& errors,
|
||||||
CAmount& old_fee,
|
CAmount& old_fee,
|
||||||
|
@ -180,28 +180,28 @@ public:
|
||||||
virtual bool signBumpTransaction(CMutableTransaction& mtx) = 0;
|
virtual bool signBumpTransaction(CMutableTransaction& mtx) = 0;
|
||||||
|
|
||||||
//! Commit bump transaction.
|
//! Commit bump transaction.
|
||||||
virtual bool commitBumpTransaction(const uint256& txid,
|
virtual bool commitBumpTransaction(const Txid& txid,
|
||||||
CMutableTransaction&& mtx,
|
CMutableTransaction&& mtx,
|
||||||
std::vector<bilingual_str>& errors,
|
std::vector<bilingual_str>& errors,
|
||||||
uint256& bumped_txid) = 0;
|
Txid& bumped_txid) = 0;
|
||||||
|
|
||||||
//! Get a transaction.
|
//! Get a transaction.
|
||||||
virtual CTransactionRef getTx(const uint256& txid) = 0;
|
virtual CTransactionRef getTx(const Txid& txid) = 0;
|
||||||
|
|
||||||
//! Get transaction information.
|
//! Get transaction information.
|
||||||
virtual WalletTx getWalletTx(const uint256& txid) = 0;
|
virtual WalletTx getWalletTx(const Txid& txid) = 0;
|
||||||
|
|
||||||
//! Get list of all wallet transactions.
|
//! Get list of all wallet transactions.
|
||||||
virtual std::set<WalletTx> getWalletTxs() = 0;
|
virtual std::set<WalletTx> getWalletTxs() = 0;
|
||||||
|
|
||||||
//! Try to get updated status for a particular transaction, if possible without blocking.
|
//! Try to get updated status for a particular transaction, if possible without blocking.
|
||||||
virtual bool tryGetTxStatus(const uint256& txid,
|
virtual bool tryGetTxStatus(const Txid& txid,
|
||||||
WalletTxStatus& tx_status,
|
WalletTxStatus& tx_status,
|
||||||
int& num_blocks,
|
int& num_blocks,
|
||||||
int64_t& block_time) = 0;
|
int64_t& block_time) = 0;
|
||||||
|
|
||||||
//! Get transaction details.
|
//! Get transaction details.
|
||||||
virtual WalletTx getWalletTxDetails(const uint256& txid,
|
virtual WalletTx getWalletTxDetails(const Txid& txid,
|
||||||
WalletTxStatus& tx_status,
|
WalletTxStatus& tx_status,
|
||||||
WalletOrderForm& order_form,
|
WalletOrderForm& order_form,
|
||||||
bool& in_mempool,
|
bool& in_mempool,
|
||||||
|
|
|
@ -561,15 +561,11 @@ bool WalletModel::bumpFee(Txid hash, Txid& new_hash)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// commit the bumped transaction
|
// commit the bumped transaction
|
||||||
// Temporary uint256 variable needed for commitBumpTransaction out parameter.
|
if(!m_wallet->commitBumpTransaction(hash, std::move(mtx), errors, new_hash)) {
|
||||||
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 />(" +
|
QMessageBox::critical(nullptr, tr("Fee bump error"), tr("Could not commit transaction") + "<br />(" +
|
||||||
QString::fromStdString(errors[0].translated)+")");
|
QString::fromStdString(errors[0].translated)+")");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Assign the received txid back to the new_hash.
|
|
||||||
new_hash = Txid::FromUint256(bumped_txid_result);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -353,7 +353,7 @@ bool SignTransaction(CWallet& wallet, CMutableTransaction& mtx) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Result CommitTransaction(CWallet& wallet, const uint256& txid, CMutableTransaction&& mtx, std::vector<bilingual_str>& errors, uint256& bumped_txid)
|
Result CommitTransaction(CWallet& wallet, const uint256& txid, CMutableTransaction&& mtx, std::vector<bilingual_str>& errors, Txid& bumped_txid)
|
||||||
{
|
{
|
||||||
LOCK(wallet.cs_wallet);
|
LOCK(wallet.cs_wallet);
|
||||||
if (!errors.empty()) {
|
if (!errors.empty()) {
|
||||||
|
|
|
@ -70,7 +70,7 @@ Result CommitTransaction(CWallet& wallet,
|
||||||
const uint256& txid,
|
const uint256& txid,
|
||||||
CMutableTransaction&& mtx,
|
CMutableTransaction&& mtx,
|
||||||
std::vector<bilingual_str>& errors,
|
std::vector<bilingual_str>& errors,
|
||||||
uint256& bumped_txid);
|
Txid& bumped_txid);
|
||||||
|
|
||||||
struct SignatureWeights
|
struct SignatureWeights
|
||||||
{
|
{
|
||||||
|
|
|
@ -299,17 +299,17 @@ public:
|
||||||
LOCK(m_wallet->cs_wallet);
|
LOCK(m_wallet->cs_wallet);
|
||||||
m_wallet->CommitTransaction(std::move(tx), std::move(value_map), std::move(order_form));
|
m_wallet->CommitTransaction(std::move(tx), std::move(value_map), std::move(order_form));
|
||||||
}
|
}
|
||||||
bool transactionCanBeAbandoned(const uint256& txid) override { return m_wallet->TransactionCanBeAbandoned(txid); }
|
bool transactionCanBeAbandoned(const Txid& txid) override { return m_wallet->TransactionCanBeAbandoned(txid); }
|
||||||
bool abandonTransaction(const uint256& txid) override
|
bool abandonTransaction(const Txid& txid) override
|
||||||
{
|
{
|
||||||
LOCK(m_wallet->cs_wallet);
|
LOCK(m_wallet->cs_wallet);
|
||||||
return m_wallet->AbandonTransaction(txid);
|
return m_wallet->AbandonTransaction(txid);
|
||||||
}
|
}
|
||||||
bool transactionCanBeBumped(const uint256& txid) override
|
bool transactionCanBeBumped(const Txid& txid) override
|
||||||
{
|
{
|
||||||
return feebumper::TransactionCanBeBumped(*m_wallet.get(), txid);
|
return feebumper::TransactionCanBeBumped(*m_wallet.get(), txid);
|
||||||
}
|
}
|
||||||
bool createBumpTransaction(const uint256& txid,
|
bool createBumpTransaction(const Txid& txid,
|
||||||
const CCoinControl& coin_control,
|
const CCoinControl& coin_control,
|
||||||
std::vector<bilingual_str>& errors,
|
std::vector<bilingual_str>& errors,
|
||||||
CAmount& old_fee,
|
CAmount& old_fee,
|
||||||
|
@ -320,15 +320,15 @@ public:
|
||||||
return feebumper::CreateRateBumpTransaction(*m_wallet.get(), txid, coin_control, errors, old_fee, new_fee, mtx, /* require_mine= */ true, outputs) == feebumper::Result::OK;
|
return feebumper::CreateRateBumpTransaction(*m_wallet.get(), txid, coin_control, errors, old_fee, new_fee, mtx, /* require_mine= */ true, outputs) == feebumper::Result::OK;
|
||||||
}
|
}
|
||||||
bool signBumpTransaction(CMutableTransaction& mtx) override { return feebumper::SignTransaction(*m_wallet.get(), mtx); }
|
bool signBumpTransaction(CMutableTransaction& mtx) override { return feebumper::SignTransaction(*m_wallet.get(), mtx); }
|
||||||
bool commitBumpTransaction(const uint256& txid,
|
bool commitBumpTransaction(const Txid& txid,
|
||||||
CMutableTransaction&& mtx,
|
CMutableTransaction&& mtx,
|
||||||
std::vector<bilingual_str>& errors,
|
std::vector<bilingual_str>& errors,
|
||||||
uint256& bumped_txid) override
|
Txid& bumped_txid) override
|
||||||
{
|
{
|
||||||
return feebumper::CommitTransaction(*m_wallet.get(), txid, std::move(mtx), errors, bumped_txid) ==
|
return feebumper::CommitTransaction(*m_wallet.get(), txid, std::move(mtx), errors, bumped_txid) ==
|
||||||
feebumper::Result::OK;
|
feebumper::Result::OK;
|
||||||
}
|
}
|
||||||
CTransactionRef getTx(const uint256& txid) override
|
CTransactionRef getTx(const Txid& txid) override
|
||||||
{
|
{
|
||||||
LOCK(m_wallet->cs_wallet);
|
LOCK(m_wallet->cs_wallet);
|
||||||
auto mi = m_wallet->mapWallet.find(txid);
|
auto mi = m_wallet->mapWallet.find(txid);
|
||||||
|
@ -337,7 +337,7 @@ public:
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
WalletTx getWalletTx(const uint256& txid) override
|
WalletTx getWalletTx(const Txid& txid) override
|
||||||
{
|
{
|
||||||
LOCK(m_wallet->cs_wallet);
|
LOCK(m_wallet->cs_wallet);
|
||||||
auto mi = m_wallet->mapWallet.find(txid);
|
auto mi = m_wallet->mapWallet.find(txid);
|
||||||
|
@ -355,7 +355,7 @@ public:
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
bool tryGetTxStatus(const uint256& txid,
|
bool tryGetTxStatus(const Txid& txid,
|
||||||
interfaces::WalletTxStatus& tx_status,
|
interfaces::WalletTxStatus& tx_status,
|
||||||
int& num_blocks,
|
int& num_blocks,
|
||||||
int64_t& block_time) override
|
int64_t& block_time) override
|
||||||
|
@ -374,7 +374,7 @@ public:
|
||||||
tx_status = MakeWalletTxStatus(*m_wallet, mi->second);
|
tx_status = MakeWalletTxStatus(*m_wallet, mi->second);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
WalletTx getWalletTxDetails(const uint256& txid,
|
WalletTx getWalletTxDetails(const Txid& txid,
|
||||||
WalletTxStatus& tx_status,
|
WalletTxStatus& tx_status,
|
||||||
WalletOrderForm& order_form,
|
WalletOrderForm& order_form,
|
||||||
bool& in_mempool,
|
bool& in_mempool,
|
||||||
|
|
|
@ -1165,7 +1165,7 @@ static RPCHelpMan bumpfee_helper(std::string method_name)
|
||||||
throw JSONRPCError(RPC_WALLET_ERROR, "Can't sign transaction.");
|
throw JSONRPCError(RPC_WALLET_ERROR, "Can't sign transaction.");
|
||||||
}
|
}
|
||||||
|
|
||||||
uint256 txid;
|
Txid txid;
|
||||||
if (feebumper::CommitTransaction(*pwallet, hash, std::move(mtx), errors, txid) != feebumper::Result::OK) {
|
if (feebumper::CommitTransaction(*pwallet, hash, std::move(mtx), errors, txid) != feebumper::Result::OK) {
|
||||||
throw JSONRPCError(RPC_WALLET_ERROR, errors[0].original);
|
throw JSONRPCError(RPC_WALLET_ERROR, errors[0].original);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue