bitcoindevkit / bdk

A modern, lightweight, descriptor-based wallet library written in Rust!
Other
796 stars 284 forks source link

Mempool.space Integration in BDK #482

Open rajarshimaitra opened 2 years ago

rajarshimaitra commented 2 years ago

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)

LLFourn commented 2 years ago

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.

rajarshimaitra commented 2 years ago

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.

afilini commented 2 years ago

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?

notmandatory commented 2 years ago

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.

LLFourn commented 2 years ago

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.

wiz commented 2 years ago

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

LLFourn commented 2 years ago

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.

wiz commented 2 years ago

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 commented 2 years ago

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 :)