bdk
bdk copied to clipboard
README example is wrong
use bdk::{bitcoin::Network, wallet::{AddressIndex, Wallet}};
fn main() {
// a type that implements `Persist`
let db = ();
let descriptor = "wpkh(tprv8ZgxMBicQKsPdy6LMhUtFHAgpocR8GC6QmwMSFpZs7h6Eziw3SpThFfczTDh5rW2krkqffa11UpX3XkeTTB2FvzZKWXqPY54Y6Rq4AQ5R8L/84'/0'/0'/0/*)";
let mut wallet = Wallet::new(descriptor, None, db, Network::Testnet).expect("should create");
// get a new address (this increments revealed derivation index)
println!("revealed address: {}", wallet.get_address(AddressIndex::New));
println!("staged changes: {:?}", wallet.staged());
// persist changes
wallet.commit().expect("must save");
}
This indicates two things that are not helpful:
- You should do
Wallet::newwhen you don't want persistence. We have a method for creating a wallet without persistence. If we want to show them how to use actual persistence then let's use that method. - You do not need to call
commitafter doingget_addressto persist the changes -- it does it automatically (in factstagedshould be empty which indicates to me no one has run this example :sweat_smile:) . There's also no point in committing anyway since the db is explicitly()so it's confusing.
+1
Kinda related, we should also remove this part:
For a release timeline see the bdk_core_staging repo where a lot of the component work is being done. The plan is that everything in the bdk_core_staging repo will be moved into the crates directory here.
And link to the actual roadmap https://github.com/orgs/bitcoindevkit/projects/14/views/1?filterQuery=
Moved to beta.0 since this isn't an API change, just an examples / docs cleanup.
It's a pretty important one though? Broken outdated READMEs often put people off trying stuff.
I agree the README example is important, and probably not too hard to fix we just have lots of higher priority stuff in the queue to code/review. As long as it's fixed before we make any big beta announcements I'd prefer to keep it in the beta milestone.
I am aware this is in need of a refresh. Leaving a few extra notes here:
- Some links are either broken or point to non-existent types
- If the intention is to demonstrate wallet persistence, we could find another method that would require the user to commit their own changes (not sure if there is a practical example of this)
- The example descriptor mixes a mainnet derivation path with Testnet network (evidently a pet peeve of mine)