ln-service 53.9.1 → 53.9.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.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Versions
2
2
 
3
- ## 53.9.1
3
+ ## 53.9.2
4
4
 
5
5
  - `getPendingPayments`: Add method to get payments in flight
6
6
 
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "dependencies": {
10
10
  "bolt07": "1.8.0",
11
11
  "cors": "2.8.5",
12
- "express": "4.17.2",
12
+ "express": "4.17.3",
13
13
  "invoices": "2.0.4",
14
14
  "lightning": "5.8.1",
15
15
  "macaroon": "3.0.4",
@@ -29,11 +29,12 @@
29
29
  "bs58check": "2.1.2",
30
30
  "ecpair": "2.0.1",
31
31
  "ln-docker-daemons": "2.2.4",
32
+ "p2tr": "1.2.0",
32
33
  "portfinder": "1.0.28",
33
34
  "psbt": "2.0.0",
34
35
  "rimraf": "3.0.2",
35
36
  "secp256k1": "4.0.3",
36
- "tiny-secp256k1": "2.2.0",
37
+ "tiny-secp256k1": "2.2.1",
37
38
  "uuid": "8.3.2",
38
39
  "varuint-bitcoin": "1.1.2"
39
40
  },
@@ -68,5 +69,5 @@
68
69
  "integration-test-0.12.0": "DOCKER_LND_VERSION=v0.12.0-beta npm run test",
69
70
  "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"
70
71
  },
71
- "version": "53.9.1"
72
+ "version": "53.9.2"
72
73
  }
@@ -1,14 +1,14 @@
1
1
  const asyncRetry = require('async/retry');
2
2
  const {address} = require('bitcoinjs-lib');
3
3
  const {createPsbt} = require('psbt');
4
- const {crypto} = require('bitcoinjs-lib');
5
4
  const {decodePsbt} = require('psbt');
6
5
  const {networks} = require('bitcoinjs-lib');
7
- const {script} = require('bitcoinjs-lib');
6
+ const {signHash} = require('p2tr');
8
7
  const {spawnLightningCluster} = require('ln-docker-daemons');
9
8
  const {test} = require('@alexbosworth/tap');
10
9
  const tinysecp = require('tiny-secp256k1');
11
10
  const {Transaction} = require('bitcoinjs-lib');
11
+ const {v1OutputScript} = require('p2tr');
12
12
 
13
13
  const {broadcastChainTransaction} = require('./../../');
14
14
  const {createChainAddress} = require('./../../');
@@ -20,28 +20,16 @@ const {sendToChainAddress} = require('./../../');
20
20
  const {signPsbt} = require('./../../');
21
21
 
22
22
  const chainAddressRowType = 'chain_address';
23
- const {compile} = script;
24
23
  const confirmationCount = 6;
25
24
  const count = 100;
26
25
  const description = 'description';
27
- const extra = Buffer.alloc(32);
28
26
  const {fromBech32} = address;
29
27
  const {fromHex} = Transaction;
30
28
  const {fromOutputScript} = address;
31
29
  const hexAsBuffer = hex => Buffer.from(hex, 'hex');
32
30
  const interval = retryCount => 10 * Math.pow(2, retryCount);
33
- const isLowPublicKey = keyPair => keyPair.publicKey[0] === 2;
34
- const makeTaprootKey = (k, h) => tinysecp.xOnlyPointAddTweak(k, h).xOnlyPubkey;
35
- const nLess1 = 'fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140';
36
- const one256BitBigEndian = '0000000000000000000000000000000000000000000000000000000000000001';
37
- const OP_1 = 81;
38
- const {privateAdd} = tinysecp;
39
- const {privateSub} = tinysecp;
40
31
  const regtestBech32AddressHrp = 'bcrt';
41
- const shortKey = keyPair => keyPair.publicKey.slice(1, 33);
42
- const {signSchnorr} = tinysecp;
43
32
  const smallTokens = 2e5;
44
- const tapHash = k => crypto.taggedHash('TapTweak', k.publicKey.slice(1, 33));
45
33
  const times = 20;
46
34
  const {toOutputScript} = address;
47
35
  const tokens = 1e6;
@@ -126,10 +114,11 @@ test(`Fund PSBT`, async ({end, equal}) => {
126
114
 
127
115
  const keyPair = ecp.makeRandom({network: networks.regtest});
128
116
 
129
- const outputKey = makeTaprootKey(shortKey(keyPair), tapHash(keyPair));
130
- const tweakHash = tapHash(keyPair);
117
+ const output = v1OutputScript({
118
+ internal_key: keyPair.publicKey.toString('hex'),
119
+ });
131
120
 
132
- const outputScript = compile([OP_1, Buffer.from(outputKey)]);
121
+ const outputScript = hexAsBuffer(output.script);
133
122
 
134
123
  const [utxo] = (await getUtxos({lnd})).utxos.reverse();
135
124
 
@@ -175,16 +164,13 @@ test(`Fund PSBT`, async ({end, equal}) => {
175
164
  );
176
165
  });
177
166
 
178
- const isLow = isLowPublicKey(keyPair);
179
- const ONE = hexAsBuffer(one256BitBigEndian);
180
- const subtract = privateSub(hexAsBuffer(nLess1), keyPair.privateKey);
181
-
182
- const privateKey = isLow ? keyPair.privateKey : privateAdd(subtract, ONE);
183
-
184
- // Only low keys are allowed to save a leading byte on the public key
185
- const lowPrivateKey = privateAdd(privateKey, tweakHash);
167
+ const signedInput = signHash({
168
+ private_key: keyPair.privateKey.toString('hex'),
169
+ public_key: keyPair.publicKey.toString('hex'),
170
+ sign_hash: hashToSign.toString('hex'),
171
+ });
186
172
 
187
- const signature = signSchnorr(hashToSign, lowPrivateKey, extra);
173
+ const signature = hexAsBuffer(signedInput.signature);
188
174
 
189
175
  // Add the signature to the input
190
176
  tx.ins.forEach((input, i) => tx.setWitness(i, [Buffer.from(signature)]));