diff --git a/lnd_methods/index.js b/lnd_methods/index.js index 42cdb03..b7262a3 100644 --- a/lnd_methods/index.js +++ b/lnd_methods/index.js @@ -77,6 +77,7 @@ const {getPublicKey} = require('./address'); const {getRouteConfidence} = require('./generic'); const {getRouteThroughHops} = require('./offchain'); const {getRouteToDestination} = require('./info'); +const {getRoutingFeeEstimate} = require('./offchain'); const {getSettlementStatus} = require('./offchain'); const {getSweepTransactions} = require('./onchain'); const {getTowerServerInfo} = require('./info'); @@ -237,6 +238,7 @@ module.exports = { getRouteConfidence, getRouteThroughHops, getRouteToDestination, + getRoutingFeeEstimate, getSettlementStatus, getSweepTransactions, getTowerServerInfo, diff --git a/lnd_methods/offchain/get_routing_fee_estimate.d.ts b/lnd_methods/offchain/get_routing_fee_estimate.d.ts new file mode 100644 index 0000000..3217344 --- /dev/null +++ b/lnd_methods/offchain/get_routing_fee_estimate.d.ts @@ -0,0 +1,32 @@ +import {AuthenticatedLnd} from '../../lnd_grpc'; +import { + AuthenticatedLightningArgs, + AuthenticatedLightningMethod +} from '../../typescript'; + +export type GetRoutingFeeEstimateRequest = AuthenticatedLightningArgs<{ + lnd: AuthenticatedLnd; + /** BOLT 11 Encoded Payment Request */ + request: string; + /** Optional Timeout in Milliseconds */ + timeout: number; +}>; + +export type GetRoutingFeeEstimateResponse = { + /** Sats (Routing Fee Sats) */ + fee: number; + /** Timeout (Time Lock Delay) */ + timeout: string; +}; + +/** + * Estimate routing fees based on an invoice. + * + * Requires `offchain:read` permission + * + * This method is not supported before LND 0.18.4 + */ +export const getRoutingFeeEstimate: AuthenticatedLightningMethod< + GetRoutingFeeEstimateRequest, + GetRoutingFeeEstimateResponse +>; \ No newline at end of file diff --git a/lnd_methods/offchain/get_routing_fee_estimate.js b/lnd_methods/offchain/get_routing_fee_estimate.js new file mode 100644 index 0000000..5582305 --- /dev/null +++ b/lnd_methods/offchain/get_routing_fee_estimate.js @@ -0,0 +1,90 @@ +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 + { + fee: + timeout: