Skip to content

Commit efa3887

Browse files
niftyneirustyrussell
authored andcommitted
listpeers: include private field in channels output
Reveal channel's 'privacy' in `listpeers` output Suggested-By: @shesek
1 parent 36e060a commit efa3887

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1313
`num_active_channels` and `num_inactive_channels` fields.
1414
- JSON API: use `\n\n` to terminate responses, for simplified parsing (pylightning now relies on this)
1515
- JSON API: `fundchannel` now includes an `announce` option, when false it will keep channel private. Defaults to true.
16+
- JSON API: `listpeers`'s `channels` now includes a `private` flag to indicate if channel is announced or not.
1617
- Plugins: Added plugins to `lightningd`, including option passthrough and JSON-RPC passthrough.
1718

1819
### Changed

lightningd/peer_control.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,8 @@ static void json_add_peer(struct lightningd *ld,
716716
json_add_txid(response,
717717
"funding_txid",
718718
&channel->funding_txid);
719+
json_add_bool(response, "private",
720+
!(channel->channel_flags & CHANNEL_FLAGS_ANNOUNCE_CHANNEL));
719721
json_add_u64(response, "msatoshi_to_us",
720722
channel->our_msatoshi);
721723
json_add_u64(response, "msatoshi_to_us_min",

tests/test_connection.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,11 @@ def test_private_channel(node_factory):
805805
assert not l1.daemon.is_in_log('Received node_announcement for node {}'.format(l2.info['id']))
806806
assert not l2.daemon.is_in_log('Received node_announcement for node {}'.format(l1.info['id']))
807807

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

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

0 commit comments

Comments
 (0)