@@ -181,8 +181,9 @@ type LightningClient interface {
181
181
182
182
// CloseChannel closes the channel provided.
183
183
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 )
186
187
187
188
// UpdateChanPolicy updates the channel policy for the passed chanPoint.
188
189
// If the chanPoint is nil, then the policy is applied for all existing
@@ -2873,7 +2874,7 @@ type PaymentRequest struct {
2873
2874
// Value is the value of the payment request in millisatoshis.
2874
2875
Value lnwire.MilliSatoshi
2875
2876
2876
- /// Timestamp of the payment request.
2877
+ // Timestamp of the payment request.
2877
2878
Timestamp time.Time
2878
2879
2879
2880
// Expiry is the time at which the payment request expires.
@@ -3085,6 +3086,33 @@ func (p *ChannelClosedUpdate) CloseTxid() chainhash.Hash {
3085
3086
return p .CloseTx
3086
3087
}
3087
3088
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
+
3088
3116
// CloseChannel closes the channel provided, returning a channel that will send
3089
3117
// a stream of close updates, and an error channel which will receive errors if
3090
3118
// the channel close stream fails. This function starts a goroutine to consume
@@ -3093,11 +3121,11 @@ func (p *ChannelClosedUpdate) CloseTxid() chainhash.Hash {
3093
3121
// sending an EOF), we close the updates and error channel to signal that there
3094
3122
// are no more updates to be sent. It takes an optional delivery address that
3095
3123
// 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.
3097
3125
func (s * lightningClient ) CloseChannel (ctx context.Context ,
3098
3126
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 ) {
3101
3129
3102
3130
var (
3103
3131
rpcCtx = s .adminMac .WithMacaroonAuth (ctx )
@@ -3108,7 +3136,7 @@ func (s *lightningClient) CloseChannel(ctx context.Context,
3108
3136
addrStr = deliveryAddr .String ()
3109
3137
}
3110
3138
3111
- stream , err := s . client . CloseChannel ( rpcCtx , & lnrpc.CloseChannelRequest {
3139
+ closeChannelReq := & lnrpc.CloseChannelRequest {
3112
3140
ChannelPoint : & lnrpc.ChannelPoint {
3113
3141
FundingTxid : & lnrpc.ChannelPoint_FundingTxidBytes {
3114
3142
FundingTxidBytes : channel .Hash [:],
@@ -3118,7 +3146,13 @@ func (s *lightningClient) CloseChannel(ctx context.Context,
3118
3146
TargetConf : confTarget ,
3119
3147
Force : force ,
3120
3148
DeliveryAddress : addrStr ,
3121
- })
3149
+ }
3150
+
3151
+ for _ , opt := range opts {
3152
+ opt (closeChannelReq )
3153
+ }
3154
+
3155
+ stream , err := s .client .CloseChannel (rpcCtx , closeChannelReq )
3122
3156
if err != nil {
3123
3157
return nil , nil , err
3124
3158
}
0 commit comments