@@ -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 )
@@ -3149,10 +3157,19 @@ func (p *ChannelClosedUpdate) CloseTxid() chainhash.Hash {
31493157// CloseChannelRequest.
31503158type CloseChannelOption func (r * lnrpc.CloseChannelRequest )
31513159
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.
31533162func SatPerVbyte (satPerVbyte chainfee.SatPerVByte ) CloseChannelOption {
31543163 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 )
31563173 }
31573174}
31583175
@@ -3164,6 +3181,9 @@ func MaxFeePerVbyte(maxFeePerVbyte chainfee.SatPerVByte) CloseChannelOption {
31643181 }
31653182}
31663183
3184+ // TODO: MaxFeePerKw
3185+ // See https://github.com/lightningnetwork/lnd/pull/10067/files#r2302906743
3186+
31673187// WithNoWait is an option for setting the NoWait flag on an
31683188// CloseChannelRequest.
31693189func WithNoWait () CloseChannelOption {
@@ -3591,26 +3611,43 @@ func (s *lightningClient) Connect(ctx context.Context, peer route.Vertex,
35913611 return err
35923612}
35933613
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+
35943626// SendCoins sends the passed amount of (or all) coins to the passed address.
35953627// Either amount or sendAll must be specified, while confTarget, satsPerVByte
35963628// are optional and may be set to zero in which case automatic conf target and
35973629// fee will be used. Returns the tx id upon success.
35983630func (s * lightningClient ) SendCoins (ctx context.Context , addr btcutil.Address ,
35993631 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 ) {
36013634
36023635 rpcCtx , cancel := context .WithTimeout (ctx , s .timeout )
36033636 defer cancel ()
36043637
36053638 rpcCtx = s .adminMac .WithMacaroonAuth (rpcCtx )
36063639
36073640 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 )
36143651 }
36153652
36163653 resp , err := s .client .SendCoins (rpcCtx , req )
0 commit comments