mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-30 02:31:05 +02:00
Merge bitcoin/bitcoin#23784: bitcoin-tx: Require that input amount is provided for witness transactions
8bd34dc774
test: check that bitcoin-tx detects missing input amount for segwit transactions (Sebastian Falbesoner)c337b27d7c
Require that input amount is provided for bitcoin-tx witness transactions (Ben Woosley) Pull request description: This PR picks up the obviously abandoned PR #13608 (last activity was three and a half years ago) by rebasing it on master and adding missing tests. Original PR description: "_Applies fix from #12458 / #13547 to bitcoin-tx._" The private key is the compressed version of the one used in most other util tests (5HpHagT65TZzG1PH3CSu63k8DbpvD8s5ip4nEB3kEsreAnchuDf, corresponds to the scalar value k=1 in big endian), since segwit signing refuses uncompressed keys. The error message from the picked up PR is changed to not include the amount, as showing any value would be just confusing. ACKs for top commit: josibake: ACK8bd34dc774
Tree-SHA512: 334b418f89527363ad7e3326b4126e86a05fd64876c49a8280de38e64cfac52cb62c4b24b83603dd68b6bcebbe57c64161832edffb1cac7e9c68426f6b6eae1f
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user