LCOV - code coverage report
Current view: top level - src/instantsend - lock.cpp (source / functions) Hit Total Coverage
Test: test_dash_coverage.info Lines: 7 13 53.8 %
Date: 2026-06-25 07:23:51 Functions: 2 3 66.7 %

          Line data    Source code
       1             : // Copyright (c) 2019-2025 The Dash 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 <instantsend/lock.h>
       6             : 
       7             : #include <hash.h>
       8             : #include <primitives/transaction.h>
       9             : #include <util/hasher.h>
      10             : 
      11             : #include <string_view>
      12             : #include <unordered_set>
      13             : 
      14             : static constexpr std::string_view INPUTLOCK_REQUESTID_PREFIX{"inlock"};
      15             : static constexpr std::string_view ISLOCK_REQUESTID_PREFIX{"islock"};
      16             : 
      17             : namespace instantsend {
      18           4 : uint256 InstantSendLock::GetRequestId() const
      19             : {
      20           4 :     CHashWriter hw(SER_GETHASH, 0);
      21           4 :     hw << ISLOCK_REQUESTID_PREFIX;
      22           4 :     hw << inputs;
      23           4 :     return hw.GetHash();
      24             : }
      25             : 
      26             : /**
      27             :  * Handles trivial ISLock verification
      28             :  * @return returns false if verification failed, otherwise true
      29             :  */
      30           0 : bool InstantSendLock::TriviallyValid() const
      31             : {
      32           0 :     if (txid.IsNull() || inputs.empty()) {
      33           0 :         return false;
      34             :     }
      35             : 
      36             :     // Check that each input is unique
      37           0 :     const std::unordered_set<COutPoint, SaltedOutpointHasher> inputs_set{inputs.begin(), inputs.end()};
      38           0 :     return inputs_set.size() == inputs.size();
      39           0 : }
      40             : 
      41          11 : uint256 GenInputLockRequestId(const COutPoint& outpoint)
      42             : {
      43          11 :     return ::SerializeHash(std::make_pair(INPUTLOCK_REQUESTID_PREFIX, outpoint));
      44             : }
      45             : } // namespace instantsend

Generated by: LCOV version 1.16