Skip to content

Commit d9a633b

Browse files
authored
Merge pull request #1046 from starius/wait-for-height
loopd: fix premature block height receipt from LND
2 parents de969fd + 6d480cf commit d9a633b

File tree

19 files changed

+104
-45
lines changed

19 files changed

+104
-45
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ env:
2020

2121
# If you change this value, please change it in the following files as well:
2222
# /Dockerfile
23-
GO_VERSION: 1.24.6
23+
GO_VERSION: 1.24.10
2424

2525
jobs:
2626
########################

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM --platform=${BUILDPLATFORM} golang:1.24.6-alpine as builder
1+
FROM --platform=${BUILDPLATFORM} golang:1.24.10-alpine as builder
22

33
# Copy in the local repository to build from.
44
COPY . /go/src/github.com/lightningnetwork/loop

docs/release.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ for a release using the following commands:
6767
```bash
6868
$ go version
6969
go version go1.25.0 linux/amd64
70-
$ go install golang.org/dl/go1.24.6@latest
71-
$ go1.24.6 download
72-
Unpacking /home/user/sdk/go1.24.6/go1.24.6.linux-amd64.tar.gz ...
73-
Success. You may now run 'go1.24.6'
74-
$ go1.24.6 version
75-
go version go1.24.6 linux/amd64
76-
77-
$ GO_CMD=/home/user/go/bin/go1.24.6 ./release.sh v0.31.5
70+
$ go install golang.org/dl/go1.24.10@latest
71+
$ go1.24.10 download
72+
Unpacking /home/user/sdk/go1.24.10/go1.24.10.linux-amd64.tar.gz ...
73+
Success. You may now run 'go1.24.10'
74+
$ go1.24.10 version
75+
go version go1.24.10 linux/amd64
76+
77+
$ GO_CMD=/home/user/go/bin/go1.24.10 ./release.sh v0.31.5
7878
```
7979

