From 497718b467330b2c6bb0d44786020c55f1aa75f9 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Mon, 1 Mar 2021 18:10:13 -0800 Subject: 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). --- src/script/sign.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/script/sign.cpp') 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; -- cgit v1.2.3