lightning 10.8.1 → 10.9.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 +10 -0
- package/grpc/protos/lightning.proto +44 -2
- package/grpc/protos/walletkit.proto +6 -0
- package/lnd_methods/offchain/subscribe_to_pay.js +39 -1
- package/lnd_methods/onchain/fund_psbt.js +7 -0
- package/lnd_methods/onchain/get_chain_fee_estimate.js +7 -0
- package/lnd_methods/onchain/send_to_chain_address.js +7 -0
- package/lnd_methods/onchain/send_to_chain_addresses.js +7 -0
- package/lnd_methods/onchain/send_to_chain_output_scripts.js +8 -1
- package/package.json +7 -7
- package/test/lnd_methods/onchain/test_fund_psbt.js +5 -0
- package/test/lnd_methods/onchain/test_get_chain_fee_estimate.js +18 -0
- package/test/lnd_methods/onchain/test_send_to_chain_address.js +11 -0
- package/test/lnd_methods/onchain/test_send_to_chain_addresses.js +11 -0
- package/test/lnd_methods/onchain/test_send_to_chain_output_scripts.js +12 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Versions
|
|
2
2
|
|
|
3
|
+
## 10.9.0
|
|
4
|
+
|
|
5
|
+
- `fundPsbt`, `getChainFeeEstimate`, `sendToChainAddress`,
|
|
6
|
+
`sendToChainAddresses`, `sendToChainOutputScripts`: Add `utxo_selection` to
|
|
7
|
+
specify preferred coin selection behavior.
|
|
8
|
+
|
|
9
|
+
## 10.8.2
|
|
10
|
+
|
|
11
|
+
- `pay` and payment via request methods: disallow features 30/31 from payments
|
|
12
|
+
|
|
3
13
|
## 10.8.1
|
|
4
14
|
|
|
5
15
|
- `removeAdvertisedFeature`: Add method to remove a feature bit support ad
|
|
@@ -1091,6 +1091,18 @@ message LightningAddress {
|
|
|
1091
1091
|
string host = 2;
|
|
1092
1092
|
}
|
|
1093
1093
|
|
|
1094
|
+
enum CoinSelectionStrategy {
|
|
1095
|
+
// Use the coin selection strategy defined in the global configuration
|
|
1096
|
+
// (lnd.conf).
|
|
1097
|
+
STRATEGY_USE_GLOBAL_CONFIG = 0;
|
|
1098
|
+
|
|
1099
|
+
// Select the largest available coins first during coin selection.
|
|
1100
|
+
STRATEGY_LARGEST = 1;
|
|
1101
|
+
|
|
1102
|
+
// Randomly select the available coins during coin selection.
|
|
1103
|
+
STRATEGY_RANDOM = 2;
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1094
1106
|
message EstimateFeeRequest {
|
|
1095
1107
|
// The map from addresses to amounts for the transaction.
|
|
1096
1108
|
map<string, int64> AddrToAmount = 1;
|
|
@@ -1105,6 +1117,9 @@ message EstimateFeeRequest {
|
|
|
1105
1117
|
|
|
1106
1118
|
// Whether unconfirmed outputs should be used as inputs for the transaction.
|
|
1107
1119
|
bool spend_unconfirmed = 4;
|
|
1120
|
+
|
|
1121
|
+
// The strategy to use for selecting coins during fees estimation.
|
|
1122
|
+
CoinSelectionStrategy coin_selection_strategy = 5;
|
|
1108
1123
|
}
|
|
1109
1124
|
|
|
1110
1125
|
message EstimateFeeResponse {
|
|
@@ -1145,6 +1160,9 @@ message SendManyRequest {
|
|
|
1145
1160
|
|
|
1146
1161
|
// Whether unconfirmed outputs should be used as inputs for the transaction.
|
|
1147
1162
|
bool spend_unconfirmed = 8;
|
|
1163
|
+
|
|
1164
|
+
// The strategy to use for selecting coins during sending many requests.
|
|
1165
|
+
CoinSelectionStrategy coin_selection_strategy = 9;
|
|
1148
1166
|
}
|
|
1149
1167
|
message SendManyResponse {
|
|
1150
1168
|
// The id of the transaction
|
|
@@ -1187,6 +1205,9 @@ message SendCoinsRequest {
|
|
|
1187
1205
|
|
|
1188
1206
|
// Whether unconfirmed outputs should be used as inputs for the transaction.
|
|
1189
1207
|
bool spend_unconfirmed = 9;
|
|
1208
|
+
|
|
1209
|
+
// The strategy to use for selecting coins.
|
|
1210
|
+
CoinSelectionStrategy coin_selection_strategy = 10;
|
|
1190
1211
|
}
|
|
1191
1212
|
message SendCoinsResponse {
|
|
1192
1213
|
// The transaction ID of the transaction
|
|
@@ -2115,6 +2136,9 @@ message BatchOpenChannelRequest {
|
|
|
2115
2136
|
|
|
2116
2137
|
// An optional label for the batch transaction, limited to 500 characters.
|
|
2117
2138
|
string label = 6;
|
|
2139
|
+
|
|
2140
|
+
// The strategy to use for selecting coins during batch opening channels.
|
|
2141
|
+
CoinSelectionStrategy coin_selection_strategy = 7;
|
|
2118
2142
|
}
|
|
2119
2143
|
|
|
2120
2144
|
message BatchOpenChannel {
|
|
@@ -3330,6 +3354,9 @@ message RoutingPolicy {
|
|
|
3330
3354
|
|
|
3331
3355
|
// Custom channel update tlv records.
|
|
3332
3356
|
map<uint64, bytes> custom_records = 8;
|
|
3357
|
+
|
|
3358
|
+
int32 inbound_fee_base_msat = 9;
|
|
3359
|
+
int32 inbound_fee_rate_milli_msat = 10;
|
|
3333
3360
|
}
|
|
3334
3361
|
|
|
3335
3362
|
/*
|
|
@@ -3545,8 +3572,11 @@ message BlindedPaymentPath {
|
|
|
3545
3572
|
// The base fee for the blinded path provided, expressed in msat.
|
|
3546
3573
|
uint64 base_fee_msat = 2;
|
|
3547
3574
|
|
|
3548
|
-
|
|
3549
|
-
|
|
3575
|
+
/*
|
|
3576
|
+
The proportional fee for the blinded path provided, expressed in parts
|
|
3577
|
+
per million.
|
|
3578
|
+
*/
|
|
3579
|
+
uint32 proportional_fee_rate = 3;
|
|
3550
3580
|
|
|
3551
3581
|
/*
|
|
3552
3582
|
The total CLTV delta for the blinded path provided, including the
|
|
@@ -4306,7 +4336,15 @@ message ChannelFeeReport {
|
|
|
4306
4336
|
// The effective fee rate in milli-satoshis. Computed by dividing the
|
|
4307
4337
|
// fee_per_mil value by 1 million.
|
|
4308
4338
|
double fee_rate = 4;
|
|
4339
|
+
|
|
4340
|
+
// The base fee charged regardless of the number of milli-satoshis sent.
|
|
4341
|
+
int32 inbound_base_fee_msat = 6;
|
|
4342
|
+
|
|
4343
|
+
// The amount charged per milli-satoshis transferred expressed in
|
|
4344
|
+
// millionths of a satoshi.
|
|
4345
|
+
int32 inbound_fee_per_mil = 7;
|
|
4309
4346
|
}
|
|
4347
|
+
|
|
4310
4348
|
message FeeReportResponse {
|
|
4311
4349
|
// An array of channel fee reports which describes the current fee schedule
|
|
4312
4350
|
// for each channel.
|
|
@@ -4357,7 +4395,11 @@ message PolicyUpdateRequest {
|
|
|
4357
4395
|
|
|
4358
4396
|
// If true, min_htlc_msat is applied.
|
|
4359
4397
|
bool min_htlc_msat_specified = 8;
|
|
4398
|
+
|
|
4399
|
+
int32 inbound_base_fee_msat = 10;
|
|
4400
|
+
int32 inbound_fee_rate_ppm = 11;
|
|
4360
4401
|
}
|
|
4402
|
+
|
|
4361
4403
|
enum UpdateFailure {
|
|
4362
4404
|
UPDATE_FAILURE_UNKNOWN = 0;
|
|
4363
4405
|
UPDATE_FAILURE_PENDING = 1;
|
|
@@ -813,6 +813,9 @@ message SendOutputsRequest {
|
|
|
813
813
|
|
|
814
814
|
// Whether unconfirmed outputs should be used as inputs for the transaction.
|
|
815
815
|
bool spend_unconfirmed = 5;
|
|
816
|
+
|
|
817
|
+
// The strategy to use for selecting coins during sending the outputs.
|
|
818
|
+
lnrpc.CoinSelectionStrategy coin_selection_strategy = 6;
|
|
816
819
|
}
|
|
817
820
|
message SendOutputsResponse {
|
|
818
821
|
/*
|
|
@@ -1308,6 +1311,9 @@ message FundPsbtRequest {
|
|
|
1308
1311
|
// accounts, no change type should be provided as the coin selection key
|
|
1309
1312
|
// scope will always be used to generate the change address.
|
|
1310
1313
|
ChangeAddressType change_type = 8;
|
|
1314
|
+
|
|
1315
|
+
// The strategy to use for selecting coins during funding the PSBT.
|
|
1316
|
+
lnrpc.CoinSelectionStrategy coin_selection_strategy = 10;
|
|
1311
1317
|
}
|
|
1312
1318
|
message FundPsbtResponse {
|
|
1313
1319
|
/*
|
|
@@ -4,6 +4,7 @@ const EventEmitter = require('events');
|
|
|
4
4
|
const asyncAuto = require('async/auto');
|
|
5
5
|
const {chanFormat} = require('bolt07');
|
|
6
6
|
const {chanNumber} = require('bolt07');
|
|
7
|
+
const {parsePaymentRequest} = require('invoices');
|
|
7
8
|
|
|
8
9
|
const {confirmedFromPayment} = require('./../../lnd_responses');
|
|
9
10
|
const {confirmedFromPaymentStatus} = require('./../../lnd_responses');
|
|
@@ -37,6 +38,7 @@ const {round} = Math;
|
|
|
37
38
|
const sha256 = preimage => createHash('sha256').update(preimage).digest();
|
|
38
39
|
const type = 'router';
|
|
39
40
|
const unknownServiceErr = 'unknown service verrpc.Versioner';
|
|
41
|
+
const unsupportedFeatures = [30, 31];
|
|
40
42
|
|
|
41
43
|
/** Initiate and subscribe to the outcome of a payment
|
|
42
44
|
|
|
@@ -252,6 +254,14 @@ module.exports = args => {
|
|
|
252
254
|
throw new Error('ExpectedTokenAmountToPayWhenPaymentRequestNotSpecified');
|
|
253
255
|
}
|
|
254
256
|
|
|
257
|
+
if (!!args.request) {
|
|
258
|
+
try {
|
|
259
|
+
parsePaymentRequest({request: args.request});
|
|
260
|
+
} catch (err) {
|
|
261
|
+
throw new Error('ExpectedValidPaymentRequestToMakePayment');
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
255
265
|
if (!!args.routes && !isArray(args.routes)) {
|
|
256
266
|
throw new Error('UnexpectedFormatForRoutesWhenSubscribingToPayment');
|
|
257
267
|
}
|
|
@@ -296,6 +306,23 @@ module.exports = args => {
|
|
|
296
306
|
const finalCltv = !args.cltv_delta ? defaultCltvDelta : args.cltv_delta;
|
|
297
307
|
|
|
298
308
|
asyncAuto({
|
|
309
|
+
// Determine what features would be used with the payment
|
|
310
|
+
featureBits: cbk => {
|
|
311
|
+
// Exit early when there are no features to look at
|
|
312
|
+
if (!args.features && !args.request) {
|
|
313
|
+
return cbk(null, []);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// Exit early when feature bits are specified directly
|
|
317
|
+
if (!!features) {
|
|
318
|
+
return cbk(null, features);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
const request = parsePaymentRequest({request: args.request});
|
|
322
|
+
|
|
323
|
+
return cbk(null, request.features.map(n => n.bit));
|
|
324
|
+
},
|
|
325
|
+
|
|
299
326
|
// Determine the block height to figure out the height delta
|
|
300
327
|
getHeight: cbk => {
|
|
301
328
|
// Exit early when there is no max timeout restriction
|
|
@@ -325,6 +352,17 @@ module.exports = args => {
|
|
|
325
352
|
}));
|
|
326
353
|
},
|
|
327
354
|
|
|
355
|
+
// Validate the payment request features
|
|
356
|
+
checkFeatures: ['featureBits', ({featureBits}, cbk) => {
|
|
357
|
+
const bit = featureBits.find(n => unsupportedFeatures.includes(n));
|
|
358
|
+
|
|
359
|
+
if (!!bit) {
|
|
360
|
+
return cbk([501, 'UnsupportedPaymentFeatureInPayRequest', {bit}]);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
return cbk();
|
|
364
|
+
}],
|
|
365
|
+
|
|
328
366
|
// Determine the maximum CLTV delta
|
|
329
367
|
maxCltvDelta: ['getHeight', ({getHeight}, cbk) => {
|
|
330
368
|
if (!args.max_timeout_height) {
|
|
@@ -394,7 +432,7 @@ module.exports = args => {
|
|
|
394
432
|
}],
|
|
395
433
|
|
|
396
434
|
// Send payment
|
|
397
|
-
send: ['params', ({params}, cbk) => {
|
|
435
|
+
send: ['checkFeatures', 'params', ({params}, cbk) => {
|
|
398
436
|
const sub = args.lnd.router.sendPaymentV2(params);
|
|
399
437
|
|
|
400
438
|
sub.on('data', data => emitPayment({data, emitter}));
|
|
@@ -16,6 +16,7 @@ const {isArray} = Array;
|
|
|
16
16
|
const {isBuffer} = Buffer;
|
|
17
17
|
const method = 'fundPsbt';
|
|
18
18
|
const notSupported = /unknown.*walletrpc.WalletKit/;
|
|
19
|
+
const strategy = type => !type ? undefined : `STRATEGY_${type.toUpperCase()}`;
|
|
19
20
|
const type = 'wallet';
|
|
20
21
|
const txIdFromBuffer = buffer => buffer.slice().reverse().toString('hex');
|
|
21
22
|
const txIdFromHash = hash => hash.reverse().toString('hex');
|
|
@@ -26,6 +27,8 @@ const txIdFromHash = hash => hash.reverse().toString('hex');
|
|
|
26
27
|
|
|
27
28
|
If there are no inputs passed, internal UTXOs will be selected and locked
|
|
28
29
|
|
|
30
|
+
`utxo_selection` methods: 'largest', 'random'
|
|
31
|
+
|
|
29
32
|
Requires `onchain:write` permission
|
|
30
33
|
|
|
31
34
|
Requires LND built with `walletrpc` tag
|
|
@@ -34,6 +37,8 @@ const txIdFromHash = hash => hash.reverse().toString('hex');
|
|
|
34
37
|
|
|
35
38
|
Specifying 0 for `min_confirmations` is not supported in LND 0.13.0 and below
|
|
36
39
|
|
|
40
|
+
`utxo_selection` is not supported in LND 0.17.4 and below
|
|
41
|
+
|
|
37
42
|
{
|
|
38
43
|
[fee_tokens_per_vbyte]: <Chain Fee Tokens Per Virtual Byte Number>
|
|
39
44
|
[inputs]: [{
|
|
@@ -48,6 +53,7 @@ const txIdFromHash = hash => hash.reverse().toString('hex');
|
|
|
48
53
|
}]
|
|
49
54
|
[target_confirmations]: <Confirmations To Wait Number>
|
|
50
55
|
[psbt]: <Existing PSBT Hex String>
|
|
56
|
+
[utxo_selection]: <Select UTXOs Using Method String>
|
|
51
57
|
}
|
|
52
58
|
|
|
53
59
|
@returns via cbk or Promise
|
|
@@ -158,6 +164,7 @@ module.exports = (args, cbk) => {
|
|
|
158
164
|
fund: ['fee', 'funding', 'minConfs', ({fee, funding, minConfs}, cbk) => {
|
|
159
165
|
return args.lnd[type][method]({
|
|
160
166
|
change_type: defaultChangeType,
|
|
167
|
+
coin_selection_strategy: strategy(args.utxo_selection),
|
|
161
168
|
min_confs: minConfs !== undefined ? minConfs : undefined,
|
|
162
169
|
psbt: !!args.psbt ? Buffer.from(args.psbt, 'hex') : undefined,
|
|
163
170
|
raw: funding || undefined,
|
|
@@ -7,15 +7,20 @@ const hasNumber = n => !!n && n !== '0';
|
|
|
7
7
|
const {isArray} = Array;
|
|
8
8
|
const method = 'estimateFee';
|
|
9
9
|
const notFound = -1;
|
|
10
|
+
const strategy = type => !type ? undefined : `STRATEGY_${type.toUpperCase()}`;
|
|
10
11
|
const type = 'default';
|
|
11
12
|
const unconfirmedConfCount = 0;
|
|
12
13
|
|
|
13
14
|
/** Get a chain fee estimate for a prospective chain send
|
|
14
15
|
|
|
16
|
+
`utxo_selection` methods: 'largest', 'random'
|
|
17
|
+
|
|
15
18
|
Requires `onchain:read` permission
|
|
16
19
|
|
|
17
20
|
Specifying 0 for `utxo_confirmations` is not supported in LND 0.13.0 or below
|
|
18
21
|
|
|
22
|
+
`utxo_selection` is not supported in LND 0.17.4 and below
|
|
23
|
+
|
|
19
24
|
{
|
|
20
25
|
lnd: <Authenticated LND API Object>
|
|
21
26
|
send_to: [{
|
|
@@ -24,6 +29,7 @@ const unconfirmedConfCount = 0;
|
|
|
24
29
|
}]
|
|
25
30
|
[target_confirmations]: <Target Confirmations Number>
|
|
26
31
|
[utxo_confirmations]: <Minimum Confirmations for UTXO Selection Number>
|
|
32
|
+
[utxo_selection]: <Select UTXOs Using Method String>
|
|
27
33
|
}
|
|
28
34
|
|
|
29
35
|
@returns via cbk or Promise
|
|
@@ -68,6 +74,7 @@ module.exports = (args, cbk) => {
|
|
|
68
74
|
|
|
69
75
|
return args.lnd[type][method]({
|
|
70
76
|
AddrToAmount,
|
|
77
|
+
coin_selection_strategy: strategy(args.utxo_selection),
|
|
71
78
|
target_conf: args.target_confirmations || undefined,
|
|
72
79
|
min_confs: args.utxo_confirmations || undefined,
|
|
73
80
|
spend_unconfirmed: args.utxo_confirmations === unconfirmedConfCount,
|
|
@@ -9,16 +9,21 @@ const {isInteger} = Number;
|
|
|
9
9
|
const lowBalanceErr = 'insufficient funds available to construct transaction';
|
|
10
10
|
const method = 'sendCoins';
|
|
11
11
|
const OPEN = 1;
|
|
12
|
+
const strategy = type => !type ? undefined : `STRATEGY_${type.toUpperCase()}`;
|
|
12
13
|
const {stringify} = JSON;
|
|
13
14
|
const type = 'default';
|
|
14
15
|
const unconfirmedConfCount = 0;
|
|
15
16
|
|
|
16
17
|
/** Send tokens in a blockchain transaction.
|
|
17
18
|
|
|
19
|
+
`utxo_selection` methods: 'largest', 'random'
|
|
20
|
+
|
|
18
21
|
Requires `onchain:write` permission
|
|
19
22
|
|
|
20
23
|
`utxo_confirmations` is not supported on LND 0.11.1 or below
|
|
21
24
|
|
|
25
|
+
`utxo_selection` is not supported in LND 0.17.4 and below
|
|
26
|
+
|
|
22
27
|
{
|
|
23
28
|
address: <Destination Chain Address String>
|
|
24
29
|
[description]: <Transaction Label String>
|
|
@@ -29,6 +34,7 @@ const unconfirmedConfCount = 0;
|
|
|
29
34
|
[target_confirmations]: <Confirmations To Wait Number>
|
|
30
35
|
[tokens]: <Tokens To Send Number>
|
|
31
36
|
[utxo_confirmations]: <Minimum Confirmations for UTXO Selection Number>
|
|
37
|
+
[utxo_selection]: <Select UTXOs Using Method String>
|
|
32
38
|
[wss]: [<Web Socket Server Object>]
|
|
33
39
|
}
|
|
34
40
|
|
|
@@ -82,6 +88,7 @@ module.exports = (args, cbk) => {
|
|
|
82
88
|
return args.lnd.default.sendCoins({
|
|
83
89
|
addr: args.address,
|
|
84
90
|
amount: args.tokens || undefined,
|
|
91
|
+
coin_selection_strategy: strategy(args.utxo_selection),
|
|
85
92
|
min_confs: args.utxo_confirmations || undefined,
|
|
86
93
|
label: args.description || undefined,
|
|
87
94
|
sat_per_byte: args.fee_tokens_per_vbyte || undefined,
|
|
@@ -8,15 +8,20 @@ const {isArray} = Array;
|
|
|
8
8
|
const method = 'sendMany';
|
|
9
9
|
const OPEN = 1;
|
|
10
10
|
const unconfirmedConfCount = 0;
|
|
11
|
+
const strategy = type => !type ? undefined : `STRATEGY_${type.toUpperCase()}`;
|
|
11
12
|
const {stringify} = JSON;
|
|
12
13
|
const type = 'default';
|
|
13
14
|
|
|
14
15
|
/** Send tokens to multiple destinations in a blockchain transaction.
|
|
15
16
|
|
|
17
|
+
`utxo_selection` methods: 'largest', 'random'
|
|
18
|
+
|
|
16
19
|
Requires `onchain:write` permission
|
|
17
20
|
|
|
18
21
|
`utxo_confirmations` is not supported on LND 0.11.1 or below
|
|
19
22
|
|
|
23
|
+
`utxo_selection` is not supported in LND 0.17.4 and below
|
|
24
|
+
|
|
20
25
|
{
|
|
21
26
|
[description]: <Transaction Label String>
|
|
22
27
|
[fee_tokens_per_vbyte]: <Chain Fee Tokens Per Virtual Byte Number>
|
|
@@ -28,6 +33,7 @@ const type = 'default';
|
|
|
28
33
|
}]
|
|
29
34
|
[target_confirmations]: <Confirmations To Wait Number>
|
|
30
35
|
[utxo_confirmations]: <Minimum Confirmations for UTXO Selection Number>
|
|
36
|
+
[utxo_selection]: <Select UTXOs Using Method String>
|
|
31
37
|
[wss]: [<Web Socket Server Object>]
|
|
32
38
|
}
|
|
33
39
|
|
|
@@ -76,6 +82,7 @@ module.exports = (args, cbk) => {
|
|
|
76
82
|
|
|
77
83
|
const send = {
|
|
78
84
|
AddrToAmount,
|
|
85
|
+
coin_selection_strategy: strategy(args.utxo_selection),
|
|
79
86
|
label: args.description || undefined,
|
|
80
87
|
min_confs: args.utxo_confirmations || undefined,
|
|
81
88
|
sat_per_byte: args.fee_tokens_per_vbyte || undefined,
|
|
@@ -12,17 +12,22 @@ const {isArray} = Array;
|
|
|
12
12
|
const {isBuffer} = Buffer;
|
|
13
13
|
const method = 'sendOutputs';
|
|
14
14
|
const minFeeRate = 1;
|
|
15
|
-
const
|
|
15
|
+
const strategy = type => !type ? undefined : `STRATEGY_${type.toUpperCase()}`;
|
|
16
16
|
const type = 'wallet';
|
|
17
|
+
const unconfirmedConfCount = 0;
|
|
17
18
|
const weightPerKWeight = 1e3;
|
|
18
19
|
const weightPerVByte = 4;
|
|
19
20
|
|
|
20
21
|
/** Send on-chain funds to multiple output scripts
|
|
21
22
|
|
|
23
|
+
`utxo_selection` methods: 'largest', 'random'
|
|
24
|
+
|
|
22
25
|
Requires `onchain:write` permission
|
|
23
26
|
|
|
24
27
|
Requires LND compiled with `walletrpc` build tag
|
|
25
28
|
|
|
29
|
+
`utxo_selection` is not supported in LND 0.17.4 and below
|
|
30
|
+
|
|
26
31
|
{
|
|
27
32
|
[description]: <Transaction Label String>
|
|
28
33
|
[fee_tokens_per_vbyte]: <Chain Fee Tokens Per Virtual Byte Number>
|
|
@@ -32,6 +37,7 @@ const weightPerVByte = 4;
|
|
|
32
37
|
tokens: <Tokens Number>
|
|
33
38
|
}]
|
|
34
39
|
[utxo_confirmations]: <Minimum Confirmations for UTXO Selection Number>
|
|
40
|
+
[utxo_selection]: <Select UTXOs Using Method String>
|
|
35
41
|
}
|
|
36
42
|
|
|
37
43
|
@returns via cbk or Promise
|
|
@@ -66,6 +72,7 @@ module.exports = (args, cbk) => {
|
|
|
66
72
|
const feePerKw = feePerVByte * weightPerKWeight / weightPerVByte;
|
|
67
73
|
|
|
68
74
|
return args.lnd[type][method]({
|
|
75
|
+
coin_selection_strategy: strategy(args.utxo_selection),
|
|
69
76
|
label: args.description || undefined,
|
|
70
77
|
min_confs: args.utxo_confirmations || undefined,
|
|
71
78
|
outputs: args.send_to.map(output => ({
|
package/package.json
CHANGED
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
"url": "https://github.com/alexbosworth/lightning/issues"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@grpc/grpc-js": "1.10.
|
|
11
|
-
"@grpc/proto-loader": "0.7.
|
|
12
|
-
"@types/node": "20.
|
|
10
|
+
"@grpc/grpc-js": "1.10.6",
|
|
11
|
+
"@grpc/proto-loader": "0.7.12",
|
|
12
|
+
"@types/node": "20.12.7",
|
|
13
13
|
"@types/request": "2.48.12",
|
|
14
14
|
"@types/ws": "8.5.10",
|
|
15
15
|
"async": "3.2.5",
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
"invoices": "3.0.0",
|
|
23
23
|
"psbt": "3.0.0",
|
|
24
24
|
"tiny-secp256k1": "2.2.3",
|
|
25
|
-
"type-fest": "4.
|
|
25
|
+
"type-fest": "4.15.0"
|
|
26
26
|
},
|
|
27
27
|
"description": "Lightning Network client library",
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"tsd": "0.
|
|
30
|
-
"typescript": "5.4.
|
|
29
|
+
"tsd": "0.31.0",
|
|
30
|
+
"typescript": "5.4.5"
|
|
31
31
|
},
|
|
32
32
|
"engines": {
|
|
33
33
|
"node": ">=18"
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"directory": "test/typescript"
|
|
54
54
|
},
|
|
55
55
|
"types": "index.d.ts",
|
|
56
|
-
"version": "10.
|
|
56
|
+
"version": "10.9.0"
|
|
57
57
|
}
|
|
@@ -169,6 +169,11 @@ const tests = [
|
|
|
169
169
|
description: 'PSBT funding can specify conf target',
|
|
170
170
|
expected: makeExpected({}),
|
|
171
171
|
},
|
|
172
|
+
{
|
|
173
|
+
args: makeArgs({utxo_selection: 'largest'}),
|
|
174
|
+
description: 'PSBT funding can select largest coins',
|
|
175
|
+
expected: makeExpected({}),
|
|
176
|
+
},
|
|
172
177
|
];
|
|
173
178
|
|
|
174
179
|
tests.forEach(({args, description, error, expected}) => {
|
|
@@ -113,6 +113,24 @@ const tests = [
|
|
|
113
113
|
description: 'Sat per vbyte result is supported',
|
|
114
114
|
expected: {fee: 1, tokens_per_vbyte: 2},
|
|
115
115
|
},
|
|
116
|
+
{
|
|
117
|
+
args: {
|
|
118
|
+
lnd: {
|
|
119
|
+
default: {
|
|
120
|
+
estimateFee: ({}, cbk) => cbk(null, {
|
|
121
|
+
fee_sat: '1',
|
|
122
|
+
feerate_sat_per_byte: '1',
|
|
123
|
+
sat_per_vbyte: '2',
|
|
124
|
+
}),
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
send_to: [{address: 'address', tokens: 1}],
|
|
128
|
+
utxo_confirmations: 0,
|
|
129
|
+
utxo_selection: 'largest',
|
|
130
|
+
},
|
|
131
|
+
description: 'Coin selection can be specified',
|
|
132
|
+
expected: {fee: 1, tokens_per_vbyte: 2},
|
|
133
|
+
},
|
|
116
134
|
];
|
|
117
135
|
|
|
118
136
|
tests.forEach(({args, description, error, expected}) => {
|
|
@@ -146,6 +146,17 @@ const tests = [
|
|
|
146
146
|
tokens: 1,
|
|
147
147
|
},
|
|
148
148
|
},
|
|
149
|
+
{
|
|
150
|
+
args: makeArgs({utxo_selection: 'random'}),
|
|
151
|
+
description: 'Send coins with coin selection',
|
|
152
|
+
expected: {
|
|
153
|
+
confirmation_count: 0,
|
|
154
|
+
id: Buffer.alloc(32).toString('hex'),
|
|
155
|
+
is_confirmed: false,
|
|
156
|
+
is_outgoing: true,
|
|
157
|
+
tokens: 1,
|
|
158
|
+
},
|
|
159
|
+
},
|
|
149
160
|
];
|
|
150
161
|
|
|
151
162
|
tests.forEach(({args, description, error, expected}) => {
|
|
@@ -130,6 +130,17 @@ const tests = [
|
|
|
130
130
|
tokens: 1,
|
|
131
131
|
},
|
|
132
132
|
},
|
|
133
|
+
{
|
|
134
|
+
args: makeArgs({utxo_selection: 'random'}),
|
|
135
|
+
description: 'Send coins with coin selection',
|
|
136
|
+
expected: {
|
|
137
|
+
confirmation_count: 0,
|
|
138
|
+
id: Buffer.alloc(32).toString('hex'),
|
|
139
|
+
is_confirmed: false,
|
|
140
|
+
is_outgoing: true,
|
|
141
|
+
tokens: 1,
|
|
142
|
+
},
|
|
143
|
+
},
|
|
133
144
|
];
|
|
134
145
|
|
|
135
146
|
tests.forEach(({args, description, error, expected}) => {
|
|
@@ -61,6 +61,18 @@ const tests = [
|
|
|
61
61
|
transaction: '01000000000000000000',
|
|
62
62
|
},
|
|
63
63
|
},
|
|
64
|
+
{
|
|
65
|
+
args: makeArgs({utxo_selection: 'random'}),
|
|
66
|
+
description: 'Send coins with coin selection',
|
|
67
|
+
expected: {
|
|
68
|
+
confirmation_count: 0,
|
|
69
|
+
id: 'd21633ba23f70118185227be58a63527675641ad37967e2aa461559f577aec43',
|
|
70
|
+
is_confirmed: false,
|
|
71
|
+
is_outgoing: true,
|
|
72
|
+
tokens: 1,
|
|
73
|
+
transaction: '01000000000000000000',
|
|
74
|
+
},
|
|
75
|
+
},
|
|
64
76
|
];
|
|
65
77
|
|
|
66
78
|
tests.forEach(({args, description, error, expected}) => {
|