Skip to content
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

rpc: have raw transaction decoding infer output descriptors #16795

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

@instagibbs
Copy link
Member

@instagibbs instagibbs commented Sep 3, 2019

Following discussion in #16725 this is complementary data to expose. All outputs are inferred.

@DrahtBot DrahtBot added the Tests label Sep 3, 2019
@DrahtBot
Copy link
Contributor

@DrahtBot DrahtBot commented Sep 3, 2019

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #22650 (Remove -deprecatedrpc=addresses flag and corresponding code/logic by mjdietzx)

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.

@NicolasDorier
Copy link
Contributor

@NicolasDorier NicolasDorier commented Sep 4, 2019

that's cool utACK

@instagibbs
Copy link
Member Author

@instagibbs instagibbs commented Sep 4, 2019

forgot to add description in RPC help, added.

@instagibbs instagibbs force-pushed the decode_descriptor branch from 1863168 to 8cd521e Sep 4, 2019
@fanquake fanquake changed the title have raw transaction decoding infer output descriptors rpc: have raw transaction decoding infer output descriptors Sep 6, 2019
@instagibbs instagibbs force-pushed the decode_descriptor branch from 8cd521e to c772728 Sep 9, 2019
@meshcollider
Copy link
Member

@meshcollider meshcollider commented Sep 9, 2019

utACK c772728

@instagibbs
Copy link
Member Author

@instagibbs instagibbs commented Sep 10, 2019

rebased

@meshcollider
Copy link
Member

@meshcollider meshcollider commented Sep 10, 2019

You need to update the help-text for the RPCs affected by this change (decoderawtransaction, decodescript, getrawtransaction) to include the additional field

@laanwj
Copy link
Member

@laanwj laanwj commented Sep 10, 2019

Travis found a real problem here (for a change !!! 🎉 )

/usr/bin/python3.6 ../test/util/bitcoin-util-test.py

2019-09-10 01:34:27,547 - ERROR - Output data mismatch for txcreateoutpubkey1.json (format json)

2019-09-10 01:34:27,548 - ERROR - Output formatting mismatch for txcreateoutpubkey1.json:

*** txcreateoutpubkey1.json

--- returned

***************

*** 15,22 ****

              "scriptPubKey": {

                  "asm": "02a5613bd857b7048924264d1e70e08fb2a7e6527d32b7ab1bb993ac59964ff397 OP_CHECKSIG",

                  "hex": "2102a5613bd857b7048924264d1e70e08fb2a7e6527d32b7ab1bb993ac59964ff397ac",

!                 "type": "pubkey",

!                 "desc": "pk(02a5613bd857b7048924264d1e70e08fb2a7e6527d32b7ab1bb993ac59964ff397)#rk5v7uqw"

              }

          }

      ],

--- 15,21 ----

              "scriptPubKey": {

                  "asm": "02a5613bd857b7048924264d1e70e08fb2a7e6527d32b7ab1bb993ac59964ff397 OP_CHECKSIG",

                  "hex": "2102a5613bd857b7048924264d1e70e08fb2a7e6527d32b7ab1bb993ac59964ff397ac",

!                 "type": "pubkey"

              }

          }

      ],

2019-09-10 01:34:30,728 - ERROR - FAILED_TESTCASES:

['Creates a new transaction with a single pay-to-pubkey output (output as json)']

@instagibbs instagibbs force-pushed the decode_descriptor branch 2 times, most recently from 326f322 to 9018d63 Sep 10, 2019
@instagibbs
Copy link
Member Author

@instagibbs instagibbs commented Sep 10, 2019

fixed rebase error, now all outputs are inferred. added description to decodescript

src/core_write.cpp Outdated Show resolved Hide resolved
src/core_write.cpp Outdated Show resolved Hide resolved
src/core_write.cpp Outdated Show resolved Hide resolved
@instagibbs instagibbs force-pushed the decode_descriptor branch from 9018d63 to 9b94596 Sep 16, 2019
luke-jr added a commit to bitcoinknots/bitcoin that referenced this issue Sep 21, 2019
Copy link
Member

@ariard ariard left a comment

ACK 9b94596 minus gettouxt/rest_getuxtos doc fixs

Tested getrawtransaction, decoderawtransaction, decodescript, work as expected.

