Skip to content

Commit

Permalink
zeroconf: Announce the channel with the real scid as well as aliases
Browse files Browse the repository at this point in the history
With zeroconf we have to duplicate the `local_channel_announcement`
since we locally announce the aliased version, and then on the first
confirmation we also add the funding scid version.
  • Loading branch information
cdecker committed Jun 7, 2022
1 parent 98fa136 commit ed24398
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions channeld/channeld.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,16 @@ struct peer {
/* We allow a 'tx-sigs' message between reconnect + funding_locked */
bool tx_sigs_allowed;

/* Have we announced the real scid with a
* local_channel_announcement? This can be different from the
* `channel_local_active` flag in case we are using zeroconf,
* in which case we'll have announced the channels with the
* two aliases (LOCAL and REMOTE) but not with the real scid
* just yet. If we get a funding depth change, with a scid,
* and the two flags not equal we know we have to announce the
* channel with the real scid. */
bool gossip_scid_announced;

/* Most recent channel_update message. */
u8 *channel_update;
};
Expand Down Expand Up @@ -535,6 +545,14 @@ static void channel_announcement_negotiate(struct peer *peer)
if (!peer->channel_local_active) {
peer->channel_local_active = true;
make_channel_local_active(peer);
} else if(!peer->gossip_scid_announced) {
/* So we know a short_channel_id, i.e., a point on
* chain, but haven't added it to our local view of
* the gossip yet. We need to add it now (and once
* only), so our `channel_update` we'll send a couple
* of lines down has something to attach to. */
peer->gossip_scid_announced = true;
make_channel_local_active(peer);
}

/* BOLT #7:
Expand Down Expand Up @@ -3984,6 +4002,7 @@ int main(int argc, char *argv[])
peer->have_sigs[LOCAL] = peer->have_sigs[REMOTE] = false;
peer->announce_depth_reached = false;
peer->channel_local_active = false;
peer->gossip_scid_announced = false;
peer->from_master = msg_queue_new(peer, true);
peer->shutdown_sent[LOCAL] = false;
peer->shutdown_wrong_funding = NULL;
Expand Down
2 changes: 1 addition & 1 deletion tests/test_opening.py
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,6 @@ def test_zeroconf_open(bitcoind, node_factory):
l2.rpc.pay(inv)


@pytest.mark.xfail(strict=True, reason="Peers do not recognize the final scid yet")
def test_zeroconf_public(bitcoind, node_factory):
"""Test that we transition correctly from zeroconf to public
Expand Down Expand Up @@ -1351,6 +1350,7 @@ def test_zeroconf_public(bitcoind, node_factory):
bitcoind.generate_block(5)
# Wait for l3 to learn about the channel, it'll have checked the
# funding outpoint, scripts, etc.
l3.connect(l1)
wait_for(lambda: len(l3.rpc.listchannels()['channels']) == 2)


Expand Down

0 comments on commit ed24398

Please sign in to comment.