lightning 4.12.1 → 4.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -1
- package/README.md +4 -0
- package/grpc/protos/invoices.proto +35 -0
- package/grpc/protos/lightning.proto +47 -7
- package/grpc/protos/signer.proto +4 -4
- package/index.js +4 -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/index.d.ts +2 -0
- package/lnd_methods/offchain/send_message_to_peer.d.ts +28 -0
- package/lnd_methods/offchain/subscribe_to_forwards.js +1 -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 +18 -0
- 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/rpc_channel_as_old_rpc_channel.js +1 -1
- package/lnd_responses/rpc_request_update_as_event.js +12 -2
- package/package.json +5 -5
- 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_responses/test_rpc_request_update_as_event.js +7 -1
- package/test/protos/protos.json +1 -1
- package/test/typescript/send_message_to_peer.test-d.ts +24 -0
- package/test/typescript/subscribe_to_peer_messages.test-d.ts +11 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
# Versions
|
|
2
2
|
|
|
3
|
-
## 4.
|
|
3
|
+
## 4.13.2
|
|
4
|
+
|
|
5
|
+
- Add `sendMessageToPeer` to send a peer to peer message to a connected peer
|
|
6
|
+
- Add `subscribeToPeerMessages` to listen to messages from connected peers
|
|
7
|
+
|
|
8
|
+
## 4.12.2
|
|
4
9
|
|
|
5
10
|
- `probeForRoute`, `subscribeToProbeForRoute`, `subscribeToPayViaRoutes`,
|
|
6
11
|
`payViaRoutes`: When probing (no hash), delete the payment failure record after the probe
|
package/README.md
CHANGED
|
@@ -225,6 +225,8 @@ Methods exported by this library support typescript, but ln-service includes add
|
|
|
225
225
|
Ask for a CPFP chain fee rate increase on a pending confirm UTXO.
|
|
226
226
|
- [revokeAccess](https://github.com/alexbosworth/ln-service#revokeaccess): Remove the access
|
|
227
227
|
privileges of a previously issued access token macaroon credential.
|
|
228
|
+
- [sendMessageToPeer](https://github.com/alexbosworth/ln-service#sendmessagetopeer): Send
|
|
229
|
+
message to a connected peer.
|
|
228
230
|
- [sendToChainAddress](https://github.com/alexbosworth/ln-service#sendtochainaddress): Send
|
|
229
231
|
funds on-chain to an address.
|
|
230
232
|
- [sendToChainAddresses](https://github.com/alexbosworth/ln-service#sendtochainaddresses):
|
|
@@ -277,6 +279,8 @@ Methods exported by this library support typescript, but ln-service includes add
|
|
|
277
279
|
Make an off-chain payment using a payment request and subscribe to the payment status.
|
|
278
280
|
- [subscribeToPayViaRoutes](https://github.com/alexbosworth/ln-service#subscribetopayviaroutes):
|
|
279
281
|
Start an off-chain payment using specific payment routes and subscribe to the payment result.
|
|
282
|
+
- [subscribeToPeerMessages](https://github.com/alexbosworth/ln-service#subscribetopeermessages):
|
|
283
|
+
Listen for incoming peer messages.
|
|
280
284
|
- [subscribeToPeers](https://github.com/alexbosworth/ln-service#subscribetopeers): Listen to peer
|
|
281
285
|
disconnect and connect events.
|
|
282
286
|
- [subscribeToProbeForRoute](https://github.com/alexbosworth/ln-service#subscribetoprobeforroute):
|
|
@@ -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
|
}
|
package/index.js
CHANGED
|
@@ -87,6 +87,7 @@ const {recoverFundsFromChannels} = require('./lnd_methods');
|
|
|
87
87
|
const {removePeer} = require('./lnd_methods');
|
|
88
88
|
const {requestChainFeeIncrease} = require('./lnd_methods');
|
|
89
89
|
const {revokeAccess} = require('./lnd_methods');
|
|
90
|
+
const {sendMessageToPeer} = require('./lnd_methods');
|
|
90
91
|
const {sendToChainAddress} = require('./lnd_methods');
|
|
91
92
|
const {sendToChainAddresses} = require('./lnd_methods');
|
|
92
93
|
const {sendToChainOutputScripts} = require('./lnd_methods');
|
|
@@ -113,6 +114,7 @@ const {subscribeToPastPayments} = require('./lnd_methods');
|
|
|
113
114
|
const {subscribeToPayViaDetails} = require('./lnd_methods');
|
|
114
115
|
const {subscribeToPayViaRequest} = require('./lnd_methods');
|
|
115
116
|
const {subscribeToPayViaRoutes} = require('./lnd_methods');
|
|
117
|
+
const {subscribeToPeerMessages} = require('./lnd_methods');
|
|
116
118
|
const {subscribeToPeers} = require('./lnd_methods');
|
|
117
119
|
const {subscribeToProbeForRoute} = require('./lnd_methods');
|
|
118
120
|
const {subscribeToRpcRequests} = require('./lnd_methods');
|
|
@@ -221,6 +223,7 @@ module.exports = {
|
|
|
221
223
|
removePeer,
|
|
222
224
|
requestChainFeeIncrease,
|
|
223
225
|
revokeAccess,
|
|
226
|
+
sendMessageToPeer,
|
|
224
227
|
sendToChainAddress,
|
|
225
228
|
sendToChainAddresses,
|
|
226
229
|
sendToChainOutputScripts,
|
|
@@ -247,6 +250,7 @@ module.exports = {
|
|
|
247
250
|
subscribeToPayViaDetails,
|
|
248
251
|
subscribeToPayViaRequest,
|
|
249
252
|
subscribeToPayViaRoutes,
|
|
253
|
+
subscribeToPeerMessages,
|
|
250
254
|
subscribeToPeers,
|
|
251
255
|
subscribeToProbeForRoute,
|
|
252
256
|
subscribeToRpcRequests,
|
|
@@ -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>;
|
|
@@ -32,6 +32,7 @@ export * from './pay';
|
|
|
32
32
|
export * from './probe_for_route';
|
|
33
33
|
export * from './recover_funds_from_channel';
|
|
34
34
|
export * from './recover_funds_from_channels';
|
|
35
|
+
export * from './send_message_to_peer';
|
|
35
36
|
export * from './subscribe_to_backups';
|
|
36
37
|
export * from './subscribe_to_channels';
|
|
37
38
|
export * from './subscribe_to_forward_requests';
|
|
@@ -42,6 +43,7 @@ export * from './subscribe_to_past_payments';
|
|
|
42
43
|
export * from './subscribe_to_pay_via_details';
|
|
43
44
|
export * from './subscribe_to_pay_via_request';
|
|
44
45
|
export * from './subscribe_to_pay_via_routes';
|
|
46
|
+
export * from './subscribe_to_peer_messages';
|
|
45
47
|
export * from './subscribe_to_probe_for_route';
|
|
46
48
|
export * from './update_connected_watchtower';
|
|
47
49
|
export * from './update_pathfinding_settings';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AuthenticatedLightningArgs,
|
|
3
|
+
AuthenticatedLightningMethod,
|
|
4
|
+
} from '../../typescript';
|
|
5
|
+
|
|
6
|
+
export type LightningMessage = {
|
|
7
|
+
/** Message Hex String */
|
|
8
|
+
message: string;
|
|
9
|
+
/** To Peer Public Key Hex String */
|
|
10
|
+
public_key: string;
|
|
11
|
+
/** Message Type Number */
|
|
12
|
+
type?: number;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type SendMessageToPeerArgs =
|
|
16
|
+
AuthenticatedLightningArgs<LightningMessage>;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Send a custom message to a connected peer
|
|
20
|
+
*
|
|
21
|
+
* If specified, message type is expected to be between 32768 and 65535
|
|
22
|
+
* Message data should not be larger than 65533 bytes
|
|
23
|
+
*
|
|
24
|
+
* Note: this method is not supported in LND versions 0.13.3 and below
|
|
25
|
+
*
|
|
26
|
+
* Requires `offchain:write` permission
|
|
27
|
+
*/
|
|
28
|
+
export const sendMessageToPeer: AuthenticatedLightningMethod<SendMessageToPeerArgs>;
|
|
@@ -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>
|
|
@@ -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>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {LightningMessage} from '.';
|
|
2
|
+
import {
|
|
3
|
+
AuthenticatedLightningArgs,
|
|
4
|
+
AuthenticatedLightningSubscription,
|
|
5
|
+
LightningError,
|
|
6
|
+
} from '../../typescript';
|
|
7
|
+
|
|
8
|
+
export type SubscribeToPeerMessagesMessageReceivedEvent =
|
|
9
|
+
Required<LightningMessage>;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Subscribe to incoming peer messages
|
|
13
|
+
*
|
|
14
|
+
* Requires `offchain:read` permission
|
|
15
|
+
*
|
|
16
|
+
* This method is not supported in LND 0.13.4 and below
|
|
17
|
+
*/
|
|
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;
|
|
@@ -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,14 +7,14 @@
|
|
|
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",
|
|
17
|
-
"asyncjs-util": "1.2.
|
|
17
|
+
"asyncjs-util": "1.2.7",
|
|
18
18
|
"bitcoinjs-lib": "5.2.0",
|
|
19
19
|
"bn.js": "5.2.0",
|
|
20
20
|
"body-parser": "1.19.0",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"bolt09": "0.2.0",
|
|
23
23
|
"cbor": "8.0.2",
|
|
24
24
|
"express": "4.17.1",
|
|
25
|
-
"invoices": "2.0.
|
|
25
|
+
"invoices": "2.0.1",
|
|
26
26
|
"psbt": "1.1.10"
|
|
27
27
|
},
|
|
28
28
|
"description": "Lightning Network client library",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"directory": "test/typescript"
|
|
57
57
|
},
|
|
58
58
|
"types": "index.d.ts",
|
|
59
|
-
"version": "4.
|
|
59
|
+
"version": "4.13.2"
|
|
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: '',
|
|
@@ -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',
|
package/test/protos/protos.json
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {expectError, expectType} from 'tsd';
|
|
2
|
+
import {AuthenticatedLnd} from '../../lnd_grpc';
|
|
3
|
+
import {sendMessageToPeer} from '../../lnd_methods';
|
|
4
|
+
|
|
5
|
+
const lnd = {} as AuthenticatedLnd;
|
|
6
|
+
const message = 'msg';
|
|
7
|
+
const public_key = 'pubkey';
|
|
8
|
+
const type = 2;
|
|
9
|
+
|
|
10
|
+
expectError(sendMessageToPeer());
|
|
11
|
+
expectError(sendMessageToPeer({}));
|
|
12
|
+
expectError(sendMessageToPeer({lnd}));
|
|
13
|
+
expectError(sendMessageToPeer({lnd, message}));
|
|
14
|
+
expectError(sendMessageToPeer({lnd, public_key}));
|
|
15
|
+
|
|
16
|
+
expectType<void>(await sendMessageToPeer({lnd, message, public_key}));
|
|
17
|
+
expectType<void>(await sendMessageToPeer({lnd, message, public_key, type}));
|
|
18
|
+
|
|
19
|
+
expectType<void>(
|
|
20
|
+
sendMessageToPeer({lnd, message, public_key}, (error, result) => {})
|
|
21
|
+
);
|
|
22
|
+
expectType<void>(
|
|
23
|
+
sendMessageToPeer({lnd, message, public_key, type}, (error, result) => {})
|
|
24
|
+
);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as events from 'events';
|
|
2
|
+
import {expectError, expectType} from 'tsd';
|
|
3
|
+
import {AuthenticatedLnd} from '../../lnd_grpc';
|
|
4
|
+
import {subscribeToPeerMessages} from '../../lnd_methods';
|
|
5
|
+
|
|
6
|
+
const lnd = {} as AuthenticatedLnd;
|
|
7
|
+
|
|
8
|
+
expectError(subscribeToPeerMessages());
|
|
9
|
+
expectError(subscribeToPeerMessages({}));
|
|
10
|
+
|
|
11
|
+
expectType<events.EventEmitter>(subscribeToPeerMessages({lnd}));
|