@@ -157,6 +158,8 @@ void ScriptPubKeyToUniv(const CScript& scriptPubKey,
int nRequired;

out.pushKV("asm", ScriptToAsmStr(scriptPubKey));
out.pushKV("desc", InferDescriptor(scriptPubKey, DUMMY_SIGNING_PROVIDER)->ToString());
Copy link
Member

@ariard ariard Nov 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to update help-debug of gettxout and also maybe REST-interface.md on rest_getutxos.

Do you want also to extend feature to decodepsbt ?

Copy link
Member Author

@instagibbs instagibbs Nov 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want also to extend feature to decodepsbt ?

going to take a little more thinking, so for now "no" :)

fixed up other missing documentation to best of knowledge

Copy link
Member Author

@instagibbs instagibbs Nov 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see **ScriptToUniv** is only used for PSBT decoding... so yeah I can do that real quick.

eh maybe not im not sure of the reasoning of addresses being included or not in decodepsbt output...

@instagibbs instagibbs force-pushed the decode_descriptor branch from 9b94596 to dcd5c4a Nov 20, 2019
@instagibbs
Copy link
Member Author

@instagibbs instagibbs commented Nov 21, 2019

pushed update fixing @ariard nits

luke-jr added a commit to bitcoinknots/bitcoin that referenced this issue Jan 5, 2020
@theStack
Copy link
Contributor

@theStack theStack commented Feb 4, 2020

Being pedantic here, but wouldn't it be more logical to put the inferred output descriptor "desc" before "asm" within the "scriptPubKey" json object, to keep the abstraction level order strictly decreasing (address -> script -> raw bytes)? From a user perspective I'd find it nice to find the higher-level interpretation of a scriptPubKey right in the first line, and I only need to dig deeper into the next two lines if I want more low-level representation.

src/rpc/rawtransaction.cpp Outdated Show resolved Hide resolved
@instagibbs instagibbs force-pushed the decode_descriptor branch from ef91078 to 4372d34 Aug 31, 2020
src/rpc/rawtransaction.cpp Outdated Show resolved Hide resolved
src/rpc/rawtransaction.cpp Outdated Show resolved Hide resolved
src/rpc/rawtransaction.cpp Outdated Show resolved Hide resolved
src/rpc/blockchain.cpp Show resolved Hide resolved
@sipa
Copy link
Member

@sipa sipa commented Dec 27, 2020

It would be nice to have this, as it compensates somewhat for the (weird) functionality lost in #20286. There are a bunch of unaddressed comments here though. And also, it'd be good if the decodescript output inside the "p2sh" and "segwit" blocks would report a descriptor that takes the structure into account (i.e., report "sh(...)" instead of "addr(...)" if it's a recognizable script).

@instagibbs
Copy link
Member Author

@instagibbs instagibbs commented Dec 27, 2020

Ah, thought I closed this PR. I'll take a fresh look.

@instagibbs instagibbs force-pushed the decode_descriptor branch from 4372d34 to 3038f94 Dec 27, 2020
@instagibbs
Copy link
Member Author

@instagibbs instagibbs commented Dec 27, 2020

@sipa Looks like it already does the native segwit inference in decodescript, p2sh doesn't have a block per se, just a single field with the p2sh address itself. Could add it I guess? Name suggestion for the object?

@sipa
Copy link
Member

@sipa sipa commented Dec 27, 2020

@instagibbs I was confusing decodescript's "p2sh" and "segwit" fields with the "embedded" field in getaddressinfo (thinking it'd give an Object with fields for the p2sh/segwit version of the specified script, instead of just the resulting address). Perhaps there is a use for that, but not in this PR.

@instagibbs
Copy link
Member Author

@instagibbs instagibbs commented Dec 27, 2020

Addressed all concerns, I think. Rebased on master since this is pretty ancient.

@FndNur1Labs
Copy link

@FndNur1Labs FndNur1Labs commented Dec 27, 2020

Desc for string. Update is good. Need known rebase that.

luke-jr added a commit to bitcoinknots/bitcoin that referenced this issue Jan 28, 2021
@meshcollider
Copy link
Member

@meshcollider meshcollider commented Sep 2, 2021

Concept ACK, sorry I missed this

@instagibbs
Copy link
Member Author

@instagibbs instagibbs commented Sep 2, 2021

kk will rebase

@instagibbs instagibbs force-pushed the decode_descriptor branch from 3038f94 to 5e25688 Sep 2, 2021
@instagibbs
Copy link
Member Author

@instagibbs instagibbs commented Sep 2, 2021

@meshcollider ready for rereview

@DrahtBot
Copy link
Contributor

@DrahtBot DrahtBot commented Sep 28, 2021

🐙 This pull request conflicts with the target branch and needs rebase.

Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft".

luke-jr added a commit to bitcoinknots/bitcoin that referenced this issue Oct 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet