lightning 5.8.1 → 5.8.4

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,6 +1,14 @@
1
1
  # Versions
2
2
 
3
- ## 5.8.1
3
+ ## 5.8.4
4
+
5
+ - `getWalletInfo`, `payViaPaymentDetails`: Correct typescript fields
6
+
7
+ ## 5.8.3
8
+
9
+ - `getInvoice`: Add typescript timeout field on individual payment HTLCs
10
+
11
+ ## 5.8.2
4
12
 
5
13
  - `getMasterPublicKeys`: Add method to lookup wallet extended public keys
6
14
 
package/README.md CHANGED
@@ -6,6 +6,8 @@ Methods for working with the Lightning Network
6
6
 
7
7
  ## Selected Projects using Lightning
8
8
 
9
+ - [bitpay.com crypto-rpc](https://bitpay.com/) -
10
+ https://github.com/bitpay/crypto-rpc
9
11
  - [coinos.io](https://coinos.io/) - https://github.com/coinos/coinos-server
10
12
  - [Lightning Shell](https://lightningshell.app/) -
11
13
  https://github.com/ibz/lightning-shell
@@ -27,6 +29,8 @@ Methods for working with the Lightning Network
27
29
  - [rekr](https://rekr.app/) - https://github.com/ryan-lingle/rekr
28
30
  - [Suredbits API](https://suredbits.com/) -
29
31
  https://github.com/Suredbits/sb-api-lnd
32
+ - [Synonym demo server](https://synonym.to) -
33
+ https://github.com/synonymdev/slash-pay-demo-server
30
34
 
31
35
  ## LND Authentication
32
36
 
@@ -34,6 +34,8 @@ export type GetWalletInfoResult = {
34
34
  pending_channels_count: number;
35
35
  /** Public Key */
36
36
  public_key: string;
37
+ /** Version String */
38
+ version: string;
37
39
  };
38
40
 
39
41
  /**
@@ -76,6 +76,8 @@ export type GetInvoiceResult = {
76
76
  mtokens: string;
77
77
  /** Pending Payment Channel HTLC Index */
78
78
  pending_index?: number;
79
+ /** HTLC CLTV Timeout Height Number */
80
+ timeout: number;
79
81
  /** Payment Tokens */
80
82
  tokens: number;
81
83
  }[];
@@ -42,7 +42,7 @@ export type PayViaPaymentDetailsArgs = AuthenticatedLightningArgs<{
42
42
  pathfinding_timeout?: number;
43
43
  /** Payment Identifier Hex String */
44
44
  payment?: string;
45
- routes: {
45
+ routes?: {
46
46
  /** Base Routing Fee In Millitokens */
47
47
  base_fee_mtokens?: string;
48
48
  /** Standard Format Channel Id */
@@ -42,7 +42,7 @@ const type = 'router';
42
42
  [outgoing_channels]: [<Pay Out of Outgoing Channel Ids String>]
43
43
  [pathfinding_timeout]: <Time to Spend Finding a Route Milliseconds Number>
44
44
  [payment]: <Payment Identifier Hex String>
45
- routes: [[{
45
+ [routes]: [[{
46
46
  [base_fee_mtokens]: <Base Routing Fee In Millitokens String>
47
47
  [channel]: <Standard Format Channel Id String>
48
48
  [cltv_delta]: <CLTV Blocks Delta Number>
@@ -67,6 +67,8 @@ export type SubscribeToPastPaymentsPaymentEvent = {
67
67
  /**
68
68
  * Subscribe to successful outgoing payments
69
69
  *
70
+ * Payments may be omitted if LND does not finalize the payment record
71
+ *
70
72
  * Requires `offchain:read` permission
71
73
  *
72
74
  * Note: Method not supported on LND 0.13.4 and below
@@ -21,6 +21,8 @@ const unknownFailureMessage = '2 UNKNOWN: unknown failure detail type: <nil>';
21
21
 
22
22
  /** Subscribe to successful outgoing payments
23
23
 
24
+ Payments may be omitted if LND does not finalize the payment record
25
+
24
26
  Requires `offchain:read` permission
25
27
 
26
28
  Note: Method not supported on LND 0.13.4 and below
@@ -113,7 +113,7 @@ module.exports = args => {
113
113
  return;
114
114
  }
115
115
 
116
- eventEmitter.emit('error', new Error('UnexpectedErrInTxSubscription'));
116
+ eventEmitter.emit('error', err);
117
117
 
118
118
  return;
119
119
  });
@@ -51,8 +51,6 @@ module.exports = ({lnd}) => {
51
51
 
52
52
  subscription.cancel();
53
53
 
54
- subscription.removeAllListeners();
55
-
56
54
  return;
57
55
  });
58
56
 
package/package.json CHANGED
@@ -7,12 +7,12 @@
7
7
  "url": "https://github.com/alexbosworth/lightning/issues"
8
8
  },
9
9
  "dependencies": {
10
- "@grpc/grpc-js": "1.5.5",
10
+ "@grpc/grpc-js": "1.5.9",
11
11
  "@grpc/proto-loader": "0.6.9",
12
12
  "@types/express": "4.17.13",
13
- "@types/node": "17.0.18",
13
+ "@types/node": "17.0.22",
14
14
  "@types/request": "2.48.8",
15
- "@types/ws": "8.2.2",
15
+ "@types/ws": "8.5.3",
16
16
  "async": "3.2.3",
17
17
  "asyncjs-util": "1.2.8",
18
18
  "bitcoinjs-lib": "6.0.1",
@@ -22,18 +22,18 @@
22
22
  "bolt09": "0.2.2",
23
23
  "cbor": "8.1.0",
24
24
  "ecpair": "2.0.1",
25
- "express": "4.17.2",
25
+ "express": "4.17.3",
26
26
  "invoices": "2.0.4",
27
27
  "psbt": "2.0.0",
28
- "tiny-secp256k1": "2.2.0",
29
- "type-fest": "2.11.2"
28
+ "tiny-secp256k1": "2.2.1",
29
+ "type-fest": "2.12.1"
30
30
  },
31
31
  "description": "Lightning Network client library",
32
32
  "devDependencies": {
33
33
  "@alexbosworth/node-fetch": "2.6.2",
34
34
  "@alexbosworth/tap": "15.0.10",
35
35
  "tsd": "0.19.1",
36
- "typescript": "4.5.5",
36
+ "typescript": "4.6.2",
37
37
  "ws": "8.5.0"
38
38
  },
39
39
  "engines": {
@@ -59,5 +59,5 @@
59
59
  "directory": "test/typescript"
60
60
  },
61
61
  "types": "index.d.ts",
62
- "version": "5.8.1"
62
+ "version": "5.8.4"
63
63
  }
@@ -3,6 +3,7 @@ const {test} = require('@alexbosworth/tap');
3
3
  const {fundPendingChannels} = require('./../../../lnd_methods');
4
4
 
5
5
  const id = Buffer.alloc(32).toString('hex');
6
+ const id2 = Buffer.alloc(32, 1).toString('hex');
6
7
 
7
8
  const makeLnd = ({finalizeErr, verifyErr}) => {
8
9
  return {
@@ -75,6 +76,35 @@ const tests = [
75
76
  args: makeArgs({}),
76
77
  description: 'Channel funding is executed',
77
78
  },
79
+ {
80
+ args: makeArgs({
81
+ channels: [id, id2],
82
+ lnd: {
83
+ default: {
84
+ fundingStateStep: (args, cbk) => {
85
+ const finalize = args.psbt_finalize;
86
+
87
+ if (!finalize) {
88
+ return cbk();
89
+ }
90
+
91
+ const pendingId = finalize.pending_chan_id.toString('hex');
92
+
93
+ if (pendingId === id && finalize.no_publish !== true) {
94
+ return cbk('ExpectedFirstChannelIsNoPublish');
95
+ }
96
+
97
+ if (pendingId === id2 && finalize.no_publish !== false) {
98
+ return cbk('ExpectedLastChannelIsNotNoPublish');
99
+ }
100
+
101
+ return cbk();
102
+ },
103
+ },
104
+ },
105
+ }),
106
+ description: 'Channel funding across multiple channels is executed',
107
+ },
78
108
  ];
79
109
 
80
110
  tests.forEach(({args, description, error, expected}) => {
@@ -5,6 +5,8 @@ const {test} = require('@alexbosworth/tap');
5
5
  const {openChannels} = require('./../../../lnd_methods');
6
6
 
7
7
  const emitter = new EventEmitter();
8
+ const nodeKey1 = Buffer.alloc(33).toString('hex');
9
+ const nodeKey2 = Buffer.alloc(33, 2).toString('hex');
8
10
 
9
11
  const makeChannels = ({}) => {
10
12
  return [{
@@ -128,6 +130,57 @@ const tests = [
128
130
  description: 'Channels are pending',
129
131
  expected: {pending: {address: 'funding_address', tokens: 1}},
130
132
  },
133
+ {
134
+ args: {
135
+ channels: [
136
+ {capacity: 1, partner_public_key: nodeKey1},
137
+ {capacity: 2, partner_public_key: nodeKey2},
138
+ ],
139
+ lnd: {
140
+ default: {
141
+ fundingStateStep: ({}, cbk) => cbk(),
142
+ openChannel: args => {
143
+ const eventEmitter = new EventEmitter();
144
+
145
+ const key = args.node_pubkey.toString('hex');
146
+
147
+ if (key === nodeKey1 && !args.funding_shim.psbt_shim.no_publish) {
148
+ throw new Error('ExpectedFirstKeyIsNoPublish');
149
+ }
150
+
151
+ if (key === nodeKey2 && !!args.funding_shim.psbt_shim.no_publish) {
152
+ throw new Error('TheSecondChannelShouldPublish');
153
+ }
154
+
155
+ process.nextTick(() => {
156
+ eventEmitter.emit('data', {});
157
+
158
+ eventEmitter.emit('data', {
159
+ psbt_fund: {
160
+ funding_address: 'funding_address',
161
+ funding_amount: '1',
162
+ },
163
+ update: 'psbt_fund',
164
+ });
165
+
166
+ // Emit twice to make sure that cbk isn't called twice
167
+ eventEmitter.emit('data', {
168
+ psbt_fund: {
169
+ funding_address: 'funding_address',
170
+ funding_amount: '1',
171
+ },
172
+ update: 'psbt_fund',
173
+ });
174
+ });
175
+
176
+ return eventEmitter;
177
+ },
178
+ },
179
+ },
180
+ },
181
+ description: 'Multiple channels are pending',
182
+ expected: {pending: {address: 'funding_address', tokens: 1}},
183
+ },
131
184
  ];
132
185
 
133
186
  tests.forEach(({args, description, error, expected}) => {
@@ -44,7 +44,6 @@ expectError(payViaPaymentDetails({destination}));
44
44
  expectError(payViaPaymentDetails({destination, routes}));
45
45
  expectError(payViaPaymentDetails({routes}));
46
46
  expectError(payViaPaymentDetails({lnd}));
47
- expectError(payViaPaymentDetails({lnd, destination}));
48
47
  expectError(payViaPaymentDetails({lnd, routes}));
49
48
 
50
49
  expectType<PayViaPaymentDetailsResult>(