lightning 5.8.3 → 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,5 +1,9 @@
1
1
  # Versions
2
2
 
3
+ ## 5.8.4
4
+
5
+ - `getWalletInfo`, `payViaPaymentDetails`: Correct typescript fields
6
+
3
7
  ## 5.8.3
4
8
 
5
9
  - `getInvoice`: Add typescript timeout field on individual payment HTLCs
@@ -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
  /**
@@ -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>
@@ -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
  });
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.7",
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.21",
13
+ "@types/node": "17.0.22",
14
14
  "@types/request": "2.48.8",
15
- "@types/ws": "8.5.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",
@@ -26,7 +26,7 @@
26
26
  "invoices": "2.0.4",
27
27
  "psbt": "2.0.0",
28
28
  "tiny-secp256k1": "2.2.1",
29
- "type-fest": "2.12.0"
29
+ "type-fest": "2.12.1"
30
30
  },
31
31
  "description": "Lightning Network client library",
32
32
  "devDependencies": {
@@ -59,5 +59,5 @@
59
59
  "directory": "test/typescript"
60
60
  },
61
61
  "types": "index.d.ts",
62
- "version": "5.8.3"
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>(