lightning 4.10.7 → 4.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Versions
2
2
 
3
+ ## 4.11.0
4
+
5
+ - `getFailedPayments`: Add method to get past failed payments
6
+ - `subscribeToRpcRequests`: Add method to listen to and interact with RPC requests
7
+
3
8
  ## 4.10.7
4
9
 
5
10
  - `getPayment`: Expand type definitions to match result data
package/README.md CHANGED
@@ -131,6 +131,8 @@ Methods exported by this library support typescript, but ln-service includes add
131
131
  channels on the node.
132
132
  - [getConnectedWatchtowers](https://github.com/alexbosworth/ln-service#getconnectedwatchtowers):
133
133
  List watchtowers that were added
134
+ - [getFailedPayments](https://github.com/alexbosworth/ln-service#getfailedpayments): List out
135
+ past payments that failed.
134
136
  - [getFeeRates](https://github.com/alexbosworth/ln-service#getfeerates): List routing fee rates
135
137
  and routing policies of channels on the node.
136
138
  - [getForwardingConfidence](https://github.com/alexbosworth/ln-service#getforwardingconfidence):
package/index.js CHANGED
@@ -37,6 +37,7 @@ const {getChannelBalance} = require('./lnd_methods');
37
37
  const {getChannels} = require('./lnd_methods');
38
38
  const {getClosedChannels} = require('./lnd_methods');
39
39
  const {getConnectedWatchtowers} = require('./lnd_methods');
40
+ const {getFailedPayments} = require('./lnd_methods');
40
41
  const {getFeeRates} = require('./lnd_methods');
41
42
  const {getForwardingConfidence} = require('./lnd_methods');
42
43
  const {getForwardingReputations} = require('./lnd_methods');
@@ -114,6 +115,7 @@ const {subscribeToPayViaRequest} = require('./lnd_methods');
114
115
  const {subscribeToPayViaRoutes} = require('./lnd_methods');
115
116
  const {subscribeToPeers} = require('./lnd_methods');
116
117
  const {subscribeToProbeForRoute} = require('./lnd_methods');
118
+ const {subscribeToRpcRequests} = require('./lnd_methods');
117
119
  const {subscribeToTransactions} = require('./lnd_methods');
118
120
  const {subscribeToWalletStatus} = require('./lnd_methods');
119
121
  const {unauthenticatedLndGrpc} = require('./lnd_grpc');
@@ -169,6 +171,7 @@ module.exports = {
169
171
  getChannels,
170
172
  getClosedChannels,
171
173
  getConnectedWatchtowers,
174
+ getFailedPayments,
172
175
  getFeeRates,
173
176
  getForwardingConfidence,
174
177
  getForwardingReputations,
@@ -246,6 +249,7 @@ module.exports = {
246
249
  subscribeToPayViaRoutes,
247
250
  subscribeToPeers,
248
251
  subscribeToProbeForRoute,
252
+ subscribeToRpcRequests,
249
253
  subscribeToTransactions,
250
254
  subscribeToWalletStatus,
251
255
  unauthenticatedLndGrpc,
@@ -1,4 +1,5 @@
1
1
  export * from './get_access_ids';
2
2
  export * from './grant_access';
3
3
  export * from './revoke_access';
4
+ export * from './subscribe_to_rpc_requests';
4
5
  export * from './verify_access';
@@ -0,0 +1,143 @@
1
+ import {
2
+ AuthenticatedLightningArgs,
3
+ AuthenticatedLightningMethod,
4
+ LightningMethod,
5
+ } from '../../typescript';
6
+
7
+ export type SubscribeToRpcRequestsArgs = AuthenticatedLightningArgs<{
8
+ /** RPC Middleware Interception Name String */
9
+ id?: string;
10
+ /** Intercept Channel Closes Bool */
11
+ is_intercepting_close_channel_requests?: boolean;
12
+ /** Intercept Channel Opens Bool */
13
+ is_intercepting_open_channel_requests?: boolean;
14
+ /** Intercept Pay Via Route Bool */
15
+ is_intercepting_pay_via_routes_requests?: boolean;
16
+ }>;
17
+
18
+ export type SubscribeToRpcRequestsResult = {
19
+ /** RPC Request Subscription EventEmitter Object */
20
+ subscription: NodeJS.EventEmitter;
21
+ };
22
+
23
+ export type SubscribeToRpcRequestsCommonEvent = {
24
+ /** Request Id Number */
25
+ id: number;
26
+ /** Base64 Encoded Macaroon String */
27
+ macaroon?: string;
28
+ /** RPC URI String */
29
+ uri?: string;
30
+ };
31
+
32
+ export type SubscribeToRpcRequestsEvent<TRequest> =
33
+ Required<SubscribeToRpcRequestsCommonEvent> & {
34
+ accept: LightningMethod;
35
+ reject: LightningMethod<{
36
+ /** Rejection String */
37
+ message: string;
38
+ }>;
39
+ request: TRequest;
40
+ };
41
+
42
+ /** A channel close request was intercepted: by default it will be rejected */
43
+ export type SubscribeToRpcRequestsCloseChannelRequestEvent =
44
+ SubscribeToRpcRequestsEvent<{
45
+ /** Request Sending Local Channel Funds To Address String */
46
+ address?: string;
47
+ /** Is Force Close Bool */
48
+ is_force_close?: boolean;
49
+ /** Confirmation Target Number */
50
+ target_confirmations?: number;
51
+ /** Tokens Per Virtual Byte Number */
52
+ tokens_per_vbyte?: number;
53
+ /** Transaction Id Hex String */
54
+ transaction_id: string;
55
+ /** Transaction Output Index Number */
56
+ transaction_vout: number;
57
+ }>;
58
+
59
+ /** A channel open request was intercepted: by default it will be rejected */
60
+ export type SubscribeToRpcRequestsOpenChannelRequestEvent =
61
+ SubscribeToRpcRequestsEvent<{
62
+ /** Chain Fee Tokens Per VByte Number */
63
+ chain_fee_tokens_per_vbyte?: number;
64
+ /** Prefer Cooperative Close To Address String */
65
+ cooperative_close_address?: string;
66
+ /** Tokens to Gift To Partner Number */
67
+ give_tokens?: number;
68
+ /** Channel is Private Bool */
69
+ is_private?: boolean;
70
+ /** Local Tokens Number */
71
+ local_tokens: number;
72
+ /** Spend UTXOs With Minimum Confirmations Number */
73
+ min_confirmations?: number;
74
+ /** Minimum HTLC Millitokens String */
75
+ min_htlc_mtokens?: string;
76
+ /** Public Key Hex String */
77
+ partner_public_key: string;
78
+ /** Peer Output CSV Delay Number */
79
+ partner_csv_delay?: number;
80
+ }>;
81
+
82
+ /** A pay to route request was intercepted: by default it will be rejected */
83
+ export type SubscribeToRpcRequestsPayViaRouteRequestEvent =
84
+ SubscribeToRpcRequestsEvent<{
85
+ /** Payment Hash Hex String */
86
+ id: string;
87
+ route: {
88
+ /** Route Fee Tokens Number */
89
+ fee: number;
90
+ /** Route Fee Millitokens String */
91
+ fee_mtokens: string;
92
+ hops: {
93
+ /** Standard Format Channel Id String */
94
+ channel: string;
95
+ /** Channel Capacity Tokens Number */
96
+ channel_capacity: number;
97
+ /** Fee Tokens Number */
98
+ fee: number;
99
+ /** Fee Millitokens String */
100
+ fee_mtokens: string;
101
+ /** Forward Tokens Number */
102
+ forward: number;
103
+ /** Forward Millitokens String */
104
+ forward_mtokens: string;
105
+ /** Forward Edge Public Key Hex String */
106
+ public_key: string;
107
+ /** Timeout Block Height Number */
108
+ timeout?: number;
109
+ }[];
110
+ /** Total Fee-Inclusive Millitokens String */
111
+ mtokens: string;
112
+ /** Payment Identifier Hex String */
113
+ payment?: string;
114
+ /** Timeout Block Height Number */
115
+ timeout?: number;
116
+ /** Total Fee-Inclusive Tokens Number */
117
+ tokens: number;
118
+ /** Total Payment Millitokens String */
119
+ total_mtokens?: string;
120
+ };
121
+ }>;
122
+
123
+ export type SubscribeToRpcRequestsRequestEvent =
124
+ SubscribeToRpcRequestsCommonEvent;
125
+
126
+ export type SubscribeToRpcRequestsResponseEvent =
127
+ SubscribeToRpcRequestsCommonEvent;
128
+
129
+ /**
130
+ * Subscribe to RPC requests and their responses
131
+ *
132
+ * `accept` and `reject` methods can be used with cbk or Promise syntax
133
+ *
134
+ * Requires `macaroon:write` permission
135
+ *
136
+ * LND must be running with "RPC middleware" enabled: `rpcmiddleware.enable=1`
137
+ *
138
+ * This method is not supported in LND 0.13.3 and below
139
+ */
140
+ export const subscribeToRpcRequests: AuthenticatedLightningMethod<
141
+ SubscribeToRpcRequestsArgs,
142
+ SubscribeToRpcRequestsResult
143
+ >;
@@ -0,0 +1,136 @@
1
+ import {
2
+ AuthenticatedLightningArgs,
3
+ AuthenticatedLightningMethod,
4
+ PaginationArgs,
5
+ } from '../../typescript';
6
+
7
+ export type GetFailedPaymentsArgs = AuthenticatedLightningArgs<PaginationArgs>;
8
+
9
+ export type GetFailedPaymentsResult = {
10
+ payments: {
11
+ attempts: {
12
+ failure?: {
13
+ /** Error Type Code Number */
14
+ code: number;
15
+ details?: {
16
+ /** Standard Format Channel Id String */
17
+ channel?: string;
18
+ /** Error Associated Block Height Number */
19
+ height?: number;
20
+ /** Failed Hop Index Number */
21
+ index?: number;
22
+ /** Error Millitokens String */
23
+ mtokens?: string;
24
+ policy?: {
25
+ /** Base Fee Millitokens String */
26
+ base_fee_mtokens: string;
27
+ /** Locktime Delta Number */
28
+ cltv_delta: number;
29
+ /** Fees Charged in Millitokens Per Million Number */
30
+ fee_rate: number;
31
+ /** Channel is Disabled Bool */
32
+ is_disabled?: boolean;
33
+ /** Maximum HLTC Millitokens Value String */
34
+ max_htlc_mtokens: string;
35
+ /** Minimum HTLC Millitokens Value String */
36
+ min_htlc_mtokens: string;
37
+ /** Updated At ISO 8601 Date String */
38
+ updated_at: string;
39
+ };
40
+ /** Error CLTV Timeout Height Number */
41
+ timeout_height?: number;
42
+ update?: {
43
+ /** Chain Id Hex String */
44
+ chain: string;
45
+ /** Channel Flags Number */
46
+ channel_flags: number;
47
+ /** Extra Opaque Data Hex String */
48
+ extra_opaque_data: string;
49
+ /** Message Flags Number */
50
+ message_flags: number;
51
+ /** Channel Update Signature Hex String */
52
+ signature: string;
53
+ };
54
+ };
55
+ /** Error Message String */
56
+ message: string;
57
+ };
58
+ /** Payment Add Index Number */
59
+ index?: number;
60
+ /** Payment Confirmed At ISO 8601 Date String */
61
+ confirmed_at?: string;
62
+ /** Payment Attempt Succeeded Bool */
63
+ is_confirmed: boolean;
64
+ /** Payment Attempt Failed Bool */
65
+ is_failed: boolean;
66
+ /** Payment Attempt is Waiting For Resolution Bool */
67
+ is_pending: boolean;
68
+ route: {
69
+ /** Route Fee Tokens Number */
70
+ fee: number;
71
+ /** Route Fee Millitokens String */
72
+ fee_mtokens: string;
73
+ hops: {
74
+ /** Standard Format Channel Id String */
75
+ channel: string;
76
+ /** Channel Capacity Tokens Number */
77
+ channel_capacity: number;
78
+ /** Fee Number */
79
+ fee: number;
80
+ /** Fee Millitokens String */
81
+ fee_mtokens: string;
82
+ /** Forward Tokens Number */
83
+ forward: number;
84
+ /** Forward Millitokens String */
85
+ forward_mtokens: string;
86
+ /** Forward Edge Public Key Hex String */
87
+ public_key?: string;
88
+ /** Timeout Block Height Number */
89
+ timeout?: number;
90
+ }[];
91
+ /** Total Fee-Inclusive Millitokens String */
92
+ mtokens: string;
93
+ /** Payment Identifier Hex String */
94
+ payment?: string;
95
+ /** Timeout Block Height Number */
96
+ timeout: number;
97
+ /** Total Fee-Inclusive Tokens Number */
98
+ tokens: number;
99
+ /** Total Millitokens String */
100
+ total_mtokens?: string;
101
+ };
102
+ }[];
103
+ /** Payment at ISO-8601 Date String */
104
+ created_at: string;
105
+ /** Destination Node Public Key Hex String */
106
+ destination?: string;
107
+ /** Payment Preimage Hash String */
108
+ id: string;
109
+ /** Payment Add Index Number */
110
+ index?: number;
111
+ /** Payment is Confirmed Bool */
112
+ is_confirmed: boolean;
113
+ /** Transaction Is Outgoing Bool */
114
+ is_outgoing: boolean;
115
+ /** Millitokens Attempted to Pay to Destination String */
116
+ mtokens: string;
117
+ /** BOLT 11 Payment Request String */
118
+ request?: string;
119
+ /** Payment Tokens Attempted to Pay Rounded Up Number */
120
+ safe_tokens: number;
121
+ /** Rounded Down Tokens Attempted to Pay to Destination Number */
122
+ tokens: number;
123
+ }[];
124
+ /** Next Opaque Paging Token String */
125
+ next?: string;
126
+ };
127
+
128
+ /**
129
+ * Get failed payments made through channels.
130
+ *
131
+ * Requires `offchain:read` permission
132
+ */
133
+ export const getFailedPayments: AuthenticatedLightningMethod<
134
+ GetFailedPaymentsArgs,
135
+ GetFailedPaymentsResult
136
+ >;
@@ -14,6 +14,7 @@ export * from './get_channel_balance';
14
14
  export * from './get_channels';
15
15
  export * from './get_closed_channels';
16
16
  export * from './get_connected_watchtowers';
17
+ export * from './get_failed_payments';
17
18
  export * from './get_fee_rates';
18
19
  export * from './get_forwarding_confidence';
19
20
  export * from './get_forwarding_reputations';
@@ -118,6 +118,10 @@ export type ProbeForRouteResult = {
118
118
  /**
119
119
  * Probe to find a successful route
120
120
  *
121
+ * When probing to a payment request, make sure to specify the fields encoded in the payment request such as `cltv_delta`.
122
+ *
123
+ * If `total_mtokens` are specified, a `payment` nonce is required.
124
+ *
121
125
  * Requires `offchain:write` permission
122
126
  */
123
127
  export const probeForRoute: AuthenticatedLightningMethod<
@@ -34,7 +34,7 @@ export type ProposeChannelArgs = AuthenticatedLightningArgs<{
34
34
  * Channel proposals can allow for cooperative close delays or external funding
35
35
  flows.
36
36
  *
37
- * Requires `offchain:write`, `onchain:write` permissions
37
+ * Requires `address:read`, `offchain:write`, `onchain:write` permissions
38
38
  *
39
39
  * Requires LND compiled with `walletrpc` build tag
40
40
  */
@@ -24,7 +24,9 @@ export type GetWalletStatusResult = {
24
24
  /**
25
25
  * Get wallet status.
26
26
  *
27
- * Requires `info:read` permission
27
+ * This method is not supported on LND 0.12.1 and below
28
+ *
29
+ * `is_ready` is not supported on LND 0.13.3 and below
28
30
  */
29
31
  export const getWalletStatus: UnauthenticatedLightningMethod<
30
32
  {lnd: UnauthenticatedLnd},
@@ -24,5 +24,7 @@ export type SubscribeToWalletStatusStartingEvent = EmptyObject;
24
24
  * Subscribe to wallet status events
25
25
  *
26
26
  * This method is not supported on LND 0.12.1 and below
27
+ *
28
+ * `ready` is not supported on LND 0.13.3 and below
27
29
  */
28
30
  export const subscribeToWalletStatus: UnauthenticatedLightningSubscription;
package/package.json CHANGED
@@ -7,10 +7,10 @@
7
7
  "url": "https://github.com/alexbosworth/lightning/issues"
8
8
  },
9
9
  "dependencies": {
10
- "@grpc/grpc-js": "1.3.7",
10
+ "@grpc/grpc-js": "1.4.1",
11
11
  "@grpc/proto-loader": "0.6.5",
12
12
  "@types/express": "4.17.13",
13
- "@types/node": "16.10.4",
13
+ "@types/node": "16.11.1",
14
14
  "@types/request": "2.48.7",
15
15
  "@types/ws": "8.2.0",
16
16
  "async": "3.2.1",
@@ -56,5 +56,5 @@
56
56
  "directory": "test/typescript"
57
57
  },
58
58
  "types": "index.d.ts",
59
- "version": "4.10.7"
59
+ "version": "4.11.0"
60
60
  }
@@ -0,0 +1,31 @@
1
+ import {expectError, expectType} from 'tsd';
2
+ import {AuthenticatedLnd} from '../../lnd_grpc';
3
+ import {getFailedPayments, GetFailedPaymentsResult} from '../../lnd_methods';
4
+
5
+ const lnd = {} as AuthenticatedLnd;
6
+ const limit = 1;
7
+ const token = 'token';
8
+
9
+ expectError(getFailedPayments());
10
+ expectError(getFailedPayments({}));
11
+ expectError(getFailedPayments({lnd, limit, token})); // ExpectedNoLimitWhenPagingPayFailuresWithToken
12
+
13
+ expectType<GetFailedPaymentsResult>(await getFailedPayments({lnd}));
14
+ expectType<GetFailedPaymentsResult>(await getFailedPayments({lnd, limit}));
15
+ expectType<GetFailedPaymentsResult>(await getFailedPayments({lnd, token}));
16
+
17
+ expectType<void>(
18
+ getFailedPayments({lnd}, (error, result) => {
19
+ expectType<GetFailedPaymentsResult>(result);
20
+ })
21
+ );
22
+ expectType<void>(
23
+ getFailedPayments({lnd, limit}, (error, result) => {
24
+ expectType<GetFailedPaymentsResult>(result);
25
+ })
26
+ );
27
+ expectType<void>(
28
+ getFailedPayments({lnd, token}, (error, result) => {
29
+ expectType<GetFailedPaymentsResult>(result);
30
+ })
31
+ );
@@ -0,0 +1,46 @@
1
+ import {expectError, expectType} from 'tsd';
2
+ import {AuthenticatedLnd} from '../../lnd_grpc';
3
+ import {
4
+ subscribeToRpcRequests,
5
+ SubscribeToRpcRequestsResult,
6
+ } from '../../lnd_methods';
7
+
8
+ const lnd = {} as AuthenticatedLnd;
9
+ const id = 'id';
10
+ const is_intercepting_close_channel_requests = true;
11
+ const is_intercepting_open_channel_requests = true;
12
+ const is_intercepting_pay_via_routes_requests = true;
13
+
14
+ expectError(subscribeToRpcRequests());
15
+ expectError(subscribeToRpcRequests({}));
16
+
17
+ expectType<SubscribeToRpcRequestsResult>(await subscribeToRpcRequests({lnd}));
18
+ expectType<SubscribeToRpcRequestsResult>(
19
+ await subscribeToRpcRequests({
20
+ lnd,
21
+ id,
22
+ is_intercepting_close_channel_requests,
23
+ is_intercepting_open_channel_requests,
24
+ is_intercepting_pay_via_routes_requests,
25
+ })
26
+ );
27
+
28
+ expectType<void>(
29
+ subscribeToRpcRequests({lnd}, (err, res) => {
30
+ expectType<SubscribeToRpcRequestsResult>(res);
31
+ })
32
+ );
33
+ expectType<void>(
34
+ subscribeToRpcRequests(
35
+ {
36
+ lnd,
37
+ id,
38
+ is_intercepting_close_channel_requests,
39
+ is_intercepting_open_channel_requests,
40
+ is_intercepting_pay_via_routes_requests,
41
+ },
42
+ (err, res) => {
43
+ expectType<SubscribeToRpcRequestsResult>(res);
44
+ }
45
+ )
46
+ );