ln-service 57.1.2 → 57.2.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,14 @@
1
1
  # Versions
2
2
 
3
+ ## 57.2.0
4
+
5
+ - `deleteChainTransaction`: Add method to delete a chain transaction
6
+ - `getChainTransaction`: Add method to get a chain transaction
7
+
8
+ ## 57.1.3
9
+
10
+ - Add support for LND 0.17.3
11
+
3
12
  ## 57.1.2
4
13
 
5
14
  - Add support for LND 0.17.2
package/README.md CHANGED
@@ -9,7 +9,7 @@ through npm.
9
9
 
10
10
  Supported LND versions:
11
11
 
12
- - v0.17.0-beta to v0.17.2-beta
12
+ - v0.17.0-beta to v0.17.3-beta
13
13
  - v0.16.0-beta to v0.16.4-beta
14
14
  - v0.15.2-beta to v0.15.5-beta
15
15
  - v0.14.4-beta to v0.14.5-beta
@@ -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,6 +181,7 @@ 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
@@ -966,6 +968,30 @@ const request = 'bolt11EncodedPaymentRequestString';
966
968
  const details = await decodePaymentRequest({lnd, request});
967
969
  ```
968
970
 
971
+ ### deleteChainTransaction
972
+
973
+ Remove a chain transaction.
974
+
975
+ Requires `onchain:write` permission
976
+
977
+ This method is not supported on LND 0.17.3 and below
978
+
979
+ {
980
+ id: <Transaction Id Hex String>
981
+ lnd: <Authenticated LND API Object>
982
+ }
983
+
984
+ @returns via cbk or Promise
985
+
986
+ Example:
987
+
988
+ ```node
989
+ const {deleteChainTransaction} = require('ln-service');
990
+
991
+ // Eliminate past broadcast chain transaction
992
+ await deleteChainTransaction({id, lnd});
993
+ ```
994
+
969
995
  ### deleteFailedPayAttempts
970
996
 
971
997
  Delete failed payment attempt records
@@ -1634,6 +1660,47 @@ const {getChainFeeRate} = require('ln-service');
1634
1660
  const fee = (await getChainFeeRate({lnd, confirmation_target: 6})).tokens_per_vbyte;
1635
1661
  ```
1636
1662
 
1663
+ ### getChainTransaction
1664
+
1665
+ Get a chain transaction.
1666
+
1667
+ Requires `onchain:read` permission
1668
+
1669
+ This method is not supported on LND 0.17.3 and below
1670
+
1671
+ {
1672
+ id: <Transaction Id Hex String>
1673
+ lnd: <Authenticated LND API Object>
1674
+ }
1675
+
1676
+ @returns via cbk or Promise
1677
+ {
1678
+ [block_id]: <Block Hash String>
1679
+ [confirmation_count]: <Confirmation Count Number>
1680
+ [confirmation_height]: <Confirmation Block Height Number>
1681
+ created_at: <Created ISO 8601 Date String>
1682
+ [description]: <Transaction Label String>
1683
+ [fee]: <Fees Paid Tokens Number>
1684
+ id: <Transaction Id String>
1685
+ inputs: [{
1686
+ is_local: <Spent Outpoint is Local Bool>
1687
+ transaction_id: <Transaction Id Hex String>
1688
+ transaction_vout: <Transaction Output Index Number>
1689
+ }]
1690
+ is_confirmed: <Is Confirmed Bool>
1691
+ is_outgoing: <Transaction Outbound Bool>
1692
+ output_addresses: [<Address String>]
1693
+ tokens: <Tokens Including Fee Number>
1694
+ [transaction]: <Raw Transaction Hex String>
1695
+ }
1696
+
1697
+ Example:
1698
+
1699
+ ```node
1700
+ const {getChainTransaction} = require('ln-service');
1701
+ const txIsConfirmed = (await getChainTransaction({id, lnd})).is_confirmed;
1702
+ ```
1703
+
1637
1704
  ### getChainTransactions
1638
1705
 
1639
1706
  Get chain transactions.
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,6 +40,7 @@ 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');
@@ -173,6 +175,7 @@ module.exports = {
173
175
  createUnsignedRequest,
174
176
  createWallet,
175
177
  decodePaymentRequest,
178
+ deleteChainTransaction,
176
179
  deleteFailedPayAttempts,
177
180
  deleteFailedPayments,
178
181
  deleteForwardingReputations,
@@ -196,6 +199,7 @@ module.exports = {
196
199
  getChainBalance,
197
200
  getChainFeeEstimate,
198
201
  getChainFeeRate,
202
+ getChainTransaction,
199
203
  getChainTransactions,
200
204
  getChannel,
201
205
  getChannelBalance,
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.3",
12
+ "lightning": "10.2.0",
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.5",
27
+ "ln-docker-daemons": "6.0.6",
28
28
  "p2tr": "2.0.0",
29
29
  "portfinder": "1.0.32",
30
30
  "psbt": "3.0.0",
@@ -52,6 +52,8 @@
52
52
  "url": "https://github.com/alexbosworth/ln-service.git"
53
53
  },
54
54
  "scripts": {
55
+ "integration-test-0.17.3": "DOCKER_LND_VERSION=v0.17.3-beta npm run test",
56
+ "integration-test-0.17.2": "DOCKER_LND_VERSION=v0.17.2-beta npm run test",
55
57
  "integration-test-0.17.1": "DOCKER_LND_VERSION=v0.17.1-beta npm run test",
56
58
  "integration-test-0.17.0": "DOCKER_LND_VERSION=v0.17.0-beta npm run test",
57
59
  "integration-test-0.16.4": "DOCKER_LND_VERSION=v0.16.4-beta npm run test",
@@ -67,5 +69,5 @@
67
69
  "integration-test-0.14.4": "DOCKER_LND_VERSION=v0.14.4-beta npm run test",
68
70
  "test": "echo $DOCKER_LND_VERSION && node test/runner"
69
71
  },
70
- "version": "57.1.2"
72
+ "version": "57.2.0"
71
73
  }
@@ -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
+ });