@@ -118,7 +118,8 @@ type LightningClient interface {
118
118
opts ... ListTransactionsOption ) ([]Transaction , error )
119
119
120
120
// ListChannels retrieves all channels of the backing lnd node.
121
- ListChannels (ctx context.Context , activeOnly , publicOnly bool ) ([]ChannelInfo , error )
121
+ ListChannels (ctx context.Context , activeOnly , publicOnly bool ) (
122
+ []ChannelInfo , error )
122
123
123
124
// PendingChannels returns a list of lnd's pending channels.
124
125
PendingChannels (ctx context.Context ) (* PendingChannels , error )
@@ -128,8 +129,8 @@ type LightningClient interface {
128
129
129
130
// ForwardingHistory makes a paginated call to our forwarding history
130
131
// endpoint.
131
- ForwardingHistory (ctx context.Context ,
132
- req ForwardingHistoryRequest ) ( * ForwardingHistoryResponse , error )
132
+ ForwardingHistory (ctx context.Context , req ForwardingHistoryRequest ) (
133
+ * ForwardingHistoryResponse , error )
133
134
134
135
// ListInvoices makes a paginated call to our list invoices endpoint.
135
136
ListInvoices (ctx context.Context , req ListInvoicesRequest ) (
@@ -148,9 +149,8 @@ type LightningClient interface {
148
149
// chanbackup.Multi payload.
149
150
ChannelBackups (ctx context.Context ) ([]byte , error )
150
151
151
- // SubscribeChannelBackups allows a client to subscribe to the
152
- // most up to date information concerning the state of all channel
153
- // backups.
152
+ // SubscribeChannelBackups allows a client to subscribe to the most
153
+ // up-to-date information concerning the state of all channel backups.
154
154
SubscribeChannelBackups (ctx context.Context ) (
155
155
<- chan lnrpc.ChanBackupSnapshot , <- chan error , error )
156
156
@@ -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
@@ -221,7 +222,8 @@ type LightningClient interface {
221
222
includeChannels bool ) (* NodeInfo , error )
222
223
223
224
// DescribeGraph returns our view of the graph.
224
- DescribeGraph (ctx context.Context , includeUnannounced bool ) (* Graph , error )
225
+ DescribeGraph (ctx context.Context , includeUnannounced bool ) (* Graph ,
226
+ error )
225
227
226
228
// SubscribeGraph allows a client to subscribe to gaph topology updates.
227
229
SubscribeGraph (ctx context.Context ) (<- chan * GraphTopologyUpdate ,
@@ -293,8 +295,7 @@ type LightningClient interface {
293
295
// The returned signature string is zbase32 encoded and pubkey
294
296
// recoverable, meaning that only the message digest and signature
295
297
// are needed for verification.
296
- SignMessage (ctx context.Context , data []byte ) (string ,
297
- error )
298
+ SignMessage (ctx context.Context , data []byte ) (string , error )
298
299
299
300
// VerifyMessage verifies a signature over a msg. The signature must
300
301
// be zbase32 encoded and signed by an active node in the resident
@@ -359,9 +360,9 @@ type ChannelInfo struct {
359
360
// Active indicates whether the channel is active.
360
361
Active bool
361
362
362
- // ChannelID holds the unique channel ID for the channel. The first 3 bytes
363
- // are the block height, the next 3 the index within the block, and the last
364
- // 2 bytes are the /output index for the channel.
363
+ // ChannelID holds the unique channel ID for the channel. The first 3
364
+ // bytes are the block height, the next 3 the index within the block,
365
+ // and the last 2 bytes are the /output index for the channel.
365
366
ChannelID uint64
366
367
367
368
// PubKeyBytes is the raw bytes of the public key of the remote node.
@@ -765,7 +766,7 @@ const (
765
766
ForceCloseAnchorStateLost = ForceCloseAnchorState (lnrpc .PendingChannelsResponse_ForceClosedChannel_LOST )
766
767
)
767
768
768
- // String provides the string represenetation of a close initiator.
769
+ // String provides the string representation of a close initiator.
769
770
func (c Initiator ) String () string {
770
771
switch c {
771
772
case InitiatorUnrecorded :
@@ -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 a
3090
+ // CloseChannelRequest.
3091
+ type CloseChannelOption func (r * lnrpc.CloseChannelRequest )
3092
+
3093
+ // SatPerVbyte is an option for setting the fee rate of a CloseChannelRequest.
3094
+ func SatPerVbyte (satPerVbyte chainfee.SatPerVByte ) CloseChannelOption {
3095
+ return func (r * lnrpc.CloseChannelRequest ) {
3096
+ r .SatPerVbyte = uint64 (satPerVbyte )
3097
+ }
3098
+ }
3099
+
3100
+ // MaxFeePerVbyte is an option for setting the maximum fee rate a closer is
3101
+ // willing to pay on a CloseChannelRequest.
3102
+ func MaxFeePerVbyte (maxFeePerVbyte chainfee.SatPerVByte ) CloseChannelOption {
3103
+ return func (r * lnrpc.CloseChannelRequest ) {
3104
+ r .MaxFeePerVbyte = uint64 (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
}
@@ -3364,7 +3398,7 @@ type ChannelEdge struct {
3364
3398
Node2Policy * RoutingPolicy
3365
3399
}
3366
3400
3367
- // getRoutingPolicy converts an lnrpc.RoutingPolicy to RoutingPolicy.
3401
+ // getRoutingPolicy converts a lnrpc.RoutingPolicy to RoutingPolicy.
3368
3402
func getRoutingPolicy (policy * lnrpc.RoutingPolicy ) * RoutingPolicy {
3369
3403
if policy == nil {
3370
3404
return nil
@@ -3678,7 +3712,7 @@ func (s *lightningClient) SubscribeGraph(ctx context.Context) (
3678
3712
return updates , errChan , nil
3679
3713
}
3680
3714
3681
- // getGraphTopologyUpdate converts an lnrpc.GraphTopologyUpdate to the higher
3715
+ // getGraphTopologyUpdate converts a lnrpc.GraphTopologyUpdate to the higher
3682
3716
// level GraphTopologyUpdate.
3683
3717
func getGraphTopologyUpdate (update * lnrpc.GraphTopologyUpdate ) (
3684
3718
* GraphTopologyUpdate , error ) {
@@ -3814,19 +3848,20 @@ func (s *lightningClient) NetworkInfo(ctx context.Context) (*NetworkInfo,
3814
3848
// to start streaming.
3815
3849
type InvoiceSubscriptionRequest struct {
3816
3850
// If specified (non-zero), then we'll first start by sending out
3817
- // notifications for all added indexes with an add_index greater than this
3818
- // value. This allows callers to catch up on any events they missed while they
3819
- // weren't connected to the streaming RPC.
3851
+ // notifications for all added indexes with an add_index greater than
3852
+ // this value. This allows callers to catch up on any events they missed
3853
+ // while they weren't connected to the streaming RPC.
3820
3854
AddIndex uint64
3821
3855
3822
3856
// If specified (non-zero), then we'll first start by sending out
3823
- // notifications for all settled indexes with an settle_index greater than
3824
- // this value. This allows callers to catch up on any events they missed while
3825
- // they weren't connected to the streaming RPC.
3857
+ // notifications for all settled indexes with a settle_index greater
3858
+ // than this value. This allows callers to catch up on any events they
3859
+ // missed while they weren't connected to the streaming RPC.
3826
3860
SettleIndex uint64
3827
3861
}
3828
3862
3829
- // SubscribeInvoices subscribes a client to updates of newly added/settled invoices.
3863
+ // SubscribeInvoices subscribes a client to updates of newly added/settled
3864
+ // invoices.
3830
3865
func (s * lightningClient ) SubscribeInvoices (ctx context.Context ,
3831
3866
req InvoiceSubscriptionRequest ) (<- chan * Invoice , <- chan error , error ) {
3832
3867
0 commit comments