lightning 10.16.1 → 10.18.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 +8 -2
- package/README.md +2 -0
- package/grpc/protos/walletkit.proto +3 -0
- package/index.js +2 -0
- package/lnd_methods/index.js +2 -0
- package/lnd_methods/onchain/get_minimum_relay_fee.js +66 -0
- package/lnd_methods/onchain/index.js +2 -0
- package/lnd_responses/rpc_fees_as_channel_fees.js +2 -0
- package/package.json +3 -3
- package/test/lnd_methods/onchain/test_get_minimum_relay_fee.js +71 -0
- package/test/lnd_responses/test_rpc_fees_as_channel_fees.js +17 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
# Versions
|
|
2
2
|
|
|
3
|
-
## 10.
|
|
3
|
+
## 10.18.0
|
|
4
|
+
|
|
5
|
+
- `getMinimumRelayFee`: Add method to get the chain backend minimum relay fee
|
|
6
|
+
|
|
7
|
+
## 10.17.0
|
|
4
8
|
|
|
5
9
|
- `getFeeRates`: Add support for `inbound_base_discount_mtokens`,
|
|
6
|
-
|
|
10
|
+
`inbound_rate_discount` for inbound fee policy discounts
|
|
11
|
+
|
|
12
|
+
## 10.16.1
|
|
7
13
|
|
|
8
14
|
- `getClosedChannels`: Add support for anchor resolution status via new
|
|
9
15
|
attributes `anchor_is_confirmed`, `anchor_is_pending`, `anchor_spent_by`,
|
package/README.md
CHANGED
|
@@ -201,6 +201,8 @@ variables set:
|
|
|
201
201
|
List out master seed derived extended public keys and derivation paths.
|
|
202
202
|
- [getMethods](https://github.com/alexbosworth/ln-service#getmethods): List RPC methods and
|
|
203
203
|
permissions required to use them.
|
|
204
|
+
- [getMinimumRelayFee](https://github.com/alexbosworth/ln-service#getminimumrelayfee):
|
|
205
|
+
Get the minimum relayable fee for publishing a chain transaction
|
|
204
206
|
- [getNetworkCentrality](https://github.com/alexbosworth/ln-service#getnetworkcentrality):
|
|
205
207
|
Calculate the graph centrality score of a node.
|
|
206
208
|
- [getNetworkGraph](https://github.com/alexbosworth/ln-service#getnetworkgraph): List all graph
|
|
@@ -839,6 +839,9 @@ message EstimateFeeResponse {
|
|
|
839
839
|
confirmation target in the request.
|
|
840
840
|
*/
|
|
841
841
|
int64 sat_per_kw = 1;
|
|
842
|
+
|
|
843
|
+
// The current minimum relay fee based on our chain backend in sat/kw.
|
|
844
|
+
int64 min_relay_fee_sat_per_kw = 2;
|
|
842
845
|
}
|
|
843
846
|
|
|
844
847
|
enum WitnessType {
|
package/index.js
CHANGED
|
@@ -61,6 +61,7 @@ const {getInvoices} = require('./lnd_methods');
|
|
|
61
61
|
const {getLockedUtxos} = require('./lnd_methods');
|
|
62
62
|
const {getMasterPublicKeys} = require('./lnd_methods');
|
|
63
63
|
const {getMethods} = require('./lnd_methods');
|
|
64
|
+
const {getMinimumRelayFee} = require('./lnd_methods');
|
|
64
65
|
const {getNetworkCentrality} = require('./lnd_methods');
|
|
65
66
|
const {getNetworkGraph} = require('./lnd_methods');
|
|
66
67
|
const {getNetworkInfo} = require('./lnd_methods');
|
|
@@ -221,6 +222,7 @@ module.exports = {
|
|
|
221
222
|
getLockedUtxos,
|
|
222
223
|
getMasterPublicKeys,
|
|
223
224
|
getMethods,
|
|
225
|
+
getMinimumRelayFee,
|
|
224
226
|
getNetworkCentrality,
|
|
225
227
|
getNetworkGraph,
|
|
226
228
|
getNetworkInfo,
|
package/lnd_methods/index.js
CHANGED
|
@@ -60,6 +60,7 @@ const {getInvoices} = require('./invoices');
|
|
|
60
60
|
const {getLockedUtxos} = require('./onchain');
|
|
61
61
|
const {getMasterPublicKeys} = require('./onchain');
|
|
62
62
|
const {getMethods} = require('./info');
|
|
63
|
+
const {getMinimumRelayFee} = require('./onchain');
|
|
63
64
|
const {getNetworkCentrality} = require('./info');
|
|
64
65
|
const {getNetworkGraph} = require('./info');
|
|
65
66
|
const {getNetworkInfo} = require('./info');
|
|
@@ -219,6 +220,7 @@ module.exports = {
|
|
|
219
220
|
getLockedUtxos,
|
|
220
221
|
getMasterPublicKeys,
|
|
221
222
|
getMethods,
|
|
223
|
+
getMinimumRelayFee,
|
|
222
224
|
getNetworkCentrality,
|
|
223
225
|
getNetworkGraph,
|
|
224
226
|
getNetworkInfo,
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
const asyncAuto = require('async/auto');
|
|
2
|
+
const {returnResult} = require('asyncjs-util');
|
|
3
|
+
|
|
4
|
+
const {isLnd} = require('./../../lnd_requests');
|
|
5
|
+
|
|
6
|
+
const method = 'estimateFee';
|
|
7
|
+
const target = 6;
|
|
8
|
+
const type = 'wallet';
|
|
9
|
+
const weightPerKWeight = 1e3;
|
|
10
|
+
const weightPerVByte = 4;
|
|
11
|
+
|
|
12
|
+
/** Get the current minimum relay fee for the chain backend
|
|
13
|
+
|
|
14
|
+
Requires LND built with `walletrpc` tag
|
|
15
|
+
|
|
16
|
+
Requires `onchain:read` permission
|
|
17
|
+
|
|
18
|
+
This method is not supported on LND 0.18.2 and below
|
|
19
|
+
|
|
20
|
+
{
|
|
21
|
+
lnd: <Authenticated LND API Object>
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@returns via cbk or Promise
|
|
25
|
+
{
|
|
26
|
+
tokens_per_vbyte: <Minimum Relayable Tokens Per Virtual Byte Number>
|
|
27
|
+
}
|
|
28
|
+
*/
|
|
29
|
+
module.exports = (args, cbk) => {
|
|
30
|
+
return new Promise((resolve, reject) => {
|
|
31
|
+
return asyncAuto({
|
|
32
|
+
// Check arguments
|
|
33
|
+
validate: cbk => {
|
|
34
|
+
if (!isLnd({method, type, lnd: args.lnd})) {
|
|
35
|
+
return cbk([400, 'ExpecteAuthenticatedLndToGetMinRelayFeeRate']);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return cbk();
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
// Get the minimum relayable fee rate
|
|
42
|
+
getRate: ['validate', ({}, cbk) => {
|
|
43
|
+
return args.lnd[type][method]({conf_target: target}, (err, res) => {
|
|
44
|
+
if (!!err) {
|
|
45
|
+
return cbk([503, 'UnexpectedErrorGettingMinRateFromLnd', {err}]);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (!res) {
|
|
49
|
+
return cbk([503, 'ExpectedResponseForMinFeeRateRequest']);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (!res.min_relay_fee_sat_per_kw) {
|
|
53
|
+
return cbk([503, 'ExpectedMinPerKwResponseForMinFeeRateRequest']);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const minPerKw = Number(res.min_relay_fee_sat_per_kw);
|
|
57
|
+
|
|
58
|
+
const minPerVbyte = minPerKw * weightPerVByte / weightPerKWeight;
|
|
59
|
+
|
|
60
|
+
return cbk(null, {tokens_per_vbyte: minPerVbyte});
|
|
61
|
+
});
|
|
62
|
+
}],
|
|
63
|
+
},
|
|
64
|
+
returnResult({reject, resolve, of: 'getRate'}, cbk));
|
|
65
|
+
});
|
|
66
|
+
};
|
|
@@ -15,6 +15,7 @@ const getChainTransaction = require('./get_chain_transaction');
|
|
|
15
15
|
const getChainTransactions = require('./get_chain_transactions');
|
|
16
16
|
const getLockedUtxos = require('./get_locked_utxos');
|
|
17
17
|
const getMasterPublicKeys = require('./get_master_public_keys');
|
|
18
|
+
const getMinimumRelayFee = require('./get_minimum_relay_fee');
|
|
18
19
|
const getPendingChainBalance = require('./get_pending_chain_balance');
|
|
19
20
|
const getPendingSweeps = require('./get_pending_sweeps');
|
|
20
21
|
const getSweepTransactions = require('./get_sweep_transactions');
|
|
@@ -59,6 +60,7 @@ module.exports = {
|
|
|
59
60
|
getChainTransactions,
|
|
60
61
|
getLockedUtxos,
|
|
61
62
|
getMasterPublicKeys,
|
|
63
|
+
getMinimumRelayFee,
|
|
62
64
|
getPendingChainBalance,
|
|
63
65
|
getPendingSweeps,
|
|
64
66
|
getSweepTransactions,
|
|
@@ -15,6 +15,8 @@ const outpointDivider = ':';
|
|
|
15
15
|
chan_id: <Numeric Format Channel Id String>
|
|
16
16
|
channel_point: <Channel Funding Outpoint String>
|
|
17
17
|
fee_per_mil: <Millitokens Per Million Fee Rate String>
|
|
18
|
+
inbound_base_fee_msat: <Inbound Base Fee Millitokens Number>
|
|
19
|
+
inbound_fee_per_mil: <Inbound Fee Rate PPM Number>
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
@returns
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@grpc/grpc-js": "1.11.1",
|
|
11
11
|
"@grpc/proto-loader": "0.7.13",
|
|
12
|
-
"@types/node": "22.
|
|
12
|
+
"@types/node": "22.2.0",
|
|
13
13
|
"@types/request": "2.48.12",
|
|
14
14
|
"@types/ws": "8.5.12",
|
|
15
15
|
"async": "3.2.5",
|
|
@@ -22,7 +22,7 @@
|
|
|
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.24.0"
|
|
26
26
|
},
|
|
27
27
|
"description": "Lightning Network client library",
|
|
28
28
|
"devDependencies": {
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"directory": "test/typescript"
|
|
54
54
|
},
|
|
55
55
|
"types": "index.d.ts",
|
|
56
|
-
"version": "10.
|
|
56
|
+
"version": "10.18.0"
|
|
57
57
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const {rejects} = require('node:assert').strict;
|
|
2
|
+
const {strictEqual} = require('node:assert').strict;
|
|
3
|
+
const test = require('node:test');
|
|
4
|
+
|
|
5
|
+
const {getMinimumRelayFee} = require('./../../../lnd_methods');
|
|
6
|
+
|
|
7
|
+
const tests = [
|
|
8
|
+
{
|
|
9
|
+
args: {},
|
|
10
|
+
description: 'LND is required',
|
|
11
|
+
error: [400, 'ExpecteAuthenticatedLndToGetMinRelayFeeRate'],
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
args: {lnd: {}},
|
|
15
|
+
description: 'LND with wallet object is required',
|
|
16
|
+
error: [400, 'ExpecteAuthenticatedLndToGetMinRelayFeeRate'],
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
args: {lnd: {wallet: {}}},
|
|
20
|
+
description: 'LND with estimateFee method is required',
|
|
21
|
+
error: [400, 'ExpecteAuthenticatedLndToGetMinRelayFeeRate'],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
args: {
|
|
25
|
+
lnd: {wallet: {estimateFee: ({}, cbk) => cbk('err')}},
|
|
26
|
+
},
|
|
27
|
+
description: 'Unexpected errors are passed back',
|
|
28
|
+
error: [503, 'UnexpectedErrorGettingMinRateFromLnd', {err: 'err'}],
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
args: {
|
|
32
|
+
lnd: {wallet: {estimateFee: ({}, cbk) => cbk()}},
|
|
33
|
+
},
|
|
34
|
+
description: 'A response is expected',
|
|
35
|
+
error: [503, 'ExpectedResponseForMinFeeRateRequest'],
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
args: {
|
|
39
|
+
lnd: {wallet: {estimateFee: ({}, cbk) => cbk(null, {})}},
|
|
40
|
+
},
|
|
41
|
+
description: 'A response is expected',
|
|
42
|
+
error: [503, 'ExpectedMinPerKwResponseForMinFeeRateRequest'],
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
args: {
|
|
46
|
+
lnd: {
|
|
47
|
+
wallet: {
|
|
48
|
+
estimateFee: ({}, cbk) => cbk(null, {
|
|
49
|
+
min_relay_fee_sat_per_kw: '250',
|
|
50
|
+
}),
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
description: 'Minimum tokens per vbyte are returned',
|
|
55
|
+
expected: {tokens_per_vbyte: 1},
|
|
56
|
+
},
|
|
57
|
+
];
|
|
58
|
+
|
|
59
|
+
tests.forEach(({args, description, error, expected}) => {
|
|
60
|
+
return test(description, async () => {
|
|
61
|
+
if (!!error) {
|
|
62
|
+
await rejects(getMinimumRelayFee(args), error, 'Got expected error');
|
|
63
|
+
} else {
|
|
64
|
+
const res = await getMinimumRelayFee(args);
|
|
65
|
+
|
|
66
|
+
strictEqual(res.tokens_per_vbyte, expected.tokens_per_vbyte, 'Got rate');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return;
|
|
70
|
+
});
|
|
71
|
+
});
|
|
@@ -72,6 +72,23 @@ const tests = [
|
|
|
72
72
|
transaction_vout: 0,
|
|
73
73
|
},
|
|
74
74
|
},
|
|
75
|
+
{
|
|
76
|
+
args: makeArgs({
|
|
77
|
+
inbound_base_fee_msat: -1,
|
|
78
|
+
inbound_fee_per_mil: -1,
|
|
79
|
+
}),
|
|
80
|
+
description: 'RPC channel fees are mapped to inverse channel fees',
|
|
81
|
+
expected: {
|
|
82
|
+
base_fee: 0,
|
|
83
|
+
base_fee_mtokens: '1',
|
|
84
|
+
fee_rate: 0,
|
|
85
|
+
id: '0x0x1',
|
|
86
|
+
inbound_base_discount_mtokens: '1',
|
|
87
|
+
inbound_rate_discount: 1,
|
|
88
|
+
transaction_id: Buffer.alloc(32).toString('hex'),
|
|
89
|
+
transaction_vout: 0,
|
|
90
|
+
},
|
|
91
|
+
},
|
|
75
92
|
];
|
|
76
93
|
|
|
77
94
|
tests.forEach(({args, description, error, expected}) => {
|