MCPcopy Create free account
hub / github.com/ElementsProject/elements / CheckSignetBlockSolution

Function CheckSignetBlockSolution

src/signet.cpp:125–152  ·  view source on GitHub ↗

Signet block solution checker

Source from the content-addressed store, hash-verified

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

Callers 4

CheckBlockFunction · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85
FUZZ_TARGET_INITFunction · 0.85
ReadBlockFromDiskFunction · 0.85

Calls 5

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

Tested by 2

BOOST_AUTO_TEST_CASEFunction · 0.68
FUZZ_TARGET_INITFunction · 0.68