@@ -118,7 +118,8 @@ type LightningClient interface {
118118 opts ... ListTransactionsOption ) ([]Transaction , error )
119119
120120 // 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 )
122123
123124 // PendingChannels returns a list of lnd's pending channels.
124125 PendingChannels (ctx context.Context ) (* PendingChannels , error )
@@ -128,8 +129,8 @@ type LightningClient interface {
128129
129130 // ForwardingHistory makes a paginated call to our forwarding history
130131 // endpoint.
131- ForwardingHistory (ctx context.Context ,
132- req ForwardingHistoryRequest ) ( * ForwardingHistoryResponse , error )
132+ ForwardingHistory (ctx context.Context , req ForwardingHistoryRequest ) (
133+ * ForwardingHistoryResponse , error )
133134
134135 // ListInvoices makes a paginated call to our list invoices endpoint.
135136 ListInvoices (ctx context.Context , req ListInvoicesRequest ) (
@@ -148,9 +149,8 @@ type LightningClient interface {
148149 // chanbackup.Multi payload.
149150 ChannelBackups (ctx context.Context ) ([]byte , error )
150151
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.
154154 SubscribeChannelBackups (ctx context.Context ) (
155155 <- chan lnrpc.ChanBackupSnapshot , <- chan error , error )
156156
@@ -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
@@ -221,7 +222,8 @@ type LightningClient interface {
221222 includeChannels bool ) (* NodeInfo , error )
222223
223224 // 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 )
225227
226228 // SubscribeGraph allows a client to subscribe to gaph topology updates.
227229 SubscribeGraph (ctx context.Context ) (<- chan * GraphTopologyUpdate ,
@@ -293,8 +295,7 @@ type LightningClient interface {
293295 // The returned signature string is zbase32 encoded and pubkey
294296 // recoverable, meaning that only the message digest and signature
295297 // are needed for verification.
296- SignMessage (ctx context.Context , data []byte ) (string ,
297- error )
298+ SignMessage (ctx context.Context , data []byte ) (string , error )
298299
299300 // VerifyMessage verifies a signature over a msg. The signature must
300301 // be zbase32 encoded and signed by an active node in the resident
@@ -359,9 +360,9 @@ type ChannelInfo struct {
359360 // Active indicates whether the channel is active.
360361 Active bool
361362
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.
365366 ChannelID uint64
366367
367368 // PubKeyBytes is the raw bytes of the public key of the remote node.
@@ -765,7 +766,7 @@ const (
765766 ForceCloseAnchorStateLost = ForceCloseAnchorState (lnrpc .PendingChannelsResponse_ForceClosedChannel_LOST )
766767)
767768
768- // String provides the string represenetation of a close initiator.
769+ // String provides the string representation of a close initiator.
769770func (c Initiator ) String () string {
770771 switch c {
771772 case InitiatorUnrecorded :
@@ -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 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+
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 }
@@ -3364,7 +3398,7 @@ type ChannelEdge struct {
33643398 Node2Policy * RoutingPolicy
33653399}
33663400
3367- // getRoutingPolicy converts an lnrpc.RoutingPolicy to RoutingPolicy.
3401+ // getRoutingPolicy converts a lnrpc.RoutingPolicy to RoutingPolicy.
33683402func getRoutingPolicy (policy * lnrpc.RoutingPolicy ) * RoutingPolicy {
33693403 if policy == nil {
33703404 return nil
@@ -3678,7 +3712,7 @@ func (s *lightningClient) SubscribeGraph(ctx context.Context) (
36783712 return updates , errChan , nil
36793713}
36803714
3681- // getGraphTopologyUpdate converts an lnrpc.GraphTopologyUpdate to the higher
3715+ // getGraphTopologyUpdate converts a lnrpc.GraphTopologyUpdate to the higher
36823716// level GraphTopologyUpdate.
36833717func getGraphTopologyUpdate (update * lnrpc.GraphTopologyUpdate ) (
36843718 * GraphTopologyUpdate , error ) {
@@ -3814,19 +3848,20 @@ func (s *lightningClient) NetworkInfo(ctx context.Context) (*NetworkInfo,
38143848// to start streaming.
38153849type InvoiceSubscriptionRequest struct {
38163850 // 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.
38203854 AddIndex uint64
38213855
38223856 // 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.
38263860 SettleIndex uint64
38273861}
38283862
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.
38303865func (s * lightningClient ) SubscribeInvoices (ctx context.Context ,
38313866 req InvoiceSubscriptionRequest ) (<- chan * Invoice , <- chan error , error ) {
38323867
0 commit comments