Require that input amount is provided for bitcoin-tx witness transactions

Co-authored-by: Sebastian Falbesoner <sebastian.falbesoner@gmail.com>
This commit is contained in:
Ben Woosley 2018-07-06 20:33:20 -04:00 committed by Sebastian Falbesoner
parent 587cbca826
commit c337b27d7c

View file

@ -630,7 +630,7 @@ static void MutateTxSign(CMutableTransaction& tx, const std::string& flagStr)
} }
Coin newcoin; Coin newcoin;
newcoin.out.scriptPubKey = scriptPubKey; newcoin.out.scriptPubKey = scriptPubKey;
newcoin.out.nValue = 0; newcoin.out.nValue = MAX_MONEY;
if (prevOut.exists("amount")) { if (prevOut.exists("amount")) {
newcoin.out.nValue = AmountFromValue(prevOut["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())) if (!fHashSingle || (i < mergedTx.vout.size()))
ProduceSignature(keystore, MutableTransactionSignatureCreator(&mergedTx, i, amount, nHashType), prevPubKey, sigdata); 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); UpdateInput(txin, sigdata);
} }