lightning 10.9.2 → 10.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 +10 -0
- package/README.md +4 -0
- package/grpc/protos/lightning.proto +6 -0
- package/grpc/protos/walletkit.proto +84 -37
- package/index.js +4 -0
- package/lnd_messages/close_channel_request.js +2 -2
- package/lnd_methods/index.js +4 -0
- package/lnd_methods/macaroon/methods.json +9 -0
- package/lnd_methods/offchain/delete_payments.js +1 -1
- package/lnd_methods/offchain/get_connected_watchtowers.js +3 -3
- package/lnd_methods/onchain/close_channel.js +24 -3
- package/lnd_methods/onchain/get_chain_fee_estimate.js +4 -15
- package/lnd_methods/onchain/get_pending_sweeps.js +81 -0
- package/lnd_methods/onchain/index.js +4 -0
- package/lnd_methods/onchain/open_channel.js +4 -1
- package/lnd_methods/onchain/request_batched_fee_increase.js +108 -0
- package/lnd_methods/onchain/request_chain_fee_increase.js +3 -2
- package/lnd_methods/onchain/send_to_chain_address.js +14 -3
- package/lnd_methods/onchain/send_to_chain_addresses.js +14 -3
- package/lnd_responses/index.js +2 -0
- package/lnd_responses/rpc_sweep_as_sweep.js +96 -0
- package/package.json +6 -6
- package/test/lnd_messages/test_close_channel_request.js +2 -2
- package/test/lnd_methods/macaroon/test_handle_rpc_request_update.js +1 -1
- package/test/lnd_methods/offchain/test_get_connected_watchtowers.js +2 -2
- package/test/lnd_methods/onchain/test_get_chain_fee_estimate.js +0 -41
- package/test/lnd_methods/onchain/test_get_pending_sweeps.js +92 -0
- package/test/lnd_methods/onchain/test_request_batched_fee_increase.js +111 -0
- package/test/lnd_methods/onchain/test_send_to_chain_address.js +27 -44
- package/test/lnd_methods/onchain/test_send_to_chain_addresses.js +25 -42
- package/test/lnd_responses/test_rpc_sweep_as_sweep.js +135 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const {deepEqual} = require('node:assert').strict;
|
|
2
2
|
const {rejects} = require('node:assert').strict;
|
|
3
3
|
const test = require('node:test');
|
|
4
4
|
|
|
@@ -22,6 +22,20 @@ const makeArgs = overrides => {
|
|
|
22
22
|
return args;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
+
const makeExpected = overrides => {
|
|
26
|
+
const args = {
|
|
27
|
+
confirmation_count: 0,
|
|
28
|
+
id: Buffer.alloc(32).toString('hex'),
|
|
29
|
+
is_confirmed: false,
|
|
30
|
+
is_outgoing: true,
|
|
31
|
+
tokens: 1,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
Object.keys(overrides).forEach(k => args[k] = overrides[k]);
|
|
35
|
+
|
|
36
|
+
return args;
|
|
37
|
+
};
|
|
38
|
+
|
|
25
39
|
const tests = [
|
|
26
40
|
{
|
|
27
41
|
args: makeArgs({address: undefined}),
|
|
@@ -89,35 +103,17 @@ const tests = [
|
|
|
89
103
|
{
|
|
90
104
|
args: makeArgs({log: console.log, wss: [{clients: [null]}]}),
|
|
91
105
|
description: 'Send coins with null wss client',
|
|
92
|
-
expected: {
|
|
93
|
-
confirmation_count: 0,
|
|
94
|
-
id: Buffer.alloc(32).toString('hex'),
|
|
95
|
-
is_confirmed: false,
|
|
96
|
-
is_outgoing: true,
|
|
97
|
-
tokens: 1,
|
|
98
|
-
},
|
|
106
|
+
expected: makeExpected({}),
|
|
99
107
|
},
|
|
100
108
|
{
|
|
101
109
|
args: makeArgs({log: console.log, wss: [{clients: [{}]}]}),
|
|
102
110
|
description: 'Send coins with no ready state',
|
|
103
|
-
expected: {
|
|
104
|
-
confirmation_count: 0,
|
|
105
|
-
id: Buffer.alloc(32).toString('hex'),
|
|
106
|
-
is_confirmed: false,
|
|
107
|
-
is_outgoing: true,
|
|
108
|
-
tokens: 1,
|
|
109
|
-
},
|
|
111
|
+
expected: makeExpected({}),
|
|
110
112
|
},
|
|
111
113
|
{
|
|
112
114
|
args: makeArgs({log: () => {}, wss: [{clients: [{readyState: 1}]}]}),
|
|
113
115
|
description: 'Send coins with no send method',
|
|
114
|
-
expected: {
|
|
115
|
-
confirmation_count: 0,
|
|
116
|
-
id: Buffer.alloc(32).toString('hex'),
|
|
117
|
-
is_confirmed: false,
|
|
118
|
-
is_outgoing: true,
|
|
119
|
-
tokens: 1,
|
|
120
|
-
},
|
|
116
|
+
expected: makeExpected({}),
|
|
121
117
|
},
|
|
122
118
|
{
|
|
123
119
|
args: makeArgs({
|
|
@@ -127,35 +123,22 @@ const tests = [
|
|
|
127
123
|
tokens: undefined,
|
|
128
124
|
}),
|
|
129
125
|
description: 'Send coins with broadcast',
|
|
130
|
-
expected: {
|
|
131
|
-
confirmation_count: 0,
|
|
132
|
-
id: Buffer.alloc(32).toString('hex'),
|
|
133
|
-
is_confirmed: false,
|
|
134
|
-
is_outgoing: true,
|
|
135
|
-
tokens: undefined,
|
|
136
|
-
},
|
|
126
|
+
expected: makeExpected({tokens: undefined}),
|
|
137
127
|
},
|
|
138
128
|
{
|
|
139
129
|
args: makeArgs({}),
|
|
140
130
|
description: 'Send coins',
|
|
141
|
-
expected: {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
},
|
|
131
|
+
expected: makeExpected({}),
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
args: makeArgs({fee_tokens_per_vbyte: 1}),
|
|
135
|
+
description: 'Send coins with a fee rate',
|
|
136
|
+
expected: makeExpected({}),
|
|
148
137
|
},
|
|
149
138
|
{
|
|
150
139
|
args: makeArgs({utxo_selection: 'random'}),
|
|
151
140
|
description: 'Send coins with coin selection',
|
|
152
|
-
expected: {
|
|
153
|
-
confirmation_count: 0,
|
|
154
|
-
id: Buffer.alloc(32).toString('hex'),
|
|
155
|
-
is_confirmed: false,
|
|
156
|
-
is_outgoing: true,
|
|
157
|
-
tokens: 1,
|
|
158
|
-
},
|
|
141
|
+
expected: makeExpected({}),
|
|
159
142
|
},
|
|
160
143
|
];
|
|
161
144
|
|
|
@@ -166,7 +149,7 @@ tests.forEach(({args, description, error, expected}) => {
|
|
|
166
149
|
} else {
|
|
167
150
|
const res = await sendToChainAddress(args);
|
|
168
151
|
|
|
169
|
-
|
|
152
|
+
deepEqual(res, expected, 'Got expected result');
|
|
170
153
|
}
|
|
171
154
|
|
|
172
155
|
return;
|
|
@@ -21,6 +21,20 @@ const makeArgs = overrides => {
|
|
|
21
21
|
return args;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
+
const makeExpected = overrides => {
|
|
25
|
+
const args = {
|
|
26
|
+
confirmation_count: 0,
|
|
27
|
+
id: Buffer.alloc(32).toString('hex'),
|
|
28
|
+
is_confirmed: false,
|
|
29
|
+
is_outgoing: true,
|
|
30
|
+
tokens: 1,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
Object.keys(overrides).forEach(k => args[k] = overrides[k]);
|
|
34
|
+
|
|
35
|
+
return args;
|
|
36
|
+
};
|
|
37
|
+
|
|
24
38
|
const tests = [
|
|
25
39
|
{
|
|
26
40
|
args: makeArgs({lnd: undefined}),
|
|
@@ -75,35 +89,17 @@ const tests = [
|
|
|
75
89
|
{
|
|
76
90
|
args: makeArgs({log: console.log, wss: [{clients: [null]}]}),
|
|
77
91
|
description: 'Send coins with null wss client',
|
|
78
|
-
expected: {
|
|
79
|
-
confirmation_count: 0,
|
|
80
|
-
id: Buffer.alloc(32).toString('hex'),
|
|
81
|
-
is_confirmed: false,
|
|
82
|
-
is_outgoing: true,
|
|
83
|
-
tokens: 1,
|
|
84
|
-
},
|
|
92
|
+
expected: makeExpected({}),
|
|
85
93
|
},
|
|
86
94
|
{
|
|
87
95
|
args: makeArgs({log: console.log, wss: [{clients: [{}]}]}),
|
|
88
96
|
description: 'Send coins with no ready state',
|
|
89
|
-
expected: {
|
|
90
|
-
confirmation_count: 0,
|
|
91
|
-
id: Buffer.alloc(32).toString('hex'),
|
|
92
|
-
is_confirmed: false,
|
|
93
|
-
is_outgoing: true,
|
|
94
|
-
tokens: 1,
|
|
95
|
-
},
|
|
97
|
+
expected: makeExpected({}),
|
|
96
98
|
},
|
|
97
99
|
{
|
|
98
100
|
args: makeArgs({log: () => {}, wss: [{clients: [{readyState: 1}]}]}),
|
|
99
101
|
description: 'Send coins with no send method',
|
|
100
|
-
expected: {
|
|
101
|
-
confirmation_count: 0,
|
|
102
|
-
id: Buffer.alloc(32).toString('hex'),
|
|
103
|
-
is_confirmed: false,
|
|
104
|
-
is_outgoing: true,
|
|
105
|
-
tokens: 1,
|
|
106
|
-
},
|
|
102
|
+
expected: makeExpected({}),
|
|
107
103
|
},
|
|
108
104
|
{
|
|
109
105
|
args: makeArgs({
|
|
@@ -111,35 +107,22 @@ const tests = [
|
|
|
111
107
|
wss: [{clients: [{readyState: 1, send: () => {}}]}],
|
|
112
108
|
}),
|
|
113
109
|
description: 'Send coins with broadcast',
|
|
114
|
-
expected: {
|
|
115
|
-
confirmation_count: 0,
|
|
116
|
-
id: Buffer.alloc(32).toString('hex'),
|
|
117
|
-
is_confirmed: false,
|
|
118
|
-
is_outgoing: true,
|
|
119
|
-
tokens: 1,
|
|
120
|
-
},
|
|
110
|
+
expected: makeExpected({}),
|
|
121
111
|
},
|
|
122
112
|
{
|
|
123
113
|
args: makeArgs({}),
|
|
124
114
|
description: 'Send coins',
|
|
125
|
-
expected: {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
},
|
|
115
|
+
expected: makeExpected({}),
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
args: makeArgs({fee_tokens_per_vbyte: 1}),
|
|
119
|
+
description: 'Send coins with fee rate',
|
|
120
|
+
expected: makeExpected({}),
|
|
132
121
|
},
|
|
133
122
|
{
|
|
134
123
|
args: makeArgs({utxo_selection: 'random'}),
|
|
135
124
|
description: 'Send coins with coin selection',
|
|
136
|
-
expected: {
|
|
137
|
-
confirmation_count: 0,
|
|
138
|
-
id: Buffer.alloc(32).toString('hex'),
|
|
139
|
-
is_confirmed: false,
|
|
140
|
-
is_outgoing: true,
|
|
141
|
-
tokens: 1,
|
|
142
|
-
},
|
|
125
|
+
expected: makeExpected({}),
|
|
143
126
|
},
|
|
144
127
|
];
|
|
145
128
|
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
const {deepEqual} = require('node:assert').strict;
|
|
2
|
+
const test = require('node:test');
|
|
3
|
+
const {throws} = require('node:assert').strict;
|
|
4
|
+
|
|
5
|
+
const {rpcSweepAsSweep} = require('./../../lnd_responses');
|
|
6
|
+
|
|
7
|
+
const makeArgs = overrides => {
|
|
8
|
+
const response = {
|
|
9
|
+
amount_sat: 0,
|
|
10
|
+
broadcast_attempts: 0,
|
|
11
|
+
budget: '0',
|
|
12
|
+
deadline_height: 0,
|
|
13
|
+
immediate: true,
|
|
14
|
+
outpoint: {
|
|
15
|
+
output_index: 0,
|
|
16
|
+
txid_str: Buffer.alloc(32).toString('hex'),
|
|
17
|
+
},
|
|
18
|
+
requested_sat_per_vbyte: '0',
|
|
19
|
+
sat_per_vbyte: '0',
|
|
20
|
+
witness_type: 'witness_type',
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
Object.keys(overrides || {}).forEach(key => response[key] = overrides[key]);
|
|
24
|
+
|
|
25
|
+
return response;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
const makeExpected = overrides => {
|
|
30
|
+
const expected = {
|
|
31
|
+
broadcasts_count: 0,
|
|
32
|
+
current_fee_rate: undefined,
|
|
33
|
+
initial_fee_rate: undefined,
|
|
34
|
+
is_batching: false,
|
|
35
|
+
max_fee: undefined,
|
|
36
|
+
max_height: undefined,
|
|
37
|
+
tokens: 0,
|
|
38
|
+
transaction_id: Buffer.alloc(32).toString('hex'),
|
|
39
|
+
transaction_vout: 0,
|
|
40
|
+
type: 'witness_type',
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
Object.keys(overrides || {}).forEach(key => expected[key] = overrides[key]);
|
|
44
|
+
|
|
45
|
+
return expected;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const tests = [
|
|
49
|
+
{
|
|
50
|
+
description: 'Pending sweep details are expected',
|
|
51
|
+
error: 'ExpectedSweepDetailsToDerivePendingSweep',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
args: makeArgs({amount_sat: undefined}),
|
|
55
|
+
description: 'The sweep amount is expected',
|
|
56
|
+
error: 'ExpectedSweepOutpointValueAmountInPendingSweep',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
args: makeArgs({broadcast_attempts: undefined}),
|
|
60
|
+
description: 'The broadcasts count is expected',
|
|
61
|
+
error: 'ExpectedBroadcastAttemptsForSweepInPendingSweep',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
args: makeArgs({budget: undefined}),
|
|
65
|
+
description: 'The sweep budget is expected',
|
|
66
|
+
error: 'ExpectedSweepBudgetAmountForSweepInPendingSweeps',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
args: makeArgs({deadline_height: undefined}),
|
|
70
|
+
description: 'The target deadline is expected',
|
|
71
|
+
error: 'ExpectedSweepConfirmationDeadlineHeightInPendingSweep',
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
args: makeArgs({immediate: undefined}),
|
|
75
|
+
description: 'The immediate status is expected',
|
|
76
|
+
error: 'ExpectedImmediateStatusOfSweepInPendingSweeps',
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
args: makeArgs({outpoint: undefined}),
|
|
80
|
+
description: 'The outpoint being swept is expected',
|
|
81
|
+
error: 'ExpectedUnspentOutpointOfSweepInPendingSweeps',
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
args: makeArgs({outpoint: {}}),
|
|
85
|
+
description: 'The outpoint vout being swept is expected',
|
|
86
|
+
error: 'ExpectedOutputIndexOfSweepInPendingSweeps',
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
args: makeArgs({outpoint: {output_index: 0}}),
|
|
90
|
+
description: 'The outpoint transaction id being swept is expected',
|
|
91
|
+
error: 'ExpectedOutpointTransactionIdHexStringInSweep',
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
args: makeArgs({requested_sat_per_vbyte: undefined}),
|
|
95
|
+
description: 'The requested sweeping chain fee rate is expected',
|
|
96
|
+
error: 'ExpectedRequestedSatPerVByteForSweepInPendingSweeps',
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
args: makeArgs({sat_per_vbyte: undefined}),
|
|
100
|
+
description: 'The sweeping chain fee rate is expected',
|
|
101
|
+
error: 'ExpectedSatPerVByteForSweepInPendingSweeps',
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
args: makeArgs({}),
|
|
105
|
+
description: 'RPC sweep is mapped to pending sweep details',
|
|
106
|
+
expected: makeExpected({}),
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
args: makeArgs({
|
|
110
|
+
budget: '1',
|
|
111
|
+
deadline_height: 1,
|
|
112
|
+
requested_sat_per_vbyte: '1',
|
|
113
|
+
sat_per_vbyte: '1',
|
|
114
|
+
}),
|
|
115
|
+
description: 'RPC sweep with all details is mapped to pending sweep ',
|
|
116
|
+
expected: makeExpected({
|
|
117
|
+
current_fee_rate: 1,
|
|
118
|
+
initial_fee_rate: 1,
|
|
119
|
+
max_fee: 1,
|
|
120
|
+
max_height: 1,
|
|
121
|
+
}),
|
|
122
|
+
},
|
|
123
|
+
];
|
|
124
|
+
|
|
125
|
+
tests.forEach(({args, description, error, expected}) => {
|
|
126
|
+
return test(description, (t, end) => {
|
|
127
|
+
if (!!error) {
|
|
128
|
+
throws(() => rpcSweepAsSweep(args), new Error(error), 'Got err');
|
|
129
|
+
} else {
|
|
130
|
+
deepEqual(rpcSweepAsSweep(args), expected, 'RPC sweep mapped');
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return end();
|
|
134
|
+
});
|
|
135
|
+
});
|