mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +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:
2
Makefile
2
Makefile
@@ -23,7 +23,7 @@ CCANDIR := ccan
|
|||||||
|
|
||||||
# Where we keep the BOLT RFCs
|
# Where we keep the BOLT RFCs
|
||||||
BOLTDIR := ../bolts/
|
BOLTDIR := ../bolts/
|
||||||
DEFAULT_BOLTVERSION := 03468e17563650fb9bfe58b2da4d1e5d28e92009
|
DEFAULT_BOLTVERSION := bc86304b4b0af5fd5ce9d24f74e2ebbceb7e2730
|
||||||
# Can be overridden on cmdline.
|
# Can be overridden on cmdline.
|
||||||
BOLTVERSION := $(DEFAULT_BOLTVERSION)
|
BOLTVERSION := $(DEFAULT_BOLTVERSION)
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
* We're fairly synchronous: our main loop looks for master or
|
||||||
* peer requests and services them synchronously.
|
* peer requests and services them synchronously.
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
|
|
||||||
struct peer {
|
struct peer {
|
||||||
struct per_peer_state *pps;
|
struct per_peer_state *pps;
|
||||||
bool funding_locked[NUM_SIDES];
|
bool channel_ready[NUM_SIDES];
|
||||||
u64 next_index[NUM_SIDES];
|
u64 next_index[NUM_SIDES];
|
||||||
|
|
||||||
/* Features peer supports. */
|
/* Features peer supports. */
|
||||||
@@ -182,7 +182,7 @@ struct peer {
|
|||||||
/* Penalty bases for this channel / peer. */
|
/* Penalty bases for this channel / peer. */
|
||||||
struct penalty_base **pbases;
|
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;
|
bool tx_sigs_allowed;
|
||||||
|
|
||||||
/* Have we announced the real scid with a
|
/* Have we announced the real scid with a
|
||||||
@@ -204,7 +204,7 @@ static void start_commit_timer(struct peer *peer);
|
|||||||
|
|
||||||
static void billboard_update(const 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->have_sigs,
|
||||||
peer->shutdown_sent,
|
peer->shutdown_sent,
|
||||||
peer->depth_togo,
|
peer->depth_togo,
|
||||||
@@ -539,7 +539,7 @@ static void channel_announcement_negotiate(struct peer *peer)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* Can't do anything until funding is locked. */
|
/* 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;
|
return;
|
||||||
|
|
||||||
if (!peer->channel_local_active) {
|
if (!peer->channel_local_active) {
|
||||||
@@ -560,7 +560,7 @@ static void channel_announcement_negotiate(struct peer *peer)
|
|||||||
* A node:
|
* A node:
|
||||||
* - if the `open_channel` message has the `announce_channel` bit set AND a `shutdown` message has not been sent:
|
* - 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 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.
|
* has been sent and received AND the funding transaction has at least six confirmations.
|
||||||
* - otherwise:
|
* - otherwise:
|
||||||
* - MUST NOT send the `announcement_signatures` message.
|
* - MUST NOT send the `announcement_signatures` message.
|
||||||
@@ -570,7 +570,7 @@ static void channel_announcement_negotiate(struct peer *peer)
|
|||||||
|
|
||||||
/* BOLT #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.
|
* has been sent and received AND the funding transaction has at least six confirmations.
|
||||||
*/
|
*/
|
||||||
if (peer->announce_depth_reached && !peer->have_sigs[LOCAL]) {
|
if (peer->announce_depth_reached && !peer->have_sigs[LOCAL]) {
|
||||||
@@ -602,18 +602,18 @@ 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 channel_id chanid;
|
||||||
struct tlv_funding_locked_tlvs *tlvs;
|
struct tlv_channel_ready_tlvs *tlvs;
|
||||||
/* BOLT #2:
|
/* BOLT #2:
|
||||||
*
|
*
|
||||||
* A node:
|
* A node:
|
||||||
*...
|
*...
|
||||||
* - upon reconnection:
|
* - 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;
|
return;
|
||||||
|
|
||||||
/* Too late, we're shutting down! */
|
/* Too late, we're shutting down! */
|
||||||
@@ -621,10 +621,10 @@ static void handle_peer_funding_locked(struct peer *peer, const u8 *msg)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
peer->old_remote_per_commit = peer->remote_per_commit;
|
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->remote_per_commit, &tlvs))
|
||||||
peer_failed_warn(peer->pps, &peer->channel_id,
|
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))
|
if (!channel_id_eq(&chanid, &peer->channel_id))
|
||||||
peer_failed_err(peer->pps, &chanid,
|
peer_failed_err(peer->pps, &chanid,
|
||||||
@@ -634,17 +634,17 @@ static void handle_peer_funding_locked(struct peer *peer, const u8 *msg)
|
|||||||
&peer->channel_id));
|
&peer->channel_id));
|
||||||
|
|
||||||
peer->tx_sigs_allowed = false;
|
peer->tx_sigs_allowed = false;
|
||||||
peer->funding_locked[REMOTE] = true;
|
peer->channel_ready[REMOTE] = true;
|
||||||
if (tlvs->alias != NULL) {
|
if (tlvs->short_channel_id != NULL) {
|
||||||
status_debug(
|
status_debug(
|
||||||
"Peer told us that they'll use alias=%s for this channel",
|
"Peer told us that they'll use alias=%s for this channel",
|
||||||
type_to_string(tmpctx, struct short_channel_id,
|
type_to_string(tmpctx, struct short_channel_id,
|
||||||
tlvs->alias));
|
tlvs->short_channel_id));
|
||||||
peer->short_channel_ids[REMOTE] = *tlvs->alias;
|
peer->short_channel_ids[REMOTE] = *tlvs->short_channel_id;
|
||||||
}
|
}
|
||||||
wire_sync_write(MASTER_FD,
|
wire_sync_write(MASTER_FD,
|
||||||
take(towire_channeld_got_funding_locked(
|
take(towire_channeld_got_channel_ready(
|
||||||
NULL, &peer->remote_per_commit, tlvs->alias)));
|
NULL, &peer->remote_per_commit, tlvs->short_channel_id)));
|
||||||
|
|
||||||
channel_announcement_negotiate(peer);
|
channel_announcement_negotiate(peer);
|
||||||
billboard_update(peer);
|
billboard_update(peer);
|
||||||
@@ -2119,8 +2119,8 @@ static void handle_unexpected_tx_sigs(struct peer *peer, const u8 *msg)
|
|||||||
struct bitcoin_txid txid;
|
struct bitcoin_txid txid;
|
||||||
|
|
||||||
/* In a rare case, a v2 peer may re-send a tx_sigs message.
|
/* In a rare case, a v2 peer may re-send a tx_sigs message.
|
||||||
* This happens when they've/we've exchanged funding_locked,
|
* This happens when they've/we've exchanged channel_ready,
|
||||||
* but they did not receive our funding_locked. */
|
* but they did not receive our channel_ready. */
|
||||||
if (!fromwire_tx_signatures(tmpctx, msg, &cid, &txid,
|
if (!fromwire_tx_signatures(tmpctx, msg, &cid, &txid,
|
||||||
cast_const3(struct witness_stack ***, &ws)))
|
cast_const3(struct witness_stack ***, &ws)))
|
||||||
peer_failed_warn(peer->pps, &peer->channel_id,
|
peer_failed_warn(peer->pps, &peer->channel_id,
|
||||||
@@ -2212,9 +2212,9 @@ static void peer_in(struct peer *peer, const u8 *msg)
|
|||||||
if (handle_peer_error(peer->pps, &peer->channel_id, msg))
|
if (handle_peer_error(peer->pps, &peer->channel_id, msg))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Must get funding_locked before almost anything. */
|
/* Must get channel_ready before almost anything. */
|
||||||
if (!peer->funding_locked[REMOTE]) {
|
if (!peer->channel_ready[REMOTE]) {
|
||||||
if (type != WIRE_FUNDING_LOCKED
|
if (type != WIRE_CHANNEL_READY
|
||||||
&& type != WIRE_SHUTDOWN
|
&& type != WIRE_SHUTDOWN
|
||||||
/* We expect these for v2 !! */
|
/* We expect these for v2 !! */
|
||||||
&& type != WIRE_TX_SIGNATURES
|
&& type != WIRE_TX_SIGNATURES
|
||||||
@@ -2228,8 +2228,8 @@ static void peer_in(struct peer *peer, const u8 *msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case WIRE_FUNDING_LOCKED:
|
case WIRE_CHANNEL_READY:
|
||||||
handle_peer_funding_locked(peer, msg);
|
handle_peer_channel_ready(peer, msg);
|
||||||
return;
|
return;
|
||||||
case WIRE_ANNOUNCEMENT_SIGNATURES:
|
case WIRE_ANNOUNCEMENT_SIGNATURES:
|
||||||
handle_peer_announcement_signatures(peer, msg);
|
handle_peer_announcement_signatures(peer, msg);
|
||||||
@@ -2664,7 +2664,7 @@ static void check_current_dataloss_fields(struct peer *peer,
|
|||||||
status_debug("option_data_loss_protect: fields are correct");
|
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. */
|
/* ... or announcement_signatures. Sigh, let's handle whatever they send. */
|
||||||
static bool capture_premature_msg(const u8 ***shit_lnd_says, const u8 *msg)
|
static bool capture_premature_msg(const u8 ***shit_lnd_says, const u8 *msg)
|
||||||
{
|
{
|
||||||
@@ -2941,19 +2941,21 @@ skip_tlvs:
|
|||||||
*
|
*
|
||||||
* - if `next_commitment_number` is 1 in both the
|
* - if `next_commitment_number` is 1 in both the
|
||||||
* `channel_reestablish` it sent and received:
|
* `channel_reestablish` it sent and received:
|
||||||
* - MUST retransmit `funding_locked`.
|
* - MUST retransmit `channel_ready`.
|
||||||
* - otherwise:
|
* - 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
|
&& peer->next_index[LOCAL] == 1
|
||||||
&& next_commitment_number == 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",
|
status_debug("Retransmitting funding_locked for channel %s",
|
||||||
type_to_string(tmpctx, struct channel_id, &peer->channel_id));
|
type_to_string(tmpctx, struct channel_id, &peer->channel_id));
|
||||||
/* Contains per commit point #1, for first post-opening commit */
|
/* Contains per commit point #1, for first post-opening commit */
|
||||||
msg = towire_funding_locked(NULL,
|
msg = towire_channel_ready(NULL,
|
||||||
&peer->channel_id,
|
&peer->channel_id,
|
||||||
&peer->next_local_per_commit, tlvs);
|
&peer->next_local_per_commit, tlvs);
|
||||||
peer_write(peer->pps, take(msg));
|
peer_write(peer->pps, take(msg));
|
||||||
@@ -3229,7 +3231,7 @@ static void handle_funding_depth(struct peer *peer, const u8 *msg)
|
|||||||
{
|
{
|
||||||
u32 depth;
|
u32 depth;
|
||||||
struct short_channel_id *scid, *alias_local;
|
struct short_channel_id *scid, *alias_local;
|
||||||
struct tlv_funding_locked_tlvs *tlvs;
|
struct tlv_channel_ready_tlvs *tlvs;
|
||||||
struct pubkey point;
|
struct pubkey point;
|
||||||
|
|
||||||
if (!fromwire_channeld_funding_depth(tmpctx,
|
if (!fromwire_channeld_funding_depth(tmpctx,
|
||||||
@@ -3258,25 +3260,25 @@ static void handle_funding_depth(struct peer *peer, const u8 *msg)
|
|||||||
else if (alias_local)
|
else if (alias_local)
|
||||||
peer->short_channel_ids[LOCAL] = *alias_local;
|
peer->short_channel_ids[LOCAL] = *alias_local;
|
||||||
|
|
||||||
if (!peer->funding_locked[LOCAL]) {
|
if (!peer->channel_ready[LOCAL]) {
|
||||||
status_debug("funding_locked: sending commit index"
|
status_debug("channel_ready: sending commit index"
|
||||||
" %"PRIu64": %s",
|
" %"PRIu64": %s",
|
||||||
peer->next_index[LOCAL],
|
peer->next_index[LOCAL],
|
||||||
type_to_string(tmpctx, struct pubkey,
|
type_to_string(tmpctx, struct pubkey,
|
||||||
&peer->next_local_per_commit));
|
&peer->next_local_per_commit));
|
||||||
tlvs = tlv_funding_locked_tlvs_new(tmpctx);
|
tlvs = tlv_channel_ready_tlvs_new(tmpctx);
|
||||||
tlvs->alias = alias_local;
|
tlvs->short_channel_id = alias_local;
|
||||||
|
|
||||||
/* Need to retrieve the first point again, even if we
|
/* 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. */
|
* first one. */
|
||||||
get_per_commitment_point(1, &point, NULL);
|
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);
|
&point, tlvs);
|
||||||
peer_write(peer->pps, take(msg));
|
peer_write(peer->pps, take(msg));
|
||||||
|
|
||||||
peer->funding_locked[LOCAL] = true;
|
peer->channel_ready[LOCAL] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
peer->announce_depth_reached = (depth >= ANNOUNCE_MIN_DEPTH);
|
peer->announce_depth_reached = (depth >= ANNOUNCE_MIN_DEPTH);
|
||||||
@@ -3310,7 +3312,7 @@ static void handle_offer_htlc(struct peer *peer, const u8 *inmsg)
|
|||||||
struct amount_sat htlc_fee;
|
struct amount_sat htlc_fee;
|
||||||
struct pubkey *blinding;
|
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,
|
status_failed(STATUS_FAIL_MASTER_IO,
|
||||||
"funding not locked for offer_htlc");
|
"funding not locked for offer_htlc");
|
||||||
|
|
||||||
@@ -3745,7 +3747,7 @@ static void req_in(struct peer *peer, const u8 *msg)
|
|||||||
case WIRE_CHANNELD_SENDING_COMMITSIG_REPLY:
|
case WIRE_CHANNELD_SENDING_COMMITSIG_REPLY:
|
||||||
case WIRE_CHANNELD_GOT_COMMITSIG_REPLY:
|
case WIRE_CHANNELD_GOT_COMMITSIG_REPLY:
|
||||||
case WIRE_CHANNELD_GOT_REVOKE_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_ANNOUNCEMENT:
|
||||||
case WIRE_CHANNELD_GOT_SHUTDOWN:
|
case WIRE_CHANNELD_GOT_SHUTDOWN:
|
||||||
case WIRE_CHANNELD_SHUTDOWN_COMPLETE:
|
case WIRE_CHANNELD_SHUTDOWN_COMPLETE:
|
||||||
@@ -3837,8 +3839,8 @@ static void init_channel(struct peer *peer)
|
|||||||
&peer->revocations_received,
|
&peer->revocations_received,
|
||||||
&peer->htlc_id,
|
&peer->htlc_id,
|
||||||
&htlcs,
|
&htlcs,
|
||||||
&peer->funding_locked[LOCAL],
|
&peer->channel_ready[LOCAL],
|
||||||
&peer->funding_locked[REMOTE],
|
&peer->channel_ready[REMOTE],
|
||||||
&peer->short_channel_ids[LOCAL],
|
&peer->short_channel_ids[LOCAL],
|
||||||
&reconnected,
|
&reconnected,
|
||||||
&peer->send_shutdown,
|
&peer->send_shutdown,
|
||||||
|
|||||||
@@ -53,8 +53,8 @@ msgdata,channeld_init,revocations_received,u64,
|
|||||||
msgdata,channeld_init,next_htlc_id,u64,
|
msgdata,channeld_init,next_htlc_id,u64,
|
||||||
msgdata,channeld_init,num_existing_htlcs,u16,
|
msgdata,channeld_init,num_existing_htlcs,u16,
|
||||||
msgdata,channeld_init,htlcs,existing_htlc,num_existing_htlcs
|
msgdata,channeld_init,htlcs,existing_htlc,num_existing_htlcs
|
||||||
msgdata,channeld_init,local_funding_locked,bool,
|
msgdata,channeld_init,local_channel_ready,bool,
|
||||||
msgdata,channeld_init,remote_funding_locked,bool,
|
msgdata,channeld_init,remote_channel_ready,bool,
|
||||||
msgdata,channeld_init,funding_short_id,short_channel_id,
|
msgdata,channeld_init,funding_short_id,short_channel_id,
|
||||||
msgdata,channeld_init,reestablish,bool,
|
msgdata,channeld_init,reestablish,bool,
|
||||||
msgdata,channeld_init,send_shutdown,bool,
|
msgdata,channeld_init,send_shutdown,bool,
|
||||||
@@ -117,10 +117,10 @@ msgdata,channeld_fulfill_htlc,fulfilled_htlc,fulfilled_htlc,
|
|||||||
msgtype,channeld_fail_htlc,1006
|
msgtype,channeld_fail_htlc,1006
|
||||||
msgdata,channeld_fail_htlc,failed_htlc,failed_htlc,
|
msgdata,channeld_fail_htlc,failed_htlc,failed_htlc,
|
||||||
|
|
||||||
# When we receive funding_locked.
|
# When we receive channel_ready.
|
||||||
msgtype,channeld_got_funding_locked,1019
|
msgtype,channeld_got_channel_ready,1019
|
||||||
msgdata,channeld_got_funding_locked,next_per_commit_point,pubkey,
|
msgdata,channeld_got_channel_ready,next_per_commit_point,pubkey,
|
||||||
msgdata,channeld_got_funding_locked,alias,?short_channel_id,
|
msgdata,channeld_got_channel_ready,alias,?short_channel_id,
|
||||||
|
|
||||||
#include <common/penalty_base.h>
|
#include <common/penalty_base.h>
|
||||||
|
|
||||||
|
|||||||
|
Can't render this file because it has a wrong number of fields in line 14.
|
@@ -260,11 +260,11 @@ receive_offer(struct per_peer_state *pps,
|
|||||||
/* BOLT #2:
|
/* BOLT #2:
|
||||||
*
|
*
|
||||||
* - upon reconnection:
|
* - 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
|
/* This should only happen if we've made no commitments, but
|
||||||
* we don't have to check that: it's their problem. */
|
* 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);
|
msg = tal_free(msg);
|
||||||
/* BOLT #2:
|
/* BOLT #2:
|
||||||
* - if it has sent a previous `shutdown`:
|
* - if it has sent a previous `shutdown`:
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
* arbitrary combination (they represent the persistent features which
|
* arbitrary combination (they represent the persistent features which
|
||||||
* affect the channel operation).
|
* affect the channel operation).
|
||||||
*
|
*
|
||||||
* The currently defined types are:
|
* The currently defined basic types are:
|
||||||
* - no features (no bits set)
|
* - no features (no bits set)
|
||||||
* - `option_static_remotekey` (bit 12)
|
* - `option_static_remotekey` (bit 12)
|
||||||
* - `option_anchor_outputs` and `option_static_remotekey` (bits 20 and 12)
|
* - `option_anchor_outputs` and `option_static_remotekey` (bits 20 and 12)
|
||||||
@@ -118,8 +118,11 @@ struct channel_type *channel_type_accept(const tal_t *ctx,
|
|||||||
OPT_ZEROCONF,
|
OPT_ZEROCONF,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* The basic channel_types can have any number of the
|
/* BOLT #2:
|
||||||
* following optional bits. */
|
* Each basic type has the following variations allowed:
|
||||||
|
* - `option_scid_alias` (bit 46)
|
||||||
|
* - `option_zeroconf` (bit 50)
|
||||||
|
*/
|
||||||
static const size_t variants[] = {
|
static const size_t variants[] = {
|
||||||
OPT_ZEROCONF,
|
OPT_ZEROCONF,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
/* BOLT #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
|
* has been sent and received AND the funding transaction has at least six
|
||||||
* confirmations.
|
* confirmations.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ static bool public_msg_type(enum peer_wire type)
|
|||||||
case WIRE_ACCEPT_CHANNEL:
|
case WIRE_ACCEPT_CHANNEL:
|
||||||
case WIRE_FUNDING_CREATED:
|
case WIRE_FUNDING_CREATED:
|
||||||
case WIRE_FUNDING_SIGNED:
|
case WIRE_FUNDING_SIGNED:
|
||||||
case WIRE_FUNDING_LOCKED:
|
case WIRE_CHANNEL_READY:
|
||||||
case WIRE_OPEN_CHANNEL2:
|
case WIRE_OPEN_CHANNEL2:
|
||||||
case WIRE_ACCEPT_CHANNEL2:
|
case WIRE_ACCEPT_CHANNEL2:
|
||||||
case WIRE_INIT_RBF:
|
case WIRE_INIT_RBF:
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ static bool is_msg_gossip_broadcast(const u8 *cursor)
|
|||||||
case WIRE_ACCEPT_CHANNEL:
|
case WIRE_ACCEPT_CHANNEL:
|
||||||
case WIRE_FUNDING_CREATED:
|
case WIRE_FUNDING_CREATED:
|
||||||
case WIRE_FUNDING_SIGNED:
|
case WIRE_FUNDING_SIGNED:
|
||||||
case WIRE_FUNDING_LOCKED:
|
case WIRE_CHANNEL_READY:
|
||||||
case WIRE_SHUTDOWN:
|
case WIRE_SHUTDOWN:
|
||||||
case WIRE_CLOSING_SIGNED:
|
case WIRE_CLOSING_SIGNED:
|
||||||
case WIRE_UPDATE_ADD_HTLC:
|
case WIRE_UPDATE_ADD_HTLC:
|
||||||
|
|||||||
@@ -361,7 +361,7 @@ static bool is_urgent(enum peer_wire type)
|
|||||||
case WIRE_ACCEPT_CHANNEL:
|
case WIRE_ACCEPT_CHANNEL:
|
||||||
case WIRE_FUNDING_CREATED:
|
case WIRE_FUNDING_CREATED:
|
||||||
case WIRE_FUNDING_SIGNED:
|
case WIRE_FUNDING_SIGNED:
|
||||||
case WIRE_FUNDING_LOCKED:
|
case WIRE_CHANNEL_READY:
|
||||||
case WIRE_OPEN_CHANNEL2:
|
case WIRE_OPEN_CHANNEL2:
|
||||||
case WIRE_ACCEPT_CHANNEL2:
|
case WIRE_ACCEPT_CHANNEL2:
|
||||||
case WIRE_INIT_RBF:
|
case WIRE_INIT_RBF:
|
||||||
|
|||||||
@@ -529,7 +529,7 @@ static void handle_recv_gossip(struct daemon *daemon, const u8 *outermsg)
|
|||||||
case WIRE_ACCEPT_CHANNEL:
|
case WIRE_ACCEPT_CHANNEL:
|
||||||
case WIRE_FUNDING_CREATED:
|
case WIRE_FUNDING_CREATED:
|
||||||
case WIRE_FUNDING_SIGNED:
|
case WIRE_FUNDING_SIGNED:
|
||||||
case WIRE_FUNDING_LOCKED:
|
case WIRE_CHANNEL_READY:
|
||||||
case WIRE_SHUTDOWN:
|
case WIRE_SHUTDOWN:
|
||||||
case WIRE_CLOSING_SIGNED:
|
case WIRE_CLOSING_SIGNED:
|
||||||
case WIRE_UPDATE_ADD_HTLC:
|
case WIRE_UPDATE_ADD_HTLC:
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ struct channel *new_unsaved_channel(struct peer *peer,
|
|||||||
channel->open_attempt = NULL;
|
channel->open_attempt = NULL;
|
||||||
|
|
||||||
channel->last_htlc_sigs = NULL;
|
channel->last_htlc_sigs = NULL;
|
||||||
channel->remote_funding_locked = false;
|
channel->remote_channel_ready = false;
|
||||||
channel->scid = NULL;
|
channel->scid = NULL;
|
||||||
channel->next_index[LOCAL] = 1;
|
channel->next_index[LOCAL] = 1;
|
||||||
channel->next_index[REMOTE] = 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_sat funding_sats,
|
||||||
struct amount_msat push,
|
struct amount_msat push,
|
||||||
struct amount_sat our_funds,
|
struct amount_sat our_funds,
|
||||||
bool remote_funding_locked,
|
bool remote_channel_ready,
|
||||||
/* NULL or stolen */
|
/* NULL or stolen */
|
||||||
struct short_channel_id *scid,
|
struct short_channel_id *scid,
|
||||||
struct short_channel_id *alias_local STEALS,
|
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->funding_sats = funding_sats;
|
||||||
channel->push = push;
|
channel->push = push;
|
||||||
channel->our_funds = our_funds;
|
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->scid = tal_steal(channel, scid);
|
||||||
channel->alias[LOCAL] = tal_steal(channel, alias_local);
|
channel->alias[LOCAL] = tal_steal(channel, alias_local);
|
||||||
channel->alias[REMOTE] = tal_steal(channel, alias_remote); /* Haven't gotten one yet. */
|
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_sat our_funds;
|
||||||
|
|
||||||
struct amount_msat push;
|
struct amount_msat push;
|
||||||
bool remote_funding_locked;
|
bool remote_channel_ready;
|
||||||
/* Channel if locked locally. */
|
/* Channel if locked locally. */
|
||||||
struct short_channel_id *scid;
|
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_sat funding_sats,
|
||||||
struct amount_msat push,
|
struct amount_msat push,
|
||||||
struct amount_sat our_funds,
|
struct amount_sat our_funds,
|
||||||
bool remote_funding_locked,
|
bool remote_channel_ready,
|
||||||
/* NULL or stolen */
|
/* NULL or stolen */
|
||||||
struct short_channel_id *scid STEALS,
|
struct short_channel_id *scid STEALS,
|
||||||
struct short_channel_id *alias_local 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. */
|
/* 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 */
|
/* We might have already started shutting down */
|
||||||
if (channel->state != CHANNELD_AWAITING_LOCKIN) {
|
if (channel->state != CHANNELD_AWAITING_LOCKIN) {
|
||||||
@@ -225,41 +225,37 @@ static void lockin_complete(struct channel *channel)
|
|||||||
true);
|
true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool channel_on_funding_locked(struct channel *channel,
|
bool channel_on_channel_ready(struct channel *channel,
|
||||||
struct pubkey *next_per_commitment_point)
|
struct pubkey *next_per_commitment_point)
|
||||||
{
|
{
|
||||||
if (channel->remote_funding_locked) {
|
if (channel->remote_channel_ready) {
|
||||||
channel_internal_error(channel,
|
channel_internal_error(channel,
|
||||||
"channel_got_funding_locked twice");
|
"channel_got_channel_ready twice");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
update_per_commit_point(channel, next_per_commitment_point);
|
update_per_commit_point(channel, next_per_commitment_point);
|
||||||
|
|
||||||
log_debug(channel->log, "Got funding_locked");
|
log_debug(channel->log, "Got channel_ready");
|
||||||
channel->remote_funding_locked = true;
|
channel->remote_channel_ready = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We were informed by channeld that it announced the channel and sent
|
/* We were informed by channeld that channel is ready (reached mindepth) */
|
||||||
* an update, so we can now start sending a node_announcement. The
|
static void peer_got_channel_ready(struct channel *channel, const u8 *msg)
|
||||||
* 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)
|
|
||||||
{
|
{
|
||||||
struct pubkey next_per_commitment_point;
|
struct pubkey next_per_commitment_point;
|
||||||
struct short_channel_id *alias_remote;
|
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)) {
|
msg, &next_per_commitment_point, &alias_remote)) {
|
||||||
channel_internal_error(channel,
|
channel_internal_error(channel,
|
||||||
"bad channel_got_funding_locked %s",
|
"bad channel_got_channel_ready %s",
|
||||||
tal_hex(channel, msg));
|
tal_hex(channel, msg));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!channel_on_funding_locked(channel, &next_per_commitment_point))
|
if (!channel_on_channel_ready(channel, &next_per_commitment_point))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (channel->alias[REMOTE] == NULL)
|
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:
|
case WIRE_CHANNELD_GOT_REVOKE:
|
||||||
peer_got_revoke(sd->channel, msg);
|
peer_got_revoke(sd->channel, msg);
|
||||||
break;
|
break;
|
||||||
case WIRE_CHANNELD_GOT_FUNDING_LOCKED:
|
case WIRE_CHANNELD_GOT_CHANNEL_READY:
|
||||||
peer_got_funding_locked(sd->channel, msg);
|
peer_got_channel_ready(sd->channel, msg);
|
||||||
break;
|
break;
|
||||||
case WIRE_CHANNELD_GOT_ANNOUNCEMENT:
|
case WIRE_CHANNELD_GOT_ANNOUNCEMENT:
|
||||||
peer_got_announcement(sd->channel, msg);
|
peer_got_announcement(sd->channel, msg);
|
||||||
@@ -765,7 +761,7 @@ bool peer_start_channeld(struct channel *channel,
|
|||||||
channel->next_htlc_id,
|
channel->next_htlc_id,
|
||||||
htlcs,
|
htlcs,
|
||||||
channel->scid != NULL,
|
channel->scid != NULL,
|
||||||
channel->remote_funding_locked,
|
channel->remote_channel_ready,
|
||||||
&scid,
|
&scid,
|
||||||
reconnected,
|
reconnected,
|
||||||
/* Anything that indicates we are or have
|
/* Anything that indicates we are or have
|
||||||
@@ -859,12 +855,11 @@ bool channel_tell_depth(struct lightningd *ld,
|
|||||||
take(towire_channeld_funding_depth(
|
take(towire_channeld_funding_depth(
|
||||||
NULL, channel->scid, channel->alias[LOCAL], depth)));
|
NULL, channel->scid, channel->alias[LOCAL], depth)));
|
||||||
|
|
||||||
if (channel->remote_funding_locked &&
|
if (channel->remote_channel_ready &&
|
||||||
channel->state == CHANNELD_AWAITING_LOCKIN &&
|
channel->state == CHANNELD_AWAITING_LOCKIN &&
|
||||||
depth >= channel->minimum_depth)
|
depth >= channel->minimum_depth) {
|
||||||
lockin_complete(channel);
|
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
|
/* If we have a zeroconf channel, i.e., no scid yet
|
||||||
* but have exchange `channel_ready` messages, then we
|
* but have exchange `channel_ready` messages, then we
|
||||||
* need to fire a second time, in order to trigger the
|
* 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 command_result *cancel_channel_before_broadcast(struct command *cmd,
|
||||||
struct peer *peer);
|
struct peer *peer);
|
||||||
|
|
||||||
/* Update the channel info on funding locked */
|
/* Update the channel info on channel_ready */
|
||||||
bool channel_on_funding_locked(struct channel *channel,
|
bool channel_on_channel_ready(struct channel *channel,
|
||||||
struct pubkey *next_per_commitment_point);
|
struct pubkey *next_per_commitment_point);
|
||||||
|
|
||||||
/* Record channel open (coin movement notifications) */
|
/* Record channel open (coin movement notifications) */
|
||||||
void channel_record_open(struct channel *channel, u32 blockheight, bool record_push);
|
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->peer->id,
|
||||||
&channel->funding_sats,
|
&channel->funding_sats,
|
||||||
&channel->funding.txid,
|
&channel->funding.txid,
|
||||||
channel->remote_funding_locked);
|
channel->remote_channel_ready);
|
||||||
|
|
||||||
/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2
|
/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2
|
||||||
* The receiving node: ...
|
* 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
|
/* Updates channel with the next per-commit point etc, calls
|
||||||
* channel_internal_error on failure */
|
* channel_internal_error on failure */
|
||||||
if (!channel_on_funding_locked(channel, &remote_per_commit))
|
if (!channel_on_channel_ready(channel, &remote_per_commit))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Remember that we got the lock-in */
|
/* 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);
|
peer_fd = new_peer_fd_arr(tmpctx, fds);
|
||||||
|
|
||||||
assert(channel->scid);
|
assert(channel->scid);
|
||||||
assert(channel->remote_funding_locked);
|
assert(channel->remote_channel_ready);
|
||||||
|
|
||||||
/* This can happen if we missed their sigs, for some reason */
|
/* This can happen if we missed their sigs, for some reason */
|
||||||
if (channel->state != DUALOPEND_AWAITING_LOCKIN)
|
if (channel->state != DUALOPEND_AWAITING_LOCKIN)
|
||||||
@@ -1997,7 +1997,7 @@ static void handle_peer_tx_sigs_msg(struct subd *dualopend,
|
|||||||
&channel->peer->id,
|
&channel->peer->id,
|
||||||
&channel->funding_sats,
|
&channel->funding_sats,
|
||||||
&channel->funding.txid,
|
&channel->funding.txid,
|
||||||
channel->remote_funding_locked);
|
channel->remote_channel_ready);
|
||||||
|
|
||||||
/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2
|
/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2
|
||||||
* The receiving node: ...
|
* The receiving node: ...
|
||||||
@@ -3364,10 +3364,14 @@ bool peer_start_dualopend(struct peer *peer,
|
|||||||
/* BOLT #2:
|
/* BOLT #2:
|
||||||
*
|
*
|
||||||
* The sender:
|
* The sender:
|
||||||
* - SHOULD set `minimum_depth` to a number of blocks it
|
* - if `channel_type` includes `option_zeroconf`:
|
||||||
* considers reasonable to avoid double-spending of the
|
* - MUST set `minimum_depth` to zero.
|
||||||
* funding transaction.
|
* - 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;
|
channel->minimum_depth = peer->ld->config.anchor_confirms;
|
||||||
|
|
||||||
msg = towire_dualopend_init(NULL, chainparams,
|
msg = towire_dualopend_init(NULL, chainparams,
|
||||||
@@ -3470,7 +3474,7 @@ bool peer_restart_dualopend(struct peer *peer,
|
|||||||
inflight->funding_psbt,
|
inflight->funding_psbt,
|
||||||
channel->opener,
|
channel->opener,
|
||||||
channel->scid != NULL,
|
channel->scid != NULL,
|
||||||
channel->remote_funding_locked,
|
channel->remote_channel_ready,
|
||||||
channel->state == CHANNELD_SHUTTING_DOWN,
|
channel->state == CHANNELD_SHUTTING_DOWN,
|
||||||
channel->shutdown_scriptpubkey[REMOTE] != NULL,
|
channel->shutdown_scriptpubkey[REMOTE] != NULL,
|
||||||
channel->shutdown_scriptpubkey[LOCAL],
|
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");
|
channel_fail_permanent(channel, reason, "Funding transaction spent");
|
||||||
|
|
||||||
/* If we haven't posted the open event yet, post an open */
|
/* 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;
|
u32 blkh;
|
||||||
/* Blockheight will be zero if it's not in chain */
|
/* Blockheight will be zero if it's not in chain */
|
||||||
blkh = wallet_transaction_height(channel->peer->ld->wallet,
|
blkh = wallet_transaction_height(channel->peer->ld->wallet,
|
||||||
|
|||||||
@@ -55,9 +55,14 @@ new_uncommitted_channel(struct peer *peer)
|
|||||||
/* BOLT #2:
|
/* BOLT #2:
|
||||||
*
|
*
|
||||||
* The sender:
|
* The sender:
|
||||||
* - SHOULD set `minimum_depth` to a number of blocks it considers
|
* - if `channel_type` includes `option_zeroconf`:
|
||||||
* reasonable to avoid double-spending of the funding transaction.
|
* - 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;
|
uc->minimum_depth = ld->config.anchor_confirms;
|
||||||
|
|
||||||
/* Declare the new channel to the HSM. */
|
/* Declare the new channel to the HSM. */
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ wallet_commit_channel(struct lightningd *ld,
|
|||||||
funding_sats,
|
funding_sats,
|
||||||
push,
|
push,
|
||||||
local_funding,
|
local_funding,
|
||||||
false, /* !remote_funding_locked */
|
false, /* !remote_channel_ready */
|
||||||
NULL, /* no scid yet */
|
NULL, /* no scid yet */
|
||||||
alias_local, /* But maybe we have an alias we want to use? */
|
alias_local, /* But maybe we have an alias we want to use? */
|
||||||
NULL, /* They haven't told us an alias yet */
|
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 */
|
/* Tell plugins about the success */
|
||||||
notify_channel_opened(ld, &channel->peer->id, &channel->funding_sats,
|
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)
|
if (pbase)
|
||||||
wallet_penalty_base_add(ld->wallet, channel->dbid, 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:
|
/* BOLT #2:
|
||||||
*
|
*
|
||||||
* The sender:
|
* The sender:
|
||||||
* - SHOULD set `minimum_depth` to a number of blocks it considers
|
* - if `channel_type` includes `option_zeroconf`:
|
||||||
* reasonable to avoid double-spending of the funding transaction.
|
* - 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);
|
assert(mindepth != NULL);
|
||||||
fc->uc->minimum_depth = *mindepth;
|
fc->uc->minimum_depth = *mindepth;
|
||||||
@@ -1376,7 +1380,7 @@ static struct channel *stub_chan(struct command *cmd,
|
|||||||
funding_sats,
|
funding_sats,
|
||||||
AMOUNT_MSAT(0),
|
AMOUNT_MSAT(0),
|
||||||
AMOUNT_SAT(0),
|
AMOUNT_SAT(0),
|
||||||
true, /* !remote_funding_locked */
|
true, /* remote_channel_ready */
|
||||||
scid,
|
scid,
|
||||||
scid,
|
scid,
|
||||||
scid,
|
scid,
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ struct state {
|
|||||||
struct feature_set *our_features;
|
struct feature_set *our_features;
|
||||||
|
|
||||||
/* Tally of which sides are locked, or not */
|
/* Tally of which sides are locked, or not */
|
||||||
bool funding_locked[NUM_SIDES];
|
bool channel_ready[NUM_SIDES];
|
||||||
|
|
||||||
/* Are we shutting down? */
|
/* Are we shutting down? */
|
||||||
bool shutdown_sent[NUM_SIDES];
|
bool shutdown_sent[NUM_SIDES];
|
||||||
@@ -380,7 +380,7 @@ static void negotiation_failed(struct state *state,
|
|||||||
|
|
||||||
static void billboard_update(struct state *state)
|
static void billboard_update(struct state *state)
|
||||||
{
|
{
|
||||||
const char *update = billboard_message(tmpctx, state->funding_locked,
|
const char *update = billboard_message(tmpctx, state->channel_ready,
|
||||||
NULL,
|
NULL,
|
||||||
state->shutdown_sent,
|
state->shutdown_sent,
|
||||||
0, /* Always zero? */
|
0, /* Always zero? */
|
||||||
@@ -930,9 +930,9 @@ static void handle_tx_sigs(struct state *state, const u8 *msg)
|
|||||||
open_err_fatal(state, "Bad tx_signatures %s",
|
open_err_fatal(state, "Bad tx_signatures %s",
|
||||||
tal_hex(msg, msg));
|
tal_hex(msg, msg));
|
||||||
|
|
||||||
/* Maybe they didn't get our funding_locked message ? */
|
/* Maybe they didn't get our channel_ready message ? */
|
||||||
if (state->funding_locked[LOCAL] && !state->reconnected) {
|
if (state->channel_ready[LOCAL] && !state->reconnected) {
|
||||||
status_broken("Got WIRE_TX_SIGNATURES after funding locked "
|
status_broken("Got WIRE_TX_SIGNATURES after channel_ready "
|
||||||
"for channel %s, ignoring: %s",
|
"for channel %s, ignoring: %s",
|
||||||
type_to_string(tmpctx, struct channel_id,
|
type_to_string(tmpctx, struct channel_id,
|
||||||
&state->channel_id),
|
&state->channel_id),
|
||||||
@@ -941,10 +941,10 @@ static void handle_tx_sigs(struct state *state, const u8 *msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* On reconnect, we expect them to resend tx_sigs if they haven't
|
/* On reconnect, we expect them to resend tx_sigs if they haven't
|
||||||
* gotten our funding_locked yet */
|
* gotten our channel_ready yet */
|
||||||
if (state->funding_locked[REMOTE] && !state->reconnected)
|
if (state->channel_ready[REMOTE] && !state->reconnected)
|
||||||
open_err_warn(state,
|
open_err_warn(state,
|
||||||
"tx_signatures sent after funding_locked %s",
|
"tx_signatures sent after channel_ready %s",
|
||||||
tal_hex(msg, msg));
|
tal_hex(msg, msg));
|
||||||
|
|
||||||
if (!tx_state->psbt)
|
if (!tx_state->psbt)
|
||||||
@@ -1128,18 +1128,18 @@ static void init_changeset(struct tx_state *tx_state, struct wally_psbt *psbt)
|
|||||||
tx_state->changeset = psbt_get_changeset(tx_state, empty_psbt, psbt);
|
tx_state->changeset = psbt_get_changeset(tx_state, empty_psbt, psbt);
|
||||||
}
|
}
|
||||||
|
|
||||||
static u8 *handle_funding_locked(struct state *state, u8 *msg)
|
static u8 *handle_channel_ready(struct state *state, u8 *msg)
|
||||||
{
|
{
|
||||||
struct channel_id cid;
|
struct channel_id cid;
|
||||||
struct pubkey remote_per_commit;
|
struct pubkey remote_per_commit;
|
||||||
struct tlv_funding_locked_tlvs *tlvs;
|
struct tlv_channel_ready_tlvs *tlvs;
|
||||||
|
|
||||||
if (!fromwire_funding_locked(tmpctx, msg, &cid, &remote_per_commit, &tlvs))
|
if (!fromwire_channel_ready(tmpctx, msg, &cid, &remote_per_commit, &tlvs))
|
||||||
open_err_fatal(state, "Bad funding_locked %s",
|
open_err_fatal(state, "Bad channel_ready %s",
|
||||||
tal_hex(msg, msg));
|
tal_hex(msg, msg));
|
||||||
|
|
||||||
if (!channel_id_eq(&cid, &state->channel_id))
|
if (!channel_id_eq(&cid, &state->channel_id))
|
||||||
open_err_fatal(state, "funding_locked ids don't match:"
|
open_err_fatal(state, "channel_ready ids don't match:"
|
||||||
" expected %s, got %s",
|
" expected %s, got %s",
|
||||||
type_to_string(msg, struct channel_id,
|
type_to_string(msg, struct channel_id,
|
||||||
&state->channel_id),
|
&state->channel_id),
|
||||||
@@ -1148,21 +1148,21 @@ static u8 *handle_funding_locked(struct state *state, u8 *msg)
|
|||||||
/* If we haven't gotten their tx_sigs yet, this is a protocol error */
|
/* If we haven't gotten their tx_sigs yet, this is a protocol error */
|
||||||
if (!state->tx_state->remote_funding_sigs_rcvd) {
|
if (!state->tx_state->remote_funding_sigs_rcvd) {
|
||||||
open_err_warn(state,
|
open_err_warn(state,
|
||||||
"funding_locked sent before tx_signatures %s",
|
"channel_ready sent before tx_signatures %s",
|
||||||
tal_hex(msg, msg));
|
tal_hex(msg, msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We save when the peer locks, so we do the right
|
/* We save when the peer locks, so we do the right
|
||||||
* thing on reconnects */
|
* thing on reconnects */
|
||||||
if (!state->funding_locked[REMOTE]) {
|
if (!state->channel_ready[REMOTE]) {
|
||||||
msg = towire_dualopend_peer_locked(NULL, &remote_per_commit);
|
msg = towire_dualopend_peer_locked(NULL, &remote_per_commit);
|
||||||
wire_sync_write(REQ_FD, take(msg));
|
wire_sync_write(REQ_FD, take(msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
state->funding_locked[REMOTE] = true;
|
state->channel_ready[REMOTE] = true;
|
||||||
billboard_update(state);
|
billboard_update(state);
|
||||||
|
|
||||||
if (state->funding_locked[LOCAL])
|
if (state->channel_ready[LOCAL])
|
||||||
return towire_dualopend_channel_locked(state);
|
return towire_dualopend_channel_locked(state);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -1247,8 +1247,8 @@ static u8 *opening_negotiate_msg(const tal_t *ctx, struct state *state)
|
|||||||
* startup an RBF */
|
* startup an RBF */
|
||||||
handle_tx_sigs(state, msg);
|
handle_tx_sigs(state, msg);
|
||||||
continue;
|
continue;
|
||||||
case WIRE_FUNDING_LOCKED:
|
case WIRE_CHANNEL_READY:
|
||||||
handle_funding_locked(state, msg);
|
handle_channel_ready(state, msg);
|
||||||
return NULL;
|
return NULL;
|
||||||
case WIRE_SHUTDOWN:
|
case WIRE_SHUTDOWN:
|
||||||
handle_peer_shutdown(state, msg);
|
handle_peer_shutdown(state, msg);
|
||||||
@@ -1608,7 +1608,7 @@ static bool run_tx_interactive(struct state *state,
|
|||||||
case WIRE_ACCEPT_CHANNEL:
|
case WIRE_ACCEPT_CHANNEL:
|
||||||
case WIRE_FUNDING_CREATED:
|
case WIRE_FUNDING_CREATED:
|
||||||
case WIRE_FUNDING_SIGNED:
|
case WIRE_FUNDING_SIGNED:
|
||||||
case WIRE_FUNDING_LOCKED:
|
case WIRE_CHANNEL_READY:
|
||||||
case WIRE_SHUTDOWN:
|
case WIRE_SHUTDOWN:
|
||||||
case WIRE_CLOSING_SIGNED:
|
case WIRE_CLOSING_SIGNED:
|
||||||
case WIRE_UPDATE_ADD_HTLC:
|
case WIRE_UPDATE_ADD_HTLC:
|
||||||
@@ -3388,19 +3388,19 @@ static void hsm_per_commitment_point(u64 index, struct pubkey *point)
|
|||||||
tal_hex(tmpctx, msg));
|
tal_hex(tmpctx, msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void send_funding_locked(struct state *state)
|
static void send_channel_ready(struct state *state)
|
||||||
{
|
{
|
||||||
u8 *msg;
|
u8 *msg;
|
||||||
struct pubkey next_local_per_commit;
|
struct pubkey next_local_per_commit;
|
||||||
struct tlv_funding_locked_tlvs *tlvs = tlv_funding_locked_tlvs_new(tmpctx);
|
struct tlv_channel_ready_tlvs *tlvs = tlv_channel_ready_tlvs_new(tmpctx);
|
||||||
/* Figure out the next local commit */
|
/* Figure out the next local commit */
|
||||||
hsm_per_commitment_point(1, &next_local_per_commit);
|
hsm_per_commitment_point(1, &next_local_per_commit);
|
||||||
|
|
||||||
msg = towire_funding_locked(NULL, &state->channel_id,
|
msg = towire_channel_ready(NULL, &state->channel_id,
|
||||||
&next_local_per_commit, tlvs);
|
&next_local_per_commit, tlvs);
|
||||||
peer_write(state->pps, take(msg));
|
peer_write(state->pps, take(msg));
|
||||||
|
|
||||||
state->funding_locked[LOCAL] = true;
|
state->channel_ready[LOCAL] = true;
|
||||||
billboard_update(state);
|
billboard_update(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3453,8 +3453,8 @@ static u8 *handle_funding_depth(struct state *state, u8 *msg)
|
|||||||
/* Tell gossipd the new channel exists before we tell peer. */
|
/* Tell gossipd the new channel exists before we tell peer. */
|
||||||
tell_gossipd_new_channel(state);
|
tell_gossipd_new_channel(state);
|
||||||
|
|
||||||
send_funding_locked(state);
|
send_channel_ready(state);
|
||||||
if (state->funding_locked[REMOTE])
|
if (state->channel_ready[REMOTE])
|
||||||
return towire_dualopend_channel_locked(state);
|
return towire_dualopend_channel_locked(state);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -3614,17 +3614,17 @@ static void do_reconnect_dance(struct state *state)
|
|||||||
/* It's possible we sent our sigs, but they didn't get them.
|
/* It's possible we sent our sigs, but they didn't get them.
|
||||||
* Resend our signatures, just in case */
|
* Resend our signatures, just in case */
|
||||||
if (psbt_side_finalized(tx_state->psbt, state->our_role)
|
if (psbt_side_finalized(tx_state->psbt, state->our_role)
|
||||||
&& !state->funding_locked[REMOTE]) {
|
&& !state->channel_ready[REMOTE]) {
|
||||||
msg = psbt_to_tx_sigs_msg(NULL, state, tx_state->psbt);
|
msg = psbt_to_tx_sigs_msg(NULL, state, tx_state->psbt);
|
||||||
peer_write(state->pps, take(msg));
|
peer_write(state->pps, take(msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->funding_locked[LOCAL]) {
|
if (state->channel_ready[LOCAL]) {
|
||||||
status_debug("Retransmitting funding_locked for channel %s",
|
status_debug("Retransmitting funding_locked for channel %s",
|
||||||
type_to_string(tmpctx,
|
type_to_string(tmpctx,
|
||||||
struct channel_id,
|
struct channel_id,
|
||||||
&state->channel_id));
|
&state->channel_id));
|
||||||
send_funding_locked(state);
|
send_channel_ready(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
peer_billboard(true, "Reconnected, and reestablished.");
|
peer_billboard(true, "Reconnected, and reestablished.");
|
||||||
@@ -3714,8 +3714,8 @@ static u8 *handle_peer_in(struct state *state)
|
|||||||
case WIRE_TX_SIGNATURES:
|
case WIRE_TX_SIGNATURES:
|
||||||
handle_tx_sigs(state, msg);
|
handle_tx_sigs(state, msg);
|
||||||
return NULL;
|
return NULL;
|
||||||
case WIRE_FUNDING_LOCKED:
|
case WIRE_CHANNEL_READY:
|
||||||
return handle_funding_locked(state, msg);
|
return handle_channel_ready(state, msg);
|
||||||
case WIRE_SHUTDOWN:
|
case WIRE_SHUTDOWN:
|
||||||
handle_peer_shutdown(state, msg);
|
handle_peer_shutdown(state, msg);
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -3833,8 +3833,8 @@ int main(int argc, char *argv[])
|
|||||||
= NULL;
|
= NULL;
|
||||||
|
|
||||||
/*~ We're not locked or shutting down quite yet */
|
/*~ We're not locked or shutting down quite yet */
|
||||||
state->funding_locked[LOCAL]
|
state->channel_ready[LOCAL]
|
||||||
= state->funding_locked[REMOTE]
|
= state->channel_ready[REMOTE]
|
||||||
= false;
|
= false;
|
||||||
state->shutdown_sent[LOCAL]
|
state->shutdown_sent[LOCAL]
|
||||||
= state->shutdown_sent[REMOTE]
|
= state->shutdown_sent[REMOTE]
|
||||||
@@ -3861,8 +3861,8 @@ int main(int argc, char *argv[])
|
|||||||
&state->first_per_commitment_point[REMOTE],
|
&state->first_per_commitment_point[REMOTE],
|
||||||
&state->tx_state->psbt,
|
&state->tx_state->psbt,
|
||||||
&opener,
|
&opener,
|
||||||
&state->funding_locked[LOCAL],
|
&state->channel_ready[LOCAL],
|
||||||
&state->funding_locked[REMOTE],
|
&state->channel_ready[REMOTE],
|
||||||
&state->shutdown_sent[LOCAL],
|
&state->shutdown_sent[LOCAL],
|
||||||
&state->shutdown_sent[REMOTE],
|
&state->shutdown_sent[REMOTE],
|
||||||
&state->upfront_shutdown_script[LOCAL],
|
&state->upfront_shutdown_script[LOCAL],
|
||||||
|
|||||||
@@ -839,8 +839,9 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg)
|
|||||||
/* BOLT #2:
|
/* BOLT #2:
|
||||||
* The receiving node MUST fail the channel if:
|
* The receiving node MUST fail the channel if:
|
||||||
*...
|
*...
|
||||||
* - It supports `channel_type`, `channel_type` was set, and the
|
* - It supports `channel_type` and `channel_type` was set:
|
||||||
* `type` is not suitable.
|
* - if `type` is not suitable.
|
||||||
|
* - if `type` includes `option_zeroconf` and it does not trust the sender to open an unconfirmed channel.
|
||||||
*/
|
*/
|
||||||
if (open_tlvs->channel_type) {
|
if (open_tlvs->channel_type) {
|
||||||
state->channel_type =
|
state->channel_type =
|
||||||
|
|||||||
@@ -1785,7 +1785,7 @@ def test_onchain_first_commit(node_factory, bitcoind):
|
|||||||
coin_mvt_plugin = os.path.join(os.getcwd(), 'tests/plugins/coin_movements.py')
|
coin_mvt_plugin = os.path.join(os.getcwd(), 'tests/plugins/coin_movements.py')
|
||||||
|
|
||||||
# HTLC 1->2, 1 fails just after funding.
|
# HTLC 1->2, 1 fails just after funding.
|
||||||
disconnects = ['+WIRE_FUNDING_LOCKED', 'permfail']
|
disconnects = ['+WIRE_CHANNEL_READY', 'permfail']
|
||||||
# Make locktime different, as we once had them reversed!
|
# Make locktime different, as we once had them reversed!
|
||||||
l1, l2 = node_factory.line_graph(2, opts=[{'disconnect': disconnects,
|
l1, l2 = node_factory.line_graph(2, opts=[{'disconnect': disconnects,
|
||||||
'plugin': coin_mvt_plugin},
|
'plugin': coin_mvt_plugin},
|
||||||
|
|||||||
@@ -679,7 +679,7 @@ def test_reconnect_no_update(node_factory, executor, bitcoind):
|
|||||||
reconnects. See comments for details.
|
reconnects. See comments for details.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
disconnects = ["-WIRE_FUNDING_LOCKED", "-WIRE_SHUTDOWN"]
|
disconnects = ["-WIRE_CHANNEL_READY", "-WIRE_SHUTDOWN"]
|
||||||
# Allow bad gossip because it might receive WIRE_CHANNEL_UPDATE before
|
# Allow bad gossip because it might receive WIRE_CHANNEL_UPDATE before
|
||||||
# announcement of the disconnection
|
# announcement of the disconnection
|
||||||
l1 = node_factory.get_node(may_reconnect=True, allow_bad_gossip=True)
|
l1 = node_factory.get_node(may_reconnect=True, allow_bad_gossip=True)
|
||||||
@@ -715,8 +715,8 @@ def test_reconnect_no_update(node_factory, executor, bitcoind):
|
|||||||
@pytest.mark.openchannel('v2')
|
@pytest.mark.openchannel('v2')
|
||||||
def test_reconnect_normal(node_factory):
|
def test_reconnect_normal(node_factory):
|
||||||
# Should reconnect fine even if locked message gets lost.
|
# Should reconnect fine even if locked message gets lost.
|
||||||
disconnects = ['-WIRE_FUNDING_LOCKED',
|
disconnects = ['-WIRE_CHANNEL_READY',
|
||||||
'+WIRE_FUNDING_LOCKED']
|
'+WIRE_CHANNEL_READY']
|
||||||
l1 = node_factory.get_node(disconnect=disconnects,
|
l1 = node_factory.get_node(disconnect=disconnects,
|
||||||
may_reconnect=True)
|
may_reconnect=True)
|
||||||
l2 = node_factory.get_node(may_reconnect=True)
|
l2 = node_factory.get_node(may_reconnect=True)
|
||||||
@@ -2234,7 +2234,7 @@ def test_channel_persistence(node_factory, bitcoind, executor):
|
|||||||
# Fire off a sendpay request, it'll get interrupted by a restart
|
# Fire off a sendpay request, it'll get interrupted by a restart
|
||||||
executor.submit(l1.pay, l2, 10000)
|
executor.submit(l1.pay, l2, 10000)
|
||||||
# Wait for it to be committed to, i.e., stored in the DB
|
# Wait for it to be committed to, i.e., stored in the DB
|
||||||
l1.daemon.wait_for_log('peer_in WIRE_FUNDING_LOCKED')
|
l1.daemon.wait_for_log('peer_in WIRE_CHANNEL_READY')
|
||||||
l1.daemon.wait_for_log('peer_in WIRE_COMMITMENT_SIGNED')
|
l1.daemon.wait_for_log('peer_in WIRE_COMMITMENT_SIGNED')
|
||||||
|
|
||||||
# Stop l2, l1 will reattempt to connect
|
# Stop l2, l1 will reattempt to connect
|
||||||
|
|||||||
@@ -1274,13 +1274,13 @@ def test_zeroconf_mindepth(bitcoind, node_factory):
|
|||||||
assert l2.db.query('SELECT minimum_depth FROM channels') == [{'minimum_depth': 2}]
|
assert l2.db.query('SELECT minimum_depth FROM channels') == [{'minimum_depth': 2}]
|
||||||
|
|
||||||
bitcoind.generate_block(2, wait_for_mempool=1) # Confirm on the l2 side.
|
bitcoind.generate_block(2, wait_for_mempool=1) # Confirm on the l2 side.
|
||||||
l2.daemon.wait_for_log(r'peer_out WIRE_FUNDING_LOCKED')
|
l2.daemon.wait_for_log(r'peer_out WIRE_CHANNEL_READY')
|
||||||
# l1 should not be sending funding_locked/channel_ready yet, it is
|
# l1 should not be sending funding_locked/channel_ready yet, it is
|
||||||
# configured to wait for 6 confirmations.
|
# configured to wait for 6 confirmations.
|
||||||
assert not l1.daemon.is_in_log(r'peer_out WIRE_FUNDING_LOCKED')
|
assert not l1.daemon.is_in_log(r'peer_out WIRE_CHANNEL_READY')
|
||||||
|
|
||||||
bitcoind.generate_block(4) # Confirm on the l2 side.
|
bitcoind.generate_block(4) # Confirm on the l2 side.
|
||||||
l1.daemon.wait_for_log(r'peer_out WIRE_FUNDING_LOCKED')
|
l1.daemon.wait_for_log(r'peer_out WIRE_CHANNEL_READY')
|
||||||
|
|
||||||
wait_for(lambda: l1.rpc.listpeers()['peers'][0]['channels'][0]['state'] == "CHANNELD_NORMAL")
|
wait_for(lambda: l1.rpc.listpeers()['peers'][0]['channels'][0]['state'] == "CHANNELD_NORMAL")
|
||||||
wait_for(lambda: l2.rpc.listpeers()['peers'][0]['channels'][0]['state'] == "CHANNELD_NORMAL")
|
wait_for(lambda: l2.rpc.listpeers()['peers'][0]['channels'][0]['state'] == "CHANNELD_NORMAL")
|
||||||
@@ -1318,11 +1318,11 @@ def test_zeroconf_open(bitcoind, node_factory):
|
|||||||
assert l2.db.query('SELECT minimum_depth FROM channels') == [{'minimum_depth': 0}]
|
assert l2.db.query('SELECT minimum_depth FROM channels') == [{'minimum_depth': 0}]
|
||||||
|
|
||||||
l1.daemon.wait_for_logs([
|
l1.daemon.wait_for_logs([
|
||||||
r'peer_in WIRE_FUNDING_LOCKED',
|
r'peer_in WIRE_CHANNEL_READY',
|
||||||
r'Peer told us that they\'ll use alias=[0-9x]+ for this channel',
|
r'Peer told us that they\'ll use alias=[0-9x]+ for this channel',
|
||||||
])
|
])
|
||||||
l2.daemon.wait_for_logs([
|
l2.daemon.wait_for_logs([
|
||||||
r'peer_in WIRE_FUNDING_LOCKED',
|
r'peer_in WIRE_CHANNEL_READY',
|
||||||
r'Peer told us that they\'ll use alias=[0-9x]+ for this channel',
|
r'Peer told us that they\'ll use alias=[0-9x]+ for this channel',
|
||||||
])
|
])
|
||||||
|
|
||||||
@@ -1606,8 +1606,8 @@ def test_zeroconf_multichan_forward(node_factory):
|
|||||||
l2.fundwallet(10**7)
|
l2.fundwallet(10**7)
|
||||||
l2.rpc.fundchannel(l3.info['id'], 2 * 10**6, mindepth=0)
|
l2.rpc.fundchannel(l3.info['id'], 2 * 10**6, mindepth=0)
|
||||||
|
|
||||||
l2.daemon.wait_for_log(r'peer_in WIRE_FUNDING_LOCKED')
|
l2.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_READY')
|
||||||
l3.daemon.wait_for_log(r'peer_in WIRE_FUNDING_LOCKED')
|
l3.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_READY')
|
||||||
|
|
||||||
inv = l3.rpc.invoice(amount_msat=10000, label='lbl1', description='desc')['bolt11']
|
inv = l3.rpc.invoice(amount_msat=10000, label='lbl1', description='desc')['bolt11']
|
||||||
l1.rpc.pay(inv)
|
l1.rpc.pay(inv)
|
||||||
|
|||||||
@@ -1922,7 +1922,7 @@ void wallet_channel_save(struct wallet *w, struct channel *chan)
|
|||||||
db_bind_int(stmt, 11, chan->funding.n);
|
db_bind_int(stmt, 11, chan->funding.n);
|
||||||
db_bind_amount_sat(stmt, 12, &chan->funding_sats);
|
db_bind_amount_sat(stmt, 12, &chan->funding_sats);
|
||||||
db_bind_amount_sat(stmt, 13, &chan->our_funds);
|
db_bind_amount_sat(stmt, 13, &chan->our_funds);
|
||||||
db_bind_int(stmt, 14, chan->remote_funding_locked);
|
db_bind_int(stmt, 14, chan->remote_channel_ready);
|
||||||
db_bind_amount_msat(stmt, 15, &chan->push);
|
db_bind_amount_msat(stmt, 15, &chan->push);
|
||||||
db_bind_amount_msat(stmt, 16, &chan->our_msat);
|
db_bind_amount_msat(stmt, 16, &chan->our_msat);
|
||||||
|
|
||||||
|
|||||||
@@ -42,9 +42,9 @@
|
|||||||
msgdata,open_channel,chain_hash,chain_hash,
|
msgdata,open_channel,chain_hash,chain_hash,
|
||||||
msgdata,open_channel,temporary_channel_id,byte,32
|
msgdata,open_channel,temporary_channel_id,byte,32
|
||||||
@@ -86,6 +116,56 @@
|
@@ -86,6 +116,56 @@
|
||||||
msgtype,funding_locked,36
|
msgdata,channel_ready,tlvs,channel_ready_tlvs,
|
||||||
msgdata,funding_locked,channel_id,channel_id,
|
tlvtype,channel_ready_tlvs,short_channel_id,1
|
||||||
msgdata,funding_locked,next_per_commitment_point,point,
|
tlvdata,channel_ready_tlvs,short_channel_id,alias,short_channel_id,
|
||||||
+msgtype,open_channel2,64
|
+msgtype,open_channel2,64
|
||||||
+msgdata,open_channel2,chain_hash,chain_hash,
|
+msgdata,open_channel2,chain_hash,chain_hash,
|
||||||
+msgdata,open_channel2,channel_id,channel_id,
|
+msgdata,open_channel2,channel_id,channel_id,
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
diff --git a/wire/peer_wire.csv b/wire/peer_wire.csv
|
|
||||||
index a028ddc66..fc24b61ef 100644
|
|
||||||
--- a/wire/peer_wire.csv
|
|
||||||
+++ b/wire/peer_wire.csv
|
|
||||||
@@ -126,6 +126,9 @@ msgdata,funding_signed,signature,signature,
|
|
||||||
msgtype,funding_locked,36
|
|
||||||
msgdata,funding_locked,channel_id,channel_id,
|
|
||||||
msgdata,funding_locked,next_per_commitment_point,point,
|
|
||||||
+msgdata,funding_locked,tlvs,funding_locked_tlvs,
|
|
||||||
+tlvtype,funding_locked_tlvs,alias,1
|
|
||||||
+tlvdata,funding_locked_tlvs,alias,scid,short_channel_id,
|
|
||||||
msgtype,open_channel2,64
|
|
||||||
msgdata,open_channel2,chain_hash,chain_hash,
|
|
||||||
msgdata,open_channel2,channel_id,channel_id,
|
|
||||||
@@ -12,7 +12,7 @@ static bool unknown_type(enum peer_wire t)
|
|||||||
case WIRE_ACCEPT_CHANNEL:
|
case WIRE_ACCEPT_CHANNEL:
|
||||||
case WIRE_FUNDING_CREATED:
|
case WIRE_FUNDING_CREATED:
|
||||||
case WIRE_FUNDING_SIGNED:
|
case WIRE_FUNDING_SIGNED:
|
||||||
case WIRE_FUNDING_LOCKED:
|
case WIRE_CHANNEL_READY:
|
||||||
case WIRE_SHUTDOWN:
|
case WIRE_SHUTDOWN:
|
||||||
case WIRE_CLOSING_SIGNED:
|
case WIRE_CLOSING_SIGNED:
|
||||||
case WIRE_UPDATE_ADD_HTLC:
|
case WIRE_UPDATE_ADD_HTLC:
|
||||||
@@ -75,7 +75,7 @@ bool is_msg_for_gossipd(const u8 *cursor)
|
|||||||
case WIRE_ACCEPT_CHANNEL:
|
case WIRE_ACCEPT_CHANNEL:
|
||||||
case WIRE_FUNDING_CREATED:
|
case WIRE_FUNDING_CREATED:
|
||||||
case WIRE_FUNDING_SIGNED:
|
case WIRE_FUNDING_SIGNED:
|
||||||
case WIRE_FUNDING_LOCKED:
|
case WIRE_CHANNEL_READY:
|
||||||
case WIRE_SHUTDOWN:
|
case WIRE_SHUTDOWN:
|
||||||
case WIRE_CLOSING_SIGNED:
|
case WIRE_CLOSING_SIGNED:
|
||||||
case WIRE_UPDATE_ADD_HTLC:
|
case WIRE_UPDATE_ADD_HTLC:
|
||||||
@@ -242,9 +242,9 @@ bool extract_channel_id(const u8 *in_pkt, struct channel_id *channel_id)
|
|||||||
* 2. data:
|
* 2. data:
|
||||||
* * [`channel_id`:`channel_id`]
|
* * [`channel_id`:`channel_id`]
|
||||||
*/
|
*/
|
||||||
case WIRE_FUNDING_LOCKED:
|
case WIRE_CHANNEL_READY:
|
||||||
/* BOLT #2:
|
/* BOLT #2:
|
||||||
* 1. type: 36 (`funding_locked`)
|
* 1. type: 36 (`channel_ready`)
|
||||||
* 2. data:
|
* 2. data:
|
||||||
* * [`channel_id`:`channel_id`]
|
* * [`channel_id`:`channel_id`]
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -123,12 +123,12 @@ msgdata,funding_created,signature,signature,
|
|||||||
msgtype,funding_signed,35
|
msgtype,funding_signed,35
|
||||||
msgdata,funding_signed,channel_id,channel_id,
|
msgdata,funding_signed,channel_id,channel_id,
|
||||||
msgdata,funding_signed,signature,signature,
|
msgdata,funding_signed,signature,signature,
|
||||||
msgtype,funding_locked,36
|
msgtype,channel_ready,36
|
||||||
msgdata,funding_locked,channel_id,channel_id,
|
msgdata,channel_ready,channel_id,channel_id,
|
||||||
msgdata,funding_locked,next_per_commitment_point,point,
|
msgdata,channel_ready,second_per_commitment_point,point,
|
||||||
msgdata,funding_locked,tlvs,funding_locked_tlvs,
|
msgdata,channel_ready,tlvs,channel_ready_tlvs,
|
||||||
tlvtype,funding_locked_tlvs,alias,1
|
tlvtype,channel_ready_tlvs,short_channel_id,1
|
||||||
tlvdata,funding_locked_tlvs,alias,scid,short_channel_id,
|
tlvdata,channel_ready_tlvs,short_channel_id,alias,short_channel_id,
|
||||||
msgtype,open_channel2,64
|
msgtype,open_channel2,64
|
||||||
msgdata,open_channel2,chain_hash,chain_hash,
|
msgdata,open_channel2,chain_hash,chain_hash,
|
||||||
msgdata,open_channel2,channel_id,channel_id,
|
msgdata,open_channel2,channel_id,channel_id,
|
||||||
|
|||||||
|
@@ -157,10 +157,10 @@ struct msg_channel_update_opt_htlc_max {
|
|||||||
struct bitcoin_blkid chain_hash;
|
struct bitcoin_blkid chain_hash;
|
||||||
struct short_channel_id short_channel_id;
|
struct short_channel_id short_channel_id;
|
||||||
};
|
};
|
||||||
struct msg_funding_locked {
|
struct msg_channel_ready {
|
||||||
struct channel_id channel_id;
|
struct channel_id channel_id;
|
||||||
struct pubkey next_per_commitment_point;
|
struct pubkey next_per_commitment_point;
|
||||||
struct tlv_funding_locked_tlvs *tlvs;
|
struct tlv_channel_ready_tlvs *tlvs;
|
||||||
};
|
};
|
||||||
struct msg_announcement_signatures {
|
struct msg_announcement_signatures {
|
||||||
struct channel_id channel_id;
|
struct channel_id channel_id;
|
||||||
@@ -477,20 +477,20 @@ static struct msg_channel_update_opt_htlc_max
|
|||||||
return tal_free(s);
|
return tal_free(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *towire_struct_funding_locked(const tal_t *ctx,
|
static void *towire_struct_channel_ready(const tal_t *ctx,
|
||||||
const struct msg_funding_locked *s)
|
const struct msg_channel_ready *s)
|
||||||
{
|
{
|
||||||
return towire_funding_locked(ctx,
|
return towire_channel_ready(ctx,
|
||||||
&s->channel_id,
|
&s->channel_id,
|
||||||
&s->next_per_commitment_point,
|
&s->next_per_commitment_point,
|
||||||
s->tlvs);
|
s->tlvs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct msg_funding_locked *fromwire_struct_funding_locked(const tal_t *ctx, const void *p)
|
static struct msg_channel_ready *fromwire_struct_channel_ready(const tal_t *ctx, const void *p)
|
||||||
{
|
{
|
||||||
struct msg_funding_locked *s = tal(ctx, struct msg_funding_locked);
|
struct msg_channel_ready *s = tal(ctx, struct msg_channel_ready);
|
||||||
|
|
||||||
if (fromwire_funding_locked(ctx,
|
if (fromwire_channel_ready(ctx,
|
||||||
p,
|
p,
|
||||||
&s->channel_id,
|
&s->channel_id,
|
||||||
&s->next_per_commitment_point,
|
&s->next_per_commitment_point,
|
||||||
@@ -816,13 +816,13 @@ static bool channel_announcement_eq(const struct msg_channel_announcement *a,
|
|||||||
&& eq_between(a, b, bitcoin_key_1, bitcoin_key_2);
|
&& eq_between(a, b, bitcoin_key_1, bitcoin_key_2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool funding_locked_eq(const struct msg_funding_locked *a,
|
static bool channel_ready_eq(const struct msg_channel_ready *a,
|
||||||
const struct msg_funding_locked *b)
|
const struct msg_channel_ready *b)
|
||||||
{
|
{
|
||||||
if (!eq_upto(a, b, tlvs))
|
if (!eq_upto(a, b, tlvs))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return eq_tlv(a, b, alias, short_channel_id_eq);
|
return eq_tlv(a, b, short_channel_id, short_channel_id_eq);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool announcement_signatures_eq(const struct msg_announcement_signatures *a,
|
static bool announcement_signatures_eq(const struct msg_announcement_signatures *a,
|
||||||
@@ -1009,7 +1009,7 @@ static bool node_announcement_eq(const struct msg_node_announcement *a,
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
struct msg_channel_announcement ca, *ca2;
|
struct msg_channel_announcement ca, *ca2;
|
||||||
struct msg_funding_locked fl, *fl2;
|
struct msg_channel_ready fl, *fl2;
|
||||||
struct msg_announcement_signatures as, *as2;
|
struct msg_announcement_signatures as, *as2;
|
||||||
struct msg_update_fail_htlc ufh, *ufh2;
|
struct msg_update_fail_htlc ufh, *ufh2;
|
||||||
struct msg_commitment_signed cs, *cs2;
|
struct msg_commitment_signed cs, *cs2;
|
||||||
@@ -1048,15 +1048,15 @@ int main(int argc, char *argv[])
|
|||||||
test_corruption(&ca, ca2, channel_announcement);
|
test_corruption(&ca, ca2, channel_announcement);
|
||||||
|
|
||||||
memset(&fl, 2, sizeof(fl));
|
memset(&fl, 2, sizeof(fl));
|
||||||
fl.tlvs = tlv_funding_locked_tlvs_new(ctx);
|
fl.tlvs = tlv_channel_ready_tlvs_new(ctx);
|
||||||
fl.tlvs->alias = tal(ctx, struct short_channel_id);
|
fl.tlvs->short_channel_id = tal(ctx, struct short_channel_id);
|
||||||
set_scid(fl.tlvs->alias);
|
set_scid(fl.tlvs->short_channel_id);
|
||||||
set_pubkey(&fl.next_per_commitment_point);
|
set_pubkey(&fl.next_per_commitment_point);
|
||||||
|
|
||||||
msg = towire_struct_funding_locked(ctx, &fl);
|
msg = towire_struct_channel_ready(ctx, &fl);
|
||||||
fl2 = fromwire_struct_funding_locked(ctx, msg);
|
fl2 = fromwire_struct_channel_ready(ctx, msg);
|
||||||
assert(funding_locked_eq(&fl, fl2));
|
assert(channel_ready_eq(&fl, fl2));
|
||||||
test_corruption_tlv(&fl, fl2, funding_locked);
|
test_corruption_tlv(&fl, fl2, channel_ready);
|
||||||
|
|
||||||
memset(&as, 2, sizeof(as));
|
memset(&as, 2, sizeof(as));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user