MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / IsTrusted

Method IsTrusted

src/wallet/wallet.cpp:2012–2041  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2010}
2011
2012bool CWalletTx::IsTrusted() const
2013{
2014 // Quick answer in most cases
2015 if (!CheckFinalTx(*tx))
2016 return false;
2017 int nDepth = GetDepthInMainChain();
2018 if (nDepth >= 1)
2019 return true;
2020 if (nDepth < 0)
2021 return false;
2022 if (!pwallet->m_spend_zero_conf_change || !IsFromMe(ISMINE_ALL)) // using wtx's cached debit
2023 return false;
2024
2025 // Don't trust unconfirmed transactions from us unless they are in the mempool.
2026 if (!InMempool())
2027 return false;
2028
2029 // Trusted if all inputs are from us and are in the mempool:
2030 for (const CTxIn& txin : tx->vin)
2031 {
2032 // Transactions not sent by us: not trusted
2033 const CWalletTx* parent = pwallet->GetWalletTx(txin.prevout.hash);
2034 if (parent == nullptr)
2035 return false;
2036 const CTxOut& parentOut = parent->tx->vout[txin.prevout.n];
2037 if (pwallet->IsMine(parentOut) != ISMINE_SPENDABLE)
2038 return false;
2039 }
2040 return true;
2041}
2042
2043bool CWalletTx::IsEquivalentTo(const CWalletTx& _tx) const
2044{

Callers 7

WalletTxToJSONFunction · 0.80
GetBalanceMethod · 0.80
GetUnconfirmedBalanceMethod · 0.80
AvailableCoinsMethod · 0.80
GetAddressBalancesMethod · 0.80
MakeWalletTxStatusFunction · 0.80

Calls 3

CheckFinalTxFunction · 0.85
GetWalletTxMethod · 0.80
IsMineMethod · 0.80

Tested by

no test coverage detected