bdk icon indicating copy to clipboard operation
bdk copied to clipboard

Update `bdk_electrum` to use electrum's merkle proof API

Open evanlinjin opened this issue 2 years ago • 7 comments

Describe the enhancement

As mentioned by @LLFourn in https://github.com/bitcoindevkit/bdk/pull/976#discussion_r1193920143:

... I think electrum really intends for you to use the merkle proof API. Best solution is to do that and attach confirmation time of each block to LocalChain.

Additional context

  • This should be attempted after #976 is merged. ~* This may require changing LocalChain.~

evanlinjin avatar May 17 '23 04:05 evanlinjin

After discussion with @evanlinjin, it has been decided that I will attempt to pick this up.

LagginTimes avatar Jun 06 '24 10:06 LagginTimes

We've started a rough document here of the plan: https://hackmd.io/@bdk/electrum_spv

evanlinjin avatar Jun 06 '24 10:06 evanlinjin

FYI, since I needed it for LDK's electrum integration, I added a utility to validate merkle proofs to rust-electrum-client a while back: https://github.com/bitcoindevkit/rust-electrum-client/pull/122

Just mentioning it as they could potentially be useful.

tnull avatar Jun 06 '24 10:06 tnull

Just chiming in that I think this should be a priority. It will need very careful engineering to make efficient. I think perhaps we should have CheckPoint in the BdkElectrumClient to keep track of re-orgs. This would allow us to cache merkle proofs and block headers (because we know they haven't changed). Despite this I predict the code would actually get simpler. No more weird loop and restarting in case of re-orgs.

To start off with we don't need to actually return the proofs. They can just be used to make our algorithm actually sound and robust.

LLFourn avatar Jun 12 '24 03:06 LLFourn

Since this doesn't touch the wallet APIs I moved it to the beta milestone.

notmandatory avatar Jun 25 '24 19:06 notmandatory

@notmandatory my suggestions on #1489 means it would touch the wallet API. Please take a look.

LLFourn avatar Jun 27 '24 01:06 LLFourn

Moving this and #1489 back to the 1.0.0-alpha milestone.

notmandatory avatar Jun 27 '24 14:06 notmandatory