LCOV - code coverage report
Current view: top level - src/script - solver.h (source / functions) Coverage Total Hit
Test: fuzz_coverage.info Lines: 100.0 % 2 2
Test Date: 2024-12-04 04:00:22 Functions: - 0 0
Branches: 100.0 % 6 6

             Branch data     Line data    Source code
       1                 :             : // Copyright (c) 2009-2010 Satoshi Nakamoto
       2                 :             : // Copyright (c) 2009-2022 The Bitcoin Core developers
       3                 :             : // Distributed under the MIT software license, see the accompanying
       4                 :             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       5                 :             : 
       6                 :             : // The Solver functions are used by policy and the wallet, but not consensus.
       7                 :             : 
       8                 :             : #ifndef BITCOIN_SCRIPT_SOLVER_H
       9                 :             : #define BITCOIN_SCRIPT_SOLVER_H
      10                 :             : 
      11                 :             : #include <attributes.h>
      12                 :             : #include <script/script.h>
      13                 :             : 
      14                 :             : #include <string>
      15                 :             : #include <optional>
      16                 :             : #include <utility>
      17                 :             : #include <vector>
      18                 :             : 
      19                 :             : class CPubKey;
      20                 :             : template <typename C> class Span;
      21                 :             : 
      22                 :             : enum class TxoutType {
      23                 :             :     NONSTANDARD,
      24                 :             :     // 'standard' transaction types:
      25                 :             :     ANCHOR, //!< anyone can spend script
      26                 :             :     PUBKEY,
      27                 :             :     PUBKEYHASH,
      28                 :             :     SCRIPTHASH,
      29                 :             :     MULTISIG,
      30                 :             :     NULL_DATA, //!< unspendable OP_RETURN script that carries data
      31                 :             :     WITNESS_V0_SCRIPTHASH,
      32                 :             :     WITNESS_V0_KEYHASH,
      33                 :             :     WITNESS_V1_TAPROOT,
      34                 :             :     WITNESS_UNKNOWN, //!< Only for Witness versions not already defined above
      35                 :             : };
      36                 :             : 
      37                 :             : /** Get the name of a TxoutType as a string */
      38                 :             : std::string GetTxnOutputType(TxoutType t);
      39                 :             : 
      40                 :     6287279 : constexpr bool IsPushdataOp(opcodetype opcode)
      41                 :             : {
      42   [ +  +  +  + ]:     6287279 :     return opcode > OP_FALSE && opcode <= OP_PUSHDATA4;
                 [ +  + ]
      43                 :             : }
      44                 :             : 
      45                 :             : /**
      46                 :             :  * Parse a scriptPubKey and identify script type for standard scripts. If
      47                 :             :  * successful, returns script type and parsed pubkeys or hashes, depending on
      48                 :             :  * the type. For example, for a P2SH script, vSolutionsRet will contain the
      49                 :             :  * script hash, for P2PKH it will contain the key hash, etc.
      50                 :             :  *
      51                 :             :  * @param[in]   scriptPubKey   Script to parse
      52                 :             :  * @param[out]  vSolutionsRet  Vector of parsed pubkeys and hashes
      53                 :             :  * @return                     The script type. TxoutType::NONSTANDARD represents a failed solve.
      54                 :             :  */
      55                 :             : TxoutType Solver(const CScript& scriptPubKey, std::vector<std::vector<unsigned char>>& vSolutionsRet);
      56                 :             : 
      57                 :             : /** Generate a P2PK script for the given pubkey. */
      58                 :             : CScript GetScriptForRawPubKey(const CPubKey& pubkey);
      59                 :             : 
      60                 :             : /** Determine if script is a "multi_a" script. Returns (threshold, keyspans) if so, and nullopt otherwise.
      61                 :             :  *  The keyspans refer to bytes in the passed script. */
      62                 :             : std::optional<std::pair<int, std::vector<Span<const unsigned char>>>> MatchMultiA(const CScript& script LIFETIMEBOUND);
      63                 :             : 
      64                 :             : /** Generate a multisig script. */
      65                 :             : CScript GetScriptForMultisig(int nRequired, const std::vector<CPubKey>& keys);
      66                 :             : 
      67                 :             : #endif // BITCOIN_SCRIPT_SOLVER_H
        

Generated by: LCOV version 2.0-1