Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add inbound fees support to getFeeRates #177

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lnd_methods/offchain/get_fee_rates.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ export type GetFeeRatesResult = {
fee_rate: number;
/** Standard Format Channel Id */
id: string;
/**
* Source Based Base Fee Reduction String
*
* Not supported on LND 0.17.5 and below
*/
inbound_base_discount_mtokens: string;
/**
* Source Based Per Million Rate Reduction Number
*
* Not supported on LND 0.17.5 and below
*/
inbound_rate_discount: number;
/** Channel Funding Transaction Id Hex */
transaction_id: string;
/** Funding Outpoint Output Index */
Expand Down
2 changes: 2 additions & 0 deletions lnd_methods/offchain/get_fee_rates.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const type = 'default';
base_fee_mtokens: <Base Flat Fee Millitokens String>
fee_rate: <Fee Rate in Millitokens Per Million Number>
id: <Standard Format Channel Id String>
inbound_base_discount_mtokens: <Source Based Base Fee Reduction String>
inbound_rate_discount: <Source Based Per Million Rate Reduction Number>
transaction_id: <Channel Funding Transaction Id Hex String>
transaction_vout: <Funding Outpoint Output Index Number>
}]
Expand Down
2 changes: 2 additions & 0 deletions lnd_responses/channel_edge_as_channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ const separatorChar = ':';
[base_fee_mtokens]: <Base Fee Millitokens String>
[cltv_delta]: <Locktime Delta Number>
[fee_rate]: <Fees Charged in Millitokens Per Million Number>
inbound_base_discount_mtokens: <Source Specific Base Fee Reduction String>
inbound_rate_discount: <Source Specific Per Million Rate Reduction Number>
[is_disabled]: <Channel Is Disabled Bool>
[max_htlc_mtokens]: <Maximum HTLC Millitokens Value String>
[min_htlc_mtokens]: <Minimum HTLC Millitokens Value String>
Expand Down
4 changes: 4 additions & 0 deletions lnd_responses/rpc_fees_as_channel_fees.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ const {chanFormat} = require('bolt07');

const {safeTokens} = require('./../bolt00');

const discount = fee => (!fee ? 0 : -fee).toString();
const inverse = rate => !rate ? 0 : -rate;
const isHash = n => /^[0-9A-F]{64}$/i.test(n);
const notFound = -1;
const outpointDivider = ':';
Expand Down Expand Up @@ -61,6 +63,8 @@ module.exports = channel => {
base_fee_mtokens: channel.base_fee_msat,
fee_rate: Number(channel.fee_per_mil),
id: chanFormat({number: channel.chan_id}).channel,
inbound_base_discount_mtokens: discount(channel.inbound_base_fee_msat),
inbound_rate_discount: inverse(channel.inbound_fee_per_mil),
transaction_id: txId,
transaction_vout: Number(index),
};
Expand Down
2 changes: 2 additions & 0 deletions test/lnd_methods/offchain/test_get_fee_rates.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ const tests = [
base_fee_mtokens: '0',
fee_rate: 0,
id: '0x0x1',
inbound_base_discount_mtokens: '0',
inbound_rate_discount: 0,
transaction_id: Buffer.alloc(32).toString('hex'),
transaction_vout: 0,
}],
Expand Down
2 changes: 2 additions & 0 deletions test/lnd_responses/test_rpc_fees_as_channel_fees.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ const tests = [
base_fee_mtokens: '1',
fee_rate: 0,
id: '0x0x1',
inbound_base_discount_mtokens: '0',
inbound_rate_discount: 0,
transaction_id: Buffer.alloc(32).toString('hex'),
transaction_vout: 0,
},
Expand Down
Loading