lightning 5.18.0 → 5.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/grpc/protos/chainnotifier.proto +12 -0
- package/grpc/protos/invoices.proto +5 -2
- package/grpc/protos/lightning.proto +82 -17
- package/grpc/protos/peers.proto +1 -1
- package/grpc/protos/router.proto +8 -0
- package/grpc/protos/walletkit.proto +10 -0
- package/grpc/protos/walletunlocker.proto +7 -0
- package/lnd_methods/offchain/get_channels.d.ts +6 -0
- package/lnd_methods/offchain/get_closed_channels.d.ts +4 -0
- package/lnd_methods/offchain/get_ephemeral_channel_ids.d.ts +27 -0
- package/lnd_methods/offchain/index.d.ts +1 -0
- package/lnd_methods/offchain/subscribe_to_channels.d.ts +6 -0
- package/lnd_methods/offchain/subscribe_to_open_requests.d.ts +8 -0
- package/lnd_methods/onchain/close_channel.d.ts +6 -0
- package/lnd_methods/onchain/close_channel.js +9 -2
- package/lnd_methods/onchain/get_chain_transactions.d.ts +38 -26
- package/lnd_methods/onchain/get_chain_transactions.js +8 -1
- package/lnd_methods/onchain/get_locked_utxos.d.ts +6 -0
- package/lnd_methods/onchain/get_locked_utxos.js +11 -0
- package/lnd_methods/onchain/open_channels.d.ts +9 -0
- package/lnd_methods/onchain/subscribe_to_transactions.d.ts +7 -24
- package/lnd_methods/onchain/subscribe_to_transactions.js +7 -0
- package/lnd_methods/onchain/unlock_utxo.js +0 -4
- package/lnd_methods/signer/sign_bytes.d.ts +4 -0
- package/lnd_responses/rpc_invoice_as_invoice.js +3 -6
- package/lnd_responses/rpc_tx_as_transaction.js +49 -0
- package/package.json +4 -4
- package/test/lnd_methods/onchain/test_get_chain_transactions.js +2 -0
- package/test/lnd_methods/onchain/test_get_locked_utxos.js +21 -0
- package/test/lnd_methods/onchain/test_get_sweep_transactions.js +1 -0
- package/test/lnd_methods/onchain/test_subscribe_to_transactions.js +2 -0
- package/test/lnd_methods/onchain/test_unlock_utxo.js +0 -7
- package/test/lnd_responses/test_rpc_invoice_as_invoice.js +2 -8
- package/test/lnd_responses/test_rpc_tx_as_transaction.js +50 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Versions
|
|
2
2
|
|
|
3
|
+
## 5.21.1
|
|
4
|
+
|
|
5
|
+
- Update typescript definitions
|
|
6
|
+
|
|
7
|
+
## 5.20.0
|
|
8
|
+
|
|
9
|
+
- `getLockedUtxos`: Add support for returning script, value of locked utxos
|
|
10
|
+
|
|
11
|
+
## 5.19.0
|
|
12
|
+
|
|
13
|
+
- `closeChannel`: Add support for `max_tokens_per_vbyte` to set max fee rate
|
|
14
|
+
- `getChainTransactions`: Add `inputs` support for previous outpoints
|
|
15
|
+
- `subscribeToTransactions`: Add `inputs` support for previous outpoints
|
|
16
|
+
|
|
3
17
|
## 5.18.0
|
|
4
18
|
|
|
5
19
|
- `signBytes`: Add `type` and support for specifying `schnorr` type signing
|
|
@@ -72,6 +72,12 @@ message ConfRequest {
|
|
|
72
72
|
broadcast height of the transaction/output script.
|
|
73
73
|
*/
|
|
74
74
|
uint32 height_hint = 4;
|
|
75
|
+
|
|
76
|
+
/*
|
|
77
|
+
If true, then the block that mines the specified txid/script will be
|
|
78
|
+
included in eventual the notification event.
|
|
79
|
+
*/
|
|
80
|
+
bool include_block = 5;
|
|
75
81
|
}
|
|
76
82
|
|
|
77
83
|
message ConfDetails {
|
|
@@ -87,6 +93,12 @@ message ConfDetails {
|
|
|
87
93
|
|
|
88
94
|
// The index of the confirmed transaction within the transaction.
|
|
89
95
|
uint32 tx_index = 4;
|
|
96
|
+
|
|
97
|
+
/*
|
|
98
|
+
The raw bytes of the block that mined the transaction. Only included if
|
|
99
|
+
include_block was set in the request.
|
|
100
|
+
*/
|
|
101
|
+
bytes raw_block = 5;
|
|
90
102
|
}
|
|
91
103
|
|
|
92
104
|
message Reorg {
|
|
@@ -44,7 +44,8 @@ service Invoices {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
message CancelInvoiceMsg {
|
|
47
|
-
// Hash corresponding to the (hold) invoice to cancel.
|
|
47
|
+
// Hash corresponding to the (hold) invoice to cancel. When using
|
|
48
|
+
// REST, this field must be encoded as base64.
|
|
48
49
|
bytes payment_hash = 1;
|
|
49
50
|
}
|
|
50
51
|
message CancelInvoiceResp {
|
|
@@ -138,7 +139,8 @@ message SettleInvoiceResp {
|
|
|
138
139
|
message SubscribeSingleInvoiceRequest {
|
|
139
140
|
reserved 1;
|
|
140
141
|
|
|
141
|
-
// Hash corresponding to the (hold) invoice to subscribe to.
|
|
142
|
+
// Hash corresponding to the (hold) invoice to subscribe to. When using
|
|
143
|
+
// REST, this field must be encoded as base64url.
|
|
142
144
|
bytes r_hash = 2;
|
|
143
145
|
}
|
|
144
146
|
|
|
@@ -163,6 +165,7 @@ enum LookupModifier {
|
|
|
163
165
|
|
|
164
166
|
message LookupInvoiceMsg {
|
|
165
167
|
oneof invoice_ref {
|
|
168
|
+
// When using REST, this field must be encoded as base64.
|
|
166
169
|
bytes payment_hash = 1;
|
|
167
170
|
bytes payment_addr = 2;
|
|
168
171
|
bytes set_id = 3;
|
|
@@ -693,7 +693,11 @@ message Transaction {
|
|
|
693
693
|
|
|
694
694
|
// A label that was optionally set on transaction broadcast.
|
|
695
695
|
string label = 10;
|
|
696
|
+
|
|
697
|
+
// PreviousOutpoints/Inputs of this transaction.
|
|
698
|
+
repeated PreviousOutPoint previous_outpoints = 12;
|
|
696
699
|
}
|
|
700
|
+
|
|
697
701
|
message GetTransactionsRequest {
|
|
698
702
|
/*
|
|
699
703
|
The height from which to list transactions, inclusive. If this value is
|
|
@@ -1029,12 +1033,21 @@ message OutPoint {
|
|
|
1029
1033
|
uint32 output_index = 3;
|
|
1030
1034
|
}
|
|
1031
1035
|
|
|
1036
|
+
message PreviousOutPoint {
|
|
1037
|
+
// The outpoint in format txid:n.
|
|
1038
|
+
string outpoint = 1;
|
|
1039
|
+
|
|
1040
|
+
// Denotes if the outpoint is controlled by the internal wallet.
|
|
1041
|
+
// The flag will only detect p2wkh, np2wkh and p2tr inputs as its own.
|
|
1042
|
+
bool is_our_output = 2;
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1032
1045
|
message LightningAddress {
|
|
1033
|
-
// The identity pubkey of the Lightning node
|
|
1046
|
+
// The identity pubkey of the Lightning node.
|
|
1034
1047
|
string pubkey = 1;
|
|
1035
1048
|
|
|
1036
1049
|
// The network location of the lightning node, e.g. `69.69.69.69:1337` or
|
|
1037
|
-
// `localhost:10011
|
|
1050
|
+
// `localhost:10011`.
|
|
1038
1051
|
string host = 2;
|
|
1039
1052
|
}
|
|
1040
1053
|
|
|
@@ -1223,11 +1236,15 @@ message VerifyMessageResponse {
|
|
|
1223
1236
|
}
|
|
1224
1237
|
|
|
1225
1238
|
message ConnectPeerRequest {
|
|
1226
|
-
|
|
1239
|
+
/*
|
|
1240
|
+
Lightning address of the peer to connect to.
|
|
1241
|
+
*/
|
|
1227
1242
|
LightningAddress addr = 1;
|
|
1228
1243
|
|
|
1229
|
-
/*
|
|
1230
|
-
|
|
1244
|
+
/*
|
|
1245
|
+
If set, the daemon will attempt to persistently connect to the target
|
|
1246
|
+
peer. Otherwise, the call will be synchronous.
|
|
1247
|
+
*/
|
|
1231
1248
|
bool perm = 2;
|
|
1232
1249
|
|
|
1233
1250
|
/*
|
|
@@ -1945,6 +1962,11 @@ message CloseChannelRequest {
|
|
|
1945
1962
|
// A manual fee rate set in sat/vbyte that should be used when crafting the
|
|
1946
1963
|
// closure transaction.
|
|
1947
1964
|
uint64 sat_per_vbyte = 6;
|
|
1965
|
+
|
|
1966
|
+
// The maximum fee rate the closer is willing to pay.
|
|
1967
|
+
//
|
|
1968
|
+
// NOTE: This field is only respected if we're the initiator of the channel.
|
|
1969
|
+
uint64 max_fee_per_vbyte = 7;
|
|
1948
1970
|
}
|
|
1949
1971
|
|
|
1950
1972
|
message CloseStatusUpdate {
|
|
@@ -2620,6 +2642,9 @@ message WalletBalanceResponse {
|
|
|
2620
2642
|
// other usage.
|
|
2621
2643
|
int64 locked_balance = 5;
|
|
2622
2644
|
|
|
2645
|
+
// The amount of reserve required.
|
|
2646
|
+
int64 reserved_balance_anchor_chan = 6;
|
|
2647
|
+
|
|
2623
2648
|
// A mapping of each wallet account's name to its balance.
|
|
2624
2649
|
map<string, WalletAccountBalance> account_balance = 4;
|
|
2625
2650
|
}
|
|
@@ -3241,6 +3266,7 @@ message Invoice {
|
|
|
3241
3266
|
/*
|
|
3242
3267
|
The hash of the preimage. When using REST, this field must be encoded as
|
|
3243
3268
|
base64.
|
|
3269
|
+
Note: Output only, don't specify for creating an invoice.
|
|
3244
3270
|
*/
|
|
3245
3271
|
bytes r_hash = 4;
|
|
3246
3272
|
|
|
@@ -3258,19 +3284,30 @@ message Invoice {
|
|
|
3258
3284
|
*/
|
|
3259
3285
|
int64 value_msat = 23;
|
|
3260
3286
|
|
|
3261
|
-
|
|
3287
|
+
/*
|
|
3288
|
+
Whether this invoice has been fulfilled
|
|
3289
|
+
|
|
3290
|
+
The field is deprecated. Use the state field instead (compare to SETTLED).
|
|
3291
|
+
*/
|
|
3262
3292
|
bool settled = 6 [deprecated = true];
|
|
3263
3293
|
|
|
3264
|
-
|
|
3294
|
+
/*
|
|
3295
|
+
When this invoice was created.
|
|
3296
|
+
Note: Output only, don't specify for creating an invoice.
|
|
3297
|
+
*/
|
|
3265
3298
|
int64 creation_date = 7;
|
|
3266
3299
|
|
|
3267
|
-
|
|
3300
|
+
/*
|
|
3301
|
+
When this invoice was settled.
|
|
3302
|
+
Note: Output only, don't specify for creating an invoice.
|
|
3303
|
+
*/
|
|
3268
3304
|
int64 settle_date = 8;
|
|
3269
3305
|
|
|
3270
3306
|
/*
|
|
3271
3307
|
A bare-bones invoice for a payment within the Lightning Network. With the
|
|
3272
3308
|
details of the invoice, the sender has all the data necessary to send a
|
|
3273
3309
|
payment to the recipient.
|
|
3310
|
+
Note: Output only, don't specify for creating an invoice.
|
|
3274
3311
|
*/
|
|
3275
3312
|
string payment_request = 9;
|
|
3276
3313
|
|
|
@@ -3305,6 +3342,7 @@ message Invoice {
|
|
|
3305
3342
|
this index making it monotonically increasing. Callers to the
|
|
3306
3343
|
SubscribeInvoices call can use this to instantly get notified of all added
|
|
3307
3344
|
invoices with an add_index greater than this one.
|
|
3345
|
+
Note: Output only, don't specify for creating an invoice.
|
|
3308
3346
|
*/
|
|
3309
3347
|
uint64 add_index = 16;
|
|
3310
3348
|
|
|
@@ -3313,6 +3351,7 @@ message Invoice {
|
|
|
3313
3351
|
increment this index making it monotonically increasing. Callers to the
|
|
3314
3352
|
SubscribeInvoices call can use this to instantly get notified of all
|
|
3315
3353
|
settled invoices with an settle_index greater than this one.
|
|
3354
|
+
Note: Output only, don't specify for creating an invoice.
|
|
3316
3355
|
*/
|
|
3317
3356
|
uint64 settle_index = 17;
|
|
3318
3357
|
|
|
@@ -3326,6 +3365,7 @@ message Invoice {
|
|
|
3326
3365
|
was ultimately accepted. Additionally, it's possible that the sender paid
|
|
3327
3366
|
MORE that was specified in the original invoice. So we'll record that here
|
|
3328
3367
|
as well.
|
|
3368
|
+
Note: Output only, don't specify for creating an invoice.
|
|
3329
3369
|
*/
|
|
3330
3370
|
int64 amt_paid_sat = 19;
|
|
3331
3371
|
|
|
@@ -3336,6 +3376,7 @@ message Invoice {
|
|
|
3336
3376
|
amount was ultimately accepted. Additionally, it's possible that the sender
|
|
3337
3377
|
paid MORE that was specified in the original invoice. So we'll record that
|
|
3338
3378
|
here as well.
|
|
3379
|
+
Note: Output only, don't specify for creating an invoice.
|
|
3339
3380
|
*/
|
|
3340
3381
|
int64 amt_paid_msat = 20;
|
|
3341
3382
|
|
|
@@ -3348,18 +3389,26 @@ message Invoice {
|
|
|
3348
3389
|
|
|
3349
3390
|
/*
|
|
3350
3391
|
The state the invoice is in.
|
|
3392
|
+
Note: Output only, don't specify for creating an invoice.
|
|
3351
3393
|
*/
|
|
3352
3394
|
InvoiceState state = 21;
|
|
3353
3395
|
|
|
3354
|
-
|
|
3396
|
+
/*
|
|
3397
|
+
List of HTLCs paying to this invoice [EXPERIMENTAL].
|
|
3398
|
+
Note: Output only, don't specify for creating an invoice.
|
|
3399
|
+
*/
|
|
3355
3400
|
repeated InvoiceHTLC htlcs = 22;
|
|
3356
3401
|
|
|
3357
|
-
|
|
3402
|
+
/*
|
|
3403
|
+
List of features advertised on the invoice.
|
|
3404
|
+
Note: Output only, don't specify for creating an invoice.
|
|
3405
|
+
*/
|
|
3358
3406
|
map<uint32, Feature> features = 24;
|
|
3359
3407
|
|
|
3360
3408
|
/*
|
|
3361
3409
|
Indicates if this invoice was a spontaneous payment that arrived via keysend
|
|
3362
3410
|
[EXPERIMENTAL].
|
|
3411
|
+
Note: Output only, don't specify for creating an invoice.
|
|
3363
3412
|
*/
|
|
3364
3413
|
bool is_keysend = 25;
|
|
3365
3414
|
|
|
@@ -3367,6 +3416,7 @@ message Invoice {
|
|
|
3367
3416
|
The payment address of this invoice. This value will be used in MPP
|
|
3368
3417
|
payments, and also for newer invoices that always require the MPP payload
|
|
3369
3418
|
for added end-to-end security.
|
|
3419
|
+
Note: Output only, don't specify for creating an invoice.
|
|
3370
3420
|
*/
|
|
3371
3421
|
bytes payment_addr = 26;
|
|
3372
3422
|
|
|
@@ -3382,6 +3432,7 @@ message Invoice {
|
|
|
3382
3432
|
given set ID. This field is always populated for AMP invoices, and can be
|
|
3383
3433
|
used along side LookupInvoice to obtain the HTLC information related to a
|
|
3384
3434
|
given sub-invoice.
|
|
3435
|
+
Note: Output only, don't specify for creating an invoice.
|
|
3385
3436
|
*/
|
|
3386
3437
|
map<string, AMPInvoiceState> amp_invoice_state = 28;
|
|
3387
3438
|
}
|
|
@@ -4389,6 +4440,14 @@ message RPCMiddlewareRequest {
|
|
|
4389
4440
|
the same type, or replaced by an error message.
|
|
4390
4441
|
*/
|
|
4391
4442
|
RPCMessage response = 6;
|
|
4443
|
+
|
|
4444
|
+
/*
|
|
4445
|
+
This is used to indicate to the client that the server has successfully
|
|
4446
|
+
registered the interceptor. This is only used in the very first message
|
|
4447
|
+
that the server sends to the client after the client sends the server
|
|
4448
|
+
the middleware registration message.
|
|
4449
|
+
*/
|
|
4450
|
+
bool reg_complete = 8;
|
|
4392
4451
|
}
|
|
4393
4452
|
|
|
4394
4453
|
/*
|
|
@@ -4426,7 +4485,8 @@ message RPCMessage {
|
|
|
4426
4485
|
|
|
4427
4486
|
/*
|
|
4428
4487
|
The full canonical gRPC name of the message type (in the format
|
|
4429
|
-
<rpcpackage>.TypeName, for example lnrpc.GetInfoRequest).
|
|
4488
|
+
<rpcpackage>.TypeName, for example lnrpc.GetInfoRequest). In case of an
|
|
4489
|
+
error being returned from lnd, this simply contains the string "error".
|
|
4430
4490
|
*/
|
|
4431
4491
|
string type_name = 3;
|
|
4432
4492
|
|
|
@@ -4435,6 +4495,13 @@ message RPCMessage {
|
|
|
4435
4495
|
format.
|
|
4436
4496
|
*/
|
|
4437
4497
|
bytes serialized = 4;
|
|
4498
|
+
|
|
4499
|
+
/*
|
|
4500
|
+
Indicates that the response from lnd was an error, not a gRPC response. If
|
|
4501
|
+
this is set to true then the type_name contains the string "error" and
|
|
4502
|
+
serialized contains the error string.
|
|
4503
|
+
*/
|
|
4504
|
+
bool is_error = 5;
|
|
4438
4505
|
}
|
|
4439
4506
|
|
|
4440
4507
|
message RPCMiddlewareResponse {
|
|
@@ -4511,18 +4578,16 @@ message InterceptFeedback {
|
|
|
4511
4578
|
string error = 1;
|
|
4512
4579
|
|
|
4513
4580
|
/*
|
|
4514
|
-
A boolean indicating that the gRPC
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
boolean is needed because in protobuf an empty message is serialized as a
|
|
4518
|
-
0-length or nil byte slice and we wouldn't be able to distinguish between
|
|
4581
|
+
A boolean indicating that the gRPC message should be replaced/overwritten.
|
|
4582
|
+
This boolean is needed because in protobuf an empty message is serialized as
|
|
4583
|
+
a 0-length or nil byte slice and we wouldn't be able to distinguish between
|
|
4519
4584
|
an empty replacement message and the "don't replace anything" case.
|
|
4520
4585
|
*/
|
|
4521
4586
|
bool replace_response = 2;
|
|
4522
4587
|
|
|
4523
4588
|
/*
|
|
4524
4589
|
If the replace_response field is set to true, this field must contain the
|
|
4525
|
-
binary serialized gRPC
|
|
4590
|
+
binary serialized gRPC message in the protobuf format.
|
|
4526
4591
|
*/
|
|
4527
4592
|
bytes replacement_serialized = 3;
|
|
4528
4593
|
}
|
package/grpc/protos/peers.proto
CHANGED
|
@@ -7,7 +7,7 @@ package peersrpc;
|
|
|
7
7
|
option go_package = "github.com/lightningnetwork/lnd/lnrpc/peersrpc";
|
|
8
8
|
|
|
9
9
|
// Peers is a service that can be used to get information and interact
|
|
10
|
-
// with the other nodes of the
|
|
10
|
+
// with the other nodes of the network.
|
|
11
11
|
service Peers {
|
|
12
12
|
/* lncli: peers updatenodeannouncement
|
|
13
13
|
UpdateNodeAnnouncement allows the caller to update the node parameters
|
package/grpc/protos/router.proto
CHANGED
|
@@ -336,6 +336,14 @@ message SendToRouteRequest {
|
|
|
336
336
|
|
|
337
337
|
// Route that should be used to attempt to complete the payment.
|
|
338
338
|
lnrpc.Route route = 2;
|
|
339
|
+
|
|
340
|
+
/*
|
|
341
|
+
Whether the payment should be marked as failed when a temporary error is
|
|
342
|
+
returned from the given route. Set it to true so the payment won't be
|
|
343
|
+
failed unless a terminal error is occurred, such as payment timeout, no
|
|
344
|
+
routes, incorrect payment details, or insufficient funds.
|
|
345
|
+
*/
|
|
346
|
+
bool skip_temp_err = 3;
|
|
339
347
|
}
|
|
340
348
|
|
|
341
349
|
message SendToRouteResponse {
|
|
@@ -844,6 +844,16 @@ message UtxoLease {
|
|
|
844
844
|
The absolute expiration of the output lease represented as a unix timestamp.
|
|
845
845
|
*/
|
|
846
846
|
uint64 expiration = 3;
|
|
847
|
+
|
|
848
|
+
/*
|
|
849
|
+
The public key script of the leased output.
|
|
850
|
+
*/
|
|
851
|
+
bytes pk_script = 4;
|
|
852
|
+
|
|
853
|
+
/*
|
|
854
|
+
The value of the leased output in satoshis.
|
|
855
|
+
*/
|
|
856
|
+
uint64 value = 5;
|
|
847
857
|
}
|
|
848
858
|
|
|
849
859
|
message SignPsbtRequest {
|
|
@@ -185,6 +185,13 @@ message InitWalletRequest {
|
|
|
185
185
|
corresponding private keys and can serve signing RPC requests.
|
|
186
186
|
*/
|
|
187
187
|
WatchOnly watch_only = 9;
|
|
188
|
+
|
|
189
|
+
/*
|
|
190
|
+
macaroon_root_key is an optional 32 byte macaroon root key that can be
|
|
191
|
+
provided when initializing the wallet rather than letting lnd generate one
|
|
192
|
+
on its own.
|
|
193
|
+
*/
|
|
194
|
+
bytes macaroon_root_key = 10;
|
|
188
195
|
}
|
|
189
196
|
message InitWalletResponse {
|
|
190
197
|
/*
|
|
@@ -40,6 +40,8 @@ export type GetChannelsResult = {
|
|
|
40
40
|
is_partner_initiated: boolean;
|
|
41
41
|
/** Channel Is Private */
|
|
42
42
|
is_private: boolean;
|
|
43
|
+
/** Funding Output is Trusted */
|
|
44
|
+
is_trusted_funding?: boolean;
|
|
43
45
|
/** Local Balance Tokens */
|
|
44
46
|
local_balance: number;
|
|
45
47
|
/** Local CSV Blocks Delay */
|
|
@@ -56,6 +58,8 @@ export type GetChannelsResult = {
|
|
|
56
58
|
local_min_htlc_mtokens?: string;
|
|
57
59
|
/** Local Reserved Tokens */
|
|
58
60
|
local_reserve: number;
|
|
61
|
+
/** Other Channel Ids */
|
|
62
|
+
other_ids: string[];
|
|
59
63
|
/** Channel Partner Public Key */
|
|
60
64
|
partner_public_key: string;
|
|
61
65
|
/** Past Channel States Count */
|
|
@@ -122,6 +126,8 @@ export type GetChannelsResult = {
|
|
|
122
126
|
*
|
|
123
127
|
* `in_channel`, `in_payment`, `is_forward`, `out_channel`, `out_payment`,
|
|
124
128
|
`payment` are not supported on LND 0.11.1 and below
|
|
129
|
+
*
|
|
130
|
+
* `is_trusted_funding` is not supported on LND 0.15.0 and below
|
|
125
131
|
*/
|
|
126
132
|
export const getChannels: AuthenticatedLightningMethod<
|
|
127
133
|
GetChannelsArgs,
|
|
@@ -66,6 +66,8 @@ export type GetClosedChannelsResult = {
|
|
|
66
66
|
is_partner_initiated?: boolean;
|
|
67
67
|
/** Is Remote Force Close */
|
|
68
68
|
is_remote_force_close: boolean;
|
|
69
|
+
/** Other Channel Ids */
|
|
70
|
+
other_ids: string[];
|
|
69
71
|
/** Partner Public Key Hex */
|
|
70
72
|
partner_public_key: string;
|
|
71
73
|
/** Channel Funding Transaction Id Hex */
|
|
@@ -81,6 +83,8 @@ export type GetClosedChannelsResult = {
|
|
|
81
83
|
* Multiple close type flags are supported.
|
|
82
84
|
*
|
|
83
85
|
* Requires `offchain:read` permission
|
|
86
|
+
*
|
|
87
|
+
* `other_ids is not supported on LND 0.15.0 and below
|
|
84
88
|
*/
|
|
85
89
|
export const getClosedChannels: AuthenticatedLightningMethod<
|
|
86
90
|
GetClosedChannelsArgs,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AuthenticatedLightningArgs,
|
|
3
|
+
AuthenticatedLightningMethod,
|
|
4
|
+
} from '../../typescript';
|
|
5
|
+
|
|
6
|
+
export type GetEphemeralChannelIdsArgs = AuthenticatedLightningArgs;
|
|
7
|
+
|
|
8
|
+
export type GetEphemeralChannelIdsResult = {
|
|
9
|
+
channels: {
|
|
10
|
+
/** Channel Identifiers */
|
|
11
|
+
other_ids: string[];
|
|
12
|
+
/** Top Level Channel Identifier */
|
|
13
|
+
reference_id: string;
|
|
14
|
+
}[];
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Get ephemeral channel ids
|
|
19
|
+
*
|
|
20
|
+
* Requires `offchain:read` permission
|
|
21
|
+
*
|
|
22
|
+
* This method is not supported on LND 0.15.0 and below
|
|
23
|
+
*/
|
|
24
|
+
export const getEphemeralChannelIds: AuthenticatedLightningMethod<
|
|
25
|
+
GetEphemeralChannelIdsArgs,
|
|
26
|
+
GetEphemeralChannelIdsResult
|
|
27
|
+
>;
|
|
@@ -15,6 +15,7 @@ export * from './get_channel_balance';
|
|
|
15
15
|
export * from './get_channels';
|
|
16
16
|
export * from './get_closed_channels';
|
|
17
17
|
export * from './get_connected_watchtowers';
|
|
18
|
+
export * from './get_ephemeral_channel_ids';
|
|
18
19
|
export * from './get_failed_payments';
|
|
19
20
|
export * from './get_fee_rates';
|
|
20
21
|
export * from './get_forwarding_confidence';
|
|
@@ -58,6 +58,8 @@ export type SubscribeToChannelsChannelClosedEvent = {
|
|
|
58
58
|
is_partner_initiated?: boolean;
|
|
59
59
|
/** Is Remote Force Close */
|
|
60
60
|
is_remote_force_close: boolean;
|
|
61
|
+
/** Other Channel Ids */
|
|
62
|
+
other_ids: string[];
|
|
61
63
|
/** Partner Public Key Hex */
|
|
62
64
|
partner_public_key: string;
|
|
63
65
|
/** Channel Funding Transaction Id Hex */
|
|
@@ -89,6 +91,8 @@ export type SubscribeToChannelsChannelOpenedEvent = {
|
|
|
89
91
|
is_partner_initiated: boolean;
|
|
90
92
|
/** Channel Is Private */
|
|
91
93
|
is_private: boolean;
|
|
94
|
+
/** Funding Output is Trusted */
|
|
95
|
+
is_trusted_funding: boolean;
|
|
92
96
|
/** Local Balance Tokens */
|
|
93
97
|
local_balance: number;
|
|
94
98
|
/** Local Initially Pushed Tokens */
|
|
@@ -138,5 +142,7 @@ export type SubscribeToChannelsChannelOpeningEvent = {
|
|
|
138
142
|
* Subscribe to channel updates
|
|
139
143
|
*
|
|
140
144
|
* Requires `offchain:read` permission
|
|
145
|
+
*
|
|
146
|
+
* `is_trusted_funding`, `other_ids` are not supported on LND 0.15.0 and below
|
|
141
147
|
*/
|
|
142
148
|
export const subscribeToChannels: AuthenticatedLightningSubscription;
|
|
@@ -5,6 +5,8 @@ export type SubscribeToOpenRequestsChannelRequestEvent = {
|
|
|
5
5
|
accept: (args: {
|
|
6
6
|
/** Restrict Coop Close To Address */
|
|
7
7
|
cooperative_close_address?: string;
|
|
8
|
+
/** Accept Funding as Trusted */
|
|
9
|
+
is_trusted_funding?: boolean;
|
|
8
10
|
/** Required Confirmations Before Channel Open */
|
|
9
11
|
min_confirmations?: number;
|
|
10
12
|
/** Peer Unilateral Balance Output CSV Delay */
|
|
@@ -28,6 +30,10 @@ export type SubscribeToOpenRequestsChannelRequestEvent = {
|
|
|
28
30
|
csv_delay: number;
|
|
29
31
|
/** Request Id Hex */
|
|
30
32
|
id: string;
|
|
33
|
+
/** Incoming Channel Is Private Bool */
|
|
34
|
+
is_private: boolean;
|
|
35
|
+
/** Request Immediate Trusted Funding */
|
|
36
|
+
is_trusted_funding: boolean;
|
|
31
37
|
/** Channel Local Tokens Balance */
|
|
32
38
|
local_balance: number;
|
|
33
39
|
/** Channel Local Reserve Tokens */
|
|
@@ -61,5 +67,7 @@ channel requests after a short delay.
|
|
|
61
67
|
listeners to `channel_request`
|
|
62
68
|
*
|
|
63
69
|
* LND 0.11.1 and below do not support `accept` or `reject` arguments
|
|
70
|
+
*
|
|
71
|
+
* LND 0.15.0 and below do not support `is_trusted_funding`
|
|
64
72
|
*/
|
|
65
73
|
export const subscribeToOpenRequests: AuthenticatedLightningSubscription;
|
|
@@ -49,6 +49,8 @@ export type CoopCloseChannelArgs = AuthenticatedLightningArgs<
|
|
|
49
49
|
is_force_close?: false;
|
|
50
50
|
/** Request Sending Local Channel Funds To Address String */
|
|
51
51
|
address?: string;
|
|
52
|
+
/** Fail Cooperative Close Above Fee Rate */
|
|
53
|
+
max_tokens_per_vbyte?: number;
|
|
52
54
|
} & ExpectedBothPublicKeyAndSocketForChannelClose &
|
|
53
55
|
UnexpectedTokensPerVbyteForChannelClose
|
|
54
56
|
>;
|
|
@@ -72,7 +74,11 @@ export type CloseChannelResult = {
|
|
|
72
74
|
*
|
|
73
75
|
* If cooperatively closing, pass a public key and socket to connect
|
|
74
76
|
*
|
|
77
|
+
* `max_tokens_per_vbyte` will be ignored when closing a peer initiated channel
|
|
78
|
+
*
|
|
75
79
|
* Requires `info:read`, `offchain:write`, `onchain:write`, `peers:write` permissions
|
|
80
|
+
*
|
|
81
|
+
* `max_tokens_per_vbyte` is not supported in LND 0.15.0 and below
|
|
76
82
|
*/
|
|
77
83
|
export const closeChannel: AuthenticatedLightningMethod<
|
|
78
84
|
CloseChannelArgs,
|
|
@@ -15,17 +15,23 @@ const type = 'default';
|
|
|
15
15
|
|
|
16
16
|
If cooperatively closing, pass a public key and socket to connect
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
`max_tokens_per_vbyte` will be ignored when closing a peer initiated channel
|
|
19
|
+
|
|
20
|
+
Requires `info:read`, `offchain:write`, `onchain:write`, `peers:write`
|
|
21
|
+
permissions
|
|
22
|
+
|
|
23
|
+
`max_tokens_per_vbyte` is not supported in LND 0.15.0 and below
|
|
19
24
|
|
|
20
25
|
{
|
|
21
26
|
[address]: <Request Sending Local Channel Funds To Address String>
|
|
22
27
|
[id]: <Standard Format Channel Id String>
|
|
23
28
|
[is_force_close]: <Is Force Close Bool>
|
|
24
29
|
lnd: <Authenticated LND API Object>
|
|
30
|
+
[max_tokens_per_vbyte]: <Fail Cooperative Close Above Fee Rate Number>
|
|
25
31
|
[public_key]: <Peer Public Key String>
|
|
26
32
|
[socket]: <Peer Socket String>
|
|
27
33
|
[target_confirmations]: <Confirmation Target Number>
|
|
28
|
-
[tokens_per_vbyte]: <Tokens Per Virtual Byte Number>
|
|
34
|
+
[tokens_per_vbyte]: <Target Tokens Per Virtual Byte Number>
|
|
29
35
|
[transaction_id]: <Transaction Id Hex String>
|
|
30
36
|
[transaction_vout]: <Transaction Output Index Number>
|
|
31
37
|
}
|
|
@@ -115,6 +121,7 @@ module.exports = (args, cbk) => {
|
|
|
115
121
|
},
|
|
116
122
|
delivery_address: args.address || undefined,
|
|
117
123
|
force: !!args.is_force_close,
|
|
124
|
+
max_fee_per_vbyte: args.max_tokens_per_vbyte || undefined,
|
|
118
125
|
sat_per_byte: !!tokensPerVByte ? tokensPerVByte : undefined,
|
|
119
126
|
target_conf: args.target_confirmations || undefined,
|
|
120
127
|
});
|
|
@@ -10,39 +10,51 @@ export type GetChainTransactionsArgs = AuthenticatedLightningArgs<{
|
|
|
10
10
|
before?: number;
|
|
11
11
|
}>;
|
|
12
12
|
|
|
13
|
-
export type
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
|
|
31
|
-
/** Transaction
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
|
|
35
|
-
/** Tokens Including Fee */
|
|
36
|
-
tokens: number;
|
|
37
|
-
/** Raw Transaction Hex */
|
|
38
|
-
transaction?: string;
|
|
13
|
+
export type ChainTransaction = {
|
|
14
|
+
/** Block Hash */
|
|
15
|
+
block_id?: string;
|
|
16
|
+
/** Confirmation Count */
|
|
17
|
+
confirmation_count?: number;
|
|
18
|
+
/** Confirmation Block Height */
|
|
19
|
+
confirmation_height?: number;
|
|
20
|
+
/** Created ISO 8601 Date */
|
|
21
|
+
created_at: string;
|
|
22
|
+
/** Transaction Label */
|
|
23
|
+
description?: string;
|
|
24
|
+
/** Fees Paid Tokens */
|
|
25
|
+
fee?: number;
|
|
26
|
+
/** Transaction Id */
|
|
27
|
+
id: string;
|
|
28
|
+
inputs: {
|
|
29
|
+
/** Spent Outpoint is Local */
|
|
30
|
+
is_local: boolean;
|
|
31
|
+
/** Transaction Id Hex */
|
|
32
|
+
transaction_id: string;
|
|
33
|
+
/** Transaction Output Index */
|
|
34
|
+
transaction_vout: number;
|
|
39
35
|
}[];
|
|
36
|
+
/** Is Confirmed */
|
|
37
|
+
is_confirmed: boolean;
|
|
38
|
+
/** Transaction Outbound */
|
|
39
|
+
is_outgoing: boolean;
|
|
40
|
+
/** Addresses */
|
|
41
|
+
output_addresses: string[];
|
|
42
|
+
/** Tokens Including Fee */
|
|
43
|
+
tokens: number;
|
|
44
|
+
/** Raw Transaction Hex */
|
|
45
|
+
transaction?: string;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export type GetChainTransactionsResult = {
|
|
49
|
+
transactions: ChainTransaction[];
|
|
40
50
|
};
|
|
41
51
|
|
|
42
52
|
/**
|
|
43
53
|
* Get chain transactions.
|
|
44
54
|
*
|
|
45
55
|
* Requires `onchain:read` permission
|
|
56
|
+
*
|
|
57
|
+
* `inputs` are not supported on LND 0.15.0 and below
|
|
46
58
|
*/
|
|
47
59
|
export const getChainTransactions: AuthenticatedLightningMethod<
|
|
48
60
|
GetChainTransactionsArgs,
|
|
@@ -13,10 +13,12 @@ const type = 'default';
|
|
|
13
13
|
|
|
14
14
|
Requires `onchain:read` permission
|
|
15
15
|
|
|
16
|
+
`inputs` are not supported on LND 0.15.0 and below
|
|
17
|
+
|
|
16
18
|
{
|
|
17
19
|
[after]: <Confirmed After Current Best Chain Block Height Number>
|
|
18
20
|
[before]: <Confirmed Before Current Best Chain Block Height Number>
|
|
19
|
-
lnd: <Authenticated LND Object>
|
|
21
|
+
lnd: <Authenticated LND API Object>
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
@returns via cbk or Promise
|
|
@@ -29,6 +31,11 @@ const type = 'default';
|
|
|
29
31
|
[description]: <Transaction Label String>
|
|
30
32
|
[fee]: <Fees Paid Tokens Number>
|
|
31
33
|
id: <Transaction Id String>
|
|
34
|
+
inputs: [{
|
|
35
|
+
is_local: <Spent Outpoint is Local Bool>
|
|
36
|
+
transaction_id: <Transaction Id Hex String>
|
|
37
|
+
transaction_vout: <Transaction Output Index Number>
|
|
38
|
+
}]
|
|
32
39
|
is_confirmed: <Is Confirmed Bool>
|
|
33
40
|
is_outgoing: <Transaction Outbound Bool>
|
|
34
41
|
output_addresses: [<Address String>]
|
|
@@ -12,6 +12,10 @@ export type GetLockedUtxosResult = {
|
|
|
12
12
|
lock_expires_at: string;
|
|
13
13
|
/** Locking Id Hex String */
|
|
14
14
|
lock_id: string;
|
|
15
|
+
/** Outpoint Output Script Hex */
|
|
16
|
+
output_script?: string;
|
|
17
|
+
/** Token Value of Outpoint */
|
|
18
|
+
tokens?: number;
|
|
15
19
|
/** Transaction Id Hex String */
|
|
16
20
|
transaction_id: string;
|
|
17
21
|
/** Transaction Output Index Number */
|
|
@@ -27,6 +31,8 @@ export type GetLockedUtxosResult = {
|
|
|
27
31
|
* Requires LND built with `walletrpc` build tag
|
|
28
32
|
*
|
|
29
33
|
* This method is not supported on LND 0.12.1 and below
|
|
34
|
+
*
|
|
35
|
+
* `output_script`, `tokens` are not supported on LND 0.15.0 and below
|
|
30
36
|
*/
|
|
31
37
|
export const getLockedUtxos: AuthenticatedLightningMethod<
|
|
32
38
|
GetLockedUtxosArgs,
|
|
@@ -6,6 +6,7 @@ const {isLnd} = require('./../../lnd_requests');
|
|
|
6
6
|
const asMs = sec => Number(sec) * 1e3;
|
|
7
7
|
const bufferAsHex = buffer => buffer.toString('hex');
|
|
8
8
|
const {isArray} = Array;
|
|
9
|
+
const {isBuffer} = Buffer;
|
|
9
10
|
const method = 'listLeases';
|
|
10
11
|
const type = 'wallet';
|
|
11
12
|
const unsuppportedErr = /unknown/;
|
|
@@ -18,6 +19,8 @@ const unsuppportedErr = /unknown/;
|
|
|
18
19
|
|
|
19
20
|
This method is not supported on LND 0.12.1 and below
|
|
20
21
|
|
|
22
|
+
`output_script`, `tokens` are not supported on LND 0.15.0 and below
|
|
23
|
+
|
|
21
24
|
{
|
|
22
25
|
lnd: <Authenticated LND API Object>
|
|
23
26
|
}
|
|
@@ -27,6 +30,8 @@ const unsuppportedErr = /unknown/;
|
|
|
27
30
|
utxos: [{
|
|
28
31
|
lock_expires_at: <Lock Expires At ISO 8601 Date String>
|
|
29
32
|
lock_id: <Locking Id Hex String>
|
|
33
|
+
[output_script]: <Outpoint Output Script Hex String>
|
|
34
|
+
[tokens]: <Token Value of Outpoint Number>
|
|
30
35
|
transaction_id: <Transaction Id Hex String>
|
|
31
36
|
transaction_vout: <Transaction Output Index Number>
|
|
32
37
|
}]
|
|
@@ -64,10 +69,16 @@ module.exports = ({lnd}, cbk) => {
|
|
|
64
69
|
return cbk([503, 'ExpectedExpirationDateForLockedUtxo']);
|
|
65
70
|
}
|
|
66
71
|
|
|
72
|
+
if (!!res.locked_utxos.filter(n => !isBuffer(n.pk_script)).length) {
|
|
73
|
+
return cbk([503, 'ExpectedPkScriptForLockedUtxosInResponse']);
|
|
74
|
+
}
|
|
75
|
+
|
|
67
76
|
try {
|
|
68
77
|
const utxos = res.locked_utxos.map(lock => ({
|
|
69
78
|
lock_expires_at: new Date(asMs(lock.expiration)).toISOString(),
|
|
70
79
|
lock_id: bufferAsHex(lock.id),
|
|
80
|
+
output_script: bufferAsHex(lock.pk_script) || undefined,
|
|
81
|
+
tokens: Number(lock.value) || undefined,
|
|
71
82
|
transaction_id: lock.outpoint.txid_str,
|
|
72
83
|
transaction_vout: lock.outpoint.output_index,
|
|
73
84
|
}));
|
|
@@ -13,6 +13,8 @@ export type OpenChannelsArgs = AuthenticatedLightningArgs<{
|
|
|
13
13
|
give_tokens?: number;
|
|
14
14
|
/** Channel is Private */
|
|
15
15
|
is_private?: boolean;
|
|
16
|
+
/** Peer Should Avoid Waiting For Confirmation */
|
|
17
|
+
is_trusted_funding?: boolean;
|
|
16
18
|
/** Minimum HTLC Millitokens */
|
|
17
19
|
min_htlc_mtokens?: string;
|
|
18
20
|
/** Public Key Hex */
|
|
@@ -45,6 +47,13 @@ minutes to fund the channels.
|
|
|
45
47
|
*
|
|
46
48
|
* If you do not fund the channels, be sure to `cancelPendingChannel`s on each
|
|
47
49
|
channel that was not funded.
|
|
50
|
+
|
|
51
|
+
Use `is_avoiding_broadcast` only when self-publishing the raw transaction
|
|
52
|
+
after the funding step.
|
|
53
|
+
|
|
54
|
+
`is_trusted_funding` is not supported on LND 0.15.0 and below and requires
|
|
55
|
+
`--protocol.option-scid-alias` and `--protocol.zero-conf` set on both sides
|
|
56
|
+
as well as a channel open request listener to accept the trusted funding.
|
|
48
57
|
*/
|
|
49
58
|
export const openChannels: AuthenticatedLightningMethod<
|
|
50
59
|
OpenChannelsArgs,
|
|
@@ -1,33 +1,16 @@
|
|
|
1
1
|
import {AuthenticatedLightningSubscription} from '../../typescript';
|
|
2
|
+
import {ChainTransaction} from './get_chain_transactions';
|
|
2
3
|
|
|
3
|
-
export type SubscribeToTransactionsChainTransactionEvent =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
confirmation_count?: number;
|
|
8
|
-
/** Confirmation Block Height */
|
|
9
|
-
confirmation_height?: number;
|
|
10
|
-
/** Created ISO 8601 Date */
|
|
11
|
-
created_at: string;
|
|
12
|
-
/** Fees Paid Tokens */
|
|
13
|
-
fee?: number;
|
|
14
|
-
/** Transaction Id */
|
|
15
|
-
id: string;
|
|
16
|
-
/** Is Confirmed */
|
|
17
|
-
is_confirmed: boolean;
|
|
18
|
-
/** Transaction Outbound */
|
|
19
|
-
is_outgoing: boolean;
|
|
20
|
-
/** Addresses */
|
|
21
|
-
output_addresses: string[];
|
|
22
|
-
/** Tokens Including Fee */
|
|
23
|
-
tokens: number;
|
|
24
|
-
/** Raw Transaction Hex */
|
|
25
|
-
transaction?: string;
|
|
26
|
-
};
|
|
4
|
+
export type SubscribeToTransactionsChainTransactionEvent = Omit<
|
|
5
|
+
ChainTransaction,
|
|
6
|
+
'description'
|
|
7
|
+
>;
|
|
27
8
|
|
|
28
9
|
/**
|
|
29
10
|
* Subscribe to transactions
|
|
30
11
|
*
|
|
31
12
|
* Requires `onchain:read` permission
|
|
13
|
+
*
|
|
14
|
+
* `inputs` are not supported on LND 0.15.0 and below
|
|
32
15
|
*/
|
|
33
16
|
export const subscribeToTransactions: AuthenticatedLightningSubscription;
|
|
@@ -12,6 +12,8 @@ const type = 'default';
|
|
|
12
12
|
|
|
13
13
|
Requires `onchain:read` permission
|
|
14
14
|
|
|
15
|
+
`inputs` are not supported on LND 0.15.0 and below
|
|
16
|
+
|
|
15
17
|
{
|
|
16
18
|
lnd: <Authenticated LND API Object>
|
|
17
19
|
}
|
|
@@ -30,6 +32,11 @@ const type = 'default';
|
|
|
30
32
|
created_at: <Created ISO 8601 Date String>
|
|
31
33
|
[fee]: <Fees Paid Tokens Number>
|
|
32
34
|
id: <Transaction Id String>
|
|
35
|
+
inputs: [{
|
|
36
|
+
is_local: <Spent Outpoint is Local Bool>
|
|
37
|
+
transaction_id: <Transaction Id Hex String>
|
|
38
|
+
transaction_vout: <Transaction Output Index Number>
|
|
39
|
+
}]
|
|
33
40
|
is_confirmed: <Is Confirmed Bool>
|
|
34
41
|
is_outgoing: <Transaction Outbound Bool>
|
|
35
42
|
output_addresses: [<Address String>]
|
|
@@ -59,10 +59,6 @@ module.exports = (args, cbk) => {
|
|
|
59
59
|
},
|
|
60
60
|
},
|
|
61
61
|
err => {
|
|
62
|
-
if (!!err && unsuppportedErr.test(err.details)) {
|
|
63
|
-
return cbk([501, 'BackingLndDoesNotSupportUnlockingUtxos']);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
62
|
if (!!err) {
|
|
67
63
|
return cbk([503, 'UnexpectedErrorUnlockingUtxo', {err}]);
|
|
68
64
|
}
|
|
@@ -10,6 +10,8 @@ export type SignBytesArgs = AuthenticatedLightningArgs<{
|
|
|
10
10
|
key_index: number;
|
|
11
11
|
/** Bytes To Hash and Sign Hex Encoded String */
|
|
12
12
|
preimage: string;
|
|
13
|
+
/** Signature Type */
|
|
14
|
+
type?: 'ecdsa' | 'schnorr';
|
|
13
15
|
}>;
|
|
14
16
|
|
|
15
17
|
export type SignBytesResult = {
|
|
@@ -23,6 +25,8 @@ export type SignBytesResult = {
|
|
|
23
25
|
* Requires LND built with `signrpc` build tag
|
|
24
26
|
*
|
|
25
27
|
* Requires `signer:generate` permission
|
|
28
|
+
*
|
|
29
|
+
* `schnorr` signature type is not supported on LND 0.15.0 and below
|
|
26
30
|
*/
|
|
27
31
|
export const signBytes: AuthenticatedLightningMethod<
|
|
28
32
|
SignBytesArgs,
|
|
@@ -167,10 +167,6 @@ module.exports = args => {
|
|
|
167
167
|
throw new Error('ExpectedPreimageInLookupInvoiceResponse');
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
if (args.settled !== false && args.settled !== true) {
|
|
171
|
-
throw new Error('ExpectedSettledStateInLookupInvoiceResponse');
|
|
172
|
-
}
|
|
173
|
-
|
|
174
170
|
if (args.value === undefined) {
|
|
175
171
|
throw new Error('ExpectedTokensValueInLookupInvoiceResponse');
|
|
176
172
|
}
|
|
@@ -180,6 +176,7 @@ module.exports = args => {
|
|
|
180
176
|
const descHash = args.description_hash;
|
|
181
177
|
const expiresInMs = Number(args.expiry) * msPerSec;
|
|
182
178
|
const isAmpPush = !args.payment_request && !!args.is_amp;
|
|
179
|
+
const isConfirmed = args.state === 'SETTLED';
|
|
183
180
|
const mtok = (BigInt(args.value) * mtokensPerToken).toString();
|
|
184
181
|
const payment = args.payment_addr.toString('hex');
|
|
185
182
|
const settleDate = args.settle_date;
|
|
@@ -190,7 +187,7 @@ module.exports = args => {
|
|
|
190
187
|
return {
|
|
191
188
|
chain_address: args.fallback_addr || undefined,
|
|
192
189
|
cltv_delta: Number(args.cltv_expiry),
|
|
193
|
-
confirmed_at:
|
|
190
|
+
confirmed_at: isConfirmed ? dateFrom(settleDate) : undefined,
|
|
194
191
|
confirmed_index: confirmedIndex || undefined,
|
|
195
192
|
created_at: new Date(createdAtMs).toISOString(),
|
|
196
193
|
description: args.memo,
|
|
@@ -205,7 +202,7 @@ module.exports = args => {
|
|
|
205
202
|
id: args.r_hash.toString('hex'),
|
|
206
203
|
index: Number(args.add_index),
|
|
207
204
|
is_canceled: args.state === 'CANCELED' || undefined,
|
|
208
|
-
is_confirmed:
|
|
205
|
+
is_confirmed: isConfirmed,
|
|
209
206
|
is_held: args.state === 'ACCEPTED' || undefined,
|
|
210
207
|
is_private: args.private,
|
|
211
208
|
is_push: isAmpPush || args.is_keysend || undefined,
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
const {abs} = Math;
|
|
2
2
|
const {isArray} = Array;
|
|
3
|
+
const isBool = n => n === false || n === true;
|
|
3
4
|
const isHash = n => !!n && /^[0-9A-F]{64}$/i.test(n);
|
|
5
|
+
const isNumber = n => !!n && !isNaN(n);
|
|
4
6
|
const msPerSec = 1e3;
|
|
5
7
|
const notFound = -1;
|
|
8
|
+
const nullHash = '0000000000000000000000000000000000000000000000000000000000000000';
|
|
9
|
+
const outpointAsComponents = n => n.split(':');
|
|
6
10
|
|
|
7
11
|
/** Transaction from RPC transaction message
|
|
8
12
|
|
|
@@ -13,6 +17,10 @@ const notFound = -1;
|
|
|
13
17
|
dest_addresses: [<Output Address String>]
|
|
14
18
|
label: <Label String>
|
|
15
19
|
num_confirmations: <Confirmation Count Number>
|
|
20
|
+
previous_outpoints: [{
|
|
21
|
+
is_our_output: <Is Local Output Bool>
|
|
22
|
+
outpoint: <Outpoint String>
|
|
23
|
+
}]
|
|
16
24
|
raw_tx_hex: <Raw Transaction Serialized Hex String>
|
|
17
25
|
time_stamp: <Transaction Created At Epoch Time String>
|
|
18
26
|
total_fees: <Total Fees Paid Related To This Transaction String>
|
|
@@ -31,6 +39,11 @@ const notFound = -1;
|
|
|
31
39
|
[description]: <Transaction Label String>
|
|
32
40
|
[fee]: <Fees Paid Tokens Number>
|
|
33
41
|
id: <Transaction Id String>
|
|
42
|
+
inputs: [{
|
|
43
|
+
is_local: <Spent Outpoint is Local Bool>
|
|
44
|
+
transaction_id: <Transaction Id Hex String>
|
|
45
|
+
transaction_vout: <Transaction Output Index Number>
|
|
46
|
+
}]
|
|
34
47
|
is_confirmed: <Is Confirmed Bool>
|
|
35
48
|
is_outgoing: <Transaction Outbound Bool>
|
|
36
49
|
output_addresses: [<Address String>]
|
|
@@ -67,6 +80,10 @@ module.exports = tx => {
|
|
|
67
80
|
throw new Error('ExpectedChainTransactionConfirmationsCount');
|
|
68
81
|
}
|
|
69
82
|
|
|
83
|
+
if (!isArray(tx.previous_outpoints)) {
|
|
84
|
+
throw new Error('ExpectedArrayOfPreviousOutpointsInRpcTransaction');
|
|
85
|
+
}
|
|
86
|
+
|
|
70
87
|
if (!tx.time_stamp) {
|
|
71
88
|
throw new Error('ExpectedChainTransactionTimestamp');
|
|
72
89
|
}
|
|
@@ -79,6 +96,37 @@ module.exports = tx => {
|
|
|
79
96
|
throw new Error('ExpectedChainTransactionId');
|
|
80
97
|
}
|
|
81
98
|
|
|
99
|
+
const inputs = tx.previous_outpoints.map(spend => {
|
|
100
|
+
if (!spend.outpoint) {
|
|
101
|
+
throw new Error('ExpectedPreviousOutpointInRpcTransaction');
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const [id, vout] = outpointAsComponents(spend.outpoint);
|
|
105
|
+
|
|
106
|
+
if (!isHash(id)) {
|
|
107
|
+
throw new Error('ExpectedOutpointSpendingTransactionIdInRpcTx');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Exit early when spend is empty
|
|
111
|
+
if (id === nullHash) {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (!isNumber(vout)) {
|
|
116
|
+
throw new Error('ExpectedOutpointSpendingTransactionVoutInRpcTx');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (!isBool(spend.is_our_output)) {
|
|
120
|
+
throw new Error('ExpectedOutpointOwnershipBooleanInRpcTransaction');
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return {
|
|
124
|
+
is_local: spend.is_our_output,
|
|
125
|
+
transaction_id: id,
|
|
126
|
+
transaction_vout: Number(vout),
|
|
127
|
+
};
|
|
128
|
+
});
|
|
129
|
+
|
|
82
130
|
return {
|
|
83
131
|
block_id: tx.block_hash || undefined,
|
|
84
132
|
confirmation_count: tx.num_confirmations || undefined,
|
|
@@ -87,6 +135,7 @@ module.exports = tx => {
|
|
|
87
135
|
description: tx.label || undefined,
|
|
88
136
|
fee: Number(tx.total_fees) || undefined,
|
|
89
137
|
id: tx.tx_hash,
|
|
138
|
+
inputs: inputs.filter(n => !!n),
|
|
90
139
|
is_confirmed: !!tx.num_confirmations,
|
|
91
140
|
is_outgoing: Number(tx.amount) < Number(),
|
|
92
141
|
output_addresses: tx.dest_addresses,
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"@grpc/grpc-js": "1.6.10",
|
|
11
11
|
"@grpc/proto-loader": "0.7.2",
|
|
12
12
|
"@types/express": "4.17.13",
|
|
13
|
-
"@types/node": "18.7.
|
|
13
|
+
"@types/node": "18.7.13",
|
|
14
14
|
"@types/request": "2.48.8",
|
|
15
15
|
"@types/ws": "8.5.3",
|
|
16
16
|
"async": "3.2.4",
|
|
@@ -26,14 +26,14 @@
|
|
|
26
26
|
"invoices": "2.1.0",
|
|
27
27
|
"psbt": "2.7.1",
|
|
28
28
|
"tiny-secp256k1": "2.2.1",
|
|
29
|
-
"type-fest": "2.
|
|
29
|
+
"type-fest": "2.19.0"
|
|
30
30
|
},
|
|
31
31
|
"description": "Lightning Network client library",
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@alexbosworth/node-fetch": "2.6.2",
|
|
34
34
|
"@alexbosworth/tap": "15.0.11",
|
|
35
35
|
"tsd": "0.22.0",
|
|
36
|
-
"typescript": "4.
|
|
36
|
+
"typescript": "4.8.2",
|
|
37
37
|
"ws": "8.8.1"
|
|
38
38
|
},
|
|
39
39
|
"engines": {
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"directory": "test/typescript"
|
|
60
60
|
},
|
|
61
61
|
"types": "index.d.ts",
|
|
62
|
-
"version": "5.
|
|
62
|
+
"version": "5.20.1"
|
|
63
63
|
}
|
|
@@ -11,6 +11,7 @@ const makeExpected = overrides => {
|
|
|
11
11
|
description: undefined,
|
|
12
12
|
fee: 1,
|
|
13
13
|
id: Buffer.alloc(32).toString('hex'),
|
|
14
|
+
inputs: [],
|
|
14
15
|
is_confirmed: true,
|
|
15
16
|
is_outgoing: false,
|
|
16
17
|
output_addresses: ['address'],
|
|
@@ -33,6 +34,7 @@ const makeLnd = overrides => {
|
|
|
33
34
|
block_height: 1,
|
|
34
35
|
dest_addresses: ['address'],
|
|
35
36
|
num_confirmations: 1,
|
|
37
|
+
previous_outpoints: [],
|
|
36
38
|
time_stamp: '1',
|
|
37
39
|
total_fees: '1',
|
|
38
40
|
tx_hash: Buffer.alloc(32).toString('hex'),
|
|
@@ -13,6 +13,8 @@ const makeLnd = overrides => {
|
|
|
13
13
|
output_index: 0,
|
|
14
14
|
txid_str: Buffer.alloc(32).toString('hex'),
|
|
15
15
|
},
|
|
16
|
+
pk_script: Buffer.alloc(1),
|
|
17
|
+
value: '1',
|
|
16
18
|
};
|
|
17
19
|
|
|
18
20
|
Object.keys(overrides).forEach(k => utxo[k] = overrides[k]);
|
|
@@ -56,12 +58,31 @@ const tests = [
|
|
|
56
58
|
description: 'An outpoint is expected in a locked utxo',
|
|
57
59
|
error: [503, 'UnexpectedErrorParsingLockedUtxosResponse'],
|
|
58
60
|
},
|
|
61
|
+
{
|
|
62
|
+
args: {lnd: makeLnd({pk_script: undefined})},
|
|
63
|
+
description: 'An output script is expected in a locked utxo',
|
|
64
|
+
error: [503, 'ExpectedPkScriptForLockedUtxosInResponse'],
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
args: {lnd: makeLnd({pk_script: Buffer.alloc(0), value: '0'})},
|
|
68
|
+
description: 'Get legacy tx and map them to normalized transactions',
|
|
69
|
+
expected: [{
|
|
70
|
+
lock_expires_at: '1970-01-01T00:00:01.000Z',
|
|
71
|
+
lock_id: '0000000000000000000000000000000000000000000000000000000000000000',
|
|
72
|
+
output_script: undefined,
|
|
73
|
+
tokens: undefined,
|
|
74
|
+
transaction_id: Buffer.alloc(32).toString('hex'),
|
|
75
|
+
transaction_vout: 0,
|
|
76
|
+
}],
|
|
77
|
+
},
|
|
59
78
|
{
|
|
60
79
|
args: {lnd: makeLnd({})},
|
|
61
80
|
description: 'Get transactions and map them to normalized transactions',
|
|
62
81
|
expected: [{
|
|
63
82
|
lock_expires_at: '1970-01-01T00:00:01.000Z',
|
|
64
83
|
lock_id: '0000000000000000000000000000000000000000000000000000000000000000',
|
|
84
|
+
output_script: '00',
|
|
85
|
+
tokens: 1,
|
|
65
86
|
transaction_id: Buffer.alloc(32).toString('hex'),
|
|
66
87
|
transaction_vout: 0,
|
|
67
88
|
}],
|
|
@@ -11,6 +11,7 @@ const makeLnd = overrides => {
|
|
|
11
11
|
block_height: 1,
|
|
12
12
|
dest_addresses: ['address'],
|
|
13
13
|
num_confirmations: 1,
|
|
14
|
+
previous_outpoints: [],
|
|
14
15
|
raw_tx_hex: '00',
|
|
15
16
|
time_stamp: '1',
|
|
16
17
|
total_fees: '1',
|
|
@@ -95,6 +96,7 @@ const tests = [
|
|
|
95
96
|
description: undefined,
|
|
96
97
|
fee: 1,
|
|
97
98
|
id: '0000000000000000000000000000000000000000000000000000000000000000',
|
|
99
|
+
inputs: [],
|
|
98
100
|
is_confirmed: true,
|
|
99
101
|
is_outgoing: false,
|
|
100
102
|
output_addresses: ['address'],
|
|
@@ -38,13 +38,6 @@ const tests = [
|
|
|
38
38
|
description: 'A transaction id is required to unlock a utxo',
|
|
39
39
|
error: [400, 'ExpectedTransactionOutputIndexToUnlockUtxo'],
|
|
40
40
|
},
|
|
41
|
-
{
|
|
42
|
-
args: makeArgs({
|
|
43
|
-
lnd: {wallet: {releaseOutput: ({}, cbk) => cbk({details: 'unknown'})}},
|
|
44
|
-
}),
|
|
45
|
-
description: 'LND unknown service errors are returned',
|
|
46
|
-
error: [501, 'BackingLndDoesNotSupportUnlockingUtxos'],
|
|
47
|
-
},
|
|
48
41
|
{
|
|
49
42
|
args: makeArgs({lnd: {wallet: {releaseOutput: ({}, cbk) => cbk('err')}}}),
|
|
50
43
|
description: 'LND errors are returned',
|
|
@@ -49,7 +49,6 @@ const makeInput = overrides => {
|
|
|
49
49
|
}],
|
|
50
50
|
settle_date: '1',
|
|
51
51
|
settle_index: '1',
|
|
52
|
-
settled: false,
|
|
53
52
|
state: 'STATE',
|
|
54
53
|
value: '1',
|
|
55
54
|
value_msat: '1000',
|
|
@@ -179,11 +178,6 @@ const tests = [
|
|
|
179
178
|
description: 'Preimage is expected',
|
|
180
179
|
error: 'ExpectedPreimageInLookupInvoiceResponse',
|
|
181
180
|
},
|
|
182
|
-
{
|
|
183
|
-
args: makeInput({settled: undefined}),
|
|
184
|
-
description: 'Settled is expected',
|
|
185
|
-
error: 'ExpectedSettledStateInLookupInvoiceResponse',
|
|
186
|
-
},
|
|
187
181
|
{
|
|
188
182
|
args: makeInput({value: undefined}),
|
|
189
183
|
description: 'Value is expected',
|
|
@@ -199,7 +193,7 @@ const tests = [
|
|
|
199
193
|
is_amp: true,
|
|
200
194
|
is_keysend: false,
|
|
201
195
|
payment_request: undefined,
|
|
202
|
-
|
|
196
|
+
state: 'SETTLED',
|
|
203
197
|
}),
|
|
204
198
|
description: 'AMP invoice mapped to invoice',
|
|
205
199
|
expected: makeExpected({
|
|
@@ -211,7 +205,7 @@ const tests = [
|
|
|
211
205
|
{
|
|
212
206
|
args: makeInput({
|
|
213
207
|
payment_request: undefined,
|
|
214
|
-
|
|
208
|
+
state: 'SETTLED',
|
|
215
209
|
value_msat: '0',
|
|
216
210
|
}),
|
|
217
211
|
description: 'Unsettled zero RPC invoice mapped to invoice',
|
|
@@ -9,6 +9,16 @@ const makeTx = override => {
|
|
|
9
9
|
block_height: 1,
|
|
10
10
|
dest_addresses: ['address'],
|
|
11
11
|
num_confirmations: 1,
|
|
12
|
+
previous_outpoints: [
|
|
13
|
+
{
|
|
14
|
+
is_our_output: true,
|
|
15
|
+
outpoint: `${Buffer.alloc(32).toString('hex')}:1`,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
is_our_output: true,
|
|
19
|
+
outpoint: `${Buffer.alloc(32, 1).toString('hex')}:1`,
|
|
20
|
+
},
|
|
21
|
+
],
|
|
12
22
|
raw_tx_hex: '00',
|
|
13
23
|
time_stamp: '1',
|
|
14
24
|
total_fees: '1',
|
|
@@ -56,6 +66,39 @@ const tests = [
|
|
|
56
66
|
description: 'Confirmation count is expected',
|
|
57
67
|
error: 'ExpectedChainTransactionConfirmationsCount',
|
|
58
68
|
},
|
|
69
|
+
{
|
|
70
|
+
args: makeTx({previous_outpoints: undefined}),
|
|
71
|
+
description: 'Previous outpoints are expected',
|
|
72
|
+
error: 'ExpectedArrayOfPreviousOutpointsInRpcTransaction',
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
args: makeTx({previous_outpoints: [{}]}),
|
|
76
|
+
description: 'An outpoint spend is expected',
|
|
77
|
+
error: 'ExpectedPreviousOutpointInRpcTransaction',
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
args: makeTx({previous_outpoints: [{outpoint: '00'}]}),
|
|
81
|
+
description: 'An outpoint with a tx id is expected',
|
|
82
|
+
error: 'ExpectedOutpointSpendingTransactionIdInRpcTx',
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
args: makeTx({
|
|
86
|
+
previous_outpoints: [{
|
|
87
|
+
outpoint: `${Buffer.alloc(32, 1).toString('hex')}`,
|
|
88
|
+
}],
|
|
89
|
+
}),
|
|
90
|
+
description: 'An outpoint with a tx vout is expected',
|
|
91
|
+
error: 'ExpectedOutpointSpendingTransactionVoutInRpcTx',
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
args: makeTx({
|
|
95
|
+
previous_outpoints: [{
|
|
96
|
+
outpoint: `${Buffer.alloc(32, 1).toString('hex')}:1`,
|
|
97
|
+
}],
|
|
98
|
+
}),
|
|
99
|
+
description: 'Local status for spend is expected',
|
|
100
|
+
error: 'ExpectedOutpointOwnershipBooleanInRpcTransaction',
|
|
101
|
+
},
|
|
59
102
|
{
|
|
60
103
|
args: makeTx({time_stamp: undefined}),
|
|
61
104
|
description: 'A time stamp is expected',
|
|
@@ -82,6 +125,11 @@ const tests = [
|
|
|
82
125
|
description: undefined,
|
|
83
126
|
fee: 1,
|
|
84
127
|
id: Buffer.alloc(32).toString('hex'),
|
|
128
|
+
inputs: [{
|
|
129
|
+
is_local: true,
|
|
130
|
+
transaction_id: '0101010101010101010101010101010101010101010101010101010101010101',
|
|
131
|
+
transaction_vout: 1,
|
|
132
|
+
}],
|
|
85
133
|
is_confirmed: true,
|
|
86
134
|
is_outgoing: false,
|
|
87
135
|
output_addresses: ['address'],
|
|
@@ -95,6 +143,7 @@ const tests = [
|
|
|
95
143
|
block_hash: '',
|
|
96
144
|
block_height: 0,
|
|
97
145
|
num_confirmations: 0,
|
|
146
|
+
previous_outpoints: [],
|
|
98
147
|
raw_tx_hex: '',
|
|
99
148
|
total_fees: '0',
|
|
100
149
|
}),
|
|
@@ -107,6 +156,7 @@ const tests = [
|
|
|
107
156
|
description: undefined,
|
|
108
157
|
fee: undefined,
|
|
109
158
|
id: Buffer.alloc(32).toString('hex'),
|
|
159
|
+
inputs: [],
|
|
110
160
|
is_confirmed: false,
|
|
111
161
|
is_outgoing: true,
|
|
112
162
|
output_addresses: ['address'],
|