rpc: print P2WSH and P2SH redem Script in (get/decode)rawtransaction#31252
rpc: print P2WSH and P2SH redem Script in (get/decode)rawtransaction#31252polespinasa wants to merge 2 commits intobitcoin:masterfrom
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/31252. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsReviewers, this pull request conflicts with the following ones:
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. LLM Linter (✨ experimental)Possible typos and grammar issues:
Possible places where named args for integral literals may be used (e.g.
2026-01-20 |
|
can we squash 66ea8941de3dfd498319c6390655a165f6a5a92b and 84fb299de72ca9e08fe5029380a779d57d302347 |
66ea894 to
4e128d4
Compare
8b23ec7 to
43dbc69
Compare
naiyoma
left a comment
There was a problem hiding this comment.
I've tested 43dbc69 on regtest, and both (P2SH redeemScript and P2WSH witnessScript )are only being decompiled when calling getblock … 2. I think you should consider editing the PR description to indicate exactly what is working so far.
Thanks for the review and testing! Yes, the description was outdated to the first implementation of it. Updated 🫡 |
src/core_write.cpp
Outdated
There was a problem hiding this comment.
the value of have_undo is always going to be 0 when calling getrawtransaction hence the reason why this only works for getblock..2
There was a problem hiding this comment.
This is not a suggestion to replace your current approach, but rather an alternative way. I have an implementation here ->naiyoma@ff82e55 that shows how to decompile outside of if(have_undo) . While it needs more testing, it successfully works for both getrawtransaction and getblock..2. You might find some ideas there for handlinggetrawtransaction.
There was a problem hiding this comment.
Sorry for the delay, got this PR a bit abandoned, re-taking it now :).
Thanks for the suggestion!
The problem is that I don't see the way to detect the type without the previous transaction.
Your patch is similar to my first approach. If you test with a P2SH-P2WPKH, the decoding is done wrong.
|
🚧 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. |
|
Are you still working on this? |
3791c4d to
58ac220
Compare
|
Rebased on top of master 58ac220e857da32401a7291f77b4b8a864e80ebb @Sjors maybe you would like to review this |
src/script/script.cpp
Outdated
There was a problem hiding this comment.
For a non-P2SH transaction, returning -1 will result in a redeemScript field being added.
I tested this using a P2PKH transaction, and this was the output: "redeemScript": { "asm": "304402...7981", "type": "nonstandard" }"
There was a problem hiding this comment.
Nice catch!
You're right, solved in 18c513f8babf65ea73ea9c785fba90446ef947db.
Now non-P2SH and non-segwit inputs return -2 and don't show any script as it's out the scope of the PR.
18c513f to
2318af9
Compare
|
Concept ACK |
2318af9 to
7341f0e
Compare
|
Rebased to resolve conflicts with #32517, only moved |
7341f0e to
2aa405a
Compare
This PR is motivated by #27391.
And inspired by a previous PR #8849 that proposed something similar.
This is an example with a real mainnet transaction (3-5 multisig) and using
decoderawtransaction(also works forgetrawtransaction 'txid' 2).Verbosity must be set to 2.