@@ -81,6 +81,13 @@ func WithRemoteMaxHtlc(maxHtlc uint32) OpenChannelOption {
8181 }
8282}
8383
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+
8491// LightningClient exposes base lightning functionality.
8592type LightningClient interface {
8693 ServiceClient [lnrpc.LightningClient ]
@@ -214,7 +221,8 @@ type LightningClient interface {
214221 // upon success.
215222 SendCoins (ctx context.Context , addr btcutil.Address ,
216223 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 )
218226
219227 // ChannelBalance returns a summary of our channel balances.
220228 ChannelBalance (ctx context.Context ) (* ChannelBalance , error )
@@ -3152,7 +3160,14 @@ type CloseChannelOption func(r *lnrpc.CloseChannelRequest)
31523160// SatPerVbyte is an option for setting the fee rate of a CloseChannelRequest.
31533161func SatPerVbyte (satPerVbyte chainfee.SatPerVByte ) CloseChannelOption {
31543162 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 )
31563171 }
31573172}
31583173
@@ -3164,6 +3179,9 @@ func MaxFeePerVbyte(maxFeePerVbyte chainfee.SatPerVByte) CloseChannelOption {
31643179 }
31653180}
31663181
3182+ // TODO: MaxFeePerKw
3183+ // See https://github.com/lightningnetwork/lnd/pull/10067/files#r2302906743
3184+
31673185// WithNoWait is an option for setting the NoWait flag on an
31683186// CloseChannelRequest.
31693187func WithNoWait () CloseChannelOption {
@@ -3591,26 +3609,43 @@ func (s *lightningClient) Connect(ctx context.Context, peer route.Vertex,
35913609 return err
35923610}
35933611
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+
35943624// SendCoins sends the passed amount of (or all) coins to the passed address.
35953625// Either amount or sendAll must be specified, while confTarget, satsPerVByte
35963626// are optional and may be set to zero in which case automatic conf target and
35973627// fee will be used. Returns the tx id upon success.
35983628func (s * lightningClient ) SendCoins (ctx context.Context , addr btcutil.Address ,
35993629 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 ) {
36013632
36023633 rpcCtx , cancel := context .WithTimeout (ctx , s .timeout )
36033634 defer cancel ()
36043635
36053636 rpcCtx = s .adminMac .WithMacaroonAuth (rpcCtx )
36063637
36073638 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 )
36143649 }
36153650
36163651 resp , err := s .client .SendCoins (rpcCtx , req )
0 commit comments