Skip to content

Commit c337b27

Browse files
EmpacttheStack
andcommitted
Require that input amount is provided for bitcoin-tx witness transactions
Co-authored-by: Sebastian Falbesoner <[email protected]>
1 parent 587cbca commit c337b27

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/bitcoin-tx.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ static void MutateTxSign(CMutableTransaction& tx, const std::string& flagStr)
630630
}
631631
Coin newcoin;
632632
newcoin.out.scriptPubKey = scriptPubKey;
633-
newcoin.out.nValue = 0;
633+
newcoin.out.nValue = MAX_MONEY;
634634
if (prevOut.exists("amount")) {
635635
newcoin.out.nValue = AmountFromValue(prevOut["amount"]);
636636
}
@@ -669,6 +669,10 @@ static void MutateTxSign(CMutableTransaction& tx, const std::string& flagStr)
669669
if (!fHashSingle || (i < mergedTx.vout.size()))
670670
ProduceSignature(keystore, MutableTransactionSignatureCreator(&mergedTx, i, amount, nHashType), prevPubKey, sigdata);
671671

672+
if (amount == MAX_MONEY && !sigdata.scriptWitness.IsNull()) {
673+
throw std::runtime_error(strprintf("Missing amount for CTxOut with scriptPubKey=%s", HexStr(prevPubKey)));
674+
}
675+
672676
UpdateInput(txin, sigdata);
673677
}
674678

0 commit comments

Comments
 (0)