LCOV - code coverage report
Current view: top level - src/instantsend - lock.cpp (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 12 13 92.3 %
Date: 2026-06-25 07:23:43 Functions: 3 3 100.0 %

          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        2666 : uint256 InstantSendLock::GetRequestId() const
      19             : {
      20        2666 :     CHashWriter hw(SER_GETHASH, 0);
      21        2666 :     hw << ISLOCK_REQUESTID_PREFIX;
      22        2666 :     hw << inputs;
      23        2666 :     return hw.GetHash();
      24             : }
      25             : 
      26             : /**
      27             :  * Handles trivial ISLock verification
      28             :  * @return returns false if verification failed, otherwise true
      29             :  */
      30         300 : bool InstantSendLock::TriviallyValid() const
      31             : {
      32         300 :     if (txid.IsNull() || inputs.empty()) {
      33           0 :         return false;
      34             :     }
      35             : 
      36             :     // Check that each input is unique
      37         300 :     const std::unordered_set<COutPoint, SaltedOutpointHasher> inputs_set{inputs.begin(), inputs.end()};
      38         300 :     return inputs_set.size() == inputs.size();
      39         300 : }
      40             : 
      41       26680 : uint256 GenInputLockRequestId(const COutPoint& outpoint)
      42             : {
      43       26680 :     return ::SerializeHash(std::make_pair(INPUTLOCK_REQUESTID_PREFIX, outpoint));
      44             : }
      45             : } // namespace instantsend

Generated by: LCOV version 1.16