aboutsummaryrefslogtreecommitdiff
path: root/src/script/sign.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter@wuille.net>2021-03-04 14:27:20 -0800
committerPieter Wuille <pieter@wuille.net>2021-06-12 12:38:17 -0700
commit458a345b0590fd2fa04c7d8d70beb8d57e34bbc8 (patch)
tree61cd60377c39986ac8a66617c5d3a446c363812c /src/script/sign.cpp
parentc0f0c8eccb04f90940007e0c6aaff56bf2ab35b5 (diff)
downloadbitcoin-458a345b0590fd2fa04c7d8d70beb8d57e34bbc8.tar.xz
Add support for SIGHASH_DEFAULT in RPCs, and make it default
For non-Taproot signatures, this is interpreted as SIGHASH_ALL.
Diffstat (limited to 'src/script/sign.cpp')
-rw-r--r--src/script/sign.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/script/sign.cpp b/src/script/sign.cpp
index 749bcc173c..65276f641f 100644
--- a/src/script/sign.cpp
+++ b/src/script/sign.cpp
@@ -44,10 +44,13 @@ bool MutableTransactionSignatureCreator::CreateSig(const SigningProvider& provid
// Signing without known amount does not work in witness scripts.
if (sigversion == SigVersion::WITNESS_V0 && !MoneyRange(amount)) return false;
- uint256 hash = SignatureHash(scriptCode, *txTo, nIn, nHashType, amount, sigversion, m_txdata);
+ // BASE/WITNESS_V0 signatures don't support explicit SIGHASH_DEFAULT, use SIGHASH_ALL instead.
+ const int hashtype = nHashType == SIGHASH_DEFAULT ? SIGHASH_ALL : nHashType;
+
+ uint256 hash = SignatureHash(scriptCode, *txTo, nIn, hashtype, amount, sigversion, m_txdata);
if (!key.Sign(hash, vchSig))
return false;
- vchSig.push_back((unsigned char)nHashType);
+ vchSig.push_back((unsigned char)hashtype);
return true;
}