ln-service 57.27.2 → 58.0.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 +11 -0
- package/README.md +1 -1
- package/package.json +5 -5
- package/test/integration/test_create_chain_address.js +13 -4
- package/test/integration/test_pay_private_invoice.js +10 -0
- package/test/invoicesrpc-integration/test_cancel_invoice.js +12 -0
- package/test/routerrpc-integration/test_pay_via_payment_details.js +6 -5
- package/test/signerrpc-integration/test_sign_transaction.js +3 -2
- package/test/walletrpc-integration/test_create_funded_psbt.js +3 -3
- package/test/walletrpc-integration/test_partially_sign_psbt.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Versions
|
|
2
2
|
|
|
3
|
+
## 58.0.0
|
|
4
|
+
|
|
5
|
+
### Breaking Changes
|
|
6
|
+
|
|
7
|
+
- End support for node.js 18, require 20 or higher
|
|
8
|
+
|
|
9
|
+
## 57.27.3
|
|
10
|
+
|
|
11
|
+
- `pay`, `payViaPaymentRequest`, `subscribeToPayViaRequest`: Allow short CLTV
|
|
12
|
+
limit payments when the payment request final CLTV delta is very short
|
|
13
|
+
|
|
3
14
|
## 57.27.2
|
|
4
15
|
|
|
5
16
|
- Add support for LND 0.20.0-beta
|
package/README.md
CHANGED
|
@@ -5643,7 +5643,7 @@ Requires LND built with `chainrpc` build tag
|
|
|
5643
5643
|
Requires `onchain:read` permission
|
|
5644
5644
|
|
|
5645
5645
|
{
|
|
5646
|
-
[bech32_address]: <Address String>
|
|
5646
|
+
[bech32_address]: <Bech32 P2WPKH or P2WSH Address String>
|
|
5647
5647
|
lnd: <Chain RPC LND gRPC API Object>
|
|
5648
5648
|
[min_confirmations]: <Minimum Confirmations Number>
|
|
5649
5649
|
min_height: <Minimum Transaction Inclusion Blockchain Height Number>
|
package/package.json
CHANGED
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"bolt07": "1.9.4",
|
|
11
|
-
"invoices": "
|
|
12
|
-
"lightning": "
|
|
11
|
+
"invoices": "5.0.0",
|
|
12
|
+
"lightning": "11.0.0",
|
|
13
13
|
"macaroon": "3.0.4"
|
|
14
14
|
},
|
|
15
15
|
"description": "Interaction helper for your Lightning Network daemon",
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@alexbosworth/blockchain": "2.0
|
|
17
|
+
"@alexbosworth/blockchain": "3.2.0",
|
|
18
18
|
"@alexbosworth/node-fetch": "2.6.2",
|
|
19
19
|
"async": "3.2.6",
|
|
20
20
|
"asyncjs-util": "1.2.12",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"varuint-bitcoin": "2.0.0"
|
|
35
35
|
},
|
|
36
36
|
"engines": {
|
|
37
|
-
"node": ">=
|
|
37
|
+
"node": ">=20"
|
|
38
38
|
},
|
|
39
39
|
"keywords": [
|
|
40
40
|
"bitcoin",
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"integration-test-0.14.4": "DOCKER_LND_VERSION=v0.14.4-beta npm run test",
|
|
82
82
|
"test": "echo $DOCKER_LND_VERSION && node test/runner"
|
|
83
83
|
},
|
|
84
|
-
"version": "
|
|
84
|
+
"version": "58.0.0"
|
|
85
85
|
}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
const {equal} = require('node:assert').strict;
|
|
2
2
|
const test = require('node:test');
|
|
3
3
|
|
|
4
|
-
const {
|
|
4
|
+
const {decodeBase58Address} = require('@alexbosworth/blockchain');
|
|
5
|
+
const {decodeBech32Address} = require('@alexbosworth/blockchain');
|
|
5
6
|
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
6
7
|
|
|
7
8
|
const {createChainAddress} = require('./../../');
|
|
8
9
|
|
|
9
10
|
const formats = ['np2wpkh', 'p2wpkh'];
|
|
10
11
|
const p2shAddressVersion = 196;
|
|
12
|
+
const p2trProgramLength = 32;
|
|
13
|
+
const p2trVersion = 1;
|
|
11
14
|
const pkHashByteLength = 20;
|
|
12
15
|
const prefixForV1 = 'bcrt1p';
|
|
13
16
|
const regtestBech32AddressHrp = 'bcrt';
|
|
@@ -21,10 +24,10 @@ test(`Create address results in address creation`, async () => {
|
|
|
21
24
|
|
|
22
25
|
const [np2wpkh, p2wpkh] = await Promise.all(createNewChainAddresses);
|
|
23
26
|
|
|
24
|
-
const nativeAddress = address
|
|
25
|
-
const nestedAddress = address
|
|
27
|
+
const nativeAddress = decodeBech32Address({address: p2wpkh.address});
|
|
28
|
+
const nestedAddress = decodeBase58Address({address: np2wpkh.address});
|
|
26
29
|
|
|
27
|
-
equal(nativeAddress.
|
|
30
|
+
equal(nativeAddress.program.length, pkHashByteLength, 'Native addr pkHash');
|
|
28
31
|
equal(nativeAddress.prefix, regtestBech32AddressHrp, 'Native addr prefix');
|
|
29
32
|
equal(nestedAddress.version, p2shAddressVersion, 'Nested address version');
|
|
30
33
|
|
|
@@ -41,6 +44,12 @@ test(`Create address results in address creation`, async () => {
|
|
|
41
44
|
const {address} = await createChainAddress({lnd, format: 'p2tr'});
|
|
42
45
|
|
|
43
46
|
equal(address.startsWith(prefixForV1), true, 'A taproot address is made');
|
|
47
|
+
|
|
48
|
+
const p2trAddress = decodeBech32Address({address});
|
|
49
|
+
|
|
50
|
+
equal(p2trAddress.prefix, regtestBech32AddressHrp, 'addr has p2tr prefix');
|
|
51
|
+
equal(p2trAddress.program.length, p2trProgramLength, 'P2TR addr length');
|
|
52
|
+
equal(p2trAddress.version, p2trVersion, 'address has the P2TR version');
|
|
44
53
|
} catch (err) {
|
|
45
54
|
// LND 0.14.5 and below do not support TR addresses
|
|
46
55
|
const [code] = err;
|
|
@@ -39,6 +39,16 @@ test(`Pay private invoice`, async () => {
|
|
|
39
39
|
}
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
+
await asyncRetry({interval, times}, async () => {
|
|
43
|
+
const wallet = await getWalletInfo({lnd: target.lnd});
|
|
44
|
+
|
|
45
|
+
await generate({});
|
|
46
|
+
|
|
47
|
+
if (!wallet.is_synced_to_chain) {
|
|
48
|
+
throw new Error('NotSyncedToChain');
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
42
52
|
const channel = await setupChannel({generate, lnd, to: target});
|
|
43
53
|
|
|
44
54
|
const remoteChannel = await setupChannel({
|
|
@@ -12,9 +12,11 @@ const {createHodlInvoice} = require('./../../');
|
|
|
12
12
|
const {getInvoice} = require('./../../');
|
|
13
13
|
const {getInvoices} = require('./../../');
|
|
14
14
|
const {getPayment} = require('./../../');
|
|
15
|
+
const {getWalletInfo} = require('./../../');
|
|
15
16
|
const {pay} = require('./../../');
|
|
16
17
|
const {subscribeToInvoice} = require('./../../');
|
|
17
18
|
|
|
19
|
+
const interval = 10;
|
|
18
20
|
const size = 2;
|
|
19
21
|
const times = 1000;
|
|
20
22
|
const tokens = 100;
|
|
@@ -26,6 +28,16 @@ test(`Cancel back a hodl invoice`, async () => {
|
|
|
26
28
|
const [{generate, lnd}, target] = nodes;
|
|
27
29
|
|
|
28
30
|
try {
|
|
31
|
+
await asyncRetry({interval, times}, async () => {
|
|
32
|
+
const wallet = await getWalletInfo({lnd});
|
|
33
|
+
|
|
34
|
+
await generate({});
|
|
35
|
+
|
|
36
|
+
if (!wallet.is_synced_to_chain) {
|
|
37
|
+
throw new Error('NotSyncedToChain');
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
29
41
|
await setupChannel({generate, lnd, to: target});
|
|
30
42
|
|
|
31
43
|
const id = createHash('sha256').update(randomBytes(32)).digest('hex');
|
|
@@ -98,11 +98,12 @@ test(`Pay via payment details`, async () => {
|
|
|
98
98
|
|
|
99
99
|
equal(tooSoonCltv, null, 'Should not be able to pay a too soon CLTV');
|
|
100
100
|
} catch (err) {
|
|
101
|
-
deepEqual(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
);
|
|
101
|
+
deepEqual(!!err, true, 'There should be an error');
|
|
102
|
+
|
|
103
|
+
const [code, msg] = err;
|
|
104
|
+
|
|
105
|
+
deepEqual(code, 400, 'The error is a user client error');
|
|
106
|
+
deepEqual(msg, 'MaxTimeoutTooNearCurrentHeightToMakePayment', 'Failed');
|
|
106
107
|
}
|
|
107
108
|
|
|
108
109
|
try {
|
|
@@ -2,10 +2,11 @@ const {equal} = require('node:assert').strict;
|
|
|
2
2
|
const test = require('node:test');
|
|
3
3
|
|
|
4
4
|
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
5
|
-
const {Transaction} = require('bitcoinjs-lib');
|
|
6
5
|
|
|
7
6
|
const {signTransaction} = require('./../../');
|
|
8
7
|
|
|
8
|
+
const transactionSighashAll = 1;
|
|
9
|
+
|
|
9
10
|
// Signing a transaction should result in signatures for the transaction
|
|
10
11
|
test(`Sign transaction`, async () => {
|
|
11
12
|
const {kill, nodes} = await spawnLightningCluster({});
|
|
@@ -19,7 +20,7 @@ test(`Sign transaction`, async () => {
|
|
|
19
20
|
key_index: 1,
|
|
20
21
|
output_script: '00147ab105a90ccd7e49d96672abcac2995bdb852baa',
|
|
21
22
|
output_tokens: 1e8,
|
|
22
|
-
sighash:
|
|
23
|
+
sighash: transactionSighashAll,
|
|
23
24
|
vin: 0,
|
|
24
25
|
witness_script: '00',
|
|
25
26
|
}],
|
|
@@ -2,8 +2,8 @@ const {equal} = require('node:assert').strict;
|
|
|
2
2
|
const test = require('node:test');
|
|
3
3
|
|
|
4
4
|
const asyncRetry = require('async/retry');
|
|
5
|
-
const {address} = require('bitcoinjs-lib');
|
|
6
5
|
const {componentsOfTransaction} = require('@alexbosworth/blockchain');
|
|
6
|
+
const {decodeBech32Address} = require('@alexbosworth/blockchain');
|
|
7
7
|
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
8
8
|
|
|
9
9
|
const {broadcastChainTransaction} = require('./../../');
|
|
@@ -18,7 +18,7 @@ const bufferAsHex = buffer => buffer.toString('hex');
|
|
|
18
18
|
const {concat} = Buffer;
|
|
19
19
|
const count = 100;
|
|
20
20
|
const format = 'p2tr';
|
|
21
|
-
const
|
|
21
|
+
const fromBech32 = address => decodeBech32Address({address}).program;
|
|
22
22
|
const interval = retryCount => 10 * Math.pow(2, retryCount);
|
|
23
23
|
const OP_1 = Buffer.from([81]);
|
|
24
24
|
const push32 = Buffer.from([32]);
|
|
@@ -62,7 +62,7 @@ test(`Create funded PSBT`, async () => {
|
|
|
62
62
|
const {address} = await createChainAddress({format, lnd});
|
|
63
63
|
const {utxos} = await getUtxos({lnd});
|
|
64
64
|
|
|
65
|
-
const outputScriptElements = [OP_1, push32, fromBech32(address)
|
|
65
|
+
const outputScriptElements = [OP_1, push32, fromBech32(address)];
|
|
66
66
|
const [utxo] = utxos;
|
|
67
67
|
|
|
68
68
|
const output = bufferAsHex(concat(outputScriptElements));
|
|
@@ -12,7 +12,6 @@ const {extractTransaction} = require('psbt');
|
|
|
12
12
|
const {finalizePsbt} = require('psbt');
|
|
13
13
|
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
14
14
|
const tinysecp = require('tiny-secp256k1');
|
|
15
|
-
const {Transaction} = require('bitcoinjs-lib');
|
|
16
15
|
const {updatePsbt} = require('psbt');
|
|
17
16
|
|
|
18
17
|
const {broadcastChainTransaction} = require('./../../');
|
|
@@ -31,6 +30,7 @@ const size = 3;
|
|
|
31
30
|
const startingFunds = 1e7;
|
|
32
31
|
const times = 1000;
|
|
33
32
|
const tokens = 1e6;
|
|
33
|
+
const transactionSighashAll = 1;
|
|
34
34
|
|
|
35
35
|
// Partially signing a PSBT should result in a partially signed PSBT
|
|
36
36
|
test(`Partially sign PSBT`, async () => {
|
|
@@ -173,7 +173,7 @@ test(`Partially sign PSBT`, async () => {
|
|
|
173
173
|
psbt: base.psbt,
|
|
174
174
|
sighashes: inputs.map(input => ({
|
|
175
175
|
id: input.transaction_id,
|
|
176
|
-
sighash:
|
|
176
|
+
sighash: transactionSighashAll,
|
|
177
177
|
vout: input.transaction_vout,
|
|
178
178
|
})),
|
|
179
179
|
transactions: controlTransactions.concat(targetTransactions),
|