@@ -2103,14 +2103,15 @@ void UpdateCoins(const CTransaction& tx, CCoinsViewCache& inputs, CTxUndo &txund
2103
2103
AddCoins (inputs, tx, nHeight);
2104
2104
}
2105
2105
2106
- std::optional<ScriptError> CScriptCheck::operator ()() {
2106
+ std::optional<std::pair< ScriptError, std::string> > CScriptCheck::operator ()() {
2107
2107
const CScript &scriptSig = ptxTo->vin [nIn].scriptSig ;
2108
2108
const CScriptWitness *witness = &ptxTo->vin [nIn].scriptWitness ;
2109
2109
ScriptError error{SCRIPT_ERR_UNKNOWN_ERROR};
2110
2110
if (VerifyScript (scriptSig, m_tx_out.scriptPubKey , witness, nFlags, CachingTransactionSignatureChecker (ptxTo, nIn, m_tx_out.nValue , cacheStore, *m_signature_cache, *txdata), &error)) {
2111
2111
return std::nullopt;
2112
2112
} else {
2113
- return error;
2113
+ auto debug_str = strprintf (" input %i of %s (wtxid %s), spending %s:%i" , nIn, ptxTo->GetHash ().ToString (), ptxTo->GetWitnessHash ().ToString (), ptxTo->vin [nIn].prevout .hash .ToString (), ptxTo->vin [nIn].prevout .n );
2114
+ return std::make_pair (error, std::move (debug_str));
2114
2115
}
2115
2116
}
2116
2117
@@ -2214,7 +2215,7 @@ bool CheckInputScripts(const CTransaction& tx, TxValidationState& state,
2214
2215
flags & ~STANDARD_NOT_MANDATORY_VERIFY_FLAGS, cacheSigStore, &txdata);
2215
2216
auto mandatory_result = check2 ();
2216
2217
if (!mandatory_result.has_value ()) {
2217
- return state.Invalid (TxValidationResult::TX_NOT_STANDARD, strprintf (" non-mandatory-script-verify-flag (%s)" , ScriptErrorString (* result)) );
2218
+ return state.Invalid (TxValidationResult::TX_NOT_STANDARD, strprintf (" non-mandatory-script-verify-flag (%s)" , ScriptErrorString (result-> first )), result-> second );
2218
2219
} else {
2219
2220
// If the second check failed, it failed due to a mandatory script verification
2220
2221
// flag, but the first check might have failed on a non-mandatory script
@@ -2228,7 +2229,7 @@ bool CheckInputScripts(const CTransaction& tx, TxValidationState& state,
2228
2229
2229
2230
// MANDATORY flag failures correspond to
2230
2231
// TxValidationResult::TX_CONSENSUS.
2231
- return state.Invalid (TxValidationResult::TX_CONSENSUS, strprintf (" mandatory-script-verify-flag-failed (%s)" , ScriptErrorString (* result)) );
2232
+ return state.Invalid (TxValidationResult::TX_CONSENSUS, strprintf (" mandatory-script-verify-flag-failed (%s)" , ScriptErrorString (result-> first )), result-> second );
2232
2233
}
2233
2234
}
2234
2235
@@ -2688,7 +2689,7 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
2688
2689
// Any transaction validation failure in ConnectBlock is a block consensus failure
2689
2690
state.Invalid (BlockValidationResult::BLOCK_CONSENSUS,
2690
2691
tx_state.GetRejectReason (), tx_state.GetDebugMessage ());
2691
- LogInfo (" Script validation error in block: %s\n " , tx_state. GetRejectReason ());
2692
+ LogInfo (" Script validation error in block: %s\n " , state. ToString ());
2692
2693
return false ;
2693
2694
}
2694
2695
control.Add (std::move (vChecks));
@@ -2716,8 +2717,8 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
2716
2717
2717
2718
auto parallel_result = control.Complete ();
2718
2719
if (parallel_result.has_value ()) {
2719
- state.Invalid (BlockValidationResult::BLOCK_CONSENSUS, strprintf (" mandatory-script-verify-flag-failed (%s)" , ScriptErrorString (* parallel_result)) );
2720
- LogInfo (" Script validation error in block: %s" , state.GetRejectReason ());
2720
+ state.Invalid (BlockValidationResult::BLOCK_CONSENSUS, strprintf (" mandatory-script-verify-flag-failed (%s)" , ScriptErrorString (parallel_result-> first )), parallel_result-> second );
2721
+ LogInfo (" Script validation error in block: %s" , state.ToString ());
2721
2722
return false ;
2722
2723
}
2723
2724
const auto time_4{SteadyClock::now ()};
0 commit comments