bdk icon indicating copy to clipboard operation
bdk copied to clipboard

Wallet::get_descriptor_for_keychain should return an Option

Open danielabrozzoni opened this issue 1 year ago • 1 comments

https://github.com/bitcoindevkit/bdk/blob/2c324d3759aed4548269084327c94ce91e7b386a/crates/bdk/src/wallet/mod.rs#L1993-L1997

In Wallet::get_descriptor_for_keychain(keychain), if a user passes in a non-existent keychain, we instead return the descriptor associated with KeychainKind::External. What's the reason behind this behavior? IMHO we should just return an Option, and None if the keychain doesn't exist. If this isn't the case, we should at least document this behavior.

danielabrozzoni avatar Feb 20 '24 18:02 danielabrozzoni

Yeah this is an old design issue with Wallet which tries to pretend the External keychain is also Internal Keychain when an Internal keychain doesn't exist. Do we still want Wallet to work with a single descriptor? We could force the user to add the same descriptor as the change descriptor if they really wanted the current behavior. We'd have to think carefully about that of course but I think after #1203 this might work ok at the KeychainTxOutIndex level.

LLFourn avatar Feb 28 '24 05:02 LLFourn

A small change but I think we should push to 2.0 milestone.

notmandatory avatar Mar 20 '24 02:03 notmandatory

We are going to make it mandatory to have descriptors for both keychains

nondiremanuel avatar Mar 21 '24 23:03 nondiremanuel