signet.h raw
1 // Copyright (c) 2019-present 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 #ifndef BITCOIN_SIGNET_H
6 #define BITCOIN_SIGNET_H
7
8 #include <primitives/block.h>
9 #include <primitives/transaction.h>
10
11 #include <optional>
12
13 class CScript;
14 namespace Consensus {
15 struct Params;
16 } // namespace Consensus
17
18 /**
19 * Extract signature and check whether a block has a valid solution
20 */
21 bool CheckSignetBlockSolution(const CBlock& block, const Consensus::Params& consensusParams);
22
23 /**
24 * Generate the signet tx corresponding to the given block
25 *
26 * The signet tx commits to everything in the block except:
27 * 1. It hashes a modified merkle root with the signet signature removed.
28 * 2. It skips the nonce.
29 */
30 class SignetTxs {
31 template<class T1, class T2>
32 SignetTxs(const T1& to_spend, const T2& to_sign) : m_to_spend{to_spend}, m_to_sign{to_sign} { }
33
34 public:
35 static std::optional<SignetTxs> Create(const CBlock& block, const CScript& challenge);
36
37 const CTransaction m_to_spend;
38 const CTransaction m_to_sign;
39 };
40
41 #endif // BITCOIN_SIGNET_H
42