Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion darepod/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,13 @@ const (

// DefaultEsploraPollInterval is the default interval at which the
// lwwallet polls the Esplora API for new blocks and transactions.
DefaultEsploraPollInterval = 5 * time.Second
// Mainnet blocks land roughly every 10 minutes, so a 30 s cadence
// stays comfortably within one block's worth of latency while
// keeping the request volume well under the public mempool.space
// rate limits. Tests / regtest environments that mine blocks on
// demand should override this to a sub-second value via the
// `wallet.pollinterval` config knob.
DefaultEsploraPollInterval = 30 * time.Second

// DefaultRecoveryWindow is the default address look-ahead window
// used during lwwallet recovery.
Expand Down
38 changes: 26 additions & 12 deletions darepod/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1198,6 +1198,18 @@ func (s *Server) startLwwallet(ctx context.Context,
s.lwWallet = fn.Some(w)
s.refreshProofKeyBackend()

// Wire up the chain backend reference if it was deferred at
// startup because the wallet was not yet available. The wallet's
// chain backend was already started inside w.Start() above
// (lwwallet.Wallet.Start calls chainBackend.Start as part of its
// startup sequence). Calling Start a second time here would
// subscribe to the shared TipPoller again and spawn a duplicate
// handleTipEvents goroutine, which would double block-epoch
// notifications and confirmation/spend re-checks.
if s.chainBackend == nil {
s.chainBackend = w.ChainBackend()
}

// Refresh the RPC clients once the wallet is available so the
// indexer client picks up the wallet-backed identity key and signer
// before any deferred wallet-dependent actors start.
Expand Down Expand Up @@ -1607,23 +1619,25 @@ func (s *Server) initChainBackend(ctx context.Context) error {

case WalletTypeLwwallet:
// If the lwwallet is already started (auto-unlock
// succeeded), use its chain backend. Otherwise, we
// need a standalone Esplora chain backend that can
// serve the chain source actor before the wallet is
// ready.
// succeeded), use its chain backend. Otherwise defer
// chain backend creation to startLwwallet so that the
// wallet's TipPoller, EsploraClient, and ChainBackend
// are all owned by the wallet — running a standalone
// EsploraClient + TipPoller here in the interactive-
// unlock path would silently double the Esplora call
// rate and pin s.chainBackend to an orphan that the
// wallet never replaces.
if s.lwWallet.IsSome() {
w := s.lwWallet.UnsafeFromSome()
s.chainBackend = w.ChainBackend()
alreadyStarted = true
} else {
s.chainBackend = lwwallet.NewChainBackend(
lwwallet.NewEsploraClient(
s.cfg.Wallet.EsploraURL,
s.subLogger(lwwallet.Subsystem),
),
s.cfg.Wallet.PollInterval,
s.subLogger(lwwallet.Subsystem),
)
// Defer chain backend start to startLwwallet.
// Skip the Start() call below; mirrors the
// btcwallet path. The chain source actor
// registration in Run is also deferred via
// the same chainBackend == nil check.
return nil
}

case WalletTypeBtcwallet:
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ require (
github.com/lightninglabs/lndclient v0.21.0-rc1
github.com/lightninglabs/loop v0.33.0-beta
github.com/lightninglabs/neutrino v0.16.2
github.com/lightninglabs/neutrino/cache v1.1.3
github.com/lightninglabs/taproot-assets v0.7.0
github.com/lightninglabs/taproot-assets/taprpc v1.0.11
github.com/lightningnetwork/lnd v0.21.0-beta.rc1
Expand All @@ -39,6 +40,7 @@ require (
github.com/stretchr/testify v1.11.1
golang.org/x/crypto v0.47.0
golang.org/x/exp v0.0.0-20251113190631-e25ba8c21ef6
golang.org/x/sync v0.19.0
google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217
google.golang.org/grpc v1.79.3
google.golang.org/protobuf v1.36.11
Expand Down Expand Up @@ -124,7 +126,6 @@ require (
github.com/klauspost/compress v1.17.9 // indirect
github.com/lightninglabs/gozmq v0.0.0-20191113021534-d20a764486bf // indirect
github.com/lightninglabs/lightning-node-connect/hashmailrpc v1.0.4-0.20250610182311-2f1d46ef18b7 // indirect
github.com/lightninglabs/neutrino/cache v1.1.3 // indirect
github.com/lightningnetwork/lightning-onion v1.3.0 // indirect
github.com/lightningnetwork/lnd/actor v0.0.6 // indirect
github.com/lightningnetwork/lnd/cert v1.2.2 // indirect
Expand Down Expand Up @@ -202,7 +203,6 @@ require (
golang.org/x/mod v0.32.0 // indirect
golang.org/x/net v0.49.0 // indirect
golang.org/x/oauth2 v0.34.0 // indirect
golang.org/x/sync v0.19.0 // indirect
golang.org/x/sys v0.40.0 // indirect
golang.org/x/term v0.39.0 // indirect
golang.org/x/text v0.33.0 // indirect
Expand Down
Loading
Loading