bitcoindevkit / bitcoindevkit/bdk-ffi
BIP descriptor constructors panic for valid single descriptor keys
- Dominant language
- Rust
- Stars
- 127
- Forks
- 81
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 5
Description
**Describe the bug**
`DescriptorSecretKey::from_string()` accepts a valid single private key encoded as WIF, but the BIP template constructors treat `BdkDescriptorSecretKey::Single(_)` as unreachable. Passing that accepted key to `Descriptor::new_bip44()`, `new_bip49()`, `new_bip84()`, or `new_bip86()` therefore panics inside Rust instead of returning a recoverable error to the UniFFI caller.
The corresponding public constructors have the same issue for `BdkDescriptorPublicKey::Single(_)`. Multipath variants are also handled with `unreachable!()`.
Current example: [`new_bip84()`](https://github.com/bitcoindevkit/bdk-ffi/blob/1fdfdf63f7dad278c1110dd5caadf5cf483684d2/bdk-ffi/src/descriptor.rs#L185-L210).
**To Reproduce**
```rust
let key = DescriptorSecretKey::from_string(
"L2wTu6hQrnDMiFNWA5na6jB12ErGQqtXwqpSL7aWquJaZG8Ai3ch".to_string(),
)
.unwrap();
let _descriptor = Descriptor::new_bip84(
&key,
KeychainKind::External,
NetworkKind::Main,
);
```
`from_string()` succeeds, then `new_bip84()` reaches `BdkDescriptorSecretKey::Single(_) => unreachable!()`. The same sequence is available from generated Kotlin and Swift bindings.
**Expected behavior**
Unsupported key variants should produce a typed error such as an invalid-key-type/descriptor error instead of panicking across the FFI boundary. The other BIP template constructors and their public-key variants should behave consistently.
**Build environment**
- BDK FFI commit: `1fdfdf63f7dad278c1110dd5caadf5cf483684d2` (`master`)
- OS/target: not platform-specific; reachable through UniFFI bindings
**Additional context**
This is related to, but not covered by, [PR #1027](https://github.com/bitcoindevkit/bdk-ffi/pull/1027), which fixed the analogous single-key panic only in `DescriptorSecretKey::secret_bytes()`. [PR #506](https://github.com/bitcoindevkit/bdk-ffi/pull/506) added `InvalidKeyType` handling to descriptor key derive/extend methods, but did not change the BIP descriptor constructors.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in bdk-ffi/src/descriptor.rs around new_bip84(), then inspect new_bip44(), new_bip49(), and new_bip86() plus their public-key variants. Reproduce the issue with DescriptorSecretKey::from_string() and a single WIF key; done means every unsupported single or multipath variant returns a typed error rather than panicking across the UniFFI boundary.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100