From 3820090bd619ac85ab35eff376c03136fe4a9f04 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Mon, 1 Mar 2021 18:07:14 -0800 Subject: Make all SignatureChecker explicit about missing data Remove the implicit MissingDataBehavior::ASSERT_FAIL in the *TransationSignatureChecker constructors, and instead specify it explicit in all call sites: * Test code uses ASSERT_FAIL * Validation uses ASSERT_FAIL (through CachingTransactionSignatureChecker) (including signet) * libconsensus uses FAIL, matching the existing behavior of the non-amount API (and the extended required data for taproot validation is not available yet) * Signing code uses FAIL --- src/signet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/signet.cpp') diff --git a/src/signet.cpp b/src/signet.cpp index e68f031aa4..e41b94da8d 100644 --- a/src/signet.cpp +++ b/src/signet.cpp @@ -139,7 +139,7 @@ bool CheckSignetBlockSolution(const CBlock& block, const Consensus::Params& cons const CScript& scriptSig = signet_txs->m_to_sign.vin[0].scriptSig; const CScriptWitness& witness = signet_txs->m_to_sign.vin[0].scriptWitness; - TransactionSignatureChecker sigcheck(&signet_txs->m_to_sign, /*nIn=*/ 0, /*amount=*/ signet_txs->m_to_spend.vout[0].nValue); + TransactionSignatureChecker sigcheck(&signet_txs->m_to_sign, /*nIn=*/ 0, /*amount=*/ signet_txs->m_to_spend.vout[0].nValue, MissingDataBehavior::ASSERT_FAIL); if (!VerifyScript(scriptSig, signet_txs->m_to_spend.vout[0].scriptPubKey, &witness, BLOCK_SCRIPT_VERIFY_FLAGS, sigcheck)) { LogPrint(BCLog::VALIDATION, "CheckSignetBlockSolution: Errors in block (block solution invalid)\n"); -- cgit v1.2.3 From 725d7ae0494d4a45f5a840bbbd19c008a7363965 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Mon, 1 Mar 2021 18:14:47 -0800 Subject: Use PrecomputedTransactionData in signet check This is out of an abundance of caution only, as signet currently doesn't enable taproot validation flags. Still, it seems cleaner to make sure that all non-test code that passes MissingDataBehavior::ASSERT_FAIL also actually makes sure no data can be missing. --- src/signet.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/signet.cpp') diff --git a/src/signet.cpp b/src/signet.cpp index e41b94da8d..368e16f9e7 100644 --- a/src/signet.cpp +++ b/src/signet.cpp @@ -139,7 +139,9 @@ bool CheckSignetBlockSolution(const CBlock& block, const Consensus::Params& cons const CScript& scriptSig = signet_txs->m_to_sign.vin[0].scriptSig; const CScriptWitness& witness = signet_txs->m_to_sign.vin[0].scriptWitness; - TransactionSignatureChecker sigcheck(&signet_txs->m_to_sign, /*nIn=*/ 0, /*amount=*/ signet_txs->m_to_spend.vout[0].nValue, MissingDataBehavior::ASSERT_FAIL); + PrecomputedTransactionData txdata; + txdata.Init(signet_txs->m_to_sign, {signet_txs->m_to_spend.vout[0]}); + TransactionSignatureChecker sigcheck(&signet_txs->m_to_sign, /*nIn=*/ 0, /*amount=*/ signet_txs->m_to_spend.vout[0].nValue, txdata, MissingDataBehavior::ASSERT_FAIL); if (!VerifyScript(scriptSig, signet_txs->m_to_spend.vout[0].scriptPubKey, &witness, BLOCK_SCRIPT_VERIFY_FLAGS, sigcheck)) { LogPrint(BCLog::VALIDATION, "CheckSignetBlockSolution: Errors in block (block solution invalid)\n"); -- cgit v1.2.3