lightning 9.10.0 → 9.11.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/.github/workflows/unit-test.yml +2 -2
- package/CHANGELOG.md +4 -0
- package/grpc/protos/lightning.proto +75 -0
- package/lnd_methods/invoices/create_hodl_invoice.d.ts +2 -0
- package/lnd_methods/invoices/create_invoice.d.ts +2 -0
- package/lnd_methods/offchain/decode_payment_request.d.ts +2 -16
- package/lnd_methods/offchain/probe_for_route.d.ts +3 -3
- package/lnd_methods/onchain/open_channel.d.ts +22 -2
- package/lnd_methods/onchain/open_channel.js +36 -5
- package/package.json +5 -4
- package/test/lnd_methods/onchain/test_open_channel.js +15 -0
- package/test/typescript/create_hodl_invoice.test-d.ts +13 -4
- package/test/typescript/create_invoice.test-d.ts +13 -4
- package/test/typescript/open_channel.test-d.ts +7 -0
- package/typescript/shared.d.ts +17 -0
|
@@ -11,10 +11,10 @@ jobs:
|
|
|
11
11
|
strategy:
|
|
12
12
|
matrix:
|
|
13
13
|
os: [ubuntu-latest]
|
|
14
|
-
node: ['
|
|
14
|
+
node: ['16', '18', '20']
|
|
15
15
|
steps:
|
|
16
16
|
- uses: actions/checkout@v2
|
|
17
17
|
- uses: actions/setup-node@v2
|
|
18
18
|
- run: npm install
|
|
19
19
|
- name: Run unit tests
|
|
20
|
-
run: npm
|
|
20
|
+
run: npm run unit-tests
|
package/CHANGELOG.md
CHANGED
|
@@ -2128,6 +2128,76 @@ message BatchOpenChannel {
|
|
|
2128
2128
|
the remote peer supports explicit channel negotiation.
|
|
2129
2129
|
*/
|
|
2130
2130
|
CommitmentType commitment_type = 9;
|
|
2131
|
+
|
|
2132
|
+
/*
|
|
2133
|
+
The maximum amount of coins in millisatoshi that can be pending within
|
|
2134
|
+
the channel. It only applies to the remote party.
|
|
2135
|
+
*/
|
|
2136
|
+
uint64 remote_max_value_in_flight_msat = 10;
|
|
2137
|
+
|
|
2138
|
+
/*
|
|
2139
|
+
The maximum number of concurrent HTLCs we will allow the remote party to add
|
|
2140
|
+
to the commitment transaction.
|
|
2141
|
+
*/
|
|
2142
|
+
uint32 remote_max_htlcs = 11;
|
|
2143
|
+
|
|
2144
|
+
/*
|
|
2145
|
+
Max local csv is the maximum csv delay we will allow for our own commitment
|
|
2146
|
+
transaction.
|
|
2147
|
+
*/
|
|
2148
|
+
uint32 max_local_csv = 12;
|
|
2149
|
+
|
|
2150
|
+
/*
|
|
2151
|
+
If this is true, then a zero-conf channel open will be attempted.
|
|
2152
|
+
*/
|
|
2153
|
+
bool zero_conf = 13;
|
|
2154
|
+
|
|
2155
|
+
/*
|
|
2156
|
+
If this is true, then an option-scid-alias channel-type open will be
|
|
2157
|
+
attempted.
|
|
2158
|
+
*/
|
|
2159
|
+
bool scid_alias = 14;
|
|
2160
|
+
|
|
2161
|
+
/*
|
|
2162
|
+
The base fee charged regardless of the number of milli-satoshis sent.
|
|
2163
|
+
*/
|
|
2164
|
+
uint64 base_fee = 15;
|
|
2165
|
+
|
|
2166
|
+
/*
|
|
2167
|
+
The fee rate in ppm (parts per million) that will be charged in
|
|
2168
|
+
proportion of the value of each forwarded HTLC.
|
|
2169
|
+
*/
|
|
2170
|
+
uint64 fee_rate = 16;
|
|
2171
|
+
|
|
2172
|
+
/*
|
|
2173
|
+
If use_base_fee is true the open channel announcement will update the
|
|
2174
|
+
channel base fee with the value specified in base_fee. In the case of
|
|
2175
|
+
a base_fee of 0 use_base_fee is needed downstream to distinguish whether
|
|
2176
|
+
to use the default base fee value specified in the config or 0.
|
|
2177
|
+
*/
|
|
2178
|
+
bool use_base_fee = 17;
|
|
2179
|
+
|
|
2180
|
+
/*
|
|
2181
|
+
If use_fee_rate is true the open channel announcement will update the
|
|
2182
|
+
channel fee rate with the value specified in fee_rate. In the case of
|
|
2183
|
+
a fee_rate of 0 use_fee_rate is needed downstream to distinguish whether
|
|
2184
|
+
to use the default fee rate value specified in the config or 0.
|
|
2185
|
+
*/
|
|
2186
|
+
bool use_fee_rate = 18;
|
|
2187
|
+
|
|
2188
|
+
/*
|
|
2189
|
+
The number of satoshis we require the remote peer to reserve. This value,
|
|
2190
|
+
if specified, must be above the dust limit and below 20% of the channel
|
|
2191
|
+
capacity.
|
|
2192
|
+
*/
|
|
2193
|
+
uint64 remote_chan_reserve_sat = 19;
|
|
2194
|
+
|
|
2195
|
+
/*
|
|
2196
|
+
An optional note-to-self to go along with the channel containing some
|
|
2197
|
+
useful information. This is only ever stored locally and in no way impacts
|
|
2198
|
+
the channel's operation.
|
|
2199
|
+
*/
|
|
2200
|
+
string memo = 20;
|
|
2131
2201
|
}
|
|
2132
2202
|
|
|
2133
2203
|
message BatchOpenChannelResponse {
|
|
@@ -2290,6 +2360,11 @@ message OpenChannelRequest {
|
|
|
2290
2360
|
the channel's operation.
|
|
2291
2361
|
*/
|
|
2292
2362
|
string memo = 27;
|
|
2363
|
+
|
|
2364
|
+
/*
|
|
2365
|
+
A list of selected outpoints that are allocated for channel funding.
|
|
2366
|
+
*/
|
|
2367
|
+
repeated OutPoint outpoints = 28;
|
|
2293
2368
|
}
|
|
2294
2369
|
message OpenStatusUpdate {
|
|
2295
2370
|
oneof update {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AuthenticatedLightningArgs,
|
|
3
3
|
AuthenticatedLightningMethod,
|
|
4
|
+
Routes,
|
|
4
5
|
} from '../../typescript';
|
|
5
6
|
|
|
6
7
|
export type CreateHodlInvoiceArgs = AuthenticatedLightningArgs<{
|
|
@@ -22,6 +23,7 @@ export type CreateHodlInvoiceArgs = AuthenticatedLightningArgs<{
|
|
|
22
23
|
is_including_private_channels?: boolean;
|
|
23
24
|
/** Millitokens */
|
|
24
25
|
mtokens?: string;
|
|
26
|
+
routes?: Routes;
|
|
25
27
|
/** Tokens */
|
|
26
28
|
tokens?: number;
|
|
27
29
|
}>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AuthenticatedLightningArgs,
|
|
3
3
|
AuthenticatedLightningMethod,
|
|
4
|
+
Routes,
|
|
4
5
|
} from '../../typescript';
|
|
5
6
|
|
|
6
7
|
export type CreateInvoiceArgs = AuthenticatedLightningArgs<{
|
|
@@ -22,6 +23,7 @@ export type CreateInvoiceArgs = AuthenticatedLightningArgs<{
|
|
|
22
23
|
secret?: string;
|
|
23
24
|
/** Millitokens */
|
|
24
25
|
mtokens?: string;
|
|
26
|
+
routes?: Routes;
|
|
25
27
|
/** Tokens */
|
|
26
28
|
tokens?: number;
|
|
27
29
|
}>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
AuthenticatedLightningArgs,
|
|
3
3
|
AuthenticatedLightningMethod,
|
|
4
|
+
Routes,
|
|
4
5
|
} from '../../typescript';
|
|
5
6
|
|
|
6
7
|
export type DecodePaymentRequestArgs = AuthenticatedLightningArgs<{
|
|
@@ -8,21 +9,6 @@ export type DecodePaymentRequestArgs = AuthenticatedLightningArgs<{
|
|
|
8
9
|
request: string;
|
|
9
10
|
}>;
|
|
10
11
|
|
|
11
|
-
export type DecodePaymentRouteEdge = {
|
|
12
|
-
/** Base Routing Fee In Millitokens */
|
|
13
|
-
base_fee_mtokens?: string;
|
|
14
|
-
/** Standard Format Channel Id */
|
|
15
|
-
channel?: string;
|
|
16
|
-
/** CLTV Blocks Delta */
|
|
17
|
-
cltv_delta?: number;
|
|
18
|
-
/** Fees Charged in Millitokens Per Million */
|
|
19
|
-
fee_rate?: number;
|
|
20
|
-
/** Forward Edge Public Key Hex */
|
|
21
|
-
public_key: string;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export type DecodePaymentRoutes = DecodePaymentRouteEdge[][];
|
|
25
|
-
|
|
26
12
|
export type DecodePaymentRequestResult = {
|
|
27
13
|
/** Fallback Chain Address */
|
|
28
14
|
chain_address: string;
|
|
@@ -52,7 +38,7 @@ export type DecodePaymentRequestResult = {
|
|
|
52
38
|
mtokens: string;
|
|
53
39
|
/** Payment Identifier Hex Encoded */
|
|
54
40
|
payment?: string;
|
|
55
|
-
routes:
|
|
41
|
+
routes: Routes;
|
|
56
42
|
/** Requested Tokens Rounded Up */
|
|
57
43
|
safe_tokens: number;
|
|
58
44
|
/** Requested Tokens Rounded Down */
|
|
@@ -2,15 +2,15 @@ import type {MergeExclusive} from 'type-fest';
|
|
|
2
2
|
import type {
|
|
3
3
|
AuthenticatedLightningArgs,
|
|
4
4
|
AuthenticatedLightningMethod,
|
|
5
|
+
RouteNode,
|
|
5
6
|
} from '../../typescript';
|
|
6
|
-
import type {DecodePaymentRouteEdge} from './decode_payment_request';
|
|
7
7
|
|
|
8
|
-
export type
|
|
8
|
+
export type ProbeForRouteNode = RouteNode & {
|
|
9
9
|
/** Channel Capacity Tokens Number */
|
|
10
10
|
channel_capacity?: number;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
export type ProbeForRouteRoutes =
|
|
13
|
+
export type ProbeForRouteRoutes = ProbeForRouteNode[][];
|
|
14
14
|
|
|
15
15
|
export type ProbeForRouteArgs = AuthenticatedLightningArgs<
|
|
16
16
|
{
|
|
@@ -3,6 +3,13 @@ import {
|
|
|
3
3
|
AuthenticatedLightningMethod,
|
|
4
4
|
} from '../../typescript';
|
|
5
5
|
|
|
6
|
+
export type ChannelOpenOptionsInput = {
|
|
7
|
+
/** Fund With Unspent Transaction Id Hex String */
|
|
8
|
+
transaction_id: string
|
|
9
|
+
/** Fund With Unspent Transaction Output Index Number */
|
|
10
|
+
transaction_vout: number
|
|
11
|
+
}
|
|
12
|
+
|
|
6
13
|
export type ChannelOpenOptions = {
|
|
7
14
|
/** Routing Base Fee Millitokens Charged String */
|
|
8
15
|
base_fee_mtokens?: string;
|
|
@@ -16,6 +23,9 @@ export type ChannelOpenOptions = {
|
|
|
16
23
|
fee_rate?: number;
|
|
17
24
|
/** Tokens to Gift To Partner */
|
|
18
25
|
give_tokens?: number;
|
|
26
|
+
inputs?: ChannelOpenOptionsInput[]
|
|
27
|
+
/** Use Maximal Chain Funds For Local Funding Bool */
|
|
28
|
+
is_max_funding?: boolean;
|
|
19
29
|
/** Channel is Private */
|
|
20
30
|
is_private?: boolean;
|
|
21
31
|
/** Peer Should Avoid Waiting For Confirmation */
|
|
@@ -26,10 +36,10 @@ export type ChannelOpenOptions = {
|
|
|
26
36
|
min_confirmations?: number;
|
|
27
37
|
/** Minimum HTLC Millitokens */
|
|
28
38
|
min_htlc_mtokens?: string;
|
|
29
|
-
/** Public Key Hex */
|
|
30
|
-
partner_public_key: string;
|
|
31
39
|
/** Peer Output CSV Delay */
|
|
32
40
|
partner_csv_delay?: number;
|
|
41
|
+
/** Public Key Hex */
|
|
42
|
+
partner_public_key: string;
|
|
33
43
|
/** Peer Connection Host:Port */
|
|
34
44
|
partner_socket?: string;
|
|
35
45
|
};
|
|
@@ -54,8 +64,18 @@ export type OpenChannelResult = {
|
|
|
54
64
|
*
|
|
55
65
|
* External funding requires LND compiled with `walletrpc` build tag
|
|
56
66
|
*
|
|
67
|
+
* `is_trusted_funding` is not supported on LND 0.15.0 and below and requires
|
|
68
|
+
* `--protocol.option-scid-alias` and `--protocol.zero-conf` set on both sides
|
|
69
|
+
* as well as a channel open request listener to accept the trusted funding.
|
|
70
|
+
*
|
|
57
71
|
* `base_fee_mtokens` is not supported on LND 0.15.5 and below
|
|
58
72
|
* `fee_rate` is not supported on LND 0.15.5 and below
|
|
73
|
+
*
|
|
74
|
+
* `is_max_funding` is not supported on LND 0.16.4 and below
|
|
75
|
+
*
|
|
76
|
+
* `description` is not supported on LND 0.16.4 and below
|
|
77
|
+
*
|
|
78
|
+
* `inputs` is not supported on LND 0.16.4 and below
|
|
59
79
|
*/
|
|
60
80
|
export const openChannel: AuthenticatedLightningMethod<
|
|
61
81
|
OpenChannelArgs,
|
|
@@ -8,11 +8,11 @@ const anchors = 'ANCHORS';
|
|
|
8
8
|
const defaultMinConfs = 1;
|
|
9
9
|
const defaultMinHtlcMtokens = '1';
|
|
10
10
|
const errMemoLength = /^provided memo \(.*\) is of length \d*, exceeds (\d*)$/;
|
|
11
|
+
const {isArray} = Array;
|
|
11
12
|
const minChannelTokens = 20000;
|
|
12
13
|
const method = 'openChannel';
|
|
13
14
|
const type = 'default';
|
|
14
15
|
|
|
15
|
-
|
|
16
16
|
/** Open a new channel.
|
|
17
17
|
|
|
18
18
|
The capacity of the channel is set with local_tokens
|
|
@@ -23,6 +23,10 @@ const type = 'default';
|
|
|
23
23
|
|
|
24
24
|
External funding requires LND compiled with `walletrpc` build tag
|
|
25
25
|
|
|
26
|
+
`is_trusted_funding` is not supported on LND 0.15.0 and below and requires
|
|
27
|
+
`--protocol.option-scid-alias` and `--protocol.zero-conf` set on both sides
|
|
28
|
+
as well as a channel open request listener to accept the trusted funding.
|
|
29
|
+
|
|
26
30
|
`base_fee_mtokens` is not supported on LND 0.15.5 and below
|
|
27
31
|
`fee_rate` is not supported on LND 0.15.5 and below
|
|
28
32
|
|
|
@@ -30,9 +34,7 @@ const type = 'default';
|
|
|
30
34
|
|
|
31
35
|
`description` is not supported on LND 0.16.4 and below
|
|
32
36
|
|
|
33
|
-
`
|
|
34
|
-
`--protocol.option-scid-alias` and `--protocol.zero-conf` set on both sides
|
|
35
|
-
as well as a channel open request listener to accept the trusted funding.
|
|
37
|
+
`inputs` is not supported on LND 0.16.4 and below
|
|
36
38
|
|
|
37
39
|
{
|
|
38
40
|
[base_fee_mtokens]: <Routing Base Fee Millitokens Charged String>
|
|
@@ -41,6 +43,10 @@ const type = 'default';
|
|
|
41
43
|
[description]: <Immutable Channel Description String>
|
|
42
44
|
[fee_rate]: <Routing Fee Rate In Millitokens Per Million Number>
|
|
43
45
|
[give_tokens]: <Tokens to Gift To Partner Number> // Defaults to zero
|
|
46
|
+
[inputs]: [{
|
|
47
|
+
transaction_id: <Fund With Unspent Transaction Id Hex String>
|
|
48
|
+
transaction_vout: <Fund With Unspent Transaction Output Index Number>
|
|
49
|
+
}]
|
|
44
50
|
[is_max_funding]: <Use Maximal Chain Funds For Local Funding Bool>
|
|
45
51
|
[is_private]: <Channel is Private Bool> // Defaults to false
|
|
46
52
|
[is_trusted_funding]: <Accept Funding as Trusted Bool>
|
|
@@ -76,6 +82,10 @@ module.exports = (args, cbk) => {
|
|
|
76
82
|
return cbk([400, 'ExpectedLargerChannelSizeForChannelOpen']);
|
|
77
83
|
}
|
|
78
84
|
|
|
85
|
+
if (!!args.inputs && !isArray(args.inputs)) {
|
|
86
|
+
return cbk([400, 'ExpectedArrayOfTransactionOutpointsAsInputs']);
|
|
87
|
+
}
|
|
88
|
+
|
|
79
89
|
if (!args.partner_public_key) {
|
|
80
90
|
return cbk([400, 'ExpectedPartnerPublicKeyForChannelOpen']);
|
|
81
91
|
}
|
|
@@ -106,8 +116,28 @@ module.exports = (args, cbk) => {
|
|
|
106
116
|
return cbk(null, args.min_confirmations);
|
|
107
117
|
}],
|
|
108
118
|
|
|
119
|
+
// Determine which inputs should be used to fund the channel
|
|
120
|
+
outpoints: ['validate', ({}, cbk) => {
|
|
121
|
+
// Exit early when there are no specific UTXOs to spend
|
|
122
|
+
if (!args.inputs) {
|
|
123
|
+
return cbk();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const utxos = args.inputs.map(input => ({
|
|
127
|
+
output_index: input.transaction_vout,
|
|
128
|
+
txid_str: input.transaction_id,
|
|
129
|
+
}));
|
|
130
|
+
|
|
131
|
+
return cbk(null, utxos);
|
|
132
|
+
}],
|
|
133
|
+
|
|
109
134
|
// Open the channel
|
|
110
|
-
openChannel: [
|
|
135
|
+
openChannel: [
|
|
136
|
+
'connect',
|
|
137
|
+
'minConfs',
|
|
138
|
+
'outpoints',
|
|
139
|
+
({minConfs, outpoints}, cbk) =>
|
|
140
|
+
{
|
|
111
141
|
let isAnnounced = false;
|
|
112
142
|
|
|
113
143
|
const options = {
|
|
@@ -120,6 +150,7 @@ module.exports = (args, cbk) => {
|
|
|
120
150
|
min_confs: minConfs,
|
|
121
151
|
min_htlc_msat: args.min_htlc_mtokens || defaultMinHtlcMtokens,
|
|
122
152
|
node_pubkey: Buffer.from(args.partner_public_key, 'hex'),
|
|
153
|
+
outpoints: outpoints || undefined,
|
|
123
154
|
private: !!args.is_private,
|
|
124
155
|
remote_csv_delay: args.partner_csv_delay || undefined,
|
|
125
156
|
spend_unconfirmed: !minConfs,
|
package/package.json
CHANGED
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
"url": "https://github.com/alexbosworth/lightning/issues"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@grpc/grpc-js": "1.
|
|
10
|
+
"@grpc/grpc-js": "1.9.0",
|
|
11
11
|
"@grpc/proto-loader": "0.7.8",
|
|
12
12
|
"@types/express": "4.17.17",
|
|
13
|
-
"@types/node": "20.4.
|
|
13
|
+
"@types/node": "20.4.6",
|
|
14
14
|
"@types/request": "2.48.8",
|
|
15
15
|
"@types/ws": "8.5.5",
|
|
16
16
|
"async": "3.2.4",
|
|
@@ -52,11 +52,12 @@
|
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"test": "npx nyc@15.1.0 node --experimental-test-coverage --test && npm run test:types",
|
|
55
|
-
"test:types": "tsd"
|
|
55
|
+
"test:types": "tsd",
|
|
56
|
+
"unit-tests": "node --test && npm run test:types"
|
|
56
57
|
},
|
|
57
58
|
"tsd": {
|
|
58
59
|
"directory": "test/typescript"
|
|
59
60
|
},
|
|
60
61
|
"types": "index.d.ts",
|
|
61
|
-
"version": "9.
|
|
62
|
+
"version": "9.11.1"
|
|
62
63
|
}
|
|
@@ -121,6 +121,11 @@ const tests = [
|
|
|
121
121
|
description: 'A public key is required',
|
|
122
122
|
error: [400, 'ExpectedPartnerPublicKeyForChannelOpen'],
|
|
123
123
|
},
|
|
124
|
+
{
|
|
125
|
+
args: makeArgs({inputs: 'inputs'}),
|
|
126
|
+
description: 'A channel is opened with a tx id set',
|
|
127
|
+
error: [400, 'ExpectedArrayOfTransactionOutpointsAsInputs'],
|
|
128
|
+
},
|
|
124
129
|
{
|
|
125
130
|
args: makeArgs({
|
|
126
131
|
public_key: Buffer.alloc(33).toString('hex'),
|
|
@@ -129,6 +134,16 @@ const tests = [
|
|
|
129
134
|
description: 'A peer is connected before opening',
|
|
130
135
|
expected: {transaction_id: '04030201', transaction_vout: 0},
|
|
131
136
|
},
|
|
137
|
+
{
|
|
138
|
+
args: makeArgs({
|
|
139
|
+
inputs: [{
|
|
140
|
+
transaction_id: Buffer.alloc(32).toString('hex'),
|
|
141
|
+
transaction_vout: 0,
|
|
142
|
+
}],
|
|
143
|
+
}),
|
|
144
|
+
description: 'A channel is opened with a tx id set',
|
|
145
|
+
expected: {transaction_id: '04030201', transaction_vout: 0},
|
|
146
|
+
},
|
|
132
147
|
{
|
|
133
148
|
args: makeArgs({}),
|
|
134
149
|
description: 'A channel is opened',
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {expectError, expectType} from 'tsd';
|
|
2
2
|
import {AuthenticatedLnd} from '../../lnd_grpc';
|
|
3
3
|
import {createHodlInvoice, CreateHodlInvoiceResult} from '../../lnd_methods';
|
|
4
|
+
import {Routes} from '../../typescript';
|
|
4
5
|
|
|
5
6
|
const lnd = {} as AuthenticatedLnd;
|
|
6
7
|
const cltv_delta = 1;
|
|
@@ -12,6 +13,13 @@ const is_fallback_nested = true;
|
|
|
12
13
|
const is_including_private_channels = true;
|
|
13
14
|
const mtokens = '1000';
|
|
14
15
|
const tokens = 1;
|
|
16
|
+
const routes: Routes = [[{
|
|
17
|
+
base_fee_mtokens: '1',
|
|
18
|
+
channel: '0',
|
|
19
|
+
cltv_delta: 1,
|
|
20
|
+
fee_rate: 1,
|
|
21
|
+
public_key: 'pubkey'
|
|
22
|
+
}]];
|
|
15
23
|
|
|
16
24
|
expectError(createHodlInvoice());
|
|
17
25
|
expectError(createHodlInvoice({}));
|
|
@@ -29,13 +37,13 @@ expectType<CreateHodlInvoiceResult>(
|
|
|
29
37
|
is_including_private_channels,
|
|
30
38
|
mtokens,
|
|
31
39
|
tokens,
|
|
32
|
-
|
|
40
|
+
})
|
|
33
41
|
);
|
|
34
42
|
|
|
35
43
|
expectType<void>(
|
|
36
44
|
createHodlInvoice({lnd}, (error, result) => {
|
|
37
45
|
expectType<CreateHodlInvoiceResult>(result);
|
|
38
|
-
|
|
46
|
+
})
|
|
39
47
|
);
|
|
40
48
|
expectType<void>(
|
|
41
49
|
createHodlInvoice(
|
|
@@ -49,10 +57,11 @@ expectType<void>(
|
|
|
49
57
|
is_fallback_nested,
|
|
50
58
|
is_including_private_channels,
|
|
51
59
|
mtokens,
|
|
60
|
+
routes,
|
|
52
61
|
tokens,
|
|
53
|
-
|
|
62
|
+
},
|
|
54
63
|
(error, result) => {
|
|
55
64
|
expectType<CreateHodlInvoiceResult>(result);
|
|
56
|
-
|
|
65
|
+
}
|
|
57
66
|
)
|
|
58
67
|
);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {expectError, expectType} from 'tsd';
|
|
2
2
|
import {AuthenticatedLnd} from '../../lnd_grpc';
|
|
3
3
|
import {createInvoice, CreateInvoiceResult} from '../../lnd_methods';
|
|
4
|
+
import {Routes} from '../../typescript';
|
|
4
5
|
|
|
5
6
|
const lnd = {} as AuthenticatedLnd;
|
|
6
7
|
const cltv_delta = 1;
|
|
@@ -12,6 +13,13 @@ const is_including_private_channels = true;
|
|
|
12
13
|
const secret = Buffer.alloc(32).toString('hex');
|
|
13
14
|
const mtokens = '1000';
|
|
14
15
|
const tokens = 1;
|
|
16
|
+
const routes: Routes = [[{
|
|
17
|
+
base_fee_mtokens: '1',
|
|
18
|
+
channel: '0',
|
|
19
|
+
cltv_delta: 1,
|
|
20
|
+
fee_rate: 1,
|
|
21
|
+
public_key: 'pubkey'
|
|
22
|
+
}]];
|
|
15
23
|
|
|
16
24
|
expectError(createInvoice());
|
|
17
25
|
expectError(createInvoice({}));
|
|
@@ -29,13 +37,13 @@ expectType<CreateInvoiceResult>(
|
|
|
29
37
|
secret,
|
|
30
38
|
mtokens,
|
|
31
39
|
tokens,
|
|
32
|
-
|
|
40
|
+
})
|
|
33
41
|
);
|
|
34
42
|
|
|
35
43
|
expectType<void>(
|
|
36
44
|
createInvoice({lnd}, (error, result) => {
|
|
37
45
|
expectType<CreateInvoiceResult>(result);
|
|
38
|
-
|
|
46
|
+
})
|
|
39
47
|
);
|
|
40
48
|
expectType<void>(
|
|
41
49
|
createInvoice(
|
|
@@ -49,10 +57,11 @@ expectType<void>(
|
|
|
49
57
|
is_including_private_channels,
|
|
50
58
|
secret,
|
|
51
59
|
mtokens,
|
|
60
|
+
routes,
|
|
52
61
|
tokens,
|
|
53
|
-
|
|
62
|
+
},
|
|
54
63
|
(error, result) => {
|
|
55
64
|
expectType<CreateInvoiceResult>(result);
|
|
56
|
-
|
|
65
|
+
}
|
|
57
66
|
)
|
|
58
67
|
);
|
|
@@ -10,6 +10,9 @@ const chain_fee_tokens_per_vbyte = 1;
|
|
|
10
10
|
const cooperative_close_address = 'close_address';
|
|
11
11
|
const give_tokens = 1;
|
|
12
12
|
|
|
13
|
+
const is_max_funding = true;
|
|
14
|
+
const inputs = [{transaction_id: 'id', transaction_vout: 0}];
|
|
15
|
+
|
|
13
16
|
expectError(openChannel());
|
|
14
17
|
expectError(openChannel({}));
|
|
15
18
|
expectError(openChannel({local_tokens}));
|
|
@@ -29,6 +32,8 @@ expectType<OpenChannelResult>(
|
|
|
29
32
|
chain_fee_tokens_per_vbyte,
|
|
30
33
|
cooperative_close_address,
|
|
31
34
|
give_tokens,
|
|
35
|
+
is_max_funding,
|
|
36
|
+
inputs,
|
|
32
37
|
})
|
|
33
38
|
);
|
|
34
39
|
|
|
@@ -46,6 +51,8 @@ expectType<void>(
|
|
|
46
51
|
chain_fee_tokens_per_vbyte,
|
|
47
52
|
cooperative_close_address,
|
|
48
53
|
give_tokens,
|
|
54
|
+
is_max_funding,
|
|
55
|
+
inputs,
|
|
49
56
|
},
|
|
50
57
|
(error, result) => {
|
|
51
58
|
expectType<OpenChannelResult>(result);
|
package/typescript/shared.d.ts
CHANGED
|
@@ -101,3 +101,20 @@ export type DateRangeFilterArgs = {
|
|
|
101
101
|
/** Creation Date Before or Equal to ISO 8601 Date String */
|
|
102
102
|
created_before?: string;
|
|
103
103
|
};
|
|
104
|
+
|
|
105
|
+
export type RouteNode = {
|
|
106
|
+
/** Base Routing Fee In Millitokens */
|
|
107
|
+
base_fee_mtokens?: string;
|
|
108
|
+
/** Standard Format Channel Id */
|
|
109
|
+
channel?: string;
|
|
110
|
+
/** CLTV Blocks Delta */
|
|
111
|
+
cltv_delta?: number;
|
|
112
|
+
/** Fees Charged in Millitokens Per Million */
|
|
113
|
+
fee_rate?: number;
|
|
114
|
+
/** Forward Edge Public Key Hex */
|
|
115
|
+
public_key: string;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export type Route = RouteNode[]
|
|
119
|
+
|
|
120
|
+
export type Routes = Route[]
|