lightning 7.1.0 → 7.1.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/.github/workflows/unit-test.yml +1 -1
- package/CHANGELOG.md +1 -1
- package/grpc/protos/lightning.proto +17 -3
- package/lnd_methods/macaroon/methods.json +1 -1
- package/lnd_methods/offchain/get_settlement_status.d.ts +2 -0
- package/lnd_methods/offchain/get_settlement_status.js +10 -3
- package/lnd_methods/onchain/index.d.ts +2 -0
- package/lnd_methods/onchain/sign_chain_address_message.d.ts +30 -0
- package/lnd_methods/onchain/verify_chain_address_message.d.ts +32 -0
- package/package.json +5 -5
- package/test/lnd_methods/offchain/test_get_settlement_status.js +20 -3
- package/test/typescript/authenticated_lightning_method.test-d.ts +18 -0
- package/test/typescript/sign_chain_address_message.test-d.ts +27 -0
- package/test/typescript/verify_chain_address_message.test-d.ts +32 -0
package/CHANGELOG.md
CHANGED
|
@@ -582,16 +582,22 @@ service Lightning {
|
|
|
582
582
|
*/
|
|
583
583
|
rpc ListAliases (ListAliasesRequest) returns (ListAliasesResponse);
|
|
584
584
|
|
|
585
|
-
|
|
585
|
+
/*
|
|
586
|
+
LookupHtlcResolution retrieves a final htlc resolution from the database.
|
|
587
|
+
If the htlc has no final resolution yet, a NotFound grpc status code is
|
|
588
|
+
returned.
|
|
589
|
+
*/
|
|
590
|
+
rpc LookupHtlcResolution (LookupHtlcResolutionRequest)
|
|
591
|
+
returns (LookupHtlcResolutionResponse);
|
|
586
592
|
}
|
|
587
593
|
|
|
588
|
-
message
|
|
594
|
+
message LookupHtlcResolutionRequest {
|
|
589
595
|
uint64 chan_id = 1;
|
|
590
596
|
|
|
591
597
|
uint64 htlc_index = 2;
|
|
592
598
|
}
|
|
593
599
|
|
|
594
|
-
message
|
|
600
|
+
message LookupHtlcResolutionResponse {
|
|
595
601
|
bool settled = 1;
|
|
596
602
|
|
|
597
603
|
bool offchain = 2;
|
|
@@ -1531,6 +1537,9 @@ message Channel {
|
|
|
1531
1537
|
|
|
1532
1538
|
// This is the confirmed / on-chain zero-conf SCID.
|
|
1533
1539
|
uint64 zero_conf_confirmed_scid = 33;
|
|
1540
|
+
|
|
1541
|
+
// The configured alias name of our peer.
|
|
1542
|
+
string peer_alias = 34;
|
|
1534
1543
|
}
|
|
1535
1544
|
|
|
1536
1545
|
message ListChannelsRequest {
|
|
@@ -1544,6 +1553,11 @@ message ListChannelsRequest {
|
|
|
1544
1553
|
empty, all channels will be returned.
|
|
1545
1554
|
*/
|
|
1546
1555
|
bytes peer = 5;
|
|
1556
|
+
|
|
1557
|
+
// Informs the server if the peer alias lookup per channel should be
|
|
1558
|
+
// enabled. It is turned off by default in order to avoid degradation of
|
|
1559
|
+
// performance for existing clients.
|
|
1560
|
+
bool peer_alias_lookup = 6;
|
|
1547
1561
|
}
|
|
1548
1562
|
message ListChannelsResponse {
|
|
1549
1563
|
// The list of active channels
|
|
@@ -22,6 +22,8 @@ export type GetSettlementStatusResult = {
|
|
|
22
22
|
*
|
|
23
23
|
* Note: this method is not supported in LND versions 0.15.5 and below
|
|
24
24
|
*
|
|
25
|
+
* Requires LND running with `--store-final-htlc-resolutions` flag
|
|
26
|
+
*
|
|
25
27
|
* Requires `offchain:read` permissions
|
|
26
28
|
*/
|
|
27
29
|
export const getSettlementStatus: AuthenticatedLightningMethod<
|
|
@@ -5,15 +5,18 @@ const {returnResult} = require('asyncjs-util');
|
|
|
5
5
|
const {isLnd} = require('./../../lnd_requests');
|
|
6
6
|
|
|
7
7
|
const errorNotFound = 'htlc unknown';
|
|
8
|
-
const
|
|
8
|
+
const errorUninitiated = 'cannot lookup with flag --store-final-htlc-resolutions=false';
|
|
9
|
+
const errorUnimplemented = 'unknown method LookupHtlcResolution for service lnrpc.Lightning';
|
|
9
10
|
const isBoolean = n => n === false || n === true;
|
|
10
|
-
const method = '
|
|
11
|
+
const method = 'lookupHtlcResolution';
|
|
11
12
|
const type = 'default';
|
|
12
13
|
|
|
13
14
|
/** Get the settlement status of a received HTLC
|
|
14
15
|
|
|
15
16
|
Note: this method is not supported in LND versions 0.15.5 and below
|
|
16
17
|
|
|
18
|
+
Requires LND running with `--store-final-htlc-resolutions` flag
|
|
19
|
+
|
|
17
20
|
Requires `offchain:read` permissions
|
|
18
21
|
|
|
19
22
|
{
|
|
@@ -60,7 +63,11 @@ module.exports = ({channel, lnd, payment}, cbk) => {
|
|
|
60
63
|
}
|
|
61
64
|
|
|
62
65
|
if (!!err && err.details === errorUnimplemented) {
|
|
63
|
-
return cbk([501, '
|
|
66
|
+
return cbk([501, 'LookupHtlcResolutionMethodUnsupported']);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (!!err && err.details == errorUninitiated) {
|
|
70
|
+
return cbk([404, 'LookupHtlcResolutionMethodUninitiated']);
|
|
64
71
|
}
|
|
65
72
|
|
|
66
73
|
if (!!err) {
|
|
@@ -24,6 +24,7 @@ export * from './request_chain_fee_increase';
|
|
|
24
24
|
export * from './send_to_chain_address';
|
|
25
25
|
export * from './send_to_chain_addresses';
|
|
26
26
|
export * from './send_to_chain_output_scripts';
|
|
27
|
+
export * from './sign_chain_address_message';
|
|
27
28
|
export * from './set_autopilot';
|
|
28
29
|
export * from './sign_psbt';
|
|
29
30
|
export * from './subscribe_to_blocks';
|
|
@@ -32,3 +33,4 @@ export * from './subscribe_to_chain_spend';
|
|
|
32
33
|
export * from './subscribe_to_transactions';
|
|
33
34
|
export * from './unlock_utxo';
|
|
34
35
|
export * from './update_chain_transaction';
|
|
36
|
+
export * from './verify_chain_address_message';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AuthenticatedLightningArgs,
|
|
3
|
+
AuthenticatedLightningMethod,
|
|
4
|
+
} from '../../typescript';
|
|
5
|
+
|
|
6
|
+
export type SignChainAddressMessageArgs = AuthenticatedLightningArgs<{
|
|
7
|
+
/** Chain Address String */
|
|
8
|
+
address: string;
|
|
9
|
+
/** Message To Sign String */
|
|
10
|
+
message: string;
|
|
11
|
+
}>;
|
|
12
|
+
|
|
13
|
+
export type SignChainAddressMessageResult = {
|
|
14
|
+
/** Hex Encoded Signature String */
|
|
15
|
+
signature: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Sign a chain address message using ECDSA
|
|
20
|
+
*
|
|
21
|
+
* Note: this method is not supported in LND versions 0.15.5 and below
|
|
22
|
+
*
|
|
23
|
+
* Requires LND built with `walletrpc` tag
|
|
24
|
+
*
|
|
25
|
+
* `onchain:write` permission is required
|
|
26
|
+
*/
|
|
27
|
+
export const signChainAddressMessage: AuthenticatedLightningMethod<
|
|
28
|
+
SignChainAddressMessageArgs,
|
|
29
|
+
SignChainAddressMessageResult
|
|
30
|
+
>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AuthenticatedLightningArgs,
|
|
3
|
+
AuthenticatedLightningMethod,
|
|
4
|
+
} from '../../typescript';
|
|
5
|
+
|
|
6
|
+
export type VerifyChainAddressMessageArgs = AuthenticatedLightningArgs<{
|
|
7
|
+
/** Chain Address String */
|
|
8
|
+
address: string;
|
|
9
|
+
/** Message to Verify String */
|
|
10
|
+
message: string;
|
|
11
|
+
/** Hex Encoded Signature String */
|
|
12
|
+
signature: string;
|
|
13
|
+
}>;
|
|
14
|
+
|
|
15
|
+
export type VerifyChainAddressMessageResult = {
|
|
16
|
+
/** Public Key Hex String */
|
|
17
|
+
signed_by: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Verify a chain address message using ECDSA
|
|
22
|
+
*
|
|
23
|
+
* Note: this method is not supported in LND versions 0.15.5 and below
|
|
24
|
+
*
|
|
25
|
+
* Requires LND built with `walletrpc` tag
|
|
26
|
+
*
|
|
27
|
+
* `onchain:write` permission is required
|
|
28
|
+
*/
|
|
29
|
+
export const verifyChainAddressMessage: AuthenticatedLightningMethod<
|
|
30
|
+
VerifyChainAddressMessageArgs,
|
|
31
|
+
VerifyChainAddressMessageResult
|
|
32
|
+
>;
|
package/package.json
CHANGED
|
@@ -7,17 +7,17 @@
|
|
|
7
7
|
"url": "https://github.com/alexbosworth/lightning/issues"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@grpc/grpc-js": "1.8.
|
|
10
|
+
"@grpc/grpc-js": "1.8.11",
|
|
11
11
|
"@grpc/proto-loader": "0.7.5",
|
|
12
12
|
"@types/express": "4.17.17",
|
|
13
|
-
"@types/node": "18.
|
|
13
|
+
"@types/node": "18.14.4",
|
|
14
14
|
"@types/request": "2.48.8",
|
|
15
15
|
"@types/ws": "8.5.4",
|
|
16
16
|
"async": "3.2.4",
|
|
17
17
|
"asyncjs-util": "1.2.11",
|
|
18
18
|
"bitcoinjs-lib": "6.1.0",
|
|
19
19
|
"bn.js": "5.2.1",
|
|
20
|
-
"body-parser": "1.20.
|
|
20
|
+
"body-parser": "1.20.2",
|
|
21
21
|
"bolt07": "1.8.3",
|
|
22
22
|
"bolt09": "0.2.5",
|
|
23
23
|
"cbor": "8.1.0",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"invoices": "2.2.3",
|
|
27
27
|
"psbt": "2.7.2",
|
|
28
28
|
"tiny-secp256k1": "2.2.1",
|
|
29
|
-
"type-fest": "3.6.
|
|
29
|
+
"type-fest": "3.6.1"
|
|
30
30
|
},
|
|
31
31
|
"description": "Lightning Network client library",
|
|
32
32
|
"devDependencies": {
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"directory": "test/typescript"
|
|
60
60
|
},
|
|
61
61
|
"types": "index.d.ts",
|
|
62
|
-
"version": "7.1.
|
|
62
|
+
"version": "7.1.2"
|
|
63
63
|
}
|
|
@@ -5,7 +5,7 @@ const {getSettlementStatus} = require('./../../../');
|
|
|
5
5
|
const makeLnd = ({err, res}) => {
|
|
6
6
|
const result = res === undefined ? {offchain: true, settled: true} : res;
|
|
7
7
|
|
|
8
|
-
return {default: {
|
|
8
|
+
return {default: {lookupHtlcResolution: ({}, cbk) => cbk(err, result)}};
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
const makeArgs = overrides => {
|
|
@@ -38,9 +38,26 @@ const tests = [
|
|
|
38
38
|
error: [404, 'PaymentNotFound'],
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
|
-
args: makeArgs({
|
|
41
|
+
args: makeArgs({
|
|
42
|
+
lnd: makeLnd({
|
|
43
|
+
err: {
|
|
44
|
+
details: 'unknown method LookupHtlcResolution for service lnrpc.Lightning',
|
|
45
|
+
},
|
|
46
|
+
}),
|
|
47
|
+
}),
|
|
42
48
|
description: 'A method not supported error is returned',
|
|
43
|
-
error: [501, '
|
|
49
|
+
error: [501, 'LookupHtlcResolutionMethodUnsupported'],
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
args: makeArgs({
|
|
53
|
+
lnd: makeLnd({
|
|
54
|
+
err: {
|
|
55
|
+
details: 'cannot lookup with flag --store-final-htlc-resolutions=false',
|
|
56
|
+
},
|
|
57
|
+
}),
|
|
58
|
+
}),
|
|
59
|
+
description: 'A method not supported error is returned',
|
|
60
|
+
error: [404, 'LookupHtlcResolutionMethodUninitiated'],
|
|
44
61
|
},
|
|
45
62
|
{
|
|
46
63
|
args: makeArgs({lnd: makeLnd({err: 'err'})}),
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {expectError, expectType} from 'tsd';
|
|
2
|
+
import {AuthenticatedLnd} from '../../lnd_grpc';
|
|
3
|
+
import {
|
|
4
|
+
AuthenticatedLightningArgs,
|
|
5
|
+
AuthenticatedLightningMethod,
|
|
6
|
+
} from '../../typescript';
|
|
7
|
+
|
|
8
|
+
type TestArgs = AuthenticatedLightningArgs;
|
|
9
|
+
type TestResult = unknown;
|
|
10
|
+
type TestMethod = AuthenticatedLightningMethod<TestArgs, TestResult>;
|
|
11
|
+
|
|
12
|
+
const authenticatedLightningMethod: TestMethod = async () => {};
|
|
13
|
+
|
|
14
|
+
const lnd = {} as AuthenticatedLnd;
|
|
15
|
+
|
|
16
|
+
expectError(authenticatedLightningMethod());
|
|
17
|
+
expectError(authenticatedLightningMethod({}));
|
|
18
|
+
expectType(authenticatedLightningMethod({lnd}));
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {expectError, expectType} from 'tsd';
|
|
2
|
+
import {AuthenticatedLnd} from '../../lnd_grpc';
|
|
3
|
+
import {
|
|
4
|
+
signChainAddressMessage,
|
|
5
|
+
SignChainAddressMessageResult,
|
|
6
|
+
} from '../../lnd_methods';
|
|
7
|
+
|
|
8
|
+
const lnd = {} as AuthenticatedLnd;
|
|
9
|
+
const address = '';
|
|
10
|
+
const message = '';
|
|
11
|
+
|
|
12
|
+
expectError(signChainAddressMessage({lnd, address}));
|
|
13
|
+
expectError(signChainAddressMessage({lnd, message}));
|
|
14
|
+
|
|
15
|
+
expectType<SignChainAddressMessageResult>(
|
|
16
|
+
await signChainAddressMessage({
|
|
17
|
+
lnd,
|
|
18
|
+
address,
|
|
19
|
+
message,
|
|
20
|
+
}),
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
expectType<void>(
|
|
24
|
+
signChainAddressMessage({lnd, address, message}, (error, result) => {
|
|
25
|
+
expectType<SignChainAddressMessageResult>(result);
|
|
26
|
+
}),
|
|
27
|
+
);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {expectError, expectType} from 'tsd';
|
|
2
|
+
import {AuthenticatedLnd} from '../../lnd_grpc';
|
|
3
|
+
import {
|
|
4
|
+
verifyChainAddressMessage,
|
|
5
|
+
VerifyChainAddressMessageResult,
|
|
6
|
+
} from '../../lnd_methods';
|
|
7
|
+
|
|
8
|
+
const lnd = {} as AuthenticatedLnd;
|
|
9
|
+
const address = '';
|
|
10
|
+
const message = '';
|
|
11
|
+
const signature = '';
|
|
12
|
+
|
|
13
|
+
expectError(verifyChainAddressMessage({lnd, address}));
|
|
14
|
+
expectError(verifyChainAddressMessage({lnd, message}));
|
|
15
|
+
expectError(verifyChainAddressMessage({lnd, address, message}));
|
|
16
|
+
expectError(verifyChainAddressMessage({lnd, address, signature}));
|
|
17
|
+
expectError(verifyChainAddressMessage({lnd, message, signature}));
|
|
18
|
+
|
|
19
|
+
expectType<VerifyChainAddressMessageResult>(
|
|
20
|
+
await verifyChainAddressMessage({
|
|
21
|
+
lnd,
|
|
22
|
+
address,
|
|
23
|
+
message,
|
|
24
|
+
signature,
|
|
25
|
+
}),
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
expectType<void>(
|
|
29
|
+
verifyChainAddressMessage({lnd, address, message, signature}, (error, result) => {
|
|
30
|
+
expectType<VerifyChainAddressMessageResult>(result);
|
|
31
|
+
}),
|
|
32
|
+
);
|