@@ -65,7 +65,7 @@ static uint256 ComputeModifiedMerkleRoot(const CMutableTransaction& cb, const CB
6565 return ComputeMerkleRoot (std::move (leaves));
6666}
6767
68- SignetTxs SignetTxs::Create (const CBlock& block, const CScript& challenge)
68+ Optional< SignetTxs> SignetTxs::Create (const CBlock& block, const CScript& challenge)
6969{
7070 CMutableTransaction tx_to_spend;
7171 tx_to_spend.nVersion = 0 ;
@@ -83,12 +83,12 @@ SignetTxs SignetTxs::Create(const CBlock& block, const CScript& challenge)
8383 // responses from block coinbase tx
8484
8585 // find and delete signet signature
86- if (block.vtx .empty ()) return invalid () ; // no coinbase tx in block; invalid
86+ if (block.vtx .empty ()) return nullopt ; // no coinbase tx in block; invalid
8787 CMutableTransaction modified_cb (*block.vtx .at (0 ));
8888
8989 const int cidx = GetWitnessCommitmentIndex (block);
9090 if (cidx == NO_WITNESS_COMMITMENT) {
91- return invalid () ; // require a witness commitment
91+ return nullopt ; // require a witness commitment
9292 }
9393
9494 CScript& witness_commitment = modified_cb.vout .at (cidx).scriptPubKey ;
@@ -101,9 +101,9 @@ SignetTxs SignetTxs::Create(const CBlock& block, const CScript& challenge)
101101 VectorReader v (SER_NETWORK, INIT_PROTO_VERSION, signet_solution, 0 );
102102 v >> tx_spending.vin [0 ].scriptSig ;
103103 v >> tx_spending.vin [0 ].scriptWitness .stack ;
104- if (!v.empty ()) return invalid () ; // extraneous data encountered
104+ if (!v.empty ()) return nullopt ; // extraneous data encountered
105105 } catch (const std::exception&) {
106- return invalid () ; // parsing error
106+ return nullopt ; // parsing error
107107 }
108108 }
109109 uint256 signet_merkle = ComputeModifiedMerkleRoot (modified_cb, block);
@@ -117,7 +117,7 @@ SignetTxs SignetTxs::Create(const CBlock& block, const CScript& challenge)
117117 tx_to_spend.vin [0 ].scriptSig << block_data;
118118 tx_spending.vin [0 ].prevout = COutPoint (tx_to_spend.GetHash (), 0 );
119119
120- return {tx_to_spend, tx_spending};
120+ return SignetTxs {tx_to_spend, tx_spending};
121121}
122122
123123// Signet block solution checker
@@ -129,19 +129,19 @@ bool CheckSignetBlockSolution(const CBlock& block, const Consensus::Params& cons
129129 }
130130
131131 const CScript challenge (consensusParams.signet_challenge .begin (), consensusParams.signet_challenge .end ());
132- const SignetTxs signet_txs (block, challenge);
132+ const Optional< SignetTxs> signet_txs = SignetTxs::Create (block, challenge);
133133
134- if (!signet_txs. m_valid ) {
134+ if (!signet_txs) {
135135 LogPrint (BCLog::VALIDATION, " CheckSignetBlockSolution: Errors in block (block solution parse failure)\n " );
136136 return false ;
137137 }
138138
139- const CScript& scriptSig = signet_txs. m_to_sign .vin [0 ].scriptSig ;
140- const CScriptWitness& witness = signet_txs. m_to_sign .vin [0 ].scriptWitness ;
139+ const CScript& scriptSig = signet_txs-> m_to_sign .vin [0 ].scriptSig ;
140+ const CScriptWitness& witness = signet_txs-> m_to_sign .vin [0 ].scriptWitness ;
141141
142- TransactionSignatureChecker sigcheck (&signet_txs. m_to_sign , /* nIn=*/ 0 , /* amount=*/ signet_txs. m_to_spend .vout [0 ].nValue );
142+ TransactionSignatureChecker sigcheck (&signet_txs-> m_to_sign , /* nIn=*/ 0 , /* amount=*/ signet_txs-> m_to_spend .vout [0 ].nValue );
143143
144- if (!VerifyScript (scriptSig, signet_txs. m_to_spend .vout [0 ].scriptPubKey , &witness, BLOCK_SCRIPT_VERIFY_FLAGS, sigcheck)) {
144+ if (!VerifyScript (scriptSig, signet_txs-> m_to_spend .vout [0 ].scriptPubKey , &witness, BLOCK_SCRIPT_VERIFY_FLAGS, sigcheck)) {
145145 LogPrint (BCLog::VALIDATION, " CheckSignetBlockSolution: Errors in block (block solution invalid)\n " );
146146 return false ;
147147 }
0 commit comments