L2-Technology / sensei

A lightning node implementation for everyone
https://l2.technology/sensei
Other
199 stars 39 forks source link

unify wallet last sync time #69

Closed johncantrell97 closed 2 years ago

johncantrell97 commented 2 years ago

BDK stores a last sync time that stores a unix timestamp and height of the block. It updates this value as part of the wallet.sync() routine. It only reads this value and only uses the height as part of signing PSBT's.

Sensei doesn't use the normal wallet.sync() routine to keep the on-chain wallet synced. It uses LDK's Listen interface to directly update the on-chain database when blocks are connected and disconnected. This means it needs to know the last synced BlockHash to use LDK's lightning-block-sync crate.

Previously we were storing both these items in separate key's in the kv_store. This PR unifies the two use-cases into a single last_onchain_wallet_sync key that stores a serialized LastSync object that contains the hash, height, and timestamp.

This means from this one value we can get what we need for lightning-block-sync and bdk's BlockTime object.

We update it every-time a block is connected or disconnected.