@@ -181,8 +181,9 @@ type LightningClient interface {
181181
182182 // CloseChannel closes the channel provided.
183183 CloseChannel (ctx context.Context , channel * wire.OutPoint ,
184- force bool , confTarget int32 , deliveryAddr btcutil.Address ) (
185- chan CloseChannelUpdate , chan error , error )
184+ force bool , confTarget int32 , deliveryAddr btcutil.Address ,
185+ opts ... CloseChannelOption ) (chan CloseChannelUpdate ,
186+ chan error , error )
186187
187188 // UpdateChanPolicy updates the channel policy for the passed chanPoint.
188189 // If the chanPoint is nil, then the policy is applied for all existing
@@ -2873,7 +2874,7 @@ type PaymentRequest struct {
28732874 // Value is the value of the payment request in millisatoshis.
28742875 Value lnwire.MilliSatoshi
28752876
2876- /// Timestamp of the payment request.
2877+ // Timestamp of the payment request.
28772878 Timestamp time.Time
28782879
28792880 // Expiry is the time at which the payment request expires.
@@ -3085,6 +3086,33 @@ func (p *ChannelClosedUpdate) CloseTxid() chainhash.Hash {
30853086 return p .CloseTx
30863087}
30873088
3089+ // CloseChannelOption is a functional type for an option that modifies an
3090+ // CloseChannelRequest.
3091+ type CloseChannelOption func (r * lnrpc.CloseChannelRequest )
3092+
3093+ // SatPerVbyte is an option for setting the fee rate of an CloseChannelRequest.
3094+ func SatPerVbyte (satPerVbyte uint64 ) CloseChannelOption {
3095+ return func (r * lnrpc.CloseChannelRequest ) {
3096+ r .SatPerVbyte = satPerVbyte
3097+ }
3098+ }
3099+
3100+ // MaxFeePerVbyte is an option for setting the maximum fee rate a closer is
3101+ // willing to pay on an CloseChannelRequest.
3102+ func MaxFeePerVbyte (maxFeePerVbyte uint64 ) CloseChannelOption {
3103+ return func (r * lnrpc.CloseChannelRequest ) {
3104+ r .MaxFeePerVbyte = maxFeePerVbyte
3105+ }
3106+ }
3107+
3108+ // WithNoWait is an option for setting the NoWait flag on an
3109+ // CloseChannelRequest.
3110+ func WithNoWait () CloseChannelOption {
3111+ return func (r * lnrpc.CloseChannelRequest ) {
3112+ r .NoWait = true
3113+ }
3114+ }
3115+
30883116// CloseChannel closes the channel provided, returning a channel that will send
30893117// a stream of close updates, and an error channel which will receive errors if
30903118// the channel close stream fails. This function starts a goroutine to consume
@@ -3093,11 +3121,11 @@ func (p *ChannelClosedUpdate) CloseTxid() chainhash.Hash {
30933121// sending an EOF), we close the updates and error channel to signal that there
30943122// are no more updates to be sent. It takes an optional delivery address that
30953123// funds will be paid out to in the case where we cooperative close a channel
3096- // that *does not* have an upfront shutdown addresss set.
3124+ // that *does not* have an upfront shutdown address set.
30973125func (s * lightningClient ) CloseChannel (ctx context.Context ,
30983126 channel * wire.OutPoint , force bool , confTarget int32 ,
3099- deliveryAddr btcutil.Address ) ( chan CloseChannelUpdate , chan error ,
3100- error ) {
3127+ deliveryAddr btcutil.Address , opts ... CloseChannelOption ) (
3128+ chan CloseChannelUpdate , chan error , error ) {
31013129
31023130 var (
31033131 rpcCtx = s .adminMac .WithMacaroonAuth (ctx )
@@ -3108,7 +3136,7 @@ func (s *lightningClient) CloseChannel(ctx context.Context,
31083136 addrStr = deliveryAddr .String ()
31093137 }
31103138
3111- stream , err := s . client . CloseChannel ( rpcCtx , & lnrpc.CloseChannelRequest {
3139+ closeChannelReq := & lnrpc.CloseChannelRequest {
31123140 ChannelPoint : & lnrpc.ChannelPoint {
31133141 FundingTxid : & lnrpc.ChannelPoint_FundingTxidBytes {
31143142 FundingTxidBytes : channel .Hash [:],
@@ -3118,7 +3146,13 @@ func (s *lightningClient) CloseChannel(ctx context.Context,
31183146 TargetConf : confTarget ,
31193147 Force : force ,
31203148 DeliveryAddress : addrStr ,
3121- })
3149+ }
3150+
3151+ for _ , opt := range opts {
3152+ opt (closeChannelReq )
3153+ }
3154+
3155+ stream , err := s .client .CloseChannel (rpcCtx , closeChannelReq )
31223156 if err != nil {
31233157 return nil , nil , err
31243158 }
0 commit comments