8080
On MacOS, you will need to install GNU tar and GNU gzip, which can be done with

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ require (
2020
github.com/jessevdk/go-flags v1.4.0
2121
github.com/lib/pq v1.10.9
2222
github.com/lightninglabs/aperture v0.3.13-beta
23-
github.com/lightninglabs/lndclient v0.20.0-4
23+
github.com/lightninglabs/lndclient v0.20.0-6
2424
github.com/lightninglabs/loop/looprpc v1.0.7
2525
github.com/lightninglabs/loop/swapserverrpc v1.0.14
2626
github.com/lightninglabs/taproot-assets v0.7.0-rc1.0.20251014172227-e6ae082c0b4b
@@ -124,7 +124,7 @@ require (
124124
github.com/lightninglabs/neutrino v0.16.1 // indirect
125125
github.com/lightninglabs/neutrino/cache v1.1.2 // indirect
126126
github.com/lightningnetwork/lightning-onion v1.2.1-0.20240815225420-8b40adf04ab9 // indirect
127-
github.com/lightningnetwork/lnd/fn/v2 v2.0.8 // indirect
127+
github.com/lightningnetwork/lnd/fn/v2 v2.0.9 // indirect
128128
github.com/lightningnetwork/lnd/healthcheck v1.2.6 // indirect
129129
github.com/lightningnetwork/lnd/kvdb v1.4.16 // indirect
130130
github.com/lightningnetwork/lnd/sqldb v1.0.11 // indirect
@@ -225,4 +225,4 @@ replace gonum.org/v1/gonum => github.com/gonum/gonum v0.11.0
225225

226226
replace gonum.org/v1/plot => github.com/gonum/plot v0.10.1
227227

228-
go 1.24.6
228+
go 1.24.10

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,8 +1107,8 @@ github.com/lightninglabs/gozmq v0.0.0-20191113021534-d20a764486bf h1:HZKvJUHlcXI
11071107
github.com/lightninglabs/gozmq v0.0.0-20191113021534-d20a764486bf/go.mod h1:vxmQPeIQxPf6Jf9rM8R+B4rKBqLA2AjttNxkFBL2Plk=
11081108
github.com/lightninglabs/lightning-node-connect/hashmailrpc v1.0.3 h1:NuDp6Z+QNMSzZ/+RzWsjgAgQSr/REDxTiHmTczZxlXA=
11091109
github.com/lightninglabs/lightning-node-connect/hashmailrpc v1.0.3/go.mod h1:bDnEKRN1u13NFBuy/C+bFLhxA5bfd3clT25y76QY0AM=
1110-
github.com/lightninglabs/lndclient v0.20.0-4 h1:oSdoAtCcGJrlr6Pwi6jgzawBRpFFZKauyL+IzwV1iGc=
1111-
github.com/lightninglabs/lndclient v0.20.0-4/go.mod h1:VxIakyBmTIy4tmg2zqj45YrDkJi53PQLwW0lmFzRR6k=
1110+
github.com/lightninglabs/lndclient v0.20.0-6 h1:sh23eZkOpHxe39c4QRYwhsM7qbnJlS++dXVmcwr0BNk=
1111+
github.com/lightninglabs/lndclient v0.20.0-6/go.mod h1:gBtIFPGmC2xIspGIv/G5+HiPSGJsFD8uIow7Oke1HFI=
11121112
github.com/lightninglabs/migrate/v4 v4.18.2-9023d66a-fork-pr-2 h1:eFjp1dIB2BhhQp/THKrjLdlYuPugO9UU4kDqu91OX/Q=
11131113
github.com/lightninglabs/migrate/v4 v4.18.2-9023d66a-fork-pr-2/go.mod h1:99BKpIi6ruaaXRM1A77eqZ+FWPQ3cfRa+ZVy5bmWMaY=
11141114
github.com/lightninglabs/neutrino v0.16.1 h1:5Kz4ToxncEVkpKC6fwUjXKtFKJhuxlG3sBB3MdJTJjs=
@@ -1129,8 +1129,8 @@ github.com/lightningnetwork/lnd/cert v1.2.2 h1:71YK6hogeJtxSxw2teq3eGeuy4rHGKcFf
11291129
github.com/lightningnetwork/lnd/cert v1.2.2/go.mod h1:jQmFn/Ez4zhDgq2hnYSw8r35bqGVxViXhX6Cd7HXM6U=
11301130
github.com/lightningnetwork/lnd/clock v1.1.1 h1:OfR3/zcJd2RhH0RU+zX/77c0ZiOnIMsDIBjgjWdZgA0=
11311131
github.com/lightningnetwork/lnd/clock v1.1.1/go.mod h1:mGnAhPyjYZQJmebS7aevElXKTFDuO+uNFFfMXK1W8xQ=
1132-
github.com/lightningnetwork/lnd/fn/v2 v2.0.8 h1:r2SLz7gZYQPVc3IZhU82M66guz3Zk2oY+Rlj9QN5S3g=
1133-
github.com/lightningnetwork/lnd/fn/v2 v2.0.8/go.mod h1:TOzwrhjB/Azw1V7aa8t21ufcQmdsQOQMDtxVOQWNl8s=
1132+
github.com/lightningnetwork/lnd/fn/v2 v2.0.9 h1:ZytG4ltPac/sCyg1EJDn10RGzPIDJeyennUMRdOw7Y8=
1133+
github.com/lightningnetwork/lnd/fn/v2 v2.0.9/go.mod h1:aPUJHJ31S+Lgoo8I5SxDIjnmeCifqujaiTXKZqpav3w=
11341134
github.com/lightningnetwork/lnd/healthcheck v1.2.6 h1:1sWhqr93GdkWy4+6U7JxBfcyZIE78MhIHTJZfPx7qqI=
11351135
github.com/lightningnetwork/lnd/healthcheck v1.2.6/go.mod h1:Mu02um4CWY/zdTOvFje7WJgJcHyX2zq/FG3MhOAiGaQ=
11361136
github.com/lightningnetwork/lnd/kvdb v1.4.16 h1:9BZgWdDfjmHRHLS97cz39bVuBAqMc4/p3HX1xtUdbDI=

loopd/daemon.go

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,10 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
451451
return fmt.Errorf("failed to get current block height: %w", err)
452452
}
453453
blockHeight := getInfo.BlockHeight
454+
if blockHeight <= 0 {
455+
return fmt.Errorf("invalid block height reported by lnd: %d",
456+
blockHeight)
457+
}
454458

455459
// If we're running an asset client, we'll log something here.
456460
if d.assetClient != nil {
@@ -586,7 +590,13 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
586590
ChainParams: d.lnd.ChainParams,
587591
ChainNotifier: d.lnd.ChainNotifier,
588592
}
589-
staticAddressManager = address.NewManager(addrCfg, int32(blockHeight))
593+
staticAddressManager, err = address.NewManager(
594+
addrCfg, int32(blockHeight),
595+
)
596+
if err != nil {
597+
return fmt.Errorf("unable to create static address manager: %w",
598+
err)
599+
}
590600

591601
// Static address deposit manager setup.
592602
depositStore := deposit.NewSqlStore(baseDb)
@@ -617,7 +627,13 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
617627
Signer: d.lnd.Signer,
618628
Store: withdrawalStore,
619629
}
620-
withdrawalManager = withdraw.NewManager(withdrawalCfg, blockHeight)
630+
withdrawalManager, err = withdraw.NewManager(
631+
withdrawalCfg, blockHeight,
632+
)
633+
if err != nil {
634+
return fmt.Errorf("unable to create withdrawal manager: %w",
635+
err)
636+
}
621637

