Skip to content

Commit

Permalink
listpeers: include private field in channels output
Browse files Browse the repository at this point in the history
Reveal channel's 'privacy' in `listpeers` output

Suggested-By: @shesek
  • Loading branch information
niftynei committed Jan 8, 2019
1 parent 6f027a2 commit 7154738
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
`num_active_channels` and `num_inactive_channels` fields.
- JSON API: use `\n\n` to terminate responses, for simplified parsing (pylightning now relies on this)
- JSON API: `fundchannel` now includes an `announce` option, when false it will keep channel private. Defaults to true.
- JSON API: `listpeers`'s `channels` now includes a `private` flag to indicate if channel is announced or not.
- Plugins: Added plugins to `lightningd`, including option passthrough and JSON-RPC passthrough.

### Changed
Expand Down
2 changes: 2 additions & 0 deletions lightningd/peer_control.c
Expand Up @@ -716,6 +716,8 @@ static void json_add_peer(struct lightningd *ld,
json_add_txid(response,
"funding_txid",
&channel->funding_txid);
json_add_bool(response, "private",
!(channel->channel_flags & CHANNEL_FLAGS_ANNOUNCE_CHANNEL));
json_add_u64(response, "msatoshi_to_us",
channel->our_msatoshi);
json_add_u64(response, "msatoshi_to_us_min",
Expand Down
5 changes: 5 additions & 0 deletions tests/test_connection.py
Expand Up @@ -805,6 +805,11 @@ def test_private_channel(node_factory):
assert not l1.daemon.is_in_log('Received node_announcement for node {}'.format(l2.info['id']))
assert not l2.daemon.is_in_log('Received node_announcement for node {}'.format(l1.info['id']))

# test for 'private' flag in rpc output
assert only_one(only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['channels'])['private']
# check non-private channel
assert not only_one(only_one(l4.rpc.listpeers(l3.info['id'])['peers'])['channels'])['private']


@unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1 for --dev-broadcast-interval")
def test_channel_reenable(node_factory):
Expand Down

0 comments on commit 7154738

Please sign in to comment.