Skip to content
Permalink
Browse files

Remove uses of CheckFinalTx in wallet code

This commit does not change behavior.
  • Loading branch information...
ryanofsky committed Jul 28, 2017
1 parent c119463 commit 2dd492b5805041468dc73e03d984de46ce56fec7
Showing with 12 additions and 6 deletions.
  1. +5 −0 src/ipc/interfaces.h
  2. +1 −0 src/ipc/local/bitcoind.cpp
  3. +3 −3 src/wallet/rpcwallet.cpp
  4. +3 −3 src/wallet/wallet.cpp
@@ -1,6 +1,8 @@
#ifndef BITCOIN_IPC_INTERFACES_H
#define BITCOIN_IPC_INTERFACES_H

#include "primitives/transaction.h"

#include <memory>
#include <vector>

@@ -88,6 +90,9 @@ class Chain

//! Return height of block on the chain using locator.
virtual int findLocatorFork(const CBlockLocator& locator) = 0;

//! Check if transaction will be final given chain height current time.
virtual bool checkFinalTx(const CTransaction& tx) = 0;
};

//! Return LockedState interface. Chain is locked when this is called, and
@@ -80,6 +80,7 @@ class LockedStateImpl : public Chain::LockedState
CBlockIndex* fork = FindForkInGlobalIndex(::chainActive, locator);
return fork ? fork->nHeight : -1;
}
bool checkFinalTx(const CTransaction& tx) override { return CheckFinalTx(tx); }
};

class LockingStateImpl : public LockedStateImpl, public CCriticalBlock
@@ -680,7 +680,7 @@ UniValue getreceivedbyaddress(const JSONRPCRequest& request)
CAmount nAmount = 0;
for (const std::pair<uint256, CWalletTx>& pairWtx : pwallet->mapWallet) {
const CWalletTx& wtx = pairWtx.second;
if (wtx.IsCoinBase() || !CheckFinalTx(*wtx.tx))
if (wtx.IsCoinBase() || !ipc_locked->checkFinalTx(*wtx.tx))
continue;

for (const CTxOut& txout : wtx.tx->vout)
@@ -740,7 +740,7 @@ UniValue getreceivedbyaccount(const JSONRPCRequest& request)
CAmount nAmount = 0;
for (const std::pair<uint256, CWalletTx>& pairWtx : pwallet->mapWallet) {
const CWalletTx& wtx = pairWtx.second;
if (wtx.IsCoinBase() || !CheckFinalTx(*wtx.tx))
if (wtx.IsCoinBase() || !ipc_locked->checkFinalTx(*wtx.tx))
continue;

for (const CTxOut& txout : wtx.tx->vout)
@@ -1320,7 +1320,7 @@ UniValue ListReceived(ipc::Chain::LockedState& ipc_locked, CWallet * const pwall
for (const std::pair<uint256, CWalletTx>& pairWtx : pwallet->mapWallet) {
const CWalletTx& wtx = pairWtx.second;

if (wtx.IsCoinBase() || !CheckFinalTx(*wtx.tx))
if (wtx.IsCoinBase() || !ipc_locked.checkFinalTx(*wtx.tx))
continue;

int nDepth = wtx.GetDepthInMainChain(ipc_locked);
@@ -1884,7 +1884,7 @@ bool CWalletTx::InMempool() const
bool CWalletTx::IsTrusted(ipc::Chain::LockedState& ipc_locked) const
{
// Quick answer in most cases
if (!CheckFinalTx(*this))
if (!ipc_locked.checkFinalTx(*this))
return false;
int nDepth = GetDepthInMainChain(ipc_locked);
if (nDepth >= 1)
@@ -2092,7 +2092,7 @@ CAmount CWallet::GetLegacyBalance(const isminefilter& filter, int minDepth, cons
for (const auto& entry : mapWallet) {
const CWalletTx& wtx = entry.second;
const int depth = wtx.GetDepthInMainChain(*ipc_locked);
if (depth < 0 || !CheckFinalTx(*wtx.tx) || wtx.GetBlocksToMaturity(*ipc_locked) > 0) {
if (depth < 0 || !ipc_locked->checkFinalTx(*wtx.tx) || wtx.GetBlocksToMaturity(*ipc_locked) > 0) {
continue;
}

@@ -2152,7 +2152,7 @@ void CWallet::AvailableCoins(ipc::Chain::LockedState& ipc_locked, std::vector<CO
const uint256& wtxid = it->first;
const CWalletTx* pcoin = &(*it).second;

if (!CheckFinalTx(*pcoin))
if (!ipc_locked.checkFinalTx(*pcoin))
continue;

if (pcoin->IsCoinBase() && pcoin->GetBlocksToMaturity(ipc_locked) > 0)

0 comments on commit 2dd492b

Please sign in to comment.
You can’t perform that action at this time.