14
14
15
15
typedef std::vector<unsigned char > valtype;
16
16
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
+ }
18
30
19
31
bool MutableTransactionSignatureCreator::CreateSig (const SigningProvider& provider, std::vector<unsigned char >& vchSig, const CKeyID& address, const CScript& scriptCode, SigVersion sigversion) const
20
32
{
@@ -26,10 +38,10 @@ bool MutableTransactionSignatureCreator::CreateSig(const SigningProvider& provid
26
38
if (sigversion == SigVersion::WITNESS_V0 && !key.IsCompressed ())
27
39
return false ;
28
40
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 ;
31
43
32
- uint256 hash = SignatureHash (scriptCode, *txTo, nIn, nHashType, amount, sigversion);
44
+ uint256 hash = SignatureHash (scriptCode, *txTo, nIn, nHashType, amount, sigversion, m_txdata );
33
45
if (!key.Sign (hash, vchSig))
34
46
return false ;
35
47
vchSig.push_back ((unsigned char )nHashType);
0 commit comments