bdk icon indicating copy to clipboard operation
bdk copied to clipboard

Mempool.space Integration in BDK

Open rajarshimaitra opened this issue 3 years ago • 9 comments

Description

mempool.space is a very nice and useful blockchain explorer. They also have a rich public API which can be used to query the blockchain data, which has more capabilities than Core RPC or other blockchain APIs.

Expected Outcomes

  • Understanding of Bitcoin Blockchain APIs.
  • Understanding of BDK’s blockchain syncing methods.
  • A mempool.space backend in BDK library.

Resources

Skills Required

Mentor(s)

@rajarshimaitra

Difficulty : Medium

Competency Test (optional)

  • Install rust, compile and run all bdk examples and tests.
  • Read through the BDK docs.
  • Make a dummy wallet with BDK with different blockchain backends.
  • Familiarity with basic rust, should be able to write basic custom trait implementations on foreign structures.

rajarshimaitra avatar Nov 30 '21 06:11 rajarshimaitra

mempool.space is just esplora. We actually use mempool.space as the default backend in gun because it's much more reliable than blockstream.info.

LLFourn avatar Dec 01 '21 05:12 LLFourn

Hmm makes sense. Probably it will be redundant in context of BDK. But might be a good exercise for students to get familiar with blockchain APIs and wallet syncing.

rajarshimaitra avatar Dec 01 '21 07:12 rajarshimaitra

I don't remember who/when, but I think somebody said that they expose more powerful APIs that we could take advantage of (?)

@notmandatory do you remember this or I am just making this up?

afilini avatar Dec 01 '21 09:12 afilini

Yes it was @wiz who suggested we integrate with mempool's more extensive api, docs are here:

https://mempool.space/api

original issue is #289.

notmandatory avatar Dec 01 '21 17:12 notmandatory

Yeah I think mempool.space does indeed have more data and indexes but to be clear I mean that the Blockchain trait can just use the esplora API it supports and do just fine.

Perhaps an interesting thing would be to add the mempool.space websocket backend to do live syncing similar to what @johncantrell97 was talking about with respect to fetching data live from blocks.

LLFourn avatar Dec 01 '21 22:12 LLFourn

I just want to add that the cool thing about our API is that it can also run on a Raspberry Pi - this probably better enables integration with BDK for self-hosted projects

wiz avatar Dec 01 '21 23:12 wiz

I just want to add that the cool thing about our API is that it can also run on a Raspberry Pi - this probably better enables integration with BDK for self-hosted projects

Don't you have to run rust esplora backend to support your API though? I thought it was pretty difficult to run on a raspberry pi. I had a lot of difficult on a old tower PC with 16gb ram.

LLFourn avatar Dec 02 '21 00:12 LLFourn

No, that's the whole point, we support 3 backends: bitcoind RPC only, romanz/electrs, and blockstream/electrs - our mempool backend is a wrapper around these 3 to expose a unified API. Of course without one of the two supported electrs backends you can't do address lookups, and using romanz/electrs also has some limitations, but for the most part everything works ;)

wiz avatar Dec 02 '21 01:12 wiz

mempool.space is just esplora

That's not true, as mempool can easily be self-hosted on a Raspberry Pi with just one click installation from the app stores on Umbrel, RaspiBlitz, RoninDojo, and MyNode - esplora only runs on a powerful server.

We actually use mempool.space as the default backend in gun because it's much more reliable than blockstream.info

Thanks, we own and operate our own global ISP for the mempool.space servers whereas Blockstream uses cloud providers and hosting companies, so it's great to hear we are more reliable :)

wiz avatar Dec 02 '21 01:12 wiz