622638
// Static address loop-in manager setup.
623639
staticAddressLoopInStore := loopin.NewSqlStore(
@@ -645,7 +661,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
645661
return err
646662
}
647663

648-
staticLoopInManager = loopin.NewManager(&loopin.Config{
664+
staticLoopInManager, err = loopin.NewManager(&loopin.Config{
649665
Server: staticAddressClient,
650666
QuoteGetter: swapClient.Server,
651667
LndClient: d.lnd.Client,
@@ -663,6 +679,9 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
663679
MaxStaticAddrHtlcFeePercentage: d.cfg.MaxStaticAddrHtlcFeePercentage,
664680
MaxStaticAddrHtlcBackupFeePercentage: d.cfg.MaxStaticAddrHtlcBackupFeePercentage,
665681
}, blockHeight)
682+
if err != nil {
683+
return fmt.Errorf("unable to create loop-in manager: %w", err)
684+
}
666685

667686
var (
668687
reservationManager *reservation.Manager

loopd/run.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,17 @@ func NewListenerConfig(config *Config, rpcCfg RPCConfig) *ListenerCfg {
8888
defer cancel()
8989

9090
svcCfg := &lndclient.LndServicesConfig{
91-
LndAddress: cfg.Host,
92-
Network: network,
93-
CustomMacaroonPath: cfg.MacaroonPath,
94-
TLSPath: cfg.TLSPath,
95-
CheckVersion: LoopMinRequiredLndVersion,
96-
BlockUntilChainSynced: true,
97-
CallerCtx: callerCtx,
98-
BlockUntilUnlocked: true,
99-
RPCTimeout: cfg.RPCTimeout,
91+
LndAddress: cfg.Host,
92+
Network: network,
93+
CustomMacaroonPath: cfg.MacaroonPath,
94+
TLSPath: cfg.TLSPath,
95+
CheckVersion: LoopMinRequiredLndVersion,
96+
CallerCtx: callerCtx,
97+
RPCTimeout: cfg.RPCTimeout,
98+
99+
BlockUntilChainSynced: true,
100+
BlockUntilUnlocked: true,
101+
BlockUntilChainNotifier: true,
100102
}
101103

102104
// If a custom lnd connection is specified we use that

loopd/swapclient_server_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,12 +1006,13 @@ func TestListUnspentDeposits(t *testing.T) {
10061006
addrStore := &mockAddressStore{params: []*address.Parameters{addrParams}}
10071007

10081008
// Build an address manager using our mock lnd and fake address store.
1009-
addrMgr := address.NewManager(&address.ManagerConfig{
1009+
addrMgr, err := address.NewManager(&address.ManagerConfig{
10101010
Store: addrStore,
10111011
WalletKit: mock.WalletKit,
10121012
ChainParams: mock.ChainParams,
10131013
// ChainNotifier and AddressClient are not needed for this test.
1014-
}, 0)
1014+
}, 1)
1015+
require.NoError(t, err)
10151016

10161017
// Construct several UTXOs with different confirmation counts.
10171018
makeUtxo := func(idx uint32, confs int64) *lnwallet.Utxo {

looprpc/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/lightninglabs/loop/looprpc
22

3-
go 1.24.6
3+
go 1.24.10
44

55
require (
66
github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3

release.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.24.6
1+
FROM golang:1.24.10
22

33
RUN apt-get update && apt-get install -y --no-install-recommends \
44
git ca-certificates zip gpg && rm -rf /var/lib/apt/lists/*

0 commit comments

Comments
 (0)