1414
1515typedef std::vector<unsigned char > valtype;
1616
17- MutableTransactionSignatureCreator::MutableTransactionSignatureCreator (const CMutableTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn, int nHashTypeIn) : txTo(txToIn), nIn(nInIn), nHashType(nHashTypeIn), amount(amountIn), checker(txTo, nIn, amountIn, MissingDataBehavior::FAIL) {}
17+ MutableTransactionSignatureCreator::MutableTransactionSignatureCreator (const CMutableTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn, int nHashTypeIn)
18+ : txTo(txToIn), nIn(nInIn), nHashType(nHashTypeIn), amount(amountIn), checker(txTo, nIn, amountIn, MissingDataBehavior::FAIL),
19+ m_txdata(nullptr )
20+ {
21+ }
22+
23+ MutableTransactionSignatureCreator::MutableTransactionSignatureCreator (const CMutableTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn, const PrecomputedTransactionData* txdata, int nHashTypeIn)
24+ : txTo(txToIn), nIn(nInIn), nHashType(nHashTypeIn), amount(amountIn),
25+ checker(txdata ? MutableTransactionSignatureChecker(txTo, nIn, amount, *txdata, MissingDataBehavior::FAIL) :
26+ MutableTransactionSignatureChecker(txTo, nIn, amount, MissingDataBehavior::FAIL)),
27+ m_txdata(txdata)
28+ {
29+ }
1830
1931bool MutableTransactionSignatureCreator::CreateSig (const SigningProvider& provider, std::vector<unsigned char >& vchSig, const CKeyID& address, const CScript& scriptCode, SigVersion sigversion) const
2032{
@@ -26,10 +38,10 @@ bool MutableTransactionSignatureCreator::CreateSig(const SigningProvider& provid
2638 if (sigversion == SigVersion::WITNESS_V0 && !key.IsCompressed ())
2739 return false ;
2840
29- // Signing for witness scripts needs the amount .
30- if (sigversion == SigVersion::WITNESS_V0 && amount < 0 ) return false ;
41+ // Signing without known amount does not work in witness scripts .
42+ if (sigversion == SigVersion::WITNESS_V0 && ! MoneyRange ( amount) ) return false ;
3143
32- uint256 hash = SignatureHash (scriptCode, *txTo, nIn, nHashType, amount, sigversion);
44+ uint256 hash = SignatureHash (scriptCode, *txTo, nIn, nHashType, amount, sigversion, m_txdata );
3345 if (!key.Sign (hash, vchSig))
3446 return false ;
3547 vchSig.push_back ((unsigned char )nHashType);
0 commit comments