ln-service 57.1.3 → 57.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 +9 -0
- package/LICENSE +1 -1
- package/README.md +99 -0
- package/index.js +6 -0
- package/package.json +3 -3
- package/test/integration/test_get_configuration.js +35 -0
- package/test/integration/test_get_forwards.js +9 -5
- package/test/integration/test_get_network_centrality.js +8 -6
- package/test/routerrpc-integration/test_is_destination_payable.js +6 -1
- package/test/routerrpc-integration/test_pay_via_payment_request.js +3 -1
- package/test/walletrpc-integration/test_delete_chain_transaction.js +82 -0
- package/test/walletrpc-integration/test_get_chain_transaction.js +70 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Versions
|
|
2
2
|
|
|
3
|
+
## 57.3.0
|
|
4
|
+
|
|
5
|
+
- `getConfiguration`: Add method to return configuration information
|
|
6
|
+
|
|
7
|
+
## 57.2.0
|
|
8
|
+
|
|
9
|
+
- `deleteChainTransaction`: Add method to delete a chain transaction
|
|
10
|
+
- `getChainTransaction`: Add method to get a chain transaction
|
|
11
|
+
|
|
3
12
|
## 57.1.3
|
|
4
13
|
|
|
5
14
|
- Add support for LND 0.17.3
|
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -153,6 +153,7 @@ for `unlocker` methods.
|
|
|
153
153
|
- [createUnsignedRequest](#createunsignedrequest) - create an unsigned invoice
|
|
154
154
|
- [createWallet](#createwallet) - Make a new wallet
|
|
155
155
|
- [decodePaymentRequest](#decodepaymentrequest) - Decode a Lightning invoice
|
|
156
|
+
- [deleteChainTransaction](#deletechaintransaction) - Remove chain transaction
|
|
156
157
|
- [deleteFailedPayAttempts](#deletefailedpayattempts) - Remove records of
|
|
157
158
|
failed pay attempts
|
|
158
159
|
- [deleteFailedPayments](#deletefailedpayments) - Remove records of payments
|
|
@@ -180,11 +181,13 @@ for `unlocker` methods.
|
|
|
180
181
|
- [getChainBalance](#getchainbalance) - Get the confirmed chain balance
|
|
181
182
|
- [getChainFeeEstimate](#getchainfeeestimate) - Get a chain fee estimate
|
|
182
183
|
- [getChainFeeRate](#getchainfeerate) - Get the fee rate for a conf target
|
|
184
|
+
- [getChainTransaction](#getchaintransaction) - Get single wallet transaction
|
|
183
185
|
- [getChainTransactions](#getchaintransactions) - Get all chain transactions
|
|
184
186
|
- [getChannel](#getchannel) - Get graph information about a channel
|
|
185
187
|
- [getChannelBalance](#getchannelbalance) - Get the balance of channel funds
|
|
186
188
|
- [getChannels](#getchannels) - Get all open channels
|
|
187
189
|
- [getClosedChannels](#getclosedchannels) - Get previously open channels
|
|
190
|
+
- [getConfiguration](#getconfiguration) - Get configuration information
|
|
188
191
|
- [getConnectedWatchtowers](#getconnectedwatchtowers) - Get connected towers
|
|
189
192
|
- [getEphemeralChannelIds](#getephemeralchannelids) - Get other channel ids
|
|
190
193
|
- [getFailedPayments](#getfailedpayments) - Get payments that were failed back
|
|
@@ -966,6 +969,30 @@ const request = 'bolt11EncodedPaymentRequestString';
|
|
|
966
969
|
const details = await decodePaymentRequest({lnd, request});
|
|
967
970
|
```
|
|
968
971
|
|
|
972
|
+
### deleteChainTransaction
|
|
973
|
+
|
|
974
|
+
Remove a chain transaction.
|
|
975
|
+
|
|
976
|
+
Requires `onchain:write` permission
|
|
977
|
+
|
|
978
|
+
This method is not supported on LND 0.17.3 and below
|
|
979
|
+
|
|
980
|
+
{
|
|
981
|
+
id: <Transaction Id Hex String>
|
|
982
|
+
lnd: <Authenticated LND API Object>
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
@returns via cbk or Promise
|
|
986
|
+
|
|
987
|
+
Example:
|
|
988
|
+
|
|
989
|
+
```node
|
|
990
|
+
const {deleteChainTransaction} = require('ln-service');
|
|
991
|
+
|
|
992
|
+
// Eliminate past broadcast chain transaction
|
|
993
|
+
await deleteChainTransaction({id, lnd});
|
|
994
|
+
```
|
|
995
|
+
|
|
969
996
|
### deleteFailedPayAttempts
|
|
970
997
|
|
|
971
998
|
Delete failed payment attempt records
|
|
@@ -1634,6 +1661,47 @@ const {getChainFeeRate} = require('ln-service');
|
|
|
1634
1661
|
const fee = (await getChainFeeRate({lnd, confirmation_target: 6})).tokens_per_vbyte;
|
|
1635
1662
|
```
|
|
1636
1663
|
|
|
1664
|
+
### getChainTransaction
|
|
1665
|
+
|
|
1666
|
+
Get a chain transaction.
|
|
1667
|
+
|
|
1668
|
+
Requires `onchain:read` permission
|
|
1669
|
+
|
|
1670
|
+
This method is not supported on LND 0.17.3 and below
|
|
1671
|
+
|
|
1672
|
+
{
|
|
1673
|
+
id: <Transaction Id Hex String>
|
|
1674
|
+
lnd: <Authenticated LND API Object>
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1677
|
+
@returns via cbk or Promise
|
|
1678
|
+
{
|
|
1679
|
+
[block_id]: <Block Hash String>
|
|
1680
|
+
[confirmation_count]: <Confirmation Count Number>
|
|
1681
|
+
[confirmation_height]: <Confirmation Block Height Number>
|
|
1682
|
+
created_at: <Created ISO 8601 Date String>
|
|
1683
|
+
[description]: <Transaction Label String>
|
|
1684
|
+
[fee]: <Fees Paid Tokens Number>
|
|
1685
|
+
id: <Transaction Id String>
|
|
1686
|
+
inputs: [{
|
|
1687
|
+
is_local: <Spent Outpoint is Local Bool>
|
|
1688
|
+
transaction_id: <Transaction Id Hex String>
|
|
1689
|
+
transaction_vout: <Transaction Output Index Number>
|
|
1690
|
+
}]
|
|
1691
|
+
is_confirmed: <Is Confirmed Bool>
|
|
1692
|
+
is_outgoing: <Transaction Outbound Bool>
|
|
1693
|
+
output_addresses: [<Address String>]
|
|
1694
|
+
tokens: <Tokens Including Fee Number>
|
|
1695
|
+
[transaction]: <Raw Transaction Hex String>
|
|
1696
|
+
}
|
|
1697
|
+
|
|
1698
|
+
Example:
|
|
1699
|
+
|
|
1700
|
+
```node
|
|
1701
|
+
const {getChainTransaction} = require('ln-service');
|
|
1702
|
+
const txIsConfirmed = (await getChainTransaction({id, lnd})).is_confirmed;
|
|
1703
|
+
```
|
|
1704
|
+
|
|
1637
1705
|
### getChainTransactions
|
|
1638
1706
|
|
|
1639
1707
|
Get chain transactions.
|
|
@@ -1905,6 +1973,36 @@ const {getClosedChannels} = require('ln-service');
|
|
|
1905
1973
|
const breachCount = await getClosedChannels({lnd, is_breach_close: true});
|
|
1906
1974
|
```
|
|
1907
1975
|
|
|
1976
|
+
### getConfiguration
|
|
1977
|
+
|
|
1978
|
+
Get the current configuration file settings and the output log
|
|
1979
|
+
|
|
1980
|
+
Requires `info:read`, `offchain:read`, `onchain:read`, `peers:read`
|
|
1981
|
+
permissions
|
|
1982
|
+
|
|
1983
|
+
This method is not supported on LND 0.17.3 and below
|
|
1984
|
+
|
|
1985
|
+
{
|
|
1986
|
+
lnd: <Authenticated LND API Object>
|
|
1987
|
+
}
|
|
1988
|
+
|
|
1989
|
+
@returns via cbk or Promise
|
|
1990
|
+
{
|
|
1991
|
+
log: [<Log Line String>]
|
|
1992
|
+
options: [{
|
|
1993
|
+
type: <Option Type String>
|
|
1994
|
+
value: <Option Value String>
|
|
1995
|
+
}]
|
|
1996
|
+
}
|
|
1997
|
+
|
|
1998
|
+
Example:
|
|
1999
|
+
|
|
2000
|
+
```node
|
|
2001
|
+
const {getConfiguration} = require('ln-service');
|
|
2002
|
+
const {log, options} = await getConfiguration({});
|
|
2003
|
+
const minimumChannelSize = options.find(n => n.type === 'minchansize').value;
|
|
2004
|
+
```
|
|
2005
|
+
|
|
1908
2006
|
### getConnectedWatchtowers
|
|
1909
2007
|
|
|
1910
2008
|
Get a list of connected watchtowers and watchtower info
|
|
@@ -2274,6 +2372,7 @@ Requires `invoices:read` permission
|
|
|
2274
2372
|
[chain_address]: <Fallback Chain Address String>
|
|
2275
2373
|
cltv_delta: <CLTV Delta Number>
|
|
2276
2374
|
[confirmed_at]: <Settled at ISO 8601 Date String>
|
|
2375
|
+
[confirmed_index]: <Confirmed Index Number>
|
|
2277
2376
|
created_at: <ISO 8601 Date String>
|
|
2278
2377
|
description: <Description String>
|
|
2279
2378
|
[description_hash]: <Description Hash Hex String>
|
package/index.js
CHANGED
|
@@ -16,6 +16,7 @@ const {createSignedRequest} = require('invoices');
|
|
|
16
16
|
const {createUnsignedRequest} = require('invoices');
|
|
17
17
|
const {createWallet} = require('lightning');
|
|
18
18
|
const {decodePaymentRequest} = require('lightning');
|
|
19
|
+
const {deleteChainTransaction} = require('lightning');
|
|
19
20
|
const {deleteForwardingReputations} = require('lightning');
|
|
20
21
|
const {deleteFailedPayAttempts} = require('lightning');
|
|
21
22
|
const {deleteFailedPayments} = require('lightning');
|
|
@@ -39,11 +40,13 @@ const {getChainAddresses} = require('lightning');
|
|
|
39
40
|
const {getChainBalance} = require('lightning');
|
|
40
41
|
const {getChainFeeEstimate} = require('lightning');
|
|
41
42
|
const {getChainFeeRate} = require('lightning');
|
|
43
|
+
const {getChainTransaction} = require('lightning');
|
|
42
44
|
const {getChainTransactions} = require('lightning');
|
|
43
45
|
const {getChannel} = require('lightning');
|
|
44
46
|
const {getChannelBalance} = require('lightning');
|
|
45
47
|
const {getChannels} = require('lightning');
|
|
46
48
|
const {getClosedChannels} = require('lightning');
|
|
49
|
+
const {getConfiguration} = require('lightning');
|
|
47
50
|
const {getConnectedWatchtowers} = require('lightning');
|
|
48
51
|
const {getEphemeralChannelIds} = require('lightning');
|
|
49
52
|
const {getFailedPayments} = require('lightning');
|
|
@@ -173,6 +176,7 @@ module.exports = {
|
|
|
173
176
|
createUnsignedRequest,
|
|
174
177
|
createWallet,
|
|
175
178
|
decodePaymentRequest,
|
|
179
|
+
deleteChainTransaction,
|
|
176
180
|
deleteFailedPayAttempts,
|
|
177
181
|
deleteFailedPayments,
|
|
178
182
|
deleteForwardingReputations,
|
|
@@ -196,11 +200,13 @@ module.exports = {
|
|
|
196
200
|
getChainBalance,
|
|
197
201
|
getChainFeeEstimate,
|
|
198
202
|
getChainFeeRate,
|
|
203
|
+
getChainTransaction,
|
|
199
204
|
getChainTransactions,
|
|
200
205
|
getChannel,
|
|
201
206
|
getChannelBalance,
|
|
202
207
|
getChannels,
|
|
203
208
|
getClosedChannels,
|
|
209
|
+
getConfiguration,
|
|
204
210
|
getConnectedWatchtowers,
|
|
205
211
|
getEphemeralChannelIds,
|
|
206
212
|
getFailedPayments,
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"bolt07": "1.8.4",
|
|
11
11
|
"invoices": "3.0.0",
|
|
12
|
-
"lightning": "10.1
|
|
12
|
+
"lightning": "10.3.1",
|
|
13
13
|
"macaroon": "3.0.4"
|
|
14
14
|
},
|
|
15
15
|
"description": "Interaction helper for your Lightning Network daemon",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"bn.js": "5.2.1",
|
|
25
25
|
"bs58check": "3.0.1",
|
|
26
26
|
"ecpair": "2.1.0",
|
|
27
|
-
"ln-docker-daemons": "6.0.
|
|
27
|
+
"ln-docker-daemons": "6.0.7",
|
|
28
28
|
"p2tr": "2.0.0",
|
|
29
29
|
"portfinder": "1.0.32",
|
|
30
30
|
"psbt": "3.0.0",
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"integration-test-0.14.4": "DOCKER_LND_VERSION=v0.14.4-beta npm run test",
|
|
70
70
|
"test": "echo $DOCKER_LND_VERSION && node test/runner"
|
|
71
71
|
},
|
|
72
|
-
"version": "57.
|
|
72
|
+
"version": "57.3.0"
|
|
73
73
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const {deepEqual} = require('node:assert').strict;
|
|
2
|
+
const {equal} = require('node:assert').strict;
|
|
3
|
+
const {ok} = require('node:assert').strict;
|
|
4
|
+
const test = require('node:test');
|
|
5
|
+
|
|
6
|
+
const asyncRetry = require('async/retry');
|
|
7
|
+
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
8
|
+
|
|
9
|
+
const {getConfiguration} = require('./../../');
|
|
10
|
+
const {getWalletInfo} = require('./../../');
|
|
11
|
+
|
|
12
|
+
// Getting the configuration info should return info about the config
|
|
13
|
+
test(`Get configuration info`, async () => {
|
|
14
|
+
const {kill, nodes} = await spawnLightningCluster({});
|
|
15
|
+
|
|
16
|
+
const [{lnd}] = nodes;
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
const {log, options} = await getConfiguration({lnd});
|
|
20
|
+
|
|
21
|
+
ok(!!log.length, 'Got the log lines');
|
|
22
|
+
|
|
23
|
+
const color = options.find(n => n.type === 'color').value.toLowerCase();
|
|
24
|
+
|
|
25
|
+
equal(color, (await getWalletInfo({lnd})).color, 'Got color from config');
|
|
26
|
+
|
|
27
|
+
await kill({});
|
|
28
|
+
} catch (err) {
|
|
29
|
+
await kill({});
|
|
30
|
+
|
|
31
|
+
deepEqual(err, [501, 'GetDebugConfigurationInfoNotSupported'], '404');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return;
|
|
35
|
+
});
|
|
@@ -24,12 +24,16 @@ test('Get forwards', async () => {
|
|
|
24
24
|
|
|
25
25
|
const [{generate, lnd}, target, remote] = nodes;
|
|
26
26
|
|
|
27
|
-
await
|
|
27
|
+
await asyncRetry({interval, times}, async () => {
|
|
28
|
+
await addPeer({lnd, public_key: remote.id, socket: remote.socket});
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
await setupChannel({generate, lnd, to: target});
|
|
31
|
+
|
|
32
|
+
await setupChannel({
|
|
33
|
+
lnd: target.lnd,
|
|
34
|
+
generate: target.generate,
|
|
35
|
+
to: remote,
|
|
36
|
+
});
|
|
33
37
|
});
|
|
34
38
|
|
|
35
39
|
await addPeer({lnd, public_key: remote.id, socket: remote.socket});
|
|
@@ -24,14 +24,16 @@ test(`Get network centrality`, async () => {
|
|
|
24
24
|
try {
|
|
25
25
|
await control.generate({count: 100});
|
|
26
26
|
|
|
27
|
-
await
|
|
27
|
+
await asyncRetry({interval, times}, async () => {
|
|
28
|
+
await addPeer({lnd, public_key: remote.id, socket: remote.socket});
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
await setupChannel({lnd, generate: control.generate, to: target});
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
await setupChannel({
|
|
33
|
+
generate: target.generate,
|
|
34
|
+
lnd: target.lnd,
|
|
35
|
+
to: remote,
|
|
36
|
+
});
|
|
35
37
|
});
|
|
36
38
|
|
|
37
39
|
await asyncRetry({interval, times}, async () => {
|
|
@@ -2,12 +2,15 @@ const {deepEqual} = require('node:assert').strict;
|
|
|
2
2
|
const {equal} = require('node:assert').strict;
|
|
3
3
|
const test = require('node:test');
|
|
4
4
|
|
|
5
|
+
const asyncRetry = require('async/retry');
|
|
5
6
|
const {setupChannel} = require('ln-docker-daemons');
|
|
6
7
|
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
7
8
|
|
|
8
9
|
const {isDestinationPayable} = require('./../../');
|
|
9
10
|
|
|
11
|
+
const interval = 100;
|
|
10
12
|
const size = 2;
|
|
13
|
+
const times = 1000;
|
|
11
14
|
const tokens = 1e6 / 2;
|
|
12
15
|
|
|
13
16
|
// Determining if a route is payable should indicate if a route can be found
|
|
@@ -17,7 +20,9 @@ test('Is destination payable', async () => {
|
|
|
17
20
|
const [{generate, lnd}, target] = nodes;
|
|
18
21
|
|
|
19
22
|
try {
|
|
20
|
-
await
|
|
23
|
+
await asyncRetry({interval, times}, async () => {
|
|
24
|
+
await setupChannel({generate, lnd, to: target});
|
|
25
|
+
});
|
|
21
26
|
|
|
22
27
|
const canPay = await isDestinationPayable({lnd, destination: target.id});
|
|
23
28
|
|
|
@@ -42,7 +42,9 @@ test(`Pay via payment request`, async () => {
|
|
|
42
42
|
}
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
-
const channel = await
|
|
45
|
+
const channel = await asyncRetry({interval, times}, async () => {
|
|
46
|
+
return await setupChannel({generate, lnd, to: target});
|
|
47
|
+
});
|
|
46
48
|
|
|
47
49
|
// Make sure that an error is returned when there is no route
|
|
48
50
|
try {
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
const {deepEqual} = require('node:assert').strict;
|
|
2
|
+
const {equal} = require('node:assert').strict;
|
|
3
|
+
const test = require('node:test');
|
|
4
|
+
|
|
5
|
+
const asyncRetry = require('async/retry');
|
|
6
|
+
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
7
|
+
|
|
8
|
+
const {broadcastChainTransaction} = require('./../../');
|
|
9
|
+
const {createChainAddress} = require('./../../');
|
|
10
|
+
const {deleteChainTransaction} = require('./../../');
|
|
11
|
+
const {fundPsbt} = require('./../../');
|
|
12
|
+
const {getChainTransactions} = require('./../../');
|
|
13
|
+
const {getWalletInfo} = require('./../../');
|
|
14
|
+
const {signPsbt} = require('./../../');
|
|
15
|
+
|
|
16
|
+
const count = 100;
|
|
17
|
+
const defaultFee = 1e3;
|
|
18
|
+
const format = 'np2wpkh';
|
|
19
|
+
const interval = 100;
|
|
20
|
+
const times = 300;
|
|
21
|
+
const tokens = 1e6;
|
|
22
|
+
|
|
23
|
+
// Deleting a chain transaction should delete the chain transactions
|
|
24
|
+
test(`Delete chain transaction`, async () => {
|
|
25
|
+
const {kill, nodes} = await spawnLightningCluster({});
|
|
26
|
+
|
|
27
|
+
const [{generate, lnd}] = nodes;
|
|
28
|
+
|
|
29
|
+
// Generate some funds for LND
|
|
30
|
+
await generate({count});
|
|
31
|
+
|
|
32
|
+
await asyncRetry({interval: 10, times: 6000}, async () => {
|
|
33
|
+
const wallet = await getWalletInfo({lnd});
|
|
34
|
+
|
|
35
|
+
if (!wallet.is_synced_to_chain) {
|
|
36
|
+
throw new Error('ExpectedWalletSyncedToChain');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
await generate({});
|
|
40
|
+
|
|
41
|
+
if (wallet.current_block_height < count + 1) {
|
|
42
|
+
throw new Error('ExpectedFullySyncedToChain');
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Wait for generation to be over
|
|
47
|
+
const tx = await asyncRetry({times}, async () => {
|
|
48
|
+
const {transactions} = await getChainTransactions({lnd});
|
|
49
|
+
|
|
50
|
+
const [tx] = transactions;
|
|
51
|
+
|
|
52
|
+
if (!tx.is_confirmed) {
|
|
53
|
+
throw new Error('ExpectedTransactionConfirmed');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return tx;
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const {address} = await createChainAddress({lnd});
|
|
60
|
+
|
|
61
|
+
const funded = await asyncRetry({interval, times}, async () => {
|
|
62
|
+
await generate({});
|
|
63
|
+
|
|
64
|
+
return await fundPsbt({lnd, outputs: [{address, tokens}]});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const {transaction} = await signPsbt({lnd, psbt: funded.psbt});
|
|
68
|
+
|
|
69
|
+
const {id} = await broadcastChainTransaction({lnd, transaction});
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
await deleteChainTransaction({id, lnd});
|
|
73
|
+
|
|
74
|
+
await kill({});
|
|
75
|
+
} catch (err) {
|
|
76
|
+
await kill({});
|
|
77
|
+
|
|
78
|
+
deepEqual(err, [501, 'RemoveChainTransactionMethodNotSupported'], 'None');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return;
|
|
82
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
const {deepEqual} = require('node:assert').strict;
|
|
2
|
+
const {equal} = require('node:assert').strict;
|
|
3
|
+
const test = require('node:test');
|
|
4
|
+
|
|
5
|
+
const asyncRetry = require('async/retry');
|
|
6
|
+
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
7
|
+
|
|
8
|
+
const {getChainTransaction} = require('./../../');
|
|
9
|
+
const {getChainTransactions} = require('./../../');
|
|
10
|
+
const {getWalletInfo} = require('./../../');
|
|
11
|
+
|
|
12
|
+
const count = 100;
|
|
13
|
+
const defaultFee = 1e3;
|
|
14
|
+
const format = 'np2wpkh';
|
|
15
|
+
const times = 300;
|
|
16
|
+
|
|
17
|
+
// Getting a chain transaction should return the chain transactions
|
|
18
|
+
test(`Get chain transaction`, async () => {
|
|
19
|
+
const {kill, nodes} = await spawnLightningCluster({});
|
|
20
|
+
|
|
21
|
+
const [{generate, lnd}] = nodes;
|
|
22
|
+
|
|
23
|
+
// Generate some funds for LND
|
|
24
|
+
await generate({count});
|
|
25
|
+
|
|
26
|
+
await asyncRetry({interval: 10, times: 6000}, async () => {
|
|
27
|
+
const wallet = await getWalletInfo({lnd});
|
|
28
|
+
|
|
29
|
+
if (!wallet.is_synced_to_chain) {
|
|
30
|
+
throw new Error('ExpectedWalletSyncedToChain');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
await generate({});
|
|
34
|
+
|
|
35
|
+
if (wallet.current_block_height < count + 1) {
|
|
36
|
+
throw new Error('ExpectedFullySyncedToChain');
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Wait for generation to be over
|
|
41
|
+
await asyncRetry({times}, async () => {
|
|
42
|
+
const {transactions} = await getChainTransactions({lnd});
|
|
43
|
+
|
|
44
|
+
const [tx] = transactions;
|
|
45
|
+
|
|
46
|
+
if (!tx.is_confirmed) {
|
|
47
|
+
throw new Error('ExpectedTransactionConfirmed');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return;
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const {transactions} = await getChainTransactions({lnd});
|
|
54
|
+
|
|
55
|
+
const [tx] = transactions;
|
|
56
|
+
|
|
57
|
+
try {
|
|
58
|
+
const singleTx = await getChainTransaction({lnd, id: tx.id});
|
|
59
|
+
|
|
60
|
+
await kill({});
|
|
61
|
+
|
|
62
|
+
deepEqual(singleTx, tx, 'Transactions are the same');
|
|
63
|
+
} catch (err) {
|
|
64
|
+
await kill({});
|
|
65
|
+
|
|
66
|
+
deepEqual(err, [501, 'GetChainTransactionMethodNotSupported'], 'Invalid');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return;
|
|
70
|
+
});
|