bdk
bdk copied to clipboard
Add birthday to the wallet database
Describe the enhancement
Add a method wallet_birthday
or birthday
that returns the unix time of when the wallet was created.
Use case
If we know the birthday of a wallet, we can avoid scanning blocks that happened before the wallet was created. If there's no birthday, we must scan the entire chain to be sure that we don't miss txs.
For this purpose, wouldn't it make sense to use the last-seen tip height rather than a UNIX timestamp?
For this purpose, wouldn't it make sense to use the last-seen tip height rather than a UNIX timestamp?
Height + Hash would be better. I'm not too familiar with the bdk internals so I suggested unix time since you can immediately calculate that and store it on start. For blocks, you'd have to wait until you receive a block from the block source so I thought unix time would be a lot simpler codewise but if height + hash is not hard, that'd be preferred.
Height + Hash would be better. I'm not too familiar with the bdk internals so I suggested unix time since you can immediately calculate that and store it on start. For blocks, you'd have to wait until you receive a block from the block source so I thought unix time would be a lot simpler codewise but if height + hash is not hard, that'd be preferred.
Yeah, fair enough. Although I want to note that UNIX time isn't necessarily easily accessibly either, e.g., in no_std
or WASM environments. You can't just assume that SystemTime::now()
is always available unfortunately.
Height + Hash would be better. I'm not too familiar with the bdk internals so I suggested unix time since you can immediately calculate that and store it on start. For blocks, you'd have to wait until you receive a block from the block source so I thought unix time would be a lot simpler codewise but if height + hash is not hard, that'd be preferred.
Yeah, fair enough. Although I want to note that UNIX time isn't necessarily easily accessibly either, e.g., in
no_std
or WASM environments. You can't just assume thatSystemTime::now()
is always available unfortunately.
Oh huh. TIL
I think this would make sense in KeychainTxOutIndex
. Needs #1101. After that you can store a height/hash in there when the descriptor is created.
I think this is a good to have. However, it is not critical for 1.0.0. I'll push it back.
However, if someone is super motivated to do this, I won't stop them. This should be pretty straightforward to implement/review.
Just wonder. Are the wallets with different birthdays in the same network equal?
It is good to check the Genesis hash and the overlapped lifetime of the index and let these wallets equal(assume they sync to the same tip and network). But is there any concern about the equality of wallets with different birthdays?