-
Notifications
You must be signed in to change notification settings - Fork 37.7k
rpc: combinerawtransaction now rejects unmergeable transactions #31298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
rpc: combinerawtransaction now rejects unmergeable transactions #31298
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/31298. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsNo conflicts as of last run. |
c0d23a0
to
8515fc6
Compare
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
9b24f38
to
192a50b
Compare
192a50b
to
f19a815
Compare
It seems like, with #31249, I should migrate these test changes as well. WIP |
This comment was marked as abuse.
This comment was marked as abuse.
This is the same functional approach and error message already. |
f19a815
to
85c2168
Compare
This comment was marked as abuse.
This comment was marked as abuse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK 85c2168
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested ACK 85c2168
Below is my full test setup:
Tested on Regtest mode
master@d2136d32bb4764e4035fb892d979c27f037fad93
- When checked with only 1 raw txn, returns only the txn (no error for missing txns)
- When checked for mergeability:
- returns only the first txn when unrelated txns were provided
- doesn't show descriptive error for any mergeability issue
combinerawtransaction-check@85c216871a01aab003e1b1aba6246b4178afc929
- When only 1 raw txn provided it returns missing inputs
- checking for mergeability:
- shows descriptive error for mergeability issue
for e.g.
- shows descriptive error for mergeability issue
error code: -8
error message:
Transaction 1 not compatible (different transactions)
Gives combine hex when same txns are provided
./build/src/bitcoin-cli combinerawtransaction '["0200000001a0d2e799d40d404da2daf128fc678fdd15f245bdd92c6e1ad15b45f7258a47b90000000000fdffffff01008c86470000000016001483f259c98962117d75154f35cb55cd60b88a257e00000000","0200000001a0d2e799d40d404da2daf128fc678fdd15f245bdd92c6e1ad15b45f7258a47b90000000000fdffffff01008c86470000000016001483f259c98962117d75154f35cb55cd60b88a257e00000000"]'
0200000001a0d2e799d40d404da2daf128fc678fdd15f245bdd92c6e1ad15b45f7258a47b90000000000fdffffff01008c86470000000016001483f259c98962117d75154f35cb55cd60b88a257e00000000
for inputs already spent:
error code: -25
error message:
Input not found or already spent
Note: newly created wallet and txns were used during the test using createrawtransaction
rpc in regtest mode
Also, the functional test LGTM:
Temporary test directory at /var/folders/jb/wlbrz0t95vl58wzxjt75wqmh0000gn/T/test_runner_₿_🏃_20241219_004940
Remaining jobs: [rpc_createmultisig.py]
1/1 - rpc_createmultisig.py passed, Duration: 3 s
TEST | STATUS | DURATION
rpc_createmultisig.py | ✓ Passed | 3 s
ALL | ✓ Passed | 3 s (accumulated)
Runtime: 3 s
85c2168
to
85d798d
Compare
Concept ACK |
Previously, combinerawtransaction would silently return the first tx when asked to combine unrelated txs. Now, it will check tx mergeability and throws a descriptive error if tx cannot be merged.
85d798d
to
9d31e94
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested ACK 9d31e94
I have tested the changes on regtest and got expected output
bitcoin-cli -regtest combinerawtransaction "[\"$RAW_TX1\", \"$RAW_TX2\"]"
error code: -8
error message:
Transaction 1 not compatible (different transactions)
|
||
// Can't merge < 2 items | ||
if (txs.size() < 2) { | ||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Missing transactions"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can ignore this as everything LGTM, but if you have to push any other changes, you can include this as well
nit: IMO, this could be a bit more descriptive
// Can't merge < 2 items
if (txs.size() < 2) {
- throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Missing transactions");
+ throw JSONRPCError(
+ RPC_INVALID_PARAMETER,
+ txs.size() == 0
+ ? "Missing transactions. At least two transactions required."
+ : "Insufficient transactions. At least two transactions required."
+ );
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-ACK 9d31e94
if (!DecodeHexTx(txVariants[idx], txs[idx].get_str())) { | ||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, strprintf("TX decode failed for tx %d. Make sure the tx has at least one input.", idx)); | ||
} | ||
} | ||
|
||
if (txVariants.empty()) { | ||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Missing transactions"); | ||
{ // Test Tx relation for mergeability. This involves converting each tx to PSBT format (stripping sigscripts/witnesses) and ensuring txid is consistent. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is incorrect, it's not doing anything related to PSBT. You can just say that the scriptSigs and scriptWitnesses are being stripped in order to do a txid comparison.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I will update this comment
Previously, combinerawtransaction would silently return the first tx when asked to combine unrelated txs. Now, it will check tx mergeability and throws a descriptive error if tx cannot be merged.
fixes #25980