@@ -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
228230func 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