-
Notifications
You must be signed in to change notification settings - Fork 48
Add wallet birthday to CreateParams
#348
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| use alloc::boxed::Box; | ||
|
|
||
| use bdk_chain::keychain_txout::DEFAULT_LOOKAHEAD; | ||
| use bdk_chain::{keychain_txout::DEFAULT_LOOKAHEAD, BlockId}; | ||
| use bitcoin::{BlockHash, Network, NetworkKind}; | ||
| use miniscript::descriptor::KeyMap; | ||
|
|
||
|
|
@@ -65,6 +65,7 @@ pub struct CreateParams { | |
| pub(crate) change_descriptor_keymap: KeyMap, | ||
| pub(crate) network: Network, | ||
| pub(crate) genesis_hash: Option<BlockHash>, | ||
| pub(crate) birthday: Option<BlockId>, | ||
| pub(crate) lookahead: u32, | ||
| pub(crate) use_spk_cache: bool, | ||
| } | ||
|
|
@@ -88,6 +89,7 @@ impl CreateParams { | |
| change_descriptor_keymap: KeyMap::default(), | ||
| network: Network::Bitcoin, | ||
| genesis_hash: None, | ||
| birthday: None, | ||
| lookahead: DEFAULT_LOOKAHEAD, | ||
| use_spk_cache: false, | ||
| } | ||
|
|
@@ -110,6 +112,7 @@ impl CreateParams { | |
| change_descriptor_keymap: KeyMap::default(), | ||
| network: Network::Bitcoin, | ||
| genesis_hash: None, | ||
| birthday: None, | ||
| lookahead: DEFAULT_LOOKAHEAD, | ||
| use_spk_cache: false, | ||
| } | ||
|
|
@@ -135,6 +138,7 @@ impl CreateParams { | |
| change_descriptor_keymap: KeyMap::default(), | ||
| network: Network::Bitcoin, | ||
| genesis_hash: None, | ||
| birthday: None, | ||
| lookahead: DEFAULT_LOOKAHEAD, | ||
| use_spk_cache: false, | ||
| } | ||
|
|
@@ -162,6 +166,13 @@ impl CreateParams { | |
| self | ||
| } | ||
|
|
||
| /// Begin wallet scanning from the specified birthday. Particularly useful for block-based | ||
| /// scanning sources. | ||
| pub fn birthday(mut self, birthday: BlockId) -> Self { | ||
| self.birthday = Some(birthday); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, it's kind of odd to having to always having to remember the birthday outside of the wallet and setting it on
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree that it's a better idea to persist the birthday in the ChangeSet, but that'd make it a breaking change.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One can either immediately persist the change using |
||
| self | ||
| } | ||
|
|
||
| /// Use a custom `lookahead` value. | ||
| /// | ||
| /// The `lookahead` defines a number of script pubkeys to derive over and above the last | ||
|
|
||
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.
How will this interact with Esplora or Electrum syncing? I do wonder if we could at least limit how far we go back in full-scan syncing.
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.
I believe this should have no effect. Both sources are based on script pub keys and I am under the impression the different between sync and full scan should only be a matter of how many scripts are queried. I may be wrong but perhaps @oleonardolima knows more precisely.