 |
Bitcoin Core
21.99.0
P2P Digital Currency
|
Go to the documentation of this file.
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);
86 if (block.
vtx.empty())
return std::nullopt;
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;
104 if (!v.
empty())
return std::nullopt;
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;
143 txdata.
Init(signet_txs->m_to_sign, {signet_txs->m_to_spend.vout[0]});
void Init(const T &tx, std::vector< CTxOut > &&spent_outputs)
static std::optional< SignetTxs > Create(const CBlock &block, const CScript &challenge)
uint256 ComputeMerkleRoot(std::vector< uint256 > hashes, bool *mutated)
static bool FetchAndClearCommitmentSection(const Span< const uint8_t > header, CScript &witness_commitment, std::vector< uint8_t > &result)
static constexpr uint8_t SIGNET_HEADER[4]
static constexpr unsigned int BLOCK_SCRIPT_VERIFY_FLAGS
bool CheckSignetBlockSolution(const CBlock &block, const Consensus::Params &consensusParams)
Extract signature and check whether a block has a valid solution.
Minimal stream for reading from an existing vector by reference.
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
A Span is an object that can refer to a contiguous sequence of objects.
Parameters that influence chain consensus.
std::vector< uint8_t > signet_challenge
@ ASSERT_FAIL
Abort execution through assertion failure (for consensus code)
#define LogPrint(category,...)
int GetWitnessCommitmentIndex(const CBlock &block)
Compute at which vout of the block's coinbase transaction the witness commitment occurs,...
Serialized script, used inside transaction inputs and outputs.
Generate the signet tx corresponding to the given block.
std::vector< CTxOut > vout
@ SCRIPT_VERIFY_NULLDUMMY
static uint256 ComputeModifiedMerkleRoot(const CMutableTransaction &cb, const CBlock &block)
std::vector< CTransactionRef > vtx
An outpoint - a combination of a transaction hash and an index n into its vout.
uint256 GetHash() const
Compute the hash of this CMutableTransaction.
A mutable version of CTransaction.
opcodetype
Script opcodes.
static constexpr int NO_WITNESS_COMMITMENT
Index marker for when no witness commitment is present in a coinbase transaction.
static const int INIT_PROTO_VERSION
initial proto version, to be increased after version/verack negotiation
bool GetOp(const_iterator &pc, opcodetype &opcodeRet, std::vector< unsigned char > &vchRet) const