Skip to content

Commit 22169a4

Browse files
committed
Add Esplora blockchain backend support
This commit adds support for using Esplora as a blockchain backend for LND, enabling operation without requiring a full Bitcoin node (btcd/bitcoind). Key features: - Esplora chain client implementation for block/transaction queries - Esplora chain notifier for confirmations and spend notifications - Esplora fee estimator with smart fee selection - FilteredChainView implementation for routing - Gap limit scanning for wallet recovery - Optimized block scanning with progress logging Configuration: - bitcoin.node=esplora - esplora.url=<esplora-api-url> - esplora.requesttimeout=30s - esplora.maxretries=3 - esplora.pollinterval=10s Co-Authored-By: Nitesh Balusu <niteshbalusu@icloud.com>
1 parent b79f32c commit 22169a4

28 files changed

+8705
-68
lines changed

chainntnfs/esploranotify/driver.go

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package esploranotify
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/btcsuite/btcd/chaincfg"
7+
"github.com/lightningnetwork/lnd/blockcache"
8+
"github.com/lightningnetwork/lnd/chainntnfs"
9+
"github.com/lightningnetwork/lnd/esplora"
10+
)
11+
12+
// createNewNotifier creates a new instance of the EsploraNotifier from a
13+
// config.
14+
func createNewNotifier(args ...interface{}) (chainntnfs.ChainNotifier, error) {
15+
if len(args) != 5 {
16+
return nil, fmt.Errorf("incorrect number of arguments to "+
17+
"createNewNotifier, expected 5, got %d", len(args))
18+
}
19+
20+
client, ok := args[0].(*esplora.Client)
21+
if !ok {
22+
return nil, fmt.Errorf("first argument must be an " +
23+
"*esplora.Client")
24+
}
25+
26+
chainParams, ok := args[1].(*chaincfg.Params)
27+
if !ok {
28+
return nil, fmt.Errorf("second argument must be a " +
29+
"*chaincfg.Params")
30+
}
31+
32+
spendHintCache, ok := args[2].(chainntnfs.SpendHintCache)
33+
if !ok {
34+
return nil, fmt.Errorf("third argument must be a " +
35+
"chainntnfs.SpendHintCache")
36+
}
37+
38+
confirmHintCache, ok := args[3].(chainntnfs.ConfirmHintCache)
39+
if !ok {
40+
return nil, fmt.Errorf("fourth argument must be a " +
41+
"chainntnfs.ConfirmHintCache")
42+
}
43+
44+
blockCache, ok := args[4].(*blockcache.BlockCache)
45+
if !ok {
46+
return nil, fmt.Errorf("fifth argument must be a " +
47+
"*blockcache.BlockCache")
48+
}
49+
50+
return New(client, chainParams, spendHintCache, confirmHintCache,
51+
blockCache), nil
52+
}
53+
54+
// init registers a driver for the EsploraNotifier.
55+
func init() {
56+
chainntnfs.RegisterNotifier(&chainntnfs.NotifierDriver{
57+
NotifierType: notifierType,
58+
New: createNewNotifier,
59+
})
60+
}

0 commit comments

Comments
 (0)