Skip to content

Commit 07ead54

Browse files
committed
tap: remove check for support GetBlockHeader
With the `minimalCompatibleVersion` bumped to `0.18.4` we can assume support for the `GetBlockHeader` RPC call. This removes the check for support of the `GetBlockHeader` RPC call.
1 parent e4778c3 commit 07ead54

File tree

1 file changed

+5
-48
lines changed

1 file changed

+5
-48
lines changed

chain_bridge.go

Lines changed: 5 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"github.com/lightninglabs/taproot-assets/tapgarden"
1919
"github.com/lightningnetwork/lnd/chainntnfs"
2020
"github.com/lightningnetwork/lnd/funding"
21-
"github.com/lightningnetwork/lnd/lnrpc/verrpc"
2221
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
2322
"github.com/lightningnetwork/lnd/lnwire"
2423
"github.com/lightningnetwork/lnd/routing/route"
@@ -37,8 +36,6 @@ const (
3736
type LndRpcChainBridge struct {
3837
lnd *lndclient.LndServices
3938

40-
getBlockHeaderSupported *bool
41-
4239
blockTimestampCache *lru.Cache[uint32, cacheableTimestamp]
4340

4441
assetStore *tapdb.AssetStore
@@ -138,31 +135,6 @@ func (l *LndRpcChainBridge) GetBlockHash(ctx context.Context,
138135
return blockHash, nil
139136
}
140137

141-
// GetBlockHeaderSupported returns true if the chain backend supports the
142-
// `GetBlockHeader` RPC call.
143-
func (l *LndRpcChainBridge) GetBlockHeaderSupported(ctx context.Context) bool {
144-
// Check if we've already asserted the compatibility of the chain
145-
// backend.
146-
if l.getBlockHeaderSupported != nil {
147-
return *l.getBlockHeaderSupported
148-
}
149-
150-
// The ChainKit.GetBlockHeader() RPC call was added in lnd v0.17.1.
151-
getBlockHeaderMinimalVersion := &verrpc.Version{
152-
AppMajor: 0,
153-
AppMinor: 17,
154-
AppPatch: 1,
155-
}
156-
157-
getBlockHeaderUnsupported := lndclient.AssertVersionCompatible(
158-
l.lnd.Version, getBlockHeaderMinimalVersion,
159-
)
160-
getBlockHeaderSupported := getBlockHeaderUnsupported == nil
161-
162-
l.getBlockHeaderSupported = &getBlockHeaderSupported
163-
return *l.getBlockHeaderSupported
164-
}
165-
166138
// VerifyBlock returns an error if a block (with given header and height) is not
167139
// present on-chain. It also checks to ensure that block height corresponds to
168140
// the given block header.
@@ -194,12 +166,7 @@ func (l *LndRpcChainBridge) VerifyBlock(ctx context.Context,
194166
// Ensure that the block header corresponds to a block on-chain. Fetch
195167
// only the corresponding block header and not the entire block if
196168
// supported.
197-
if l.GetBlockHeaderSupported(ctx) {
198-
_, err = l.GetBlockHeader(ctx, header.BlockHash())
199-
return err
200-
}
201-
202-
_, err = l.GetBlock(ctx, header.BlockHash())
169+
_, err = l.GetBlockHeader(ctx, header.BlockHash())
203170
return err
204171
}
205172

@@ -233,20 +200,10 @@ func (l *LndRpcChainBridge) GetBlockTimestamp(ctx context.Context,
233200
return 0
234201
}
235202

236-
// Let's see if we can get the block header directly.
237-
var header *wire.BlockHeader
238-
if l.GetBlockHeaderSupported(ctx) {
239-
header, err = l.GetBlockHeader(ctx, hash)
240-
if err != nil {
241-
return 0
242-
}
243-
} else {
244-
block, err := l.lnd.ChainKit.GetBlock(ctx, hash)
245-
if err != nil {
246-
return 0
247-
}
248-
249-
header = &block.Header
203+
// Get block header.
204+
header, err := l.GetBlockHeader(ctx, hash)
205+
if err != nil {
206+
return 0
250207
}
251208

252209
ts := uint32(header.Timestamp.Unix())

0 commit comments

Comments
 (0)