lightning 5.3.3 → 5.4.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/CHANGELOG.md +9 -0
- package/README.md +16 -7
- package/grpc/protos/lightning.proto +16 -4
- package/grpc/protos/router.proto +5 -0
- package/grpc/protos/walletkit.proto +28 -0
- package/index.js +2 -0
- package/lnd_methods/index.js +2 -0
- package/lnd_methods/invoices/get_invoices.d.ts +6 -1
- package/lnd_methods/macaroon/methods.json +4 -0
- package/lnd_methods/offchain/delete_pending_channel.d.ts +21 -0
- package/lnd_methods/offchain/delete_pending_channel.js +5 -0
- package/lnd_methods/offchain/get_failed_payments.js +2 -2
- package/lnd_methods/offchain/get_payments.js +2 -2
- package/lnd_methods/offchain/index.d.ts +1 -0
- package/lnd_methods/onchain/index.js +2 -0
- package/lnd_methods/onchain/partially_sign_psbt.js +79 -0
- package/lnd_methods/peers/get_peers.d.ts +1 -1
- package/lnd_methods/peers/get_peers.js +1 -1
- package/lnd_responses/rpc_peer_as_peer.js +1 -1
- package/package.json +6 -6
- package/test/lnd_methods/offchain/test_delete_pending_channel.js +7 -0
- package/test/lnd_methods/onchain/test_partially_sign_psbt.js +100 -0
- package/test/protos/protos.json +1 -5
- package/test/typescript/delete_pending_channel.test-d.ts +43 -0
- package/test/typescript/get_invoices.test-d.ts +14 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Versions
|
|
2
2
|
|
|
3
|
+
## 5.4.2
|
|
4
|
+
|
|
5
|
+
- `deletePendingChannel`: Add method to delete a stuck pending channel
|
|
6
|
+
- `getInvoices`: Fill in type definition for `is_unconfirmed`
|
|
7
|
+
|
|
8
|
+
## 5.3.4
|
|
9
|
+
|
|
10
|
+
- `getPayments`: Correct paging issue that prevented paging through all results
|
|
11
|
+
|
|
3
12
|
## 5.3.3
|
|
4
13
|
|
|
5
14
|
- `pay`, `payViaPaymentRequest`: Fix support for `outgoing_channels` constraint
|
package/README.md
CHANGED
|
@@ -7,17 +7,26 @@ Methods for working with the Lightning Network
|
|
|
7
7
|
## Selected Projects using Lightning
|
|
8
8
|
|
|
9
9
|
- [coinos.io](https://coinos.io/) - https://github.com/coinos/coinos-server
|
|
10
|
-
- [
|
|
10
|
+
- [Lightning Shell](https://lightningshell.app/) -
|
|
11
|
+
https://github.com/ibz/lightning-shell
|
|
12
|
+
- [LNMarkets](https://twitter.com/lnmarkets) -
|
|
13
|
+
https://github.com/lnmarkets/umbrel
|
|
11
14
|
- [Galoy](https://galoy.io/) - https://github.com/GaloyMoney/galoy
|
|
12
15
|
- [Tarnhelm](https://www.tarnhelm.app/) - https://github.com/bkiac/tarnhelm
|
|
13
|
-
- [tbtcswaps](https://tbtcswaps.com/) -
|
|
14
|
-
|
|
15
|
-
- [
|
|
16
|
-
|
|
17
|
-
- [
|
|
16
|
+
- [tbtcswaps](https://tbtcswaps.com/) -
|
|
17
|
+
https://github.com/keep-community/tbtcswaps
|
|
18
|
+
- [stackernews](https://stacker.news/) -
|
|
19
|
+
https://github.com/stackernews/stacker.news
|
|
20
|
+
- [Thunderhub](https://www.thunderhub.io/) -
|
|
21
|
+
https://github.com/apotdevin/thunderhub
|
|
22
|
+
- [Lightning Roulette](https://lightning-roulette.com/) -
|
|
23
|
+
https://github.com/igreshev/lightning-roulette
|
|
24
|
+
- [Lightning Poker](https://lightning-poker.com/) -
|
|
25
|
+
https://github.com/igreshev/lightning-poker
|
|
18
26
|
- [p2plnbot](https://telegram.me/lnp2pbot) - https://github.com/grunch/p2plnbot
|
|
19
27
|
- [rekr](https://rekr.app/) - https://github.com/ryan-lingle/rekr
|
|
20
|
-
- [Suredbits API](https://suredbits.com/) -
|
|
28
|
+
- [Suredbits API](https://suredbits.com/) -
|
|
29
|
+
https://github.com/Suredbits/sb-api-lnd
|
|
21
30
|
|
|
22
31
|
## LND Authentication
|
|
23
32
|
|
|
@@ -1210,13 +1210,13 @@ enum CommitmentType {
|
|
|
1210
1210
|
/*
|
|
1211
1211
|
Returned when the commitment type isn't known or unavailable.
|
|
1212
1212
|
*/
|
|
1213
|
-
UNKNOWN_COMMITMENT_TYPE =
|
|
1213
|
+
UNKNOWN_COMMITMENT_TYPE = 0;
|
|
1214
1214
|
|
|
1215
1215
|
/*
|
|
1216
1216
|
A channel using the legacy commitment format having tweaked to_remote
|
|
1217
1217
|
keys.
|
|
1218
1218
|
*/
|
|
1219
|
-
LEGACY =
|
|
1219
|
+
LEGACY = 1;
|
|
1220
1220
|
|
|
1221
1221
|
/*
|
|
1222
1222
|
A channel that uses the modern commitment format where the key in the
|
|
@@ -1224,14 +1224,14 @@ enum CommitmentType {
|
|
|
1224
1224
|
up and recovery easier as when the channel is closed, the funds go
|
|
1225
1225
|
directly to that key.
|
|
1226
1226
|
*/
|
|
1227
|
-
STATIC_REMOTE_KEY =
|
|
1227
|
+
STATIC_REMOTE_KEY = 2;
|
|
1228
1228
|
|
|
1229
1229
|
/*
|
|
1230
1230
|
A channel that uses a commitment format that has anchor outputs on the
|
|
1231
1231
|
commitments, allowing fee bumping after a force close transaction has
|
|
1232
1232
|
been broadcast.
|
|
1233
1233
|
*/
|
|
1234
|
-
ANCHORS =
|
|
1234
|
+
ANCHORS = 3;
|
|
1235
1235
|
|
|
1236
1236
|
/*
|
|
1237
1237
|
A channel that uses a commitment type that builds upon the anchors
|
|
@@ -2312,6 +2312,12 @@ message PendingChannelsResponse {
|
|
|
2312
2312
|
|
|
2313
2313
|
// Total number of forwarding packages created in this channel.
|
|
2314
2314
|
int64 num_forwarding_packages = 10;
|
|
2315
|
+
|
|
2316
|
+
// A set of flags showing the current state of the channel.
|
|
2317
|
+
string chan_status_flags = 11;
|
|
2318
|
+
|
|
2319
|
+
// Whether this channel is advertised to the network or not.
|
|
2320
|
+
bool private = 12;
|
|
2315
2321
|
}
|
|
2316
2322
|
|
|
2317
2323
|
message PendingOpenChannel {
|
|
@@ -2353,6 +2359,9 @@ message PendingChannelsResponse {
|
|
|
2353
2359
|
this point.
|
|
2354
2360
|
*/
|
|
2355
2361
|
Commitments commitments = 3;
|
|
2362
|
+
|
|
2363
|
+
// The transaction id of the closing transaction
|
|
2364
|
+
string closing_txid = 4;
|
|
2356
2365
|
}
|
|
2357
2366
|
|
|
2358
2367
|
message Commitments {
|
|
@@ -3742,6 +3751,9 @@ message PolicyUpdateRequest {
|
|
|
3742
3751
|
// goes up to 6 decimal places, so 1e-6.
|
|
3743
3752
|
double fee_rate = 4;
|
|
3744
3753
|
|
|
3754
|
+
// The effective fee rate in micro-satoshis (parts per million).
|
|
3755
|
+
uint32 fee_rate_ppm = 9;
|
|
3756
|
+
|
|
3745
3757
|
// The required timelock delta for HTLCs forwarded over the channel.
|
|
3746
3758
|
uint32 time_lock_delta = 5;
|
|
3747
3759
|
|
package/grpc/protos/router.proto
CHANGED
|
@@ -360,6 +360,11 @@ message QueryMissionControlResponse {
|
|
|
360
360
|
message XImportMissionControlRequest {
|
|
361
361
|
// Node pair-level mission control state to be imported.
|
|
362
362
|
repeated PairHistory pairs = 1;
|
|
363
|
+
|
|
364
|
+
// Whether to force override MC pair history. Note that even with force
|
|
365
|
+
// override the failure pair is imported before the success pair and both
|
|
366
|
+
// still clamp existing failure/success amounts.
|
|
367
|
+
bool force = 2;
|
|
363
368
|
}
|
|
364
369
|
|
|
365
370
|
message XImportMissionControlResponse {
|
|
@@ -200,6 +200,21 @@ service WalletKit {
|
|
|
200
200
|
*/
|
|
201
201
|
rpc FundPsbt (FundPsbtRequest) returns (FundPsbtResponse);
|
|
202
202
|
|
|
203
|
+
/*
|
|
204
|
+
SignPsbt expects a partial transaction with all inputs and outputs fully
|
|
205
|
+
declared and tries to sign all unsigned inputs that have all required fields
|
|
206
|
+
(UTXO information, BIP32 derivation information, witness or sig scripts)
|
|
207
|
+
set.
|
|
208
|
+
If no error is returned, the PSBT is ready to be given to the next signer or
|
|
209
|
+
to be finalized if lnd was the last signer.
|
|
210
|
+
|
|
211
|
+
NOTE: This RPC only signs inputs (and only those it can sign), it does not
|
|
212
|
+
perform any other tasks (such as coin selection, UTXO locking or
|
|
213
|
+
input/output/fee value validation, PSBT finalization). Any input that is
|
|
214
|
+
incomplete will be skipped.
|
|
215
|
+
*/
|
|
216
|
+
rpc SignPsbt (SignPsbtRequest) returns (SignPsbtResponse);
|
|
217
|
+
|
|
203
218
|
/*
|
|
204
219
|
FinalizePsbt expects a partial transaction with all inputs and outputs fully
|
|
205
220
|
declared and tries to sign all inputs that belong to the wallet. Lnd must be
|
|
@@ -820,6 +835,19 @@ message UtxoLease {
|
|
|
820
835
|
uint64 expiration = 3;
|
|
821
836
|
}
|
|
822
837
|
|
|
838
|
+
message SignPsbtRequest {
|
|
839
|
+
/*
|
|
840
|
+
The PSBT that should be signed. The PSBT must contain all required inputs,
|
|
841
|
+
outputs, UTXO data and custom fields required to identify the signing key.
|
|
842
|
+
*/
|
|
843
|
+
bytes funded_psbt = 1;
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
message SignPsbtResponse {
|
|
847
|
+
// The signed transaction in PSBT format.
|
|
848
|
+
bytes signed_psbt = 1;
|
|
849
|
+
}
|
|
850
|
+
|
|
823
851
|
message FinalizePsbtRequest {
|
|
824
852
|
/*
|
|
825
853
|
A PSBT that should be signed and finalized. The PSBT must contain all
|
package/index.js
CHANGED
|
@@ -76,6 +76,7 @@ const {lndGateway} = require('./lnd_gateway');
|
|
|
76
76
|
const {lockUtxo} = require('./lnd_methods');
|
|
77
77
|
const {openChannel} = require('./lnd_methods');
|
|
78
78
|
const {openChannels} = require('./lnd_methods');
|
|
79
|
+
const {partiallySignPsbt} = require('./lnd_methods');
|
|
79
80
|
const {pay} = require('./lnd_methods');
|
|
80
81
|
const {payViaPaymentDetails} = require('./lnd_methods');
|
|
81
82
|
const {payViaPaymentRequest} = require('./lnd_methods');
|
|
@@ -213,6 +214,7 @@ module.exports = {
|
|
|
213
214
|
lockUtxo,
|
|
214
215
|
openChannel,
|
|
215
216
|
openChannels,
|
|
217
|
+
partiallySignPsbt,
|
|
216
218
|
pay,
|
|
217
219
|
payViaPaymentDetails,
|
|
218
220
|
payViaPaymentRequest,
|
package/lnd_methods/index.js
CHANGED
|
@@ -72,6 +72,7 @@ const {isDestinationPayable} = require('./offchain');
|
|
|
72
72
|
const {lockUtxo} = require('./onchain');
|
|
73
73
|
const {openChannel} = require('./onchain');
|
|
74
74
|
const {openChannels} = require('./onchain');
|
|
75
|
+
const {partiallySignPsbt} = require('./onchain');
|
|
75
76
|
const {pay} = require('./offchain');
|
|
76
77
|
const {payViaPaymentDetails} = require('./offchain');
|
|
77
78
|
const {payViaPaymentRequest} = require('./offchain');
|
|
@@ -205,6 +206,7 @@ module.exports = {
|
|
|
205
206
|
lockUtxo,
|
|
206
207
|
openChannel,
|
|
207
208
|
openChannels,
|
|
209
|
+
partiallySignPsbt,
|
|
208
210
|
pay,
|
|
209
211
|
payViaPaymentDetails,
|
|
210
212
|
payViaPaymentRequest,
|
|
@@ -4,7 +4,12 @@ import {
|
|
|
4
4
|
PaginationArgs,
|
|
5
5
|
} from '../../typescript';
|
|
6
6
|
|
|
7
|
-
export type GetInvoicesArgs = AuthenticatedLightningArgs<
|
|
7
|
+
export type GetInvoicesArgs = AuthenticatedLightningArgs<
|
|
8
|
+
PaginationArgs & {
|
|
9
|
+
/** Omit Canceled and Settled Invoices Bool */
|
|
10
|
+
is_unconfirmed?: boolean;
|
|
11
|
+
}
|
|
12
|
+
>;
|
|
8
13
|
|
|
9
14
|
export type GetInvoicesResult = {
|
|
10
15
|
invoices: {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AuthenticatedLightningArgs,
|
|
3
|
+
AuthenticatedLightningMethod,
|
|
4
|
+
} from '../../typescript';
|
|
5
|
+
|
|
6
|
+
export type DeletePendingChannelArgs = AuthenticatedLightningArgs<{
|
|
7
|
+
/** Hex Encoded Conflicting Transaction String */
|
|
8
|
+
confirmed_transaction: string;
|
|
9
|
+
/** Hex Encoded Pending Transaction String */
|
|
10
|
+
pending_transaction: string;
|
|
11
|
+
/** Pending Channel Output Index Number */
|
|
12
|
+
pending_transaction_vout: number;
|
|
13
|
+
}>;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Delete a pending channel
|
|
17
|
+
*
|
|
18
|
+
* Pass the confirmed conflicting transaction that spends the same input to make sure that no funds are being deleted.
|
|
19
|
+
* This method is not supported on LND 0.13.3 and below
|
|
20
|
+
*/
|
|
21
|
+
export const deletePendingChannel: AuthenticatedLightningMethod<DeletePendingChannelArgs>;
|
|
@@ -4,6 +4,7 @@ const {Transaction} = require('bitcoinjs-lib');
|
|
|
4
4
|
|
|
5
5
|
const {fromHex} = Transaction;
|
|
6
6
|
const method = 'abandonChannel';
|
|
7
|
+
const methodUnsupported = 'AbandonChannel RPC call only available in dev builds';
|
|
7
8
|
const txIdAsHash = id => Buffer.from(id, 'hex').reverse();
|
|
8
9
|
const type = 'default';
|
|
9
10
|
|
|
@@ -96,6 +97,10 @@ module.exports = (args, cbk) => {
|
|
|
96
97
|
i_know_what_i_am_doing: true,
|
|
97
98
|
},
|
|
98
99
|
err => {
|
|
100
|
+
if (!!err && err.details === methodUnsupported) {
|
|
101
|
+
return cbk([501, 'DeletePendingChannelMethodNotSupported']);
|
|
102
|
+
}
|
|
103
|
+
|
|
99
104
|
if (!!err) {
|
|
100
105
|
return cbk([503, 'UnexpectedErrorDeletingPendingChannel', {err}]);
|
|
101
106
|
}
|
|
@@ -8,7 +8,7 @@ const {sortBy} = require('./../../arrays');
|
|
|
8
8
|
const defaultLimit = 250;
|
|
9
9
|
const {isArray} = Array;
|
|
10
10
|
const isFailed = payment => !!payment && payment.status === 'FAILED';
|
|
11
|
-
const lastPageFirstIndexOffset =
|
|
11
|
+
const lastPageFirstIndexOffset = 1;
|
|
12
12
|
const method = 'listPayments';
|
|
13
13
|
const {parse} = JSON;
|
|
14
14
|
const {stringify} = JSON;
|
|
@@ -152,7 +152,7 @@ module.exports = ({limit, lnd, token}, cbk) => {
|
|
|
152
152
|
|
|
153
153
|
return cbk(null, {
|
|
154
154
|
payments: res.payments.filter(isFailed),
|
|
155
|
-
token: offset
|
|
155
|
+
token: offset <= lastPageFirstIndexOffset ? undefined : token,
|
|
156
156
|
});
|
|
157
157
|
});
|
|
158
158
|
}],
|
|
@@ -157,7 +157,7 @@ module.exports = ({limit, lnd, token}, cbk) => {
|
|
|
157
157
|
|
|
158
158
|
return cbk(null, {
|
|
159
159
|
payments: res.payments,
|
|
160
|
-
token: offset
|
|
160
|
+
token: offset <= lastPageFirstIndexOffset ? undefined : token,
|
|
161
161
|
});
|
|
162
162
|
});
|
|
163
163
|
}],
|
|
@@ -185,7 +185,7 @@ module.exports = ({limit, lnd, token}, cbk) => {
|
|
|
185
185
|
});
|
|
186
186
|
|
|
187
187
|
return cbk(null, {
|
|
188
|
-
next:
|
|
188
|
+
next: listPayments.token || undefined,
|
|
189
189
|
payments: payments.sorted.reverse(),
|
|
190
190
|
});
|
|
191
191
|
}],
|
|
@@ -5,6 +5,7 @@ export * from './delete_failed_payments';
|
|
|
5
5
|
export * from './delete_forwarding_reputations';
|
|
6
6
|
export * from './delete_payment';
|
|
7
7
|
export * from './delete_payments';
|
|
8
|
+
export * from './delete_pending_channel';
|
|
8
9
|
export * from './disable_channel';
|
|
9
10
|
export * from './disconnect_watchtower';
|
|
10
11
|
export * from './enable_channel';
|
|
@@ -14,6 +14,7 @@ const getUtxos = require('./get_utxos');
|
|
|
14
14
|
const lockUtxo = require('./lock_utxo');
|
|
15
15
|
const openChannel = require('./open_channel');
|
|
16
16
|
const openChannels = require('./open_channels');
|
|
17
|
+
const partiallySignPsbt = require('./partially_sign_psbt');
|
|
17
18
|
const prepareForChannelProposal = require('./prepare_for_channel_proposal');
|
|
18
19
|
const proposeChannel = require('./propose_channel');
|
|
19
20
|
const requestChainFeeIncrease = require('./request_chain_fee_increase');
|
|
@@ -46,6 +47,7 @@ module.exports = {
|
|
|
46
47
|
lockUtxo,
|
|
47
48
|
openChannel,
|
|
48
49
|
openChannels,
|
|
50
|
+
partiallySignPsbt,
|
|
49
51
|
prepareForChannelProposal,
|
|
50
52
|
proposeChannel,
|
|
51
53
|
requestChainFeeIncrease,
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
const asyncAuto = require('async/auto');
|
|
2
|
+
const {returnResult} = require('asyncjs-util');
|
|
3
|
+
|
|
4
|
+
const {isLnd} = require('./../../lnd_requests');
|
|
5
|
+
|
|
6
|
+
const bufferAsHex = buffer => buffer.toString('hex');
|
|
7
|
+
const hexAsBuf = hex => Buffer.from(hex, 'hex');
|
|
8
|
+
const {isBuffer} = Buffer;
|
|
9
|
+
const method = 'signPsbt';
|
|
10
|
+
const notSupported = /unknown.*walletrpc.WalletKit/;
|
|
11
|
+
const type = 'wallet';
|
|
12
|
+
|
|
13
|
+
/** Sign a PSBT to produce a partially signed PSBT
|
|
14
|
+
|
|
15
|
+
Requires `onchain:write` permission
|
|
16
|
+
|
|
17
|
+
Requires LND built with `walletrpc` tag
|
|
18
|
+
|
|
19
|
+
This method is not supported in LND 0.14.1 and below
|
|
20
|
+
|
|
21
|
+
{
|
|
22
|
+
lnd: <Authenticated LND API Object>
|
|
23
|
+
psbt: <Funded PSBT Hex String>
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@returns via cbk or Promise
|
|
27
|
+
{
|
|
28
|
+
psbt: <Partially Signed PSBT Hex String>
|
|
29
|
+
}
|
|
30
|
+
*/
|
|
31
|
+
module.exports = ({lnd, psbt}, cbk) => {
|
|
32
|
+
return new Promise((resolve, reject) => {
|
|
33
|
+
return asyncAuto({
|
|
34
|
+
// Check arguments
|
|
35
|
+
validate: cbk => {
|
|
36
|
+
if (!isLnd({lnd, method, type})) {
|
|
37
|
+
return cbk([400, 'ExpectedAuthenticatedLndToPartiallySignPsbt']);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (!psbt) {
|
|
41
|
+
return cbk([400, 'ExpectedPsbtToPartiallySign']);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return cbk();
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
// Partially sign the funded PSBT
|
|
48
|
+
sign: ['validate', ({}, cbk) => {
|
|
49
|
+
return lnd[type][method]({funded_psbt: hexAsBuf(psbt)}, (err, res) => {
|
|
50
|
+
if (!!err && notSupported.test(err.details)) {
|
|
51
|
+
return cbk([501, 'PartiallySignPsbtMethodNotSupported']);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (!!err) {
|
|
55
|
+
return cbk([503, 'UnexpectedErrorPartiallySigningPsbt', {err}]);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (!res) {
|
|
59
|
+
return cbk([503, 'ExpectedResponseWhenPartiallySigningPsbt']);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (!isBuffer(res.signed_psbt)) {
|
|
63
|
+
return cbk([503, 'ExpectedSignPsbtInSignPsbtResult']);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const signed = bufferAsHex(res.signed_psbt);
|
|
67
|
+
|
|
68
|
+
// Detect a failure to add a partial signature
|
|
69
|
+
if (signed === psbt) {
|
|
70
|
+
return cbk([503, 'FailedToModifyInputPsbt']);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return cbk(null, {psbt: signed});
|
|
74
|
+
});
|
|
75
|
+
}],
|
|
76
|
+
},
|
|
77
|
+
returnResult({reject, resolve, of: 'sign'}, cbk));
|
|
78
|
+
});
|
|
79
|
+
};
|
|
@@ -22,7 +22,7 @@ export type GetPeersResult = {
|
|
|
22
22
|
/** Is Syncing Graph Data */
|
|
23
23
|
is_sync_peer?: boolean;
|
|
24
24
|
/** Peer Last Reconnected At ISO 8601 Date */
|
|
25
|
-
|
|
25
|
+
last_reconnection?: string;
|
|
26
26
|
/** Ping Latency Milliseconds */
|
|
27
27
|
ping_time: number;
|
|
28
28
|
/** Node Identity Public Key */
|
|
@@ -31,7 +31,7 @@ const type = 'default';
|
|
|
31
31
|
}]
|
|
32
32
|
is_inbound: <Is Inbound Peer Bool>
|
|
33
33
|
[is_sync_peer]: <Is Syncing Graph Data Bool>
|
|
34
|
-
[
|
|
34
|
+
[last_reconnection]: <Peer Last Reconnected At ISO 8601 Date String>
|
|
35
35
|
ping_time: <Ping Latency Milliseconds Number>
|
|
36
36
|
public_key: <Node Identity Public Key String>
|
|
37
37
|
[reconnection_rate]: <Count of Reconnections Over Time Number>
|
|
@@ -49,7 +49,7 @@ const microPerMilli = 1e3;
|
|
|
49
49
|
}]
|
|
50
50
|
is_inbound: <Is Inbound Peer Bool>
|
|
51
51
|
[is_sync_peer]: <Is Syncing Graph Data Bool>
|
|
52
|
-
[
|
|
52
|
+
[last_reconnection]: <Peer Last Reconnected At ISO 8601 Date String>
|
|
53
53
|
ping_time: <Milliseconds Number>
|
|
54
54
|
public_key: <Public Key String>
|
|
55
55
|
[reconnection_rate]: <Count of Reconnections Over Time Number>
|
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.5.
|
|
10
|
+
"@grpc/grpc-js": "1.5.3",
|
|
11
11
|
"@grpc/proto-loader": "0.6.9",
|
|
12
12
|
"@types/express": "4.17.13",
|
|
13
|
-
"@types/node": "17.0.
|
|
13
|
+
"@types/node": "17.0.13",
|
|
14
14
|
"@types/request": "2.48.8",
|
|
15
15
|
"@types/ws": "8.2.2",
|
|
16
16
|
"async": "3.2.3",
|
|
@@ -23,15 +23,15 @@
|
|
|
23
23
|
"cbor": "8.1.0",
|
|
24
24
|
"express": "4.17.2",
|
|
25
25
|
"invoices": "2.0.3",
|
|
26
|
-
"psbt": "1.1.
|
|
27
|
-
"type-fest": "2.
|
|
26
|
+
"psbt": "1.1.11",
|
|
27
|
+
"type-fest": "2.11.0"
|
|
28
28
|
},
|
|
29
29
|
"description": "Lightning Network client library",
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@alexbosworth/node-fetch": "2.6.2",
|
|
32
32
|
"@alexbosworth/tap": "15.0.10",
|
|
33
33
|
"tsd": "0.19.1",
|
|
34
|
-
"typescript": "4.5.
|
|
34
|
+
"typescript": "4.5.5",
|
|
35
35
|
"ws": "8.4.2"
|
|
36
36
|
},
|
|
37
37
|
"engines": {
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"directory": "test/typescript"
|
|
58
58
|
},
|
|
59
59
|
"types": "index.d.ts",
|
|
60
|
-
"version": "5.
|
|
60
|
+
"version": "5.4.2"
|
|
61
61
|
}
|
|
@@ -67,6 +67,13 @@ const tests = [
|
|
|
67
67
|
description: 'A conflicting tx is required',
|
|
68
68
|
error: [400, 'FailedToFindConflictingInputInConfirmedTx'],
|
|
69
69
|
},
|
|
70
|
+
{
|
|
71
|
+
args: makeArgs({lnd: {default: {abandonChannel: ({}, cbk) => cbk({
|
|
72
|
+
details: 'AbandonChannel RPC call only available in dev builds',
|
|
73
|
+
})}}}),
|
|
74
|
+
description: 'Method unsupported error is returned',
|
|
75
|
+
error: [501, 'DeletePendingChannelMethodNotSupported'],
|
|
76
|
+
},
|
|
70
77
|
{
|
|
71
78
|
args: makeArgs({lnd: {default: {abandonChannel: ({}, cbk) => cbk('er')}}}),
|
|
72
79
|
description: 'A server error is passed back',
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
const {test} = require('@alexbosworth/tap');
|
|
2
|
+
|
|
3
|
+
const {partiallySignPsbt} = require('./../../../lnd_methods');
|
|
4
|
+
|
|
5
|
+
const unsupported = {details: 'unknown method for service walletrpc.WalletKit'};
|
|
6
|
+
|
|
7
|
+
const makeLnd = overrides => {
|
|
8
|
+
const res = {signed_psbt: Buffer.alloc(2)};
|
|
9
|
+
|
|
10
|
+
Object.keys(overrides).forEach(k => res[k] = overrides[k]);
|
|
11
|
+
|
|
12
|
+
return {wallet: {signPsbt: (args, cbk) => cbk(null, res)}};
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const makeArgs = overrides => {
|
|
16
|
+
const args = {lnd: makeLnd({}), psbt: '00'};
|
|
17
|
+
|
|
18
|
+
Object.keys(overrides).forEach(key => args[key] = overrides[key]);
|
|
19
|
+
|
|
20
|
+
return args;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const makeExpected = overrides => {
|
|
24
|
+
const expected = {psbt: '0000'};
|
|
25
|
+
|
|
26
|
+
Object.keys(overrides).forEach(k => expected[k] = overrides[k]);
|
|
27
|
+
|
|
28
|
+
return expected;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const tests = [
|
|
32
|
+
{
|
|
33
|
+
args: makeArgs({lnd: undefined}),
|
|
34
|
+
description: 'An LND object is required',
|
|
35
|
+
error: [400, 'ExpectedAuthenticatedLndToPartiallySignPsbt'],
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
args: makeArgs({psbt: undefined}),
|
|
39
|
+
description: 'A PSBT is required',
|
|
40
|
+
error: [400, 'ExpectedPsbtToPartiallySign'],
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
args: makeArgs({
|
|
44
|
+
lnd: {
|
|
45
|
+
wallet: {
|
|
46
|
+
signPsbt: ({}, cbk) => cbk({
|
|
47
|
+
details: 'unknown method for service walletrpc.WalletKit',
|
|
48
|
+
}),
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
}),
|
|
52
|
+
description: 'Unsupported error is passed back',
|
|
53
|
+
error: [501, 'SignPsbtMethodNotSupported'],
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
args: makeArgs({lnd: {wallet: {signPsbt: ({}, cbk) => cbk('err')}}}),
|
|
57
|
+
description: 'Errors signing are passed back',
|
|
58
|
+
error: [503, 'UnexpectedErrorPartiallySigningPsbt', {err: 'err'}],
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
args: makeArgs({lnd: {wallet: {signPsbt: ({}, cbk) => cbk()}}}),
|
|
62
|
+
description: 'A result is expected',
|
|
63
|
+
error: [503, 'ExpectedResponseWhenPartiallySigningPsbt'],
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
args: makeArgs({lnd: makeLnd({signed_psbt: undefined})}),
|
|
67
|
+
description: 'A partially signed psbt is expected',
|
|
68
|
+
error: [503, 'ExpectedSignPsbtInSignPsbtResult'],
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
args: makeArgs({
|
|
72
|
+
lnd: {
|
|
73
|
+
wallet: {
|
|
74
|
+
signPsbt: ({}, cbk) => cbk(null, {signed_psbt: Buffer.alloc(1)}),
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
}),
|
|
78
|
+
description: 'A signature is expected',
|
|
79
|
+
error: [503, 'FailedToModifyInputPsbt'],
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
args: makeArgs({}),
|
|
83
|
+
description: 'PSBT partial signing is executed',
|
|
84
|
+
expected: makeExpected({}),
|
|
85
|
+
},
|
|
86
|
+
];
|
|
87
|
+
|
|
88
|
+
tests.forEach(({args, description, error, expected}) => {
|
|
89
|
+
return test(description, async ({end, rejects, strictSame}) => {
|
|
90
|
+
if (!!error) {
|
|
91
|
+
await rejects(partiallySignPsbt(args), error, 'Got error');
|
|
92
|
+
} else {
|
|
93
|
+
const got = await partiallySignPsbt(args);
|
|
94
|
+
|
|
95
|
+
strictSame(got, expected, 'Got expected result');
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return end();
|
|
99
|
+
});
|
|
100
|
+
});
|
package/test/protos/protos.json
CHANGED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {expectError, expectType} from 'tsd';
|
|
2
|
+
import {AuthenticatedLnd} from '../../lnd_grpc';
|
|
3
|
+
import {deletePendingChannel} from '../../lnd_methods';
|
|
4
|
+
|
|
5
|
+
const lnd = {} as AuthenticatedLnd;
|
|
6
|
+
const confirmed_transaction = 'tx0';
|
|
7
|
+
const pending_transaction = 'tx1';
|
|
8
|
+
const pending_transaction_vout = 1;
|
|
9
|
+
|
|
10
|
+
expectError(deletePendingChannel());
|
|
11
|
+
expectError(deletePendingChannel({}));
|
|
12
|
+
expectError(deletePendingChannel({lnd}));
|
|
13
|
+
expectError(deletePendingChannel({confirmed_transaction}));
|
|
14
|
+
expectError(deletePendingChannel({pending_transaction}));
|
|
15
|
+
expectError(deletePendingChannel({pending_transaction_vout}));
|
|
16
|
+
expectError(deletePendingChannel({lnd, confirmed_transaction}));
|
|
17
|
+
expectError(deletePendingChannel({lnd, pending_transaction}));
|
|
18
|
+
expectError(deletePendingChannel({lnd, pending_transaction_vout}));
|
|
19
|
+
expectError(
|
|
20
|
+
deletePendingChannel({lnd, confirmed_transaction, pending_transaction})
|
|
21
|
+
);
|
|
22
|
+
expectError(
|
|
23
|
+
deletePendingChannel({lnd, confirmed_transaction, pending_transaction_vout})
|
|
24
|
+
);
|
|
25
|
+
expectError(
|
|
26
|
+
deletePendingChannel({lnd, pending_transaction, pending_transaction_vout})
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
expectType<void>(
|
|
30
|
+
await deletePendingChannel({
|
|
31
|
+
lnd,
|
|
32
|
+
confirmed_transaction,
|
|
33
|
+
pending_transaction,
|
|
34
|
+
pending_transaction_vout,
|
|
35
|
+
})
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
expectType<void>(
|
|
39
|
+
deletePendingChannel(
|
|
40
|
+
{lnd, confirmed_transaction, pending_transaction, pending_transaction_vout},
|
|
41
|
+
() => {}
|
|
42
|
+
)
|
|
43
|
+
);
|
|
@@ -5,14 +5,18 @@ import {getInvoices, GetInvoicesResult} from '../../lnd_methods';
|
|
|
5
5
|
const lnd = {} as AuthenticatedLnd;
|
|
6
6
|
const limit = 100;
|
|
7
7
|
const token = 'token';
|
|
8
|
+
const is_unconfirmed = true;
|
|
8
9
|
|
|
9
10
|
expectError(getInvoices());
|
|
10
11
|
expectError(getInvoices({}));
|
|
11
12
|
expectError(getInvoices({lnd, limit, token}));
|
|
13
|
+
expectError(getInvoices({lnd, limit, token, is_unconfirmed}));
|
|
12
14
|
|
|
13
15
|
expectType<GetInvoicesResult>(await getInvoices({lnd}));
|
|
14
16
|
expectType<GetInvoicesResult>(await getInvoices({lnd, limit}));
|
|
17
|
+
expectType<GetInvoicesResult>(await getInvoices({lnd, limit, is_unconfirmed}));
|
|
15
18
|
expectType<GetInvoicesResult>(await getInvoices({lnd, token}));
|
|
19
|
+
expectType<GetInvoicesResult>(await getInvoices({lnd, token, is_unconfirmed}));
|
|
16
20
|
|
|
17
21
|
expectType<void>(
|
|
18
22
|
getInvoices({lnd}, (error, result) => {
|
|
@@ -24,8 +28,18 @@ expectType<void>(
|
|
|
24
28
|
expectType<GetInvoicesResult>(result);
|
|
25
29
|
})
|
|
26
30
|
);
|
|
31
|
+
expectType<void>(
|
|
32
|
+
getInvoices({lnd, limit, is_unconfirmed}, (error, result) => {
|
|
33
|
+
expectType<GetInvoicesResult>(result);
|
|
34
|
+
})
|
|
35
|
+
);
|
|
27
36
|
expectType<void>(
|
|
28
37
|
getInvoices({lnd, token}, (error, result) => {
|
|
29
38
|
expectType<GetInvoicesResult>(result);
|
|
30
39
|
})
|
|
31
40
|
);
|
|
41
|
+
expectType<void>(
|
|
42
|
+
getInvoices({lnd, token, is_unconfirmed}, (error, result) => {
|
|
43
|
+
expectType<GetInvoicesResult>(result);
|
|
44
|
+
})
|
|
45
|
+
);
|