| 2010 | } |
| 2011 | |
| 2012 | bool 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 | |
| 2043 | bool CWalletTx::IsEquivalentTo(const CWalletTx& _tx) const |
| 2044 | { |
no test coverage detected