lightning 4.14.1 → 5.0.0
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 +13 -1
- package/index.js +4 -4
- package/lnd_methods/address/create_chain_address.d.ts +1 -1
- package/lnd_methods/address/create_chain_address.js +7 -4
- package/lnd_methods/info/constants.json +2 -1
- package/lnd_methods/macaroon/subscribe_to_rpc_requests.d.ts +8 -4
- package/lnd_methods/macaroon/verify_access.d.ts +1 -1
- package/lnd_methods/macaroon/verify_access.js +1 -1
- package/lnd_methods/offchain/disconnect_watchtower.d.ts +0 -2
- package/lnd_methods/offchain/disconnect_watchtower.js +0 -1
- package/lnd_methods/offchain/emit_payment.js +12 -0
- package/lnd_methods/offchain/get_channels.d.ts +0 -2
- package/lnd_methods/offchain/get_channels.js +0 -3
- package/lnd_methods/offchain/get_pending_channels.js +0 -1
- package/lnd_methods/offchain/send_message_to_peer.d.ts +1 -1
- package/lnd_methods/offchain/send_message_to_peer.js +1 -1
- package/lnd_methods/offchain/subscribe_to_channels.d.ts +0 -2
- package/lnd_methods/offchain/subscribe_to_channels.js +0 -3
- package/lnd_methods/offchain/subscribe_to_past_payment.d.ts +50 -1
- package/lnd_methods/offchain/subscribe_to_past_payment.js +5 -0
- package/lnd_methods/offchain/subscribe_to_pay.js +57 -2
- package/lnd_methods/offchain/subscribe_to_pay_via_details.js +55 -1
- package/lnd_methods/offchain/subscribe_to_pay_via_request.js +56 -1
- package/lnd_methods/onchain/send_to_chain_output_scripts.js +9 -2
- package/lnd_methods/unauthenticated/subscribe_to_wallet_status.js +0 -2
- package/lnd_responses/index.js +2 -0
- package/lnd_responses/pending_as_pending_channels.js +0 -2
- package/lnd_responses/routing_failure_from_htlc.js +105 -0
- package/lnd_responses/rpc_channel_as_channel.js +0 -6
- package/package.json +7 -7
- package/test/lnd_methods/address/test_create_chain_address.js +0 -5
- package/test/lnd_methods/offchain/test_get_channels.js +0 -7
- package/test/lnd_methods/offchain/test_get_payment.js +2 -0
- package/test/lnd_methods/offchain/test_subscribe_to_channels.js +0 -3
- package/test/lnd_responses/test_pending_as_pending_channels.js +0 -1
- package/test/lnd_responses/test_routing_failure_from_htlc.js +137 -0
- package/test/lnd_responses/test_rpc_channel_as_channel.js +0 -7
- package/test/typescript/disconnect_watchtower.test-d.ts +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
# Versions
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 5.0.0
|
|
4
|
+
|
|
5
|
+
- Removed support for determining the type of channel to support LND 0.14.0.
|
|
6
|
+
|
|
7
|
+
- `createChainAddress`: Make address format optional and add p2wpkh as default
|
|
8
|
+
- `sendToChainOutputScripts`: Fix specification of `fee_tokens_per_vbyte`
|
|
9
|
+
|
|
10
|
+
### Breaking Changes
|
|
11
|
+
|
|
12
|
+
- `getChannels`, `getPendingChannels`, `subscribeToChannels`: Remove
|
|
13
|
+
attributes `is_anchor`, `is_static_remote_key`, `is_variable_remote_key`.
|
|
14
|
+
|
|
15
|
+
## 4.14.4
|
|
4
16
|
|
|
5
17
|
- `getPayment`, `subscribeToPastPayment`: Add `pending` for pending payment details
|
|
6
18
|
|
package/index.js
CHANGED
|
@@ -75,10 +75,10 @@ const {lndGateway} = require('./lnd_gateway');
|
|
|
75
75
|
const {lockUtxo} = require('./lnd_methods');
|
|
76
76
|
const {openChannel} = require('./lnd_methods');
|
|
77
77
|
const {openChannels} = require('./lnd_methods');
|
|
78
|
+
const {pay} = require('./lnd_methods');
|
|
78
79
|
const {payViaPaymentDetails} = require('./lnd_methods');
|
|
79
80
|
const {payViaPaymentRequest} = require('./lnd_methods');
|
|
80
81
|
const {payViaRoutes} = require('./lnd_methods');
|
|
81
|
-
const {pay} = require('./lnd_methods');
|
|
82
82
|
const {prepareForChannelProposal} = require('./lnd_methods');
|
|
83
83
|
const {probeForRoute} = require('./lnd_methods');
|
|
84
84
|
const {proposeChannel} = require('./lnd_methods');
|
|
@@ -123,8 +123,8 @@ const {subscribeToWalletStatus} = require('./lnd_methods');
|
|
|
123
123
|
const {unauthenticatedLndGrpc} = require('./lnd_grpc');
|
|
124
124
|
const {unlockUtxo} = require('./lnd_methods');
|
|
125
125
|
const {unlockWallet} = require('./lnd_methods');
|
|
126
|
-
const {updateConnectedWatchtower} = require('./lnd_methods');
|
|
127
126
|
const {updateChainTransaction} = require('./lnd_methods');
|
|
127
|
+
const {updateConnectedWatchtower} = require('./lnd_methods');
|
|
128
128
|
const {updatePathfindingSettings} = require('./lnd_methods');
|
|
129
129
|
const {updateRoutingFees} = require('./lnd_methods');
|
|
130
130
|
const {verifyAccess} = require('./lnd_methods');
|
|
@@ -211,10 +211,10 @@ module.exports = {
|
|
|
211
211
|
lockUtxo,
|
|
212
212
|
openChannel,
|
|
213
213
|
openChannels,
|
|
214
|
+
pay,
|
|
214
215
|
payViaPaymentDetails,
|
|
215
216
|
payViaPaymentRequest,
|
|
216
217
|
payViaRoutes,
|
|
217
|
-
pay,
|
|
218
218
|
prepareForChannelProposal,
|
|
219
219
|
probeForRoute,
|
|
220
220
|
proposeChannel,
|
|
@@ -259,8 +259,8 @@ module.exports = {
|
|
|
259
259
|
unauthenticatedLndGrpc,
|
|
260
260
|
unlockUtxo,
|
|
261
261
|
unlockWallet,
|
|
262
|
-
updateConnectedWatchtower,
|
|
263
262
|
updateChainTransaction,
|
|
263
|
+
updateConnectedWatchtower,
|
|
264
264
|
updatePathfindingSettings,
|
|
265
265
|
updateRoutingFees,
|
|
266
266
|
verifyAccess,
|
|
@@ -5,6 +5,7 @@ const addressFormats = require('./address_formats');
|
|
|
5
5
|
const {isLnd} = require('./../../lnd_requests');
|
|
6
6
|
|
|
7
7
|
const connectFailMessage = '14 UNAVAILABLE: Connect Failed';
|
|
8
|
+
const defaultAddressFormat = 'p2wpkh';
|
|
8
9
|
const method = 'newAddress';
|
|
9
10
|
const type = 'default';
|
|
10
11
|
|
|
@@ -13,7 +14,7 @@ const type = 'default';
|
|
|
13
14
|
Requires `address:write` permission
|
|
14
15
|
|
|
15
16
|
{
|
|
16
|
-
format: <Receive Address Type String> // "np2wpkh" || "p2wpkh"
|
|
17
|
+
[format]: <Receive Address Type String> // "np2wpkh" || "p2wpkh"
|
|
17
18
|
[is_unused]: <Get As-Yet Unused Address Bool>
|
|
18
19
|
lnd: <Authenticated LND API Object>
|
|
19
20
|
}
|
|
@@ -28,7 +29,7 @@ module.exports = (args, cbk) => {
|
|
|
28
29
|
return asyncAuto({
|
|
29
30
|
// Check arguments
|
|
30
31
|
validate: cbk => {
|
|
31
|
-
if (
|
|
32
|
+
if (!!args.format && addressFormats[args.format] === undefined) {
|
|
32
33
|
return cbk([400, 'ExpectedKnownAddressFormat']);
|
|
33
34
|
}
|
|
34
35
|
|
|
@@ -41,11 +42,13 @@ module.exports = (args, cbk) => {
|
|
|
41
42
|
|
|
42
43
|
// Type
|
|
43
44
|
type: ['validate', ({}, cbk) => {
|
|
45
|
+
const format = args.format || defaultAddressFormat;
|
|
46
|
+
|
|
44
47
|
if (!args.is_unused) {
|
|
45
|
-
return cbk(null, addressFormats[
|
|
48
|
+
return cbk(null, addressFormats[format]);
|
|
46
49
|
}
|
|
47
50
|
|
|
48
|
-
return cbk(null, addressFormats[`unused_${
|
|
51
|
+
return cbk(null, addressFormats[`unused_${format}`]);
|
|
49
52
|
}],
|
|
50
53
|
|
|
51
54
|
// Get the address
|
|
@@ -31,7 +31,8 @@
|
|
|
31
31
|
"86114c575c2dff9dff1e1bb4df961c64aea9fc1c": "0.10.4-beta",
|
|
32
32
|
"d176d2d65fc06e6631c4dc9478592be8545a21de": "0.12.0-beta",
|
|
33
33
|
"d233f61383f2f950aa06f5b09da5b0e78e784fae": "0.12.1-beta",
|
|
34
|
-
"d62c575f8499a314eb27f12462d20500b6bda2c7": "0.10.3-beta"
|
|
34
|
+
"d62c575f8499a314eb27f12462d20500b6bda2c7": "0.10.3-beta",
|
|
35
|
+
"df0b82f0165f19bde8832bacd1e35544b0a2990d": "0.14.0-beta"
|
|
35
36
|
},
|
|
36
37
|
"weightedType": "weightedcomb",
|
|
37
38
|
"wrongLnd": "12 UNIMPLEMENTED: unknown service autopilotrpc.Autopilot"
|
|
@@ -21,8 +21,6 @@ export type SubscribeToRpcRequestsResult = {
|
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
export type SubscribeToRpcRequestsCommonEvent = {
|
|
24
|
-
/** Call Id Number */
|
|
25
|
-
call: number;
|
|
26
24
|
/** Message Id Number */
|
|
27
25
|
id: number;
|
|
28
26
|
/** Base64 Encoded Macaroon String */
|
|
@@ -122,11 +120,17 @@ export type SubscribeToRpcRequestsPayViaRouteRequestEvent =
|
|
|
122
120
|
};
|
|
123
121
|
}>;
|
|
124
122
|
|
|
123
|
+
export type SubscribeToRpcRequestsRequestOrResponseEvent =
|
|
124
|
+
SubscribeToRpcRequestsCommonEvent & {
|
|
125
|
+
/** Call Id Number */
|
|
126
|
+
call: number;
|
|
127
|
+
};
|
|
128
|
+
|
|
125
129
|
export type SubscribeToRpcRequestsRequestEvent =
|
|
126
|
-
|
|
130
|
+
SubscribeToRpcRequestsRequestOrResponseEvent;
|
|
127
131
|
|
|
128
132
|
export type SubscribeToRpcRequestsResponseEvent =
|
|
129
|
-
|
|
133
|
+
SubscribeToRpcRequestsRequestOrResponseEvent;
|
|
130
134
|
|
|
131
135
|
/**
|
|
132
136
|
* Subscribe to RPC requests and their responses
|
|
@@ -18,7 +18,7 @@ export type VerifyAccessResult = {
|
|
|
18
18
|
/**
|
|
19
19
|
* Verify an access token has a given set of permissions
|
|
20
20
|
*
|
|
21
|
-
* Note: this method is not supported in LND versions 0.13.
|
|
21
|
+
* Note: this method is not supported in LND versions 0.13.4 and below
|
|
22
22
|
*
|
|
23
23
|
* Requires `macaroon:read` permission
|
|
24
24
|
*/
|
|
@@ -14,7 +14,7 @@ const type = 'default';
|
|
|
14
14
|
|
|
15
15
|
/** Verify an access token has a given set of permissions
|
|
16
16
|
|
|
17
|
-
Note: this method is not supported in LND versions 0.13.
|
|
17
|
+
Note: this method is not supported in LND versions 0.13.4 and below
|
|
18
18
|
|
|
19
19
|
Requires `macaroon:read` permission
|
|
20
20
|
|
|
@@ -17,7 +17,6 @@ const unimplementedError = '12 UNIMPLEMENTED: unknown service wtclientrpc.Watcht
|
|
|
17
17
|
{
|
|
18
18
|
lnd: <Authenticated LND API Object>
|
|
19
19
|
public_key: <Watchtower Public Key Hex String>
|
|
20
|
-
[retry_delay]: <Retry Delay Milliseconds Number>
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
@returns via cbk or Promise
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
const {confirmedFromPayment} = require('./../../lnd_responses');
|
|
2
2
|
const {failureFromPayment} = require('./../../lnd_responses');
|
|
3
3
|
const {pendingFromPayment} = require('./../../lnd_responses');
|
|
4
|
+
const {routingFailureFromHtlc} = require('./../../lnd_responses');
|
|
4
5
|
const {states} = require('./payment_states');
|
|
5
6
|
|
|
7
|
+
const failedStatus = 'FAILED';
|
|
6
8
|
const {isArray} = Array;
|
|
7
9
|
|
|
8
10
|
/** Emit payment from payment event
|
|
@@ -31,6 +33,16 @@ module.exports = ({data, emitter}) => {
|
|
|
31
33
|
return;
|
|
32
34
|
}
|
|
33
35
|
|
|
36
|
+
// Emit routing failures
|
|
37
|
+
data.htlcs.filter(n => n.status === failedStatus).forEach(htlc => {
|
|
38
|
+
return emitter.emit('routing_failure', routingFailureFromHtlc(htlc));
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// Exit early when the HTLCs have no pending payments
|
|
42
|
+
if (!data.htlcs.find(n => n.status === states.paying)) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
34
46
|
return emitter.emit('paying', pendingFromPayment(data));
|
|
35
47
|
|
|
36
48
|
default:
|
|
@@ -40,8 +40,6 @@ export type GetChannelsResult = {
|
|
|
40
40
|
is_partner_initiated: boolean;
|
|
41
41
|
/** Channel Is Private */
|
|
42
42
|
is_private: boolean;
|
|
43
|
-
/** Remote Key Is Static */
|
|
44
|
-
is_static_remote_key: boolean;
|
|
45
43
|
/** Local Balance Tokens */
|
|
46
44
|
local_balance: number;
|
|
47
45
|
/** Local CSV Blocks Delay */
|
|
@@ -34,13 +34,10 @@ const type = 'default';
|
|
|
34
34
|
[cooperative_close_delay_height]: <Deny Coop Close Until Height Number>
|
|
35
35
|
id: <Standard Format Channel Id String>
|
|
36
36
|
is_active: <Channel Active Bool>
|
|
37
|
-
is_anchor: <Channel Supports Anchor Outputs Bool>
|
|
38
37
|
is_closing: <Channel Is Closing Bool>
|
|
39
38
|
is_opening: <Channel Is Opening Bool>
|
|
40
39
|
is_partner_initiated: <Channel Partner Opened Channel Bool>
|
|
41
40
|
is_private: <Channel Is Private Bool>
|
|
42
|
-
is_static_remote_key: <Remote Key Is Static Bool>
|
|
43
|
-
is_variable_remote_key: <Remote Key Is Variable Bool>
|
|
44
41
|
local_balance: <Local Balance Tokens Number>
|
|
45
42
|
[local_csv]: <Local CSV Blocks Delay Number>
|
|
46
43
|
[local_dust]: <Remote Non-Enforceable Amount Tokens Number>
|
|
@@ -27,7 +27,6 @@ const type = 'default';
|
|
|
27
27
|
pending_channels: [{
|
|
28
28
|
[close_transaction_id]: <Channel Closing Transaction Id String>
|
|
29
29
|
is_active: <Channel Is Active Bool>
|
|
30
|
-
is_anchor: <Channel Is Anchor Channel Type Bool>
|
|
31
30
|
is_closing: <Channel Is Closing Bool>
|
|
32
31
|
is_opening: <Channel Is Opening Bool>
|
|
33
32
|
is_partner_initiated: <Channel Partner Initiated Channel Bool>
|
|
@@ -21,7 +21,7 @@ export type SendMessageToPeerArgs =
|
|
|
21
21
|
* If specified, message type is expected to be between 32768 and 65535
|
|
22
22
|
* Message data should not be larger than 65533 bytes
|
|
23
23
|
*
|
|
24
|
-
* Note: this method is not supported in LND versions 0.13.
|
|
24
|
+
* Note: this method is not supported in LND versions 0.13.4 and below
|
|
25
25
|
*
|
|
26
26
|
* Requires `offchain:write` permission
|
|
27
27
|
*/
|
|
@@ -17,7 +17,7 @@ const type = 'default';
|
|
|
17
17
|
|
|
18
18
|
Message data should not be larger than 65533 bytes
|
|
19
19
|
|
|
20
|
-
Note: this method is not supported in LND versions 0.13.
|
|
20
|
+
Note: this method is not supported in LND versions 0.13.4 and below
|
|
21
21
|
|
|
22
22
|
Requires `offchain:write` permission
|
|
23
23
|
|
|
@@ -89,8 +89,6 @@ export type SubscribeToChannelsChannelOpenedEvent = {
|
|
|
89
89
|
is_partner_initiated: boolean;
|
|
90
90
|
/** Channel Is Private */
|
|
91
91
|
is_private: boolean;
|
|
92
|
-
/** Remote Key Is Static */
|
|
93
|
-
is_static_remote_key: boolean;
|
|
94
92
|
/** Local Balance Tokens */
|
|
95
93
|
local_balance: number;
|
|
96
94
|
/** Local Initially Pushed Tokens */
|
|
@@ -83,13 +83,10 @@ const updateOpening = 'pending_open_channel';
|
|
|
83
83
|
[cooperative_close_delay_height]: <Prevent Coop Close Until Height Number>
|
|
84
84
|
id: <Standard Format Channel Id String>
|
|
85
85
|
is_active: <Channel Active Bool>
|
|
86
|
-
is_anchor: <Channel Supports Anchor Outputs Bool>
|
|
87
86
|
is_closing: <Channel Is Closing Bool>
|
|
88
87
|
is_opening: <Channel Is Opening Bool>
|
|
89
88
|
is_partner_initiated: <Channel Partner Opened Channel Bool>
|
|
90
89
|
is_private: <Channel Is Private Bool>
|
|
91
|
-
is_static_remote_key: <Remote Key Is Static Bool>
|
|
92
|
-
is_variable_remote_key: <Remote Key Is Variable Bool>
|
|
93
90
|
local_balance: <Local Balance Tokens Number>
|
|
94
91
|
local_given: <Local Initially Pushed Tokens Number>
|
|
95
92
|
local_reserve: <Local Reserved Tokens Number>
|
|
@@ -66,7 +66,56 @@ export type SubscribeToPastPaymentFailedEvent = {
|
|
|
66
66
|
is_route_not_found: boolean;
|
|
67
67
|
};
|
|
68
68
|
|
|
69
|
-
export type SubscribeToPastPaymentPayingEvent = {
|
|
69
|
+
export type SubscribeToPastPaymentPayingEvent = {
|
|
70
|
+
/** Payment Created At ISO 8601 Date String */
|
|
71
|
+
created_at: string;
|
|
72
|
+
/** Payment Destination Hex String */
|
|
73
|
+
destination: string;
|
|
74
|
+
/** Payment Hash Hex String */
|
|
75
|
+
id: string;
|
|
76
|
+
/** Total Millitokens Pending String */
|
|
77
|
+
mtokens: string;
|
|
78
|
+
paths: {
|
|
79
|
+
/** Total Fee Tokens Pending Number */
|
|
80
|
+
fee: number;
|
|
81
|
+
/** Total Fee Millitokens Pending String */
|
|
82
|
+
fee_mtokens: string;
|
|
83
|
+
hops: {
|
|
84
|
+
/** Standard Format Channel Id String */
|
|
85
|
+
channel: string;
|
|
86
|
+
/** Channel Capacity Tokens Number */
|
|
87
|
+
channel_capacity: number;
|
|
88
|
+
/** Fee Tokens Rounded Down Number */
|
|
89
|
+
fee: number;
|
|
90
|
+
/** Fee Millitokens String */
|
|
91
|
+
fee_mtokens: string;
|
|
92
|
+
/** Forward Tokens Number */
|
|
93
|
+
forward: number;
|
|
94
|
+
/** Forward Millitokens String */
|
|
95
|
+
forward_mtokens: string;
|
|
96
|
+
/** Public Key Hex String */
|
|
97
|
+
public_key: string;
|
|
98
|
+
/** Timeout Block Height Number */
|
|
99
|
+
timeout: number;
|
|
100
|
+
}[];
|
|
101
|
+
/** Total Millitokens Pending String */
|
|
102
|
+
mtokens: string;
|
|
103
|
+
/** Total Fee Tokens Pending Rounded Up Number */
|
|
104
|
+
safe_fee: number;
|
|
105
|
+
/** Total Tokens Pending, Rounded Up Number */
|
|
106
|
+
safe_tokens: number;
|
|
107
|
+
/** Expiration Block Height Number */
|
|
108
|
+
timeout: number;
|
|
109
|
+
}[];
|
|
110
|
+
/** BOLT 11 Encoded Payment Request String */
|
|
111
|
+
request?: string;
|
|
112
|
+
/** Total Tokens Pending, Rounded Up Number */
|
|
113
|
+
safe_tokens: number;
|
|
114
|
+
/** Expiration Block Height Number */
|
|
115
|
+
timeout?: number;
|
|
116
|
+
/** Total Tokens Pending Rounded Down Number */
|
|
117
|
+
tokens: number;
|
|
118
|
+
};
|
|
70
119
|
|
|
71
120
|
/**
|
|
72
121
|
* Subscribe to the status of a past payment
|
|
@@ -8,10 +8,12 @@ const {confirmedFromPayment} = require('./../../lnd_responses');
|
|
|
8
8
|
const {confirmedFromPaymentStatus} = require('./../../lnd_responses');
|
|
9
9
|
const emitPayment = require('./emit_payment');
|
|
10
10
|
const {failureFromPayment} = require('./../../lnd_responses');
|
|
11
|
+
const {handleRemoveListener} = require('./../../grpc');
|
|
11
12
|
const {isLnd} = require('./../../lnd_requests');
|
|
12
13
|
const {safeTokens} = require('./../../bolt00');
|
|
13
14
|
const {states} = require('./payment_states');
|
|
14
15
|
|
|
16
|
+
const events = ['confirmed', 'failed', 'paying'];
|
|
15
17
|
const hexToBuffer = hex => Buffer.from(hex, 'hex');
|
|
16
18
|
const {isArray} = Array;
|
|
17
19
|
const isHash = n => /^[0-9A-F]{64}$/i.test(n);
|
|
@@ -141,6 +143,9 @@ module.exports = args => {
|
|
|
141
143
|
|
|
142
144
|
const sub = args.lnd[type][method]({payment_hash: hash});
|
|
143
145
|
|
|
146
|
+
// Terminate subscription when all listeners are removed
|
|
147
|
+
handleRemoveListener({emitter, events, subscription: sub});
|
|
148
|
+
|
|
144
149
|
sub.on('data', data => emitPayment({data, emitter}));
|
|
145
150
|
sub.on('end', () => emitter.emit('end'));
|
|
146
151
|
sub.on('error', err => emitError(err));
|
|
@@ -146,7 +146,62 @@ const unknownServiceErr = 'unknown service verrpc.Versioner';
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
@event 'paying'
|
|
149
|
-
{
|
|
149
|
+
{
|
|
150
|
+
created_at: <Payment Created At ISO 8601 Date String>
|
|
151
|
+
destination: <Payment Destination Hex String>
|
|
152
|
+
id: <Payment Hash Hex String>
|
|
153
|
+
mtokens: <Total Millitokens Pending String>
|
|
154
|
+
paths: [{
|
|
155
|
+
fee: <Total Fee Tokens Pending Number>
|
|
156
|
+
fee_mtokens: <Total Fee Millitokens Pending String>
|
|
157
|
+
hops: [{
|
|
158
|
+
channel: <Standard Format Channel Id String>
|
|
159
|
+
channel_capacity: <Channel Capacity Tokens Number>
|
|
160
|
+
fee: <Fee Tokens Rounded Down Number>
|
|
161
|
+
fee_mtokens: <Fee Millitokens String>
|
|
162
|
+
forward: <Forward Tokens Number>
|
|
163
|
+
forward_mtokens: <Forward Millitokens String>
|
|
164
|
+
public_key: <Public Key Hex String>
|
|
165
|
+
timeout: <Timeout Block Height Number>
|
|
166
|
+
}]
|
|
167
|
+
mtokens: <Total Millitokens Pending String>
|
|
168
|
+
safe_fee: <Total Fee Tokens Pending Rounded Up Number>
|
|
169
|
+
safe_tokens: <Total Tokens Pending, Rounded Up Number>
|
|
170
|
+
timeout: <Expiration Block Height Number>
|
|
171
|
+
}]
|
|
172
|
+
[request]: <BOLT 11 Encoded Payment Request String>
|
|
173
|
+
safe_tokens: <Total Tokens Pending, Rounded Up Number>
|
|
174
|
+
[timeout]: <Expiration Block Height Number>
|
|
175
|
+
tokens: <Total Tokens Pending Rounded Down Number>
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
@event 'routing_failure'
|
|
179
|
+
{
|
|
180
|
+
[channel]: <Standard Format Channel Id String>
|
|
181
|
+
index: <Failure Index Number>
|
|
182
|
+
[mtokens]: <Millitokens String>
|
|
183
|
+
[public_key]: <Public Key Hex String>
|
|
184
|
+
reason: <Failure Reason String>
|
|
185
|
+
route: {
|
|
186
|
+
fee: <Total Route Fee Tokens To Pay Number>
|
|
187
|
+
fee_mtokens: <Total Route Fee Millitokens To Pay String>
|
|
188
|
+
hops: [{
|
|
189
|
+
channel: <Standard Format Channel Id String>
|
|
190
|
+
channel_capacity: <Channel Capacity Tokens Number>
|
|
191
|
+
fee: <Fee Number>
|
|
192
|
+
fee_mtokens: <Fee Millitokens String>
|
|
193
|
+
forward: <Forward Tokens Number>
|
|
194
|
+
forward_mtokens: <Forward Millitokens String>
|
|
195
|
+
public_key: <Public Key Hex String>
|
|
196
|
+
timeout: <Timeout Block Height Number>
|
|
197
|
+
}]
|
|
198
|
+
mtokens: <Total Route Millitokens String>
|
|
199
|
+
[payment]: <Payment Identifier Hex String>
|
|
200
|
+
timeout: <Expiration Block Height Number>
|
|
201
|
+
tokens: <Total Route Tokens Number>
|
|
202
|
+
[total_mtokens]: <Total Millitokens String>
|
|
203
|
+
}
|
|
204
|
+
}
|
|
150
205
|
*/
|
|
151
206
|
module.exports = args => {
|
|
152
207
|
if (!!args.cltv_delta && !!args.request) {
|
|
@@ -316,7 +371,7 @@ module.exports = args => {
|
|
|
316
371
|
last_hop_pubkey: hexToBuf(args.incoming_peer),
|
|
317
372
|
max_parts: args.max_paths || defaultMaxPaths,
|
|
318
373
|
max_shard_size_msat: args.max_path_mtokens || undefined,
|
|
319
|
-
no_inflight_updates:
|
|
374
|
+
no_inflight_updates: false,
|
|
320
375
|
outgoing_chan_id: !hasOutIds ? singleOut : undefined,
|
|
321
376
|
outgoing_chan_ids: outgoingChannelIds,
|
|
322
377
|
payment_addr: !!args.payment ? hexToBuf(args.payment) : undefined,
|
|
@@ -120,7 +120,61 @@ const type = 'router';
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
@event 'paying'
|
|
123
|
-
{
|
|
123
|
+
{
|
|
124
|
+
created_at: <Payment Created At ISO 8601 Date String>
|
|
125
|
+
destination: <Payment Destination Hex String>
|
|
126
|
+
id: <Payment Hash Hex String>
|
|
127
|
+
mtokens: <Total Millitokens Pending String>
|
|
128
|
+
paths: [{
|
|
129
|
+
fee: <Total Fee Tokens Pending Number>
|
|
130
|
+
fee_mtokens: <Total Fee Millitokens Pending String>
|
|
131
|
+
hops: [{
|
|
132
|
+
channel: <Standard Format Channel Id String>
|
|
133
|
+
channel_capacity: <Channel Capacity Tokens Number>
|
|
134
|
+
fee: <Fee Tokens Rounded Down Number>
|
|
135
|
+
fee_mtokens: <Fee Millitokens String>
|
|
136
|
+
forward: <Forward Tokens Number>
|
|
137
|
+
forward_mtokens: <Forward Millitokens String>
|
|
138
|
+
public_key: <Public Key Hex String>
|
|
139
|
+
timeout: <Timeout Block Height Number>
|
|
140
|
+
}]
|
|
141
|
+
mtokens: <Total Millitokens Pending String>
|
|
142
|
+
safe_fee: <Total Fee Tokens Pending Rounded Up Number>
|
|
143
|
+
safe_tokens: <Total Tokens Pending, Rounded Up Number>
|
|
144
|
+
timeout: <Expiration Block Height Number>
|
|
145
|
+
}]
|
|
146
|
+
safe_tokens: <Total Tokens Pending, Rounded Up Number>
|
|
147
|
+
[timeout]: <Expiration Block Height Number>
|
|
148
|
+
tokens: <Total Tokens Pending Rounded Down Number>
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
@event 'routing_failure'
|
|
152
|
+
{
|
|
153
|
+
[channel]: <Standard Format Channel Id String>
|
|
154
|
+
index: <Failure Index Number>
|
|
155
|
+
[mtokens]: <Millitokens String>
|
|
156
|
+
[public_key]: <Public Key Hex String>
|
|
157
|
+
reason: <Failure Reason String>
|
|
158
|
+
route: {
|
|
159
|
+
fee: <Total Route Fee Tokens To Pay Number>
|
|
160
|
+
fee_mtokens: <Total Route Fee Millitokens To Pay String>
|
|
161
|
+
hops: [{
|
|
162
|
+
channel: <Standard Format Channel Id String>
|
|
163
|
+
channel_capacity: <Channel Capacity Tokens Number>
|
|
164
|
+
fee: <Fee Number>
|
|
165
|
+
fee_mtokens: <Fee Millitokens String>
|
|
166
|
+
forward: <Forward Tokens Number>
|
|
167
|
+
forward_mtokens: <Forward Millitokens String>
|
|
168
|
+
public_key: <Public Key Hex String>
|
|
169
|
+
timeout: <Timeout Block Height Number>
|
|
170
|
+
}]
|
|
171
|
+
mtokens: <Total Route Millitokens String>
|
|
172
|
+
[payment]: <Payment Identifier Hex String>
|
|
173
|
+
timeout: <Expiration Block Height Number>
|
|
174
|
+
tokens: <Total Route Tokens Number>
|
|
175
|
+
[total_mtokens]: <Total Millitokens String>
|
|
176
|
+
}
|
|
177
|
+
}
|
|
124
178
|
*/
|
|
125
179
|
module.exports = args => {
|
|
126
180
|
if (!isPublicKey(args.destination)) {
|
|
@@ -100,7 +100,62 @@ const type = 'router';
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
@event 'paying'
|
|
103
|
-
{
|
|
103
|
+
{
|
|
104
|
+
created_at: <Payment Created At ISO 8601 Date String>
|
|
105
|
+
destination: <Payment Destination Hex String>
|
|
106
|
+
id: <Payment Hash Hex String>
|
|
107
|
+
mtokens: <Total Millitokens Pending String>
|
|
108
|
+
paths: [{
|
|
109
|
+
fee: <Total Fee Tokens Pending Number>
|
|
110
|
+
fee_mtokens: <Total Fee Millitokens Pending String>
|
|
111
|
+
hops: [{
|
|
112
|
+
channel: <Standard Format Channel Id String>
|
|
113
|
+
channel_capacity: <Channel Capacity Tokens Number>
|
|
114
|
+
fee: <Fee Tokens Rounded Down Number>
|
|
115
|
+
fee_mtokens: <Fee Millitokens String>
|
|
116
|
+
forward: <Forward Tokens Number>
|
|
117
|
+
forward_mtokens: <Forward Millitokens String>
|
|
118
|
+
public_key: <Public Key Hex String>
|
|
119
|
+
timeout: <Timeout Block Height Number>
|
|
120
|
+
}]
|
|
121
|
+
mtokens: <Total Millitokens Pending String>
|
|
122
|
+
safe_fee: <Total Fee Tokens Pending Rounded Up Number>
|
|
123
|
+
safe_tokens: <Total Tokens Pending, Rounded Up Number>
|
|
124
|
+
timeout: <Expiration Block Height Number>
|
|
125
|
+
}]
|
|
126
|
+
[request]: <BOLT 11 Encoded Payment Request String>
|
|
127
|
+
safe_tokens: <Total Tokens Pending, Rounded Up Number>
|
|
128
|
+
[timeout]: <Expiration Block Height Number>
|
|
129
|
+
tokens: <Total Tokens Pending Rounded Down Number>
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
@event 'routing_failure'
|
|
133
|
+
{
|
|
134
|
+
[channel]: <Standard Format Channel Id String>
|
|
135
|
+
index: <Failure Index Number>
|
|
136
|
+
[mtokens]: <Millitokens String>
|
|
137
|
+
[public_key]: <Public Key Hex String>
|
|
138
|
+
reason: <Failure Reason String>
|
|
139
|
+
route: {
|
|
140
|
+
fee: <Total Route Fee Tokens To Pay Number>
|
|
141
|
+
fee_mtokens: <Total Route Fee Millitokens To Pay String>
|
|
142
|
+
hops: [{
|
|
143
|
+
channel: <Standard Format Channel Id String>
|
|
144
|
+
channel_capacity: <Channel Capacity Tokens Number>
|
|
145
|
+
fee: <Fee Number>
|
|
146
|
+
fee_mtokens: <Fee Millitokens String>
|
|
147
|
+
forward: <Forward Tokens Number>
|
|
148
|
+
forward_mtokens: <Forward Millitokens String>
|
|
149
|
+
public_key: <Public Key Hex String>
|
|
150
|
+
timeout: <Timeout Block Height Number>
|
|
151
|
+
}]
|
|
152
|
+
mtokens: <Total Route Millitokens String>
|
|
153
|
+
[payment]: <Payment Identifier Hex String>
|
|
154
|
+
timeout: <Expiration Block Height Number>
|
|
155
|
+
tokens: <Total Route Tokens Number>
|
|
156
|
+
[total_mtokens]: <Total Millitokens String>
|
|
157
|
+
}
|
|
158
|
+
}
|
|
104
159
|
*/
|
|
105
160
|
module.exports = args => {
|
|
106
161
|
if (!args.request) {
|
|
@@ -11,8 +11,11 @@ const initialConfirmationCount = 0;
|
|
|
11
11
|
const {isArray} = Array;
|
|
12
12
|
const {isBuffer} = Buffer;
|
|
13
13
|
const method = 'sendOutputs';
|
|
14
|
+
const minFeeRate = 1;
|
|
14
15
|
const unconfirmedConfCount = 0;
|
|
15
16
|
const type = 'wallet';
|
|
17
|
+
const weightPerKWeight = 1e3;
|
|
18
|
+
const weightPerVByte = 4;
|
|
16
19
|
|
|
17
20
|
/** Send on-chain funds to multiple output scripts
|
|
18
21
|
|
|
@@ -58,6 +61,10 @@ module.exports = (args, cbk) => {
|
|
|
58
61
|
},
|
|
59
62
|
|
|
60
63
|
send: ['validate', ({}, cbk) => {
|
|
64
|
+
const feePerVByte = args.fee_tokens_per_vbyte || minFeeRate;
|
|
65
|
+
|
|
66
|
+
const feePerKw = feePerVByte * weightPerKWeight / weightPerVByte;
|
|
67
|
+
|
|
61
68
|
return args.lnd[type][method]({
|
|
62
69
|
label: args.description || undefined,
|
|
63
70
|
min_confs: args.utxo_confirmations || undefined,
|
|
@@ -65,7 +72,7 @@ module.exports = (args, cbk) => {
|
|
|
65
72
|
pk_script: hexAsBuffer(output.script),
|
|
66
73
|
value: output.tokens.toString(),
|
|
67
74
|
})),
|
|
68
|
-
|
|
75
|
+
sat_per_kw: feePerKw,
|
|
69
76
|
spend_unconfirmed: args.utxo_confirmations === unconfirmedConfCount,
|
|
70
77
|
},
|
|
71
78
|
(err, res) => {
|
|
@@ -78,7 +85,7 @@ module.exports = (args, cbk) => {
|
|
|
78
85
|
}
|
|
79
86
|
|
|
80
87
|
try {
|
|
81
|
-
fromBuffer(res.raw_tx).getId()
|
|
88
|
+
fromBuffer(res.raw_tx).getId();
|
|
82
89
|
} catch (err) {
|
|
83
90
|
return cbk([500, 'ExpectedRawTransactionInSendToOutputsResponse']);
|
|
84
91
|
}
|
package/lnd_responses/index.js
CHANGED
|
@@ -14,6 +14,7 @@ const pendingAsPendingChannels = require('./pending_as_pending_channels');
|
|
|
14
14
|
const pendingFromPayment = require('./pending_from_payment');
|
|
15
15
|
const policyFromChannelUpdate = require('./policy_from_channel_update');
|
|
16
16
|
const routesFromQueryRoutes = require('./routes_from_query_routes');
|
|
17
|
+
const routingFailureFromHtlc = require('./routing_failure_from_htlc');
|
|
17
18
|
const rpcAttemptHtlcAsAttempt = require('./rpc_attempt_htlc_as_attempt');
|
|
18
19
|
const rpcChannelAsChannel = require('./rpc_channel_as_channel');
|
|
19
20
|
const rpcChannelAsOldRpcChannel = require('./rpc_channel_as_old_rpc_channel');
|
|
@@ -57,6 +58,7 @@ module.exports = {
|
|
|
57
58
|
pendingFromPayment,
|
|
58
59
|
policyFromChannelUpdate,
|
|
59
60
|
routesFromQueryRoutes,
|
|
61
|
+
routingFailureFromHtlc,
|
|
60
62
|
rpcAttemptHtlcAsAttempt,
|
|
61
63
|
rpcChannelAsChannel,
|
|
62
64
|
rpcChannelAsOldRpcChannel,
|
|
@@ -82,7 +82,6 @@ const outpointSeparator = ':';
|
|
|
82
82
|
pending_channels: [{
|
|
83
83
|
[close_transaction_id]: <Channel Closing Transaction Id String>
|
|
84
84
|
is_active: <Channel Is Active Bool>
|
|
85
|
-
is_anchor: <Channel Is Anchor Channel Type Bool>
|
|
86
85
|
is_closing: <Channel Is Closing Bool>
|
|
87
86
|
is_opening: <Channel Is Opening Bool>
|
|
88
87
|
is_partner_initiated: <Channel Partner Initiated Channel Bool>
|
|
@@ -288,7 +287,6 @@ module.exports = args => {
|
|
|
288
287
|
return {
|
|
289
288
|
close_transaction_id: endTx || undefined,
|
|
290
289
|
is_active: false,
|
|
291
|
-
is_anchor: channel.commitment_type === anchorChannelType,
|
|
292
290
|
is_closing: !chanOpen,
|
|
293
291
|
is_opening: !!chanOpen,
|
|
294
292
|
is_partner_initiated: channel.initiator === remoteInitiator,
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
const paymentFailure = require('./payment_failure');
|
|
2
|
+
const rpcRouteAsRoute = require('./rpc_route_as_route');
|
|
3
|
+
|
|
4
|
+
/** Derive routing failure details from an HTLC
|
|
5
|
+
|
|
6
|
+
{
|
|
7
|
+
attempt_time_ns: <HTLC Sent At Epoch Time Nanoseconds String>
|
|
8
|
+
failure: {
|
|
9
|
+
[channel_update]: {
|
|
10
|
+
base_fee: <Base Fee Millitokens Number>
|
|
11
|
+
chain_hash: <Chain Hash Buffer Object>
|
|
12
|
+
[chan_id]: <Numeric Channel Id String>
|
|
13
|
+
channel_flags: <Channel Flags Number>
|
|
14
|
+
extra_opaque_data: <Extra Opaque Data Buffer Object>
|
|
15
|
+
fee_rate: <Fee Rate Number>
|
|
16
|
+
htlc_maximum_msat: <Maximum HTLC Millitokens Number>
|
|
17
|
+
htlc_minimum_msat: <Minimum HTLC Millitokens Number>
|
|
18
|
+
message_flags: <Message Flags Number>
|
|
19
|
+
signature: <Signature Buffer Object>
|
|
20
|
+
time_lock_delta: <CLTV Delta Number>
|
|
21
|
+
timestamp: <Update Epoch Time Seconds Number>
|
|
22
|
+
}
|
|
23
|
+
code: <Failure Code String>
|
|
24
|
+
[failure_source_index]: <Failed Hop Index Number>
|
|
25
|
+
height: <Height Number>
|
|
26
|
+
htlc_msat: <HTLC Millitokens String>
|
|
27
|
+
}
|
|
28
|
+
resolve_time_ns: <HTLC Resolved At Epoch Time Nanoseconds String>
|
|
29
|
+
route: {
|
|
30
|
+
hops: [{
|
|
31
|
+
amt_to_forward: <Tokens to Forward String>
|
|
32
|
+
amt_to_forward_msat: <Millitokens to Forward String>
|
|
33
|
+
chan_id: <Numeric Format Channel Id String>
|
|
34
|
+
chan_capacity: <Channel Capacity Number>
|
|
35
|
+
expiry: <Timeout Chain Height Number>
|
|
36
|
+
fee: <Fee in Tokens Number>
|
|
37
|
+
fee_msat: <Fee in Millitokens Number>
|
|
38
|
+
[mpp_record]: {
|
|
39
|
+
payment_addr: <Payment Identifier Buffer>
|
|
40
|
+
total_amt_msat: <Total Payment Millitokens Amount String>
|
|
41
|
+
}
|
|
42
|
+
pub_key: <Next Hop Public Key Hex String>
|
|
43
|
+
tlv_payload: <Has Extra TLV Data Bool>
|
|
44
|
+
}]
|
|
45
|
+
total_amt: <Total Tokens String>
|
|
46
|
+
total_amt_msat: <Route Total Millitokens String>
|
|
47
|
+
total_fees: <Route Fee Tokens String>
|
|
48
|
+
total_fees_msat: <Route Total Fees Millitokens String>
|
|
49
|
+
total_time_lock: <Route Total Timelock Number>
|
|
50
|
+
}
|
|
51
|
+
status: <HTLC Status String>
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@throws
|
|
55
|
+
<Error>
|
|
56
|
+
|
|
57
|
+
@returns
|
|
58
|
+
{
|
|
59
|
+
[channel]: <Standard Format Channel Id String>
|
|
60
|
+
index: <Failure Index Number>
|
|
61
|
+
[mtokens]: <Millitokens String>
|
|
62
|
+
[public_key]: <Public Key Hex String>
|
|
63
|
+
reason: <Failure Reason String>
|
|
64
|
+
route: {
|
|
65
|
+
fee: <Total Route Fee Tokens To Pay Number>
|
|
66
|
+
fee_mtokens: <Total Route Fee Millitokens To Pay String>
|
|
67
|
+
hops: [{
|
|
68
|
+
channel: <Standard Format Channel Id String>
|
|
69
|
+
channel_capacity: <Channel Capacity Tokens Number>
|
|
70
|
+
fee: <Fee Number>
|
|
71
|
+
fee_mtokens: <Fee Millitokens String>
|
|
72
|
+
forward: <Forward Tokens Number>
|
|
73
|
+
forward_mtokens: <Forward Millitokens String>
|
|
74
|
+
public_key: <Public Key Hex String>
|
|
75
|
+
timeout: <Timeout Block Height Number>
|
|
76
|
+
}]
|
|
77
|
+
mtokens: <Total Route Millitokens String>
|
|
78
|
+
[payment]: <Payment Identifier Hex String>
|
|
79
|
+
timeout: <Expiration Block Height Number>
|
|
80
|
+
tokens: <Total Route Tokens Number>
|
|
81
|
+
[total_mtokens]: <Total Millitokens String>
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
*/
|
|
85
|
+
module.exports = htlc => {
|
|
86
|
+
const from = htlc.route.hops[htlc.failure.failure_source_index - 1] || {};
|
|
87
|
+
|
|
88
|
+
const failure = paymentFailure({
|
|
89
|
+
channel: htlc.channel,
|
|
90
|
+
failure: htlc.failure,
|
|
91
|
+
index: htlc.index,
|
|
92
|
+
key: from.pub_key,
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
const route = rpcRouteAsRoute(htlc.route);
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
route,
|
|
99
|
+
channel: failure.details.channel,
|
|
100
|
+
index: failure.details.index,
|
|
101
|
+
mtokens: route.mtokens,
|
|
102
|
+
public_key: from.pub_key,
|
|
103
|
+
reason: failure.message,
|
|
104
|
+
};
|
|
105
|
+
};
|
|
@@ -74,13 +74,10 @@ const outpointDelimiter = ':';
|
|
|
74
74
|
[cooperative_close_delay_height]: <Prevent Coop Close Until Height Number>
|
|
75
75
|
id: <Standard Format Channel Id String>
|
|
76
76
|
is_active: <Channel Active Bool>
|
|
77
|
-
is_anchor: <Channel Supports Anchor Outputs Bool>
|
|
78
77
|
is_closing: <Channel Is Closing Bool>
|
|
79
78
|
is_opening: <Channel Is Opening Bool>
|
|
80
79
|
is_partner_initiated: <Channel Partner Opened Channel Bool>
|
|
81
80
|
is_private: <Channel Is Private Bool>
|
|
82
|
-
is_static_remote_key: <Remote Key Is Static Bool>
|
|
83
|
-
is_variable_remote_key: <Remote Key Is Variable Bool>
|
|
84
81
|
local_balance: <Local Balance Tokens Number>
|
|
85
82
|
local_csv: <Local CSV Blocks Delay Number>
|
|
86
83
|
local_dust: <Remote Non-Enforceable Amount Tokens Number>
|
|
@@ -224,13 +221,10 @@ module.exports = args => {
|
|
|
224
221
|
cooperative_close_delay_height: height,
|
|
225
222
|
id: chanFormat({number: args.chan_id}).channel,
|
|
226
223
|
is_active: args.active,
|
|
227
|
-
is_anchor: chanType === commitmentTypes.anchor,
|
|
228
224
|
is_closing: false,
|
|
229
225
|
is_opening: false,
|
|
230
226
|
is_partner_initiated: !args.initiator,
|
|
231
227
|
is_private: args.private,
|
|
232
|
-
is_static_remote_key: chanType === commitmentTypes.static_remote_key,
|
|
233
|
-
is_variable_remote_key: chanType === commitmentTypes.variable_remote_key,
|
|
234
228
|
local_balance: Number(args.local_balance),
|
|
235
229
|
local_csv: own.csv_delay,
|
|
236
230
|
local_dust: Number(own.dust_limit_sat),
|
package/package.json
CHANGED
|
@@ -8,29 +8,29 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@grpc/grpc-js": "1.4.4",
|
|
11
|
-
"@grpc/proto-loader": "0.6.
|
|
11
|
+
"@grpc/proto-loader": "0.6.7",
|
|
12
12
|
"@types/express": "4.17.13",
|
|
13
|
-
"@types/node": "16.11.
|
|
13
|
+
"@types/node": "16.11.9",
|
|
14
14
|
"@types/request": "2.48.7",
|
|
15
15
|
"@types/ws": "8.2.0",
|
|
16
16
|
"async": "3.2.2",
|
|
17
17
|
"asyncjs-util": "1.2.7",
|
|
18
|
-
"bitcoinjs-lib": "
|
|
18
|
+
"bitcoinjs-lib": "6.0.0",
|
|
19
19
|
"bn.js": "5.2.0",
|
|
20
20
|
"body-parser": "1.19.0",
|
|
21
21
|
"bolt07": "1.7.4",
|
|
22
22
|
"bolt09": "0.2.0",
|
|
23
23
|
"cbor": "8.1.0",
|
|
24
24
|
"express": "4.17.1",
|
|
25
|
-
"invoices": "2.0.
|
|
25
|
+
"invoices": "2.0.2",
|
|
26
26
|
"psbt": "1.1.10"
|
|
27
27
|
},
|
|
28
28
|
"description": "Lightning Network client library",
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@alexbosworth/node-fetch": "2.6.2",
|
|
31
31
|
"@alexbosworth/tap": "15.0.10",
|
|
32
|
-
"tsd": "0.
|
|
33
|
-
"typescript": "4.
|
|
32
|
+
"tsd": "0.19.0",
|
|
33
|
+
"typescript": "4.5.2",
|
|
34
34
|
"ws": "8.2.3"
|
|
35
35
|
},
|
|
36
36
|
"engines": {
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"directory": "test/typescript"
|
|
57
57
|
},
|
|
58
58
|
"types": "index.d.ts",
|
|
59
|
-
"version": "
|
|
59
|
+
"version": "5.0.0"
|
|
60
60
|
}
|
|
@@ -3,11 +3,6 @@ const {test} = require('@alexbosworth/tap');
|
|
|
3
3
|
const {createChainAddress} = require('./../../../');
|
|
4
4
|
|
|
5
5
|
const tests = [
|
|
6
|
-
{
|
|
7
|
-
args: {},
|
|
8
|
-
description: 'An address format is required',
|
|
9
|
-
error: [400, 'ExpectedKnownAddressFormat'],
|
|
10
|
-
},
|
|
11
6
|
{
|
|
12
7
|
args: {format: 'foo'},
|
|
13
8
|
description: 'A known address format is required',
|
|
@@ -11,13 +11,10 @@ const makeExpected = overrides => {
|
|
|
11
11
|
cooperative_close_delay_height: undefined,
|
|
12
12
|
id: '0x0x1',
|
|
13
13
|
is_active: true,
|
|
14
|
-
is_anchor: false,
|
|
15
14
|
is_closing: false,
|
|
16
15
|
is_opening: false,
|
|
17
16
|
is_partner_initiated: false,
|
|
18
17
|
is_private: true,
|
|
19
|
-
is_static_remote_key: false,
|
|
20
|
-
is_variable_remote_key: true,
|
|
21
18
|
local_balance: 1,
|
|
22
19
|
local_csv: 1,
|
|
23
20
|
local_dust: 1,
|
|
@@ -250,8 +247,6 @@ const tests = [
|
|
|
250
247
|
expected: {
|
|
251
248
|
channel: makeExpected({
|
|
252
249
|
cooperative_close_delay_height: 1,
|
|
253
|
-
is_static_remote_key: true,
|
|
254
|
-
is_variable_remote_key: false,
|
|
255
250
|
}),
|
|
256
251
|
},
|
|
257
252
|
},
|
|
@@ -261,8 +256,6 @@ const tests = [
|
|
|
261
256
|
expected: {
|
|
262
257
|
channel: makeExpected({
|
|
263
258
|
cooperative_close_delay_height: 5e5,
|
|
264
|
-
is_anchor: true,
|
|
265
|
-
is_variable_remote_key: false,
|
|
266
259
|
}),
|
|
267
260
|
},
|
|
268
261
|
},
|
|
@@ -244,13 +244,10 @@ const tests = [
|
|
|
244
244
|
cooperative_close_delay_height: undefined,
|
|
245
245
|
id: '0x0x1',
|
|
246
246
|
is_active: false,
|
|
247
|
-
is_anchor: false,
|
|
248
247
|
is_closing: false,
|
|
249
248
|
is_opening: false,
|
|
250
249
|
is_partner_initiated: false,
|
|
251
250
|
is_private: false,
|
|
252
|
-
is_static_remote_key: false,
|
|
253
|
-
is_variable_remote_key: true,
|
|
254
251
|
local_balance: 1,
|
|
255
252
|
local_csv: 1,
|
|
256
253
|
local_dust: 1,
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
const {test} = require('@alexbosworth/tap');
|
|
2
|
+
|
|
3
|
+
const {routingFailureFromHtlc} = require('./../../lnd_responses');
|
|
4
|
+
|
|
5
|
+
const makeHtlc = overrides => {
|
|
6
|
+
const htlc = {
|
|
7
|
+
attempt_time_ns: '1',
|
|
8
|
+
failure: {
|
|
9
|
+
channel_update: {
|
|
10
|
+
base_fee: 1,
|
|
11
|
+
chain_hash: Buffer.alloc(32),
|
|
12
|
+
chan_id: '1',
|
|
13
|
+
channel_flags: 1,
|
|
14
|
+
extra_opaque_data: Buffer.alloc(0),
|
|
15
|
+
fee_rate: 1,
|
|
16
|
+
htlc_maximum_msat: 1,
|
|
17
|
+
htlc_minimum_msat: 1,
|
|
18
|
+
message_flags: 1,
|
|
19
|
+
signature: Buffer.alloc(0),
|
|
20
|
+
time_lock_delta: 1,
|
|
21
|
+
timestamp: 1,
|
|
22
|
+
},
|
|
23
|
+
code: 'TEMPORARY_CHANNEL_FAILURE',
|
|
24
|
+
failure_source_index: 0,
|
|
25
|
+
height: 1,
|
|
26
|
+
htlc_msat: '1000',
|
|
27
|
+
},
|
|
28
|
+
resolve_time_ns: '1',
|
|
29
|
+
route: {
|
|
30
|
+
hops: [{
|
|
31
|
+
amt_to_forward: '1',
|
|
32
|
+
amt_to_forward_msat: '1000',
|
|
33
|
+
chan_id: '1',
|
|
34
|
+
chan_capacity: 1,
|
|
35
|
+
expiry: 1,
|
|
36
|
+
fee: 0,
|
|
37
|
+
fee_msat: '0',
|
|
38
|
+
pub_key: Buffer.alloc(33, 3).toString('hex'),
|
|
39
|
+
tlv_payload: true,
|
|
40
|
+
}],
|
|
41
|
+
total_amt: '1',
|
|
42
|
+
total_amt_msat: '1000',
|
|
43
|
+
total_fees: 0,
|
|
44
|
+
total_fees_msat: '0',
|
|
45
|
+
total_time_lock: 1,
|
|
46
|
+
},
|
|
47
|
+
status: 'FAILED',
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
Object.keys(overrides || {}).forEach(k => htlc[k] = overrides[k]);
|
|
51
|
+
|
|
52
|
+
return htlc;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const makeExpected = overrides => {
|
|
56
|
+
const expected = {
|
|
57
|
+
route: {
|
|
58
|
+
fee: 0,
|
|
59
|
+
fee_mtokens: '0',
|
|
60
|
+
hops: [
|
|
61
|
+
{
|
|
62
|
+
channel: '0x0x1',
|
|
63
|
+
channel_capacity: 1,
|
|
64
|
+
fee: 0,
|
|
65
|
+
fee_mtokens: '0',
|
|
66
|
+
forward: 1,
|
|
67
|
+
forward_mtokens: '1000',
|
|
68
|
+
public_key: '030303030303030303030303030303030303030303030303030303030303030303',
|
|
69
|
+
timeout: 1,
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
mtokens: '1000',
|
|
73
|
+
payment: undefined,
|
|
74
|
+
timeout: 1,
|
|
75
|
+
tokens: 1,
|
|
76
|
+
total_mtokens: undefined,
|
|
77
|
+
},
|
|
78
|
+
channel: '0x0x1',
|
|
79
|
+
index: 0,
|
|
80
|
+
mtokens: '1000',
|
|
81
|
+
public_key: undefined,
|
|
82
|
+
reason: 'TemporaryChannelFailure',
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
Object.keys(overrides || {}).forEach(key => expected[key] = overrides[key]);
|
|
86
|
+
|
|
87
|
+
return expected;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const tests = [
|
|
91
|
+
{
|
|
92
|
+
args: makeHtlc({}),
|
|
93
|
+
description: 'HTLC is mapped to a routing failure',
|
|
94
|
+
expected: makeExpected({}),
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
args: makeHtlc({
|
|
98
|
+
failure: {
|
|
99
|
+
channel_update: {
|
|
100
|
+
base_fee: 1,
|
|
101
|
+
chain_hash: Buffer.alloc(32),
|
|
102
|
+
chan_id: '1',
|
|
103
|
+
channel_flags: 1,
|
|
104
|
+
extra_opaque_data: Buffer.alloc(0),
|
|
105
|
+
fee_rate: 1,
|
|
106
|
+
htlc_maximum_msat: 1,
|
|
107
|
+
htlc_minimum_msat: 1,
|
|
108
|
+
message_flags: 1,
|
|
109
|
+
signature: Buffer.alloc(0),
|
|
110
|
+
time_lock_delta: 1,
|
|
111
|
+
timestamp: 1,
|
|
112
|
+
},
|
|
113
|
+
code: 'TEMPORARY_CHANNEL_FAILURE',
|
|
114
|
+
failure_source_index: 1,
|
|
115
|
+
height: 1,
|
|
116
|
+
htlc_msat: '1000',
|
|
117
|
+
},
|
|
118
|
+
}),
|
|
119
|
+
description: 'HTLC is mapped to a routing failure with key',
|
|
120
|
+
expected: makeExpected({
|
|
121
|
+
index: 1,
|
|
122
|
+
public_key: Buffer.alloc(33, 3).toString('hex'),
|
|
123
|
+
}),
|
|
124
|
+
},
|
|
125
|
+
];
|
|
126
|
+
|
|
127
|
+
tests.forEach(({args, description, error, expected}) => {
|
|
128
|
+
return test(description, ({end, strictSame, throws}) => {
|
|
129
|
+
if (!!error) {
|
|
130
|
+
throws(() => routingFailureFromHtlc(args), new Error(error), 'Got err');
|
|
131
|
+
} else {
|
|
132
|
+
strictSame(routingFailureFromHtlc(args), expected, 'HTLC mapped');
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return end();
|
|
136
|
+
});
|
|
137
|
+
});
|
|
@@ -69,13 +69,10 @@ const makeExpected = overrides => {
|
|
|
69
69
|
cooperative_close_delay_height: undefined,
|
|
70
70
|
id: '0x0x1',
|
|
71
71
|
is_active: true,
|
|
72
|
-
is_anchor: false,
|
|
73
72
|
is_closing: false,
|
|
74
73
|
is_opening: false,
|
|
75
74
|
is_partner_initiated: true,
|
|
76
75
|
is_private: true,
|
|
77
|
-
is_static_remote_key: false,
|
|
78
|
-
is_variable_remote_key: true,
|
|
79
76
|
local_balance: 1,
|
|
80
77
|
local_csv: 1,
|
|
81
78
|
local_dust: 1,
|
|
@@ -236,8 +233,6 @@ const tests = [
|
|
|
236
233
|
description: 'Initiated RPC channel is mapped to channel',
|
|
237
234
|
expected: makeExpected({
|
|
238
235
|
is_partner_initiated: false,
|
|
239
|
-
is_static_remote_key: true,
|
|
240
|
-
is_variable_remote_key: false,
|
|
241
236
|
}),
|
|
242
237
|
},
|
|
243
238
|
{
|
|
@@ -262,8 +257,6 @@ const tests = [
|
|
|
262
257
|
}),
|
|
263
258
|
description: 'Local constraints RPC channel is mapped to channel',
|
|
264
259
|
expected: makeExpected({
|
|
265
|
-
is_anchor: true,
|
|
266
|
-
is_variable_remote_key: false,
|
|
267
260
|
local_csv: 1,
|
|
268
261
|
local_dust: 1,
|
|
269
262
|
local_max_htlcs: 1,
|
|
@@ -10,13 +10,7 @@ expectError(disconnectWatchtower());
|
|
|
10
10
|
expectError(disconnectWatchtower({}));
|
|
11
11
|
expectError(disconnectWatchtower({lnd}));
|
|
12
12
|
expectError(disconnectWatchtower({public_key}));
|
|
13
|
-
expectError(disconnectWatchtower({retry_delay}));
|
|
14
|
-
expectError(disconnectWatchtower({lnd, retry_delay}));
|
|
15
13
|
|
|
16
14
|
expectType<void>(await disconnectWatchtower({lnd, public_key}));
|
|
17
|
-
expectType<void>(await disconnectWatchtower({lnd, public_key, retry_delay}));
|
|
18
15
|
|
|
19
16
|
expectType<void>(disconnectWatchtower({lnd, public_key}, () => {}));
|
|
20
|
-
expectType<void>(
|
|
21
|
-
disconnectWatchtower({lnd, public_key, retry_delay}, () => {})
|
|
22
|
-
);
|