Skip to content

Commit

Permalink
doc: update BOLTs to bc86304b4b0af5fd5ce9d24f74e2ebbceb7e2730
Browse files Browse the repository at this point in the history
This contains the zeroconf stuff, with funding_locked renamed to
channel_ready.  I change that everywhere, and try to fix up the
comments.

Also the `alias` field is called `short_channel_id`.

Signed-off-by: Rusty Russell <[email protected]>
Changelog-Changed: Protocol: `funding_locked` is now called `channel_ready` as per latest BOLTs.
  • Loading branch information
rustyrussell committed Sep 12, 2022
1 parent 341bbdf commit 1b30ea4
Show file tree
Hide file tree
Showing 29 changed files with 205 additions and 205 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ CCANDIR := ccan

# Where we keep the BOLT RFCs
BOLTDIR := ../bolts/
DEFAULT_BOLTVERSION := 03468e17563650fb9bfe58b2da4d1e5d28e92009
DEFAULT_BOLTVERSION := bc86304b4b0af5fd5ce9d24f74e2ebbceb7e2730
# Can be overridden on cmdline.
BOLTVERSION := $(DEFAULT_BOLTVERSION)

Expand Down
90 changes: 46 additions & 44 deletions channeld/channeld.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Main channel operation daemon: runs from funding_locked to shutdown_complete.
/* Main channel operation daemon: runs from channel_ready to shutdown_complete.
*
* We're fairly synchronous: our main loop looks for master or
* peer requests and services them synchronously.
Expand Down Expand Up @@ -52,7 +52,7 @@

struct peer {
struct per_peer_state *pps;
bool funding_locked[NUM_SIDES];
bool channel_ready[NUM_SIDES];
u64 next_index[NUM_SIDES];

/* Features peer supports. */
Expand Down Expand Up @@ -182,7 +182,7 @@ struct peer {
/* Penalty bases for this channel / peer. */
struct penalty_base **pbases;

/* We allow a 'tx-sigs' message between reconnect + funding_locked */
/* We allow a 'tx-sigs' message between reconnect + channel_ready */
bool tx_sigs_allowed;

/* Have we announced the real scid with a
Expand All @@ -204,7 +204,7 @@ static void start_commit_timer(struct peer *peer);

static void billboard_update(const struct peer *peer)
{
const char *update = billboard_message(tmpctx, peer->funding_locked,
const char *update = billboard_message(tmpctx, peer->channel_ready,
peer->have_sigs,
peer->shutdown_sent,
peer->depth_togo,
Expand Down Expand Up @@ -539,7 +539,7 @@ static void channel_announcement_negotiate(struct peer *peer)
return;

/* Can't do anything until funding is locked. */
if (!peer->funding_locked[LOCAL] || !peer->funding_locked[REMOTE])
if (!peer->channel_ready[LOCAL] || !peer->channel_ready[REMOTE])
return;

if (!peer->channel_local_active) {
Expand All @@ -560,7 +560,7 @@ static void channel_announcement_negotiate(struct peer *peer)
* A node:
* - if the `open_channel` message has the `announce_channel` bit set AND a `shutdown` message has not been sent:
* - MUST send the `announcement_signatures` message.
* - MUST NOT send `announcement_signatures` messages until `funding_locked`
* - MUST NOT send `announcement_signatures` messages until `channel_ready`
* has been sent and received AND the funding transaction has at least six confirmations.
* - otherwise:
* - MUST NOT send the `announcement_signatures` message.
Expand All @@ -570,7 +570,7 @@ static void channel_announcement_negotiate(struct peer *peer)

/* BOLT #7:
*
* - MUST NOT send `announcement_signatures` messages until `funding_locked`
* - MUST NOT send `announcement_signatures` messages until `channel_ready`
* has been sent and received AND the funding transaction has at least six confirmations.
*/
if (peer->announce_depth_reached && !peer->have_sigs[LOCAL]) {
Expand Down Expand Up @@ -602,29 +602,29 @@ static void channel_announcement_negotiate(struct peer *peer)
}
}

static void handle_peer_funding_locked(struct peer *peer, const u8 *msg)
static void handle_peer_channel_ready(struct peer *peer, const u8 *msg)
{
struct channel_id chanid;
struct tlv_funding_locked_tlvs *tlvs;
struct tlv_channel_ready_tlvs *tlvs;
/* BOLT #2:
*
* A node:
*...
* - upon reconnection:
* - MUST ignore any redundant `funding_locked` it receives.
* - MUST ignore any redundant `channel_ready` it receives.
*/
if (peer->funding_locked[REMOTE])
if (peer->channel_ready[REMOTE])
return;

/* Too late, we're shutting down! */
if (peer->shutdown_sent[LOCAL])
return;

peer->old_remote_per_commit = peer->remote_per_commit;
if (!fromwire_funding_locked(msg, msg, &chanid,
if (!fromwire_channel_ready(msg, msg, &chanid,
&peer->remote_per_commit, &tlvs))
peer_failed_warn(peer->pps, &peer->channel_id,
"Bad funding_locked %s", tal_hex(msg, msg));
"Bad channel_ready %s", tal_hex(msg, msg));

if (!channel_id_eq(&chanid, &peer->channel_id))
peer_failed_err(peer->pps, &chanid,
Expand All @@ -634,17 +634,17 @@ static void handle_peer_funding_locked(struct peer *peer, const u8 *msg)
&peer->channel_id));

peer->tx_sigs_allowed = false;
peer->funding_locked[REMOTE] = true;
if (tlvs->alias != NULL) {
peer->channel_ready[REMOTE] = true;
if (tlvs->short_channel_id != NULL) {
status_debug(
"Peer told us that they'll use alias=%s for this channel",
type_to_string(tmpctx, struct short_channel_id,
tlvs->alias));
peer->short_channel_ids[REMOTE] = *tlvs->alias;
tlvs->short_channel_id));
peer->short_channel_ids[REMOTE] = *tlvs->short_channel_id;
}
wire_sync_write(MASTER_FD,
take(towire_channeld_got_funding_locked(
NULL, &peer->remote_per_commit, tlvs->alias)));
take(towire_channeld_got_channel_ready(
NULL, &peer->remote_per_commit, tlvs->short_channel_id)));

