diff --git a/lnd_methods/index.js b/lnd_methods/index.js index 42cdb03..49ccb85 100644 --- a/lnd_methods/index.js +++ b/lnd_methods/index.js @@ -26,6 +26,7 @@ const {diffieHellmanComputeSecret} = require('./signer'); const {disableChannel} = require('./offchain'); const {disconnectWatchtower} = require('./offchain'); const {enableChannel} = require('./offchain'); +const {estimateRouteFee} = require('./offchain'); const {endGroupSigningSession} = require('./signer'); const {fundPendingChannels} = require('./onchain'); const {fundPsbt} = require('./onchain'); @@ -186,6 +187,7 @@ module.exports = { disableChannel, disconnectWatchtower, enableChannel, + estimateRouteFee, endGroupSigningSession, fundPendingChannels, fundPsbt, diff --git a/lnd_methods/offchain/estimate_route_fee.d.ts b/lnd_methods/offchain/estimate_route_fee.d.ts new file mode 100644 index 0000000..b33777b --- /dev/null +++ b/lnd_methods/offchain/estimate_route_fee.d.ts @@ -0,0 +1,32 @@ +import {AuthenticatedLnd} from '../../lnd_grpc'; +import { + AuthenticatedLightningArgs, + AuthenticatedLightningMethod +} from '../../typescript'; + +export type RouteFeeRequest = AuthenticatedLightningArgs<{ + lnd: AuthenticatedLnd; + /** BOLT 11 Encoded Payment Request */ + request: string; + /** Optional Timeout in Milliseconds */ + timeout: number; +}>; + +export type RouteFeeResponse = { + /** Millitokens (Routing Fee Msat) */ + mtoken: number; + /** Timeout (Time Lock Delay) */ + timeout: number; +}; + +/** + * Estimate routing fees based on an invoice. + * + * Requires `offchain:read` permission + * + * This method is not supported before LND 0.18.4 + */ +export const estimateRouteFee: AuthenticatedLightningMethod< + RouteFeeRequest, + RouteFeeResponse +>; \ No newline at end of file diff --git a/lnd_methods/offchain/estimate_route_fee.js b/lnd_methods/offchain/estimate_route_fee.js new file mode 100644 index 0000000..9ac71bb --- /dev/null +++ b/lnd_methods/offchain/estimate_route_fee.js @@ -0,0 +1,83 @@ +const asyncAuto = require('async/auto'); +const {returnResult} = require('asyncjs-util'); + +/** + * Estimate routing fees based on an invoice. + * + * Requires `offchain:read` permission + * + * This method is not supported before LND 0.18.4 + * + * + @argument + { + lnd: + request: + timeout: + } + + @returns via cbk or Promise + { + mtoken: + timeout: