-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Add rawtr() descriptor for P2TR with specified (tweaked) output key #23480
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
Conversation
@apoelstra @real-or-random @jonasnick @sanket1729 Perhaps the documentation here needs some disclaimer at least about the potential pitfalls of using it directly to construct a wallet. It's not intended for that purpose, only for things like representing otherwise incomplete knowledge in e.g. inference, but adding it to the descriptor language does make it available for all purposes. Can you help think about examples/pitfalls that could be listed? |
Agreed that the documentation needs a disclaimer. The two drawbacks that I can think of.
Some more points for discussion:
|
The only pitfall I see is the one mentioned by @sanket1729 : |
I second that question. |
Right; I guess the only advantage of rawtr over raw/addr is dealing with cases where the public key is either actually untweaked (and e.g. you need want to provide origin information along with it) or it is tweaked in an unknown way, but you have the tweaked private key. raw() in those cases cannot represent all information you have, while rawtr can. |
Agree with Sanket's comments. I also agree that having Regarding the usefulness, I think it's definitely useful for "infer-only" cases like running |
@apoelstra https://twitter.com/achow101/status/1459617340123926534 may or may not have been related. Arguably, not a good justification, but a use case nonetheless... |
Not the worst usecase :) I use vanity addresses in Liquid test networks sometimes to make logs easier to read and having descriptor support in Core could plausibly make that better. |
A usecase for Although as I mentioned later in response comment, this can also be made compatible with Overall, I am leaning towards a concept ACK for this. |
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. |
252a9b8
to
d40a9c5
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.
Should tr(xpriv)
and rawtr(xpriv)
return different addresses ?
I created two blank wallets and imported tr(xpriv)
into one and rawtr(xpriv)
into the other. The xpriv
was the same.
The addresses have the same desc
property but not the same address
, as seen below.
There are also some fields missing from the address generated from rawtr(xpriv)
like timestamp
.
$ ./src/bitcoin-cli -regtest -named createwallet wallet_name=tr_test blank=true
$ ./src/bitcoin-cli -regtest importdescriptors "[{\"desc\": \"tr(tprv8ZgxMBicQKsPdKziibn63Rm6aNzp7dSjDnufZMStXr71Huz7iihCRpbZZZ6Voy5HyuHCWx6foHMipzMzUq4tZrtkZ24DJwz5EeNWdsuwX5h/*)#223d6gp6\", \"active\": true, \"timestamp\": \"now\"}]"
$ ./src/bitcoin-cli -regtest -named createwallet wallet_name=rawtr_test blank=true
$ ./src/bitcoin-cli -regtest -rpcwallet="rawtr_test" importdescriptors "[{\"desc\": \"rawtr(tprv8ZgxMBicQKsPdKziibn63Rm6aNzp7dSjDnufZMStXr71Huz7iihCRpbZZZ6Voy5HyuHCWx6foHMipzMzUq4tZrtkZ24DJwz5EeNWdsuwX5h/*)#223d6gp6\", \"active\": true, \"timestamp\": \"now\"}]"
$ ./src/bitcoin-cli -regtest -rpcwallet="tr_test" -named getnewaddress address_type='bech32m'
bcrt1p8eafa4hnyfae7kyc42ehndduu49zfuhneerma58j2xexc6lx5wxsm8e5j7
$ ./src/bitcoin-cli -regtest -rpcwallet="rawtr_test" -named getnewaddress address_type='bech32m'
bcrt1pqwnxn65jduuptqhvfgqqh9rjh29pwdrlt7c4nmwafgrsx6n8rr4supy9dh
$ ./src/bitcoin-cli -regtest -rpcwallet="rawtr_test" getaddressinfo "bcrt1pqwnxn65jduuptqhvfgqqh9rjh29pwdrlt7c4nmwafgrsx6n8rr4supy9dh"
{
"address": "bcrt1pqwnxn65jduuptqhvfgqqh9rjh29pwdrlt7c4nmwafgrsx6n8rr4supy9dh",
"scriptPubKey": "512003a669ea926f381582ec4a000b9472ba8a17347f5fb159eddd4a07036a6718eb",
"ismine": true,
"solvable": true,
"desc": "rawtr([8324d0e9/0]03a669ea926f381582ec4a000b9472ba8a17347f5fb159eddd4a07036a6718eb)#5rk6yanl",
"parent_desc": "rawtr(tpubD6NzVbkrYhZ4Wo2WcFSgSqRD9QWkGxddo6WSqsVBx7uQ8QEtM7WncKDRjhFEexK119NigyCsFygA4b7sAPQxqebyFGAZ9XVV1BtcgNzbCRR/*)#x2xz0lq0",
"iswatchonly": false,
"isscript": true,
"iswitness": true,
"witness_version": 1,
"witness_program": "03a669ea926f381582ec4a000b9472ba8a17347f5fb159eddd4a07036a6718eb",
"ischange": false,
"labels": [
""
]
}
$ ./src/bitcoin-cli -regtest -rpcwallet="tr_test" getaddressinfo "bcrt1p8eafa4hnyfae7kyc42ehndduu49zfuhneerma58j2xexc6lx5wxsm8e5j7"
{
"address": "bcrt1p8eafa4hnyfae7kyc42ehndduu49zfuhneerma58j2xexc6lx5wxsm8e5j7",
"scriptPubKey": "51203e7a9ed6f3227b9f5898aab379b5bce54a24f2f3ce47bed0f251b26c6be6a38d",
"ismine": true,
"solvable": true,
"desc": "tr([8324d0e9/0]03a669ea926f381582ec4a000b9472ba8a17347f5fb159eddd4a07036a6718eb)#05zmkxzl",
"parent_desc": "tr(tpubD6NzVbkrYhZ4Wo2WcFSgSqRD9QWkGxddo6WSqsVBx7uQ8QEtM7WncKDRjhFEexK119NigyCsFygA4b7sAPQxqebyFGAZ9XVV1BtcgNzbCRR/*)#fdlr9alf",
"iswatchonly": false,
"isscript": true,
"iswitness": true,
"witness_version": 1,
"witness_program": "3e7a9ed6f3227b9f5898aab379b5bce54a24f2f3ce47bed0f251b26c6be6a38d",
"ischange": false,
"timestamp": 1646090838,
"hdkeypath": "m/0",
"hdseedid": "0000000000000000000000000000000000000000",
"hdmasterfingerprint": "8324d0e9",
"labels": [
""
]
}
@w0xlt Yes, that'd definitely expected. If the two weren't different, we wouldn't need to add |
@sipa Thanks for the clarification. But since the wallet is able to generate multiple addresses for For example: # First address
"desc": "tr([8324d0e9/0]03a669ea926f381582ec4a000b9472ba8a17347f5fb159eddd4a07036a6718eb)#05zmkxzl"
"desc": "rawtr([8324d0e9/0]03a669ea926f381582ec4a000b9472ba8a17347f5fb159eddd4a07036a6718eb)#5rk6yanl"
# Second address
"desc": "tr([8324d0e9/1]bbf56b14b119bccafb686adec2e3d2a6b51b1626213590c3afa815d1fd36f85d)#0djkz4yx"
"desc": "rawtr([8324d0e9/1]bbf56b14b119bccafb686adec2e3d2a6b51b1626213590c3afa815d1fd36f85d)#56xhsw4x" Shouldn't |
Different keys give rise to different addresses.... |
Rebased. |
It looks like the CI is failing due to the difference between the expected result and the RPC result in Script (first element in Expected result: RPC result: |
|
I'll get back to this soon. |
…tcoin/bitcoin)
…tcoin/bitcoin)
…tcoin/bitcoin)
…tcoin/bitcoin)
…tcoin/bitcoin)
This might fix the CI errors: from test_framework.key import H_POINT
+ from test_framework.segwit_addr import encode_segwit_address |
…tcoin/bitcoin)
Rebased, and made a few changes:
|
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.
code review ACK 544b433
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.
reACK 544b433
ACK 544b433 |
…tcoin/bitcoin)
…tcoin/bitcoin)
…tcoin/bitcoin)
…tcoin/bitcoin)
…tcoin/bitcoin)
…tcoin/bitcoin)
…tcoin/bitcoin)
It may be useful to be able to represent P2TR outputs in descriptors whose script tree and/or internal key aren't known. This PR does that, by adding a
rawtr(KEY)
descriptor, where the KEY represents the output key directly. If the private key corresponding to that output key is known, it also permits signing with it.I'm not convinced this is desirable, but presumably "tr(KEY)" sounds more intended for direct use than "rawtr(KEY)".