Author

Topic: Bitcoin Descriptor decomposition (Read 213 times)

legendary
Activity: 2618
Merit: 6452
Self-proclaimed Genius
October 17, 2024, 11:33:09 PM
#6
-snip-
An interesting detail is about the behavior of bitcoin core when importing an extended private key with the descriptor configured on the root node (m). When doing this and then exporting the descriptors (gethdkeys command for example) Bitcoin Core doesn't derive the fingerprint from the descriptor.
It's a neat detail because otherwise, it'll be showing a value that wont be any of use.

Here's why:
That's because the xpub in your first example gethdkeys result is a "master public key" which is the pair of the master private key.
Since it's the master public key, there's no reason to compute a master fingerprint because it's basically the master public key itself (w/o the chain code), hashed.
hero member
Activity: 1120
Merit: 540
Duelbits - Play for Free | Win for Real
October 17, 2024, 01:58:28 PM
#5
The derivation path indicates the actual positions of the displayed master fingerprint (representing "m") and the extended public key.
So the watch-only descriptor's derivation path is m/84'/0'/0'(xpub)/0/*(address_index) defining the path to your receiving addresses.

--edit-fixed-the-labeled-derivation-path--
An interesting detail is about the behavior of bitcoin core when importing an extended private key with the descriptor configured on the root node (m). When doing this and then exporting the descriptors (gethdkeys command for example) Bitcoin Core doesn't derive the fingerprint from the descriptor.

Using for example the extended private key of an electrum wallet (with descriptors):

Code:
"wpkh(xprv9twuT81YpbNNiyxZzuWvppZvDdyHKrALPWbDWWeitj1KwkpmQo9xBKQYhrRoaD54FN2WESq3DREXmpuYhvM1uJNRTGZBfhZzwN6A3BCfjth/0/*)#nf7hkv8v"
"wpkh(xprv9twuT81YpbNNiyxZzuWvppZvDdyHKrALPWbDWWeitj1KwkpmQo9xBKQYhrRoaD54FN2WESq3DREXmpuYhvM1uJNRTGZBfhZzwN6A3BCfjth/1/*)#zamkteh5"

Importing into Bitcoin Core:
Code:
importdescriptors '[{"desc":"wpkh(xprv9twuT81YpbNNiyxZzuWvppZvDdyHKrALPWbDWWeitj1KwkpmQo9xBKQYhrRoaD54FN2WESq3DREXmpuYhvM1uJNRTGZBfhZzwN6A3BCfjth/0/*)#nf7hkv8v","timestamp":"now","active":false,"range": [0, 1000], "internal":false},{"desc":"wpkh(xprv9twuT81YpbNNiyxZzuWvppZvDdyHKrALPWbDWWeitj1KwkpmQo9xBKQYhrRoaD54FN2WESq3DREXmpuYhvM1uJNRTGZBfhZzwN6A3BCfjth/1/*)#zamkteh5","timestamp":"now","active":false,"range": [0, 1000], "internal":true}]'

When listing the public keys available in the keystore using the gethdkeys command, Bitcoin Core returns the following:

Code:
[
  {
    "xpub": "xpub67wFrdYSexvfwU336w3wBxWemfomjJtBkjWpJu4LT4YJpZ9uxLUCj7j2Z6i9i19mLD4gzCXrSVXuWhDSpwBcPUpEaf9gPpQWDTBTjCy439u",
    "has_private": true,
    "descriptors": [
      {
        "desc": "wpkh(xpub67wFrdYSexvfwU336w3wBxWemfomjJtBkjWpJu4LT4YJpZ9uxLUCj7j2Z6i9i19mLD4gzCXrSVXuWhDSpwBcPUpEaf9gPpQWDTBTjCy439u/0/*)#vr2akcza",
        "active": false
      },
      {
        "desc": "wpkh(xpub67wFrdYSexvfwU336w3wBxWemfomjJtBkjWpJu4LT4YJpZ9uxLUCj7j2Z6i9i19mLD4gzCXrSVXuWhDSpwBcPUpEaf9gPpQWDTBTjCy439u/1/*)#ah0utdj9",
        "active": false
      }
    ]
  }
]

Note that there is no fingerprint listed in this case.

Now, when comparing this to an extended private key set to the derivation path m/84'/0'/0', Bitcoin Core displays the fingerprint correctly. Here is an example:

Code:
{
    "desc": "wpkh([1a8a5ac4/84h/0h/0h]xpub6CbMhMYjFEv2KY2VV3S2TRUAsV1Gv96z88pzafh66ZfScvsN9NQ59Uubycj98i6pruPGH8MsrRfJ6br4h17GXeJ5fhN9bjTe9XdKCpZks9H/0/*)#pny32srk",
    "active": false
},
{
    "desc": "wpkh([1a8a5ac4/84h/0h/0h]xpub6CbMhMYjFEv2KY2VV3S2TRUAsV1Gv96z88pzafh66ZfScvsN9NQ59Uubycj98i6pruPGH8MsrRfJ6br4h17GXeJ5fhN9bjTe9XdKCpZks9H/1/*)#s8psh9nw",
    "active": false
}
legendary
Activity: 2618
Merit: 6452
Self-proclaimed Genius
October 10, 2024, 01:28:36 AM
#4
Then I'm guessing the xpub value is just the extended public key resulting from that derivation?
Yes, from the example descriptor; it's the extended public key at m/84'/0'/0'
(BTW, I double-checked it and removed an extra "/" )

So I see that given the master private key, first we derive 84h/0h/0h.
Yes, that's done in the signer wallet where the master private key is available.
In descriptors without private key like your example, the extended public key is specified instead and its derivation path from the master private key is indicated on its left.
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
October 09, 2024, 09:13:12 AM
#3
So the watch-only descriptor's derivation path is m/84'/0'/0'/xpub/0/address_index defining the path to your receiving addresses.

So I see that given the master private key, first we derive 84h/0h/0h.

Then I'm guessing the xpub value is just the extended public key resulting from that derivation? Since there's more derivation paths after it, it wouldn't make much sense if it was something otherwise.
legendary
Activity: 2618
Merit: 6452
Self-proclaimed Genius
October 08, 2024, 01:23:11 AM
#2
The "e7ae72ff" on the left is the "master fingerprint" computed from the public key pair of the master private key.
Refer to this post to see how it works: https://bitcointalksearch.org/topic/m.61903879

each with their own derivation paths.
The derivation path indicates the actual positions of the displayed master fingerprint (representing "m") and the extended public key.
So the watch-only descriptor's derivation path is m/84'/0'/0'(xpub)/0/*(address_index) defining the path to your receiving addresses.

--edit-fixed-the-labeled-derivation-path--
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
October 07, 2024, 02:08:13 AM
#1
These new descriptors generated by Bitcoin Core and Sparrow Wallet, that look like this:

Code:
wpkh([e7ae72ff/84h/0h/0h]xpub6Bu4sXJDbqjmDt4NmiWQpfFdoNPnvBDoy3y4ehtEsHEwgb7LjxCaxwKUXkuhW5QaQvGQWGrWWCAmskcWtt3vVf4drhshbomcTLRQJtdX3h3/0/*)#29e7w7k7

I don't fully understand them. Like I know the wpkh means to derive P2WPKH keys, and the hash followed by those characters at the end is a checksum, but I cannot determine the difference between what appears to be a chain code on the left with the xpub on the right, each with their own derivation paths.
Jump to: