Issue Details
- Number
- 29320
- Title
- getdescriptorinfo returns unusable descriptor
- Description
- ### Is there an existing issue for this?
- [X] I have searched the existing issues
### Current behaviour
NOTE: Replace `bch.sh` below in the code with `bitcoin-cli -signet`.
Let's have a random new testnet descriptor wallet with following private descriptors:
```sh
~/.bitcoin/signet$ bch.sh listdescriptors true | jq .descriptors[].desc | tail -1
"wpkh(tprv8ZgxMBicQKsPdpPsVvhB5XZtRfRWGqH1uwJNmG27dQgDwTS76oCd3hKbn3zERUZjG2fCgdKe8rqT2NomNbCgGSUQ829rJkTLUWvGKzyHX7Z/84h/1h/0h/1/*)#duvgfk6y"
```
I will use just the one on the last line.
When the prvate descriptor above is used with `getdescriptorinfo` RPC call I get following:
```sh
~/.bitcoin/signet$ bch.sh getdescriptorinfo "wpkh(tprv8ZgxMBicQKsPdpPsVvhB5XZtRfRWGqH1uwJNmG27dQgDwTS76oCd3hKbn3zERUZjG2fCgdKe8rqT2NomNbCgGSUQ829rJkTLUWvGKzyHX7Z/84h/1h/0h/1/*)#duvgfk6y"
{
"descriptor": "wpkh(tpubD6NzVbkrYhZ4XHRfPaMmUwDzzgwSSATvVEuA3n4R3gUcmwgsjC2DEBwTxB4qBjSBoofF3xKGAsQE3GhBDSFi6b8PcDwXLdEoNxrovTFmyYt/84h/1h/0h/1/*)#9zp9fyaf",
"checksum": "duvgfk6y",
"isrange": true,
"issolvable": true,
"hasprivatekeys": true
}
```
When the just-returned descriptor is used in `deriveaddress` it ends with an error:
```sh
~/.bitcoin/signet$ bch.sh deriveaddresses "wpkh(tpubD6NzVbkrYhZ4XHRfPaMmUwDzzgwSSATvVEuA3n4R3gUcmwgsjC2DEBwTxB4qBjSBoofF3xKGAsQE3GhBDSFi6b8PcDwXLdEoNxrovTFmyYt/84h/1h/0h/1/*)#9zp9fyaf" '[0,1]'
error code: -5
error message:
Cannot derive script without private keys
```
If the wallet is queried by `listdescriptors`, just public, I get this for the same derivation path:
```sh
~/.bitcoin/signet$ bch.sh listdescriptors | jq .descriptors[].desc | tail -1
"wpkh([823c2027/84h/1h/0h]tpubDDPGZQssk8ekvcN85aXhvz5omhZdQPWcczP21RqCHw7i5ce89zgYHoxowE8HrUUi2XUr4Vv4x48Ykhw7JBCH6G8QUfgRRR9UPgbC74DdNC4/1/*)#spvfr65h"
```
When I use the above just-returned public descriptor it derives addresses well:
```sh
~/.bitcoin/signet$ bch.sh deriveaddresses "wpkh([823c2027/84h/1h/0h]tpubDDPGZQssk8ekvcN85aXhvz5omhZdQPWcczP21RqCHw7i5ce89zgYHoxowE8HrUUi2XUr4Vv4x48Ykhw7JBCH6G8QUfgRRR9UPgbC74DdNC4/1/*)#spvfr65h" '[0,1]'
[
"tb1qegtflj2zzv6wqwh0zgh7zeztv2ek6awsvz4fpk",
"tb1qslc5s8gd5zd7fa3cj64zt7kmlnw348x6q6cg28"
]
```
### Expected behaviour
I would expect also the `getdescriptorinfo` for the private descriptor to return a valid public descriptor usable for deriving addresses.
### Steps to reproduce
```sh
myderive() {
bitcoin-cli -signet getdescriptorinfo "$1" | jq -r .descriptor | while read a; do bitcoin-cli -signet deriveaddresses "$a" '[0,1]'; done
}
myderive "wpkh(tprv8ZgxMBicQKsPdpPsVvhB5XZtRfRWGqH1uwJNmG27dQgDwTS76oCd3hKbn3zERUZjG2fCgdKe8rqT2NomNbCgGSUQ829rJkTLUWvGKzyHX7Z/84h/1h/0h/1/*)#duvgfk6y"
# above fails
myderive "wpkh([823c2027/84h/1h/0h]tpubDDPGZQssk8ekvcN85aXhvz5omhZdQPWcczP21RqCHw7i5ce89zgYHoxowE8HrUUi2XUr4Vv4x48Ykhw7JBCH6G8QUfgRRR9UPgbC74DdNC4/1/*)#spvfr65h"
```
Former errs, the latter works. Both are returned from `listdescriptors`, but former is the private from `listdescriptors true`.
### Relevant log output
_No response_
### How did you obtain Bitcoin Core
Pre-built binaries
### What version of Bitcoin Core are you using?
v26.0.0
### Operating system and version
Pop!_OS 22.04 LTS (like Ubuntu, just uses zram)
### Machine specifications
x86_64
SSD big enough for Signet (proper, non-custom)
- URL
-
https://github.com/bitcoin/bitcoin/issue/29320
- Closed by
-
Back to List