@@ -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 )
@@ -3149,10 +3157,19 @@ func (p *ChannelClosedUpdate) CloseTxid() chainhash.Hash {
3149
3157
// CloseChannelRequest.
3150
3158
type CloseChannelOption func (r * lnrpc.CloseChannelRequest )
3151
3159
3152
- // SatPerVbyte is an option for setting the fee rate of a CloseChannelRequest.
3160
+ // SatPerVbyte is an option for setting the fee rate of a CloseChannelRequest
3161
+ // specified in sats/vbyte.
3153
3162
func SatPerVbyte (satPerVbyte chainfee.SatPerVByte ) CloseChannelOption {
3154
3163
return func (r * lnrpc.CloseChannelRequest ) {
3155
- r .SatPerVbyte = uint64 (satPerVbyte )
3164
+ r .SatPerKw = uint64 (satPerVbyte .FeePerKWeight ())
3165
+ }
3166
+ }
3167
+
3168
+ // SatPerKw is an option for setting the fee rate of a CloseChannelRequest
3169
+ // specified in sats/kw.
3170
+ func SatPerKw (satPerKw chainfee.SatPerKWeight ) CloseChannelOption {
3171
+ return func (r * lnrpc.CloseChannelRequest ) {
3172
+ r .SatPerKw = uint64 (satPerKw )
3156
3173
}
3157
3174
}
3158
3175
@@ -3164,6 +3181,9 @@ func MaxFeePerVbyte(maxFeePerVbyte chainfee.SatPerVByte) CloseChannelOption {
3164
3181
}
3165
3182
}
3166
3183
3184
+ // TODO: MaxFeePerKw
3185
+ // See https://github.com/lightningnetwork/lnd/pull/10067/files#r2302906743
3186
+
3167
3187
// WithNoWait is an option for setting the NoWait flag on an
3168
3188
// CloseChannelRequest.
3169
3189
func WithNoWait () CloseChannelOption {
@@ -3591,26 +3611,43 @@ func (s *lightningClient) Connect(ctx context.Context, peer route.Vertex,
3591
3611
return err
3592
3612
}
3593
3613
3614
+ // SendCoinsOption is an option used in SendCoins call.
3615
+ type SendCoinsOption func (* lnrpc.SendCoinsRequest )
3616
+
3617
+ // WithSendCoinsFeerate specifies feerate in sats/kw for SendCoins request.
3618
+ // To use it pass satsPerVByte=0 and WithSendCoinsFeerate(desired_feerate) to
3619
+ // SendCoins.
3620
+ func WithSendCoinsFeerate (satPerKw chainfee.SatPerKWeight ) SendCoinsOption {
3621
+ return func (req * lnrpc.SendCoinsRequest ) {
3622
+ req .SatPerKw = uint64 (satPerKw )
3623
+ }
3624
+ }
3625
+
3594
3626
// SendCoins sends the passed amount of (or all) coins to the passed address.
3595
3627
// Either amount or sendAll must be specified, while confTarget, satsPerVByte
3596
3628
// are optional and may be set to zero in which case automatic conf target and
3597
3629
// fee will be used. Returns the tx id upon success.
3598
3630
func (s * lightningClient ) SendCoins (ctx context.Context , addr btcutil.Address ,
3599
3631
amount btcutil.Amount , sendAll bool , confTarget int32 ,
3600
- satsPerVByte chainfee.SatPerVByte , label string ) (string , error ) {
3632
+ satsPerVByte chainfee.SatPerVByte , label string ,
3633
+ opts ... SendCoinsOption ) (string , error ) {
3601
3634
3602
3635
rpcCtx , cancel := context .WithTimeout (ctx , s .timeout )
3603
3636
defer cancel ()
3604
3637
3605
3638
rpcCtx = s .adminMac .WithMacaroonAuth (rpcCtx )
3606
3639
3607
3640
req := & lnrpc.SendCoinsRequest {
3608
- Addr : addr .String (),
3609
- Amount : int64 (amount ),
3610
- TargetConf : confTarget ,
3611
- SatPerVbyte : uint64 (satsPerVByte ),
3612
- SendAll : sendAll ,
3613
- Label : label ,
3641
+ Addr : addr .String (),
3642
+ Amount : int64 (amount ),
3643
+ TargetConf : confTarget ,
3644
+ SatPerKw : uint64 (satsPerVByte .FeePerKWeight ()),
3645
+ SendAll : sendAll ,
3646
+ Label : label ,
3647
+ }
3648
+
3649
+ for _ , opt := range opts {
3650
+ opt (req )
3614
3651
}
3615
3652
3616
3653
resp , err := s .client .SendCoins (rpcCtx , req )
0 commit comments