diff options
author | Jeremy Rubin <j@rubin.io> | 2019-09-06 09:24:35 -0700 |
---|---|---|
committer | Jeremy Rubin <j@rubin.io> | 2019-10-21 13:16:22 -0700 |
commit | 8f174ef112199aa4e98d756039855cc561687c2e (patch) | |
tree | d8b6b53d017174af5f1b98d7cde1d814f7949b16 /src | |
parent | b49dcbedf79613f0e0f61bfd742ed265213ed280 (diff) |
Systematize style of IsTrusted single line if
Diffstat (limited to 'src')
-rw-r--r-- | src/wallet/wallet.cpp | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 2204381079..96ae7bbb1e 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2302,38 +2302,29 @@ bool CWalletTx::IsTrusted(interfaces::Chain::Lock& locked_chain) const bool CWalletTx::IsTrusted(interfaces::Chain::Lock& locked_chain, std::set<uint256>& trusted_parents) const { // Quick answer in most cases - if (!locked_chain.checkFinalTx(*tx)) { - return false; - } + if (!locked_chain.checkFinalTx(*tx)) return false; int nDepth = GetDepthInMainChain(locked_chain); - if (nDepth >= 1) - return true; - if (nDepth < 0) - return false; - if (!pwallet->m_spend_zero_conf_change || !IsFromMe(ISMINE_ALL)) // using wtx's cached debit - return false; + if (nDepth >= 1) return true; + if (nDepth < 0) return false; + // using wtx's cached debit + if (!pwallet->m_spend_zero_conf_change || !IsFromMe(ISMINE_ALL)) return false; // Don't trust unconfirmed transactions from us unless they are in the mempool. - if (!InMempool()) - return false; + if (!InMempool()) return false; // Trusted if all inputs are from us and are in the mempool: for (const CTxIn& txin : tx->vin) { // Transactions not sent by us: not trusted const CWalletTx* parent = pwallet->GetWalletTx(txin.prevout.hash); - if (parent == nullptr) - return false; + if (parent == nullptr) return false; const CTxOut& parentOut = parent->tx->vout[txin.prevout.n]; // Check that this specific input being spent is trusted - if (pwallet->IsMine(parentOut) != ISMINE_SPENDABLE) - return false; + if (pwallet->IsMine(parentOut) != ISMINE_SPENDABLE) return false; // If we've already trusted this parent, continue - if (trusted_parents.count(parent->GetHash())) - continue; + if (trusted_parents.count(parent->GetHash())) continue; // Recurse to check that the parent is also trusted - if (!parent->IsTrusted(locked_chain, trusted_parents)) - return false; + if (!parent->IsTrusted(locked_chain, trusted_parents)) return false; trusted_parents.insert(parent->GetHash()); } return true; |