ln-service 57.22.2 → 57.23.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 -0
- package/README.md +31 -1
- package/index.js +2 -0
- package/package.json +4 -4
- package/test/routerrpc-integration/test_get_routing_fee_estimate.js +76 -0
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ through npm.
|
|
|
9
9
|
|
|
10
10
|
Supported LND versions:
|
|
11
11
|
|
|
12
|
-
- v0.18.0-beta to v0.18.
|
|
12
|
+
- v0.18.0-beta to v0.18.4-beta
|
|
13
13
|
- v0.17.0-beta to v0.17.5-beta
|
|
14
14
|
- v0.16.0-beta to v0.16.4-beta
|
|
15
15
|
- v0.15.2-beta to v0.15.5-beta
|
|
@@ -223,6 +223,7 @@ for `unlocker` methods.
|
|
|
223
223
|
- [getRouteConfidence](#getrouteconfidence) - Get confidence in a route
|
|
224
224
|
- [getRouteThroughHops](#getroutethroughhops) - Get a route through nodes
|
|
225
225
|
- [getRouteToDestination](#getroutetodestination) - Get a route to a destination
|
|
226
|
+
- [getRoutingFeeEstimate](#getroutingfeeestimate) - Get offchain fee estimate
|
|
226
227
|
- [getSettlementStatus](#getsettlementstatus) - Get status of a received HTLC
|
|
227
228
|
- [getSweepTransactions](#getsweeptransactions) - Get transactions sweeping to
|
|
228
229
|
self
|
|
@@ -3629,6 +3630,35 @@ const {route} = await getRouteToDestination({destination, lnd, tokens});
|
|
|
3629
3630
|
await payViaRoutes({lnd, routes: [route]});
|
|
3630
3631
|
```
|
|
3631
3632
|
|
|
3633
|
+
### getRoutingFeeEstimate
|
|
3634
|
+
|
|
3635
|
+
Estimate routing fees and timeout required to pay a payment request
|
|
3636
|
+
|
|
3637
|
+
Requires `offchain:read` permission
|
|
3638
|
+
|
|
3639
|
+
This method is not supported on LND 0.18.3 and below
|
|
3640
|
+
|
|
3641
|
+
{
|
|
3642
|
+
lnd: <Authenticated LND API Object>
|
|
3643
|
+
request: <BOLT 11 Payment Request String>
|
|
3644
|
+
[timeout]: <Maximum Route Pathfinding Time in Milliseconds Number>
|
|
3645
|
+
}
|
|
3646
|
+
|
|
3647
|
+
@returns via cbk or Promise
|
|
3648
|
+
{
|
|
3649
|
+
fee_mtokens: <Estimated Minimum Required Route Fee Millitokens String>
|
|
3650
|
+
timeout: <Estimated Minimum Time Lock Block Height Delay Number>
|
|
3651
|
+
}
|
|
3652
|
+
|
|
3653
|
+
Example:
|
|
3654
|
+
|
|
3655
|
+
```node
|
|
3656
|
+
const {getRoutingFeeEstimate} = require('ln-service');
|
|
3657
|
+
|
|
3658
|
+
// Get the minimum fee required to make an offchain payment to a request
|
|
3659
|
+
const minFeeMtok = (await getRoutingFeeEstimate({lnd, request})).fee_mtokens;
|
|
3660
|
+
```
|
|
3661
|
+
|
|
3632
3662
|
### getSettlementStatus
|
|
3633
3663
|
|
|
3634
3664
|
Get the settlement status of a received HTLC
|
package/index.js
CHANGED
|
@@ -80,6 +80,7 @@ const {getPublicKey} = require('lightning');
|
|
|
80
80
|
const {getRouteConfidence} = require('lightning');
|
|
81
81
|
const {getRouteThroughHops} = require('lightning');
|
|
82
82
|
const {getRouteToDestination} = require('lightning');
|
|
83
|
+
const {getRoutingFeeEstimate} = require('lightning');
|
|
83
84
|
const {getSettlementStatus} = require('lightning');
|
|
84
85
|
const {getSweepTransactions} = require('lightning');
|
|
85
86
|
const {getTowerServerInfo} = require('lightning');
|
|
@@ -246,6 +247,7 @@ module.exports = {
|
|
|
246
247
|
getRouteConfidence,
|
|
247
248
|
getRouteThroughHops,
|
|
248
249
|
getRouteToDestination,
|
|
250
|
+
getRoutingFeeEstimate,
|
|
249
251
|
getSettlementStatus,
|
|
250
252
|
getSweepTransactions,
|
|
251
253
|
getTowerServerInfo,
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"bolt07": "1.9.4",
|
|
11
11
|
"invoices": "3.0.0",
|
|
12
|
-
"lightning": "10.
|
|
12
|
+
"lightning": "10.23.0",
|
|
13
13
|
"macaroon": "3.0.4"
|
|
14
14
|
},
|
|
15
15
|
"description": "Interaction helper for your Lightning Network daemon",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"asyncjs-util": "1.2.12",
|
|
21
21
|
"bip32": "4.0.0",
|
|
22
22
|
"bip66": "2.0.0",
|
|
23
|
-
"bitcoinjs-lib": "6.1.
|
|
23
|
+
"bitcoinjs-lib": "6.1.7",
|
|
24
24
|
"bn.js": "5.2.1",
|
|
25
25
|
"bs58check": "4.0.0",
|
|
26
26
|
"ecpair": "2.1.0",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"psbt": "3.0.0",
|
|
31
31
|
"rimraf": "6.0.1",
|
|
32
32
|
"tiny-secp256k1": "2.2.3",
|
|
33
|
-
"uuid": "
|
|
33
|
+
"uuid": "11.0.3",
|
|
34
34
|
"varuint-bitcoin": "2.0.0"
|
|
35
35
|
},
|
|
36
36
|
"engines": {
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"integration-test-0.14.4": "DOCKER_LND_VERSION=v0.14.4-beta npm run test",
|
|
74
74
|
"test": "echo $DOCKER_LND_VERSION && node test/runner"
|
|
75
75
|
},
|
|
76
|
-
"version": "57.
|
|
76
|
+
"version": "57.23.0"
|
|
77
77
|
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const {equal} = require('node:assert').strict;
|
|
2
|
+
const test = require('node:test');
|
|
3
|
+
|
|
4
|
+
const asyncRetry = require('async/retry');
|
|
5
|
+
const {setupChannel} = require('ln-docker-daemons');
|
|
6
|
+
const {spawnLightningCluster} = require('ln-docker-daemons');
|
|
7
|
+
|
|
8
|
+
const {addPeer} = require('./../../');
|
|
9
|
+
const {createInvoice} = require('./../../');
|
|
10
|
+
const {getRoutingFeeEstimate} = require('./../../');
|
|
11
|
+
const {getWalletInfo} = require('./../../');
|
|
12
|
+
const {probeForRoute} = require('./../../');
|
|
13
|
+
const {waitForRoute} = require('./../macros');
|
|
14
|
+
|
|
15
|
+
const channelCapacityTokens = 1e6;
|
|
16
|
+
const interval = 50;
|
|
17
|
+
const size = 3;
|
|
18
|
+
const times = 9000;
|
|
19
|
+
const tokens = 1e6 / 2;
|
|
20
|
+
|
|
21
|
+
// Getting routing fee estimate should return required fee for a route
|
|
22
|
+
test('Get route confidence', async () => {
|
|
23
|
+
const {kill, nodes} = await spawnLightningCluster({size});
|
|
24
|
+
|
|
25
|
+
const [{generate, lnd}, target, remote] = nodes;
|
|
26
|
+
|
|
27
|
+
await asyncRetry({interval, times}, async () => {
|
|
28
|
+
const wallet = await getWalletInfo({lnd});
|
|
29
|
+
|
|
30
|
+
await generate({});
|
|
31
|
+
|
|
32
|
+
if (!wallet.is_synced_to_chain) {
|
|
33
|
+
throw new Error('NotSyncedToChain');
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
// Create a channel from the control to the target node
|
|
39
|
+
await setupChannel({
|
|
40
|
+
generate,
|
|
41
|
+
lnd,
|
|
42
|
+
capacity: channelCapacityTokens,
|
|
43
|
+
to: target,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Create a channel from target to remote
|
|
47
|
+
await setupChannel({
|
|
48
|
+
generate: target.generate,
|
|
49
|
+
give: Math.round(channelCapacityTokens / 2),
|
|
50
|
+
lnd: target.lnd,
|
|
51
|
+
to: remote,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
await addPeer({lnd, public_key: remote.id, socket: remote.socket});
|
|
55
|
+
|
|
56
|
+
const destination = remote.id;
|
|
57
|
+
|
|
58
|
+
// Allow time for graph sync to complete
|
|
59
|
+
const {routes} = await waitForRoute({destination, lnd, tokens});
|
|
60
|
+
|
|
61
|
+
const {request} = await createInvoice({tokens, lnd: remote.lnd});
|
|
62
|
+
|
|
63
|
+
const height = (await getWalletInfo({lnd})).current_block_height;
|
|
64
|
+
|
|
65
|
+
const estimate = await getRoutingFeeEstimate({lnd, request});
|
|
66
|
+
|
|
67
|
+
equal(estimate.fee_mtokens, '1500', 'Got fee');
|
|
68
|
+
equal(estimate.timeout - height, 83, 'Got timeout');
|
|
69
|
+
} catch (err) {
|
|
70
|
+
equal(err, null, 'Expected no error');
|
|
71
|
+
} finally {
|
|
72
|
+
await kill({});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return;
|
|
76
|
+
});
|