MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / CheckSignetBlockSolution

Function CheckSignetBlockSolution

src/signet.cpp:126–153  ·  view source on GitHub ↗

Signet block solution checker

Source from the content-addressed store, hash-verified

124
125// Signet block solution checker
126bool CheckSignetBlockSolution(const CBlock& block, const Consensus::Params& consensusParams)
127{
128 if (block.GetHash() == consensusParams.hashGenesisBlock) {
129 // genesis block solution is always valid
130 return true;
131 }
132
133 const CScript challenge(consensusParams.signet_challenge.begin(), consensusParams.signet_challenge.end());
134 const std::optional<SignetTxs> signet_txs = SignetTxs::Create(block, challenge);
135
136 if (!signet_txs) {
137 LogDebug(BCLog::VALIDATION, "CheckSignetBlockSolution: Errors in block (block solution parse failure)\n");
138 return false;
139 }
140
141 const CScript& scriptSig = signet_txs->m_to_sign.vin[0].scriptSig;
142 const CScriptWitness& witness = signet_txs->m_to_sign.vin[0].scriptWitness;
143
144 PrecomputedTransactionData txdata;
145 txdata.Init(signet_txs->m_to_sign, {signet_txs->m_to_spend.vout[0]});
146 TransactionSignatureChecker sigcheck(&signet_txs->m_to_sign, /* nInIn= */ 0, /* amountIn= */ signet_txs->m_to_spend.vout[0].nValue, txdata, MissingDataBehavior::ASSERT_FAIL);
147
148 if (!VerifyScript(scriptSig, signet_txs->m_to_spend.vout[0].scriptPubKey, &witness, BLOCK_SCRIPT_VERIFY_FLAGS, sigcheck)) {
149 LogDebug(BCLog::VALIDATION, "CheckSignetBlockSolution: Errors in block (block solution invalid)\n");
150 return false;
151 }
152 return true;
153}

Callers 4

CheckBlockFunction · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85
signet.cppFile · 0.85
ReadBlockMethod · 0.85

Calls 5

VerifyScriptFunction · 0.85
GetHashMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
InitMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.68