mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 03:47:29 -03:00
script/sign: avoid duplicated signature verification after signing
`ProduceSignature` already calls `VerifyScript` internally as last step in order to check whether the signature data is complete. If and only if that is the case, the `complete` field of the `SignatureData` is set accordingly and there is no need then to verify the script after again, as we already know that it would succeed. This leads to a rough ~20% speed-up for `SignTransaction` for single-input ECDSA or Taproot inputs, according to the `SignTransaction{ECDSA,Taproot}` benchmarks.
This commit is contained in:
parent
080089567c
commit
fe92c15f0c
1 changed files with 1 additions and 1 deletions
|
@ -831,7 +831,7 @@ bool SignTransaction(CMutableTransaction& mtx, const SigningProvider* keystore,
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptError serror = SCRIPT_ERR_OK;
|
ScriptError serror = SCRIPT_ERR_OK;
|
||||||
if (!VerifyScript(txin.scriptSig, prevPubKey, &txin.scriptWitness, STANDARD_SCRIPT_VERIFY_FLAGS, TransactionSignatureChecker(&txConst, i, amount, txdata, MissingDataBehavior::FAIL), &serror)) {
|
if (!sigdata.complete && !VerifyScript(txin.scriptSig, prevPubKey, &txin.scriptWitness, STANDARD_SCRIPT_VERIFY_FLAGS, TransactionSignatureChecker(&txConst, i, amount, txdata, MissingDataBehavior::FAIL), &serror)) {
|
||||||
if (serror == SCRIPT_ERR_INVALID_STACK_OPERATION) {
|
if (serror == SCRIPT_ERR_INVALID_STACK_OPERATION) {
|
||||||
// Unable to sign input and verification failed (possible attempt to partially sign).
|
// Unable to sign input and verification failed (possible attempt to partially sign).
|
||||||
input_errors[i] = Untranslated("Unable to sign input, invalid stack size (possibly missing key)");
|
input_errors[i] = Untranslated("Unable to sign input, invalid stack size (possibly missing key)");
|
||||||
|
|
Loading…
Reference in a new issue