lightning 7.1.1 → 7.1.3

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,6 @@
1
1
  # Versions
2
2
 
3
- ## 7.1.1
3
+ ## 7.1.3
4
4
 
5
5
  - `signChainAddressMessage`: Add method to sign a message given a chain address
6
6
  - `verifyChainAddressMessage`: Add method to verify a chain address message
@@ -582,16 +582,22 @@ service Lightning {
582
582
  */
583
583
  rpc ListAliases (ListAliasesRequest) returns (ListAliasesResponse);
584
584
 
585
- rpc LookupHtlc (LookupHtlcRequest) returns (LookupHtlcResponse);
585
+ /*
586
+ LookupHtlcResolution retrieves a final htlc resolution from the database.
587
+ If the htlc has no final resolution yet, a NotFound grpc status code is
588
+ returned.
589
+ */
590
+ rpc LookupHtlcResolution (LookupHtlcResolutionRequest)
591
+ returns (LookupHtlcResolutionResponse);
586
592
  }
587
593
 
588
- message LookupHtlcRequest {
594
+ message LookupHtlcResolutionRequest {
589
595
  uint64 chan_id = 1;
590
596
 
591
597
  uint64 htlc_index = 2;
592
598
  }
593
599
 
594
- message LookupHtlcResponse {
600
+ message LookupHtlcResolutionResponse {
595
601
  bool settled = 1;
596
602
 
597
603
  bool offchain = 2;
@@ -1531,6 +1537,9 @@ message Channel {
1531
1537
 
1532
1538
  // This is the confirmed / on-chain zero-conf SCID.
1533
1539
  uint64 zero_conf_confirmed_scid = 33;
1540
+
1541
+ // The configured alias name of our peer.
1542
+ string peer_alias = 34;
1534
1543
  }
1535
1544
 
1536
1545
  message ListChannelsRequest {
@@ -1544,6 +1553,11 @@ message ListChannelsRequest {
1544
1553
  empty, all channels will be returned.
1545
1554
  */
1546
1555
  bytes peer = 5;
1556
+
1557
+ // Informs the server if the peer alias lookup per channel should be
1558
+ // enabled. It is turned off by default in order to avoid degradation of
1559
+ // performance for existing clients.
1560
+ bool peer_alias_lookup = 6;
1547
1561
  }
1548
1562
  message ListChannelsResponse {
1549
1563
  // The list of active channels
@@ -285,7 +285,7 @@
285
285
  "type": "default"
286
286
  },
287
287
  "getSettlementStatus": {
288
- "method": "LookupHtlc",
288
+ "method": "LookupHtlcResolution",
289
289
  "type": "default"
290
290
  },
291
291
  "getSweepTransactions": {
@@ -22,6 +22,8 @@ export type GetSettlementStatusResult = {
22
22
  *
23
23
  * Note: this method is not supported in LND versions 0.15.5 and below
24
24
  *
25
+ * Requires LND running with `--store-final-htlc-resolutions` flag
26
+ *
25
27
  * Requires `offchain:read` permissions
26
28
  */
27
29
  export const getSettlementStatus: AuthenticatedLightningMethod<
@@ -5,15 +5,18 @@ const {returnResult} = require('asyncjs-util');
5
5
  const {isLnd} = require('./../../lnd_requests');
6
6
 
7
7
  const errorNotFound = 'htlc unknown';
8
- const errorUnimplemented = 'unknown method LookupHtlc for service lnrpc.Lightning';
8
+ const errorUninitiated = 'cannot lookup with flag --store-final-htlc-resolutions=false';
9
+ const errorUnimplemented = 'unknown method LookupHtlcResolution for service lnrpc.Lightning';
9
10
  const isBoolean = n => n === false || n === true;
10
- const method = 'lookupHtlc';
11
+ const method = 'lookupHtlcResolution';
11
12
  const type = 'default';
12
13
 
13
14
  /** Get the settlement status of a received HTLC
14
15
 
15
16
  Note: this method is not supported in LND versions 0.15.5 and below
16
17
 
18
+ Requires LND running with `--store-final-htlc-resolutions` flag
19
+
17
20
  Requires `offchain:read` permissions
18
21
 
19
22
  {
@@ -60,7 +63,11 @@ module.exports = ({channel, lnd, payment}, cbk) => {
60
63
  }
61
64
 
62
65
  if (!!err && err.details === errorUnimplemented) {
63
- return cbk([501, 'LookupHtlcMethodUnsupported']);
66
+ return cbk([501, 'LookupHtlcResolutionMethodUnsupported']);
67
+ }
68
+
69
+ if (!!err && err.details == errorUninitiated) {
70
+ return cbk([404, 'LookupHtlcResolutionMethodUninitiated']);
64
71
  }
65
72
 
66
73
  if (!!err) {
@@ -7,6 +7,7 @@ const {isLnd} = require('./../../lnd_requests');
7
7
  const bufFromHex = hex => Buffer.from(hex, 'hex');
8
8
  const {fromHex} = Transaction;
9
9
  const method = 'publishTransaction';
10
+ const minRelayFeeError = /^unmatched backend error: -26: mempool min fee not met, (\d*) < (\d*)$/;
10
11
  const type = 'wallet';
11
12
 
12
13
  /** Publish a raw blockchain transaction to Blockchain network peers
@@ -51,6 +52,19 @@ module.exports = ({description, lnd, transaction}, cbk) => {
51
52
  tx_hex: bufFromHex(transaction),
52
53
  },
53
54
  (err, res) => {
55
+ if (!!err && minRelayFeeError.test(err.details)) {
56
+ const [, got, expected] = err.details.match(minRelayFeeError);
57
+
58
+ return cbk([
59
+ 503,
60
+ 'ChainBackendMinimumRelayFeeNotMet',
61
+ {
62
+ fee: Number(got),
63
+ minimum: Number(expected),
64
+ }
65
+ ]);
66
+ }
67
+
54
68
  if (!!err) {
55
69
  return cbk([503, 'UnexpectedErrBroadcastingRawTx', {err}]);
56
70
  }
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.8.11",
10
+ "@grpc/grpc-js": "1.8.12",
11
11
  "@grpc/proto-loader": "0.7.5",
12
12
  "@types/express": "4.17.17",
13
- "@types/node": "18.14.1",
13
+ "@types/node": "18.14.6",
14
14
  "@types/request": "2.48.8",
15
15
  "@types/ws": "8.5.4",
16
16
  "async": "3.2.4",
@@ -32,7 +32,7 @@
32
32
  "devDependencies": {
33
33
  "@alexbosworth/node-fetch": "2.6.2",
34
34
  "@alexbosworth/tap": "15.0.12",
35
- "tsd": "0.25.0",
35
+ "tsd": "0.26.1",
36
36
  "typescript": "4.9.5",
37
37
  "ws": "8.12.1"
38
38
  },
@@ -59,5 +59,5 @@
59
59
  "directory": "test/typescript"
60
60
  },
61
61
  "types": "index.d.ts",
62
- "version": "7.1.1"
62
+ "version": "7.1.3"
63
63
  }
@@ -5,7 +5,7 @@ const {getSettlementStatus} = require('./../../../');
5
5
  const makeLnd = ({err, res}) => {
6
6
  const result = res === undefined ? {offchain: true, settled: true} : res;
7
7
 
8
- return {default: {lookupHtlc: ({}, cbk) => cbk(err, result)}};
8
+ return {default: {lookupHtlcResolution: ({}, cbk) => cbk(err, result)}};
9
9
  };
10
10
 
11
11
  const makeArgs = overrides => {
@@ -38,9 +38,26 @@ const tests = [
38
38
  error: [404, 'PaymentNotFound'],
39
39
  },
40
40
  {
41
- args: makeArgs({lnd: makeLnd({err: {details: 'unknown method LookupHtlc for service lnrpc.Lightning'}})}),
41
+ args: makeArgs({
42
+ lnd: makeLnd({
43
+ err: {
44
+ details: 'unknown method LookupHtlcResolution for service lnrpc.Lightning',
45
+ },
46
+ }),
47
+ }),
42
48
  description: 'A method not supported error is returned',
43
- error: [501, 'LookupHtlcMethodUnsupported'],
49
+ error: [501, 'LookupHtlcResolutionMethodUnsupported'],
50
+ },
51
+ {
52
+ args: makeArgs({
53
+ lnd: makeLnd({
54
+ err: {
55
+ details: 'cannot lookup with flag --store-final-htlc-resolutions=false',
56
+ },
57
+ }),
58
+ }),
59
+ description: 'A method not supported error is returned',
60
+ error: [404, 'LookupHtlcResolutionMethodUninitiated'],
44
61
  },
45
62
  {
46
63
  args: makeArgs({lnd: makeLnd({err: 'err'})}),
@@ -46,6 +46,27 @@ const tests = [
46
46
  {res: {publish_error: 'err'}},
47
47
  ],
48
48
  },
49
+ {
50
+ args: {
51
+ lnd: {
52
+ wallet: {
53
+ publishTransaction: ({}, cbk) => cbk({
54
+ details: 'unmatched backend error: -26: mempool min fee not met, 123 < 1234',
55
+ }),
56
+ },
57
+ },
58
+ transaction: new Transaction().toHex(),
59
+ },
60
+ description: 'Minimum relay fee not met',
61
+ error: [
62
+ 503,
63
+ 'ChainBackendMinimumRelayFeeNotMet',
64
+ {
65
+ fee: 123,
66
+ minimum: 1234,
67
+ },
68
+ ],
69
+ },
49
70
  {
50
71
  args: {
51
72
  lnd: {wallet: {publishTransaction: ({}, cbk) => cbk(null, {})}},
@@ -5,7 +5,7 @@ const {beginGroupSigningSession} = require('./../../../');
5
5
  const makeLnd = (err, res) => {
6
6
  return {
7
7
  signer: {
8
- muSig2CreateSession: ({}, cbk) => cbk(err, res)
8
+ muSig2CreateSession: ({}, cbk) => cbk(err, res),
9
9
  },
10
10
  wallet: {
11
11
  deriveKey: ({}, cbk) => cbk(null, {
@@ -84,6 +84,153 @@ const tests = [
84
84
  description: 'A valid response is expected',
85
85
  error: [503, 'ExpectedCombinedPublicKeyInMuSig2SessionResponse'],
86
86
  },
87
+ {
88
+ args: makeArgs({
89
+ lnd: {
90
+ signer: {
91
+ muSig2CreateSession: (args, cbk) => {
92
+ if (args.version === 'MUSIG2_VERSION_V100RC2') {
93
+ return cbk({
94
+ details: 'error parsing signer public key 0: bad pubkey byte string size (want 32, have 33)',
95
+ });
96
+ }
97
+
98
+ return cbk({
99
+ details: 'unknown method MuSig2CreateSession for service signrpc.Signer',
100
+ });
101
+ },
102
+ },
103
+ wallet: {
104
+ deriveKey: ({}, cbk) => cbk(null, {
105
+ key_loc: {key_index: 0},
106
+ raw_key_bytes: Buffer.alloc(1),
107
+ }),
108
+ },
109
+ },
110
+ }),
111
+ description: 'Just in case unsupported message is supported',
112
+ error: [501, 'MuSig2BeginSigningSessionNotSupported'],
113
+ },
114
+ {
115
+ args: makeArgs({
116
+ lnd: {
117
+ signer: {
118
+ muSig2CreateSession: (args, cbk) => {
119
+ if (args.version === 'MUSIG2_VERSION_V100RC2') {
120
+ return cbk({
121
+ details: 'error parsing signer public key 0: bad pubkey byte string size (want 32, have 33)',
122
+ });
123
+ }
124
+
125
+ return cbk('err');
126
+ },
127
+ },
128
+ wallet: {
129
+ deriveKey: ({}, cbk) => cbk(null, {
130
+ key_loc: {key_index: 0},
131
+ raw_key_bytes: Buffer.alloc(1),
132
+ }),
133
+ },
134
+ },
135
+ }),
136
+ description: 'Errors are passed back',
137
+ error: [503, 'UnexpectedErrorCreatingMuSig2Session', {err: 'err'}],
138
+ },
139
+ {
140
+ args: makeArgs({
141
+ lnd: {
142
+ signer: {
143
+ muSig2CreateSession: (args, cbk) => {
144
+ if (args.version === 'MUSIG2_VERSION_V100RC2') {
145
+ return cbk({
146
+ details: 'error parsing signer public key 0: bad pubkey byte string size (want 32, have 33)',
147
+ });
148
+ }
149
+
150
+ return cbk(null, {});
151
+ },
152
+ },
153
+ wallet: {
154
+ deriveKey: ({}, cbk) => cbk(null, {
155
+ key_loc: {key_index: 0},
156
+ raw_key_bytes: Buffer.alloc(1),
157
+ }),
158
+ },
159
+ },
160
+ }),
161
+ description: 'A valid response is expected',
162
+ error: [503, 'ExpectedCombinedPublicKeyInMuSig2SessionResponse'],
163
+ },
164
+ {
165
+ args: makeArgs({
166
+ lnd: {
167
+ signer: {
168
+ muSig2CreateSession: (args, cbk) => {
169
+ if (args.version === 'MUSIG2_VERSION_V100RC2') {
170
+ return cbk({
171
+ details: 'error parsing signer public key 0: bad pubkey byte string size (want 32, have 33)',
172
+ });
173
+ }
174
+
175
+ return cbk(null, {
176
+ combined_key: Buffer.alloc(32, 1),
177
+ local_public_nonces: Buffer.alloc(66, 1),
178
+ session_id: Buffer.alloc(32, 1),
179
+ taproot_internal_key: Buffer.alloc(0),
180
+ });
181
+ },
182
+ },
183
+ wallet: {
184
+ deriveKey: ({}, cbk) => cbk(null, {
185
+ key_loc: {key_index: 0},
186
+ raw_key_bytes: Buffer.alloc(1),
187
+ }),
188
+ },
189
+ },
190
+ }),
191
+ description: 'Legacy signer is supported',
192
+ expected: {
193
+ external_key: '0101010101010101010101010101010101010101010101010101010101010101',
194
+ id: '0101010101010101010101010101010101010101010101010101010101010101',
195
+ internal_key: undefined,
196
+ nonce: '010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101',
197
+ },
198
+ },
199
+ {
200
+ args: makeArgs({
201
+ lnd: {
202
+ signer: {
203
+ muSig2CreateSession: (args, cbk) => {
204
+ if (args.version === 'MUSIG2_VERSION_V100RC2') {
205
+ return cbk({
206
+ details: 'error parsing all signer public keys: error parsing signer public key 0 for v1.0.0rc2 (compressed format): malformed public key: invalid length: 32',
207
+ });
208
+ }
209
+
210
+ return cbk(null, {
211
+ combined_key: Buffer.alloc(32, 1),
212
+ local_public_nonces: Buffer.alloc(66, 1),
213
+ session_id: Buffer.alloc(32, 1),
214
+ taproot_internal_key: Buffer.alloc(0),
215
+ });
216
+ },
217
+ },
218
+ wallet: {
219
+ deriveKey: ({}, cbk) => cbk(null, {
220
+ key_loc: {key_index: 0},
221
+ raw_key_bytes: Buffer.alloc(1),
222
+ }),
223
+ },
224
+ },
225
+ }),
226
+ description: 'Legacy signer is supported when invalid keys specified',
227
+ expected: {
228
+ external_key: '0101010101010101010101010101010101010101010101010101010101010101',
229
+ id: '0101010101010101010101010101010101010101010101010101010101010101',
230
+ internal_key: undefined,
231
+ nonce: '010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101',
232
+ },
233
+ },
87
234
  {
88
235
  args: makeArgs({}),
89
236
  description: 'A group signing session is started',