ln-service 54.4.1 → 54.6.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,15 @@
1
1
  # Versions
2
2
 
3
+ ## 54.6.0
4
+
5
+ - `getBlock`: Add method to retrieve the raw bytes of a block in the chain
6
+
7
+ ## 54.5.0
8
+
9
+ - `getFailedPayments`, `getInvoices`, `getPayments`, `getPendingPayments`: add
10
+ support for date based filtering with `created_after` and `created_before`
11
+ arguments
12
+
3
13
  ## 54.4.1
4
14
 
5
15
  - `subscribeToRpcRequests`: `open_channel_request` add support for
package/README.md CHANGED
@@ -139,6 +139,7 @@ for `unlocker` methods.
139
139
  - [getAutopilot](#getautopilot) - Get autopilot status or node scores
140
140
  - [getBackup](#getbackup) - Get a backup of a channel
141
141
  - [getBackups](#getbackups) - Get a backup for all channels
142
+ - [getBlock](#getblock) - Get the raw block data given a block id in the chain
142
143
  - [getChainBalance](#getchainbalance) - Get the confirmed chain balance
143
144
  - [getChainFeeEstimate](#getchainfeeestimate) - Get a chain fee estimate
144
145
  - [getChainFeeRate](#getchainfeerate) - Get the fee rate for a conf target
@@ -1408,6 +1409,38 @@ const {getBackups} = require('ln-service');
1408
1409
  const {backup} = await getBackups({lnd});
1409
1410
  ```
1410
1411
 
1412
+ ### getBlock
1413
+
1414
+ Get a block in the chain
1415
+
1416
+ This method requires LND built with `chainkit` build tag
1417
+
1418
+ Requires `onchain:read` permission
1419
+
1420
+ This method is not supported on LND 0.15.5 and below
1421
+
1422
+ {
1423
+ id: <Block Hash Hex String>
1424
+ lnd: <Authenticated LND API Object>
1425
+ }
1426
+
1427
+ @returns via cbk or Promise
1428
+ {
1429
+ block: <Raw Block Bytes Hex String>
1430
+ }
1431
+
1432
+ Example:
1433
+
1434
+ ```node
1435
+ const {getBlock, getHeight} = require('ln-service');
1436
+
1437
+ const chain = await getHeight({lnd});
1438
+
1439
+ const {block} = await getBlock({lnd, id: chain.current_block_hash});
1440
+
1441
+ const lastBlockSize = Buffer.from(block, 'hex').byteLength();
1442
+ ```
1443
+
1411
1444
  ### getChainBalance
1412
1445
 
1413
1446
  Get balance on the chain.
@@ -1832,7 +1865,12 @@ Get failed payments made through channels.
1832
1865
 
1833
1866
  Requires `offchain:read` permission
1834
1867
 
1868
+ `created_after` is not supported on LND 0.15.5 and below
1869
+ `created_before` is not supported on LND 0.15.5 and below
1870
+
1835
1871
  {
1872
+ [created_after]: <Creation Date After or Equal to ISO 8601 Date String>
1873
+ [created_before]: <Creation Date Before or Equal to ISO 8601 Date String>
1836
1874
  [limit]: <Page Result Limit Number>
1837
1875
  lnd: <Authenticated LND API Object>
1838
1876
  [token]: <Opaque Paging Token String>
@@ -2176,7 +2214,12 @@ Requires `invoices:read` permission
2176
2214
 
2177
2215
  Invoice `payment` is not supported on LND 0.11.1 and below
2178
2216
 
2217
+ `created_after` is not supported on LND 0.15.5 and below
2218
+ `created_before` is not supported on LND 0.15.5 and below
2219
+
2179
2220
  {
2221
+ [created_after]: <Creation Date After or Equal to ISO 8601 Date String>
2222
+ [created_before]: <Creation Date Before or Equal to ISO 8601 Date String>
2180
2223
  [is_unconfirmed]: <Omit Canceled and Settled Invoices Bool>
2181
2224
  [limit]: <Page Result Limit Number>
2182
2225
  lnd: <Authenticated LND API Object>
@@ -2631,7 +2674,12 @@ Get payments made through channels.
2631
2674
 
2632
2675
  Requires `offchain:read` permission
2633
2676
 
2677
+ `created_after` is not supported on LND 0.15.5 and below
2678
+ `created_before` is not supported on LND 0.15.5 and below
2679
+
2634
2680
  {
2681
+ [created_after]: <Creation Date After or Equal to ISO 8601 Date String>
2682
+ [created_before]: <Creation Date Before or Equal to ISO 8601 Date String>
2635
2683
  [limit]: <Page Result Limit Number>
2636
2684
  lnd: <Authenticated LND API Object>
2637
2685
  [token]: <Opaque Paging Token String>
@@ -2848,7 +2896,12 @@ Get pending payments made through channels.
2848
2896
 
2849
2897
  Requires `offchain:read` permission
2850
2898
 
2899
+ `created_after` is not supported on LND 0.15.5 and below
2900
+ `created_before` is not supported on LND 0.15.5 and below
2901
+
2851
2902
  {
2903
+ [created_after]: <Creation Date After or Equal to ISO 8601 Date String>
2904
+ [created_before]: <Creation Date Before or Equal to ISO 8601 Date String>
2852
2905
  [limit]: <Page Result Limit Number>
2853
2906
  lnd: <Authenticated LND API Object>
2854
2907
  [token]: <Opaque Paging Token String>
package/index.js CHANGED
@@ -33,6 +33,7 @@ const {getAccessIds} = require('lightning');
33
33
  const {getAutopilot} = require('lightning');
34
34
  const {getBackup} = require('lightning');
35
35
  const {getBackups} = require('lightning');
36
+ const {getBlock} = require('lightning');
36
37
  const {getChainBalance} = require('lightning');
37
38
  const {getChainFeeEstimate} = require('lightning');
38
39
  const {getChainFeeRate} = require('lightning');
@@ -185,6 +186,7 @@ module.exports = {
185
186
  getAutopilot,
186
187
  getBackup,
187
188
  getBackups,
189
+ getBlock,
188
190
  getChainBalance,
189
191
  getChainFeeEstimate,
190
192
  getChainFeeRate,
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "cors": "2.8.5",
12
12
  "express": "4.18.2",
13
13
  "invoices": "2.2.2",
14
- "lightning": "6.4.1",
14
+ "lightning": "6.6.0",
15
15
  "macaroon": "3.0.4",
16
16
  "morgan": "1.10.0",
17
17
  "ws": "8.11.0"
@@ -28,7 +28,7 @@
28
28
  "bn.js": "5.2.1",
29
29
  "bs58check": "2.1.2",
30
30
  "ecpair": "2.1.0",
31
- "ln-docker-daemons": "4.0.0",
31
+ "ln-docker-daemons": "4.0.2",
32
32
  "p2tr": "1.3.2",
33
33
  "portfinder": "1.0.32",
34
34
  "psbt": "2.7.1",
@@ -64,5 +64,5 @@
64
64
  "integration-test-0.14.4": "DOCKER_LND_VERSION=v0.14.4-beta npm run test",
65
65
  "test": "echo $DOCKER_LND_VERSION && tap -j 2 --branches=1 --functions=1 --lines=1 --statements=1 -t 200 test/autopilotrpc-integration/*.js test/chainrpc-integration/*.js test/integration/*.js test/invoicesrpc-integration/*.js test/peersrpc-integration/*.js test/routerrpc-integration/*.js test/signerrpc-integration/*.js test/tower_clientrpc-integration/*.js test/tower_serverrpc-integration/*.js test/walletrpc-integration/*.js"
66
66
  },
67
- "version": "54.4.1"
67
+ "version": "54.6.0"
68
68
  }
@@ -0,0 +1,35 @@
1
+ const asyncRetry = require('async/retry');
2
+ const {Block} = require('bitcoinjs-lib');
3
+ const {spawnLightningCluster} = require('ln-docker-daemons');
4
+ const {test} = require('@alexbosworth/tap');
5
+
6
+ const {getBlock} = require('./../../');
7
+ const {getHeight} = require('./../../');
8
+
9
+ const confirmationCount = 6;
10
+ const {fromHex} = Block;
11
+ const times = 100;
12
+
13
+ // Get height should return height
14
+ test(`Get height`, async ({end, equal, fail}) => {
15
+ const {nodes} = await spawnLightningCluster({});
16
+
17
+ const [{chain, generate, kill, lnd}] = nodes;
18
+
19
+ const blockchain = await getHeight({lnd});
20
+
21
+ try {
22
+ const {block} = await getBlock({lnd, id: blockchain.current_block_hash});
23
+
24
+ equal(fromHex(block).getId(), blockchain.current_block_hash, 'Got block');
25
+ } catch (err) {
26
+ const [code, message] = err;
27
+
28
+ equal(code, 501, 'Got expected code');
29
+ equal(message, 'GetBlockMethodNotSupported', 'Got expected message');
30
+ }
31
+
32
+ await kill({});
33
+
34
+ return end();
35
+ });
@@ -185,23 +185,29 @@ test(`Subscribe to RPC requests`, async ({end, equal, fail, strictSame}) => {
185
185
  }
186
186
  });
187
187
 
188
- try {
189
- // Attempt a channel close with an address
190
- await closeChannel({
191
- lnd,
192
- address: 'address',
193
- transaction_id: Buffer.alloc(32).toString('hex'),
194
- transaction_vout: 0,
195
- });
188
+ await asyncRetry({interval, times}, async () => {
189
+ try {
190
+ // Attempt a channel close with an address
191
+ await closeChannel({
192
+ lnd,
193
+ address: 'address',
194
+ transaction_id: Buffer.alloc(32).toString('hex'),
195
+ transaction_vout: 0,
196
+ });
196
197
 
197
- fail('ExpectedChannelCloseRejected');
198
- } catch (err) {
199
- const [code, message, raw] = err;
198
+ fail('ExpectedChannelCloseRejected');
199
+ } catch (err) {
200
+ const [code, message, raw] = err;
200
201
 
201
- strictSame(code, 503, 'Close fails with server error');
202
- strictSame(message, 'UnexpectedCloseChannelError', 'Close err message');
203
- strictSame(raw.err.details, 'message', 'Custom message received');
204
- }
202
+ if (raw.err.details !== 'message') {
203
+ throw err;
204
+ }
205
+
206
+ strictSame(code, 503, 'Close fails with server error');
207
+ strictSame(message, 'UnexpectedCloseChannelError', 'Close err message');
208
+ strictSame(raw.err.details, 'message', 'Custom message received');
209
+ }
210
+ });
205
211
 
206
212
  subscription.removeAllListeners();
207
213
  }