diff options
author | Ben Woosley <ben.woosley@gmail.com> | 2018-07-06 20:33:20 -0400 |
---|---|---|
committer | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2021-12-29 21:12:12 +0100 |
commit | c337b27d7cfd468048bcf816e585a1f7d59e066d (patch) | |
tree | 0b54d3e9cee8aab2c71f537463f08eec82974958 /src/bitcoin-tx.cpp | |
parent | 587cbca826d7331633a30b5a6cce170e3dbe2612 (diff) |
Require that input amount is provided for bitcoin-tx witness transactions
Co-authored-by: Sebastian Falbesoner <sebastian.falbesoner@gmail.com>
Diffstat (limited to 'src/bitcoin-tx.cpp')
-rw-r--r-- | src/bitcoin-tx.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp index eb97cfc6f6..427e58b0de 100644 --- a/src/bitcoin-tx.cpp +++ b/src/bitcoin-tx.cpp @@ -630,7 +630,7 @@ static void MutateTxSign(CMutableTransaction& tx, const std::string& flagStr) } Coin newcoin; newcoin.out.scriptPubKey = scriptPubKey; - newcoin.out.nValue = 0; + newcoin.out.nValue = MAX_MONEY; if (prevOut.exists("amount")) { newcoin.out.nValue = AmountFromValue(prevOut["amount"]); } @@ -669,6 +669,10 @@ static void MutateTxSign(CMutableTransaction& tx, const std::string& flagStr) if (!fHashSingle || (i < mergedTx.vout.size())) ProduceSignature(keystore, MutableTransactionSignatureCreator(&mergedTx, i, amount, nHashType), prevPubKey, sigdata); + if (amount == MAX_MONEY && !sigdata.scriptWitness.IsNull()) { + throw std::runtime_error(strprintf("Missing amount for CTxOut with scriptPubKey=%s", HexStr(prevPubKey))); + } + UpdateInput(txin, sigdata); } |