@@ -134,7 +134,8 @@ type WalletKitClient interface {
134
134
// child-pays-for-parent (CPFP) scenario. If the given output has been
135
135
// used in a previous BumpFee call, then a transaction replacing the
136
136
// previous is broadcast, resulting in a replace-by-fee (RBF) scenario.
137
- BumpFee (context.Context , wire.OutPoint , chainfee.SatPerKWeight ) error
137
+ BumpFee (context.Context , wire.OutPoint , chainfee.SatPerKWeight ,
138
+ ... BumpFeeOption ) error
138
139
139
140
// ListAccounts retrieves all accounts belonging to the wallet by default.
140
141
// Optional name and addressType can be provided to filter through all the
@@ -737,28 +738,69 @@ func (m *walletKitClient) ListSweepsVerbose(ctx context.Context,
737
738
return result , nil
738
739
}
739
740
741
+ // BumpFeeOption customizes a BumpFee call.
742
+ type BumpFeeOption func (* walletrpc.BumpFeeRequest )
743
+
744
+ // WithImmediate is an option for enabling the immediate mode of BumpFee. The
745
+ // sweeper will sweep this input without waiting for the next batch.
746
+ func WithImmediate () BumpFeeOption {
747
+ return func (r * walletrpc.BumpFeeRequest ) {
748
+ r .Immediate = true
749
+ }
750
+ }
751
+
752
+ // WithTargetConf is an option for setting the target_conf of BumpFee. If set,
753
+ // the underlying fee estimator will use the target_conf to estimate the
754
+ // starting fee rate for the fee function. The value of feeRate passed to
755
+ // BumpFee will be ignored.
756
+ func WithTargetConf (targetConf uint32 ) BumpFeeOption {
757
+ return func (r * walletrpc.BumpFeeRequest ) {
758
+ r .TargetConf = targetConf
759
+
760
+ // We unset sat_per_vbyte, because if it is specified, it is
761
+ // used instead of target_conf.
762
+ r .SatPerVbyte = 0
763
+ }
764
+ }
765
+
766
+ // WithBudget is an option for setting the budget of BumpFee. It is the max
767
+ // amount in sats that can be used as the fees. Setting this value greater than
768
+ // the input's value may result in CPFP - one or more wallet utxos will be used
769
+ // to pay the fees specified by the budget. If not set, for new inputs, by
770
+ // default 50% of the input's value will be treated as the budget for fee
771
+ // bumping; for existing inputs, their current budgets will be retained.
772
+ func WithBudget (budget btcutil.Amount ) BumpFeeOption {
773
+ return func (r * walletrpc.BumpFeeRequest ) {
774
+ r .Budget = uint64 (budget )
775
+ }
776
+ }
777
+
740
778
// BumpFee attempts to bump the fee of a transaction by spending one of its
741
779
// outputs at the given fee rate. This essentially results in a
742
780
// child-pays-for-parent (CPFP) scenario. If the given output has been used in a
743
781
// previous BumpFee call, then a transaction replacing the previous is
744
782
// broadcast, resulting in a replace-by-fee (RBF) scenario.
745
783
func (m * walletKitClient ) BumpFee (ctx context.Context , op wire.OutPoint ,
746
- feeRate chainfee.SatPerKWeight ) error {
784
+ feeRate chainfee.SatPerKWeight , opts ... BumpFeeOption ) error {
747
785
748
786
rpcCtx , cancel := context .WithTimeout (ctx , m .timeout )
749
787
defer cancel ()
750
788
751
- _ , err := m .client .BumpFee (
752
- m .walletKitMac .WithMacaroonAuth (rpcCtx ),
753
- & walletrpc.BumpFeeRequest {
754
- Outpoint : & lnrpc.OutPoint {
755
- TxidBytes : op .Hash [:],
756
- OutputIndex : op .Index ,
757
- },
758
- SatPerVbyte : uint64 (feeRate .FeePerKVByte () / 1000 ),
759
- Immediate : false ,
789
+ req := & walletrpc.BumpFeeRequest {
790
+ Outpoint : & lnrpc.OutPoint {
791
+ TxidBytes : op .Hash [:],
792
+ OutputIndex : op .Index ,
760
793
},
761
- )
794
+ SatPerVbyte : uint64 (feeRate .FeePerKVByte () / 1000 ),
795
+ Immediate : false ,
796
+ }
797
+
798
+ for _ , opt := range opts {
799
+ opt (req )
800
+ }
801
+
802
+ _ , err := m .client .BumpFee (m .walletKitMac .WithMacaroonAuth (rpcCtx ), req )
803
+
762
804
return err
763
805
}
764
806
0 commit comments