-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: show example migration from bdk to bdk_wallet #1648
base: master
Are you sure you want to change the base?
Conversation
23a9d14
to
eb7328f
Compare
Looks good, simpler and safer than dealing directly with database or intermediate text files as I'd originally proposed. A few suggestions:
|
ffa2eef
to
dca8941
Compare
I tested this by first syncing a
and persisted with sqlite. Then I ran the example in this PR, initializing
I added assertions for utxos, balance, and revealed addresses. Just to note: this assumes the old database is up to date and no new information is presented as a result of syncing the new wallet. I'm wondering whether |
Yes I agree it might make a better book section with companion code to take snippets from. |
Maintenance version v0.30.0 of |
let old_wallet = Wallet::new(EXTERNAL, Some(INTERNAL), NETWORK, db)?; | ||
|
||
// Get last revealed addresses for each keychain | ||
let addr = old_wallet.get_address(AddressIndex::LastUnused)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should sync old_wallet
to make sure we have an accurate AddressIndex::LastUnused
or could use AddressIndex::New
here which makes sure we are working with the last exposed (possibly not yet used) index from old_wallet
.
// for a fully functioning wallet. | ||
|
||
let client = BdkElectrumClient::new(electrum_client::Client::new(ELECTRUM_URL)?); | ||
let request = new_wallet.start_full_scan().inspect({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need a full_scan()
here? Since we already know the last exposed SPK we should be able to do a sync()
instead which will be quicker and can still retrieve the previous txouts.
Overall looks great, short and too the point. I have a couple suggestions but otherwise this looks ready to go. |
As discussed on call today, this can be closed in favor of bitcoindevkit/book-of-bdk#81. That PR is already using |
I created a migration workflow in the form of a runnable example that does everything in one go. In the example we
bdk_wallet::Wallet
with new databasefixes #1606
Changelog notice
Checklists
All Submissions:
cargo fmt
andcargo clippy
before committing