33 bool found_header =
false;
38 std::vector<uint8_t> pushdata;
39 while (witness_commitment.
GetOp(pc, opcode, pushdata)) {
40 if (pushdata.size() > 0) {
43 result.insert(result.end(), pushdata.begin() + header.
size(), pushdata.end());
44 pushdata.erase(pushdata.begin() + header.
size(), pushdata.end());
47 replacement << pushdata;
49 replacement << opcode;
53 if (found_header) witness_commitment = replacement;
59 std::vector<uint256> leaves;
60 leaves.resize(block.
vtx.size());
62 for (
size_t s = 1; s < block.
vtx.size(); ++s) {
63 leaves[s] = block.
vtx[s]->GetHash();
74 tx_to_spend.
vout.emplace_back(0, challenge);
94 CScript& witness_commitment = modified_cb.vout.at(cidx).scriptPubKey;
96 std::vector<uint8_t> signet_solution;
102 v >> tx_spending.
vin[0].scriptSig;
103 v >> tx_spending.
vin[0].scriptWitness.stack;
105 }
catch (
const std::exception&) {
111 std::vector<uint8_t> block_data;
115 writer << signet_merkle;
116 writer << block.
nTime;
117 tx_to_spend.
vin[0].scriptSig << block_data;
120 return SignetTxs{tx_to_spend, tx_spending};
139 const CScript& scriptSig = signet_txs->m_to_sign.vin[0].scriptSig;
140 const CScriptWitness& witness = signet_txs->m_to_sign.vin[0].scriptWitness;
#define LogPrint(category,...)
bool GetOp(const_iterator &pc, opcodetype &opcodeRet, std::vector< unsigned char > &vchRet) const
bool VerifyScript(const CScript &scriptSig, const CScript &scriptPubKey, const CScriptWitness *witness, unsigned int flags, const BaseSignatureChecker &checker, ScriptError *serror)
constexpr std::size_t size() const noexcept
static auto & nullopt
Substitute for C++17 std::nullopt DEPRECATED use std::nullopt in new code.
static constexpr int NO_WITNESS_COMMITMENT
Index marker for when no witness commitment is present in a coinbase transaction. ...
opcodetype
Script opcodes.
Minimal stream for reading from an existing vector by reference.
static bool FetchAndClearCommitmentSection(const Span< const uint8_t > header, CScript &witness_commitment, std::vector< uint8_t > &result)
static const int INIT_PROTO_VERSION
initial proto version, to be increased after version/verack negotiation
Parameters that influence chain consensus.
An outpoint - a combination of a transaction hash and an index n into its vout.
std::vector< CTxOut > vout
uint256 ComputeMerkleRoot(std::vector< uint256 > hashes, bool *mutated)
std::vector< CTransactionRef > vtx
uint256 GetHash() const
Compute the hash of this CMutableTransaction.
Serialized script, used inside transaction inputs and outputs.
std::vector< uint8_t > signet_challenge
static uint256 ComputeModifiedMerkleRoot(const CMutableTransaction &cb, const CBlock &block)
A mutable version of CTransaction.
A Span is an object that can refer to a contiguous sequence of objects.
static constexpr unsigned int BLOCK_SCRIPT_VERIFY_FLAGS
Generate the signet tx corresponding to the given block.
int GetWitnessCommitmentIndex(const CBlock &block)
Compute at which vout of the block's coinbase transaction the witness commitment occurs, or -1 if not found.
static Optional< SignetTxs > Create(const CBlock &block, const CScript &challenge)
std::optional< T > Optional
Substitute for C++17 std::optional DEPRECATED use std::optional in new code.
static constexpr uint8_t SIGNET_HEADER[4]
bool CheckSignetBlockSolution(const CBlock &block, const Consensus::Params &consensusParams)
Extract signature and check whether a block has a valid solution.