Signatures using segregated witness commit to the amount being spent, so that value must be passed into signrawtransactionwithkey and signrawtransactionwithwallet. This ensures an error is issued if that doesn't happen, rather than just assuming the value is 0 and producing a signature that is almost certainly invalid.
Make signrawtransaction* give an error when amount is needed but missing #13547
pull ajtowns wants to merge 2 commits into bitcoin:master from ajtowns:signrawamount changing 2 files +61 −1-
ajtowns commented at 4:16 PM on June 27, 2018: member
-
a3b065b51f
Error on missing amount in signrawtransaction*
Signatures using segregated witness commit to the amount being spent, so that value must be passed into signrawtransactionwithkey and signrawtransactionwithwallet. This ensures an error is issued if that doesn't happen, rather than just assuming the value is 0 and producing a signature that is almost certainly invalid.
-
[tests] Check signrawtransaction* errors on missing prevtx info 685d1d8115
- fanquake added the label RPC/REST/ZMQ on Jun 27, 2018
-
ajtowns commented at 4:18 PM on June 27, 2018: member
Note that this does the signature, and then checks if it didn't make sense. It might be cleaner to work out if the scriptPubKey implies segwit is used and not do the signature at all, but that seemed a bit more invasive.
It's currently missing tests to check signrawtransactionwithkey also fails correctly.
-
DrahtBot commented at 9:29 AM on June 28, 2018: member
<!--e57a25ab6845829454e8d69fc972939a-->Note to reviewers: This pull request conflicts with the following ones:
- #12458 (Enforce that amount is provided for signrawtransaction prevtxs by Empact)
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
- laanwj added this to the "Blockers" column in a project
-
in test/functional/rpc_rawtransaction.py:160 in 685d1d8115
155 | + if type == "legacy": 156 | + del prevtx["amount"] 157 | + succ = self.nodes[0].signrawtransactionwithwallet(rawtx, [prevtx]) 158 | + assert succ["complete"] 159 | + 160 | + if type != "legacy":
MarcoFalke commented at 7:52 AM on July 7, 2018:Looks like this condition is false when the above is true, so a plain
elseseems more appropriate. Also, could move thedel prevtx["amount"]out of the scopes of the if-else and drop the line below this one?
MarcoFalke commented at 7:58 AM on July 7, 2018:Alternatively remove the
prevtxvariable from the patch and always pass a fresh dict tosignrawtransactionwithwallet:prevtxs=dict(txid=txid, amount missing...)MarcoFalke commented at 7:58 AM on July 7, 2018: memberutACK 685d1d8115f61b15115d80523dd8273f0a816534 tests only (haven't looked at the code changes, feel free to ignore my style nits)
in src/rpc/rawtransaction.cpp:814 in 685d1d8115
810 | @@ -811,7 +811,7 @@ UniValue SignTransaction(CMutableTransaction& mtx, const UniValue& prevTxsUnival 811 | } 812 | Coin newcoin; 813 | newcoin.out.scriptPubKey = scriptPubKey; 814 | - newcoin.out.nValue = 0; 815 | + newcoin.out.nValue = MAX_MONEY;
laanwj commented at 3:34 PM on July 9, 2018:isn't MAX_MONEY theoretically a valid amount to send?
achow101 commented at 9:21 PM on July 9, 2018:No,
MAX_MONEYis defined as 21000000 BTC, but the actual maximum is 20999999.97690000 BTC so you couldn't actually haveMAX_MONEY.
l2a5b1 commented at 8:12 AM on July 10, 2018:I was wondering about the use of
MAX_MONEYunderstanding that it doesn't represent the maximum money supply (Note that this constant is *not* the total money supply, which in Bitcoin currently happens to be less than 21,000,000 BTC), but still felt the need to comment on it, because it seemed a valid transaction amount to me on the basis of at least its documentation (No amount larger than this (in satoshi) is valid.), the functionMoneyRange(which defines a range that includesMAX_MONEY) and unit test vectors below.To me the amount
MAX_MONEYis as valid as the value0that it replaces, but admittedly I don't fully comprehend all the details.
l2a5b1 commented at 10:17 AM on July 10, 2018:Please ignore the explanation why the use of
MAX_MONEYis confusing to me. I needed @sipa's confirmation #12458 (comment) to connect the dots.
achow101 commented at 9:26 PM on July 9, 2018: memberutACK 685d1d8115f61b15115d80523dd8273f0a816534
laanwj commented at 3:04 PM on July 10, 2018: memberutACK 685d1d8115f61b15115d80523dd8273f0a816534
laanwj merged this on Jul 10, 2018laanwj closed this on Jul 10, 2018laanwj referenced this in commit fad42e8c4a on Jul 10, 2018laanwj removed this from the "Blockers" column in a project
luke-jr referenced this in commit 1825e37075 on Jul 29, 2018luke-jr referenced this in commit 212ef1f954 on Jul 29, 2018laanwj referenced this in commit b64f02fcfa on Aug 8, 2018sipa added the label Needs release notes on Aug 14, 2018HashUnlimited referenced this in commit 65a6eae03d on Jan 11, 2019HashUnlimited referenced this in commit d84b3c70cc on Jan 11, 2019fanquake removed the label Needs release note on Mar 20, 2019PastaPastaPasta referenced this in commit f5459232f7 on Jul 17, 2020jasonbcox referenced this in commit 1eeffea66f on Oct 23, 2020PastaPastaPasta referenced this in commit 8bacc96f07 on Jun 27, 2021PastaPastaPasta referenced this in commit 5ecee84163 on Jun 28, 2021PastaPastaPasta referenced this in commit d1ad6b157f on Jun 29, 2021DrahtBot locked this on Dec 16, 2021LabelsLinked (view graph)#12429 signrawtransaction without "amount" creates invalid signature#12458 Enforce that amount is provided for signrawtransaction prevtxs#13608 WIP: bitcoin-tx: Require that input amount is provided for witness transactions#13796 [0.16] Make signrawtransaction give an error when amount is needed but missing#23784 bitcoin-tx: Require that input amount is provided for witness transactions
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:15 UTC
More mirrored repositories can be found on mirror.b10c.me