Skip to content

Commit

Permalink
add support for extended channel balances
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbosworth committed Sep 27, 2020
1 parent 761d8cd commit 73e9fd2
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 7 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Versions

## 49.12.0

- `getChannelBalance`: Add support for `channel_balance_mtokens` to show local mtokens
- `getChannelBalance`: Add support for `inbound`, `inbound_mtokens` to show remote balance
- `getChannelBalance`: Add support for `pending_inbound` to show pending remote balance
- `getChannelBalance`: Add support for `unsettled_balance` to show HTLCs balance
- `getChannelBalance`: Add support for `unsettled_balance_mtokens` to show HTLCs balance

## 49.11.1

- `addPeer`: Allow specifying a `timeout` in milliseconds to abort a connect attempt
Expand Down
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1250,14 +1250,30 @@ Get balance across channels.

Requires `offchain:read` permission

`channel_balance_mtokens` is not supported on LND 0.11.1 and below

`inbound` and `inbound_mtokens` are not supported on LND 0.11.1 and below

`pending_inbound` is not supported on LND 0.11.1 and below

`unsettled_balance` is not supported on LND 0.11.1 and below

`unsettled_balance_mtokens` is not supported on LND 0.11.1 and below

{
lnd: <Authenticated LND API Object>
}

@returns via cbk or Promise
{
channel_balance: <Channels Balance Tokens Number>
pending_balance: <Pending Channels Balance Tokens Number>
[channel_balance_mtokens]: <Channels Balance Millitokens String>
[inbound]: <Inbound Liquidity Tokens Number>
[inbound_mtokens]: <Inbound Liquidity Millitokens String>
pending_balance: <Pending On-Chain Channels Balance Tokens Number>
[pending_inbound]: <Pending On-Chain Inbound Liquidity Tokens Number>
[unsettled_balance]: <In-Flight Tokens Number>
[unsettled_balance_mtokens]: <In-Flight Millitokens Number>
}

Example:
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"express": "4.17.1",
"invoices": "1.1.4",
"is-base64": "1.1.0",
"lightning": "2.0.49",
"lightning": "2.0.50",
"macaroon": "3.0.4",
"morgan": "1.10.0",
"ws": "7.3.1"
Expand Down Expand Up @@ -63,5 +63,5 @@
"tower_server-integration-tests": "tap --no-coverage test/tower_serverrpc-integration/*.js",
"wallet-integration-tests": "tap --no-coverage test/walletrpc-integration/*.js"
},
"version": "49.11.1"
"version": "49.12.0"
}
18 changes: 18 additions & 0 deletions test/invoicesrpc-integration/test_settle_invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const {test} = require('tap');
const {createCluster} = require('./../macros');
const {createHodlInvoice} = require('./../../');
const {createInvoice} = require('./../../');
const {getChannelBalance} = require('./../../');
const {getChannels} = require('./../../');
const {getInvoice} = require('./../../');
const {getInvoices} = require('./../../');
Expand Down Expand Up @@ -76,6 +77,23 @@ test(`Pay a hodl invoice`, async ({deepIs, end, equal, rejects}) => {

const [held] = (await getInvoices({lnd})).invoices;

const controlChannelBalance = await getChannelBalance({lnd});

// LND 0.11.1 and below do not support extended channel balance details
if (!!controlChannelBalance.channel_balance_mtokens) {
deepIs(controlChannelBalance, {
channel_balance: 990950,
channel_balance_mtokens: '990950000',
inbound: 990850,
inbound_mtokens: '990850000',
pending_balance: 0,
pending_inbound: 0,
unsettled_balance: tokens,
unsettled_balance_mtokens: '100000',
},
'Channel balance is updated');
}

deepIs(invoice, held, 'Invoice is held');

const {secret} = await pay({lnd, request, timeout, tokens});
Expand Down

0 comments on commit 73e9fd2

Please sign in to comment.