channel_announcement_negotiate(peer);
billboard_update(peer);
Expand Down Expand Up @@ -2119,8 +2119,8 @@ static void handle_unexpected_tx_sigs(struct peer *peer, const u8 *msg)
struct bitcoin_txid txid;

/* In a rare case, a v2 peer may re-send a tx_sigs message.
* This happens when they've/we've exchanged funding_locked,
* but they did not receive our funding_locked. */
* This happens when they've/we've exchanged channel_ready,
* but they did not receive our channel_ready. */
if (!fromwire_tx_signatures(tmpctx, msg, &cid, &txid,
cast_const3(struct witness_stack ***, &ws)))
peer_failed_warn(peer->pps, &peer->channel_id,
Expand Down Expand Up @@ -2212,9 +2212,9 @@ static void peer_in(struct peer *peer, const u8 *msg)
if (handle_peer_error(peer->pps, &peer->channel_id, msg))
return;

/* Must get funding_locked before almost anything. */
if (!peer->funding_locked[REMOTE]) {
if (type != WIRE_FUNDING_LOCKED
/* Must get channel_ready before almost anything. */
if (!peer->channel_ready[REMOTE]) {
if (type != WIRE_CHANNEL_READY
&& type != WIRE_SHUTDOWN
/* We expect these for v2 !! */
&& type != WIRE_TX_SIGNATURES
Expand All @@ -2228,8 +2228,8 @@ static void peer_in(struct peer *peer, const u8 *msg)
}

switch (type) {
case WIRE_FUNDING_LOCKED:
handle_peer_funding_locked(peer, msg);
case WIRE_CHANNEL_READY:
handle_peer_channel_ready(peer, msg);
return;
case WIRE_ANNOUNCEMENT_SIGNATURES:
handle_peer_announcement_signatures(peer, msg);
Expand Down Expand Up @@ -2664,7 +2664,7 @@ static void check_current_dataloss_fields(struct peer *peer,
status_debug("option_data_loss_protect: fields are correct");
}

/* Older LND sometimes sends funding_locked before reestablish! */
/* Older LND sometimes sends channel_ready before reestablish! */
/* ... or announcement_signatures. Sigh, let's handle whatever they send. */
static bool capture_premature_msg(const u8 ***shit_lnd_says, const u8 *msg)
{
Expand Down Expand Up @@ -2941,19 +2941,21 @@ static void peer_reconnect(struct peer *peer,
*
* - if `next_commitment_number` is 1 in both the
* `channel_reestablish` it sent and received:
* - MUST retransmit `funding_locked`.
* - MUST retransmit `channel_ready`.
* - otherwise:
* - MUST NOT retransmit `funding_locked`.
* - MUST NOT retransmit `channel_ready`, but MAY send
* `channel_ready` with a different `short_channel_id`
* `alias` field.
*/
if (peer->funding_locked[LOCAL]
if (peer->channel_ready[LOCAL]
&& peer->next_index[LOCAL] == 1
&& next_commitment_number == 1) {
struct tlv_funding_locked_tlvs *tlvs = tlv_funding_locked_tlvs_new(tmpctx);
struct tlv_channel_ready_tlvs *tlvs = tlv_channel_ready_tlvs_new(tmpctx);

status_debug("Retransmitting funding_locked for channel %s",
type_to_string(tmpctx, struct channel_id, &peer->channel_id));
/* Contains per commit point #1, for first post-opening commit */
msg = towire_funding_locked(NULL,
msg = towire_channel_ready(NULL,
&peer->channel_id,
&peer->next_local_per_commit, tlvs);
peer_write(peer->pps, take(msg));
Expand Down Expand Up @@ -3229,7 +3231,7 @@ static void handle_funding_depth(struct peer *peer, const u8 *msg)
{
u32 depth;
struct short_channel_id *scid, *alias_local;
struct tlv_funding_locked_tlvs *tlvs;
struct tlv_channel_ready_tlvs *tlvs;
struct pubkey point;

if (!fromwire_channeld_funding_depth(tmpctx,
Expand Down Expand Up @@ -3258,25 +3260,25 @@ static void handle_funding_depth(struct peer *peer, const u8 *msg)
else if (alias_local)
peer->short_channel_ids[LOCAL] = *alias_local;

if (!peer->funding_locked[LOCAL]) {
status_debug("funding_locked: sending commit index"
if (!peer->channel_ready[LOCAL]) {
status_debug("channel_ready: sending commit index"
" %"PRIu64": %s",
peer->next_index[LOCAL],
type_to_string(tmpctx, struct pubkey,
&peer->next_local_per_commit));
tlvs = tlv_funding_locked_tlvs_new(tmpctx);
tlvs->alias = alias_local;
tlvs = tlv_channel_ready_tlvs_new(tmpctx);
tlvs->short_channel_id = alias_local;

/* Need to retrieve the first point again, even if we
* moved on, as funding_locked explicitly includes the
* moved on, as channel_ready explicitly includes the
* first one. */
get_per_commitment_point(1, &point, NULL);

msg = towire_funding_locked(NULL, &peer->channel_id,
msg = towire_channel_ready(NULL, &peer->channel_id,
&point, tlvs);
peer_write(peer->pps, take(msg));

peer->funding_locked[LOCAL] = true;
peer->channel_ready[LOCAL] = true;
}

peer->announce_depth_reached = (depth >= ANNOUNCE_MIN_DEPTH);
Expand Down Expand Up @@ -3310,7 +3312,7 @@ static void handle_offer_htlc(struct peer *peer, const u8 *inmsg)
struct amount_sat htlc_fee;
struct pubkey *blinding;

if (!peer->funding_locked[LOCAL] || !peer->funding_locked[REMOTE])
if (!peer->channel_ready[LOCAL] || !peer->channel_ready[REMOTE])
status_failed(STATUS_FAIL_MASTER_IO,
"funding not locked for offer_htlc");

Expand Down Expand Up @@ -3745,7 +3747,7 @@ static void req_in(struct peer *peer, const u8 *msg)
case WIRE_CHANNELD_SENDING_COMMITSIG_REPLY:
case WIRE_CHANNELD_GOT_COMMITSIG_REPLY:
case WIRE_CHANNELD_GOT_REVOKE_REPLY:
case WIRE_CHANNELD_GOT_FUNDING_LOCKED:
case WIRE_CHANNELD_GOT_CHANNEL_READY:
case WIRE_CHANNELD_GOT_ANNOUNCEMENT:
case WIRE_CHANNELD_GOT_SHUTDOWN:
case WIRE_CHANNELD_SHUTDOWN_COMPLETE:
Expand Down Expand Up @@ -3837,8 +3839,8 @@ static void init_channel(struct peer *peer)
&peer->revocations_received,
&peer->htlc_id,
&htlcs,
&peer->funding_locked[LOCAL],
&peer->funding_locked[REMOTE],
&peer->channel_ready[LOCAL],
&peer->channel_ready[REMOTE],
&peer->short_channel_ids[LOCAL],
&reconnected,
&peer->send_shutdown,
Expand Down
12 changes: 6 additions & 6 deletions channeld/channeld_wire.csv
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ msgdata,channeld_init,revocations_received,u64,
msgdata,channeld_init,next_htlc_id,u64,
msgdata,channeld_init,num_existing_htlcs,u16,
msgdata,channeld_init,htlcs,existing_htlc,num_existing_htlcs
msgdata,channeld_init,local_funding_locked,bool,
msgdata,channeld_init,remote_funding_locked,bool,
msgdata,channeld_init,local_channel_ready,bool,
msgdata,channeld_init,remote_channel_ready,bool,
msgdata,channeld_init,funding_short_id,short_channel_id,
msgdata,channeld_init,reestablish,bool,
msgdata,channeld_init,send_shutdown,bool,
Expand Down Expand Up @@ -117,10 +117,10 @@ msgdata,channeld_fulfill_htlc,fulfilled_htlc,fulfilled_htlc,
msgtype,channeld_fail_htlc,1006
msgdata,channeld_fail_htlc,failed_htlc,failed_htlc,

# When we receive funding_locked.
msgtype,channeld_got_funding_locked,1019
msgdata,channeld_got_funding_locked,next_per_commit_point,pubkey,
msgdata,channeld_got_funding_locked,alias,?short_channel_id,
# When we receive channel_ready.
msgtype,channeld_got_channel_ready,1019
msgdata,channeld_got_channel_ready,next_per_commit_point,pubkey,
msgdata,channeld_got_channel_ready,alias,?short_channel_id,

#include <common/penalty_base.h>

Expand Down
4 changes: 2 additions & 2 deletions closingd/closingd.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,11 @@ receive_offer(struct per_peer_state *pps,
/* BOLT #2:
*
* - upon reconnection:
* - MUST ignore any redundant `funding_locked` it receives.
* - MUST ignore any redundant `channel_ready` it receives.
*/
/* This should only happen if we've made no commitments, but
* we don't have to check that: it's their problem. */
if (fromwire_peektype(msg) == WIRE_FUNDING_LOCKED)
if (fromwire_peektype(msg) == WIRE_CHANNEL_READY)
msg = tal_free(msg);
/* BOLT #2:
* - if it has sent a previous `shutdown`:
Expand Down
9 changes: 6 additions & 3 deletions common/channel_type.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* arbitrary combination (they represent the persistent features which
* affect the channel operation).
*
* The currently defined types are:
* The currently defined basic types are:
* - no features (no bits set)
* - `option_static_remotekey` (bit 12)
* - `option_anchor_outputs` and `option_static_remotekey` (bits 20 and 12)
Expand Down Expand Up @@ -118,8 +118,11 @@ struct channel_type *channel_type_accept(const tal_t *ctx,
OPT_ZEROCONF,
};

/* The basic channel_types can have any number of the
* following optional bits. */
/* BOLT #2:
* Each basic type has the following variations allowed:
* - `option_scid_alias` (bit 46)
* - `option_zeroconf` (bit 50)
*/
static const size_t variants[] = {
OPT_ZEROCONF,
};
Expand Down
2 changes: 1 addition & 1 deletion common/gossip_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

/* BOLT #7:
*
* - MUST NOT send `announcement_signatures` messages until `funding_locked`
* - MUST NOT send `announcement_signatures` messages until `channel_ready`
* has been sent and received AND the funding transaction has at least six
* confirmations.
*/
Expand Down
2 changes: 1 addition & 1 deletion common/gossip_store.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static bool public_msg_type(enum peer_wire type)
case WIRE_ACCEPT_CHANNEL:
case WIRE_FUNDING_CREATED:
case WIRE_FUNDING_SIGNED:
case WIRE_FUNDING_LOCKED:
case WIRE_CHANNEL_READY:
case WIRE_OPEN_CHANNEL2:
case WIRE_ACCEPT_CHANNEL2:
case WIRE_INIT_RBF:
Expand Down
2 changes: 1 addition & 1 deletion connectd/gossip_rcvd_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static bool is_msg_gossip_broadcast(const u8 *cursor)
case WIRE_ACCEPT_CHANNEL:
case WIRE_FUNDING_CREATED:
case WIRE_FUNDING_SIGNED:
case WIRE_FUNDING_LOCKED:
case WIRE_CHANNEL_READY:
case WIRE_SHUTDOWN:
case WIRE_CLOSING_SIGNED:
case WIRE_UPDATE_ADD_HTLC:
Expand Down
2 changes: 1 addition & 1 deletion connectd/multiplex.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ static bool is_urgent(enum peer_wire type)
case WIRE_ACCEPT_CHANNEL:
case WIRE_FUNDING_CREATED:
case WIRE_FUNDING_SIGNED:
case WIRE_FUNDING_LOCKED:
case WIRE_CHANNEL_READY:
case WIRE_OPEN_CHANNEL2:
case WIRE_ACCEPT_CHANNEL2:
case WIRE_INIT_RBF:
Expand Down
2 changes: 1 addition & 1 deletion gossipd/gossipd.c
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ static void handle_recv_gossip(struct daemon *daemon, const u8 *outermsg)
case WIRE_ACCEPT_CHANNEL:
case WIRE_FUNDING_CREATED:
case WIRE_FUNDING_SIGNED:
case WIRE_FUNDING_LOCKED:
case WIRE_CHANNEL_READY:
case WIRE_SHUTDOWN:
case WIRE_CLOSING_SIGNED:
case WIRE_UPDATE_ADD_HTLC:
Expand Down
Loading

0 comments on commit 1b30ea4

Please sign in to comment.