lightning 10.2.0 → 10.3.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,13 @@
1
1
  # Versions
2
2
 
3
+ ## 10.3.0
4
+
5
+ - `getConfiguration`: Add method to get the configuration file options
6
+
7
+ ## 10.2.1
8
+
9
+ - `deleteChainTransaction`, `getChainTransaction`: Add types
10
+
3
11
  ## 10.2.0
4
12
 
5
13
  - `deleteChainTransaction`: Add method to delete a chain transaction
@@ -467,7 +475,7 @@
467
475
 
468
476
  ## 4.2.1
469
477
 
470
- - `getChannelBalance`: Corrrect typescript type for `unsettled_balance_mtokens`
478
+ - `getChannelBalance`: Correct typescript type for `unsettled_balance_mtokens`
471
479
  - `subscribeToProbeForRoute`: Correct typescript type for `base_fee_mtokens`
472
480
 
473
481
  ## 4.2.0
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2019-2023 Alex Bosworth
3
+ Copyright (c) 2019-2024 Alex Bosworth
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -167,6 +167,8 @@ variables set:
167
167
  the node.
168
168
  - [getClosedChannels](https://github.com/alexbosworth/ln-service#getclosedchannels): List closed
169
169
  channels on the node.
170
+ - [getConfiguration](https://github.com/alexbosworth/ln-service#getconfiguration):
171
+ Get the configuration file settings for the node and the log.
170
172
  - [getConnectedWatchtowers](https://github.com/alexbosworth/ln-service#getconnectedwatchtowers):
171
173
  List watchtowers that were added
172
174
  - [getEphemeralChannelIds](https://github.com/alexbosworth/ln-service#getephemeralchannelids):
@@ -143,6 +143,13 @@ service Lightning {
143
143
  */
144
144
  rpc GetInfo (GetInfoRequest) returns (GetInfoResponse);
145
145
 
146
+ /* lncli: 'getdebuginfo'
147
+ GetDebugInfo returns debug information concerning the state of the daemon
148
+ and its subsystems. This includes the full configuration and the latest log
149
+ entries from the log file.
150
+ */
151
+ rpc GetDebugInfo (GetDebugInfoRequest) returns (GetDebugInfoResponse);
152
+
146
153
  /** lncli: `getrecoveryinfo`
147
154
  GetRecoveryInfo returns information concerning the recovery mode including
148
155
  whether it's in a recovery mode, whether the recovery is finished, and the
@@ -322,7 +329,7 @@ service Lightning {
322
329
  optionally specify the add_index and/or the settle_index. If the add_index
323
330
  is specified, then we'll first start by sending add invoice events for all
324
331
  invoices with an add_index greater than the specified value. If the
325
- settle_index is specified, the next, we'll send out all settle events for
332
+ settle_index is specified, then next, we'll send out all settle events for
326
333
  invoices with a settle_index greater than the specified value. One or both
327
334
  of these fields can be set. If no fields are set, then we'll only send out
328
335
  the latest add/settle events.
@@ -1952,6 +1959,14 @@ message GetInfoResponse {
1952
1959
  bool store_final_htlc_resolutions = 22;
1953
1960
  }
1954
1961
 
1962
+ message GetDebugInfoRequest {
1963
+ }
1964
+
1965
+ message GetDebugInfoResponse {
1966
+ map<string, string> config = 1;
1967
+ repeated string log = 2;
1968
+ }
1969
+
1955
1970
  message GetRecoveryInfoRequest {
1956
1971
  }
1957
1972
  message GetRecoveryInfoResponse {
@@ -4486,6 +4501,7 @@ message Failure {
4486
4501
  EXPIRY_TOO_FAR = 22;
4487
4502
  MPP_TIMEOUT = 23;
4488
4503
  INVALID_ONION_PAYLOAD = 24;
4504
+ INVALID_ONION_BLINDING = 25;
4489
4505
 
4490
4506
  /*
4491
4507
  An internal error occurred.
@@ -1067,6 +1067,8 @@ message BumpFeeRequest {
1067
1067
  }
1068
1068
 
1069
1069
  message BumpFeeResponse {
1070
+ // The status of the bump fee operation.
1071
+ string status = 1;
1070
1072
  }
1071
1073
 
1072
1074
  message ListSweepsRequest {
package/index.js CHANGED
@@ -44,6 +44,7 @@ const {getChannel} = require('./lnd_methods');
44
44
  const {getChannelBalance} = require('./lnd_methods');
45
45
  const {getChannels} = require('./lnd_methods');
46
46
  const {getClosedChannels} = require('./lnd_methods');
47
+ const {getConfiguration} = require('./lnd_methods');
47
48
  const {getConnectedWatchtowers} = require('./lnd_methods');
48
49
  const {getEphemeralChannelIds} = require('./lnd_methods');
49
50
  const {getFailedPayments} = require('./lnd_methods');
@@ -198,6 +199,7 @@ module.exports = {
198
199
  getChannelBalance,
199
200
  getChannels,
200
201
  getClosedChannels,
202
+ getConfiguration,
201
203
  getConnectedWatchtowers,
202
204
  getEphemeralChannelIds,
203
205
  getFailedPayments,
@@ -43,6 +43,7 @@ const {getChannel} = require('./info');
43
43
  const {getChannelBalance} = require('./offchain');
44
44
  const {getChannels} = require('./offchain');
45
45
  const {getClosedChannels} = require('./offchain');
46
+ const {getConfiguration} = require('./info');
46
47
  const {getConnectedWatchtowers} = require('./offchain');
47
48
  const {getEphemeralChannelIds} = require('./offchain');
48
49
  const {getFailedPayments} = require('./offchain');
@@ -196,6 +197,7 @@ module.exports = {
196
197
  getChannelBalance,
197
198
  getChannels,
198
199
  getClosedChannels,
200
+ getConfiguration,
199
201
  getConnectedWatchtowers,
200
202
  getEphemeralChannelIds,
201
203
  getFailedPayments,
@@ -0,0 +1,84 @@
1
+ const asyncAuto = require('async/auto');
2
+ const {returnResult} = require('asyncjs-util');
3
+
4
+ const {isLnd} = require('./../../lnd_requests');
5
+
6
+ const asOptions = o => Object.keys(o).map(type => ({type, value: o[type]}));
7
+ const errNotFound = 'unknown method GetDebugInfo for service lnrpc.Lightning';
8
+ const {isArray} = Array;
9
+ const isIncluding = (arr, test) => arr.findIndex(test) !== -1;
10
+ const isNotString = n => typeof n !== 'string';
11
+ const method = 'getDebugInfo';
12
+ const type = 'default';
13
+ const {values} = Object;
14
+
15
+ /** Get the current configuration file settings and the output log
16
+
17
+ Requires `info:read`, `offchain:read`, `onchain:read`, `peers:read`
18
+ permissions
19
+
20
+ This method is not supported on LND 0.17.3 and below
21
+
22
+ {
23
+ lnd: <Authenticated LND API Object>
24
+ }
25
+
26
+ @returns via cbk or Promise
27
+ {
28
+ log: [<Log Line String>]
29
+ options: [{
30
+ type: <Option Type String>
31
+ value: <Option Value String>
32
+ }]
33
+ }
34
+ */
35
+ module.exports = ({lnd}, cbk) => {
36
+ return new Promise((resolve, reject) => {
37
+ return asyncAuto({
38
+ // Check arguments
39
+ validate: cbk => {
40
+ if (!isLnd({lnd, method, type})) {
41
+ return cbk([400, 'ExpectedAuthenticatedLndGrpcForGetConfigRequest']);
42
+ }
43
+
44
+ return cbk();
45
+ },
46
+
47
+ // Get configuration info
48
+ getInfo: ['validate', ({}, cbk) => {
49
+ return lnd[type][method]({}, (err, res) => {
50
+ if (!!err && err.details === errNotFound) {
51
+ return cbk([501, 'GetDebugConfigurationInfoNotSupported']);
52
+ }
53
+
54
+ if (!!err) {
55
+ return cbk([503, 'UnexpectedGetDebugInfoError', {err}]);
56
+ }
57
+
58
+ if (!res) {
59
+ return cbk([503, 'ExpectedResponseForGetConfigurationRequest']);
60
+ }
61
+
62
+ if (!isArray(res.log)) {
63
+ return cbk([503, 'ExpectedLogInConfigurationResponse']);
64
+ }
65
+
66
+ if (isIncluding(res.log, isNotString)) {
67
+ return cbk([503, 'ExpectedAllLogEntriesAsStrings']);
68
+ }
69
+
70
+ if (!res.config) {
71
+ return cbk([503, 'ExpectedArrayOfConfigurationOptionsInResponse']);
72
+ }
73
+
74
+ if (isIncluding(values(res.config), isNotString)) {
75
+ return cbk([503, 'ExpectedAllConfigOptionsAsStrings']);
76
+ }
77
+
78
+ return cbk(null, {log: res.log, options: asOptions(res.config)});
79
+ });
80
+ }],
81
+ },
82
+ returnResult({reject, resolve, of: 'getInfo'}, cbk));
83
+ });
84
+ };
@@ -1,5 +1,6 @@
1
1
  const getAutopilot = require('./get_autopilot');
2
2
  const getChannel = require('./get_channel');
3
+ const getConfiguration = require('./get_configuration');
3
4
  const getIdentity = require('./get_identity');
4
5
  const getMethods = require('./get_methods');
5
6
  const getNetworkCentrality = require('./get_network_centrality');
@@ -16,6 +17,7 @@ const subscribeToGraph = require('./subscribe_to_graph');
16
17
  module.exports = {
17
18
  getAutopilot,
18
19
  getChannel,
20
+ getConfiguration,
19
21
  getIdentity,
20
22
  getMethods,
21
23
  getNetworkCentrality,
@@ -173,6 +173,10 @@
173
173
  "method": "ClosedChannels",
174
174
  "type": "default"
175
175
  },
176
+ "getConfiguration": {
177
+ "method": "GetDebugInfo",
178
+ "type": "default"
179
+ },
176
180
  "getConnectedWatchtowers": {
177
181
  "methods": ["ListTowers", "Policy", "Stats"],
178
182
  "type": "tower_client"
@@ -17,7 +17,7 @@ export type SubscribeToOpenRequestsChannelRequestEvent = {
17
17
  remote_max_htlcs?: number;
18
18
  /** Maximum HTLCs Value Millitokens */
19
19
  remote_max_pending_mtokens?: string;
20
- /** Minimium HTLC Value Millitokens */
20
+ /** Minimum HTLC Value Millitokens */
21
21
  remote_min_htlc_mtokens?: string;
22
22
  }) => void;
23
23
  /** Capacity Tokens */
@@ -41,7 +41,7 @@ const type = 'default';
41
41
  [remote_reserve]: <Minimum Tokens Peer Must Keep On Their Side Number>
42
42
  [remote_max_htlcs]: <Maximum Slots For Attaching HTLCs Number>
43
43
  [remote_max_pending_mtokens]: <Maximum HTLCs Value Millitokens String>
44
- [remote_min_htlc_mtokens]: <Minimium HTLC Value Millitokens String>
44
+ [remote_min_htlc_mtokens]: <Minimum HTLC Value Millitokens String>
45
45
  }) -> {}
46
46
  capacity: <Capacity Tokens Number>
47
47
  chain: <Chain Id Hex String>
@@ -0,0 +1,19 @@
1
+ import {
2
+ AuthenticatedLightningArgs,
3
+ AuthenticatedLightningMethod,
4
+ } from '../../typescript';
5
+
6
+ export type DeleteChainTransactionArgs = AuthenticatedLightningArgs<{
7
+ /** Transaction Id Hex String */
8
+ id: string;
9
+ }>;
10
+
11
+ /**
12
+ *
13
+ * Remove a chain transaction.
14
+ *
15
+ * Requires `onchain:write` permission
16
+ *
17
+ * This method is not supported on LND 0.17.3 and below
18
+ */
19
+ export const deleteChainTransaction: AuthenticatedLightningMethod<DeleteChainTransactionArgs>;
@@ -0,0 +1,24 @@
1
+ import {
2
+ AuthenticatedLightningArgs,
3
+ AuthenticatedLightningMethod,
4
+ } from '../../typescript';
5
+ import {ChainTransaction} from './get_chain_transactions';
6
+
7
+ export type GetChainTransactionArgs = AuthenticatedLightningArgs<{
8
+ /** Transaction Id Hex String */
9
+ id: string;
10
+ }>;
11
+
12
+ export type GetChainTransactionResult = ChainTransaction;
13
+
14
+ /**
15
+ * Get a chain transaction.
16
+ *
17
+ * Requires `onchain:read` permission
18
+ *
19
+ * This method is not supported on LND 0.17.3 and below
20
+ */
21
+ export const getChainTransaction: AuthenticatedLightningMethod<
22
+ GetChainTransactionArgs,
23
+ GetChainTransactionResult
24
+ >;
@@ -1,6 +1,7 @@
1
1
  export * from './broadcast_chain_transaction';
2
2
  export * from './cancel_pending_channel';
3
3
  export * from './close_channel';
4
+ export * from './delete_chain_transaction';
4
5
  export * from './fund_pending_channels';
5
6
  export * from './fund_psbt';
6
7
  export * from './get_block';
@@ -9,6 +10,7 @@ export * from './get_chain_addresses';
9
10
  export * from './get_chain_balance';
10
11
  export * from './get_chain_fee_estimate';
11
12
  export * from './get_chain_fee_rate';
13
+ export * from './get_chain_transaction';
12
14
  export * from './get_chain_transactions';
13
15
  export * from './get_locked_utxos';
14
16
  export * from './get_master_public_keys';
package/package.json CHANGED
@@ -7,9 +7,9 @@
7
7
  "url": "https://github.com/alexbosworth/lightning/issues"
8
8
  },
9
9
  "dependencies": {
10
- "@grpc/grpc-js": "1.9.13",
10
+ "@grpc/grpc-js": "1.9.14",
11
11
  "@grpc/proto-loader": "0.7.10",
12
- "@types/node": "20.10.4",
12
+ "@types/node": "20.11.5",
13
13
  "@types/request": "2.48.12",
14
14
  "@types/ws": "8.5.10",
15
15
  "async": "3.2.5",
@@ -22,11 +22,11 @@
22
22
  "invoices": "3.0.0",
23
23
  "psbt": "3.0.0",
24
24
  "tiny-secp256k1": "2.2.3",
25
- "type-fest": "4.8.3"
25
+ "type-fest": "4.9.0"
26
26
  },
27
27
  "description": "Lightning Network client library",
28
28
  "devDependencies": {
29
- "tsd": "0.29.0",
29
+ "tsd": "0.30.4",
30
30
  "typescript": "5.3.3"
31
31
  },
32
32
  "engines": {
@@ -53,5 +53,5 @@
53
53
  "directory": "test/typescript"
54
54
  },
55
55
  "types": "index.d.ts",
56
- "version": "10.2.0"
56
+ "version": "10.3.0"
57
57
  }
@@ -0,0 +1,81 @@
1
+ const {deepStrictEqual} = require('node:assert').strict;
2
+ const {rejects} = require('node:assert').strict;
3
+ const test = require('node:test');
4
+
5
+ const {getConfiguration} = require('./../../../');
6
+
7
+ const makeLnd = ({custom, err, res}) => {
8
+ const response = {config: {type: 'value'}, log: ['log']};
9
+
10
+ return {
11
+ default: {
12
+ getDebugInfo: ({}, cbk) => cbk(err, res !== undefined ? res : response),
13
+ },
14
+ };
15
+ };
16
+
17
+ const tests = [
18
+ {
19
+ args: {},
20
+ description: 'LND is required to get configuration info',
21
+ error: [400, 'ExpectedAuthenticatedLndGrpcForGetConfigRequest'],
22
+ },
23
+ {
24
+ args: {
25
+ lnd: makeLnd({
26
+ err: {
27
+ details: 'unknown method GetDebugInfo for service lnrpc.Lightning',
28
+ },
29
+ }),
30
+ },
31
+ description: 'Unknown service returns unsupported info',
32
+ error: [501, 'GetDebugConfigurationInfoNotSupported'],
33
+ },
34
+ {
35
+ args: {lnd: makeLnd({err: 'err'})},
36
+ description: 'Generic failure returns back the error',
37
+ error: [503, 'UnexpectedGetDebugInfoError', {err: 'err'}],
38
+ },
39
+ {
40
+ args: {lnd: makeLnd({res: null})},
41
+ description: 'Valid result is expected',
42
+ error: [503, 'ExpectedResponseForGetConfigurationRequest'],
43
+ },
44
+ {
45
+ args: {lnd: makeLnd({res: {}})},
46
+ description: 'Result should have a log',
47
+ error: [503, 'ExpectedLogInConfigurationResponse'],
48
+ },
49
+ {
50
+ args: {lnd: makeLnd({res: {log: [1]}})},
51
+ description: 'Result should have a log with strings',
52
+ error: [503, 'ExpectedAllLogEntriesAsStrings'],
53
+ },
54
+ {
55
+ args: {lnd: makeLnd({res: {log: []}})},
56
+ description: 'Result should have a config',
57
+ error: [503, 'ExpectedArrayOfConfigurationOptionsInResponse'],
58
+ },
59
+ {
60
+ args: {lnd: makeLnd({res: {config: {type: 1}, log: []}})},
61
+ description: 'Result should have a config',
62
+ error: [503, 'ExpectedAllConfigOptionsAsStrings'],
63
+ },
64
+ {
65
+ args: {lnd: makeLnd({})},
66
+ description: 'Configuration is returned',
67
+ expected: {log: ['log'], options: [{type: 'type', value: 'value'}]},
68
+ },
69
+ ];
70
+
71
+ tests.forEach(({args, description, error, expected}) => {
72
+ return test(description, async () => {
73
+ if (!!error) {
74
+ await rejects(() => getConfiguration(args), error, 'Got error');
75
+ } else {
76
+ deepStrictEqual(await getConfiguration(args), expected, 'Got info');
77
+ }
78
+
79
+ return;
80
+ });
81
+ });
@@ -42,7 +42,7 @@ const sendToRouteFailure = {
42
42
  const makeLnd = ({count, getInfo, sendToRouteV2}) => {
43
43
  let returnedRoutes = 0;
44
44
 
45
- const defaultSendTo = ({}, cbk) => cbk(null, {faillure: sendToRouteFailure});
45
+ const defaultSendTo = ({}, cbk) => cbk(null, {});
46
46
 
47
47
  const lnd = {
48
48
  default: {
@@ -38,7 +38,7 @@ const tests = [
38
38
  lnd: {default: {estimateFee: ({}, cbk) => cbk('err')}},
39
39
  send_to: [{address: 'address', tokens: 1}],
40
40
  },
41
- description: 'An error is pased back from fee estimate',
41
+ description: 'An error is passed back from fee estimate',
42
42
  error: [503, 'UnexpectedErrEstimatingFeeForChainSend', {err: 'err'}],
43
43
  },
44
44
  {