lightning 5.13.1 → 5.15.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 +19 -0
- package/README.md +2 -2
- package/grpc/protos/chainnotifier.proto +5 -3
- package/grpc/protos/lightning.proto +15 -1
- package/grpc/protos/router.proto +6 -0
- package/grpc/protos/signer.proto +308 -0
- package/index.js +6 -0
- package/lnd_methods/index.js +6 -0
- package/lnd_methods/info/get_route_to_destination.js +10 -0
- package/lnd_methods/macaroon/methods.json +13 -0
- package/lnd_methods/offchain/get_failed_payments.js +3 -1
- package/lnd_methods/offchain/get_payments.js +3 -1
- package/lnd_methods/offchain/get_pending_payments.js +2 -0
- package/lnd_methods/offchain/is_destination_payable.js +4 -0
- package/lnd_methods/offchain/pay.js +4 -0
- package/lnd_methods/offchain/pay_via_payment_details.js +4 -0
- package/lnd_methods/offchain/pay_via_payment_request.js +4 -0
- package/lnd_methods/offchain/probe_for_route.js +4 -0
- package/lnd_methods/offchain/subscribe_to_pay.js +10 -0
- package/lnd_methods/offchain/subscribe_to_pay_via_details.js +4 -0
- package/lnd_methods/offchain/subscribe_to_pay_via_request.js +4 -0
- package/lnd_methods/offchain/subscribe_to_probe_for_route.js +4 -0
- package/lnd_methods/signer/begin_group_signing_session.js +144 -0
- package/lnd_methods/signer/end_group_signing_session.js +102 -0
- package/lnd_methods/signer/index.js +6 -0
- package/lnd_methods/signer/update_group_signing_session.js +110 -0
- package/lnd_responses/index.js +2 -0
- package/lnd_responses/rpc_attempt_htlc_as_attempt.js +39 -5
- package/lnd_responses/rpc_group_session_as_session.js +51 -0
- package/lnd_responses/rpc_payment_as_payment.js +6 -0
- package/package.json +6 -6
- package/test/lnd_methods/offchain/test_get_payments.js +2 -0
- package/test/lnd_methods/signer/test_begin_group_signing_session.js +134 -0
- package/test/lnd_methods/signer/test_diffie_hellman_compute_secret.js +3 -1
- package/test/lnd_methods/signer/test_end_group_signing_session.js +93 -0
- package/test/lnd_methods/signer/test_update_group_signing_session.js +108 -0
- package/test/lnd_responses/test_rpc_attempt_htlc_as_attempt.js +19 -3
- package/test/lnd_responses/test_rpc_group_session_as_session.js +79 -0
- package/test/lnd_responses/test_rpc_payment_as_payment.js +5 -1
|
@@ -81,6 +81,9 @@ const routePublicKeys = route => route.hops.map(n => n.public_key);
|
|
|
81
81
|
@returns
|
|
82
82
|
{
|
|
83
83
|
attempts: [{
|
|
84
|
+
[confirmed_at]: <Payment Attempt Succeeded At ISO 8601 Date String>
|
|
85
|
+
created_at: <Attempt Was Started At ISO 8601 Date String>
|
|
86
|
+
[failed_at]: <Payment Attempt Failed At ISO 8601 Date String>
|
|
84
87
|
[failure]: {
|
|
85
88
|
code: <Error Type Code Number>
|
|
86
89
|
[details]: {
|
|
@@ -108,6 +111,9 @@ const routePublicKeys = route => route.hops.map(n => n.public_key);
|
|
|
108
111
|
}
|
|
109
112
|
message: <Error Message String>
|
|
110
113
|
}
|
|
114
|
+
[confirmed_at]: <Payment Attempt Succeeded At ISO 8601 Date String>
|
|
115
|
+
created_at: <Attempt Was Started At ISO 8601 Date String>
|
|
116
|
+
[failed_at]: <Payment Attempt Failed At ISO 8601 Date String>
|
|
111
117
|
is_confirmed: <Payment Attempt Succeeded Bool>
|
|
112
118
|
is_failed: <Payment Attempt Failed Bool>
|
|
113
119
|
is_pending: <Payment Attempt is Waiting For Resolution Bool>
|
package/package.json
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@grpc/grpc-js": "1.6.7",
|
|
11
|
-
"@grpc/proto-loader": "0.6.
|
|
11
|
+
"@grpc/proto-loader": "0.6.12",
|
|
12
12
|
"@types/express": "4.17.13",
|
|
13
|
-
"@types/node": "17.0.
|
|
13
|
+
"@types/node": "17.0.31",
|
|
14
14
|
"@types/request": "2.48.8",
|
|
15
15
|
"@types/ws": "8.5.3",
|
|
16
16
|
"async": "3.2.3",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"bolt09": "0.2.3",
|
|
23
23
|
"cbor": "8.1.0",
|
|
24
24
|
"ecpair": "2.0.1",
|
|
25
|
-
"express": "4.
|
|
25
|
+
"express": "4.18.1",
|
|
26
26
|
"invoices": "2.0.6",
|
|
27
27
|
"psbt": "2.0.1",
|
|
28
28
|
"tiny-secp256k1": "2.2.1",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"@alexbosworth/node-fetch": "2.6.2",
|
|
34
34
|
"@alexbosworth/tap": "15.0.11",
|
|
35
35
|
"tsd": "0.20.0",
|
|
36
|
-
"typescript": "4.6.
|
|
37
|
-
"ws": "8.
|
|
36
|
+
"typescript": "4.6.4",
|
|
37
|
+
"ws": "8.6.0"
|
|
38
38
|
},
|
|
39
39
|
"engines": {
|
|
40
40
|
"node": ">=12.20"
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"directory": "test/typescript"
|
|
60
60
|
},
|
|
61
61
|
"types": "index.d.ts",
|
|
62
|
-
"version": "5.
|
|
62
|
+
"version": "5.15.1"
|
|
63
63
|
}
|
|
@@ -65,6 +65,8 @@ const makeExpectedPayment = ({}) => {
|
|
|
65
65
|
destination: '020202020202020202020202020202020202020202020202020202020202020202',
|
|
66
66
|
attempts: [{
|
|
67
67
|
confirmed_at: '1970-01-01T00:00:00.000Z',
|
|
68
|
+
created_at: '1970-01-01T00:00:00.000Z',
|
|
69
|
+
failed_at: undefined,
|
|
68
70
|
is_confirmed: true,
|
|
69
71
|
is_failed: false,
|
|
70
72
|
is_pending: false,
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
const {test} = require('@alexbosworth/tap');
|
|
2
|
+
|
|
3
|
+
const {beginGroupSigningSession} = require('./../../../');
|
|
4
|
+
|
|
5
|
+
const makeLnd = (err, res) => {
|
|
6
|
+
return {
|
|
7
|
+
signer: {
|
|
8
|
+
muSig2CreateSession: ({}, cbk) => cbk(err, res)
|
|
9
|
+
},
|
|
10
|
+
wallet: {
|
|
11
|
+
deriveKey: ({}, cbk) => cbk(null, {
|
|
12
|
+
key_loc: {key_index: 0},
|
|
13
|
+
raw_key_bytes: Buffer.alloc(1),
|
|
14
|
+
}),
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const makeArgs = override => {
|
|
20
|
+
const args = {
|
|
21
|
+
lnd: makeLnd(null, {
|
|
22
|
+
combined_key: Buffer.alloc(32),
|
|
23
|
+
local_public_nonces: Buffer.alloc(66),
|
|
24
|
+
session_id: Buffer.alloc(32),
|
|
25
|
+
taproot_internal_key: Buffer.alloc(0),
|
|
26
|
+
}),
|
|
27
|
+
key_family: 0,
|
|
28
|
+
key_index: 0,
|
|
29
|
+
public_keys: [Buffer.alloc(33, 2).toString('hex')],
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
Object.keys(override || {}).forEach(key => args[key] = override[key]);
|
|
33
|
+
|
|
34
|
+
return args;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const tests = [
|
|
38
|
+
{
|
|
39
|
+
args: makeArgs({lnd: undefined}),
|
|
40
|
+
description: 'LND object is required',
|
|
41
|
+
error: [400, 'ExpectedAuthenticatedLndToStartMuSig2Session'],
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
args: makeArgs({key_family: undefined}),
|
|
45
|
+
description: 'A key family is required',
|
|
46
|
+
error: [400, 'ExpectedKeyFamilyToStartMuSig2Session'],
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
args: makeArgs({key_index: undefined}),
|
|
50
|
+
description: 'The key index is required',
|
|
51
|
+
error: [400, 'ExpectedKeyIndexToStartMuSig2Session'],
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
args: makeArgs({public_keys: undefined}),
|
|
55
|
+
description: 'Public keys are required',
|
|
56
|
+
error: [400, 'ExpectedArrayOfPublicKeysForMuSig2SessionStart'],
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
args: makeArgs({public_keys: []}),
|
|
60
|
+
description: 'Remote public keys are required',
|
|
61
|
+
error: [400, 'ExpectedOtherPublicKeysForMuSig2SessionStart'],
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
args: makeArgs({root_hash: 'root_hash'}),
|
|
65
|
+
description: 'Root hash must be valid',
|
|
66
|
+
error: [400, 'ExpectedHashWhenSpecifyingMuSig2ScriptRootHash'],
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
args: makeArgs({
|
|
70
|
+
lnd: makeLnd({
|
|
71
|
+
details: 'unknown method MuSig2CreateSession for service signrpc.Signer',
|
|
72
|
+
}),
|
|
73
|
+
}),
|
|
74
|
+
description: 'MuSig2 must be supported',
|
|
75
|
+
error: [501, 'MuSig2BeginSigningSessionNotSupported'],
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
args: makeArgs({lnd: makeLnd('err')}),
|
|
79
|
+
description: 'Unexpected errors are passed back',
|
|
80
|
+
error: [503, 'UnexpectedErrorCreatingMuSig2Session', {err: 'err'}],
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
args: makeArgs({lnd: makeLnd(null, {})}),
|
|
84
|
+
description: 'A valid response is expected',
|
|
85
|
+
error: [503, 'ExpectedCombinedPublicKeyInMuSig2SessionResponse'],
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
args: makeArgs({}),
|
|
89
|
+
description: 'A group signing session is started',
|
|
90
|
+
expected: {
|
|
91
|
+
external_key: '0000000000000000000000000000000000000000000000000000000000000000',
|
|
92
|
+
id: '0000000000000000000000000000000000000000000000000000000000000000',
|
|
93
|
+
internal_key: undefined,
|
|
94
|
+
nonce: '000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
args: makeArgs({
|
|
99
|
+
public_keys: [Buffer.alloc(32, 1).toString('hex')],
|
|
100
|
+
root_hash: Buffer.alloc(32).toString('hex'),
|
|
101
|
+
}),
|
|
102
|
+
description: 'A group signing session is started with a root hash',
|
|
103
|
+
expected: {
|
|
104
|
+
external_key: '0000000000000000000000000000000000000000000000000000000000000000',
|
|
105
|
+
id: '0000000000000000000000000000000000000000000000000000000000000000',
|
|
106
|
+
internal_key: undefined,
|
|
107
|
+
nonce: '000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
args: makeArgs({is_key_spend: true}),
|
|
112
|
+
description: 'A group signing session is started with a key spend',
|
|
113
|
+
expected: {
|
|
114
|
+
external_key: '0000000000000000000000000000000000000000000000000000000000000000',
|
|
115
|
+
id: '0000000000000000000000000000000000000000000000000000000000000000',
|
|
116
|
+
internal_key: undefined,
|
|
117
|
+
nonce: '000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
];
|
|
121
|
+
|
|
122
|
+
tests.forEach(({args, description, error, expected}) => {
|
|
123
|
+
return test(description, async ({end, rejects, strictSame}) => {
|
|
124
|
+
if (!!error) {
|
|
125
|
+
await rejects(beginGroupSigningSession(args), error, 'Got expected err');
|
|
126
|
+
} else {
|
|
127
|
+
const res = await beginGroupSigningSession(args);
|
|
128
|
+
|
|
129
|
+
strictSame(res, expected, 'Got expected result');
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return end();
|
|
133
|
+
});
|
|
134
|
+
});
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
const {test} = require('@alexbosworth/tap');
|
|
2
|
+
|
|
3
|
+
const {endGroupSigningSession} = require('./../../../');
|
|
4
|
+
|
|
5
|
+
const makeLnd = ({cleanErr, combineErr, combineRes}) => {
|
|
6
|
+
return {
|
|
7
|
+
signer: {
|
|
8
|
+
muSig2Cleanup: ({}, cbk) => cbk(cleanErr),
|
|
9
|
+
muSig2CombineSig: ({}, cbk) => cbk(combineErr, combineRes),
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const makeArgs = override => {
|
|
15
|
+
const args = {
|
|
16
|
+
id: Buffer.alloc(32).toString('hex'),
|
|
17
|
+
lnd: makeLnd({combineRes: {final_signature: Buffer.alloc(64)}}),
|
|
18
|
+
signatures: [Buffer.alloc(64).toString('hex')],
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
Object.keys(override || {}).forEach(key => args[key] = override[key]);
|
|
22
|
+
|
|
23
|
+
return args;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const tests = [
|
|
27
|
+
{
|
|
28
|
+
args: makeArgs({id: undefined}),
|
|
29
|
+
description: 'A session id is required',
|
|
30
|
+
error: [400, 'ExpectedSessionIdToFinishMuSig2Session'],
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
args: makeArgs({lnd: undefined}),
|
|
34
|
+
description: 'An authenticated lnd is required',
|
|
35
|
+
error: [400, 'ExpectedAuthenticatedLndToFinishMuSig2Session'],
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
args: makeArgs({signatures: []}),
|
|
39
|
+
description: 'Signatures are required',
|
|
40
|
+
error: [400, 'ExpectedPartialSignaturesToCombineToEndSession'],
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
args: makeArgs({lnd: makeLnd({cleanErr: 'err'}), signatures: undefined}),
|
|
44
|
+
description: 'A cleanup error is passed back',
|
|
45
|
+
error: [503, 'UnexpectedErrorCleaningUpMuSig2Session', {err: 'err'}],
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
args: makeArgs({lnd: makeLnd({combineErr: 'err'})}),
|
|
49
|
+
description: 'A combine error is passed back',
|
|
50
|
+
error: [503, 'UnexpectedErrorFinishingMuSig2Session', {err: 'err'}],
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
args: makeArgs({lnd: makeLnd({combineRes: null})}),
|
|
54
|
+
description: 'A combine response is expected',
|
|
55
|
+
error: [503, 'ExpectedResponseForMuSig2CombineRequest'],
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
args: makeArgs({lnd: makeLnd({combineRes: {have_all_signatures: false}})}),
|
|
59
|
+
description: 'A combine success response is expected',
|
|
60
|
+
error: [400, 'ExpectedAllSignaturesProvidedForSession'],
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
args: makeArgs({lnd: makeLnd({combineRes: {}})}),
|
|
64
|
+
description: 'A combined signature is expected',
|
|
65
|
+
error: [503, 'ExpectedFinalSignatureInCombineResponse'],
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
args: makeArgs({}),
|
|
69
|
+
description: 'A group signing session is ended',
|
|
70
|
+
expected: {
|
|
71
|
+
signature: '00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
args: makeArgs({signatures: undefined}),
|
|
76
|
+
description: 'A group signing session is canceled',
|
|
77
|
+
expected: {},
|
|
78
|
+
},
|
|
79
|
+
];
|
|
80
|
+
|
|
81
|
+
tests.forEach(({args, description, error, expected}) => {
|
|
82
|
+
return test(description, async ({end, rejects, strictSame}) => {
|
|
83
|
+
if (!!error) {
|
|
84
|
+
await rejects(endGroupSigningSession(args), error, 'Got expected err');
|
|
85
|
+
} else {
|
|
86
|
+
const res = await endGroupSigningSession(args);
|
|
87
|
+
|
|
88
|
+
strictSame(res, expected, 'Got expected result');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return end();
|
|
92
|
+
});
|
|
93
|
+
});
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
const {test} = require('@alexbosworth/tap');
|
|
2
|
+
|
|
3
|
+
const {updateGroupSigningSession} = require('./../../../');
|
|
4
|
+
|
|
5
|
+
const makeLnd = ({noncesErr, noncesRes, signErr, signRes}) => {
|
|
6
|
+
return {
|
|
7
|
+
signer: {
|
|
8
|
+
muSig2RegisterNonces: ({}, cbk) => cbk(noncesErr, noncesRes),
|
|
9
|
+
muSig2Sign: ({}, cbk) => cbk(signErr, signRes),
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const makeArgs = override => {
|
|
15
|
+
const args = {
|
|
16
|
+
hash: Buffer.alloc(32).toString('hex'),
|
|
17
|
+
id: Buffer.alloc(32).toString('hex'),
|
|
18
|
+
lnd: makeLnd({
|
|
19
|
+
noncesRes: {have_all_nonces: true},
|
|
20
|
+
signRes: {local_partial_signature: Buffer.alloc(64)},
|
|
21
|
+
}),
|
|
22
|
+
nonces: [Buffer.alloc(66).toString('hex')],
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
Object.keys(override || {}).forEach(key => args[key] = override[key]);
|
|
26
|
+
|
|
27
|
+
return args;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const tests = [
|
|
31
|
+
{
|
|
32
|
+
args: makeArgs({hash: undefined}),
|
|
33
|
+
description: 'A hash to sign is required',
|
|
34
|
+
error: [400, 'ExpectedHashToSignToUpdateMuSig2Session'],
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
args: makeArgs({id: undefined}),
|
|
38
|
+
description: 'A signing group id is required',
|
|
39
|
+
error: [400, 'ExpectedSessionIdToUpdateMuSig2Session'],
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
args: makeArgs({lnd: undefined}),
|
|
43
|
+
description: 'LND object is required',
|
|
44
|
+
error: [400, 'ExpectedAuthenticatedLndToUpdateMuSig2Session'],
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
args: makeArgs({nonces: undefined}),
|
|
48
|
+
description: 'Nonces are required',
|
|
49
|
+
error: [400, 'ExpectedArrayOfNoncesToUpdateMuSig2Session'],
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
args: makeArgs({lnd: makeLnd({noncesErr: 'err'})}),
|
|
53
|
+
description: 'Update nonces errors are passed back',
|
|
54
|
+
error: [503, 'UnexpectedErrorUpdatingMuSig2Session', {err: 'err'}],
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
args: makeArgs({lnd: makeLnd({noncesRes: null})}),
|
|
58
|
+
description: 'An update response is expected',
|
|
59
|
+
error: [503, 'ExpectedResultOfRegisterNoncesRequest'],
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
args: makeArgs({lnd: makeLnd({noncesRes: {}})}),
|
|
63
|
+
description: 'A successful update response is expected',
|
|
64
|
+
error: [400, 'ExpectedAllNoncesForRegisterNoncesRequest'],
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
args: makeArgs({
|
|
68
|
+
lnd: makeLnd({noncesRes: {have_all_nonces: true}, signErr: 'err'}),
|
|
69
|
+
}),
|
|
70
|
+
description: 'Sign errors are passed back',
|
|
71
|
+
error: [503, 'UnexpectedErrorSigningMuSig2Session', {err: 'err'}],
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
args: makeArgs({
|
|
75
|
+
lnd: makeLnd({noncesRes: {have_all_nonces: true}, signRes: null}),
|
|
76
|
+
}),
|
|
77
|
+
description: 'Sign response is expected',
|
|
78
|
+
error: [503, 'ExpectedResultForMuSig2SignRequest'],
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
args: makeArgs({
|
|
82
|
+
lnd: makeLnd({noncesRes: {have_all_nonces: true}, signRes: {}}),
|
|
83
|
+
}),
|
|
84
|
+
description: 'A partial signature is expected',
|
|
85
|
+
error: [503, 'ExpectedPartialSignatureForMuSig2SignRequest'],
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
args: makeArgs({}),
|
|
89
|
+
description: 'A group signing session is updated',
|
|
90
|
+
expected: {
|
|
91
|
+
signature: '00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
];
|
|
95
|
+
|
|
96
|
+
tests.forEach(({args, description, error, expected}) => {
|
|
97
|
+
return test(description, async ({end, rejects, strictSame}) => {
|
|
98
|
+
if (!!error) {
|
|
99
|
+
await rejects(updateGroupSigningSession(args), error, 'Got expected err');
|
|
100
|
+
} else {
|
|
101
|
+
const res = await updateGroupSigningSession(args);
|
|
102
|
+
|
|
103
|
+
strictSame(res, expected, 'Got expected result');
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return end();
|
|
107
|
+
});
|
|
108
|
+
});
|
|
@@ -19,7 +19,12 @@ const route = {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
const makeArgs = overrides => {
|
|
22
|
-
const args = {
|
|
22
|
+
const args = {
|
|
23
|
+
route,
|
|
24
|
+
attempt_time_ns: '1',
|
|
25
|
+
resolve_time_ns: '1',
|
|
26
|
+
status: 'IN_FLIGHT',
|
|
27
|
+
};
|
|
23
28
|
|
|
24
29
|
Object.keys(overrides).forEach(k => args[k] = overrides[k]);
|
|
25
30
|
|
|
@@ -29,6 +34,8 @@ const makeArgs = overrides => {
|
|
|
29
34
|
const makeExpected = overrides => {
|
|
30
35
|
const attempt = {
|
|
31
36
|
confirmed_at: '1970-01-01T00:00:00.000Z',
|
|
37
|
+
created_at: '1970-01-01T00:00:00.000Z',
|
|
38
|
+
failed_at: undefined,
|
|
32
39
|
is_confirmed: false,
|
|
33
40
|
is_failed: false,
|
|
34
41
|
is_pending: false,
|
|
@@ -64,6 +71,11 @@ const tests = [
|
|
|
64
71
|
description: 'An rpc attempt is required to map to an attempt',
|
|
65
72
|
error: 'ExpectedRpcAttemptDetailsToDeriveAttempt',
|
|
66
73
|
},
|
|
74
|
+
{
|
|
75
|
+
args: makeArgs({attempt_time_ns: undefined}),
|
|
76
|
+
description: 'Expected attempt time in rpc attempt details',
|
|
77
|
+
error: 'ExpectedRpcAttemptStartTimeNs',
|
|
78
|
+
},
|
|
67
79
|
{
|
|
68
80
|
args: makeArgs({resolve_time_ns: undefined}),
|
|
69
81
|
description: 'Expected resolve time in rpc attempt details',
|
|
@@ -82,7 +94,7 @@ const tests = [
|
|
|
82
94
|
{
|
|
83
95
|
args: makeArgs({}),
|
|
84
96
|
description: 'An in flight rpc attempt is mapped to an attempt',
|
|
85
|
-
expected: makeExpected({is_pending: true}),
|
|
97
|
+
expected: makeExpected({confirmed_at: undefined, is_pending: true}),
|
|
86
98
|
},
|
|
87
99
|
{
|
|
88
100
|
args: makeArgs({status: 'SUCCEEDED'}),
|
|
@@ -92,7 +104,11 @@ const tests = [
|
|
|
92
104
|
{
|
|
93
105
|
args: makeArgs({status: 'FAILED'}),
|
|
94
106
|
description: 'An rpc attempt is mapped to an attempt',
|
|
95
|
-
expected: makeExpected({
|
|
107
|
+
expected: makeExpected({
|
|
108
|
+
confirmed_at: undefined,
|
|
109
|
+
failed_at: '1970-01-01T00:00:00.000Z',
|
|
110
|
+
is_failed: true,
|
|
111
|
+
}),
|
|
96
112
|
},
|
|
97
113
|
];
|
|
98
114
|
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
const {test} = require('@alexbosworth/tap');
|
|
2
|
+
|
|
3
|
+
const {rpcGroupSessionAsSession} = require('./../../lnd_responses');
|
|
4
|
+
|
|
5
|
+
const makeArgs = overrides => {
|
|
6
|
+
const args = {
|
|
7
|
+
combined_key: Buffer.alloc(32),
|
|
8
|
+
local_public_nonces: Buffer.alloc(66),
|
|
9
|
+
session_id: Buffer.alloc(32),
|
|
10
|
+
taproot_internal_key: Buffer.alloc(32),
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
Object.keys(overrides).forEach(k => args[k] = overrides[k]);
|
|
14
|
+
|
|
15
|
+
return args;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
const tests = [
|
|
20
|
+
{
|
|
21
|
+
args: null,
|
|
22
|
+
description: 'A response is expected',
|
|
23
|
+
error: 'ExpectedResponseForMuSig2SessionRequest',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
args: makeArgs({combined_key: undefined}),
|
|
27
|
+
description: 'A combined key is expected',
|
|
28
|
+
error: 'ExpectedCombinedPublicKeyInMuSig2SessionResponse',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
args: makeArgs({local_public_nonces: undefined}),
|
|
32
|
+
description: 'Local public nonces are expected',
|
|
33
|
+
error: 'ExpectedLocalPublicNoncesInMuSig2SessionResponse',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
args: makeArgs({session_id: undefined}),
|
|
37
|
+
description: 'A session id is expected',
|
|
38
|
+
error: 'ExpectedMuSig2SigningSessionIdInSessionResponse',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
args: makeArgs({taproot_internal_key: undefined}),
|
|
42
|
+
description: 'A taproot internal key is expected',
|
|
43
|
+
error: 'ExpectedTaprootInternalKeyInMuSig2SessionResponse',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
args: makeArgs({}),
|
|
47
|
+
description: 'Session data is returned',
|
|
48
|
+
expected: {
|
|
49
|
+
external_key: '0000000000000000000000000000000000000000000000000000000000000000',
|
|
50
|
+
id: '0000000000000000000000000000000000000000000000000000000000000000',
|
|
51
|
+
internal_key: '0000000000000000000000000000000000000000000000000000000000000000',
|
|
52
|
+
nonce: '000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
args: makeArgs({taproot_internal_key: Buffer.alloc(0)}),
|
|
57
|
+
description: 'Session data is returned for a script key',
|
|
58
|
+
expected: {
|
|
59
|
+
external_key: '0000000000000000000000000000000000000000000000000000000000000000',
|
|
60
|
+
id: '0000000000000000000000000000000000000000000000000000000000000000',
|
|
61
|
+
internal_key: undefined,
|
|
62
|
+
nonce: '000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
tests.forEach(({args, description, error, expected}) => {
|
|
68
|
+
return test(description, ({end, strictSame, throws}) => {
|
|
69
|
+
if (!!error) {
|
|
70
|
+
throws(() => rpcGroupSessionAsSession(args), new Error(error), 'Error');
|
|
71
|
+
} else {
|
|
72
|
+
const res = rpcGroupSessionAsSession(args);
|
|
73
|
+
|
|
74
|
+
strictSame(res, expected, 'Got expected result');
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return end();
|
|
78
|
+
});
|
|
79
|
+
});
|
|
@@ -73,7 +73,9 @@ const makeArgs = overrides => {
|
|
|
73
73
|
const makeExpected = overrides => {
|
|
74
74
|
const expected = {
|
|
75
75
|
attempts: [{
|
|
76
|
-
confirmed_at:
|
|
76
|
+
confirmed_at: undefined,
|
|
77
|
+
created_at: '1970-01-01T00:00:00.001Z',
|
|
78
|
+
failed_at: '1970-01-01T00:00:00.001Z',
|
|
77
79
|
is_confirmed: false,
|
|
78
80
|
is_failed: true,
|
|
79
81
|
is_pending: false,
|
|
@@ -272,6 +274,8 @@ const tests = [
|
|
|
272
274
|
expected: makeExpected({
|
|
273
275
|
attempts: [{
|
|
274
276
|
confirmed_at: '2020-04-20T19:17:16.160Z',
|
|
277
|
+
created_at: '2020-04-20T19:17:15.428Z',
|
|
278
|
+
failed_at: undefined,
|
|
275
279
|
is_confirmed: true,
|
|
276
280
|
is_failed: false,
|
|
277
281
|
is_pending: false,
|