bitcoin-cli deriveaddresses always returns an error 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

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
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 hs 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.