ln-service 53.2.0 → 53.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,6 +1,10 @@
1
1
  # Versions
2
2
 
3
- ## 54.2.0
3
+ ## 53.3.0
4
+
5
+ - `getInvoices`: Add `is_unconfirmed` to filter out canceled/settled invoices
6
+
7
+ ## 53.2.0
4
8
 
5
9
  - `getPendingChannels`: Add support for channel `capacity`
6
10
 
package/README.md CHANGED
@@ -1952,6 +1952,7 @@ Requires `invoices:read` permission
1952
1952
  Invoice `payment` is not supported on LND 0.11.1 and below
1953
1953
 
1954
1954
  {
1955
+ [is_unconfirmed]: <Omit Canceled and Settled Invoices Bool>
1955
1956
  [limit]: <Page Result Limit Number>
1956
1957
  lnd: <Authenticated LND API Object>
1957
1958
  [token]: <Opaque Paging Token String>
package/package.json CHANGED
@@ -7,30 +7,31 @@
7
7
  "url": "https://github.com/alexbosworth/ln-service/issues"
8
8
  },
9
9
  "dependencies": {
10
- "bolt07": "1.7.4",
10
+ "bolt07": "1.8.0",
11
11
  "cors": "2.8.5",
12
- "express": "4.17.1",
12
+ "express": "4.17.2",
13
13
  "invoices": "2.0.2",
14
- "lightning": "5.2.1",
14
+ "lightning": "5.3.0",
15
15
  "macaroon": "3.0.4",
16
16
  "morgan": "1.10.0",
17
- "ws": "8.3.0"
17
+ "ws": "8.4.0"
18
18
  },
19
19
  "description": "Interaction helper for your Lightning Network daemon",
20
20
  "devDependencies": {
21
21
  "@alexbosworth/tap": "15.0.10",
22
22
  "@alexbosworth/node-fetch": "2.6.2",
23
- "async": "3.2.2",
23
+ "async": "3.2.3",
24
24
  "asyncjs-util": "1.2.7",
25
25
  "bip66": "1.1.5",
26
26
  "bitcoinjs-lib": "6.0.1",
27
27
  "bn.js": "5.2.0",
28
- "ecpair": "1.0.1",
28
+ "ecpair": "2.0.1",
29
29
  "ln-docker-daemons": "2.1.0",
30
30
  "portfinder": "1.0.28",
31
31
  "psbt": "1.1.10",
32
32
  "rimraf": "3.0.2",
33
- "secp256k1": "4.0.2",
33
+ "secp256k1": "4.0.3",
34
+ "tiny-secp256k1": "2.1.2",
34
35
  "uuid": "8.3.2",
35
36
  "varuint-bitcoin": "1.1.2"
36
37
  },
@@ -54,5 +55,5 @@
54
55
  "scripts": {
55
56
  "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/routerrpc-integration/*.js test/signerrpc-integration/*.js test/tower_clientrpc-integration/*.js test/tower_serverrpc-integration/*.js test/walletrpc-integration/*.js"
56
57
  },
57
- "version": "53.2.0"
58
+ "version": "53.3.0"
58
59
  }
@@ -1,13 +1,15 @@
1
+ const asyncEach = require('async/each');
1
2
  const {spawnLightningCluster} = require('ln-docker-daemons');
2
3
  const {test} = require('@alexbosworth/tap');
3
4
 
5
+ const {cancelHodlInvoice} = require('./../../');
4
6
  const {createInvoice} = require('./../../');
5
7
  const {getInvoices} = require('./../../');
6
8
 
7
9
  const limit = 1;
8
10
 
9
11
  // createInvoice should result in a created invoice
