<p>There are multiple things you are doing wrong.</p>

<p>Firstly, in your first descriptor, you have a miscellaneous space between the origin info (the stuff in square brackets) and the xpub. Secondly, this descriptor is also invalid because you have not computed the correct checksum for it. The checksum is the stuff that appears after the pound symbol (<code>#</code>) at the end of the descriptor. The checksum you have there is the checksum for the one from the help text which is only valid for that descriptor.</p>

<p>In order for your descriptor to be valid, you need to remove the space and recompute the checksum. Remove the checksum, including the pound symbol separator, and pass the non-checksummed descriptor into <code>getdescriptorinfo</code>. This will give you a descriptor with the correct checksum. Please note that it will change the <code>h</code>s in the origin info to single quotes (<code>'</code>) which may need to be escaped.</p>

<p>Furthermore, because you are changing the xpub in your descriptor, the origin info in your descriptor is incorrect (although Bitcoin Core does not know this). You should change the origin information to match your xpub, or remove it entirely.</p>

<p>The reason the second descriptor you are trying does not work is because it does not have a checksum. The PR for <code>deriveaddress</code> was written before descriptors had checksums. The RPC was updated and changed when checksums were introduced.</p>

CC BY-SA 4.0
2019-05-07T16:59:14.833Z
Thank you, what is the "d34db33f" portion of the origin info and how do I get the correct origin info for my xpub? I understand the derivation path 84'/0'/0' but not the rest.
Fontaine
CC BY-SA 4.0
2019-05-07T17:11:20.927Z
That is the fingerprint of the master public key. It's the first 4 bytes of the ripemd160 hash of the sha256 hash of the public key.
Ava Chow
CC BY-SA 4.0
2019-05-07T17:12:27.557Z
How can i ensure the descriptor has range?
Fontaine
CC BY-SA 4.0
2019-05-07T17:19:11.697Z
By having `/*` after your xpub. You can specify unhardened indexes after the xpub, and ending with `/*` indicates that the last index is the range.
Ava Chow
CC BY-SA 4.0
2019-05-07T17:37:18.520Z
Still trying to wrap my head around the origin info and its effect on the derived keys. Again i get how the 84'/0'/0' derives keys work. But when I input `deriveaddresses "wpkh([d34db33f/84'/0'/0']xpub6EuEBhzm7KD3yxmt9wFHisymSNmK8w2CFmfgUgXi74ChFa79YouJ1w3hpZmFAWiuLezZqD38fY6K8PkxUfPifzSEB35skuBBNf1efmSp12K/*)#9k0fv7eh" "[0,99]"` It returns the same 100 keys from an xpub that I created on another app, which is great, but I copied the `d34db33f` from the example origin, it seems like the fingerprint doesn't have an effect? If it does can you explain its effect?
Fontaine
CC BY-SA 4.0
2019-05-07T17:40:22.420Z
Origin info has no effect on key derivation entirely. It is metadata that is useful for transaction signing. You would want to have origin info if you were importing the descriptors via `importmulti`, but for `deriveaddress`, it is unnecessary.
Ava Chow
CC BY-SA 4.0
2019-05-07T14:41:01.413Z
2019-05-07T14:41:01.413Z
Ava Chow
<p>I am copying and pasting the example from the bitcoin-cli help:</p>

<pre><code>deriveaddresses "wpkh([d34db33f/84h/0h/0h] xpub6EuEBhzm7KD3yxmt9wFHisymSNmK8w2CFmfgUgXi74ChFa79YouJ1w3hpZmFAWiuLezZqD38fY6K8PkxUfPifzSEB35skuBBNf1efmSp12K/0/*)#trd0mf0l" "[0,2]"
</code></pre>

<p>And copying in a valid xpub.</p>

<p>However I always get an error:</p>

<pre><code>Invalid descriptor (code -5)
</code></pre>

<p>Even if I copy in the exact bitcoin-cli call from the bitcoin github page here <a href="https://github.com/bitcoin/bitcoin/pull/14667" rel="nofollow noreferrer">deriveaddresses pull request</a></p>

<pre><code>deriveaddresses "wpkh([d34db33f/84h/0h/0h]xpub6DJ2dNUysrn5Vt36jH2KLBT2i1auw1tTSSomg8PhqNiUtx8QX2SvC9nrHu81fT41fvDUnhMjEzQgXnQjKEu3oaqMSzhSrHMxyyoEAmUHQbY/0/0)"
</code></pre>

<p>I still get the same error.</p>

<p>I am entering the commands directly in the console. What am I doing wrong?</p>

<p>Im using mainnet bitcoin core 0.18.0, mac OS 10.13.6</p>

<json-rpc><bitcoin-cli><output-script-descriptors><checksum>
bitcoin-cli deriveaddresses always returns an error
Fontaine
# bitcoin-cli deriveaddresses always returns an error

(Asked by: username_0 on 2019-05-07)

I am copying and pasting the example from the bitcoin-cli help:

```
deriveaddresses "wpkh([d34db33f/84h/0h/0h] xpub6EuEBhzm7KD3yxmt9wFHisymSNmK8w2CFmfgUgXi74ChFa79YouJ1w3hpZmFAWiuLezZqD38fY6K8PkxUfPifzSEB35skuBBNf1efmSp12K/0/*)#trd0mf0l" "[0,2]"

```

And copying in a valid xpub.

However I always get an error:

```
Invalid descriptor (code -5)

```

Even if I copy in the exact bitcoin-cli call from the bitcoin github page here [deriveaddresses pull request](https://github.com/bitcoin/bitcoin/pull/14667)

```
deriveaddresses "wpkh([d34db33f/84h/0h/0h]xpub6DJ2dNUysrn5Vt36jH2KLBT2i1auw1tTSSomg8PhqNiUtx8QX2SvC9nrHu81fT41fvDUnhMjEzQgXnQjKEu3oaqMSzhSrHMxyyoEAmUHQbY/0/0)"

```

I still get the same error.

I am entering the commands directly in the console. What am I doing wrong?

Im using mainnet bitcoin core 0.18.0, mac OS 10.13.6

**Tags:** json-rpc, bitcoin-cli, output-script-descriptors, checksum


---

## 1 answers

### Answer by username_1 on 2019-05-07. Score: 1 | Accepted answer

There are multiple things you are doing wrong.

Firstly, in your first descriptor, you have a miscellaneous space between the origin info (the stuff in square brackets) and the xpub. Secondly, this descriptor is also invalid because you have not computed the correct checksum for it. The checksum is the stuff that appears after the pound symbol (`#`) at the end of the descriptor. The checksum you have there is the checksum for the one from the help text which is only valid for that descriptor.

In order for your descriptor to be valid, you need to remove the space and recompute the checksum. Remove the checksum, including the pound symbol separator, and pass the non-checksummed descriptor into `getdescriptorinfo`. This will give you a descriptor with the correct checksum. Please note that it will change the `h`s in the origin info to single quotes (`'`) which may need to be escaped.

Furthermore, because you are changing the xpub in your descriptor, the origin info in your descriptor is incorrect (although Bitcoin Core does not know this). You should change the origin information to match your xpub, or remove it entirely.

The reason the second descriptor you are trying does not work is because it does not have a checksum. The PR for `deriveaddress` was written before descriptors had checksums. The RPC was updated and changed when checksums were introduced.

> **Comments:**
> **username_0**: Thank you, what is the "d34db33f" portion of the origin info and how do I get the correct origin info for my xpub? I understand the derivation path 84'/0'/0' but not the rest.  
> **username_1**: That is the fingerprint of the master public key. It's the first 4 bytes of the ripemd160 hash of the sha256 hash of the public key.  
> **username_0**: How can i ensure the descriptor has range?  
> **username_1**: By having `/*` after your xpub. You can specify unhardened indexes after the xpub, and ending with `/*` indicates that the last index is the range.  
> **username_0**: Still trying to wrap my head around the origin info and its effect on the derived keys. Again i get how the 84'/0'/0' derives keys work. But when I input `deriveaddresses "wpkh([d34db33f/84'/0'/0']xpub6EuEBhzm7KD3yxmt9wFHisymSNmK8w2CFmfgUgXi74ChFa79YouJ1w3hpZmFAWiuLezZqD38fY6K8PkxUfPifzSEB35skuBBNf1efmSp12K/*)#9k0fv7eh" "[0,99]"` It returns the same 100 keys from an xpub that I created on another app, which is great, but I copied the `d34db33f` from the example origin, it seems like the fingerprint doesn't have an effect? If it does can you explain its effect?  
> **username_1**: Origin info has no effect on key derivation entirely. It is metadata that is useful for transaction signing. You would want to have origin info if you were importing the descriptors via `importmulti`, but for `deriveaddress`, it is unnecessary.  

---

