@@ -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,18 +3157,35 @@ 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
31593176// MaxFeePerVbyte is an option for setting the maximum fee rate a closer is
31603177// willing to pay on a CloseChannelRequest.
31613178func MaxFeePerVbyte (maxFeePerVbyte chainfee.SatPerVByte ) CloseChannelOption {
31623179 return func (r * lnrpc.CloseChannelRequest ) {
3163- r .MaxFeePerVbyte = uint64 (maxFeePerVbyte )
3180+ r .MaxFeePerKw = uint64 (maxFeePerVbyte .FeePerKWeight ())
3181+ }
3182+ }
3183+
3184+ // MaxFeePerKw is an option for setting the maximum fee rate a closer is
3185+ // willing to pay on a CloseChannelRequest.
3186+ func MaxFeePerKw (maxFeePerKw chainfee.SatPerKWeight ) CloseChannelOption {
3187+ return func (r * lnrpc.CloseChannelRequest ) {
3188+ r .MaxFeePerKw = uint64 (maxFeePerKw )
31643189 }
31653190}
31663191
@@ -3591,26 +3616,43 @@ func (s *lightningClient) Connect(ctx context.Context, peer route.Vertex,
35913616 return err
35923617}
35933618
3619+ // SendCoinsOption is an option used in SendCoins call.
3620+ type SendCoinsOption func (* lnrpc.SendCoinsRequest )
3621+
3622+ // WithSendCoinsFeerate specifies feerate in sats/kw for SendCoins request.
3623+ // To use it pass satsPerVByte=0 and WithSendCoinsFeerate(desired_feerate) to
3624+ // SendCoins.
3625+ func WithSendCoinsFeerate (satPerKw chainfee.SatPerKWeight ) SendCoinsOption {
3626+ return func (req * lnrpc.SendCoinsRequest ) {
3627+ req .SatPerKw = uint64 (satPerKw )
3628+ }
3629+ }
3630+
35943631// SendCoins sends the passed amount of (or all) coins to the passed address.
35953632// Either amount or sendAll must be specified, while confTarget, satsPerVByte
35963633// are optional and may be set to zero in which case automatic conf target and
35973634// fee will be used. Returns the tx id upon success.
35983635func (s * lightningClient ) SendCoins (ctx context.Context , addr btcutil.Address ,
35993636 amount btcutil.Amount , sendAll bool , confTarget int32 ,
3600- satsPerVByte chainfee.SatPerVByte , label string ) (string , error ) {
3637+ satsPerVByte chainfee.SatPerVByte , label string ,
3638+ opts ... SendCoinsOption ) (string , error ) {
36013639
36023640 rpcCtx , cancel := context .WithTimeout (ctx , s .timeout )
36033641 defer cancel ()
36043642
36053643 rpcCtx = s .adminMac .WithMacaroonAuth (rpcCtx )
36063644
36073645 req := & lnrpc.SendCoinsRequest {
3608- Addr : addr .String (),
3609- Amount : int64 (amount ),
3610- TargetConf : confTarget ,
3611- SatPerVbyte : uint64 (satsPerVByte ),
3612- SendAll : sendAll ,
3613- Label : label ,
3646+ Addr : addr .String (),
3647+ Amount : int64 (amount ),
3648+ TargetConf : confTarget ,
3649+ SatPerKw : uint64 (satsPerVByte .FeePerKWeight ()),
3650+ SendAll : sendAll ,
3651+ Label : label ,
3652+ }
3653+
3654+ for _ , opt := range opts {
3655+ opt (req )
36143656 }
36153657
36163658 resp , err := s .client .SendCoins (rpcCtx , req )
0 commit comments