bdk icon indicating copy to clipboard operation
bdk copied to clipboard

Add an example showing how to open a pre-existing wallet

Open casey opened this issue 3 years ago • 5 comments

All the examples I've been able to find show how to initialize a wallet with BDK, but not how to open an existing wallet.

From looking at the examples, I'm not sure how to open an existing wallet without having the seed phrase available to generate the output descriptor needed to pass to new.

casey avatar Jul 18 '22 19:07 casey

Our database doesn't store secrets, just blockchain data. This means that if you want to re-open a wallet you need to give us through new both the private descriptor and the database path (if you're using a persistent database, obviously).

Alternatively, if you don't want to re-create the private descriptor, and you don't care about signing, the public descriptor is enough.

danielabrozzoni avatar Jul 20 '22 21:07 danielabrozzoni

This is what eluded me. Thank you for explaining! If it's a common misconception, it might be worth documenting somewhere. E.g., "Your application will need to arrange to securely store the secret/descriptor/whatever outside of the wallet." "Wallet" makes me think "something that stores secrets", so others might also have this confusion.

casey avatar Jul 20 '22 21:07 casey

You're right, we should probably add this to the rust docs and also maybe somewhere in the tutorials on the website. Thanks!

danielabrozzoni avatar Jul 21 '22 16:07 danielabrozzoni

Our database doesn't store secrets

Since the BDK wallet is able to sign (bdk::wallet::Wallet pub fn sign), are private keys stored in memory?

Are there any recommendations on how to store descriptors/mnemonics to recreate the wallet every time?

w0xlt avatar Jul 26 '22 04:07 w0xlt

I think how descriptors can be stored with private information is entirely an application layer logic.. It can be stored in a simple file in encrypted format.. Or it can be stored in a hardware device.. Depends on how the users wanna use it.. But I agree it would be good to document somewhere that BDK doesn't store private key information anywhere.. It only exists in memory as long as the wallet is in scope.. Its upto the user to fetch the full descriptor and feed it to BDK..

rajarshimaitra avatar Aug 15 '22 15:08 rajarshimaitra