lightning 5.0.1 → 5.1.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
+ ## 5.1.0
4
+
5
+ - Add support for LND 0.14.1
6
+ - `openChannels`: Add `is_avoiding_broadcast` to avoid all funding broadcast
7
+
3
8
  ## 5.0.1
4
9
 
5
10
  - `createChainAddress`: Fix type hints to reflect optionality of `format`
package/README.md CHANGED
@@ -52,10 +52,6 @@ To access unauthenticated methods like the wallet unlocker, use
52
52
 
53
53
  ## Methods
54
54
 
55
- There are two libraries, [ln-service](https://github.com/alexbosworth/ln-service) and this library.
56
-
57
- Methods exported by this library support typescript, but ln-service includes additional metthods.
58
-
59
55
  - [addPeer](https://github.com/alexbosworth/ln-service#addpeer): Connect to a new peer
60
56
  - [authenticatedLndGrpc](https://github.com/alexbosworth/ln-service#authenticatedlndgrpc):
61
57
  Instantiate connection to authenticated lnd methods.
@@ -24,6 +24,7 @@
24
24
  "4f567577db9d85b6f392f960b3aabddcad3cd02c": "0.13.3-beta",
25
25
  "52bb3f33707b81972c67937c7a89addcdf00991c": "0.10.1-beta",
26
26
  "596fd90ef310cd7abbf2251edaae9ba4d5f8a689": "0.13.1-beta",
27
+ "6042004edaaa5b3cad0a0808ff23dba4716f7178": "0.14.1-beta",
27
28
  "61c34683058f2cc8dc10f49392a0057440d831c4": "0.13.4-beta",
28
29
  "725ff104808f49f0a5247bfdb4b6b5da7f488d38": "0.13.0-beta",
29
30
  "7f34774529fa0964d47fc418d4d2965435cbfdc0": "0.11.1-beta",
@@ -24,32 +24,32 @@ const type = 'default';
24
24
 
25
25
  @returns via cbk or Promise
26
26
  */
27
- module.exports = ({channels, funding, lnd}, cbk) => {
27
+ module.exports = (args, cbk) => {
28
28
  return new Promise((resolve, reject) => {
29
29
  return asyncAuto({
30
30
  // Check arguments
31
31
  validate: cbk => {
32
- if (!isArray(channels)) {
32
+ if (!isArray(args.channels)) {
33
33
  return cbk([400, 'ExpectedPendingChannelIdsToFundChannels']);
34
34
  }
35
35
 
36
- if (!channels.length) {
36
+ if (!args.channels.length) {
37
37
  return cbk([400, 'ExpectedPendingChannelIdsToFund']);
38
38
  }
39
39
 
40
- if (channels.filter(n => !n).length) {
40
+ if (args.channels.filter(n => !n).length) {
41
41
  return cbk([400, 'ExpectedNonEmptyPendingChannelIdsToFund']);
42
42
  }
43
43
 
44
- if (!!channels.find(n => !isHash(n))) {
44
+ if (!!args.channels.find(n => !isHash(n))) {
45
45
  return cbk([400, 'ExpectedPendingChannelIdOfChannelToFund']);
46
46
  }
47
47
 
48
- if (!isHex(funding)) {
48
+ if (!isHex(args.funding)) {
49
49
  return cbk([400, 'ExpectedFundingPsbtToFundChannel']);
50
50
  }
51
51
 
52
- if (!isLnd({lnd, method, type})) {
52
+ if (!isLnd({method, type, lnd: args.lnd})) {
53
53
  return cbk([400, 'ExpectedAuthenticatedLndToFundChannels']);
54
54
  }
55
55
 
@@ -57,12 +57,12 @@ module.exports = ({channels, funding, lnd}, cbk) => {
57
57
  },
58
58
 
59
59
  // Funded and signed PSBT
60
- psbt: ['validate', ({}, cbk) => cbk(null, bufferFromHex(funding))],
60
+ psbt: ['validate', ({}, cbk) => cbk(null, bufferFromHex(args.funding))],
61
61
 
62
62
  // Verify the funding for each pending channel
63
63
  verify: ['psbt', 'validate', ({psbt}, cbk) => {
64
- return asyncEach(channels, (id, cbk) => {
65
- return lnd[type][method]({
64
+ return asyncEach(args.channels, (id, cbk) => {
65
+ return args.lnd[type][method]({
66
66
  psbt_verify: {
67
67
  funded_psbt: psbt,
68
68
  pending_chan_id: bufferFromHex(id),
@@ -81,10 +81,10 @@ module.exports = ({channels, funding, lnd}, cbk) => {
81
81
 
82
82
  // Finalize the psbts
83
83
  finalize: ['psbt', 'verify', ({psbt}, cbk) => {
84
- const [lastChannel] = channels.slice().reverse();
84
+ const [lastChannel] = args.channels.slice().reverse();
85
85
 
86
- return asyncEachSeries(channels, (id, cbk) => {
87
- return lnd[type][method]({
86
+ return asyncEachSeries(args.channels, (id, cbk) => {
87
+ return args.lnd[type][method]({
88
88
  psbt_finalize: {
89
89
  no_publish: id !== lastChannel,
90
90
  pending_chan_id: bufferFromHex(id),
@@ -22,6 +22,8 @@ export type OpenChannelsArgs = AuthenticatedLightningArgs<{
22
22
  /** Peer Connection Host:Port */
23
23
  partner_socket?: string;
24
24
  }[];
25
+ /** Do not broadcast any channel funding transactions */
26
+ is_avoiding_broadcast?: boolean;
25
27
  }>;
26
28
 
27
29
  export type OpenChannelsResult = {
@@ -29,6 +29,9 @@ const type = 'default';
29
29
  If you do not fund the channels, be sure to `cancelPendingChannel` on each
30
30
  channel that was not funded.
31
31
 
32
+ Use `is_avoiding_broadcast` only when self-publishing the raw transaction
33
+ after the funding step.
34
+
32
35
  {
33
36
  channels: [{
34
37
  capacity: <Channel Capacity Tokens Number>
@@ -40,6 +43,7 @@ const type = 'default';
40
43
  [partner_csv_delay]: <Peer Output CSV Delay Number>
41
44
  [partner_socket]: <Peer Connection Host:Port String>
42
45
  }]
46
+ is_avoiding_broadcast: <Avoid Broadcast of All Channels Bool>
43
47
  lnd: <Authenticated LND API Object>
44
48
  }
45
49
 
@@ -52,28 +56,28 @@ const type = 'default';
52
56
  }]
53
57
  }
54
58
  */
55
- module.exports = ({channels, lnd}, cbk) => {
59
+ module.exports = (args, cbk) => {
56
60
  return new Promise((resolve, reject) => {
57
61
  return asyncAuto({
58
62
  // Check arguments
59
63
  validate: cbk => {
60
- if (!isArray(channels)) {
64
+ if (!isArray(args.channels)) {
61
65
  return cbk([400, 'ExpectedChannelsToOpenChannels']);
62
66
  }
63
67
 
64
- if (channels.filter(n => !!n).length !== channels.length) {
68
+ if (args.channels.filter(n => !!n).length !== args.channels.length) {
65
69
  return cbk([400, 'ExpectedChannelDetailsToOpenChannels']);
66
70
  }
67
71
 
68
- if (!!channels.find(n => !n.capacity)) {
72
+ if (!!args.channels.find(n => !n.capacity)) {
69
73
  return cbk([400, 'ExpectedCapacityOfChannelsToOpenChannels']);
70
74
  }
71
75
 
72
- if (!!channels.find(n => !isPublicKey(n.partner_public_key))) {
76
+ if (!!args.channels.find(n => !isPublicKey(n.partner_public_key))) {
73
77
  return cbk([400, 'ExpectedPeerPublicKeyToOpenChannels']);
74
78
  }
75
79
 
76
- if (!isLnd({lnd, method, type})) {
80
+ if (!isLnd({method, type, lnd: args.lnd})) {
77
81
  return cbk([400, 'ExpectedAuthenticatedLndToOpenChannels']);
78
82
  }
79
83
 
@@ -82,7 +86,7 @@ module.exports = ({channels, lnd}, cbk) => {
82
86
 
83
87
  // Channels to open
84
88
  toOpen: ['validate', ({}, cbk) => {
85
- return cbk(null, channels.map(channel => ({
89
+ return cbk(null, args.channels.map(channel => ({
86
90
  capacity: channel.capacity,
87
91
  id: makeId(),
88
92
  cooperative_close_address: channel.cooperative_close_address,
@@ -101,11 +105,12 @@ module.exports = ({channels, lnd}, cbk) => {
101
105
 
102
106
  return asyncMap(toOpen, (channel, cbk) => {
103
107
  let isDone = false;
108
+ const isSelfPublish = !!args.is_avoiding_broadcast;
104
109
 
105
- const channelOpen = lnd[type][method]({
110
+ const channelOpen = args.lnd[type][method]({
106
111
  funding_shim: {
107
112
  psbt_shim: {
108
- no_publish: !channel.id.equals(lastChannel),
113
+ no_publish: !!isSelfPublish || !channel.id.equals(lastChannel),
109
114
  pending_chan_id: channel.id,
110
115
  },
111
116
  },
@@ -183,7 +188,7 @@ module.exports = ({channels, lnd}, cbk) => {
183
188
  return asyncEach(toOpen, (channel, cbk) => {
184
189
  const id = hexFromBuffer(channel.id);
185
190
 
186
- return cancelPendingChannel({id, lnd}, () => cbk());
191
+ return cancelPendingChannel({id, lnd: args.lnd}, () => cbk());
187
192
  },
188
193
  () => {
189
194
  return cbk([503, 'UnexpectedErrorOpeningChannels', {err}]);
package/package.json CHANGED
@@ -10,12 +10,12 @@
10
10
  "@grpc/grpc-js": "1.4.4",
11
11
  "@grpc/proto-loader": "0.6.7",
12
12
  "@types/express": "4.17.13",
13
- "@types/node": "16.11.9",
13
+ "@types/node": "16.11.10",
14
14
  "@types/request": "2.48.7",
15
15
  "@types/ws": "8.2.0",
16
16
  "async": "3.2.2",
17
17
  "asyncjs-util": "1.2.7",
18
- "bitcoinjs-lib": "6.0.0",
18
+ "bitcoinjs-lib": "6.0.1",
19
19
  "bn.js": "5.2.0",
20
20
  "body-parser": "1.19.0",
21
21
  "bolt07": "1.7.4",
@@ -32,7 +32,7 @@
32
32
  "@alexbosworth/tap": "15.0.10",
33
33
  "tsd": "0.19.0",
34
34
  "typescript": "4.5.2",
35
- "ws": "8.2.3"
35
+ "ws": "8.3.0"
36
36
  },
37
37
  "engines": {
38
38
  "node": ">=12"
@@ -57,5 +57,5 @@
57
57
  "directory": "test/typescript"
58
58
  },
59
59
  "types": "index.d.ts",
60
- "version": "5.0.1"
60
+ "version": "5.1.0"
61
61
  }