Skip to content

Commit c8ed51e

Browse files
committed
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`.
1 parent b3214ce commit c8ed51e

File tree

6 files changed

+24
-28
lines changed

6 files changed

+24
-28
lines changed

src/interfaces/wallet.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -157,16 +157,16 @@ class Wallet
157157
WalletOrderForm order_form) = 0;
158158

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

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

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

168168
//! Create bump transaction.
169-
virtual bool createBumpTransaction(const uint256& txid,
169+
virtual bool createBumpTransaction(const Txid& txid,
170170
const wallet::CCoinControl& coin_control,
171171
std::vector<bilingual_str>& errors,
172172
CAmount& old_fee,
@@ -177,28 +177,28 @@ class Wallet
177177
virtual bool signBumpTransaction(CMutableTransaction& mtx) = 0;
178178

179179
//! Commit bump transaction.
180-
virtual bool commitBumpTransaction(const uint256& txid,
180+
virtual bool commitBumpTransaction(const Txid& txid,
181181
CMutableTransaction&& mtx,
182182
std::vector<bilingual_str>& errors,
183-
uint256& bumped_txid) = 0;
183+
Txid& bumped_txid) = 0;
184184

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

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

191191
//! Get list of all wallet transactions.
192192
virtual std::set<WalletTx> getWalletTxs() = 0;
193193

194194
//! Try to get updated status for a particular transaction, if possible without blocking.
195-
virtual bool tryGetTxStatus(const uint256& txid,
195+
virtual bool tryGetTxStatus(const Txid& txid,
196196
WalletTxStatus& tx_status,
197197
int& num_blocks,
198198
int64_t& block_time) = 0;
199199

200200
//! Get transaction details.
201-
virtual WalletTx getWalletTxDetails(const uint256& txid,
201+
virtual WalletTx getWalletTxDetails(const Txid& txid,
202202
WalletTxStatus& tx_status,
203203
WalletOrderForm& order_form,
204204
bool& in_mempool,

src/qt/walletmodel.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -561,15 +561,11 @@ bool WalletModel::bumpFee(Txid hash, Txid& new_hash)
561561
return false;
562562
}
563563
// commit the bumped transaction
564-
// Temporary uint256 variable needed for commitBumpTransaction out parameter.
565-
uint256 bumped_txid_result;
566-
if(!m_wallet->commitBumpTransaction(hash, std::move(mtx), errors, bumped_txid_result)) {
564+
if(!m_wallet->commitBumpTransaction(hash, std::move(mtx), errors, new_hash)) {
567565
QMessageBox::critical(nullptr, tr("Fee bump error"), tr("Could not commit transaction") + "<br />(" +
568566
QString::fromStdString(errors[0].translated)+")");
569567
return false;
570568
}
571-
// Assign the received txid back to the new_hash.
572-
new_hash = Txid::FromUint256(bumped_txid_result);
573569
return true;
574570
}
575571

src/wallet/feebumper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ bool SignTransaction(CWallet& wallet, CMutableTransaction& mtx) {
348348
}
349349
}
350350

351-
Result CommitTransaction(CWallet& wallet, const uint256& txid, CMutableTransaction&& mtx, std::vector<bilingual_str>& errors, uint256& bumped_txid)
351+
Result CommitTransaction(CWallet& wallet, const uint256& txid, CMutableTransaction&& mtx, std::vector<bilingual_str>& errors, Txid& bumped_txid)
352352
{
353353
LOCK(wallet.cs_wallet);
354354
if (!errors.empty()) {

src/wallet/feebumper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Result CommitTransaction(CWallet& wallet,
7070
const uint256& txid,
7171
CMutableTransaction&& mtx,
7272
std::vector<bilingual_str>& errors,
73-
uint256& bumped_txid);
73+
Txid& bumped_txid);
7474

7575
struct SignatureWeights
7676
{

src/wallet/interfaces.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -291,17 +291,17 @@ class WalletImpl : public Wallet
291291
LOCK(m_wallet->cs_wallet);
292292
m_wallet->CommitTransaction(std::move(tx), std::move(value_map), std::move(order_form));
293293
}
294-
bool transactionCanBeAbandoned(const uint256& txid) override { return m_wallet->TransactionCanBeAbandoned(txid); }
295-
bool abandonTransaction(const uint256& txid) override
294+
bool transactionCanBeAbandoned(const Txid& txid) override { return m_wallet->TransactionCanBeAbandoned(txid); }
295+
bool abandonTransaction(const Txid& txid) override
296296
{
297297
LOCK(m_wallet->cs_wallet);
298298
return m_wallet->AbandonTransaction(txid);
299299
}
300-
bool transactionCanBeBumped(const uint256& txid) override
300+
bool transactionCanBeBumped(const Txid& txid) override
301301
{
302302
return feebumper::TransactionCanBeBumped(*m_wallet.get(), txid);
303303
}
304-
bool createBumpTransaction(const uint256& txid,
304+
bool createBumpTransaction(const Txid& txid,
305305
const CCoinControl& coin_control,
306306
std::vector<bilingual_str>& errors,
307307
CAmount& old_fee,
@@ -312,15 +312,15 @@ class WalletImpl : public Wallet
312312
return feebumper::CreateRateBumpTransaction(*m_wallet.get(), txid, coin_control, errors, old_fee, new_fee, mtx, /* require_mine= */ true, outputs) == feebumper::Result::OK;
313313
}
314314
bool signBumpTransaction(CMutableTransaction& mtx) override { return feebumper::SignTransaction(*m_wallet.get(), mtx); }
315-
bool commitBumpTransaction(const uint256& txid,
315+
bool commitBumpTransaction(const Txid& txid,
316316
CMutableTransaction&& mtx,
317317
std::vector<bilingual_str>& errors,
318-
uint256& bumped_txid) override
318+
Txid& bumped_txid) override
319319
{
320320
return feebumper::CommitTransaction(*m_wallet.get(), txid, std::move(mtx), errors, bumped_txid) ==
321321
feebumper::Result::OK;
322322
}
323-
CTransactionRef getTx(const uint256& txid) override
323+
CTransactionRef getTx(const Txid& txid) override
324324
{
325325
LOCK(m_wallet->cs_wallet);
326326
auto mi = m_wallet->mapWallet.find(txid);
@@ -329,7 +329,7 @@ class WalletImpl : public Wallet
329329
}
330330
return {};
331331
}
332-
WalletTx getWalletTx(const uint256& txid) override
332+
WalletTx getWalletTx(const Txid& txid) override
333333
{
334334
LOCK(m_wallet->cs_wallet);
335335
auto mi = m_wallet->mapWallet.find(txid);
@@ -347,7 +347,7 @@ class WalletImpl : public Wallet
347347
}
348348
return result;
349349
}
350-
bool tryGetTxStatus(const uint256& txid,
350+
bool tryGetTxStatus(const Txid& txid,
351351
interfaces::WalletTxStatus& tx_status,
352352
int& num_blocks,
353353
int64_t& block_time) override
@@ -366,7 +366,7 @@ class WalletImpl : public Wallet
366366
tx_status = MakeWalletTxStatus(*m_wallet, mi->second);
367367
return true;
368368
}
369-
WalletTx getWalletTxDetails(const uint256& txid,
369+
WalletTx getWalletTxDetails(const Txid& txid,
370370
WalletTxStatus& tx_status,
371371
WalletOrderForm& order_form,
372372
bool& in_mempool,

src/wallet/rpc/spend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,7 @@ static RPCHelpMan bumpfee_helper(std::string method_name)
11661166
throw JSONRPCError(RPC_WALLET_ERROR, "Can't sign transaction.");
11671167
}
11681168

1169-
uint256 txid;
1169+
Txid txid;
11701170
if (feebumper::CommitTransaction(*pwallet, hash, std::move(mtx), errors, txid) != feebumper::Result::OK) {
11711171
throw JSONRPCError(RPC_WALLET_ERROR, errors[0].original);
11721172
}

0 commit comments

Comments
 (0)