LCOV - code coverage report
Current view: top level - src/index - addressindex_util.cpp (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 10 16 62.5 %
Date: 2026-06-25 07:23:43 Functions: 1 1 100.0 %

          Line data    Source code
       1             : // Copyright (c) 2026 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 <index/addressindex_util.h>
       6             : 
       7             : #include <hash.h>
       8             : #include <script/script.h>
       9             : 
      10             : #include <vector>
      11             : 
      12        2421 : bool AddressBytesFromScript(const CScript& script, AddressType& address_type, uint160& address_bytes)
      13             : {
      14        2421 :     if (script.IsPayToScriptHash()) {
      15         168 :         address_type = AddressType::P2SH;
      16         168 :         address_bytes = uint160(std::vector<uint8_t>(script.begin() + 2, script.begin() + 22));
      17        2421 :     } else if (script.IsPayToPublicKeyHash()) {
      18        2253 :         address_type = AddressType::P2PK_OR_P2PKH;
      19        2253 :         address_bytes = uint160(std::vector<uint8_t>(script.begin() + 3, script.begin() + 23));
      20        2253 :     } else if (script.IsPayToPublicKey()) {
      21           0 :         address_type = AddressType::P2PK_OR_P2PKH;
      22           0 :         address_bytes = Hash160(std::vector<uint8_t>(script.begin() + 1, script.end() - 1));
      23           0 :     } else {
      24           0 :         address_type = AddressType::UNKNOWN;
      25           0 :         address_bytes.SetNull();
      26           0 :         return false;
      27             :     }
      28        2421 :     return true;
      29        2421 : }

Generated by: LCOV version 1.16