/Users/eugenesiegel/btc/bitcoin/src/wallet/transaction.cpp
| Line | Count | Source (jump to first uncovered line) | 
| 1 |  | // Copyright (c) 2021 The Bitcoin Core developers | 
| 2 |  | // Distributed under the MIT software license, see the accompanying | 
| 3 |  | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | 
| 4 |  |  | 
| 5 |  | #include <wallet/transaction.h> | 
| 6 |  |  | 
| 7 |  | #include <interfaces/chain.h> | 
| 8 |  |  | 
| 9 |  | using interfaces::FoundBlock; | 
| 10 |  |  | 
| 11 |  | namespace wallet { | 
| 12 |  | bool CWalletTx::IsEquivalentTo(const CWalletTx& _tx) const | 
| 13 | 0 | { | 
| 14 | 0 |         CMutableTransaction tx1 {*this->tx}; | 
| 15 | 0 |         CMutableTransaction tx2 {*_tx.tx}; | 
| 16 | 0 |         for (auto& txin : tx1.vin) { | 
| 17 | 0 |             txin.scriptSig = CScript(); | 
| 18 | 0 |             txin.scriptWitness.SetNull(); | 
| 19 | 0 |         } | 
| 20 | 0 |         for (auto& txin : tx2.vin) { | 
| 21 | 0 |             txin.scriptSig = CScript(); | 
| 22 | 0 |             txin.scriptWitness.SetNull(); | 
| 23 | 0 |         } | 
| 24 | 0 |         return CTransaction(tx1) == CTransaction(tx2); | 
| 25 | 0 | } | 
| 26 |  |  | 
| 27 |  | bool CWalletTx::InMempool() const | 
| 28 | 0 | { | 
| 29 | 0 |     return state<TxStateInMempool>(); | 
| 30 | 0 | } | 
| 31 |  |  | 
| 32 |  | int64_t CWalletTx::GetTxTime() const | 
| 33 | 0 | { | 
| 34 | 0 |     int64_t n = nTimeSmart; | 
| 35 | 0 |     return n ? n : nTimeReceived; | 
| 36 | 0 | } | 
| 37 |  |  | 
| 38 |  | void CWalletTx::updateState(interfaces::Chain& chain) | 
| 39 | 0 | { | 
| 40 | 0 |     bool active; | 
| 41 | 0 |     auto lookup_block = [&](const uint256& hash, int& height, TxState& state) { | 
| 42 |  |         // If tx block (or conflicting block) was reorged out of chain | 
| 43 |  |         // while the wallet was shutdown, change tx status to UNCONFIRMED | 
| 44 |  |         // and reset block height, hash, and index. ABANDONED tx don't have | 
| 45 |  |         // associated blocks and don't need to be updated. The case where a | 
| 46 |  |         // transaction was reorged out while online and then reconfirmed | 
| 47 |  |         // while offline is covered by the rescan logic. | 
| 48 | 0 |         if (!chain.findBlock(hash, FoundBlock().inActiveChain(active).height(height)) || !active) { | 
| 49 | 0 |             state = TxStateInactive{}; | 
| 50 | 0 |         } | 
| 51 | 0 |     }; | 
| 52 | 0 |     if (auto* conf = state<TxStateConfirmed>()) { | 
| 53 | 0 |         lookup_block(conf->confirmed_block_hash, conf->confirmed_block_height, m_state); | 
| 54 | 0 |     } else if (auto* conf = state<TxStateBlockConflicted>()) { | 
| 55 | 0 |         lookup_block(conf->conflicting_block_hash, conf->conflicting_block_height, m_state); | 
| 56 | 0 |     } | 
| 57 | 0 | } | 
| 58 |  |  | 
| 59 |  | void CWalletTx::CopyFrom(const CWalletTx& _tx) | 
| 60 | 0 | { | 
| 61 | 0 |     *this = _tx; | 
| 62 | 0 | } | 
| 63 |  | } // namespace wallet |