mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
wire: Add funding_locked tlv patch from PR lightning/bolts#910
Minimal set of changes to update the peer_wire.csv to include the TLV field in the `funding_locked` message, and add type 1=alias from that PR too.
This commit is contained in:
@@ -587,7 +587,7 @@ static void channel_announcement_negotiate(struct peer *peer)
|
||||
static void handle_peer_funding_locked(struct peer *peer, const u8 *msg)
|
||||
{
|
||||
struct channel_id chanid;
|
||||
|
||||
struct tlv_funding_locked_tlvs *tlvs;
|
||||
/* BOLT #2:
|
||||
*
|
||||
* A node:
|
||||
@@ -603,8 +603,8 @@ static void handle_peer_funding_locked(struct peer *peer, const u8 *msg)
|
||||
return;
|
||||
|
||||
peer->old_remote_per_commit = peer->remote_per_commit;
|
||||
if (!fromwire_funding_locked(msg, &chanid,
|
||||
&peer->remote_per_commit))
|
||||
if (!fromwire_funding_locked(msg, msg, &chanid,
|
||||
&peer->remote_per_commit, &tlvs))
|
||||
peer_failed_warn(peer->pps, &peer->channel_id,
|
||||
"Bad funding_locked %s", tal_hex(msg, msg));
|
||||
|
||||
@@ -2928,13 +2928,14 @@ skip_tlvs:
|
||||
&& peer->next_index[LOCAL] == 1
|
||||
&& next_commitment_number == 1) {
|
||||
u8 *msg;
|
||||
struct tlv_funding_locked_tlvs *tlvs = tlv_funding_locked_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,
|
||||
&peer->channel_id,
|
||||
&peer->next_local_per_commit);
|
||||
&peer->next_local_per_commit, tlvs);
|
||||
peer_write(peer->pps, take(msg));
|
||||
}
|
||||
|
||||
@@ -3234,9 +3235,12 @@ static void handle_funding_depth(struct peer *peer, const u8 *msg)
|
||||
peer->next_index[LOCAL],
|
||||
type_to_string(tmpctx, struct pubkey,
|
||||
&peer->next_local_per_commit));
|
||||
msg = towire_funding_locked(NULL,
|
||||
&peer->channel_id,
|
||||
&peer->next_local_per_commit);
|
||||
struct tlv_funding_locked_tlvs *tlvs =
|
||||
tlv_funding_locked_tlvs_new(tmpctx);
|
||||
|
||||
msg = towire_funding_locked(
|
||||
NULL, &peer->channel_id,
|
||||
&peer->next_local_per_commit, tlvs);
|
||||
peer_write(peer->pps, take(msg));
|
||||
|
||||
peer->funding_locked[LOCAL] = true;
|
||||
|
||||
@@ -1132,8 +1132,9 @@ static u8 *handle_funding_locked(struct state *state, u8 *msg)
|
||||
{
|
||||
struct channel_id cid;
|
||||
struct pubkey remote_per_commit;
|
||||
struct tlv_funding_locked_tlvs *tlvs;
|
||||
|
||||
if (!fromwire_funding_locked(msg, &cid, &remote_per_commit))
|
||||
if (!fromwire_funding_locked(tmpctx, msg, &cid, &remote_per_commit, &tlvs))
|
||||
open_err_fatal(state, "Bad funding_locked %s",
|
||||
tal_hex(msg, msg));
|
||||
|
||||
@@ -3392,13 +3393,12 @@ static void send_funding_locked(struct state *state)
|
||||
{
|
||||
u8 *msg;
|
||||
struct pubkey next_local_per_commit;
|
||||
|
||||
struct tlv_funding_locked_tlvs *tlvs = tlv_funding_locked_tlvs_new(tmpctx);
|
||||
/* Figure out the next local commit */
|
||||
hsm_per_commitment_point(1, &next_local_per_commit);
|
||||
|
||||
msg = towire_funding_locked(NULL,
|
||||
&state->channel_id,
|
||||
&next_local_per_commit);
|
||||
msg = towire_funding_locked(NULL, &state->channel_id,
|
||||
&next_local_per_commit, tlvs);
|
||||
peer_write(state->pps, take(msg));
|
||||
|
||||
state->funding_locked[LOCAL] = true;
|
||||
|
||||
14
wire/extracted_peer_06_zeroconf.patch
Normal file
14
wire/extracted_peer_06_zeroconf.patch
Normal file
@@ -0,0 +1,14 @@
|
||||
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,
|
||||
@@ -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,
|
||||
|
||||
|
@@ -7,6 +7,7 @@
|
||||
#include "common/amount.c"
|
||||
#include "common/channel_id.c"
|
||||
#include "common/node_id.c"
|
||||
#include "wire/tlvstream.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -34,6 +35,11 @@ static void set_node_id(struct node_id *id)
|
||||
memset(id->k, 2, sizeof(id->k));
|
||||
}
|
||||
|
||||
static void set_scid(struct short_channel_id *scid)
|
||||
{
|
||||
memset(scid, 2, sizeof(struct short_channel_id));
|
||||
}
|
||||
|
||||
/* Size up to field. */
|
||||
#define upto_field(p, field) \
|
||||
((char *)&(p)->field - (char *)(p))
|
||||
@@ -146,6 +152,7 @@ struct msg_channel_update_opt_htlc_max {
|
||||
struct msg_funding_locked {
|
||||
struct channel_id channel_id;
|
||||
struct pubkey next_per_commitment_point;
|
||||
struct tlv_funding_locked_tlvs *tlvs;
|
||||
};
|
||||
struct msg_announcement_signatures {
|
||||
struct channel_id channel_id;
|
||||
@@ -463,20 +470,23 @@ static struct msg_channel_update_opt_htlc_max
|
||||
}
|
||||
|
||||
static void *towire_struct_funding_locked(const tal_t *ctx,
|
||||
const struct msg_funding_locked *s)
|
||||
const struct msg_funding_locked *s)
|
||||
{
|
||||
return towire_funding_locked(ctx,
|
||||
&s->channel_id,
|
||||
&s->next_per_commitment_point);
|
||||
&s->next_per_commitment_point,
|
||||
s->tlvs);
|
||||
}
|
||||
|
||||
static struct msg_funding_locked *fromwire_struct_funding_locked(const tal_t *ctx, const void *p)
|
||||
{
|
||||
struct msg_funding_locked *s = tal(ctx, struct msg_funding_locked);
|
||||
|
||||
if (fromwire_funding_locked(p,
|
||||
if (fromwire_funding_locked(ctx,
|
||||
p,
|
||||
&s->channel_id,
|
||||
&s->next_per_commitment_point))
|
||||
&s->next_per_commitment_point,
|
||||
&s->tlvs))
|
||||
return s;
|
||||
return tal_free(s);
|
||||
}
|
||||
@@ -801,7 +811,9 @@ static bool channel_announcement_eq(const struct msg_channel_announcement *a,
|
||||
static bool funding_locked_eq(const struct msg_funding_locked *a,
|
||||
const struct msg_funding_locked *b)
|
||||
{
|
||||
return memcmp(a, b, sizeof(*a)) == 0;
|
||||
return eq_upto(a, b, tlvs) &&
|
||||
memeq(a->tlvs->alias, sizeof(a->tlvs->alias), b->tlvs->alias,
|
||||
sizeof(b->tlvs->alias));
|
||||
}
|
||||
|
||||
static bool announcement_signatures_eq(const struct msg_announcement_signatures *a,
|
||||
@@ -1044,12 +1056,16 @@ int main(int argc, char *argv[])
|
||||
test_corruption(&ca, ca2, channel_announcement);
|
||||
|
||||
memset(&fl, 2, sizeof(fl));
|
||||
fl.tlvs = tlv_funding_locked_tlvs_new(ctx);
|
||||
fl.tlvs->alias = tal(ctx, struct short_channel_id);
|
||||
set_scid(fl.tlvs->alias);
|
||||
set_pubkey(&fl.next_per_commitment_point);
|
||||
|
||||
msg = towire_struct_funding_locked(ctx, &fl);
|
||||
fl2 = fromwire_struct_funding_locked(ctx, msg);
|
||||
assert(funding_locked_eq(&fl, fl2));
|
||||
test_corruption(&fl, fl2, funding_locked);
|
||||
/* FIXME: Corruptions in the TLV can still parse correctly, but won't be equal. */
|
||||
/*test_corruption_tlv(&fl, fl2, funding_locked);*/
|
||||
|
||||
memset(&as, 2, sizeof(as));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user