Conversation
527a8d4 to
77e2d88
Compare
77e2d88 to
8ea292f
Compare
| /// Set the [`Wallet`]'s birthday, as a [`BlockId`]. | ||
| /// | ||
| /// The birthday can be used to limit how far back a chain oracle is queried, | ||
| /// saving up time and data bandwidth in full-scans. | ||
| pub fn birthday(mut self, birthday: BlockId) -> Self { | ||
| self.birthday = Some(birthday); | ||
| self | ||
| } | ||
|
|
There was a problem hiding this comment.
I wonder if this should be public. It gives the user the freedom to set whatever value he wants, even if they're incorrect. @ValuedMammal or @evanlinjin can you shed some light on what would happen if I create a CheckPoint with a height+hash pair that doesn't exist on the chain, and then synched from genesis?
There was a problem hiding this comment.
Good question and probably requires testing before going ahead with this feature. The hope is that the bad block will be "reorged out" of the wallet, but that'll depend on which block IDs the chain source decides to return.
There was a problem hiding this comment.
I think the best approach would be to not allow manually setting the birthday, and instead rely on the result of a full-scan to define it.
|
I was more in favor of the approach in #348 which provided an option on |
Indeed, this would be a better flow, but may conflict with a possibly inexistent |
Some thoughts:
The only fear is if the chain source has never even seen the no-longer-existing-block - in which case, the chain source starts syncing from genesis (as that would be the closest checkpoint that connects). So if the user creates a wallet just before a reorg, that would be non-ideal. My suggestion:
Then we provide docs as how to convey the wallet's birthday to the chain source using the checkpoint tip. |
WIP, needs bitcoindevkit/bdk#2097
This PR adds a birthday to the wallet, as a
BlockId. Block-by-Block and CBF scanning can use this as a hint to only scan from the birthday onwards, saving time and bandwidth on full-scans where the birthday is previously known.Client code should be updated to automatically set the birthday when performing a full-scan.
TODO
bitcoind_rpcexample that uses the birthday as thestart_height