Expose txinwitness for coinbase in JSON form from RPC#18826
Expose txinwitness for coinbase in JSON form from RPC#18826maflcko merged 2 commits intobitcoin:masterfrom
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. 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. |
|
ACK 2a52c3c4caaf8dbe5c3d406c2fc7b1fd4347d0fd Built, run and tested on macOS Catalina 10.15.4 Regarding functional tests, I'd recommend to expand witnesses = tx["decoded"]["vin"][0]['txinwitness']
for witness in witnesses:
assert_is_hex_string(witness) |
promag
left a comment
There was a problem hiding this comment.
Please update some test with the new field.
|
Re-ACK 3a20ee8a1c0f86fb7628240f144d02fb6a32022d |
|
utACK |
|
Moved to feature_segwit.py as suggested. It's a more logical place for it to be, but there's not really anything else in there testing anything similar so it doesn't seem perfectly in place. But perhaps that's just a matter of increasing the coverage in general. |
38feda6 to
959a17d
Compare
txinwitness is used as the witness commitment nonce so is necessary if reconstructing block data from RPC data.
959a17d to
34645c4
Compare
|
Squashed the fixups and rebased to master, I think there was a rebasing problem previously and I ended up with stray commits. It should just be the two commits in here now and should be ready for landing if there are no further suggestions or objections. |
|
ACK 34645c4 |
|
Wondering what the process is for getting things merged in this project? This is not super urgent but it'd be nice to know if it's in a process and not going to get lost. |
|
@rvagg There is a very loose process described in CONTRIBUTING.md I was hoping that someone else reviews this, because it is a relatively easy rpc change. If no one else reviews it, I will merge it at some point because it is a clear improvement. |
…m RPC 34645c4 Test txinwitness is accessible on coinbase vin (Rod Vagg) 3e44210 Expose txinwitness for coinbase in JSON form (Rod Vagg) Pull request description: ## Rationale The CLI can provide you with everything about transactions and blocks that you need to reconstruct the block structure and raw block itself **except** for the witness commitment nonce which is stored in the `scriptWitness` of the coinbase and is not printed. You could manually parse the raw `"hex"` fields for transactions if you really wanted to, but this seems to defeat the point of having a JSONification of the raw block/transaction data. Without the nonce you can't: 1. calculate and validate the witness commitment yourself, you can generate the witness tx merkle root but you don't have the nonce to combine it with 2. reconstruct the raw block form because you don't have `scriptWitness` stack associated with the coinbase (although you know how big it will be and can guess the common case of `[0x000...000]`) I'm building some archiving tooling for block data and being able to do a validated two-way conversion is very helpful. ## What This PR simply makes the `txinwitness` field not dependent on whether we are working with the coinbase or not. So you get it for the coinbase as well as the rest. ## Examples Common case of a `[0x000...000]` nonce: 00000000000000000000140a7289f3aada855dfd23b0bb13bb5502b0ca60cdd7 ```json "vin": [ { "coinbase": "0368890904c1fe8d5e2f706f6f6c696e2e636f6d2ffabe6d6d5565843a681160cf7b08b1b74ac90a719e6d6ab28c16d336b924f0dc2fcabdc6010000000000000051bf2ad74af345dbe642154b2658931612a70d195e007add0100ffffffff", "txinwitness": [ "0000000000000000000000000000000000000000000000000000000000000000" ], "sequence": 4294967295 } ], ... ``` Novel nonce value: 000000000000000000008c31945b2012258366cc600a3e9a3ee0598e8f797731 ```json "vin": [ { "coinbase": "031862082cfabe6d6d80c099b5e21f4c186d54eb292e17026932e52b1b807fa1380574c5adc1c843450200000000000000", "txinwitness": [ "5b5032506f6f6c5d5b5032506f6f6c5d5b5032506f6f6c5d5b5032506f6f6c5d" ], "sequence": 4294967295 } ], ... ``` ## Alternatives This field could be renamed for the coinbase, `"witnessnonce"` perhaps. It could also be omitted when null/zero (`0x000...000`). ## Tests This didn't break any tests and I couldn't find an obvious way to include a test for this. If this is desired I'd apreicate some pointers. ACKs for top commit: MarcoFalke: ACK 34645c4 Tree-SHA512: b192facc1dfd210a5ec3f0d5d1ac6d0cae81eb35be15eaa71f60009a538dd6a79ab396f218434e7e998563f7f0df2c396cc925cb91619f6841c5a67806148c85
Rationale
The CLI can provide you with everything about transactions and blocks that you need to reconstruct the block structure and raw block itself except for the witness commitment nonce which is stored in the
scriptWitnessof the coinbase and is not printed. You could manually parse the raw"hex"fields for transactions if you really wanted to, but this seems to defeat the point of having a JSONification of the raw block/transaction data.Without the nonce you can't:
scriptWitnessstack associated with the coinbase (although you know how big it will be and can guess the common case of[0x000...000])I'm building some archiving tooling for block data and being able to do a validated two-way conversion is very helpful.
What
This PR simply makes the
txinwitnessfield not dependent on whether we are working with the coinbase or not. So you get it for the coinbase as well as the rest.Examples
Common case of a
[0x000...000]nonce: 00000000000000000000140a7289f3aada855dfd23b0bb13bb5502b0ca60cdd7Novel nonce value: 000000000000000000008c31945b2012258366cc600a3e9a3ee0598e8f797731
Alternatives
This field could be renamed for the coinbase,
"witnessnonce"perhaps. It could also be omitted when null/zero (0x000...000).Tests
This didn't break any tests and I couldn't find an obvious way to include a test for this. If this is desired I'd apreicate some pointers.