@@ -65,7 +65,7 @@ static uint256 ComputeModifiedMerkleRoot(const CMutableTransaction& cb, const CB
65
65
return ComputeMerkleRoot (std::move (leaves));
66
66
}
67
67
68
- SignetTxs SignetTxs::Create (const CBlock& block, const CScript& challenge)
68
+ Optional< SignetTxs> SignetTxs::Create (const CBlock& block, const CScript& challenge)
69
69
{
70
70
CMutableTransaction tx_to_spend;
71
71
tx_to_spend.nVersion = 0 ;
@@ -83,12 +83,12 @@ SignetTxs SignetTxs::Create(const CBlock& block, const CScript& challenge)
83
83
// responses from block coinbase tx
84
84
85
85
// 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
87
87
CMutableTransaction modified_cb (*block.vtx .at (0 ));
88
88
89
89
const int cidx = GetWitnessCommitmentIndex (block);
90
90
if (cidx == NO_WITNESS_COMMITMENT) {
91
- return invalid () ; // require a witness commitment
91
+ return nullopt ; // require a witness commitment
92
92
}
93
93
94
94
CScript& witness_commitment = modified_cb.vout .at (cidx).scriptPubKey ;
@@ -101,9 +101,9 @@ SignetTxs SignetTxs::Create(const CBlock& block, const CScript& challenge)
101
101
VectorReader v (SER_NETWORK, INIT_PROTO_VERSION, signet_solution, 0 );
102
102
v >> tx_spending.vin [0 ].scriptSig ;
103
103
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
105
105
} catch (const std::exception&) {
106
- return invalid () ; // parsing error
106
+ return nullopt ; // parsing error
107
107
}
108
108
}
109
109
uint256 signet_merkle = ComputeModifiedMerkleRoot (modified_cb, block);
@@ -117,7 +117,7 @@ SignetTxs SignetTxs::Create(const CBlock& block, const CScript& challenge)
117
117
tx_to_spend.vin [0 ].scriptSig << block_data;
118
118
tx_spending.vin [0 ].prevout = COutPoint (tx_to_spend.GetHash (), 0 );
119
119
120
- return {tx_to_spend, tx_spending};
120
+ return SignetTxs {tx_to_spend, tx_spending};
121
121
}
122
122
123
123
// Signet block solution checker
@@ -129,19 +129,19 @@ bool CheckSignetBlockSolution(const CBlock& block, const Consensus::Params& cons
129
129
}
130
130
131
131
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);
133
133
134
- if (!signet_txs. m_valid ) {
134
+ if (!signet_txs) {
135
135
LogPrint (BCLog::VALIDATION, " CheckSignetBlockSolution: Errors in block (block solution parse failure)\n " );
136
136
return false ;
137
137
}
138
138
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 ;
141
141
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 );
143
143
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)) {
145
145
LogPrint (BCLog::VALIDATION, " CheckSignetBlockSolution: Errors in block (block solution invalid)\n " );
146
146
return false ;
147
147
}
0 commit comments