10
- test(`Create an invoice`, async ({end, equal}) => {
12
+ test(`Create an invoice`, async ({end, equal, strictSame}) => {
11
13
  const {kill, nodes} = await spawnLightningCluster({});
12
14
 
13
15
  try {
@@ -48,6 +50,16 @@ test(`Create an invoice`, async ({end, equal}) => {
48
50
  equal(invoice.secret, expected.secret, 'Payment secret');
49
51
  equal(invoice.tokens, expected.tokens, 'Tokens');
50
52
  });
53
+
54
+ const reversed = invoices.slice().reverse();
55
+
56
+ await asyncEach(reversed.filter((n, i) => !!i), async (invoice) => {
57
+ return await cancelHodlInvoice({lnd, id: invoice.id});
58
+ });
59
+
60
+ const unconfirmed = await getInvoices({limit, lnd, is_unconfirmed: true});
61
+
62
+ strictSame(unconfirmed, thirdPage, 'Pending invoices are ignored');
51
63
  } catch (err) {
52
64
  equal(err, null, 'No error is expected');
53
65
  }
@@ -2,12 +2,11 @@ const {join} = require('path');
2
2
  const {spawn} = require('child_process');
3
3
 
4
4
  const asyncAuto = require('async/auto');
5
- const {ECPair} = require('ecpair');
6
5
  const openPortFinder = require('portfinder');
7
6
  const {networks} = require('bitcoinjs-lib');
8
7
  const {payments} = require('bitcoinjs-lib');
8
+ const tinysecp = require('tiny-secp256k1');
9
9
 
10
- const {fromPublicKey} = ECPair;
11
10
  const knownDaemons = ['btcd'];
12
11
  const localhost = '127.0.0.1';
13
12
  const notFoundIndex = -1;
@@ -37,6 +36,9 @@ const unableToStartServer = /Unable.to.start.server/;
37
36
  */
38
37
  module.exports = (args, cbk) => {
39
38
  return asyncAuto({
39
+ // Import ECPair library
40
+ ecp: async () => (await import('ecpair')).ECPairFactory(tinysecp),
41
+
40
42
  // Check arguments
41
43
  validate: cbk => {
42
44
  if (knownDaemons.indexOf(args.daemon) === notFoundIndex) {
@@ -85,11 +87,16 @@ module.exports = (args, cbk) => {
85
87
  }],
86
88
 
87
89
  // Spin up the chain daemon
88
- spawnDaemon: ['listenPort', 'rpcPort', ({listenPort, rpcPort}, cbk) => {
90
+ spawnDaemon: [
91
+ 'ecp',
92
+ 'listenPort',
93
+ 'rpcPort',
94
+ ({ecp, listenPort, rpcPort}, cbk) =>
95
+ {
89
96
  const miningKey = Buffer.from(args.mining_public_key, 'hex');
90
97
  const network = networks.testnet;
91
98
 
92
- const pubkey = fromPublicKey(miningKey, network).publicKey;
99
+ const pubkey = ecp.fromPublicKey(miningKey, network).publicKey;
93
100
 
94
101
  const daemon = spawn(args.daemon, [
95
102
  '--datadir', args.dir,
@@ -2,13 +2,13 @@ const {encode} = require('varuint-bitcoin');
2
2
 
3
3
  const {address} = require('bitcoinjs-lib');
4
4
  const {crypto} = require('bitcoinjs-lib');
5
- const {ECPair} = require('ecpair');
6
5
  const {networks} = require('bitcoinjs-lib');
7
6
  const {payments} = require('bitcoinjs-lib');
8
7
  const {script} = require('bitcoinjs-lib');
9
- const scriptBufAsScript = require('./script_buffers_as_script');
10
8
  const {Transaction} = require('bitcoinjs-lib');
11
9
 
10
+ const scriptBufAsScript = require('./script_buffers_as_script');
11
+
12
12
  const defaultNetwork = 'testnet';
13
13
  const encodeSignature = script.signature.encode;
14
14
  const hexBase = 16;
@@ -20,6 +20,7 @@ const {toOutputScript} = address;
20
20
 
21
21
  {
22
22
  destination: <Destination Address String>
23
+ ecp: <ECPair Object>
23
24
  fee: <Fee Tokens To Remove From Spend Number>
24
25
  private_key: <WIF Serialized Private Key String>
25
26
  spend_transaction_id: <Transaction Id to Spend Hex String>
@@ -32,11 +33,15 @@ const {toOutputScript} = address;
32
33
  transaction: <Transaction Hex Serialized String>
33
34
  }
34
35
  */
35
- module.exports = (args, cbk) => {
36
+ module.exports = args => {
36
37
  if (!args.destination) {
37
38
  throw new Error('ExpectedDestinationAddressToSendTokensTo');
38
39
  }
39
40
 
41
+ if (!args.ecp) {
42
+ throw new Error('ExpectedEcpairObjectToChainSendTransaction');
43
+ }
44
+
40
45
  if (!args.private_key) {
41
46
  throw new Error('ExpectedPrivateKeyToAuthorizeSend');
42
47
  }
@@ -55,7 +60,7 @@ module.exports = (args, cbk) => {
55
60
 
56
61
  const network = networks[defaultNetwork];
57
62
 
58
- const keyPair = ECPair.fromWIF(args.private_key, network);
63
+ const keyPair = args.ecp.fromWIF(args.private_key, network);
59
64
  const outputScript = toOutputScript(args.destination, network);
60
65
  const tx = new Transaction();
61
66
 
@@ -6,9 +6,9 @@ const {spawn} = require('child_process');
6
6
  const asyncAuto = require('async/auto');
7
7
  const asyncMapSeries = require('async/mapSeries');
8
8
  const asyncRetry = require('async/retry');
9
- const {ECPair} = require('ecpair');
10
9
  const {networks} = require('bitcoinjs-lib');
11
10
  const openPortFinder = require('portfinder');
11
+ const tinysecp = require('tiny-secp256k1');
12
12
 
13
13
  const {changePassword} = require('./../../');
14
14
  const {createSeed} = require('./../../');
@@ -53,6 +53,9 @@ const times = 100;
53
53
  */
54
54
  module.exports = ({network}, cbk) => {
55
55
  return asyncAuto({
56
+ // Import ECPair library
57
+ ecp: async () => (await import('ecpair')).ECPairFactory(tinysecp),
58
+
56
59
  // Find open ports for the listen, REST and RPC ports
57
60
  getPorts: cbk => {
58
61
  return asyncMapSeries(['listen', 'rest', 'rpc'], (_, cbk) => {
@@ -77,14 +80,14 @@ module.exports = ({network}, cbk) => {
77
80
  },
78
81
 
79
82
  // Make a private key for mining rewards
80
- miningKey: cbk => {
81
- const keyPair = ECPair.makeRandom({network: networks.testnet});
83
+ miningKey: ['ecp', ({ecp}, cbk) => {
84
+ const keyPair = ecp.makeRandom({network: networks.testnet});
82
85
 
83
86
  return cbk(null, {
84
87
  private_key: keyPair.toWIF(),
85
88
  public_key: keyPair.publicKey.toString('hex'),
86
89
  });
87
- },
90
+ }],
88
91
 
89
92
  // Spawn a backing chain daemon for lnd
90
93
  spawnChainDaemon: ['miningKey', ({miningKey}, cbk) => {
@@ -3,6 +3,7 @@ const {promisify} = require('util');
3
3
  const asyncAuto = require('async/auto');
4
4
  const asyncEach = require('async/each');
5
5
  const asyncRetry = require('async/retry');
6
+ const tinysecp = require('tiny-secp256k1');
6
7
 
7
8
  const {addPeer} = require('./../../');
8
9
  const chainSendTransaction = require('./chain_send_transaction');
@@ -62,6 +63,9 @@ const tokens = 50e8;
62
63
  */
63
64
  module.exports = (args, cbk) => {
64
65
  return asyncAuto({
66
+ // Import ECPair library
67
+ ecp: async () => (await import('ecpair')).ECPairFactory(tinysecp),
68
+
65
69
  // Create control lnd
66
70
  control: cbk => {
67
71
  return spawnLnd({
@@ -225,11 +229,13 @@ module.exports = (args, cbk) => {
225
229
  funding: [
226
230
  'control',
227
231
  'controlChainAddress',
232
+ 'ecp',
228
233
  'generateBlocks',
229
234
  'targetChainAddress',
230
235
  ({
231
236
  control,
232
237
  controlChainAddress,
238
+ ecp,
233
239
  generateBlocks,
234
240
  targetChainAddress,
235
241
  },
@@ -243,6 +249,7 @@ module.exports = (args, cbk) => {
243
249
  const [targetCoinbase] = targetBlock.transaction_ids;
244
250
 
245
251
  const controlChainSend = chainSendTransaction({
252
+ ecp,
246
253
  tokens,
247
254
  destination: controlChainAddress.address,
248
255
  fee: defaultFee,
@@ -252,6 +259,7 @@ module.exports = (args, cbk) => {
252
259
  });
253
260
 
254
261
  const targetChainSend = chainSendTransaction({
262
+ ecp,
255
263
  tokens,
256
264
  destination: targetChainAddress.address,
257
265
  fee: defaultFee,
@@ -2,14 +2,13 @@ const asyncAuto = require('async/auto');
2
2
  const asyncMap = require('async/map');
3
3
  const asyncTimesSeries = require('async/timesSeries');
4
4
  const asyncRetry = require('async/retry');
5
- const {ECPair} = require('ecpair');
6
5
  const {networks} = require('bitcoinjs-lib');
7
6
  const {payments} = require('bitcoinjs-lib');
8
7
  const {returnResult} = require('asyncjs-util');
8
+ const tinysecp = require('tiny-secp256k1');
9
9
 
10
10
  const rpc = require('./rpc');
11
11
 
12
- const {fromPublicKey} = ECPair;
13
12
  const interval = retryCount => 2000 * Math.random();
14
13
  const {p2pkh} = payments;
15
14
  const retryTimes = 50;
@@ -35,6 +34,9 @@ const retryTimes = 50;
35
34
  module.exports = ({cert, chain, count, host, key, pass, port, user}, cbk) => {
36
35
  return new Promise((resolve, reject) => {
37
36
  return asyncAuto({
37
+ // Import ECPair library
38
+ ecp: async () => (await import('ecpair')).ECPairFactory(tinysecp),
39
+
38
40
  // Check arguments
39
41
  validate: cbk => {
40
42
  if (!host) {
@@ -57,7 +59,7 @@ module.exports = ({cert, chain, count, host, key, pass, port, user}, cbk) => {
57
59
  },
58
60
 
59
61
  // Generate blocks
60
- generate: ['validate', ({}, cbk) => {
62
+ generate: ['ecp', 'validate', ({ecp}, cbk) => {
61
63
  let cmd;
62
64
  let params;
63
65
 
@@ -66,7 +68,7 @@ module.exports = ({cert, chain, count, host, key, pass, port, user}, cbk) => {
66
68
  const miningKey = Buffer.from(key, 'hex');
67
69
  const network = networks.testnet;
68
70
 
69
- const pubkey = fromPublicKey(miningKey, network).publicKey;
71
+ const pubkey = ecp.fromPublicKey(miningKey, network).publicKey;
70
72
 
71
73
  cmd = 'generatetoaddress';
72
74
  params = [[count].length, p2pkh({network, pubkey}).address];
@@ -7,9 +7,9 @@ const asyncAuto = require('async/auto');
7
7
  const asyncMap = require('async/map');
8
8
  const asyncMapSeries = require('async/mapSeries');
9
9
  const asyncRetry = require('async/retry');
10
- const {ECPair} = require('ecpair');
11
10
  const {networks} = require('bitcoinjs-lib');
12
11
  const openPortFinder = require('portfinder');
12
+ const tinysecp = require('tiny-secp256k1');
13
13
 
14
14
  const {authenticatedLndGrpc} = require('./../../');
15
15
  const {createSeed} = require('./../../');
@@ -79,6 +79,9 @@ const times = 30;
79
79
  */
80
80
  module.exports = (args, cbk) => {
81
81
  return asyncAuto({
82
+ // Import ECPair library
83
+ ecp: async () => (await import('ecpair')).ECPairFactory(tinysecp),
84
+
82
85
  // Find open ports for the listen, REST and RPC ports
83
86
  getPorts: cbk => {
84
87
  return asyncRetry({interval: n => round(random() * 100), times: 1000}, cbk => {
@@ -112,14 +115,14 @@ module.exports = (args, cbk) => {
112
115
  },
113
116
 
114
117
  // Make a private key for mining rewards
115
- miningKey: cbk => {
116
- const keyPair = ECPair.makeRandom({network: networks.testnet});
118
+ miningKey: ['ecp', ({ecp}, cbk) => {
119
+ const keyPair = ecp.makeRandom({network: networks.testnet});
117
120
 
118
121
  return cbk(null, {
119
122
  private_key: keyPair.toWIF(),
120
123
  public_key: keyPair.publicKey.toString('hex'),
121
124
  });
122
- },
125
+ }],
123
126
 
124
127
  // Spawn a backing chain daemon for lnd
125
128
  spawnChainDaemon: ['miningKey', ({miningKey}, cbk) => {
@@ -1,4 +1,5 @@
1
1
  const {test} = require('@alexbosworth/tap');
2
+ const tinysecp = require('tiny-secp256k1');
2
3
 
3
4
  const {broadcastChainTransaction} = require('./../../');
4
5
  const {chainSendTransaction} = require('./../macros');
@@ -32,6 +33,7 @@ test(`Send chain transaction`, async ({end, equal}) => {
32
33
  fee,
33
34
  tokens,
34
35
  destination: (await createChainAddress({format, lnd})).address,
36
+ ecp: (await import('ecpair')).ECPairFactory(tinysecp),
35
37
  private_key: node.mining_key,
36
38
  spend_transaction_id: coinbaseTransactionId,
37
39
  spend_vout: defaultVout,
@@ -1,4 +1,5 @@
1
1
  const {test} = require('@alexbosworth/tap');
2
+ const tinysecp = require('tiny-secp256k1');
2
3
 
3
4
  const {broadcastChainTransaction} = require('./../../');
4
5
  const {chainSendTransaction} = require('./../macros');
@@ -31,6 +32,7 @@ test(`Request chain fee increase`, async ({end, equal}) => {
31
32
  fee,
32
33
  tokens,
33
34
  destination: (await createChainAddress({format, lnd})).address,
35
+ ecp: (await import('ecpair')).ECPairFactory(tinysecp),
34
36
  private_key: node.mining_key,
35
37
  spend_transaction_id: coinbaseTransactionId,
36
38
  spend_vout: defaultVout,