LCOV - code coverage report
Current view: top level - src/wallet - transaction.cpp (source / functions) Coverage Total Hit
Test: fuzz_coverage.info Lines: 13.8 % 29 4
Test Date: 2024-07-04 04:02:30 Functions: 16.7 % 6 1
Branches: 3.8 % 26 1

             Branch data     Line data    Source code
       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                 :           0 : bool CWalletTx::IsEquivalentTo(const CWalletTx& _tx) const
      13                 :             : {
      14                 :           0 :         CMutableTransaction tx1 {*this->tx};
      15         [ #  # ]:           0 :         CMutableTransaction tx2 {*_tx.tx};
      16   [ #  #  #  # ]:           0 :         for (auto& txin : tx1.vin) txin.scriptSig = CScript();
      17   [ #  #  #  # ]:           0 :         for (auto& txin : tx2.vin) txin.scriptSig = CScript();
      18   [ #  #  #  #  :           0 :         return CTransaction(tx1) == CTransaction(tx2);
                   #  # ]
      19                 :           0 : }
      20                 :             : 
      21                 :           0 : bool CWalletTx::InMempool() const
      22                 :             : {
      23                 :           0 :     return state<TxStateInMempool>();
      24                 :             : }
      25                 :             : 
      26                 :     4057535 : int64_t CWalletTx::GetTxTime() const
      27                 :             : {
      28                 :     4057535 :     int64_t n = nTimeSmart;
      29         [ +  - ]:     4057535 :     return n ? n : nTimeReceived;
      30                 :     4057535 : }
      31                 :             : 
      32                 :           0 : void CWalletTx::updateState(interfaces::Chain& chain)
      33                 :             : {
      34                 :           0 :     bool active;
      35                 :           0 :     auto lookup_block = [&](const uint256& hash, int& height, TxState& state) {
      36                 :             :         // If tx block (or conflicting block) was reorged out of chain
      37                 :             :         // while the wallet was shutdown, change tx status to UNCONFIRMED
      38                 :             :         // and reset block height, hash, and index. ABANDONED tx don't have
      39                 :             :         // associated blocks and don't need to be updated. The case where a
      40                 :             :         // transaction was reorged out while online and then reconfirmed
      41                 :             :         // while offline is covered by the rescan logic.
      42   [ #  #  #  # ]:           0 :         if (!chain.findBlock(hash, FoundBlock().inActiveChain(active).height(height)) || !active) {
      43                 :           0 :             state = TxStateInactive{};
      44                 :           0 :         }
      45                 :           0 :     };
      46         [ #  # ]:           0 :     if (auto* conf = state<TxStateConfirmed>()) {
      47                 :           0 :         lookup_block(conf->confirmed_block_hash, conf->confirmed_block_height, m_state);
      48         [ #  # ]:           0 :     } else if (auto* conf = state<TxStateBlockConflicted>()) {
      49                 :           0 :         lookup_block(conf->conflicting_block_hash, conf->conflicting_block_height, m_state);
      50                 :           0 :     }
      51                 :           0 : }
      52                 :             : 
      53                 :           0 : void CWalletTx::CopyFrom(const CWalletTx& _tx)
      54                 :             : {
      55                 :           0 :     *this = _tx;
      56                 :           0 : }
      57                 :             : } // namespace wallet
        

Generated by: LCOV version 2.0-1