Browse Source

[wallet] Remove CTransaction&() helper conversion operator from wallet implementation.

0.16
Karl-Johan Alm 8 years ago
parent
commit
5a5e4e9cc1
No known key found for this signature in database
GPG Key ID: 57AF762DB3353322
  1. 2
      src/qt/transactiondesc.cpp
  2. 2
      src/qt/transactionrecord.cpp
  3. 2
      src/qt/transactiontablemodel.cpp
  4. 2
      src/qt/walletmodeltransaction.cpp
  5. 4
      src/wallet/feebumper.cpp
  6. 2
      src/wallet/rpcdump.cpp
  7. 4
      src/wallet/rpcwallet.cpp
  8. 4
      src/wallet/test/accounting_tests.cpp
  9. 20
      src/wallet/wallet.cpp
  10. 4
      src/wallet/wallet.h
  11. 2
      src/wallet/walletdb.cpp

2
src/qt/transactiondesc.cpp

@ -24,7 +24,7 @@
QString TransactionDesc::FormatTxStatus(const CWalletTx& wtx) QString TransactionDesc::FormatTxStatus(const CWalletTx& wtx)
{ {
AssertLockHeld(cs_main); AssertLockHeld(cs_main);
if (!CheckFinalTx(wtx)) if (!CheckFinalTx(*wtx.tx))
{ {
if (wtx.tx->nLockTime < LOCKTIME_THRESHOLD) if (wtx.tx->nLockTime < LOCKTIME_THRESHOLD)
return tr("Open for %n more block(s)", "", wtx.tx->nLockTime - chainActive.Height()); return tr("Open for %n more block(s)", "", wtx.tx->nLockTime - chainActive.Height());

2
src/qt/transactionrecord.cpp

@ -183,7 +183,7 @@ void TransactionRecord::updateStatus(const CWalletTx &wtx)
status.depth = wtx.GetDepthInMainChain(); status.depth = wtx.GetDepthInMainChain();
status.cur_num_blocks = chainActive.Height(); status.cur_num_blocks = chainActive.Height();
if (!CheckFinalTx(wtx)) if (!CheckFinalTx(*wtx.tx))
{ {
if (wtx.tx->nLockTime < LOCKTIME_THRESHOLD) if (wtx.tx->nLockTime < LOCKTIME_THRESHOLD)
{ {

2
src/qt/transactiontablemodel.cpp

@ -228,7 +228,7 @@ public:
std::map<uint256, CWalletTx>::iterator mi = wallet->mapWallet.find(rec->hash); std::map<uint256, CWalletTx>::iterator mi = wallet->mapWallet.find(rec->hash);
if(mi != wallet->mapWallet.end()) if(mi != wallet->mapWallet.end())
{ {
std::string strHex = EncodeHexTx(static_cast<CTransaction>(mi->second)); std::string strHex = EncodeHexTx(*mi->second.tx);
return QString::fromStdString(strHex); return QString::fromStdString(strHex);
} }
return QString(); return QString();

2
src/qt/walletmodeltransaction.cpp

@ -34,7 +34,7 @@ CWalletTx *WalletModelTransaction::getTransaction()
unsigned int WalletModelTransaction::getTransactionSize() unsigned int WalletModelTransaction::getTransactionSize()
{ {
return (!walletTransaction ? 0 : ::GetVirtualTransactionSize(*walletTransaction)); return (!walletTransaction ? 0 : ::GetVirtualTransactionSize(*walletTransaction->tx));
} }
CAmount WalletModelTransaction::getTransactionFee() CAmount WalletModelTransaction::getTransactionFee()

4
src/wallet/feebumper.cpp

@ -80,7 +80,7 @@ CFeeBumper::CFeeBumper(const CWallet *pWallet, const uint256 txidIn, int newConf
return; return;
} }
if (!SignalsOptInRBF(wtx)) { if (!SignalsOptInRBF(*wtx.tx)) {
vErrors.push_back("Transaction is not BIP 125 replaceable"); vErrors.push_back("Transaction is not BIP 125 replaceable");
currentResult = BumpFeeResult::WALLET_ERROR; currentResult = BumpFeeResult::WALLET_ERROR;
return; return;
@ -94,7 +94,7 @@ CFeeBumper::CFeeBumper(const CWallet *pWallet, const uint256 txidIn, int newConf
// check that original tx consists entirely of our inputs // check that original tx consists entirely of our inputs
// 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) // 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)
if (!pWallet->IsAllFromMe(wtx, ISMINE_SPENDABLE)) { if (!pWallet->IsAllFromMe(*wtx.tx, ISMINE_SPENDABLE)) {
vErrors.push_back("Transaction contains inputs that don't belong to this wallet"); vErrors.push_back("Transaction contains inputs that don't belong to this wallet");
currentResult = BumpFeeResult::WALLET_ERROR; currentResult = BumpFeeResult::WALLET_ERROR;
return; return;

2
src/wallet/rpcdump.cpp

@ -339,7 +339,7 @@ UniValue importprunedfunds(const JSONRPCRequest& request)
LOCK2(cs_main, pwallet->cs_wallet); LOCK2(cs_main, pwallet->cs_wallet);
if (pwallet->IsMine(wtx)) { if (pwallet->IsMine(*wtx.tx)) {
pwallet->AddToWallet(wtx, false); pwallet->AddToWallet(wtx, false);
return NullUniValue; return NullUniValue;
} }

4
src/wallet/rpcwallet.cpp

@ -87,7 +87,7 @@ void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry)
std::string rbfStatus = "no"; std::string rbfStatus = "no";
if (confirms <= 0) { if (confirms <= 0) {
LOCK(mempool.cs); LOCK(mempool.cs);
RBFTransactionState rbfState = IsRBFOptIn(wtx, mempool); RBFTransactionState rbfState = IsRBFOptIn(*wtx.tx, mempool);
if (rbfState == RBF_TRANSACTIONSTATE_UNKNOWN) if (rbfState == RBF_TRANSACTIONSTATE_UNKNOWN)
rbfStatus = "unknown"; rbfStatus = "unknown";
else if (rbfState == RBF_TRANSACTIONSTATE_REPLACEABLE_BIP125) else if (rbfState == RBF_TRANSACTIONSTATE_REPLACEABLE_BIP125)
@ -1867,7 +1867,7 @@ UniValue gettransaction(const JSONRPCRequest& request)
ListTransactions(pwallet, wtx, "*", 0, false, details, filter); ListTransactions(pwallet, wtx, "*", 0, false, details, filter);
entry.push_back(Pair("details", details)); entry.push_back(Pair("details", details));
std::string strHex = EncodeHexTx(static_cast<CTransaction>(wtx), RPCSerializationFlags()); std::string strHex = EncodeHexTx(*wtx.tx, RPCSerializationFlags());
entry.push_back(Pair("hex", strHex)); entry.push_back(Pair("hex", strHex));
return entry; return entry;

4
src/wallet/test/accounting_tests.cpp

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

20
src/wallet/wallet.cpp

@ -1592,7 +1592,7 @@ CAmount CWalletTx::GetDebit(const isminefilter& filter) const
debit += nDebitCached; debit += nDebitCached;
else else
{ {
nDebitCached = pwallet->GetDebit(*this, ISMINE_SPENDABLE); nDebitCached = pwallet->GetDebit(*tx, ISMINE_SPENDABLE);
fDebitCached = true; fDebitCached = true;
debit += nDebitCached; debit += nDebitCached;
} }
@ -1603,7 +1603,7 @@ CAmount CWalletTx::GetDebit(const isminefilter& filter) const
debit += nWatchDebitCached; debit += nWatchDebitCached;
else else
{ {
nWatchDebitCached = pwallet->GetDebit(*this, ISMINE_WATCH_ONLY); nWatchDebitCached = pwallet->GetDebit(*tx, ISMINE_WATCH_ONLY);
fWatchDebitCached = true; fWatchDebitCached = true;
debit += nWatchDebitCached; debit += nWatchDebitCached;
} }
@ -1625,7 +1625,7 @@ CAmount CWalletTx::GetCredit(const isminefilter& filter) const
credit += nCreditCached; credit += nCreditCached;
else else
{ {
nCreditCached = pwallet->GetCredit(*this, ISMINE_SPENDABLE); nCreditCached = pwallet->GetCredit(*tx, ISMINE_SPENDABLE);
fCreditCached = true; fCreditCached = true;
credit += nCreditCached; credit += nCreditCached;
} }
@ -1636,7 +1636,7 @@ CAmount CWalletTx::GetCredit(const isminefilter& filter) const
credit += nWatchCreditCached; credit += nWatchCreditCached;
else else
{ {
nWatchCreditCached = pwallet->GetCredit(*this, ISMINE_WATCH_ONLY); nWatchCreditCached = pwallet->GetCredit(*tx, ISMINE_WATCH_ONLY);
fWatchCreditCached = true; fWatchCreditCached = true;
credit += nWatchCreditCached; credit += nWatchCreditCached;
} }
@ -1650,7 +1650,7 @@ CAmount CWalletTx::GetImmatureCredit(bool fUseCache) const
{ {
if (fUseCache && fImmatureCreditCached) if (fUseCache && fImmatureCreditCached)
return nImmatureCreditCached; return nImmatureCreditCached;
nImmatureCreditCached = pwallet->GetCredit(*this, ISMINE_SPENDABLE); nImmatureCreditCached = pwallet->GetCredit(*tx, ISMINE_SPENDABLE);
fImmatureCreditCached = true; fImmatureCreditCached = true;
return nImmatureCreditCached; return nImmatureCreditCached;
} }
@ -1694,7 +1694,7 @@ CAmount CWalletTx::GetImmatureWatchOnlyCredit(const bool& fUseCache) const
{ {
if (fUseCache && fImmatureWatchCreditCached) if (fUseCache && fImmatureWatchCreditCached)
return nImmatureWatchCreditCached; return nImmatureWatchCreditCached;
nImmatureWatchCreditCached = pwallet->GetCredit(*this, ISMINE_WATCH_ONLY); nImmatureWatchCreditCached = pwallet->GetCredit(*tx, ISMINE_WATCH_ONLY);
fImmatureWatchCreditCached = true; fImmatureWatchCreditCached = true;
return nImmatureWatchCreditCached; return nImmatureWatchCreditCached;
} }
@ -1735,7 +1735,7 @@ CAmount CWalletTx::GetChange() const
{ {
if (fChangeCached) if (fChangeCached)
return nChangeCached; return nChangeCached;
nChangeCached = pwallet->GetChange(*this); nChangeCached = pwallet->GetChange(*tx);
fChangeCached = true; fChangeCached = true;
return nChangeCached; return nChangeCached;
} }
@ -1749,7 +1749,7 @@ bool CWalletTx::InMempool() const
bool CWalletTx::IsTrusted() const bool CWalletTx::IsTrusted() const
{ {
// Quick answer in most cases // Quick answer in most cases
if (!CheckFinalTx(*this)) if (!CheckFinalTx(*tx))
return false; return false;
int nDepth = GetDepthInMainChain(); int nDepth = GetDepthInMainChain();
if (nDepth >= 1) if (nDepth >= 1)
@ -1988,7 +1988,7 @@ void CWallet::AvailableCoins(std::vector<COutput>& vCoins, bool fOnlySafe, const
const uint256& wtxid = it->first; const uint256& wtxid = it->first;
const CWalletTx* pcoin = &(*it).second; const CWalletTx* pcoin = &(*it).second;
if (!CheckFinalTx(*pcoin)) if (!CheckFinalTx(*pcoin->tx))
continue; continue;
if (pcoin->IsCoinBase() && pcoin->GetBlocksToMaturity() > 0) if (pcoin->IsCoinBase() && pcoin->GetBlocksToMaturity() > 0)
@ -2676,7 +2676,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
wtxNew.SetTx(MakeTransactionRef(std::move(txNew))); wtxNew.SetTx(MakeTransactionRef(std::move(txNew)));
// Limit size // Limit size
if (GetTransactionWeight(wtxNew) >= MAX_STANDARD_TX_WEIGHT) if (GetTransactionWeight(*wtxNew.tx) >= MAX_STANDARD_TX_WEIGHT)
{ {
strFailReason = _("Transaction too large"); strFailReason = _("Transaction too large");
return false; return false;

4
src/wallet/wallet.h

@ -209,10 +209,6 @@ public:
Init(); Init();
} }
/** Helper conversion operator to allow passing CMerkleTx where CTransaction is expected.
* TODO: adapt callers and remove this operator. */
operator const CTransaction&() const { return *tx; }
void Init() void Init()
{ {
hashBlock = uint256(); hashBlock = uint256();

2
src/wallet/walletdb.cpp

@ -304,7 +304,7 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
CWalletTx wtx; CWalletTx wtx;
ssValue >> wtx; ssValue >> wtx;
CValidationState state; CValidationState state;
if (!(CheckTransaction(wtx, state) && (wtx.GetHash() == hash) && state.IsValid())) if (!(CheckTransaction(*wtx.tx, state) && (wtx.GetHash() == hash) && state.IsValid()))
return false; return false;
// Undo serialize changes in 31600 // Undo serialize changes in 31600

Loading…
Cancel
Save