Skip to content

Commit 53c3fb7

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 6c7630d commit 53c3fb7

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-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: 27 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

@@ -771,6 +775,15 @@ func WithBudget(budget btcutil.Amount) BumpFeeOption {
771775
}
772776
}
773777

778+
// targetConfFixed is the minimum version in which bug #9470 is merged and new
779+
// meaning of TargetConf is enabled. In versions prior to this version the field
780+
// had a different meaning.
781+
var targetConfFixed = &verrpc.Version{
782+
AppMajor: 0,
783+
AppMinor: 18,
784+
AppPatch: 5,
785+
}
786+
774787
// BumpFee attempts to bump the fee of a transaction by spending one of its
775788
// outputs at the given fee rate. This essentially results in a
776789
// child-pays-for-parent (CPFP) scenario. If the given output has been used in a
@@ -800,6 +813,19 @@ func (m *walletKitClient) BumpFee(ctx context.Context, op wire.OutPoint,
800813
return fmt.Errorf("can't use target_conf if feeRate != 0")
801814
}
802815

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

805831
return err

0 commit comments

Comments
 (0)