lightning 5.3.1 → 5.4.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,18 @@
1
1
  # Versions
2
2
 
3
+ ## 5.4.0
4
+
5
+ - `deletePendingChannel`: Add method to delete a stuck pending channel
6
+ - `getInvoices`: Fill in type definition for `is_unconfirmed`
7
+
8
+ ## 5.3.4
9
+
10
+ - `getPayments`: Correct paging issue that prevented paging through all results
11
+
12
+ ## 5.3.3
13
+
14
+ - `pay`, `payViaPaymentRequest`: Fix support for `outgoing_channels` constraint
15
+
3
16
  ## 5.3.1
4
17
 
5
18
  - `getInvoices`: Add `is_unconfirmed` to filter out canceled/settled invoices
package/README.md CHANGED
@@ -7,17 +7,26 @@ Methods for working with the Lightning Network
7
7
  ## Selected Projects using Lightning
8
8
 
9
9
  - [coinos.io](https://coinos.io/) - https://github.com/coinos/coinos-server
10
- - [LNMarkets](https://twitter.com/lnmarkets) - https://github.com/lnmarkets/umbrel
10
+ - [Lightning Shell](https://lightningshell.app/) -
11
+ https://github.com/ibz/lightning-shell
12
+ - [LNMarkets](https://twitter.com/lnmarkets) -
13
+ https://github.com/lnmarkets/umbrel
11
14
  - [Galoy](https://galoy.io/) - https://github.com/GaloyMoney/galoy
12
15
  - [Tarnhelm](https://www.tarnhelm.app/) - https://github.com/bkiac/tarnhelm
13
- - [tbtcswaps](https://tbtcswaps.com/) - https://github.com/keep-community/tbtcswaps
14
- - [stackernews](https://stacker.news/) - https://github.com/stackernews/stacker.news
15
- - [Thunderhub](https://www.thunderhub.io/) - https://github.com/apotdevin/thunderhub
16
- - [Lightning Roulette](https://lightning-roulette.com/) - https://github.com/igreshev/lightning-roulette
17
- - [Lightning Poker](https://lightning-poker.com/) - https://github.com/igreshev/lightning-poker
16
+ - [tbtcswaps](https://tbtcswaps.com/) -
17
+ https://github.com/keep-community/tbtcswaps
18
+ - [stackernews](https://stacker.news/) -
19
+ https://github.com/stackernews/stacker.news
20
+ - [Thunderhub](https://www.thunderhub.io/) -
21
+ https://github.com/apotdevin/thunderhub
22
+ - [Lightning Roulette](https://lightning-roulette.com/) -
23
+ https://github.com/igreshev/lightning-roulette
24
+ - [Lightning Poker](https://lightning-poker.com/) -
25
+ https://github.com/igreshev/lightning-poker
18
26
  - [p2plnbot](https://telegram.me/lnp2pbot) - https://github.com/grunch/p2plnbot
19
27
  - [rekr](https://rekr.app/) - https://github.com/ryan-lingle/rekr
20
- - [Suredbits API](https://suredbits.com/) - https://github.com/Suredbits/sb-api-lnd
28
+ - [Suredbits API](https://suredbits.com/) -
29
+ https://github.com/Suredbits/sb-api-lnd
21
30
 
22
31
  ## LND Authentication
23
32
 
@@ -4,7 +4,12 @@ import {
4
4
  PaginationArgs,
5
5
  } from '../../typescript';
6
6
 
7
- export type GetInvoicesArgs = AuthenticatedLightningArgs<PaginationArgs>;
7
+ export type GetInvoicesArgs = AuthenticatedLightningArgs<
8
+ PaginationArgs & {
9
+ /** Omit Canceled and Settled Invoices Bool */
10
+ is_unconfirmed?: boolean;
11
+ }
12
+ >;
8
13
 
9
14
  export type GetInvoicesResult = {
10
15
  invoices: {
@@ -0,0 +1,21 @@
1
+ import {
2
+ AuthenticatedLightningArgs,
3
+ AuthenticatedLightningMethod,
4
+ } from '../../typescript';
5
+
6
+ export type DeletePendingChannelArgs = AuthenticatedLightningArgs<{
7
+ /** Hex Encoded Conflicting Transaction String */
8
+ confirmed_transaction: string;
9
+ /** Hex Encoded Pending Transaction String */
10
+ pending_transaction: string;
11
+ /** Pending Channel Output Index Number */
12
+ pending_transaction_vout: number;
13
+ }>;
14
+
15
+ /**
16
+ * Delete a pending channel
17
+ *
18
+ * Pass the confirmed conflicting transaction that spends the same input to make sure that no funds are being deleted.
19
+ * This method is not supported on LND 0.13.3 and below
20
+ */
21
+ export const deletePendingChannel: AuthenticatedLightningMethod<DeletePendingChannelArgs>;
@@ -8,7 +8,7 @@ const {sortBy} = require('./../../arrays');
8
8
  const defaultLimit = 250;
9
9
  const {isArray} = Array;
10
10
  const isFailed = payment => !!payment && payment.status === 'FAILED';
11
- const lastPageFirstIndexOffset = 0;
11
+ const lastPageFirstIndexOffset = 1;
12
12
  const method = 'listPayments';
13
13
  const {parse} = JSON;
14
14
  const {stringify} = JSON;
@@ -152,7 +152,7 @@ module.exports = ({limit, lnd, token}, cbk) => {
152
152
 
153
153
  return cbk(null, {
154
154
  payments: res.payments.filter(isFailed),
155
- token: offset === lastPageFirstIndexOffset ? undefined : token,
155
+ token: offset <= lastPageFirstIndexOffset ? undefined : token,
156
156
  });
157
157
  });
158
158
  }],
@@ -157,7 +157,7 @@ module.exports = ({limit, lnd, token}, cbk) => {
157
157
 
158
158
  return cbk(null, {
159
159
  payments: res.payments,
160
- token: offset === lastPageFirstIndexOffset ? undefined : token,
160
+ token: offset <= lastPageFirstIndexOffset ? undefined : token,
161
161
  });
162
162
  });
163
163
  }],
@@ -185,7 +185,7 @@ module.exports = ({limit, lnd, token}, cbk) => {
185
185
  });
186
186
 
187
187
  return cbk(null, {
188
- next: !!foundPayments.length ? listPayments.token : undefined,
188
+ next: listPayments.token || undefined,
189
189
  payments: payments.sorted.reverse(),
190
190
  });
191
191
  }],
@@ -5,6 +5,7 @@ export * from './delete_failed_payments';
5
5
  export * from './delete_forwarding_reputations';
6
6
  export * from './delete_payment';
7
7
  export * from './delete_payments';
8
+ export * from './delete_pending_channel';
8
9
  export * from './disable_channel';
9
10
  export * from './disconnect_watchtower';
10
11
  export * from './enable_channel';
@@ -99,6 +99,7 @@ module.exports = (args, cbk) => {
99
99
  messages: args.messages,
100
100
  mtokens: args.mtokens,
101
101
  outgoing_channel: args.outgoing_channel,
102
+ outgoing_channels: args.outgoing_channels,
102
103
  pathfinding_timeout: args.pathfinding_timeout,
103
104
  request: args.request,
104
105
  tokens: args.tokens,
@@ -3,6 +3,8 @@ const {returnResult} = require('asyncjs-util');
3
3
 
4
4
  const {isLnd} = require('./../../lnd_requests');
5
5
 
6
+ const bufferAsBase64 = buffer => buffer.toString('base64');
7
+ const {isBuffer} = Buffer;
6
8
  const method = 'initWallet';
7
9
  const type = 'unlocker';
8
10
  const utf8AsBuf = utf8 => Buffer.from(utf8, 'utf8');
@@ -19,6 +21,9 @@ const utf8AsBuf = utf8 => Buffer.from(utf8, 'utf8');
19
21
  }
20
22
 
21
23
  @returns via cbk or Promise
24
+ {
25
+ macaroon: <Base64 Encoded Admin Macaroon String>
26
+ }
22
27
  */
23
28
  module.exports = ({lnd, passphrase, password, seed}, cbk) => {
24
29
  return new Promise((resolve, reject) => {
@@ -47,12 +52,20 @@ module.exports = ({lnd, passphrase, password, seed}, cbk) => {
47
52
  cipher_seed_mnemonic: seed.split(' '),
48
53
  wallet_password: utf8AsBuf(password),
49
54
  },
50
- err => {
55
+ (err, res) => {
51
56
  if (!!err) {
52
57
  return cbk([503, 'UnexpectedInitWalletError', {err}]);
53
58
  }
54
59
 
55
- return cbk();
60
+ if (!res) {
61
+ return cbk([503, 'ExpectedResponseForInitWallet']);
62
+ }
63
+
64
+ if (!isBuffer(res.admin_macaroon)) {
65
+ return cbk([503, 'ExpectedAdminMacaroonToCrateWallet']);
66
+ }
67
+
68
+ return cbk(null, bufferAsBase64(res.admin_macaroon));
56
69
  });
57
70
  }],
58
71
  },
package/package.json CHANGED
@@ -7,32 +7,32 @@
7
7
  "url": "https://github.com/alexbosworth/lightning/issues"
8
8
  },
9
9
  "dependencies": {
10
- "@grpc/grpc-js": "1.5.0",
10
+ "@grpc/grpc-js": "1.5.3",
11
11
  "@grpc/proto-loader": "0.6.9",
12
12
  "@types/express": "4.17.13",
13
- "@types/node": "17.0.8",
13
+ "@types/node": "17.0.10",
14
14
  "@types/request": "2.48.8",
15
15
  "@types/ws": "8.2.2",
16
16
  "async": "3.2.3",
17
- "asyncjs-util": "1.2.7",
17
+ "asyncjs-util": "1.2.8",
18
18
  "bitcoinjs-lib": "6.0.1",
19
19
  "bn.js": "5.2.0",
20
20
  "body-parser": "1.19.1",
21
21
  "bolt07": "1.8.0",
22
- "bolt09": "0.2.0",
22
+ "bolt09": "0.2.1",
23
23
  "cbor": "8.1.0",
24
24
  "express": "4.17.2",
25
- "invoices": "2.0.2",
25
+ "invoices": "2.0.3",
26
26
  "psbt": "1.1.10",
27
- "type-fest": "2.9.0"
27
+ "type-fest": "2.10.0"
28
28
  },
29
29
  "description": "Lightning Network client library",
30
30
  "devDependencies": {
31
31
  "@alexbosworth/node-fetch": "2.6.2",
32
32
  "@alexbosworth/tap": "15.0.10",
33
33
  "tsd": "0.19.1",
34
- "typescript": "4.5.4",
35
- "ws": "8.4.0"
34
+ "typescript": "4.5.5",
35
+ "ws": "8.4.2"
36
36
  },
37
37
  "engines": {
38
38
  "node": ">=12.20"
@@ -57,5 +57,5 @@
57
57
  "directory": "test/typescript"
58
58
  },
59
59
  "types": "index.d.ts",
60
- "version": "5.3.1"
60
+ "version": "5.4.0"
61
61
  }
@@ -30,7 +30,13 @@ const tests = [
30
30
  },
31
31
  {
32
32
  args: {
33
- lnd: {unlocker: {initWallet: ({}, cbk) => cbk()}},
33
+ lnd: {
34
+ unlocker: {
35
+ initWallet: ({}, cbk) => cbk(null, {
36
+ admin_macaroon: Buffer.alloc(1),
37
+ }),
38
+ },
39
+ },
34
40
  password: 'pass',
35
41
  seed: 'seed',
36
42
  },
@@ -0,0 +1,43 @@
1
+ import {expectError, expectType} from 'tsd';
2
+ import {AuthenticatedLnd} from '../../lnd_grpc';
3
+ import {deletePendingChannel} from '../../lnd_methods';
4
+
5
+ const lnd = {} as AuthenticatedLnd;
6
+ const confirmed_transaction = 'tx0';
7
+ const pending_transaction = 'tx1';
8
+ const pending_transaction_vout = 1;
9
+
10
+ expectError(deletePendingChannel());
11
+ expectError(deletePendingChannel({}));
12
+ expectError(deletePendingChannel({lnd}));
13
+ expectError(deletePendingChannel({confirmed_transaction}));
14
+ expectError(deletePendingChannel({pending_transaction}));
15
+ expectError(deletePendingChannel({pending_transaction_vout}));
16
+ expectError(deletePendingChannel({lnd, confirmed_transaction}));
17
+ expectError(deletePendingChannel({lnd, pending_transaction}));
18
+ expectError(deletePendingChannel({lnd, pending_transaction_vout}));
19
+ expectError(
20
+ deletePendingChannel({lnd, confirmed_transaction, pending_transaction})
21
+ );
22
+ expectError(
23
+ deletePendingChannel({lnd, confirmed_transaction, pending_transaction_vout})
24
+ );
25
+ expectError(
26
+ deletePendingChannel({lnd, pending_transaction, pending_transaction_vout})
27
+ );
28
+
29
+ expectType<void>(
30
+ await deletePendingChannel({
31
+ lnd,
32
+ confirmed_transaction,
33
+ pending_transaction,
34
+ pending_transaction_vout,
35
+ })
36
+ );
37
+
38
+ expectType<void>(
39
+ deletePendingChannel(
40
+ {lnd, confirmed_transaction, pending_transaction, pending_transaction_vout},
41
+ () => {}
42
+ )
43
+ );
@@ -5,14 +5,18 @@ import {getInvoices, GetInvoicesResult} from '../../lnd_methods';
5
5
  const lnd = {} as AuthenticatedLnd;
6
6
  const limit = 100;
7
7
  const token = 'token';
8
+ const is_unconfirmed = true;
8
9
 
9
10
  expectError(getInvoices());
10
11
  expectError(getInvoices({}));
11
12
  expectError(getInvoices({lnd, limit, token}));
13
+ expectError(getInvoices({lnd, limit, token, is_unconfirmed}));
12
14
 
13
15
  expectType<GetInvoicesResult>(await getInvoices({lnd}));
14
16
  expectType<GetInvoicesResult>(await getInvoices({lnd, limit}));
17
+ expectType<GetInvoicesResult>(await getInvoices({lnd, limit, is_unconfirmed}));
15
18
  expectType<GetInvoicesResult>(await getInvoices({lnd, token}));
19
+ expectType<GetInvoicesResult>(await getInvoices({lnd, token, is_unconfirmed}));
16
20
 
17
21
  expectType<void>(
18
22
  getInvoices({lnd}, (error, result) => {
@@ -24,8 +28,18 @@ expectType<void>(
24
28
  expectType<GetInvoicesResult>(result);
25
29
  })
26
30
  );
31
+ expectType<void>(
32
+ getInvoices({lnd, limit, is_unconfirmed}, (error, result) => {
33
+ expectType<GetInvoicesResult>(result);
34
+ })
35
+ );
27
36
  expectType<void>(
28
37
  getInvoices({lnd, token}, (error, result) => {
29
38
  expectType<GetInvoicesResult>(result);
30
39
  })
31
40
  );
41
+ expectType<void>(
42
+ getInvoices({lnd, token, is_unconfirmed}, (error, result) => {
43
+ expectType<GetInvoicesResult>(result);
44
+ })
45
+ );