ln-service 53.7.1 → 53.7.2

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.
@@ -3,6 +3,7 @@ const {address} = require('bitcoinjs-lib');
3
3
  const {decodePsbt} = require('psbt');
4
4
  const {spawnLightningCluster} = require('ln-docker-daemons');
5
5
  const {test} = require('@alexbosworth/tap');
6
+ const tinysecp = require('tiny-secp256k1');
6
7
 
7
8
  const {createChainAddress} = require('./../../');
8
9
  const {fundPsbt} = require('./../../');
@@ -24,6 +25,8 @@ const txIdHexByteLength = 64;
24
25
 
25
26
  // Funding a transaction should result in a funded PSBT
26
27
  test(`Fund PSBT`, async ({end, equal}) => {
28
+ const ecp = (await import('ecpair')).ECPairFactory(tinysecp);
29
+
27
30
  const {kill, nodes} = await spawnLightningCluster({});
28
31
 
29
32
  const [{generate, lnd}] = nodes;
@@ -86,7 +89,7 @@ test(`Fund PSBT`, async ({end, equal}) => {
86
89
 
87
90
  equal(output.output_script, expectedOutput, 'Got expected output script');
88
91
 
89
- const decoded = decodePsbt({psbt: funded.psbt});
92
+ const decoded = decodePsbt({ecp, psbt: funded.psbt});
90
93
 
91
94
  const [decodedInput] = decoded.inputs;
92
95
 
@@ -8,6 +8,7 @@ const {extractTransaction} = require('psbt');
8
8
  const {finalizePsbt} = require('psbt');
9
9
  const {spawnLightningCluster} = require('ln-docker-daemons');
10
10
  const {test} = require('@alexbosworth/tap');
11
+ const tinysecp = require('tiny-secp256k1');
11
12
  const {Transaction} = require('bitcoinjs-lib');
12
13
  const {updatePsbt} = require('psbt');
13
14
 
@@ -30,6 +31,8 @@ const tokens = 1e6;
30
31
 
31
32
  // Partially signing a PSBT should result in a partially signed PSBT
32
33
  test(`Partially sign PSBT`, async ({end, equal, strictSame}) => {
34
+ const ecp = (await import('ecpair')).ECPairFactory(tinysecp);
35
+
33
36
  const {kill, nodes} = await spawnLightningCluster({size});
34
37
 
35
38
  const [control, target, remote] = nodes;
@@ -125,9 +128,9 @@ test(`Partially sign PSBT`, async ({end, equal, strictSame}) => {
125
128
  });
126
129
 
127
130
  // Decode the PSBTs to get signing key details
128
- const controlDecoded = decodePsbt({psbt: controlFund.psbt});
129
- const targetDecoded = decodePsbt({psbt: targetFund.psbt});
130
- const remoteDecoded = decodePsbt({psbt: remoteFund.psbt});
131
+ const controlDecoded = decodePsbt({ecp, psbt: controlFund.psbt});
132
+ const targetDecoded = decodePsbt({ecp, psbt: targetFund.psbt});
133
+ const remoteDecoded = decodePsbt({ecp, psbt: remoteFund.psbt});
131
134
 
132
135
  // Collect all the BIP32 derivations
133
136
  const controlBip32Derivations = controlDecoded.inputs
@@ -157,6 +160,7 @@ test(`Partially sign PSBT`, async ({end, equal, strictSame}) => {
157
160
 
158
161
  // Update the PSBT so that it has the consolidated details
159
162
  const updated = updatePsbt({
163
+ ecp,
160
164
  bip32_derivations: bip32Derivations,
161
165
  psbt: base.psbt,
162
166
  sighashes: inputs.map(input => ({
@@ -175,10 +179,13 @@ test(`Partially sign PSBT`, async ({end, equal, strictSame}) => {
175
179
  });
176
180
 
177
181
  // Finalize the signatures
178
- const finalize = finalizePsbt({psbt: combinePsbts({psbts}).psbt});
182
+ const finalize = finalizePsbt({
183
+ ecp,
184
+ psbt: combinePsbts({ecp, psbts}).psbt,
185
+ });
179
186
 
180
187
  // Pull out the transaction
181
- const {transaction} = extractTransaction({psbt: finalize.psbt});
188
+ const {transaction} = extractTransaction({ecp, psbt: finalize.psbt});
182
189
 
183
190
  // Publish the transaction
184
191
  await broadcastChainTransaction({lnd: control.lnd, transaction});
@@ -3,6 +3,7 @@ const {address} = require('bitcoinjs-lib');
3
3
  const {decodePsbt} = require('psbt');
4
4
  const {spawnLightningCluster} = require('ln-docker-daemons');
5
5
  const {test} = require('@alexbosworth/tap');
6
+ const tinysecp = require('tiny-secp256k1');
6
7
  const {Transaction} = require('bitcoinjs-lib');
7
8
 
8
9
  const {broadcastChainTransaction} = require('./../../');
@@ -29,6 +30,8 @@ const txIdHexByteLength = 64;
29
30
 
30
31
  // Signing a PSBT should result in a finalized PSBT
31
32
  test(`Sign PSBT`, async ({end, equal}) => {
33
+ const ecp = (await import('ecpair')).ECPairFactory(tinysecp);
34
+
32
35
  const {kill, nodes} = await spawnLightningCluster({size});
33
36
 
34
37
  const [control, target] = nodes;
@@ -72,7 +75,7 @@ test(`Sign PSBT`, async ({end, equal}) => {
72
75
 
73
76
  const tx = Transaction.fromHex(finalized.transaction);
74
77
 
75
- const decoded = decodePsbt({psbt: finalized.psbt});
78
+ const decoded = decodePsbt({ecp, psbt: finalized.psbt});
76
79
 
77
80
  equal(!!decoded, true, 'Got a finalized PSBT');
78
81
  equal(!!tx, true, 'Got a raw signed transaction');