Skip to content

Commit cc6a0fa

Browse files
committed
bumpfee: check LND>=0.18.5 if target_conf is used
The conf-target only reflects this behaviour for the 0.18.5 release, before the conf target had a different meaning: lightningnetwork/lnd#9470 This commit can be undone after minimalCompatibleVersion is bumbed to 0.18.5.
1 parent 2974fa7 commit cc6a0fa

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

lnd_services.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ func NewLndServices(cfg *LndServicesConfig) (*GrpcLndServices, error) {
372372
)
373373
walletKitClient := newWalletKitClient(
374374
conn, macaroons[WalletKitServiceMac], timeout, chainParams,
375+
version,
375376
)
376377
invoicesClient := newInvoicesClient(
377378
conn, macaroons[InvoiceServiceMac], timeout,

walletkit_client.go

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"github.com/lightningnetwork/lnd/keychain"
2121
"github.com/lightningnetwork/lnd/lnrpc"
2222
"github.com/lightningnetwork/lnd/lnrpc/signrpc"
23+
"github.com/lightningnetwork/lnd/lnrpc/verrpc"
2324
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
2425
"github.com/lightningnetwork/lnd/lnwallet"
2526
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
@@ -219,6 +220,7 @@ type walletKitClient struct {
219220
walletKitMac serializedMacaroon
220221
timeout time.Duration
221222
params *chaincfg.Params
223+
version *verrpc.Version
222224
}
223225

224226
// A compile time check to ensure that walletKitClient implements the
@@ -227,13 +229,15 @@ var _ WalletKitClient = (*walletKitClient)(nil)
227229

228230
func newWalletKitClient(conn grpc.ClientConnInterface,
229231
walletKitMac serializedMacaroon, timeout time.Duration,
230-
chainParams *chaincfg.Params) *walletKitClient {
232+
chainParams *chaincfg.Params,
233+
version *verrpc.Version) *walletKitClient {
231234

232235
return &walletKitClient{
233236
client: walletrpc.NewWalletKitClient(conn),
234237
walletKitMac: walletKitMac,
235238
timeout: timeout,
236239
params: chainParams,
240+
version: version,
237241
}
238242
}
239243

@@ -775,6 +779,15 @@ func WithBudget(budget btcutil.Amount) BumpFeeOption {
775779
}
776780
}
777781

782+
// targetConfFixed is the minimum version in which bug #9470 is merged and new
783+
// meaning of TargetConf is enabled. In versions prior to this version the field
784+
// had a different meaning.
785+
var targetConfFixed = &verrpc.Version{
786+
AppMajor: 0,
787+
AppMinor: 18,
788+
AppPatch: 5,
789+
}
790+
778791
// BumpFee attempts to bump the fee of a transaction by spending one of its
779792
// outputs at the given fee rate. This essentially results in a
780793
// child-pays-for-parent (CPFP) scenario. If the given output has been used in a
@@ -799,6 +812,20 @@ func (m *walletKitClient) BumpFee(ctx context.Context, op wire.OutPoint,
799812
opt(req)
800813
}
801814

815+
// Make sure that the version of LND is at least targetConfFixed,
816+
// because before it the meaning of TargetConf was different. See
817+
// https://github.com/lightningnetwork/lnd/pull/9470
818+
// TODO(Boris): remove this check when minimalCompatibleVersion
819+
// is bumped to targetConfFixed.
820+
if req.TargetConf != 0 {
821+
err := AssertVersionCompatible(m.version, targetConfFixed)
822+
if err != nil {
823+
return fmt.Errorf("can't use target_conf before "+
824+
"version %s, current LND version is %s, "+
825+
"see #9470", targetConfFixed, m.version)
826+
}
827+
}
828+
802829
_, err := m.client.BumpFee(m.walletKitMac.WithMacaroonAuth(rpcCtx), req)
803830

804831
return err

0 commit comments

Comments
 (0)