@@ -342,13 +342,14 @@ bool CheckCbTxBestChainlock(const CBlock& block, const CBlockIndex* pindex,
342
342
if (!opt_cbTx) {
343
343
return state.Invalid (BlockValidationResult::BLOCK_CONSENSUS, " bad-cbtx-payload" );
344
344
}
345
+ const auto & cbTx = *opt_cbTx;
345
346
346
- if (opt_cbTx-> nVersion < CCbTx::Version::CLSIG_AND_BALANCE) {
347
+ if (cbTx. nVersion < CCbTx::Version::CLSIG_AND_BALANCE) {
347
348
return true ;
348
349
}
349
350
350
351
auto best_clsig = chainlock_handler.GetBestChainLock ();
351
- if (best_clsig.getHeight () == pindex->nHeight - 1 && opt_cbTx-> bestCLHeightDiff == 0 && opt_cbTx-> bestCLSignature == best_clsig.getSig ()) {
352
+ if (best_clsig.getHeight () == pindex->nHeight - 1 && cbTx. bestCLHeightDiff == 0 && cbTx. bestCLSignature == best_clsig.getSig ()) {
352
353
// matches our best clsig which still hold values for the previous block
353
354
return true ;
354
355
}
@@ -357,27 +358,27 @@ bool CheckCbTxBestChainlock(const CBlock& block, const CBlockIndex* pindex,
357
358
// If std::optional prevBlockCoinbaseChainlock is empty, then up to the previous block, coinbase Chainlock is null.
358
359
if (prevBlockCoinbaseChainlock.has_value ()) {
359
360
// Previous block Coinbase has a non-null Chainlock: current block's Chainlock must be non-null and at least as new as the previous one
360
- if (!opt_cbTx-> bestCLSignature .IsValid ()) {
361
+ if (!cbTx. bestCLSignature .IsValid ()) {
361
362
// IsNull() doesn't exist for CBLSSignature: we assume that a non valid BLS sig is null
362
363
return state.Invalid (BlockValidationResult::BLOCK_CONSENSUS, " bad-cbtx-null-clsig" );
363
364
}
364
- if (opt_cbTx-> bestCLHeightDiff > prevBlockCoinbaseChainlock.value ().second + 1 ) {
365
+ if (cbTx. bestCLHeightDiff > prevBlockCoinbaseChainlock.value ().second + 1 ) {
365
366
return state.Invalid (BlockValidationResult::BLOCK_CONSENSUS, " bad-cbtx-older-clsig" );
366
367
}
367
368
}
368
369
369
370
// IsNull() doesn't exist for CBLSSignature: we assume that a valid BLS sig is non-null
370
- if (opt_cbTx-> bestCLSignature .IsValid ()) {
371
- int curBlockCoinbaseCLHeight = pindex->nHeight - static_cast <int >(opt_cbTx-> bestCLHeightDiff ) - 1 ;
372
- if (best_clsig.getHeight () == curBlockCoinbaseCLHeight && best_clsig.getSig () == opt_cbTx-> bestCLSignature ) {
371
+ if (cbTx. bestCLSignature .IsValid ()) {
372
+ int curBlockCoinbaseCLHeight = pindex->nHeight - static_cast <int >(cbTx. bestCLHeightDiff ) - 1 ;
373
+ if (best_clsig.getHeight () == curBlockCoinbaseCLHeight && best_clsig.getSig () == cbTx. bestCLSignature ) {
373
374
// matches our best (but outdated) clsig, no need to verify it again
374
375
return true ;
375
376
}
376
377
uint256 curBlockCoinbaseCLBlockHash = pindex->GetAncestor (curBlockCoinbaseCLHeight)->GetBlockHash ();
377
- if (chainlock_handler.VerifyChainLock (llmq::CChainLockSig (curBlockCoinbaseCLHeight, curBlockCoinbaseCLBlockHash, opt_cbTx-> bestCLSignature )) != llmq::VerifyRecSigStatus::Valid) {
378
+ if (chainlock_handler.VerifyChainLock (llmq::CChainLockSig (curBlockCoinbaseCLHeight, curBlockCoinbaseCLBlockHash, cbTx. bestCLSignature )) != llmq::VerifyRecSigStatus::Valid) {
378
379
return state.Invalid (BlockValidationResult::BLOCK_CONSENSUS, " bad-cbtx-invalid-clsig" );
379
380
}
380
- } else if (opt_cbTx-> bestCLHeightDiff != 0 ) {
381
+ } else if (cbTx. bestCLHeightDiff != 0 ) {
381
382
// Null bestCLSignature is allowed only with bestCLHeightDiff = 0
382
383
return state.Invalid (BlockValidationResult::BLOCK_CONSENSUS, " bad-cbtx-cldiff" );
383
384
}
0 commit comments