mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-08 00:24:28 +01:00
doc: update BOLTs to bc86304b4b0af5fd5ce9d24f74e2ebbceb7e2730
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 <rusty@rustcorp.com.au> Changelog-Changed: Protocol: `funding_locked` is now called `channel_ready` as per latest BOLTs.
This commit is contained in:
@@ -221,7 +221,7 @@ struct channel *new_unsaved_channel(struct peer *peer,
|
||||
channel->open_attempt = NULL;
|
||||
|
||||
channel->last_htlc_sigs = NULL;
|
||||
channel->remote_funding_locked = false;
|
||||
channel->remote_channel_ready = false;
|
||||
channel->scid = NULL;
|
||||
channel->next_index[LOCAL] = 1;
|
||||
channel->next_index[REMOTE] = 1;
|
||||
@@ -345,7 +345,7 @@ struct channel *new_channel(struct peer *peer, u64 dbid,
|
||||
struct amount_sat funding_sats,
|
||||
struct amount_msat push,
|
||||
struct amount_sat our_funds,
|
||||
bool remote_funding_locked,
|
||||
bool remote_channel_ready,
|
||||
/* NULL or stolen */
|
||||
struct short_channel_id *scid,
|
||||
struct short_channel_id *alias_local STEALS,
|
||||
@@ -441,7 +441,7 @@ struct channel *new_channel(struct peer *peer, u64 dbid,
|
||||
channel->funding_sats = funding_sats;
|
||||
channel->push = push;
|
||||
channel->our_funds = our_funds;
|
||||
channel->remote_funding_locked = remote_funding_locked;
|
||||
channel->remote_channel_ready = remote_channel_ready;
|
||||
channel->scid = tal_steal(channel, scid);
|
||||
channel->alias[LOCAL] = tal_steal(channel, alias_local);
|
||||
channel->alias[REMOTE] = tal_steal(channel, alias_remote); /* Haven't gotten one yet. */
|
||||
|
||||
@@ -138,7 +138,7 @@ struct channel {
|
||||
struct amount_sat our_funds;
|
||||
|
||||
struct amount_msat push;
|
||||
bool remote_funding_locked;
|
||||
bool remote_channel_ready;
|
||||
/* Channel if locked locally. */
|
||||
struct short_channel_id *scid;
|
||||
|
||||
@@ -291,7 +291,7 @@ struct channel *new_channel(struct peer *peer, u64 dbid,
|
||||
struct amount_sat funding_sats,
|
||||
struct amount_msat push,
|
||||
struct amount_sat our_funds,
|
||||
bool remote_funding_locked,
|
||||
bool remote_channel_ready,
|
||||
/* NULL or stolen */
|
||||
struct short_channel_id *scid STEALS,
|
||||
struct short_channel_id *alias_local STEALS,
|
||||
|
||||
@@ -195,7 +195,7 @@ static void lockin_complete(struct channel *channel)
|
||||
}
|
||||
|
||||
/* We set this once they're locked in. */
|
||||
assert(channel->remote_funding_locked);
|
||||
assert(channel->remote_channel_ready);
|
||||
|
||||
/* We might have already started shutting down */
|
||||
if (channel->state != CHANNELD_AWAITING_LOCKIN) {
|
||||
@@ -225,41 +225,37 @@ static void lockin_complete(struct channel *channel)
|
||||
true);
|
||||
}
|
||||
|
||||
bool channel_on_funding_locked(struct channel *channel,
|
||||
struct pubkey *next_per_commitment_point)
|
||||
bool channel_on_channel_ready(struct channel *channel,
|
||||
struct pubkey *next_per_commitment_point)
|
||||
{
|
||||
if (channel->remote_funding_locked) {
|
||||
if (channel->remote_channel_ready) {
|
||||
channel_internal_error(channel,
|
||||
"channel_got_funding_locked twice");
|
||||
"channel_got_channel_ready twice");
|
||||
return false;
|
||||
}
|
||||
update_per_commit_point(channel, next_per_commitment_point);
|
||||
|
||||
log_debug(channel->log, "Got funding_locked");
|
||||
channel->remote_funding_locked = true;
|
||||
log_debug(channel->log, "Got channel_ready");
|
||||
channel->remote_channel_ready = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* We were informed by channeld that it announced the channel and sent
|
||||
* an update, so we can now start sending a node_announcement. The
|
||||
* first step is to build the provisional announcement and ask the HSM
|
||||
* to sign it. */
|
||||
|
||||
static void peer_got_funding_locked(struct channel *channel, const u8 *msg)
|
||||
/* We were informed by channeld that channel is ready (reached mindepth) */
|
||||
static void peer_got_channel_ready(struct channel *channel, const u8 *msg)
|
||||
{
|
||||
struct pubkey next_per_commitment_point;
|
||||
struct short_channel_id *alias_remote;
|
||||
|
||||
if (!fromwire_channeld_got_funding_locked(tmpctx,
|
||||
if (!fromwire_channeld_got_channel_ready(tmpctx,
|
||||
msg, &next_per_commitment_point, &alias_remote)) {
|
||||
channel_internal_error(channel,
|
||||
"bad channel_got_funding_locked %s",
|
||||
"bad channel_got_channel_ready %s",
|
||||
tal_hex(channel, msg));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!channel_on_funding_locked(channel, &next_per_commitment_point))
|
||||
if (!channel_on_channel_ready(channel, &next_per_commitment_point))
|
||||
return;
|
||||
|
||||
if (channel->alias[REMOTE] == NULL)
|
||||
@@ -538,8 +534,8 @@ static unsigned channel_msg(struct subd *sd, const u8 *msg, const int *fds)
|
||||
case WIRE_CHANNELD_GOT_REVOKE:
|
||||
peer_got_revoke(sd->channel, msg);
|
||||
break;
|
||||
case WIRE_CHANNELD_GOT_FUNDING_LOCKED:
|
||||
peer_got_funding_locked(sd->channel, msg);
|
||||
case WIRE_CHANNELD_GOT_CHANNEL_READY:
|
||||
peer_got_channel_ready(sd->channel, msg);
|
||||
break;
|
||||
case WIRE_CHANNELD_GOT_ANNOUNCEMENT:
|
||||
peer_got_announcement(sd->channel, msg);
|
||||
@@ -765,7 +761,7 @@ bool peer_start_channeld(struct channel *channel,
|
||||
channel->next_htlc_id,
|
||||
htlcs,
|
||||
channel->scid != NULL,
|
||||
channel->remote_funding_locked,
|
||||
channel->remote_channel_ready,
|
||||
&scid,
|
||||
reconnected,
|
||||
/* Anything that indicates we are or have
|
||||
@@ -859,12 +855,11 @@ bool channel_tell_depth(struct lightningd *ld,
|
||||
take(towire_channeld_funding_depth(
|
||||
NULL, channel->scid, channel->alias[LOCAL], depth)));
|
||||
|
||||
if (channel->remote_funding_locked &&
|
||||
channel->state == CHANNELD_AWAITING_LOCKIN &&
|
||||
depth >= channel->minimum_depth)
|
||||
if (channel->remote_channel_ready &&
|
||||
channel->state == CHANNELD_AWAITING_LOCKIN &&
|
||||
depth >= channel->minimum_depth) {
|
||||
lockin_complete(channel);
|
||||
|
||||
else if (depth == 1 && channel->minimum_depth == 0) {
|
||||
} else if (depth == 1 && channel->minimum_depth == 0) {
|
||||
/* If we have a zeroconf channel, i.e., no scid yet
|
||||
* but have exchange `channel_ready` messages, then we
|
||||
* need to fire a second time, in order to trigger the
|
||||
|
||||
@@ -30,9 +30,9 @@ void channel_notify_new_block(struct lightningd *ld,
|
||||
struct command_result *cancel_channel_before_broadcast(struct command *cmd,
|
||||
struct peer *peer);
|
||||
|
||||
/* Update the channel info on funding locked */
|
||||
bool channel_on_funding_locked(struct channel *channel,
|
||||
struct pubkey *next_per_commitment_point);
|
||||
/* Update the channel info on channel_ready */
|
||||
bool channel_on_channel_ready(struct channel *channel,
|
||||
struct pubkey *next_per_commitment_point);
|
||||
|
||||
/* Record channel open (coin movement notifications) */
|
||||
void channel_record_open(struct channel *channel, u32 blockheight, bool record_push);
|
||||
|
||||
@@ -1631,7 +1631,7 @@ static void handle_peer_tx_sigs_sent(struct subd *dualopend,
|
||||
&channel->peer->id,
|
||||
&channel->funding_sats,
|
||||
&channel->funding.txid,
|
||||
channel->remote_funding_locked);
|
||||
channel->remote_channel_ready);
|
||||
|
||||
/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2
|
||||
* The receiving node: ...
|
||||
@@ -1714,7 +1714,7 @@ static void handle_peer_locked(struct subd *dualopend, const u8 *msg)
|
||||
|
||||
/* Updates channel with the next per-commit point etc, calls
|
||||
* channel_internal_error on failure */
|
||||
if (!channel_on_funding_locked(channel, &remote_per_commit))
|
||||
if (!channel_on_channel_ready(channel, &remote_per_commit))
|
||||
return;
|
||||
|
||||
/* Remember that we got the lock-in */
|
||||
@@ -1737,7 +1737,7 @@ static void handle_channel_locked(struct subd *dualopend,
|
||||
peer_fd = new_peer_fd_arr(tmpctx, fds);
|
||||
|
||||
assert(channel->scid);
|
||||
assert(channel->remote_funding_locked);
|
||||
assert(channel->remote_channel_ready);
|
||||
|
||||
/* This can happen if we missed their sigs, for some reason */
|
||||
if (channel->state != DUALOPEND_AWAITING_LOCKIN)
|
||||
@@ -1997,7 +1997,7 @@ static void handle_peer_tx_sigs_msg(struct subd *dualopend,
|
||||
&channel->peer->id,
|
||||
&channel->funding_sats,
|
||||
&channel->funding.txid,
|
||||
channel->remote_funding_locked);
|
||||
channel->remote_channel_ready);
|
||||
|
||||
/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2
|
||||
* The receiving node: ...
|
||||
@@ -3364,10 +3364,14 @@ bool peer_start_dualopend(struct peer *peer,
|
||||
/* BOLT #2:
|
||||
*
|
||||
* The sender:
|
||||
* - SHOULD set `minimum_depth` to a number of blocks it
|
||||
* considers reasonable to avoid double-spending of the
|
||||
* funding transaction.
|
||||
* - if `channel_type` includes `option_zeroconf`:
|
||||
* - MUST set `minimum_depth` to zero.
|
||||
* - otherwise:
|
||||
* - SHOULD set `minimum_depth` to a number of blocks it
|
||||
* considers reasonable to avoid double-spending of the
|
||||
* funding transaction.
|
||||
*/
|
||||
/* FIXME: We should override this to 0 in the openchannel2 hook of we want zeroconf*/
|
||||
channel->minimum_depth = peer->ld->config.anchor_confirms;
|
||||
|
||||
msg = towire_dualopend_init(NULL, chainparams,
|
||||
@@ -3470,7 +3474,7 @@ bool peer_restart_dualopend(struct peer *peer,
|
||||
inflight->funding_psbt,
|
||||
channel->opener,
|
||||
channel->scid != NULL,
|
||||
channel->remote_funding_locked,
|
||||
channel->remote_channel_ready,
|
||||
channel->state == CHANNELD_SHUTTING_DOWN,
|
||||
channel->shutdown_scriptpubkey[REMOTE] != NULL,
|
||||
channel->shutdown_scriptpubkey[LOCAL],
|
||||
|
||||
@@ -625,7 +625,7 @@ enum watch_result onchaind_funding_spent(struct channel *channel,
|
||||
channel_fail_permanent(channel, reason, "Funding transaction spent");
|
||||
|
||||
/* If we haven't posted the open event yet, post an open */
|
||||
if (!channel->scid || !channel->remote_funding_locked) {
|
||||
if (!channel->scid || !channel->remote_channel_ready) {
|
||||
u32 blkh;
|
||||
/* Blockheight will be zero if it's not in chain */
|
||||
blkh = wallet_transaction_height(channel->peer->ld->wallet,
|
||||
|
||||
@@ -55,9 +55,14 @@ new_uncommitted_channel(struct peer *peer)
|
||||
/* BOLT #2:
|
||||
*
|
||||
* The sender:
|
||||
* - SHOULD set `minimum_depth` to a number of blocks it considers
|
||||
* reasonable to avoid double-spending of the funding transaction.
|
||||
* - if `channel_type` includes `option_zeroconf`:
|
||||
* - MUST set `minimum_depth` to zero.
|
||||
* - otherwise:
|
||||
* - SHOULD set `minimum_depth` to a number of blocks it
|
||||
* considers reasonable to avoid double-spending of the
|
||||
* funding transaction.
|
||||
*/
|
||||
/* We override this in openchannel hook if we want zeroconf */
|
||||
uc->minimum_depth = ld->config.anchor_confirms;
|
||||
|
||||
/* Declare the new channel to the HSM. */
|
||||
|
||||
@@ -178,7 +178,7 @@ wallet_commit_channel(struct lightningd *ld,
|
||||
funding_sats,
|
||||
push,
|
||||
local_funding,
|
||||
false, /* !remote_funding_locked */
|
||||
false, /* !remote_channel_ready */
|
||||
NULL, /* no scid yet */
|
||||
alias_local, /* But maybe we have an alias we want to use? */
|
||||
NULL, /* They haven't told us an alias yet */
|
||||
@@ -539,7 +539,7 @@ static void opening_fundee_finished(struct subd *openingd,
|
||||
|
||||
/* Tell plugins about the success */
|
||||
notify_channel_opened(ld, &channel->peer->id, &channel->funding_sats,
|
||||
&channel->funding.txid, channel->remote_funding_locked);
|
||||
&channel->funding.txid, channel->remote_channel_ready);
|
||||
|
||||
if (pbase)
|
||||
wallet_penalty_base_add(ld->wallet, channel->dbid, pbase);
|
||||
@@ -1213,8 +1213,12 @@ static struct command_result *json_fundchannel_start(struct command *cmd,
|
||||
/* BOLT #2:
|
||||
*
|
||||
* The sender:
|
||||
* - SHOULD set `minimum_depth` to a number of blocks it considers
|
||||
* reasonable to avoid double-spending of the funding transaction.
|
||||
* - if `channel_type` includes `option_zeroconf`:
|
||||
* - MUST set `minimum_depth` to zero.
|
||||
* - otherwise:
|
||||
* - SHOULD set `minimum_depth` to a number of blocks it
|
||||
* considers reasonable to avoid double-spending of the
|
||||
* funding transaction.
|
||||
*/
|
||||
assert(mindepth != NULL);
|
||||
fc->uc->minimum_depth = *mindepth;
|
||||
@@ -1376,7 +1380,7 @@ static struct channel *stub_chan(struct command *cmd,
|
||||
funding_sats,
|
||||
AMOUNT_MSAT(0),
|
||||
AMOUNT_SAT(0),
|
||||
true, /* !remote_funding_locked */
|
||||
true, /* remote_channel_ready */
|
||||
scid,
|
||||
scid,
|
||||
scid,
|
||||
|
||||
Reference in New Issue
Block a user