mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-17 19:03:42 +01:00
json_getchannels: add public flag.
Fixes: #509 Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
7975a1cbfc
commit
a8de8a3140
@ -87,9 +87,8 @@ cli/lightning-cli fundchannel <node_id> <amount>
|
|||||||
```
|
```
|
||||||
|
|
||||||
This opens a connection and, on top of that connection, then opens a channel.
|
This opens a connection and, on top of that connection, then opens a channel.
|
||||||
The funding transaction needs 6 confirmations in order for the channel to be usable.
|
The funding transaction needs 1 confirmations in order for the channel to be usable, and 6 to be broadcast for others to use.
|
||||||
You can check the status of the channel using `cli/lightning-cli getpeers`, which after 1 confirmation should say that the status is in _Normal operation_.
|
You can check the status of the channel using `cli/lightning-cli getpeers`, which after 1 confirmation should say that `state` is `CHANNELD_NORMAL`; after 6 confirmations you can use `cli/lightning-cli getchannels` to verify that the `public` field is now `true`.
|
||||||
After 6 confirmations you can use `cli/lightning-cli getchannels` to verify that the channel shows up in the list of open channels.
|
|
||||||
|
|
||||||
### Receiving and receiving payments
|
### Receiving and receiving payments
|
||||||
|
|
||||||
|
@ -1059,6 +1059,7 @@ static struct io_plan *getchannels_req(struct io_conn *conn, struct daemon *daem
|
|||||||
entries[num_chans].destination = n->out[j]->dst->id;
|
entries[num_chans].destination = n->out[j]->dst->id;
|
||||||
entries[num_chans].active = n->out[j]->active;
|
entries[num_chans].active = n->out[j]->active;
|
||||||
entries[num_chans].flags = n->out[j]->flags;
|
entries[num_chans].flags = n->out[j]->flags;
|
||||||
|
entries[num_chans].public = (n->out[j]->channel_update != NULL);
|
||||||
entries[num_chans].short_channel_id = n->out[j]->short_channel_id;
|
entries[num_chans].short_channel_id = n->out[j]->short_channel_id;
|
||||||
entries[num_chans].last_update_timestamp = n->out[j]->last_timestamp;
|
entries[num_chans].last_update_timestamp = n->out[j]->last_timestamp;
|
||||||
if (entries[num_chans].last_update_timestamp >= 0) {
|
if (entries[num_chans].last_update_timestamp >= 0) {
|
||||||
|
@ -292,6 +292,7 @@ static void json_getchannels_reply(struct subd *gossip, const u8 *reply,
|
|||||||
&entries[i].short_channel_id));
|
&entries[i].short_channel_id));
|
||||||
json_add_num(response, "flags", entries[i].flags);
|
json_add_num(response, "flags", entries[i].flags);
|
||||||
json_add_bool(response, "active", entries[i].active);
|
json_add_bool(response, "active", entries[i].active);
|
||||||
|
json_add_bool(response, "public", entries[i].public);
|
||||||
if (entries[i].last_update_timestamp >= 0) {
|
if (entries[i].last_update_timestamp >= 0) {
|
||||||
json_add_num(response, "last_update",
|
json_add_num(response, "last_update",
|
||||||
entries[i].last_update_timestamp);
|
entries[i].last_update_timestamp);
|
||||||
|
@ -51,6 +51,7 @@ void fromwire_gossip_getchannels_entry(const u8 **pptr, size_t *max,
|
|||||||
fromwire_pubkey(pptr, max, &entry->destination);
|
fromwire_pubkey(pptr, max, &entry->destination);
|
||||||
entry->active = fromwire_bool(pptr, max);
|
entry->active = fromwire_bool(pptr, max);
|
||||||
entry->flags = fromwire_u16(pptr, max);
|
entry->flags = fromwire_u16(pptr, max);
|
||||||
|
entry->public = fromwire_bool(pptr, max);
|
||||||
entry->last_update_timestamp = fromwire_u64(pptr, max);
|
entry->last_update_timestamp = fromwire_u64(pptr, max);
|
||||||
if (entry->last_update_timestamp >= 0) {
|
if (entry->last_update_timestamp >= 0) {
|
||||||
entry->base_fee_msat = fromwire_u32(pptr, max);
|
entry->base_fee_msat = fromwire_u32(pptr, max);
|
||||||
@ -67,6 +68,7 @@ void towire_gossip_getchannels_entry(
|
|||||||
towire_pubkey(pptr, &entry->destination);
|
towire_pubkey(pptr, &entry->destination);
|
||||||
towire_bool(pptr, entry->active);
|
towire_bool(pptr, entry->active);
|
||||||
towire_u16(pptr, entry->flags);
|
towire_u16(pptr, entry->flags);
|
||||||
|
towire_bool(pptr, entry->public);
|
||||||
towire_u64(pptr, entry->last_update_timestamp);
|
towire_u64(pptr, entry->last_update_timestamp);
|
||||||
if (entry->last_update_timestamp >= 0) {
|
if (entry->last_update_timestamp >= 0) {
|
||||||
towire_u32(pptr, entry->base_fee_msat);
|
towire_u32(pptr, entry->base_fee_msat);
|
||||||
|
@ -14,6 +14,7 @@ struct gossip_getchannels_entry {
|
|||||||
bool active;
|
bool active;
|
||||||
struct short_channel_id short_channel_id;
|
struct short_channel_id short_channel_id;
|
||||||
u16 flags;
|
u16 flags;
|
||||||
|
bool public;
|
||||||
s64 last_update_timestamp; /* -1 means never */
|
s64 last_update_timestamp; /* -1 means never */
|
||||||
/* These are only set if last_update_timestamp >= 0 */
|
/* These are only set if last_update_timestamp >= 0 */
|
||||||
u32 delay;
|
u32 delay;
|
||||||
|
@ -1342,6 +1342,17 @@ class LightningDTests(BaseLightningDTests):
|
|||||||
# Make sure we can route through the channel, will raise on failure
|
# Make sure we can route through the channel, will raise on failure
|
||||||
l1.rpc.getroute(l2.info['id'], 100, 1)
|
l1.rpc.getroute(l2.info['id'], 100, 1)
|
||||||
|
|
||||||
|
# Outgoing should be active, but not public.
|
||||||
|
channels = l1.rpc.getchannels()['channels']
|
||||||
|
assert len(channels) == 1
|
||||||
|
assert channels[0]['active'] == True
|
||||||
|
assert channels[0]['public'] == False
|
||||||
|
|
||||||
|
channels = l2.rpc.getchannels()['channels']
|
||||||
|
assert len(channels) == 1
|
||||||
|
assert channels[0]['active'] == True
|
||||||
|
assert channels[0]['public'] == False
|
||||||
|
|
||||||
# Now proceed to funding-depth and do a full gossip round
|
# Now proceed to funding-depth and do a full gossip round
|
||||||
l1.bitcoin.generate_block(5)
|
l1.bitcoin.generate_block(5)
|
||||||
# Could happen in either order.
|
# Could happen in either order.
|
||||||
@ -1358,9 +1369,16 @@ class LightningDTests(BaseLightningDTests):
|
|||||||
l1.daemon.wait_for_log('peer_in WIRE_CHANNEL_UPDATE')
|
l1.daemon.wait_for_log('peer_in WIRE_CHANNEL_UPDATE')
|
||||||
l2.daemon.wait_for_log('peer_in WIRE_CHANNEL_UPDATE')
|
l2.daemon.wait_for_log('peer_in WIRE_CHANNEL_UPDATE')
|
||||||
|
|
||||||
|
# Now should be active and public.
|
||||||
channels = l1.rpc.getchannels()['channels']
|
channels = l1.rpc.getchannels()['channels']
|
||||||
assert len(channels) == 2
|
assert len(channels) == 2
|
||||||
wait_for(lambda: [c['active'] for c in channels] == [True, True])
|
assert [c['active'] for c in channels] == [True, True]
|
||||||
|
assert [c['public'] for c in channels] == [True, True]
|
||||||
|
|
||||||
|
channels = l2.rpc.getchannels()['channels']
|
||||||
|
assert len(channels) == 2
|
||||||
|
assert [c['active'] for c in channels] == [True, True]
|
||||||
|
assert [c['public'] for c in channels] == [True, True]
|
||||||
|
|
||||||
def ping_tests(self, l1, l2):
|
def ping_tests(self, l1, l2):
|
||||||
# 0-byte pong gives just type + length field.
|
# 0-byte pong gives just type + length field.
|
||||||
|
Loading…
Reference in New Issue
Block a user