Skip to content

Commit

Permalink
bumpfee: check LND>=0.18.5 if target_conf is used
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
starius committed Feb 15, 2025
1 parent 2974fa7 commit cc6a0fa
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions lnd_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ func NewLndServices(cfg *LndServicesConfig) (*GrpcLndServices, error) {
)
walletKitClient := newWalletKitClient(
conn, macaroons[WalletKitServiceMac], timeout, chainParams,
version,
)
invoicesClient := newInvoicesClient(
conn, macaroons[InvoiceServiceMac], timeout,
Expand Down
29 changes: 28 additions & 1 deletion walletkit_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lnrpc/signrpc"
"github.com/lightningnetwork/lnd/lnrpc/verrpc"
"github.com/lightningnetwork/lnd/lnrpc/walletrpc"
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
Expand Down Expand Up @@ -219,6 +220,7 @@ type walletKitClient struct {
walletKitMac serializedMacaroon
timeout time.Duration
params *chaincfg.Params
version *verrpc.Version
}

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

func newWalletKitClient(conn grpc.ClientConnInterface,
walletKitMac serializedMacaroon, timeout time.Duration,
chainParams *chaincfg.Params) *walletKitClient {
chainParams *chaincfg.Params,
version *verrpc.Version) *walletKitClient {

return &walletKitClient{
client: walletrpc.NewWalletKitClient(conn),
walletKitMac: walletKitMac,
timeout: timeout,
params: chainParams,
version: version,
}
}

Expand Down Expand Up @@ -775,6 +779,15 @@ func WithBudget(budget btcutil.Amount) BumpFeeOption {
}
}

// targetConfFixed is the minimum version in which bug #9470 is merged and new
// meaning of TargetConf is enabled. In versions prior to this version the field
// had a different meaning.
var targetConfFixed = &verrpc.Version{
AppMajor: 0,
AppMinor: 18,
AppPatch: 5,
}

// BumpFee attempts to bump the fee of a transaction by spending one of its
// outputs at the given fee rate. This essentially results in a
// child-pays-for-parent (CPFP) scenario. If the given output has been used in a
Expand All @@ -799,6 +812,20 @@ func (m *walletKitClient) BumpFee(ctx context.Context, op wire.OutPoint,
opt(req)
}

// Make sure that the version of LND is at least targetConfFixed,
// because before it the meaning of TargetConf was different. See
// https://github.com/lightningnetwork/lnd/pull/9470
// TODO(Boris): remove this check when minimalCompatibleVersion
// is bumped to targetConfFixed.
if req.TargetConf != 0 {
err := AssertVersionCompatible(m.version, targetConfFixed)
if err != nil {
return fmt.Errorf("can't use target_conf before "+
"version %s, current LND version is %s, "+
"see #9470", targetConfFixed, m.version)
}
}

_, err := m.client.BumpFee(m.walletKitMac.WithMacaroonAuth(rpcCtx), req)

return err
Expand Down

0 comments on commit cc6a0fa

Please sign in to comment.