lightning 4.13.0 → 4.14.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 +5 -1
- package/grpc/protos/invoices.proto +35 -0
- package/grpc/protos/lightning.proto +47 -7
- package/grpc/protos/signer.proto +4 -4
- package/lnd_methods/info/constants.json +1 -0
- package/lnd_methods/macaroon/accept_rpc_request.js +1 -1
- package/lnd_methods/macaroon/handle_rpc_request_update.js +6 -3
- package/lnd_methods/macaroon/reject_rpc_request.js +1 -1
- package/lnd_methods/macaroon/subscribe_to_rpc_requests.d.ts +4 -2
- package/lnd_methods/macaroon/subscribe_to_rpc_requests.js +8 -6
- package/lnd_methods/offchain/delete_failed_pay_attempts.js +1 -1
- package/lnd_methods/offchain/delete_payment.d.ts +1 -1
- package/lnd_methods/offchain/delete_payment.js +1 -1
- package/lnd_methods/offchain/emit_payment.js +2 -1
- package/lnd_methods/offchain/get_payment.d.ts +54 -0
- package/lnd_methods/offchain/get_payment.js +26 -1
- package/lnd_methods/offchain/subscribe_to_forwards.js +1 -1
- package/lnd_methods/offchain/subscribe_to_past_payment.js +28 -1
- package/lnd_methods/offchain/subscribe_to_past_payments.d.ts +1 -1
- package/lnd_methods/offchain/subscribe_to_past_payments.js +1 -1
- package/lnd_methods/offchain/subscribe_to_peer_messages.d.ts +1 -1
- package/lnd_methods/offchain/subscribe_to_peer_messages.js +1 -1
- package/lnd_methods/offchain/update_routing_fees.d.ts +1 -1
- package/lnd_methods/offchain/update_routing_fees.js +1 -1
- package/lnd_methods/unauthenticated/get_wallet_status.d.ts +1 -1
- package/lnd_methods/unauthenticated/get_wallet_status.js +1 -1
- package/lnd_methods/unauthenticated/subscribe_to_wallet_status.d.ts +1 -1
- package/lnd_methods/unauthenticated/subscribe_to_wallet_status.js +1 -1
- package/lnd_responses/index.js +2 -0
- package/lnd_responses/pending_from_payment.js +145 -0
- package/lnd_responses/rpc_channel_as_old_rpc_channel.js +1 -1
- package/lnd_responses/rpc_request_update_as_event.js +12 -2
- package/package.json +4 -4
- package/test/lnd_methods/macaroon/test_handle_rpc_request_update.js +4 -0
- package/test/lnd_methods/macaroon/test_subscribe_to_rpc_requests.js +5 -2
- package/test/lnd_methods/offchain/test_get_payment.js +71 -1
- package/test/lnd_responses/test_pending_from_payment.js +143 -0
- package/test/lnd_responses/test_rpc_request_update_as_event.js +7 -1
- package/test/protos/protos.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# Versions
|
|
2
2
|
|
|
3
|
-
## 4.
|
|
3
|
+
## 4.14.0
|
|
4
|
+
|
|
5
|
+
- `getPayment`, `subscribeToPastPayment`: Add `pending` for pending payment details
|
|
6
|
+
|
|
7
|
+
## 4.13.3
|
|
4
8
|
|
|
5
9
|
- Add `sendMessageToPeer` to send a peer to peer message to a connected peer
|
|
6
10
|
- Add `subscribeToPeerMessages` to listen to messages from connected peers
|
|
@@ -35,6 +35,12 @@ service Invoices {
|
|
|
35
35
|
settled, this call will succeed.
|
|
36
36
|
*/
|
|
37
37
|
rpc SettleInvoice (SettleInvoiceMsg) returns (SettleInvoiceResp);
|
|
38
|
+
|
|
39
|
+
/*
|
|
40
|
+
LookupInvoiceV2 attempts to look up at invoice. An invoice can be refrenced
|
|
41
|
+
using either its payment hash, payment address, or set ID.
|
|
42
|
+
*/
|
|
43
|
+
rpc LookupInvoiceV2 (LookupInvoiceMsg) returns (lnrpc.Invoice);
|
|
38
44
|
}
|
|
39
45
|
|
|
40
46
|
message CancelInvoiceMsg {
|
|
@@ -134,4 +140,33 @@ message SubscribeSingleInvoiceRequest {
|
|
|
134
140
|
|
|
135
141
|
// Hash corresponding to the (hold) invoice to subscribe to.
|
|
136
142
|
bytes r_hash = 2;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
enum LookupModifier {
|
|
146
|
+
// The default look up modifier, no look up behavior is changed.
|
|
147
|
+
DEFAULT = 0;
|
|
148
|
+
|
|
149
|
+
/*
|
|
150
|
+
Indicates that when a look up is done based on a set_id, then only that set
|
|
151
|
+
of HTLCs related to that set ID should be returned.
|
|
152
|
+
*/
|
|
153
|
+
HTLC_SET_ONLY = 1;
|
|
154
|
+
|
|
155
|
+
/*
|
|
156
|
+
Indicates that when a look up is done using a payment_addr, then no HTLCs
|
|
157
|
+
related to the payment_addr should be returned. This is useful when one
|
|
158
|
+
wants to be able to obtain the set of associated setIDs with a given
|
|
159
|
+
invoice, then look up the sub-invoices "projected" by that set ID.
|
|
160
|
+
*/
|
|
161
|
+
HTLC_SET_BLANK = 2;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
message LookupInvoiceMsg {
|
|
165
|
+
oneof invoice_ref {
|
|
166
|
+
bytes payment_hash = 1;
|
|
167
|
+
bytes payment_addr = 2;
|
|
168
|
+
bytes set_id = 3;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
LookupModifier lookup_modifier = 4;
|
|
137
172
|
}
|
|
@@ -3056,6 +3056,10 @@ message HopHint {
|
|
|
3056
3056
|
uint32 cltv_expiry_delta = 5;
|
|
3057
3057
|
}
|
|
3058
3058
|
|
|
3059
|
+
message SetID {
|
|
3060
|
+
bytes set_id = 1;
|
|
3061
|
+
}
|
|
3062
|
+
|
|
3059
3063
|
message RouteHint {
|
|
3060
3064
|
/*
|
|
3061
3065
|
A list of hop hints that when chained together can assist in reaching a
|
|
@@ -3064,6 +3068,20 @@ message RouteHint {
|
|
|
3064
3068
|
repeated HopHint hop_hints = 1;
|
|
3065
3069
|
}
|
|
3066
3070
|
|
|
3071
|
+
message AMPInvoiceState {
|
|
3072
|
+
// The state the HTLCs associated with this setID are in.
|
|
3073
|
+
InvoiceHTLCState state = 1;
|
|
3074
|
+
|
|
3075
|
+
// The settle index of this HTLC set, if the invoice state is settled.
|
|
3076
|
+
uint64 settle_index = 2;
|
|
3077
|
+
|
|
3078
|
+
// The time this HTLC set was settled expressed in unix epoch.
|
|
3079
|
+
int64 settle_time = 3;
|
|
3080
|
+
|
|
3081
|
+
// The total amount paid for the sub-invoice expressed in milli satoshis.
|
|
3082
|
+
int64 amt_paid_msat = 5;
|
|
3083
|
+
}
|
|
3084
|
+
|
|
3067
3085
|
message Invoice {
|
|
3068
3086
|
/*
|
|
3069
3087
|
An optional memo to attach along with the invoice. Used for record keeping
|
|
@@ -3209,7 +3227,7 @@ message Invoice {
|
|
|
3209
3227
|
|
|
3210
3228
|
/*
|
|
3211
3229
|
The payment address of this invoice. This value will be used in MPP
|
|
3212
|
-
payments, and also for newer
|
|
3230
|
+
payments, and also for newer invoices that always require the MPP payload
|
|
3213
3231
|
for added end-to-end security.
|
|
3214
3232
|
*/
|
|
3215
3233
|
bytes payment_addr = 26;
|
|
@@ -3218,6 +3236,16 @@ message Invoice {
|
|
|
3218
3236
|
Signals whether or not this is an AMP invoice.
|
|
3219
3237
|
*/
|
|
3220
3238
|
bool is_amp = 27;
|
|
3239
|
+
|
|
3240
|
+
/*
|
|
3241
|
+
[EXPERIMENTAL]:
|
|
3242
|
+
|
|
3243
|
+
Maps a 32-byte hex-encoded set ID to the sub-invoice AMP state for the
|
|
3244
|
+
given set ID. This field is always populated for AMP invoices, and can be
|
|
3245
|
+
used along side LookupInvoice to obtain the HTLC information related to a
|
|
3246
|
+
given sub-invoice.
|
|
3247
|
+
*/
|
|
3248
|
+
map<string, AMPInvoiceState> amp_invoice_state = 28;
|
|
3221
3249
|
}
|
|
3222
3250
|
|
|
3223
3251
|
enum InvoiceHTLCState {
|
|
@@ -4147,8 +4175,10 @@ message CheckMacPermResponse {
|
|
|
4147
4175
|
|
|
4148
4176
|
message RPCMiddlewareRequest {
|
|
4149
4177
|
/*
|
|
4150
|
-
The unique ID of the intercepted request. Useful for mapping
|
|
4151
|
-
response when implementing full duplex message interception.
|
|
4178
|
+
The unique ID of the intercepted original gRPC request. Useful for mapping
|
|
4179
|
+
request to response when implementing full duplex message interception. For
|
|
4180
|
+
streaming requests, this will be the same ID for all incoming and outgoing
|
|
4181
|
+
middleware intercept messages of the _same_ stream.
|
|
4152
4182
|
*/
|
|
4153
4183
|
uint64 request_id = 1;
|
|
4154
4184
|
|
|
@@ -4203,6 +4233,16 @@ message RPCMiddlewareRequest {
|
|
|
4203
4233
|
*/
|
|
4204
4234
|
RPCMessage response = 6;
|
|
4205
4235
|
}
|
|
4236
|
+
|
|
4237
|
+
/*
|
|
4238
|
+
The unique message ID of this middleware intercept message. There can be
|
|
4239
|
+
multiple middleware intercept messages per single gRPC request (one for the
|
|
4240
|
+
incoming request and one for the outgoing response) or gRPC stream (one for
|
|
4241
|
+
each incoming message and one for each outgoing response). This message ID
|
|
4242
|
+
must be referenced when responding (accepting/rejecting/modifying) to an
|
|
4243
|
+
intercept message.
|
|
4244
|
+
*/
|
|
4245
|
+
uint64 msg_id = 7;
|
|
4206
4246
|
}
|
|
4207
4247
|
|
|
4208
4248
|
message StreamAuth {
|
|
@@ -4242,11 +4282,11 @@ message RPCMessage {
|
|
|
4242
4282
|
|
|
4243
4283
|
message RPCMiddlewareResponse {
|
|
4244
4284
|
/*
|
|
4245
|
-
The
|
|
4246
|
-
|
|
4247
|
-
|
|
4285
|
+
The request message ID this response refers to. Must always be set when
|
|
4286
|
+
giving feedback to an intercept but is ignored for the initial registration
|
|
4287
|
+
message.
|
|
4248
4288
|
*/
|
|
4249
|
-
uint64
|
|
4289
|
+
uint64 ref_msg_id = 1;
|
|
4250
4290
|
|
|
4251
4291
|
/*
|
|
4252
4292
|
The middleware can only send two types of messages to lnd: The initial
|
package/grpc/protos/signer.proto
CHANGED
|
@@ -74,14 +74,14 @@ message KeyLocator {
|
|
|
74
74
|
|
|
75
75
|
message KeyDescriptor {
|
|
76
76
|
/*
|
|
77
|
-
The raw bytes of the key being identified. Either
|
|
78
|
-
must be specified.
|
|
77
|
+
The raw bytes of the public key in the key pair being identified. Either
|
|
78
|
+
this or the KeyLocator must be specified.
|
|
79
79
|
*/
|
|
80
80
|
bytes raw_key_bytes = 1;
|
|
81
81
|
|
|
82
82
|
/*
|
|
83
|
-
The key locator that identifies which key to use for signing.
|
|
84
|
-
or the raw bytes of the target key must be specified.
|
|
83
|
+
The key locator that identifies which private key to use for signing.
|
|
84
|
+
Either this or the raw bytes of the target public key must be specified.
|
|
85
85
|
*/
|
|
86
86
|
KeyLocator key_loc = 2;
|
|
87
87
|
}
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"4f567577db9d85b6f392f960b3aabddcad3cd02c": "0.13.3-beta",
|
|
25
25
|
"52bb3f33707b81972c67937c7a89addcdf00991c": "0.10.1-beta",
|
|
26
26
|
"596fd90ef310cd7abbf2251edaae9ba4d5f8a689": "0.13.1-beta",
|
|
27
|
+
"61c34683058f2cc8dc10f49392a0057440d831c4": "0.13.4-beta",
|
|
27
28
|
"725ff104808f49f0a5247bfdb4b6b5da7f488d38": "0.13.0-beta",
|
|
28
29
|
"7f34774529fa0964d47fc418d4d2965435cbfdc0": "0.11.1-beta",
|
|
29
30
|
"86d3dec7b939b21bb10f2cd1ff56970c392a1c69": "0.13.2-beta",
|
|
@@ -30,7 +30,7 @@ module.exports = ({id, subscription}, cbk) => {
|
|
|
30
30
|
|
|
31
31
|
// Send accept feedback to the stream
|
|
32
32
|
accept: ['validate', ({}, cbk) => {
|
|
33
|
-
return subscription.write({feedback,
|
|
33
|
+
return subscription.write({feedback, ref_msg_id: id}, err => {
|
|
34
34
|
if (!!err) {
|
|
35
35
|
return cbk([503, 'UnexpectedErrorAcceptingRpcRequest', {err}]);
|
|
36
36
|
}
|
|
@@ -17,6 +17,7 @@ const isPayViaRoute = n => !!n && n === '/routerrpc.Router/SendToRouteV2';
|
|
|
17
17
|
[is_intercepting_pay_via_routes_requests]: <Is Handling Route Reqs Bool>
|
|
18
18
|
subscription: <Stream Subscription Object>
|
|
19
19
|
update: {
|
|
20
|
+
msg_id: <Message Id Number String>
|
|
20
21
|
request_id: <Request Id Number String>
|
|
21
22
|
raw_macaroon: <Raw Macaroon Buffer Object>
|
|
22
23
|
custom_caveat_condition: <Custom Caveat Condition String>
|
|
@@ -47,12 +48,13 @@ const isPayViaRoute = n => !!n && n === '/routerrpc.Router/SendToRouteV2';
|
|
|
47
48
|
[accept]: ({}, cbk) => {}
|
|
48
49
|
data: {
|
|
49
50
|
[accept]: ({}, cbk) => {}
|
|
50
|
-
|
|
51
|
+
call: <Call Id Number>
|
|
52
|
+
id: <Message Id Number>
|
|
51
53
|
[macaroon]: <Base64 Encoded Macaroon String>
|
|
52
54
|
[reject]: ({}, cbk) => {}
|
|
53
55
|
[request]: {
|
|
54
56
|
[chain_fee_tokens_per_vbyte]: <Chain Fee Tokens Per VByte Number>
|
|
55
|
-
[cooperative_close_address]: <Prefer Cooperative Close
|
|
57
|
+
[cooperative_close_address]: <Prefer Cooperative Close Address String>
|
|
56
58
|
[give_tokens]: <Tokens to Gift To Partner Number>
|
|
57
59
|
[is_private]: <Channel is Private Bool>
|
|
58
60
|
local_tokens: <Local Tokens Number>
|
|
@@ -72,6 +74,7 @@ module.exports = args => {
|
|
|
72
74
|
const isInterceptOpenChans = !!args.is_intercepting_open_channel_requests;
|
|
73
75
|
const isInterceptPayOnRoute = !!args.is_intercepting_pay_via_routes_requests;
|
|
74
76
|
|
|
77
|
+
const {call} = details;
|
|
75
78
|
const {event} = details;
|
|
76
79
|
const {id} = details;
|
|
77
80
|
const {macaroon} = details;
|
|
@@ -144,5 +147,5 @@ module.exports = args => {
|
|
|
144
147
|
};
|
|
145
148
|
}
|
|
146
149
|
|
|
147
|
-
return {accept, event, data: {id, macaroon, uri}};
|
|
150
|
+
return {accept, event, data: {call, id, macaroon, uri}};
|
|
148
151
|
};
|
|
@@ -21,7 +21,9 @@ export type SubscribeToRpcRequestsResult = {
|
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
export type SubscribeToRpcRequestsCommonEvent = {
|
|
24
|
-
/**
|
|
24
|
+
/** Call Id Number */
|
|
25
|
+
call: number;
|
|
26
|
+
/** Message Id Number */
|
|
25
27
|
id: number;
|
|
26
28
|
/** Base64 Encoded Macaroon String */
|
|
27
29
|
macaroon?: string;
|
|
@@ -135,7 +137,7 @@ export type SubscribeToRpcRequestsResponseEvent =
|
|
|
135
137
|
*
|
|
136
138
|
* LND must be running with "RPC middleware" enabled: `rpcmiddleware.enable=1`
|
|
137
139
|
*
|
|
138
|
-
* This method is not supported in LND 0.13.
|
|
140
|
+
* This method is not supported in LND 0.13.4 and below
|
|
139
141
|
*/
|
|
140
142
|
export const subscribeToRpcRequests: AuthenticatedLightningMethod<
|
|
141
143
|
SubscribeToRpcRequestsArgs,
|
|
@@ -22,7 +22,7 @@ const type = 'default';
|
|
|
22
22
|
|
|
23
23
|
LND must be running with "RPC middleware" enabled: `rpcmiddleware.enable=1`
|
|
24
24
|
|
|
25
|
-
This method is not supported in LND 0.13.
|
|
25
|
+
This method is not supported in LND 0.13.4 and below
|
|
26
26
|
|
|
27
27
|
{
|
|
28
28
|
[id]: <RPC Middleware Interception Name String>
|
|
@@ -41,7 +41,7 @@ const type = 'default';
|
|
|
41
41
|
@event 'close_channel_request'
|
|
42
42
|
{
|
|
43
43
|
accept: ({}, [cbk]) => {}
|
|
44
|
-
id: <
|
|
44
|
+
id: <Message Id Number>
|
|
45
45
|
macaroon: <Base64 Encoded Macaroon String>
|
|
46
46
|
reject: ({message: <Rejection String>}, [cbk]) => {}
|
|
47
47
|
request: {
|
|
@@ -59,7 +59,7 @@ const type = 'default';
|
|
|
59
59
|
@event 'open_channel_request'
|
|
60
60
|
{
|
|
61
61
|
accept: ({}, [cbk]) => {}
|
|
62
|
-
id: <
|
|
62
|
+
id: <Message Id Number>
|
|
63
63
|
macaroon: <Base64 Encoded Macaroon String>
|
|
64
64
|
reject: ({message: <Rejection String>}, [cbk]) => {}
|
|
65
65
|
request: {
|
|
@@ -80,7 +80,7 @@ const type = 'default';
|
|
|
80
80
|
@event 'pay_via_route_request'
|
|
81
81
|
{
|
|
82
82
|
accept: ({}, [cbk]) => {}
|
|
83
|
-
id: <
|
|
83
|
+
id: <Message Id Number>
|
|
84
84
|
macaroon: <Base64 Encoded Macaroon String>
|
|
85
85
|
reject: ({message: <Rejection String>}, [cbk]) => {}
|
|
86
86
|
request: {
|
|
@@ -110,14 +110,16 @@ const type = 'default';
|
|
|
110
110
|
|
|
111
111
|
@event 'request'
|
|
112
112
|
{
|
|
113
|
-
|
|
113
|
+
call: <Call Identifier Number>
|
|
114
|
+
id: <Message Id Number>
|
|
114
115
|
[macaroon]: <Base64 Encoded Macaroon String>
|
|
115
116
|
[uri]: <RPC URI String>
|
|
116
117
|
}
|
|
117
118
|
|
|
118
119
|
@event 'response'
|
|
119
120
|
{
|
|
120
|
-
|
|
121
|
+
call: <Call Identifier Number>
|
|
122
|
+
id: <Message Id Number>
|
|
121
123
|
[macaroon]: <Base64 Encoded Macaroon String>
|
|
122
124
|
[uri]: <RPC URI String>
|
|
123
125
|
}
|
|
@@ -13,6 +13,6 @@ export type DeletePaymentArgs = AuthenticatedLightningArgs<{
|
|
|
13
13
|
*
|
|
14
14
|
* Requires `offchain:write` permission
|
|
15
15
|
*
|
|
16
|
-
* Note: this method is not supported on LND 0.13.
|
|
16
|
+
* Note: this method is not supported on LND 0.13.4 and below
|
|
17
17
|
*/
|
|
18
18
|
export const deletePayment: AuthenticatedLightningMethod<DeletePaymentArgs>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const {confirmedFromPayment} = require('./../../lnd_responses');
|
|
2
2
|
const {failureFromPayment} = require('./../../lnd_responses');
|
|
3
|
+
const {pendingFromPayment} = require('./../../lnd_responses');
|
|
3
4
|
const {states} = require('./payment_states');
|
|
4
5
|
|
|
5
6
|
/** Emit payment from payment event
|
|
@@ -21,7 +22,7 @@ module.exports = ({data, emitter}) => {
|
|
|
21
22
|
return emitter.emit('failed', failureFromPayment(data));
|
|
22
23
|
|
|
23
24
|
case states.paying:
|
|
24
|
-
return emitter.emit('paying',
|
|
25
|
+
return emitter.emit('paying', pendingFromPayment(data));
|
|
25
26
|
|
|
26
27
|
default:
|
|
27
28
|
return;
|
|
@@ -105,6 +105,60 @@ export type GetPaymentResult = {
|
|
|
105
105
|
/** Total Tokens Paid */
|
|
106
106
|
tokens: number;
|
|
107
107
|
};
|
|
108
|
+
pending?: {
|
|
109
|
+
/** Created at ISO-8601 Date */
|
|
110
|
+
created_at: string;
|
|
111
|
+
/** Payment Destination Public Key Hex */
|
|
112
|
+
destination: string;
|
|
113
|
+
/** Payment Hash Hex */
|
|
114
|
+
id: string;
|
|
115
|
+
/** Total Millitokens Pending */
|
|
116
|
+
mtokens: string;
|
|
117
|
+
paths: {
|
|
118
|
+
/** Total Path Fee Tokens */
|
|
119
|
+
fee: number;
|
|
120
|
+
/** Total Path Fee Millitokens */
|
|
121
|
+
fee_mtokens: string;
|
|
122
|
+
hops: {
|
|
123
|
+
/** Standard Format Channel Id */
|
|
124
|
+
channel: string;
|
|
125
|
+
/** Channel Capacity Tokens */
|
|
126
|
+
channel_capacity: number;
|
|
127
|
+
/** Routing Fee Tokens */
|
|
128
|
+
fee: number;
|
|
129
|
+
/** Fee Millitokens */
|
|
130
|
+
fee_mtokens: string;
|
|
131
|
+
/** Forwarded Tokens */
|
|
132
|
+
forward: number;
|
|
133
|
+
/** Forward Millitokens */
|
|
134
|
+
forward_mtokens: string;
|
|
135
|
+
/** Public Key Hex */
|
|
136
|
+
public_key: string;
|
|
137
|
+
/** Timeout Block Height */
|
|
138
|
+
timeout: number;
|
|
139
|
+
}[];
|
|
140
|
+
/** Total Path Millitokens Paid */
|
|
141
|
+
mtokens: string;
|
|
142
|
+
/** MPP Payment Identifying Nonce */
|
|
143
|
+
payment: string;
|
|
144
|
+
/** Expiration Block Height */
|
|
145
|
+
timeout: number;
|
|
146
|
+
/** Path Tokens Paid */
|
|
147
|
+
tokens: number;
|
|
148
|
+
/** Total Millitokens Pending */
|
|
149
|
+
total_mtokens: string;
|
|
150
|
+
}[]
|
|
151
|
+
/** BOLT 11 Payment Request */
|
|
152
|
+
request?: string;
|
|
153
|
+
/** Payment Tokens Rounded Up */
|
|
154
|
+
safe_tokens: number;
|
|
155
|
+
/** Payment Preimage Hex */
|
|
156
|
+
secret: string;
|
|
157
|
+
/** Expiration Block Height */
|
|
158
|
+
timeout?: number;
|
|
159
|
+
/** Total Tokens Pending */
|
|
160
|
+
tokens: number;
|
|
161
|
+
};
|
|
108
162
|
};
|
|
109
163
|
|
|
110
164
|
/**
|
|
@@ -67,6 +67,30 @@ const type = 'router';
|
|
|
67
67
|
timeout: <Expiration Block Height Number>
|
|
68
68
|
tokens: <Total Tokens Paid Number>
|
|
69
69
|
}
|
|
70
|
+
[pending]: {
|
|
71
|
+
created_at: <Payment Created At ISO 8601 Date String>
|
|
72
|
+
destination: <Payment Destination Hex String>
|
|
73
|
+
id: <Payment Hash Hex String>
|
|
74
|
+
mtokens: <Total Millitokens Pending String>
|
|
75
|
+
paths: [{
|
|
76
|
+
fee_mtokens: <Total Fee Millitokens Paid String>
|
|
77
|
+
hops: [{
|
|
78
|
+
channel: <Standard Format Channel Id String>
|
|
79
|
+
channel_capacity: <Channel Capacity Tokens Number>
|
|
80
|
+
fee: <Fee Tokens Rounded Down Number>
|
|
81
|
+
fee_mtokens: <Fee Millitokens String>
|
|
82
|
+
forward: <Forwarded Tokens Number>
|
|
83
|
+
forward_mtokens: <Forward Millitokens String>
|
|
84
|
+
public_key: <Public Key Hex String>
|
|
85
|
+
timeout: <Timeout Block Height Number>
|
|
86
|
+
}]
|
|
87
|
+
mtokens: <Total Millitokens Pending String>
|
|
88
|
+
}]
|
|
89
|
+
[request]: <BOLT 11 Encoded Payment Request String>
|
|
90
|
+
safe_tokens: <Payment Tokens Rounded Up Number>
|
|
91
|
+
[timeout]: <Expiration Block Height Number>
|
|
92
|
+
tokens: <Total Tokens Pending Number>
|
|
93
|
+
}
|
|
70
94
|
}
|
|
71
95
|
*/
|
|
72
96
|
module.exports = ({id, lnd}, cbk) => {
|
|
@@ -102,6 +126,7 @@ module.exports = ({id, lnd}, cbk) => {
|
|
|
102
126
|
is_failed: !!res.failed,
|
|
103
127
|
is_pending: !res.payment && !res.failed,
|
|
104
128
|
payment: res.payment || undefined,
|
|
129
|
+
pending: res.pending || undefined,
|
|
105
130
|
});
|
|
106
131
|
};
|
|
107
132
|
|
|
@@ -109,7 +134,7 @@ module.exports = ({id, lnd}, cbk) => {
|
|
|
109
134
|
sub.once('end', () => cbk([503, 'UnknownStatusOfPayment']));
|
|
110
135
|
sub.once('error', err => finished(err));
|
|
111
136
|
sub.once('failed', failed => finished(null, {failed}));
|
|
112
|
-
sub.once('paying',
|
|
137
|
+
sub.once('paying', pending => finished(null, {pending}));
|
|
113
138
|
|
|
114
139
|
return;
|
|
115
140
|
}],
|
|
@@ -16,7 +16,7 @@ const unknownFailureMessage = '2 UNKNOWN: unknown failure detail type: <nil>';
|
|
|
16
16
|
|
|
17
17
|
Requires `offchain:read` permission
|
|
18
18
|
|
|
19
|
-
Note: LND 0.13.
|
|
19
|
+
Note: LND 0.13.4 and below do not return `secret` for forwards
|
|
20
20
|
|
|
21
21
|
{
|
|
22
22
|
lnd: <Authenticated LND API Object>
|
|
@@ -82,7 +82,34 @@ const unknownServiceErr = 'unknown service verrpc.Versioner';
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
@event 'paying'
|
|
85
|
-
{
|
|
85
|
+
{
|
|
86
|
+
created_at: <Payment Created At ISO 8601 Date String>
|
|
87
|
+
destination: <Payment Destination Hex String>
|
|
88
|
+
id: <Payment Hash Hex String>
|
|
89
|
+
mtokens: <Total Millitokens Pending String>
|
|
90
|
+
paths: [{
|
|
91
|
+
fee: <Total Fee Tokens Pending Number>
|
|
92
|
+
fee_mtokens: <Total Fee Millitokens Pending String>
|
|
93
|
+
hops: [{
|
|
94
|
+
channel: <Standard Format Channel Id String>
|
|
95
|
+
channel_capacity: <Channel Capacity Tokens Number>
|
|
96
|
+
fee: <Fee Tokens Rounded Down Number>
|
|
97
|
+
fee_mtokens: <Fee Millitokens String>
|
|
98
|
+
forward: <Forward Tokens Number>
|
|
99
|
+
forward_mtokens: <Forward Millitokens String>
|
|
100
|
+
public_key: <Public Key Hex String>
|
|
101
|
+
timeout: <Timeout Block Height Number>
|
|
102
|
+
}]
|
|
103
|
+
mtokens: <Total Millitokens Pending String>
|
|
104
|
+
safe_fee: <Total Fee Tokens Pending Rounded Up Number>
|
|
105
|
+
safe_tokens: <Total Tokens Pending, Rounded Up Number>
|
|
106
|
+
timeout: <Expiration Block Height Number>
|
|
107
|
+
}]
|
|
108
|
+
[request]: <BOLT 11 Encoded Payment Request String>
|
|
109
|
+
safe_tokens: <Total Tokens Pending, Rounded Up Number>
|
|
110
|
+
[timeout]: <Expiration Block Height Number>
|
|
111
|
+
tokens: <Total Tokens Pending Rounded Down Number>
|
|
112
|
+
}
|
|
86
113
|
*/
|
|
87
114
|
module.exports = args => {
|
|
88
115
|
if (!isHash(args.id)) {
|
|
@@ -69,6 +69,6 @@ export type SubscribeToPastPaymentsPaymentEvent = {
|
|
|
69
69
|
*
|
|
70
70
|
* Requires `offchain:read` permission
|
|
71
71
|
*
|
|
72
|
-
* Note: Method not supported on LND 0.13.
|
|
72
|
+
* Note: Method not supported on LND 0.13.4 and below
|
|
73
73
|
*/
|
|
74
74
|
export const subscribeToPastPayments: AuthenticatedLightningSubscription<SubscribeToPastPaymentsArgs>;
|
|
@@ -23,7 +23,7 @@ const unknownFailureMessage = '2 UNKNOWN: unknown failure detail type: <nil>';
|
|
|
23
23
|
|
|
24
24
|
Requires `offchain:read` permission
|
|
25
25
|
|
|
26
|
-
Note: Method not supported on LND 0.13.
|
|
26
|
+
Note: Method not supported on LND 0.13.4 and below
|
|
27
27
|
|
|
28
28
|
{
|
|
29
29
|
lnd: <Authenticated LND API Object>
|
|
@@ -13,6 +13,6 @@ export type SubscribeToPeerMessagesMessageReceivedEvent =
|
|
|
13
13
|
*
|
|
14
14
|
* Requires `offchain:read` permission
|
|
15
15
|
*
|
|
16
|
-
* This method is not supported in LND 0.13.
|
|
16
|
+
* This method is not supported in LND 0.13.4 and below
|
|
17
17
|
*/
|
|
18
18
|
export const subscribeToPeerMessages: AuthenticatedLightningSubscription;
|
|
@@ -67,7 +67,7 @@ export type UpdateRoutingFeesResult = {
|
|
|
67
67
|
*
|
|
68
68
|
* Setting both `base_fee_tokens` and `base_fee_mtokens` is not supported
|
|
69
69
|
*
|
|
70
|
-
* `failures` are not returned on LND 0.13.
|
|
70
|
+
* `failures` are not returned on LND 0.13.4 and below
|
|
71
71
|
*
|
|
72
72
|
* Requires `offchain:write` permission
|
|
73
73
|
*/
|
|
@@ -26,7 +26,7 @@ export type GetWalletStatusResult = {
|
|
|
26
26
|
*
|
|
27
27
|
* This method is not supported on LND 0.12.1 and below
|
|
28
28
|
*
|
|
29
|
-
* `is_ready` is not supported on LND 0.13.
|
|
29
|
+
* `is_ready` is not supported on LND 0.13.4 and below
|
|
30
30
|
*/
|
|
31
31
|
export const getWalletStatus: UnauthenticatedLightningMethod<
|
|
32
32
|
{lnd: UnauthenticatedLnd},
|
|
@@ -14,7 +14,7 @@ const unsupportedMessage = 'unknown service lnrpc.State';
|
|
|
14
14
|
|
|
15
15
|
This method is not supported on LND 0.12.1 and below
|
|
16
16
|
|
|
17
|
-
`is_ready` is not supported on LND 0.13.
|
|
17
|
+
`is_ready` is not supported on LND 0.13.4 and below
|
|
18
18
|
|
|
19
19
|
{
|
|
20
20
|
lnd: <Unauthenticated LND API Object>
|
|
@@ -25,6 +25,6 @@ export type SubscribeToWalletStatusStartingEvent = EmptyObject;
|
|
|
25
25
|
*
|
|
26
26
|
* This method is not supported on LND 0.12.1 and below
|
|
27
27
|
*
|
|
28
|
-
* `ready` is not supported on LND 0.13.
|
|
28
|
+
* `ready` is not supported on LND 0.13.4 and below
|
|
29
29
|
*/
|
|
30
30
|
export const subscribeToWalletStatus: UnauthenticatedLightningSubscription;
|
package/lnd_responses/index.js
CHANGED
|
@@ -11,6 +11,7 @@ const nodeInfoAsNode = require('./node_info_as_node');
|
|
|
11
11
|
const paymentFailure = require('./payment_failure');
|
|
12
12
|
const paymentRequestDetails = require('./payment_request_details');
|
|
13
13
|
const pendingAsPendingChannels = require('./pending_as_pending_channels');
|
|
14
|
+
const pendingFromPayment = require('./pending_from_payment');
|
|
14
15
|
const policyFromChannelUpdate = require('./policy_from_channel_update');
|
|
15
16
|
const routesFromQueryRoutes = require('./routes_from_query_routes');
|
|
16
17
|
const rpcAttemptHtlcAsAttempt = require('./rpc_attempt_htlc_as_attempt');
|
|
@@ -53,6 +54,7 @@ module.exports = {
|
|
|
53
54
|
paymentFailure,
|
|
54
55
|
paymentRequestDetails,
|
|
55
56
|
pendingAsPendingChannels,
|
|
57
|
+
pendingFromPayment,
|
|
56
58
|
policyFromChannelUpdate,
|
|
57
59
|
routesFromQueryRoutes,
|
|
58
60
|
rpcAttemptHtlcAsAttempt,
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
const {attemptStates} = require('./constants');
|
|
2
|
+
const rpcAttemptHtlcAsAttempt = require('./rpc_attempt_htlc_as_attempt');
|
|
3
|
+
const {safeTokens} = require('./../bolt00');
|
|
4
|
+
|
|
5
|
+
const {isArray} = Array;
|
|
6
|
+
const is256Hex = n => !!n && /^[0-9A-F]{64}$/i.test(n);
|
|
7
|
+
const {max} = Math;
|
|
8
|
+
const mtokensAsTokens = mtokens => safeTokens({mtokens}).tokens;
|
|
9
|
+
const nsAsDate = ns => new Date(Number(BigInt(ns) / BigInt(1e6)));
|
|
10
|
+
|
|
11
|
+
/** Calculate total payment details from RPC payment HTLC elements
|
|
12
|
+
|
|
13
|
+
The `route` attribute only returns the first route, there may be more due to
|
|
14
|
+
payment splitting
|
|
15
|
+
|
|
16
|
+
{
|
|
17
|
+
creation_date: <Creation Date Epoch Time Seconds String>
|
|
18
|
+
creation_time_ns: <Creation Date Epoch Time Nanoseconds String>
|
|
19
|
+
failure_reason: <Payment Failure Reason String>
|
|
20
|
+
fee_msat: <Fee Paid in Millitokens String>
|
|
21
|
+
fee_sat: <Fee Paid in Tokens String>
|
|
22
|
+
htlcs: [{
|
|
23
|
+
attempt_time_ns: <HTLC Sent At Epoch Time Nanoseconds String>
|
|
24
|
+
resolve_time_ns: <HTLC Resolved At Epoch Time Nanoseconds String>
|
|
25
|
+
route: {
|
|
26
|
+
hops: [{
|
|
27
|
+
amt_to_forward: <Tokens to Forward String>
|
|
28
|
+
amt_to_forward_msat: <Millitokens to Forward String>
|
|
29
|
+
chan_id: <Numeric Format Channel Id String>
|
|
30
|
+
chan_capacity: <Channel Capacity Tokens String>
|
|
31
|
+
custom_records: {
|
|
32
|
+
<UInt64 String>: <Record Data Buffer>
|
|
33
|
+
}
|
|
34
|
+
expiry: <Timeout Chain Height Number>
|
|
35
|
+
fee: <Fee in Tokens String>
|
|
36
|
+
fee_msat: <Fee in Millitokens String>
|
|
37
|
+
[mpp_record]: {
|
|
38
|
+
payment_addr: <Payment Identifier Buffer>
|
|
39
|
+
total_amt_msat: <Total Payment Millitokens Amount String>
|
|
40
|
+
}
|
|
41
|
+
[pub_key]: <Next Hop Public Key Hex String>
|
|
42
|
+
tlv_payload: <Has Extra TLV Data Bool>
|
|
43
|
+
}]
|
|
44
|
+
total_amt: <Total Tokens String>
|
|
45
|
+
total_amt_msat: <Route Total Millitokens String>
|
|
46
|
+
total_fees: <Route Fee Tokens String>
|
|
47
|
+
total_fees_msat: <Route Total Fees Millitokens String>
|
|
48
|
+
total_time_lock: <Route Total Timelock Number>
|
|
49
|
+
}
|
|
50
|
+
status: <HTLC Status String>
|
|
51
|
+
}]
|
|
52
|
+
path: [<Hop Public Key Hex String>]
|
|
53
|
+
payment_hash: <Preimage SHA256 Hash Hex String>
|
|
54
|
+
payment_index: <Payment Index String>
|
|
55
|
+
payment_preimage: <Payment Secret Preimage Hex String>
|
|
56
|
+
payment_request: <BOLT 11 Payment Request String>
|
|
57
|
+
status: <Payment State String>
|
|
58
|
+
value: <Tokens String>
|
|
59
|
+
value_msat: <Paid Tokens Without Routing Fees Millitokens String>
|
|
60
|
+
value_sat: <Paid Tokens Without Routing Fees String>
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@throws
|
|
64
|
+
<Error>
|
|
65
|
+
|
|
66
|
+
@returns
|
|
67
|
+
{
|
|
68
|
+
created_at: <Payment Created At ISO 8601 Date String>
|
|
69
|
+
destination: <Payment Destination Public Key Hex String>
|
|
70
|
+
id: <Payment Hash Hex String>
|
|
71
|
+
mtokens: <Total Millitokens Pending String>
|
|
72
|
+
paths: [{
|
|
73
|
+
fee: <Total Fee Tokens Pending Number>
|
|
74
|
+
fee_mtokens: <Total Fee Millitokens Pending String>
|
|
75
|
+
hops: [{
|
|
76
|
+
channel: <Standard Format Channel Id String>
|
|
77
|
+
channel_capacity: <Channel Capacity Tokens Number>
|
|
78
|
+
fee: <Fee Tokens Rounded Down Number>
|
|
79
|
+
fee_mtokens: <Fee Millitokens String>
|
|
80
|
+
forward: <Forward Tokens Number>
|
|
81
|
+
forward_mtokens: <Forward Millitokens String>
|
|
82
|
+
public_key: <Public Key Hex String>
|
|
83
|
+
timeout: <Timeout Block Height Number>
|
|
84
|
+
}]
|
|
85
|
+
mtokens: <Total Millitokens Paid String>
|
|
86
|
+
safe_fee: <Total Fee Tokens Paid Rounded Up Number>
|
|
87
|
+
safe_tokens: <Total Tokens Paid, Rounded Up Number>
|
|
88
|
+
timeout: <Expiration Block Height Number>
|
|
89
|
+
}]
|
|
90
|
+
[request]: <BOLT 11 Encoded Payment Request String>
|
|
91
|
+
safe_tokens: <Total Tokens Pending, Rounded Up Number>
|
|
92
|
+
[timeout]: <Expiration Block Height Number>
|
|
93
|
+
tokens: <Total Tokens Pending Rounded Down Number>
|
|
94
|
+
}
|
|
95
|
+
*/
|
|
96
|
+
module.exports = payment => {
|
|
97
|
+
if (!payment) {
|
|
98
|
+
throw new Error('ExpectedPendingPaymentToDerivePendingDetails');
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (!payment.creation_time_ns) {
|
|
102
|
+
throw new Error('ExpectedPaymentCreationDateToDerivePendingDetails');
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (!payment.fee_msat) {
|
|
106
|
+
throw new Error('ExpectedPaymentFeeMillitokensAmountForPendingPayment');
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (!isArray(payment.htlcs)) {
|
|
110
|
+
throw new Error('ExpectedArrayOfPaymentHtlcsInPendingPayment');
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (!payment.htlcs.find(n => n.status === attemptStates.pending)) {
|
|
114
|
+
throw new Error('ExpectedPendingHtlcInPendingPayment');
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (!is256Hex(payment.payment_hash)) {
|
|
118
|
+
throw new Error('ExpectedPaymentHashForPaymentAsPendingPayment');
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (mtokensAsTokens(payment.value_msat) !== Number(payment.value_sat)) {
|
|
122
|
+
throw new Error('ExpectedValueOfTokensAndMillitokensToBeConsistent');
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const attempts = payment.htlcs.map(htlc => rpcAttemptHtlcAsAttempt(htlc));
|
|
126
|
+
const mtokens = BigInt(payment.value_msat) + BigInt(payment.fee_msat);
|
|
127
|
+
|
|
128
|
+
const pending = attempts.filter(n => n.is_pending);
|
|
129
|
+
|
|
130
|
+
const [first] = pending;
|
|
131
|
+
|
|
132
|
+
const [destination] = first.route.hops.map(n => n.public_key).reverse();
|
|
133
|
+
|
|
134
|
+
return {
|
|
135
|
+
destination,
|
|
136
|
+
created_at: nsAsDate(payment.creation_time_ns).toISOString(),
|
|
137
|
+
id: payment.payment_hash,
|
|
138
|
+
mtokens: mtokens.toString(),
|
|
139
|
+
paths: pending.map(n => n.route),
|
|
140
|
+
request: payment.payment_request || undefined,
|
|
141
|
+
safe_tokens: safeTokens({mtokens: mtokens.toString()}).safe,
|
|
142
|
+
timeout: max(...pending.map(n => n.route.timeout).filter(n => !!n)),
|
|
143
|
+
tokens: safeTokens({mtokens: mtokens.toString()}).tokens,
|
|
144
|
+
};
|
|
145
|
+
};
|
|
@@ -23,6 +23,6 @@ module.exports = ({channel, version}) => {
|
|
|
23
23
|
|
|
24
24
|
const type = adjustedChannelTypes[channel.commitment_type];
|
|
25
25
|
|
|
26
|
-
// Versions of LND 0.13.
|
|
26
|
+
// Versions of LND 0.13.4 and before use a different channel type value
|
|
27
27
|
return assign(channel, {commitment_type: type || defaultChannelType});
|
|
28
28
|
};
|
|
@@ -7,6 +7,7 @@ const streamAuth = 'stream_auth';
|
|
|
7
7
|
/** Derive request details from an RPC request update
|
|
8
8
|
|
|
9
9
|
{
|
|
10
|
+
msg_id: <Message Id Number String>
|
|
10
11
|
request_id: <Request Id Number String>
|
|
11
12
|
raw_macaroon: <Raw Macaroon Buffer Object>
|
|
12
13
|
custom_caveat_condition: <Custom Caveat Condition String>
|
|
@@ -33,6 +34,7 @@ const streamAuth = 'stream_auth';
|
|
|
33
34
|
|
|
34
35
|
@returns
|
|
35
36
|
{
|
|
37
|
+
call: <Call Id Number>
|
|
36
38
|
[event]: <Event Type String>
|
|
37
39
|
id: <Request Id Number>
|
|
38
40
|
[macaroon]: <Base64 Encoded Macaroon String>
|
|
@@ -52,6 +54,10 @@ module.exports = args => {
|
|
|
52
54
|
throw new Error('ExpectedInterceptTypeInRpcRequestUpdate');
|
|
53
55
|
}
|
|
54
56
|
|
|
57
|
+
if (args.msg_id === undefined) {
|
|
58
|
+
throw new Error('ExpectedMessageIdInRpcRequestUpdate');
|
|
59
|
+
}
|
|
60
|
+
|
|
55
61
|
if (!isBuffer(args.raw_macaroon)) {
|
|
56
62
|
throw new Error('ExpectedCompleteMacaroonCredentialsInRequestUpdate');
|
|
57
63
|
}
|
|
@@ -60,7 +66,8 @@ module.exports = args => {
|
|
|
60
66
|
throw new Error('ExpectedRequestIdInRpcRequestUpdate');
|
|
61
67
|
}
|
|
62
68
|
|
|
63
|
-
const
|
|
69
|
+
const call = Number(args.request_id);
|
|
70
|
+
const id = Number(args.msg_id);
|
|
64
71
|
|
|
65
72
|
switch (args.intercept_type) {
|
|
66
73
|
// New subscription
|
|
@@ -74,6 +81,7 @@ module.exports = args => {
|
|
|
74
81
|
}
|
|
75
82
|
|
|
76
83
|
return {
|
|
84
|
+
call,
|
|
77
85
|
id,
|
|
78
86
|
event: request,
|
|
79
87
|
macaroon: bufferAsBase64(args.raw_macaroon),
|
|
@@ -91,6 +99,7 @@ module.exports = args => {
|
|
|
91
99
|
}
|
|
92
100
|
|
|
93
101
|
return {
|
|
102
|
+
call,
|
|
94
103
|
id,
|
|
95
104
|
event: request,
|
|
96
105
|
macaroon: bufferAsBase64(args.raw_macaroon),
|
|
@@ -108,6 +117,7 @@ module.exports = args => {
|
|
|
108
117
|
}
|
|
109
118
|
|
|
110
119
|
return {
|
|
120
|
+
call,
|
|
111
121
|
id,
|
|
112
122
|
event: response,
|
|
113
123
|
macaroon: bufferAsBase64(args.raw_macaroon),
|
|
@@ -116,6 +126,6 @@ module.exports = args => {
|
|
|
116
126
|
|
|
117
127
|
// Unknown update
|
|
118
128
|
default:
|
|
119
|
-
return {id, macaroon: bufferAsBase64(args.raw_macaroon)};
|
|
129
|
+
return {call, id, macaroon: bufferAsBase64(args.raw_macaroon)};
|
|
120
130
|
}
|
|
121
131
|
};
|
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.4.
|
|
10
|
+
"@grpc/grpc-js": "1.4.4",
|
|
11
11
|
"@grpc/proto-loader": "0.6.6",
|
|
12
12
|
"@types/express": "4.17.13",
|
|
13
|
-
"@types/node": "16.11.
|
|
13
|
+
"@types/node": "16.11.7",
|
|
14
14
|
"@types/request": "2.48.7",
|
|
15
15
|
"@types/ws": "8.2.0",
|
|
16
16
|
"async": "3.2.2",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"body-parser": "1.19.0",
|
|
21
21
|
"bolt07": "1.7.4",
|
|
22
22
|
"bolt09": "0.2.0",
|
|
23
|
-
"cbor": "8.0
|
|
23
|
+
"cbor": "8.1.0",
|
|
24
24
|
"express": "4.17.1",
|
|
25
25
|
"invoices": "2.0.1",
|
|
26
26
|
"psbt": "1.1.10"
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"directory": "test/typescript"
|
|
57
57
|
},
|
|
58
58
|
"types": "index.d.ts",
|
|
59
|
-
"version": "4.
|
|
59
|
+
"version": "4.14.0"
|
|
60
60
|
}
|
|
@@ -24,6 +24,7 @@ const tests = [
|
|
|
24
24
|
},
|
|
25
25
|
subscription: {},
|
|
26
26
|
update: {
|
|
27
|
+
msg_id: '1',
|
|
27
28
|
request_id: '1',
|
|
28
29
|
raw_macaroon: Buffer.alloc(0),
|
|
29
30
|
custom_caveat_condition: '',
|
|
@@ -79,6 +80,7 @@ const tests = [
|
|
|
79
80
|
},
|
|
80
81
|
subscription: {},
|
|
81
82
|
update: {
|
|
83
|
+
msg_id: '1',
|
|
82
84
|
request_id: '1',
|
|
83
85
|
raw_macaroon: Buffer.alloc(0),
|
|
84
86
|
custom_caveat_condition: '',
|
|
@@ -141,6 +143,7 @@ const tests = [
|
|
|
141
143
|
},
|
|
142
144
|
subscription: {},
|
|
143
145
|
update: {
|
|
146
|
+
msg_id: '1',
|
|
144
147
|
request_id: '1',
|
|
145
148
|
raw_macaroon: Buffer.alloc(0),
|
|
146
149
|
custom_caveat_condition: '',
|
|
@@ -189,6 +192,7 @@ const tests = [
|
|
|
189
192
|
args: {
|
|
190
193
|
subscription: {},
|
|
191
194
|
update: {
|
|
195
|
+
msg_id: '1',
|
|
192
196
|
request_id: '1',
|
|
193
197
|
raw_macaroon: Buffer.alloc(0),
|
|
194
198
|
custom_caveat_condition: '',
|
|
@@ -18,6 +18,7 @@ const makeArgs = overrides => {
|
|
|
18
18
|
|
|
19
19
|
process.nextTick(() => {
|
|
20
20
|
emitter.emit('data', {
|
|
21
|
+
msg_id: '1',
|
|
21
22
|
request_id: '1',
|
|
22
23
|
raw_macaroon: Buffer.alloc(0),
|
|
23
24
|
custom_caveat_condition: '',
|
|
@@ -86,6 +87,7 @@ const tests = [
|
|
|
86
87
|
|
|
87
88
|
process.nextTick(() => {
|
|
88
89
|
emitter.emit('data', {
|
|
90
|
+
msg_id: '1',
|
|
89
91
|
request_id: '1',
|
|
90
92
|
raw_macaroon: Buffer.alloc(0),
|
|
91
93
|
custom_caveat_condition: '',
|
|
@@ -102,7 +104,7 @@ const tests = [
|
|
|
102
104
|
description: 'RPC write errors are passed back',
|
|
103
105
|
expected: {
|
|
104
106
|
events: [
|
|
105
|
-
{id: 1, macaroon: undefined, uri: 'method_full_uri'},
|
|
107
|
+
{call: 1, id: 1, macaroon: undefined, uri: 'method_full_uri'},
|
|
106
108
|
[503, 'UnexpectedErrorAcceptingRpcRequest', {err: 'err'}],
|
|
107
109
|
],
|
|
108
110
|
},
|
|
@@ -112,7 +114,7 @@ const tests = [
|
|
|
112
114
|
description: 'RPC request subscription is returned',
|
|
113
115
|
expected: {
|
|
114
116
|
events: [
|
|
115
|
-
{id: 1, macaroon: undefined, uri: 'method_full_uri'},
|
|
117
|
+
{call: 1, id: 1, macaroon: undefined, uri: 'method_full_uri'},
|
|
116
118
|
[503, 'ExpectedCustomCaveatConditionInRpcRequestUpdate'],
|
|
117
119
|
{details: 'Cancelled on client'},
|
|
118
120
|
],
|
|
@@ -161,6 +163,7 @@ const tests = [
|
|
|
161
163
|
|
|
162
164
|
process.nextTick(() => {
|
|
163
165
|
emitter.emit('data', {
|
|
166
|
+
msg_id: '1',
|
|
164
167
|
request_id: '1',
|
|
165
168
|
raw_macaroon: Buffer.alloc(0),
|
|
166
169
|
custom_caveat_condition: '',
|
|
@@ -8,7 +8,48 @@ const makeLnd = args => {
|
|
|
8
8
|
return {
|
|
9
9
|
router: {
|
|
10
10
|
trackPaymentV2: ({}) => {
|
|
11
|
-
const data = args.data || {
|
|
11
|
+
const data = args.data || {
|
|
12
|
+
creation_date: '1',
|
|
13
|
+
creation_time_ns: '1',
|
|
14
|
+
failure_reason: 'FAILURE_REASON_NONE',
|
|
15
|
+
fee: '1',
|
|
16
|
+
fee_msat: '1000',
|
|
17
|
+
fee_sat: '1',
|
|
18
|
+
htlcs: [{
|
|
19
|
+
attempt_time_ns: '1',
|
|
20
|
+
status: 'IN_FLIGHT',
|
|
21
|
+
resolve_time_ns: '1',
|
|
22
|
+
route: {
|
|
23
|
+
hops: [{
|
|
24
|
+
amt_to_forward: '1',
|
|
25
|
+
amt_to_forward_msat: '1000',
|
|
26
|
+
chan_capacity: '1',
|
|
27
|
+
chan_id: '1',
|
|
28
|
+
custom_records: {'1': Buffer.alloc(1)},
|
|
29
|
+
expiry: 1,
|
|
30
|
+
fee: '1',
|
|
31
|
+
fee_msat: '1000',
|
|
32
|
+
mpp_record: {payment_addr: Buffer.alloc(32), total_amt_msat: '1000'},
|
|
33
|
+
pub_key: Buffer.alloc(33).toString('hex'),
|
|
34
|
+
tlv_payload: true,
|
|
35
|
+
}],
|
|
36
|
+
total_amt: '1',
|
|
37
|
+
total_amt_msat: '1000',
|
|
38
|
+
total_time_lock: 1,
|
|
39
|
+
total_fees: '1',
|
|
40
|
+
total_fees_msat: '1000',
|
|
41
|
+
},
|
|
42
|
+
}],
|
|
43
|
+
path: [Buffer.alloc(33).toString('hex')],
|
|
44
|
+
payment_hash: Buffer.alloc(32).toString('hex'),
|
|
45
|
+
payment_index: '1',
|
|
46
|
+
payment_preimage: Buffer.alloc(32).toString('hex'),
|
|
47
|
+
payment_request: '',
|
|
48
|
+
status: 'IN_FLIGHT',
|
|
49
|
+
value: '1',
|
|
50
|
+
value_msat: '1000',
|
|
51
|
+
value_sat: '1',
|
|
52
|
+
};
|
|
12
53
|
const emitter = new EventEmitter();
|
|
13
54
|
|
|
14
55
|
if (!!args.is_end) {
|
|
@@ -146,6 +187,35 @@ const tests = [
|
|
|
146
187
|
is_failed: false,
|
|
147
188
|
is_pending: true,
|
|
148
189
|
payment: undefined,
|
|
190
|
+
pending: {
|
|
191
|
+
created_at: '1970-01-01T00:00:00.000Z',
|
|
192
|
+
destination: Buffer.alloc(33).toString('hex'),
|
|
193
|
+
id: Buffer.alloc(32).toString('hex'),
|
|
194
|
+
mtokens: '2000',
|
|
195
|
+
paths: [{
|
|
196
|
+
fee: 1,
|
|
197
|
+
fee_mtokens: '1000',
|
|
198
|
+
hops: [{
|
|
199
|
+
channel: '0x0x1',
|
|
200
|
+
channel_capacity: 1,
|
|
201
|
+
fee: 1,
|
|
202
|
+
fee_mtokens: '1000',
|
|
203
|
+
forward: 1,
|
|
204
|
+
forward_mtokens: '1000',
|
|
205
|
+
public_key: Buffer.alloc(33).toString('hex'),
|
|
206
|
+
timeout: 1,
|
|
207
|
+
}],
|
|
208
|
+
mtokens: '1000',
|
|
209
|
+
payment: '0000000000000000000000000000000000000000000000000000000000000000',
|
|
210
|
+
timeout: 1,
|
|
211
|
+
tokens: 1,
|
|
212
|
+
total_mtokens: '1000',
|
|
213
|
+
}],
|
|
214
|
+
request: undefined,
|
|
215
|
+
safe_tokens: 2,
|
|
216
|
+
timeout: 1,
|
|
217
|
+
tokens: 2,
|
|
218
|
+
},
|
|
149
219
|
},
|
|
150
220
|
},
|
|
151
221
|
},
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
const {test} = require('@alexbosworth/tap');
|
|
2
|
+
|
|
3
|
+
const {pendingFromPayment} = require('./../../lnd_responses');
|
|
4
|
+
|
|
5
|
+
const makeArgs = overrides => {
|
|
6
|
+
const args = {
|
|
7
|
+
creation_date: '1',
|
|
8
|
+
creation_time_ns: '1',
|
|
9
|
+
failure_reason: 'FAILURE_REASON_NONE',
|
|
10
|
+
fee: '1',
|
|
11
|
+
fee_msat: '1000',
|
|
12
|
+
fee_sat: '1',
|
|
13
|
+
htlcs: [{
|
|
14
|
+
attempt_time_ns: '1',
|
|
15
|
+
status: 'IN_FLIGHT',
|
|
16
|
+
resolve_time_ns: '1',
|
|
17
|
+
route: {
|
|
18
|
+
hops: [{
|
|
19
|
+
amt_to_forward: '1',
|
|
20
|
+
amt_to_forward_msat: '1000',
|
|
21
|
+
chan_capacity: '1',
|
|
22
|
+
chan_id: '1',
|
|
23
|
+
custom_records: {'1': Buffer.alloc(1)},
|
|
24
|
+
expiry: 1,
|
|
25
|
+
fee: '1',
|
|
26
|
+
fee_msat: '1000',
|
|
27
|
+
mpp_record: {payment_addr: Buffer.alloc(32), total_amt_msat: '1000'},
|
|
28
|
+
pub_key: Buffer.alloc(33).toString('hex'),
|
|
29
|
+
tlv_payload: true,
|
|
30
|
+
}],
|
|
31
|
+
total_amt: '1',
|
|
32
|
+
total_amt_msat: '1000',
|
|
33
|
+
total_time_lock: 1,
|
|
34
|
+
total_fees: '1',
|
|
35
|
+
total_fees_msat: '1000',
|
|
36
|
+
},
|
|
37
|
+
}],
|
|
38
|
+
path: [Buffer.alloc(33).toString('hex')],
|
|
39
|
+
payment_hash: Buffer.alloc(32).toString('hex'),
|
|
40
|
+
payment_index: '1',
|
|
41
|
+
payment_preimage: Buffer.alloc(32).toString('hex'),
|
|
42
|
+
payment_request: '',
|
|
43
|
+
status: 'IN_FLIGHT',
|
|
44
|
+
value: '1',
|
|
45
|
+
value_msat: '1000',
|
|
46
|
+
value_sat: '1',
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
Object.keys(overrides).forEach(k => args[k] = overrides[k]);
|
|
50
|
+
|
|
51
|
+
return args;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const makeExpected = overrides => {
|
|
55
|
+
const expected = {
|
|
56
|
+
created_at: '1970-01-01T00:00:00.000Z',
|
|
57
|
+
destination: Buffer.alloc(33).toString('hex'),
|
|
58
|
+
id: Buffer.alloc(32).toString('hex'),
|
|
59
|
+
mtokens: '2000',
|
|
60
|
+
paths: [{
|
|
61
|
+
fee: 1,
|
|
62
|
+
fee_mtokens: '1000',
|
|
63
|
+
hops: [{
|
|
64
|
+
channel: '0x0x1',
|
|
65
|
+
channel_capacity: 1,
|
|
66
|
+
fee: 1,
|
|
67
|
+
fee_mtokens: '1000',
|
|
68
|
+
forward: 1,
|
|
69
|
+
forward_mtokens: '1000',
|
|
70
|
+
public_key: Buffer.alloc(33).toString('hex'),
|
|
71
|
+
timeout: 1,
|
|
72
|
+
}],
|
|
73
|
+
mtokens: '1000',
|
|
74
|
+
payment: '0000000000000000000000000000000000000000000000000000000000000000',
|
|
75
|
+
timeout: 1,
|
|
76
|
+
tokens: 1,
|
|
77
|
+
total_mtokens: '1000',
|
|
78
|
+
}],
|
|
79
|
+
request: undefined,
|
|
80
|
+
safe_tokens: 2,
|
|
81
|
+
timeout: 1,
|
|
82
|
+
tokens: 2,
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
Object.keys(overrides).forEach(k => expected[k] = overrides[k]);
|
|
86
|
+
|
|
87
|
+
return expected;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const tests = [
|
|
91
|
+
{
|
|
92
|
+
args: undefined,
|
|
93
|
+
description: 'A payment is expected',
|
|
94
|
+
error: 'ExpectedPendingPaymentToDerivePendingDetails',
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
args: makeArgs({creation_time_ns: undefined}),
|
|
98
|
+
description: 'Creation time is expected',
|
|
99
|
+
error: 'ExpectedPaymentCreationDateToDerivePendingDetails',
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
args: makeArgs({fee_msat: undefined}),
|
|
103
|
+
description: 'Fee millitokens are expected',
|
|
104
|
+
error: 'ExpectedPaymentFeeMillitokensAmountForPendingPayment',
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
args: makeArgs({htlcs: undefined}),
|
|
108
|
+
description: 'HTLCs are expected',
|
|
109
|
+
error: 'ExpectedArrayOfPaymentHtlcsInPendingPayment',
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
args: makeArgs({htlcs: [{}]}),
|
|
113
|
+
description: 'A successful HTLC is expected',
|
|
114
|
+
error: 'ExpectedPendingHtlcInPendingPayment',
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
args: makeArgs({payment_hash: undefined}),
|
|
118
|
+
description: 'A payment hash is expected',
|
|
119
|
+
error: 'ExpectedPaymentHashForPaymentAsPendingPayment',
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
args: makeArgs({value_sat: '1', value_msat: '0'}),
|
|
123
|
+
description: 'Values are expected to agree',
|
|
124
|
+
error: 'ExpectedValueOfTokensAndMillitokensToBeConsistent',
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
args: makeArgs({}),
|
|
128
|
+
description: 'Payment is mapped to confirmed payment details',
|
|
129
|
+
expected: makeExpected({}),
|
|
130
|
+
},
|
|
131
|
+
];
|
|
132
|
+
|
|
133
|
+
tests.forEach(({args, description, error, expected}) => {
|
|
134
|
+
return test(description, ({end, strictSame, throws}) => {
|
|
135
|
+
if (!!error) {
|
|
136
|
+
throws(() => pendingFromPayment(args), new Error(error), 'Err');
|
|
137
|
+
} else {
|
|
138
|
+
strictSame(pendingFromPayment(args), expected, 'Mapped');
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return end();
|
|
142
|
+
});
|
|
143
|
+
});
|
|
@@ -4,6 +4,7 @@ const method = require('./../../lnd_responses/rpc_request_update_as_event');
|
|
|
4
4
|
|
|
5
5
|
const makeArgs = overrides => {
|
|
6
6
|
const args = {
|
|
7
|
+
msg_id: '1',
|
|
7
8
|
request_id: '1',
|
|
8
9
|
raw_macaroon: Buffer.alloc(0),
|
|
9
10
|
custom_caveat_condition: '',
|
|
@@ -16,7 +17,7 @@ const makeArgs = overrides => {
|
|
|
16
17
|
};
|
|
17
18
|
|
|
18
19
|
const makeExpected = overrides => {
|
|
19
|
-
const expected = {id: 1, macaroon: undefined};
|
|
20
|
+
const expected = {call: 1, id: 1, macaroon: undefined};
|
|
20
21
|
|
|
21
22
|
Object.keys(overrides).forEach(k => expected[k] = overrides[k]);
|
|
22
23
|
|
|
@@ -39,6 +40,11 @@ const tests = [
|
|
|
39
40
|
description: 'An intercept type is expected',
|
|
40
41
|
error: 'ExpectedInterceptTypeInRpcRequestUpdate',
|
|
41
42
|
},
|
|
43
|
+
{
|
|
44
|
+
args: makeArgs({msg_id: undefined}),
|
|
45
|
+
description: 'A message id is expected',
|
|
46
|
+
error: 'ExpectedMessageIdInRpcRequestUpdate',
|
|
47
|
+
},
|
|
42
48
|
{
|
|
43
49
|
args: makeArgs({raw_macaroon: undefined}),
|
|
44
50
|
description: 'A raw macaroon is expected',
|