Skip to content

Commit 5a5e4e9

Browse files
committed
[wallet] Remove CTransaction&() helper conversion operator from wallet implementation.
1 parent 6a796b2 commit 5a5e4e9

11 files changed

+22
-26
lines changed

src/qt/transactiondesc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
QString TransactionDesc::FormatTxStatus(const CWalletTx& wtx)
2525
{
2626
AssertLockHeld(cs_main);
27-
if (!CheckFinalTx(wtx))
27+
if (!CheckFinalTx(*wtx.tx))
2828
{
2929
if (wtx.tx->nLockTime < LOCKTIME_THRESHOLD)
3030
return tr("Open for %n more block(s)", "", wtx.tx->nLockTime - chainActive.Height());

src/qt/transactionrecord.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ void TransactionRecord::updateStatus(const CWalletTx &wtx)
183183
status.depth = wtx.GetDepthInMainChain();
184184
status.cur_num_blocks = chainActive.Height();
185185

186-
if (!CheckFinalTx(wtx))
186+
if (!CheckFinalTx(*wtx.tx))
187187
{
188188
if (wtx.tx->nLockTime < LOCKTIME_THRESHOLD)
189189
{

src/qt/transactiontablemodel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ class TransactionTablePriv
228228
std::map<uint256, CWalletTx>::iterator mi = wallet->mapWallet.find(rec->hash);
229229
if(mi != wallet->mapWallet.end())
230230
{
231-
std::string strHex = EncodeHexTx(static_cast<CTransaction>(mi->second));
231+
std::string strHex = EncodeHexTx(*mi->second.tx);
232232
return QString::fromStdString(strHex);
233233
}
234234
return QString();

src/qt/walletmodeltransaction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ CWalletTx *WalletModelTransaction::getTransaction()
3434

3535
unsigned int WalletModelTransaction::getTransactionSize()
3636
{
37-
return (!walletTransaction ? 0 : ::GetVirtualTransactionSize(*walletTransaction));
37+
return (!walletTransaction ? 0 : ::GetVirtualTransactionSize(*walletTransaction->tx));
3838
}
3939

4040
CAmount WalletModelTransaction::getTransactionFee()

src/wallet/feebumper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ CFeeBumper::CFeeBumper(const CWallet *pWallet, const uint256 txidIn, int newConf
8080
return;
8181
}
8282

83-
if (!SignalsOptInRBF(wtx)) {
83+
if (!SignalsOptInRBF(*wtx.tx)) {
8484
vErrors.push_back("Transaction is not BIP 125 replaceable");
8585
currentResult = BumpFeeResult::WALLET_ERROR;
8686
return;
@@ -94,7 +94,7 @@ CFeeBumper::CFeeBumper(const CWallet *pWallet, const uint256 txidIn, int newConf
9494

9595
// check that original tx consists entirely of our inputs
9696
// if not, we can't bump the fee, because the wallet has no way of knowing the value of the other inputs (thus the fee)
97-
if (!pWallet->IsAllFromMe(wtx, ISMINE_SPENDABLE)) {
97+
if (!pWallet->IsAllFromMe(*wtx.tx, ISMINE_SPENDABLE)) {
9898
vErrors.push_back("Transaction contains inputs that don't belong to this wallet");
9999
currentResult = BumpFeeResult::WALLET_ERROR;
100100
return;

src/wallet/rpcdump.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ UniValue importprunedfunds(const JSONRPCRequest& request)
339339

340340
LOCK2(cs_main, pwallet->cs_wallet);
341341

342-
if (pwallet->IsMine(wtx)) {
342+
if (pwallet->IsMine(*wtx.tx)) {
343343
pwallet->AddToWallet(wtx, false);
344344
return NullUniValue;
345345
}

src/wallet/rpcwallet.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry)
8787
std::string rbfStatus = "no";
8888
if (confirms <= 0) {
8989
LOCK(mempool.cs);
90-
RBFTransactionState rbfState = IsRBFOptIn(wtx, mempool);
90+
RBFTransactionState rbfState = IsRBFOptIn(*wtx.tx, mempool);
9191
if (rbfState == RBF_TRANSACTIONSTATE_UNKNOWN)
9292
rbfStatus = "unknown";
9393
else if (rbfState == RBF_TRANSACTIONSTATE_REPLACEABLE_BIP125)
@@ -1867,7 +1867,7 @@ UniValue gettransaction(const JSONRPCRequest& request)
18671867
ListTransactions(pwallet, wtx, "*", 0, false, details, filter);
18681868
entry.push_back(Pair("details", details));
18691869

1870-
std::string strHex = EncodeHexTx(static_cast<CTransaction>(wtx), RPCSerializationFlags());
1870+
std::string strHex = EncodeHexTx(*wtx.tx, RPCSerializationFlags());
18711871
entry.push_back(Pair("hex", strHex));
18721872

18731873
return entry;

src/wallet/test/accounting_tests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ BOOST_AUTO_TEST_CASE(acc_orderupgrade)
8484

8585
wtx.mapValue["comment"] = "y";
8686
{
87-
CMutableTransaction tx(wtx);
87+
CMutableTransaction tx(*wtx.tx);
8888
--tx.nLockTime; // Just to change the hash :)
8989
wtx.SetTx(MakeTransactionRef(std::move(tx)));
9090
}
@@ -94,7 +94,7 @@ BOOST_AUTO_TEST_CASE(acc_orderupgrade)
9494

9595
wtx.mapValue["comment"] = "x";
9696
{
97-
CMutableTransaction tx(wtx);
97+
CMutableTransaction tx(*wtx.tx);
9898
--tx.nLockTime; // Just to change the hash :)
9999
wtx.SetTx(MakeTransactionRef(std::move(tx)));
100100
}

src/wallet/wallet.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,7 +1592,7 @@ CAmount CWalletTx::GetDebit(const isminefilter& filter) const
15921592
debit += nDebitCached;
15931593
else
15941594
{
1595-
nDebitCached = pwallet->GetDebit(*this, ISMINE_SPENDABLE);
1595+
nDebitCached = pwallet->GetDebit(*tx, ISMINE_SPENDABLE);
15961596
fDebitCached = true;
15971597
debit += nDebitCached;
15981598
}
@@ -1603,7 +1603,7 @@ CAmount CWalletTx::GetDebit(const isminefilter& filter) const
16031603
debit += nWatchDebitCached;
16041604
else
16051605
{
1606-
nWatchDebitCached = pwallet->GetDebit(*this, ISMINE_WATCH_ONLY);
1606+
nWatchDebitCached = pwallet->GetDebit(*tx, ISMINE_WATCH_ONLY);
16071607
fWatchDebitCached = true;
16081608
debit += nWatchDebitCached;
16091609
}
@@ -1625,7 +1625,7 @@ CAmount CWalletTx::GetCredit(const isminefilter& filter) const
16251625
credit += nCreditCached;
16261626
else
16271627
{
1628-
nCreditCached = pwallet->GetCredit(*this, ISMINE_SPENDABLE);
1628+
nCreditCached = pwallet->GetCredit(*tx, ISMINE_SPENDABLE);
16291629
fCreditCached = true;
16301630
credit += nCreditCached;
16311631
}
@@ -1636,7 +1636,7 @@ CAmount CWalletTx::GetCredit(const isminefilter& filter) const
16361636
credit += nWatchCreditCached;
16371637
else
16381638
{
1639-
nWatchCreditCached = pwallet->GetCredit(*this, ISMINE_WATCH_ONLY);
1639+
nWatchCreditCached = pwallet->GetCredit(*tx, ISMINE_WATCH_ONLY);
16401640
fWatchCreditCached = true;
16411641
credit += nWatchCreditCached;
16421642
}
@@ -1650,7 +1650,7 @@ CAmount CWalletTx::GetImmatureCredit(bool fUseCache) const
16501650
{
16511651
if (fUseCache && fImmatureCreditCached)
16521652
return nImmatureCreditCached;
1653-
nImmatureCreditCached = pwallet->GetCredit(*this, ISMINE_SPENDABLE);
1653+
nImmatureCreditCached = pwallet->GetCredit(*tx, ISMINE_SPENDABLE);
16541654
fImmatureCreditCached = true;
16551655
return nImmatureCreditCached;
16561656
}
@@ -1694,7 +1694,7 @@ CAmount CWalletTx::GetImmatureWatchOnlyCredit(const bool& fUseCache) const
16941694
{
16951695
if (fUseCache && fImmatureWatchCreditCached)
16961696
return nImmatureWatchCreditCached;
1697-
nImmatureWatchCreditCached = pwallet->GetCredit(*this, ISMINE_WATCH_ONLY);
1697+
nImmatureWatchCreditCached = pwallet->GetCredit(*tx, ISMINE_WATCH_ONLY);
16981698
fImmatureWatchCreditCached = true;
16991699
return nImmatureWatchCreditCached;
17001700
}
@@ -1735,7 +1735,7 @@ CAmount CWalletTx::GetChange() const
17351735
{
17361736
if (fChangeCached)
17371737
return nChangeCached;
1738-
nChangeCached = pwallet->GetChange(*this);
1738+
nChangeCached = pwallet->GetChange(*tx);
17391739
fChangeCached = true;
17401740
return nChangeCached;
17411741
}
@@ -1749,7 +1749,7 @@ bool CWalletTx::InMempool() const
17491749
bool CWalletTx::IsTrusted() const
17501750
{
17511751
// Quick answer in most cases
1752-
if (!CheckFinalTx(*this))
1752+
if (!CheckFinalTx(*tx))
17531753
return false;
17541754
int nDepth = GetDepthInMainChain();
17551755
if (nDepth >= 1)
@@ -1988,7 +1988,7 @@ void CWallet::AvailableCoins(std::vector<COutput>& vCoins, bool fOnlySafe, const
19881988
const uint256& wtxid = it->first;
19891989
const CWalletTx* pcoin = &(*it).second;
19901990

1991-
if (!CheckFinalTx(*pcoin))
1991+
if (!CheckFinalTx(*pcoin->tx))
19921992
continue;
19931993

19941994
if (pcoin->IsCoinBase() && pcoin->GetBlocksToMaturity() > 0)
@@ -2676,7 +2676,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
26762676
wtxNew.SetTx(MakeTransactionRef(std::move(txNew)));
26772677

26782678
// Limit size
2679-
if (GetTransactionWeight(wtxNew) >= MAX_STANDARD_TX_WEIGHT)
2679+
if (GetTransactionWeight(*wtxNew.tx) >= MAX_STANDARD_TX_WEIGHT)
26802680
{
26812681
strFailReason = _("Transaction too large");
26822682
return false;

src/wallet/wallet.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,6 @@ class CMerkleTx
209209
Init();
210210
}
211211

212-
/** Helper conversion operator to allow passing CMerkleTx where CTransaction is expected.
213-
* TODO: adapt callers and remove this operator. */
214-
operator const CTransaction&() const { return *tx; }
215-
216212
void Init()
217213
{
218214
hashBlock = uint256();

0 commit comments

Comments
 (0)