ln-service 54.9.2 → 54.10.1
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 +5 -0
- package/LICENSE +1 -1
- package/README.md +75 -0
- package/index.js +4 -0
- package/package.json +4 -4
- package/test/integration/test_get_settlement_status.js +25 -16
- package/test/integration/test_trusted_funding.js +11 -0
- package/test/walletrpc-integration/test_get_master_public_keys.js +2 -2
- package/test/walletrpc-integration/test_sign_chain_address_message.js +32 -0
- package/test/walletrpc-integration/test_verify_chain_address_message.js +58 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Versions
|
|
2
2
|
|
|
3
|
+
## 54.10.1
|
|
4
|
+
|
|
5
|
+
- `signChainAddressMessage`: Add method to sign a message given a chain address
|
|
6
|
+
- `verifyChainAddressMessage`: Add method to verify a chain address message
|
|
7
|
+
|
|
3
8
|
## 54.9.2
|
|
4
9
|
|
|
5
10
|
- `getChainAddresses`: Add method to get the list of chain addresses
|
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -220,6 +220,7 @@ for `unlocker` methods.
|
|
|
220
220
|
- [setAutopilot](#setautopilot) - Turn autopilot on and set autopilot scores
|
|
221
221
|
- [settleHodlInvoice](#settlehodlinvoice) - Accept a HODL HTLC invoice
|
|
222
222
|
- [signBytes](#signbytes) - Sign over arbitrary bytes with node keys
|
|
223
|
+
- [signChainAddressMessage](#signchainaddressmessage) - Sign with chain address
|
|
223
224
|
- [signMessage](#signmessage) - Sign a message with the node identity key
|
|
224
225
|
- [signPsbt](#signpsbt) - Sign and finalize an unsigned PSBT using internal keys
|
|
225
226
|
- [signTransaction](#signtransaction) - Sign an on-chain transaction
|
|
@@ -268,6 +269,7 @@ for `unlocker` methods.
|
|
|
268
269
|
- [verifyBackup](#verifybackup) - Verify a channel backup
|
|
269
270
|
- [verifyBackups](#verifybackups) - Verify a set of channel backups
|
|
270
271
|
- [verifyBytesSignature](#verifybytessignature) - Verify a signature over bytes
|
|
272
|
+
- [verifyChainAddressMessage](#verifychainaddressmessage) - Check chain message
|
|
271
273
|
- [verifyMessage](#verifymessage) - Verify a message signed by a node identity
|
|
272
274
|
|
|
273
275
|
## Additional Libraries
|
|
@@ -4918,6 +4920,40 @@ const {signature} = await signBytes({
|
|
|
4918
4920
|
});
|
|
4919
4921
|
```
|
|
4920
4922
|
|
|
4923
|
+
### signChainAddressMessage
|
|
4924
|
+
|
|
4925
|
+
Sign a chain address message using ECDSA
|
|
4926
|
+
|
|
4927
|
+
Note: this method is not supported in LND versions 0.15.5 and below
|
|
4928
|
+
|
|
4929
|
+
Requires LND built with `walletrpc` tag
|
|
4930
|
+
|
|
4931
|
+
`onchain:write` permission is required
|
|
4932
|
+
|
|
4933
|
+
{
|
|
4934
|
+
address: <Chain Address String>
|
|
4935
|
+
lnd: <Authenticated LND API Object>
|
|
4936
|
+
message: <Message To Sign String>
|
|
4937
|
+
}
|
|
4938
|
+
|
|
4939
|
+
@returns via cbk or Promise
|
|
4940
|
+
{
|
|
4941
|
+
signature: <Hex Encoded Signature String>
|
|
4942
|
+
}
|
|
4943
|
+
|
|
4944
|
+
```node
|
|
4945
|
+
const {createChainAddress} = require('ln-service');
|
|
4946
|
+
const {signChainAddressMessage} = require('ln-service');
|
|
4947
|
+
|
|
4948
|
+
const {address} = await createChainAddress({lnd});
|
|
4949
|
+
|
|
4950
|
+
const {signature} = await signChainAddressMessage({
|
|
4951
|
+
address,
|
|
4952
|
+
lnd,
|
|
4953
|
+
message: 'hello world',
|
|
4954
|
+
});
|
|
4955
|
+
```
|
|
4956
|
+
|
|
4921
4957
|
### signMessage
|
|
4922
4958
|
|
|
4923
4959
|
Sign a message
|
|
@@ -7401,6 +7437,45 @@ const validity = await verifyBytesSignature({
|
|
|
7401
7437
|
});
|
|
7402
7438
|
```
|
|
7403
7439
|
|
|
7440
|
+
### verifyChainAddressMessage
|
|
7441
|
+
|
|
7442
|
+
Verify a chain address message using ECDSA
|
|
7443
|
+
|
|
7444
|
+
Note: this method is not supported in LND versions 0.15.5 and below
|
|
7445
|
+
|
|
7446
|
+
Requires LND built with `walletrpc` tag
|
|
7447
|
+
|
|
7448
|
+
`onchain:write` permission is required
|
|
7449
|
+
|
|
7450
|
+
{
|
|
7451
|
+
address: <Chain Address String>
|
|
7452
|
+
lnd: <Authenticated LND API Object>
|
|
7453
|
+
message: <Message to Verify String>
|
|
7454
|
+
signature: <Hex Encoded Signature String>
|
|
7455
|
+
}
|
|
7456
|
+
|
|
7457
|
+
@returns via cbk or Promise
|
|
7458
|
+
{
|
|
7459
|
+
signed_by: <Public Key Hex String>
|
|
7460
|
+
}
|
|
7461
|
+
|
|
7462
|
+
```node
|
|
7463
|
+
const {createChainAddress} = require('ln-service');
|
|
7464
|
+
const {signChainAddressMessage} = require('ln-service');
|
|
7465
|
+
|
|
7466
|
+
const {address} = await createChainAddress({lnd});
|
|
7467
|
+
|
|
7468
|
+
const message = 'hello world';
|
|
7469
|
+
|
|
7470
|
+
const {signature} = await signChainAddressMessage({address, lnd, message});
|
|
7471
|
+
|
|
7472
|
+
try {
|
|
7473
|
+
await verifyChainAddressMessage({address, lnd, message, signature});
|
|
7474
|
+
} catch (err) {
|
|
7475
|
+
// Signature failed to vaildate
|
|
7476
|
+
}
|
|
7477
|
+
```
|
|
7478
|
+
|
|
7404
7479
|
### verifyMessage
|
|
7405
7480
|
|
|
7406
7481
|
Verify a message was signed by a known pubkey
|
package/index.js
CHANGED
|
@@ -108,6 +108,7 @@ const {sendToChainOutputScripts} = require('lightning');
|
|
|
108
108
|
const {setAutopilot} = require('lightning');
|
|
109
109
|
const {settleHodlInvoice} = require('lightning');
|
|
110
110
|
const {signBytes} = require('lightning');
|
|
111
|
+
const {signChainAddressMessage} = require('lightning');
|
|
111
112
|
const {signMessage} = require('lightning');
|
|
112
113
|
const {signPsbt} = require('lightning');
|
|
113
114
|
const {signTransaction} = require('lightning');
|
|
@@ -149,6 +150,7 @@ const {verifyAccess} = require('lightning');
|
|
|
149
150
|
const {verifyBackup} = require('lightning');
|
|
150
151
|
const {verifyBackups} = require('lightning');
|
|
151
152
|
const {verifyBytesSignature} = require('lightning');
|
|
153
|
+
const {verifyChainAddressMessage} = require('lightning');
|
|
152
154
|
const {verifyMessage} = require('lightning');
|
|
153
155
|
|
|
154
156
|
module.exports = {
|
|
@@ -262,6 +264,7 @@ module.exports = {
|
|
|
262
264
|
setAutopilot,
|
|
263
265
|
settleHodlInvoice,
|
|
264
266
|
signBytes,
|
|
267
|
+
signChainAddressMessage,
|
|
265
268
|
signMessage,
|
|
266
269
|
signPsbt,
|
|
267
270
|
signTransaction,
|
|
@@ -303,5 +306,6 @@ module.exports = {
|
|
|
303
306
|
verifyBackup,
|
|
304
307
|
verifyBackups,
|
|
305
308
|
verifyBytesSignature,
|
|
309
|
+
verifyChainAddressMessage,
|
|
306
310
|
verifyMessage,
|
|
307
311
|
};
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"cors": "2.8.5",
|
|
12
12
|
"express": "4.18.2",
|
|
13
13
|
"invoices": "2.2.3",
|
|
14
|
-
"lightning": "7.
|
|
14
|
+
"lightning": "7.1.1",
|
|
15
15
|
"macaroon": "3.0.4",
|
|
16
16
|
"morgan": "1.10.0",
|
|
17
17
|
"ws": "8.12.1"
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
"@alexbosworth/node-fetch": "2.6.2",
|
|
23
23
|
"async": "3.2.4",
|
|
24
24
|
"asyncjs-util": "1.2.11",
|
|
25
|
-
"bip32": "
|
|
25
|
+
"bip32": "4.0.0",
|
|
26
26
|
"bip66": "1.1.5",
|
|
27
27
|
"bitcoinjs-lib": "6.1.0",
|
|
28
28
|
"bn.js": "5.2.1",
|
|
29
|
-
"bs58check": "
|
|
29
|
+
"bs58check": "3.0.1",
|
|
30
30
|
"ecpair": "2.1.0",
|
|
31
31
|
"ln-docker-daemons": "4.1.1",
|
|
32
32
|
"p2tr": "1.3.3",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"integration-test-0.14.4": "DOCKER_LND_VERSION=v0.14.4-beta npm run test",
|
|
65
65
|
"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/peersrpc-integration/*.js test/routerrpc-integration/*.js test/signerrpc-integration/*.js test/tower_clientrpc-integration/*.js test/tower_serverrpc-integration/*.js test/walletrpc-integration/*.js"
|
|
66
66
|
},
|
|
67
|
-
"version": "54.
|
|
67
|
+
"version": "54.10.1"
|
|
68
68
|
}
|
|
@@ -15,30 +15,39 @@ const tokens = 100;
|
|
|
15
15
|
|
|
16
16
|
// Get the settlement status of an HTLC
|
|
17
17
|
test(`Get settlement status`, async ({end, equal, strictSame}) => {
|
|
18
|
-
|
|
18
|
+
// LND 0.15.5 and below do not support settlement status lookups
|
|
19
|
+
{
|
|
20
|
+
const {kill, nodes} = await spawnLightningCluster({size});
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
const [{generate, lnd}, target] = nodes;
|
|
21
23
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
const [code, message] = err;
|
|
24
|
+
try {
|
|
25
|
+
await getSettlementStatus({
|
|
26
|
+
lnd: target.lnd,
|
|
27
|
+
channel: fakeChannelId,
|
|
28
|
+
payment: Number(),
|
|
29
|
+
});
|
|
30
|
+
} catch (err) {
|
|
31
|
+
const [code, message] = err;
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
if (code !== 404) {
|
|
34
|
+
equal(code, 501, 'Method unsupported');
|
|
35
|
+
equal(message, 'LookupHtlcMethodUnsupported', 'Got unsupported message');
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
await kill({});
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
return end();
|
|
40
|
+
}
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
43
|
|
|
44
|
+
const {kill, nodes} = await spawnLightningCluster({
|
|
45
|
+
size,
|
|
46
|
+
lnd_configuration: ['--store-final-htlc-resolutions'],
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const [{generate, lnd}, target] = nodes;
|
|
50
|
+
|
|
42
51
|
try {
|
|
43
52
|
const channel = await setupChannel({generate, lnd, to: target});
|
|
44
53
|
|
|
@@ -164,6 +164,17 @@ test(`Open unconfirmed channels`, async ({end, equal, match, strictSame}) => {
|
|
|
164
164
|
|
|
165
165
|
match(otherId, /16000000x0/, 'Got ephemeral id');
|
|
166
166
|
|
|
167
|
+
// Make sure the channel is really active
|
|
168
|
+
await asyncRetry({interval, times}, async () => {
|
|
169
|
+
const {channels} = await getChannels({lnd});
|
|
170
|
+
|
|
171
|
+
const [channel] = channels;
|
|
172
|
+
|
|
173
|
+
if (!channel.time_online) {
|
|
174
|
+
throw new Error('ExpectedChannelOnline');
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
|
|
167
178
|
await asyncRetry({interval, times}, async () => {
|
|
168
179
|
await closeChannel({lnd, id: confirmed.id});
|
|
169
180
|
});
|
|
@@ -59,8 +59,8 @@ test(`Get master public keys`, async ({end, equal, strictSame}) => {
|
|
|
59
59
|
// Convert the key from base58 into its raw form
|
|
60
60
|
const rawKey = bs58check.decode(masterIdentityKey.extended_public_key);
|
|
61
61
|
|
|
62
|
-
const chainCode = chainCodeFromMasterPublicKey(rawKey);
|
|
63
|
-
const publicKey = publicKeyFromMasterPublicKey(rawKey);
|
|
62
|
+
const chainCode = Buffer.from(chainCodeFromMasterPublicKey(rawKey));
|
|
63
|
+
const publicKey = Buffer.from(publicKeyFromMasterPublicKey(rawKey));
|
|
64
64
|
|
|
65
65
|
// Make a bip32 object to derive from
|
|
66
66
|
const masterKey = fromPublicKey(publicKey, chainCode);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
2
|
+
const {test} = require('@alexbosworth/tap');
|
|
3
|
+
|
|
4
|
+
const {createChainAddress} = require('./../../');
|
|
5
|
+
const {signChainAddressMessage} = require('./../../');
|
|
6
|
+
|
|
7
|
+
const message = 'message';
|
|
8
|
+
|
|
9
|
+
// Signing a chain address message should result in a signature
|
|
10
|
+
test(`Sign chain address message`, async ({end, equal}) => {
|
|
11
|
+
const {kill, nodes} = await spawnLightningCluster({});
|
|
12
|
+
|
|
13
|
+
const [control] = nodes;
|
|
14
|
+
|
|
15
|
+
const {lnd} = control;
|
|
16
|
+
|
|
17
|
+
const {address} = await createChainAddress({lnd});
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
const {signature} = await signChainAddressMessage({address, lnd, message});
|
|
21
|
+
|
|
22
|
+
equal(!!signature, true, 'Got a signature for a chain address');
|
|
23
|
+
} catch (err) {
|
|
24
|
+
const [code, message] = err;
|
|
25
|
+
|
|
26
|
+
equal(message, 'BackingLndDoesNotSupportSigningChainMessages', 'missing');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
await kill({});
|
|
30
|
+
|
|
31
|
+
return end();
|
|
32
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
2
|
+
const {test} = require('@alexbosworth/tap');
|
|
3
|
+
|
|
4
|
+
const {createChainAddress} = require('./../../');
|
|
5
|
+
const {signChainAddressMessage} = require('./../../');
|
|
6
|
+
const {verifyChainAddressMessage} = require('./../../');
|
|
7
|
+
|
|
8
|
+
const message = 'message';
|
|
9
|
+
|
|
10
|
+
// Verifying a chain address message signature should result in verification
|
|
11
|
+
test(`Verify chain address message`, async ({end, equal}) => {
|
|
12
|
+
const {kill, nodes} = await spawnLightningCluster({});
|
|
13
|
+
|
|
14
|
+
const [control] = nodes;
|
|
15
|
+
|
|
16
|
+
const {lnd} = control;
|
|
17
|
+
|
|
18
|
+
const {address} = await createChainAddress({lnd});
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
const {signature} = await signChainAddressMessage({address, lnd, message});
|
|
22
|
+
|
|
23
|
+
const verify = await verifyChainAddressMessage({
|
|
24
|
+
address,
|
|
25
|
+
lnd,
|
|
26
|
+
message,
|
|
27
|
+
signature,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
equal(verify.signed_by.length, 66, 'Got public key');
|
|
31
|
+
} catch (err) {
|
|
32
|
+
const [code, message] = err;
|
|
33
|
+
|
|
34
|
+
equal(message, 'BackingLndDoesNotSupportSigningChainMessages', 'missing');
|
|
35
|
+
|
|
36
|
+
await kill({});
|
|
37
|
+
|
|
38
|
+
return end();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
const verify = await verifyChainAddressMessage({
|
|
43
|
+
address,
|
|
44
|
+
lnd,
|
|
45
|
+
message,
|
|
46
|
+
signature: '1f54fe4a1332633d3c625cf8de41004f3ce3978f7e6e9845dea944e46fab878ec5676e08d44b505ede70fa2e693192405e16baf3e18de44987db6d9e82d4f14907',
|
|
47
|
+
});
|
|
48
|
+
} catch (err) {
|
|
49
|
+
const [code, message] = err;
|
|
50
|
+
|
|
51
|
+
equal(code, 400, 'Invalid signature code');
|
|
52
|
+
equal(message, 'InvalidSignatureReceivedForChainAddress', 'invalid sig');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
await kill({});
|
|
56
|
+
|
|
57
|
+
return end();
|
|
58
|
+
});
|