@@ -81,6 +81,13 @@ func WithRemoteMaxHtlc(maxHtlc uint32) OpenChannelOption {
81
81
}
82
82
}
83
83
84
+ // WithOpenChannelFeerate specifies feerate in sats/kw for OpenChannel request.
85
+ func WithOpenChannelFeerate (satPerKw chainfee.SatPerKWeight ) OpenChannelOption {
86
+ return func (r * lnrpc.OpenChannelRequest ) {
87
+ r .SatPerKw = uint64 (satPerKw )
88
+ }
89
+ }
90
+
84
91
// LightningClient exposes base lightning functionality.
85
92
type LightningClient interface {
86
93
ServiceClient [lnrpc.LightningClient ]
@@ -214,7 +221,8 @@ type LightningClient interface {
214
221
// upon success.
215
222
SendCoins (ctx context.Context , addr btcutil.Address ,
216
223
amount btcutil.Amount , sendAll bool , confTarget int32 ,
217
- satsPerVByte chainfee.SatPerVByte , label string ) (string , error )
224
+ satsPerVByte chainfee.SatPerVByte , label string ,
225
+ opts ... SendCoinsOption ) (string , error )
218
226
219
227
// ChannelBalance returns a summary of our channel balances.
220
228
ChannelBalance (ctx context.Context ) (* ChannelBalance , error )
@@ -3152,7 +3160,14 @@ type CloseChannelOption func(r *lnrpc.CloseChannelRequest)
3152
3160
// SatPerVbyte is an option for setting the fee rate of a CloseChannelRequest.
3153
3161
func SatPerVbyte (satPerVbyte chainfee.SatPerVByte ) CloseChannelOption {
3154
3162
return func (r * lnrpc.CloseChannelRequest ) {
3155
- r .SatPerVbyte = uint64 (satPerVbyte )
3163
+ r .SatPerKw = uint64 (satPerVbyte .FeePerKWeight ())
3164
+ }
3165
+ }
3166
+
3167
+ // SatPerVbyte is an option for setting the fee rate of a CloseChannelRequest.
3168
+ func SatPerKw (satPerKw chainfee.SatPerKWeight ) CloseChannelOption {
3169
+ return func (r * lnrpc.CloseChannelRequest ) {
3170
+ r .SatPerKw = uint64 (satPerKw )
3156
3171
}
3157
3172
}
3158
3173
@@ -3164,6 +3179,9 @@ func MaxFeePerVbyte(maxFeePerVbyte chainfee.SatPerVByte) CloseChannelOption {
3164
3179
}
3165
3180
}
3166
3181
3182
+ // TODO: MaxFeePerKw
3183
+ // See https://github.com/lightningnetwork/lnd/pull/10067/files#r2302906743
3184
+
3167
3185
// WithNoWait is an option for setting the NoWait flag on an
3168
3186
// CloseChannelRequest.
3169
3187
func WithNoWait () CloseChannelOption {
@@ -3591,26 +3609,43 @@ func (s *lightningClient) Connect(ctx context.Context, peer route.Vertex,
3591
3609
return err
3592
3610
}
3593
3611
3612
+ // SendCoinsOption is an option used in SendCoins call.
3613
+ type SendCoinsOption func (* lnrpc.SendCoinsRequest )
3614
+
3615
+ // WithSendCoinsFeerate specifies feerate in sats/kw for SendCoins request.
3616
+ // To use it pass satsPerVByte=0 and WithSendCoinsFeerate(desired_feerate) to
3617
+ // SendCoins.
3618
+ func WithSendCoinsFeerate (satPerKw chainfee.SatPerKWeight ) SendCoinsOption {
3619
+ return func (req * lnrpc.SendCoinsRequest ) {
3620
+ req .SatPerKw = uint64 (satPerKw )
3621
+ }
3622
+ }
3623
+
3594
3624
// SendCoins sends the passed amount of (or all) coins to the passed address.
3595
3625
// Either amount or sendAll must be specified, while confTarget, satsPerVByte
3596
3626
// are optional and may be set to zero in which case automatic conf target and
3597
3627
// fee will be used. Returns the tx id upon success.
3598
3628
func (s * lightningClient ) SendCoins (ctx context.Context , addr btcutil.Address ,
3599
3629
amount btcutil.Amount , sendAll bool , confTarget int32 ,
3600
- satsPerVByte chainfee.SatPerVByte , label string ) (string , error ) {
3630
+ satsPerVByte chainfee.SatPerVByte , label string ,
3631
+ opts ... SendCoinsOption ) (string , error ) {
3601
3632
3602
3633
rpcCtx , cancel := context .WithTimeout (ctx , s .timeout )
3603
3634
defer cancel ()
3604
3635
3605
3636
rpcCtx = s .adminMac .WithMacaroonAuth (rpcCtx )
3606
3637
3607
3638
req := & lnrpc.SendCoinsRequest {
3608
- Addr : addr .String (),
3609
- Amount : int64 (amount ),
3610
- TargetConf : confTarget ,
3611
- SatPerVbyte : uint64 (satsPerVByte ),
3612
- SendAll : sendAll ,
3613
- Label : label ,
3639
+ Addr : addr .String (),
3640
+ Amount : int64 (amount ),
3641
+ TargetConf : confTarget ,
3642
+ SatPerKw : uint64 (satsPerVByte .FeePerKWeight ()),
3643
+ SendAll : sendAll ,
3644
+ Label : label ,
3645
+ }
3646
+
3647
+ for _ , opt := range opts {
3648
+ opt (req )
3614
3649
}
3615
3650
3616
3651
resp , err := s .client .SendCoins (rpcCtx , req )
0 commit comments