aboutsummaryrefslogtreecommitdiff
path: root/src/script/sign.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter@wuille.net>2021-03-01 18:10:13 -0800
committerPieter Wuille <pieter@wuille.net>2021-03-15 17:29:39 -0700
commit497718b467330b2c6bb0d44786020c55f1aa75f9 (patch)
treee69fdfc0e4302474c62be3873f6b56c07cdf9961 /src/script/sign.cpp
parent3820090bd619ac85ab35eff376c03136fe4a9f04 (diff)
downloadbitcoin-497718b467330b2c6bb0d44786020c55f1aa75f9.tar.xz
Treat amount<0 also as missing data for P2WPKH/P2WSH
Historically lack of amount data has been treated as amount==-1. Change this and treat it as missing data, as introduced in the previous commits. To be minimally invasive, do this at SignatureHash() call sites rather than inside SignatureHash() (which currently has no means or returning a failure code).
Diffstat (limited to 'src/script/sign.cpp')
-rw-r--r--src/script/sign.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/script/sign.cpp b/src/script/sign.cpp
index fb3466f320..6426c8de59 100644
--- a/src/script/sign.cpp
+++ b/src/script/sign.cpp
@@ -26,6 +26,9 @@ bool MutableTransactionSignatureCreator::CreateSig(const SigningProvider& provid
if (sigversion == SigVersion::WITNESS_V0 && !key.IsCompressed())
return false;
+ // Signing for witness scripts needs the amount.
+ if (sigversion == SigVersion::WITNESS_V0 && amount < 0) return false;
+
uint256 hash = SignatureHash(scriptCode, *txTo, nIn, nHashType, amount, sigversion);
if (!key.Sign(hash, vchSig))
return false;