ln-service 54.5.0 → 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
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.
|
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.
|
|
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.
|
|
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.
|
|
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
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
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
|
-
|
|
198
|
-
|
|
199
|
-
|
|
198
|
+
fail('ExpectedChannelCloseRejected');
|
|
199
|
+
} catch (err) {
|
|
200
|
+
const [code, message, raw] = err;
|
|
200
201
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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
|
}
|