mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-06 15:44:21 +01:00
channel: import upgrade spec.
See https://github.com/lightningnetwork/lightning-rfc/pull/868 Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -1930,12 +1930,19 @@ static void handle_unexpected_reestablish(struct peer *peer, const u8 *msg)
|
||||
u64 next_revocation_number;
|
||||
struct secret your_last_per_commitment_secret;
|
||||
struct pubkey my_current_per_commitment_point;
|
||||
#if EXPERIMENTAL_FEATURES
|
||||
struct tlv_channel_reestablish_tlvs *tlvs = tlv_channel_reestablish_tlvs_new(tmpctx);
|
||||
#endif
|
||||
|
||||
if (!fromwire_channel_reestablish(msg, &channel_id,
|
||||
&next_commitment_number,
|
||||
&next_revocation_number,
|
||||
&your_last_per_commitment_secret,
|
||||
&my_current_per_commitment_point))
|
||||
&my_current_per_commitment_point
|
||||
#if EXPERIMENTAL_FEATURES
|
||||
, tlvs
|
||||
#endif
|
||||
))
|
||||
peer_failed_warn(peer->pps, &peer->channel_id,
|
||||
"Bad channel_reestablish %s", tal_hex(peer, msg));
|
||||
|
||||
@@ -2474,6 +2481,9 @@ static void peer_reconnect(struct peer *peer,
|
||||
struct secret last_local_per_commitment_secret;
|
||||
bool dataloss_protect, check_extra_fields;
|
||||
const u8 **premature_msgs = tal_arr(peer, const u8 *, 0);
|
||||
#if EXPERIMENTAL_FEATURES
|
||||
struct tlv_channel_reestablish_tlvs *send_tlvs, *recv_tlvs;
|
||||
#endif
|
||||
|
||||
dataloss_protect = feature_negotiated(peer->our_features,
|
||||
peer->their_features,
|
||||
@@ -2488,6 +2498,10 @@ static void peer_reconnect(struct peer *peer,
|
||||
get_per_commitment_point(peer->next_index[LOCAL] - 1,
|
||||
&my_current_per_commitment_point, NULL);
|
||||
|
||||
#if EXPERIMENTAL_FEATURES
|
||||
send_tlvs = tlv_channel_reestablish_tlvs_new(tmpctx);
|
||||
#endif
|
||||
|
||||
/* BOLT #2:
|
||||
*
|
||||
* - upon reconnection:
|
||||
@@ -2525,14 +2539,22 @@ static void peer_reconnect(struct peer *peer,
|
||||
peer->revocations_received,
|
||||
last_remote_per_commit_secret,
|
||||
/* Can send any (valid) point here */
|
||||
&peer->remote_per_commit);
|
||||
&peer->remote_per_commit
|
||||
#if EXPERIMENTAL_FEATURES
|
||||
, send_tlvs
|
||||
#endif
|
||||
);
|
||||
} else {
|
||||
msg = towire_channel_reestablish
|
||||
(NULL, &peer->channel_id,
|
||||
peer->next_index[LOCAL],
|
||||
peer->revocations_received,
|
||||
last_remote_per_commit_secret,
|
||||
&my_current_per_commitment_point);
|
||||
&my_current_per_commitment_point
|
||||
#if EXPERIMENTAL_FEATURES
|
||||
, send_tlvs
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
sync_crypto_write(peer->pps, take(msg));
|
||||
@@ -2552,12 +2574,20 @@ static void peer_reconnect(struct peer *peer,
|
||||
msg) ||
|
||||
capture_premature_msg(&premature_msgs, msg));
|
||||
|
||||
#if EXPERIMENTAL_FEATURES
|
||||
recv_tlvs = tlv_channel_reestablish_tlvs_new(tmpctx);
|
||||
#endif
|
||||
|
||||
if (!fromwire_channel_reestablish(msg,
|
||||
&channel_id,
|
||||
&next_commitment_number,
|
||||
&next_revocation_number,
|
||||
&last_local_per_commitment_secret,
|
||||
&remote_current_per_commitment_point)) {
|
||||
&remote_current_per_commitment_point
|
||||
#if EXPERIMENTAL_FEATURES
|
||||
, recv_tlvs
|
||||
#endif
|
||||
)) {
|
||||
peer_failed_warn(peer->pps,
|
||||
&peer->channel_id,
|
||||
"bad reestablish msg: %s %s",
|
||||
|
||||
@@ -176,6 +176,9 @@ static void do_reconnect(struct per_peer_state *pps,
|
||||
struct pubkey my_current_per_commitment_point, next_commitment_point;
|
||||
struct secret their_secret;
|
||||
struct tlv_shutdown_tlvs *tlvs;
|
||||
#if EXPERIMENTAL_FEATURES
|
||||
struct tlv_channel_reestablish_tlvs *reestablish_tlvs = tlv_channel_reestablish_tlvs_new(tmpctx);
|
||||
#endif
|
||||
|
||||
my_current_per_commitment_point = get_per_commitment_point(next_index[LOCAL]-1);
|
||||
|
||||
@@ -201,7 +204,11 @@ static void do_reconnect(struct per_peer_state *pps,
|
||||
next_index[LOCAL],
|
||||
revocations_received,
|
||||
last_remote_per_commit_secret,
|
||||
&my_current_per_commitment_point);
|
||||
&my_current_per_commitment_point
|
||||
#if EXPERIMENTAL_FEATURES
|
||||
, reestablish_tlvs
|
||||
#endif
|
||||
);
|
||||
sync_crypto_write(pps, take(msg));
|
||||
|
||||
/* They might have already sent reestablish, which triggered us */
|
||||
@@ -217,11 +224,19 @@ static void do_reconnect(struct per_peer_state *pps,
|
||||
!= WIRE_CHANNEL_REESTABLISH);
|
||||
}
|
||||
|
||||
#if EXPERIMENTAL_FEATURES
|
||||
reestablish_tlvs = tlv_channel_reestablish_tlvs_new(tmpctx);
|
||||
#endif
|
||||
|
||||
if (!fromwire_channel_reestablish(channel_reestablish, &their_channel_id,
|
||||
&next_local_commitment_number,
|
||||
&next_remote_revocation_number,
|
||||
&their_secret,
|
||||
&next_commitment_point)) {
|
||||
&next_commitment_point
|
||||
#if EXPERIMENTAL_FEATURES
|
||||
, reestablish_tlvs
|
||||
#endif
|
||||
)) {
|
||||
peer_failed_warn(pps, channel_id,
|
||||
"bad reestablish msg: %s %s",
|
||||
peer_wire_name(fromwire_peektype(channel_reestablish)),
|
||||
|
||||
@@ -3164,6 +3164,9 @@ static void do_reconnect_dance(struct state *state)
|
||||
last_remote_per_commit_secret;
|
||||
struct pubkey remote_current_per_commit_point;
|
||||
struct tx_state *tx_state = state->tx_state;
|
||||
#if EXPERIMENTAL_FEATURES
|
||||
struct tlv_channel_reestablish_tlvs *tlvs = tlv_channel_reestablish_tlvs_new(tmpctx);
|
||||
#endif
|
||||
|
||||
/* BOLT #2:
|
||||
* - if `next_revocation_number` equals 0:
|
||||
@@ -3177,7 +3180,11 @@ static void do_reconnect_dance(struct state *state)
|
||||
msg = towire_channel_reestablish
|
||||
(NULL, &state->channel_id, 1, 0,
|
||||
&last_remote_per_commit_secret,
|
||||
&state->first_per_commitment_point[LOCAL]);
|
||||
&state->first_per_commitment_point[LOCAL]
|
||||
#if EXPERIMENTAL_FEATURES
|
||||
, tlvs
|
||||
#endif
|
||||
);
|
||||
sync_crypto_write(state->pps, take(msg));
|
||||
|
||||
peer_billboard(false, "Sent reestablish, waiting for theirs");
|
||||
@@ -3200,7 +3207,11 @@ static void do_reconnect_dance(struct state *state)
|
||||
&next_commitment_number,
|
||||
&next_revocation_number,
|
||||
&last_local_per_commit_secret,
|
||||
&remote_current_per_commit_point))
|
||||
&remote_current_per_commit_point
|
||||
#if EXPERIMENTAL_FEATURES
|
||||
, tlvs
|
||||
#endif
|
||||
))
|
||||
open_err_fatal(state, "Bad reestablish msg: %s %s",
|
||||
peer_wire_name(fromwire_peektype(msg)),
|
||||
tal_hex(msg, msg));
|
||||
|
||||
21
wire/extracted_peer_exp_upgradable.patch
Normal file
21
wire/extracted_peer_exp_upgradable.patch
Normal file
@@ -0,0 +1,21 @@
|
||||
--- wire/peer_wire.csv 2021-05-09 15:44:59.166135652 +0930
|
||||
+++ wire/peer_wire.csv.raw 2021-05-11 09:59:31.695459756 +0930
|
||||
@@ -221,6 +131,18 @@
|
||||
msgdata,channel_reestablish,next_revocation_number,u64,
|
||||
msgdata,channel_reestablish,your_last_per_commitment_secret,byte,32
|
||||
msgdata,channel_reestablish,my_current_per_commitment_point,point,
|
||||
+msgdata,channel_reestablish,tlvs,channel_reestablish_tlvs,
|
||||
+tlvtype,channel_reestablish_tlvs,next_to_send,1
|
||||
+tlvdata,channel_reestablish_tlvs,next_to_send,commitment_number,tu64,
|
||||
+tlvtype,channel_reestablish_tlvs,desired_type,3
|
||||
+tlvdata,channel_reestablish_tlvs,desired_type,type,channel_type,
|
||||
+tlvtype,channel_reestablish_tlvs,current_type,5
|
||||
+tlvdata,channel_reestablish_tlvs,current_type,type,channel_type,
|
||||
+tlvtype,channel_reestablish_tlvs,upgradable,7
|
||||
+tlvdata,channel_reestablish_tlvs,upgradable,upgrades,channel_type,...
|
||||
+subtype,channel_type
|
||||
+subtypedata,channel_type,len,u16,
|
||||
+subtypedata,channel_type,features,byte,len
|
||||
msgtype,announcement_signatures,259
|
||||
msgdata,announcement_signatures,channel_id,channel_id,
|
||||
msgdata,announcement_signatures,short_channel_id,short_channel_id,
|
||||
@@ -124,10 +124,17 @@ bool extract_channel_id(const u8 *in_pkt, struct channel_id *channel_id)
|
||||
struct bitcoin_blkid ignored_chainhash;
|
||||
struct secret ignored_secret;
|
||||
struct tlv_open_channel_tlvs *tlvs = tlv_open_channel_tlvs_new(tmpctx);
|
||||
#if EXPERIMENTAL_FEATURES
|
||||
struct tlv_channel_reestablish_tlvs *reestab_tlvs = tlv_channel_reestablish_tlvs_new(tmpctx);
|
||||
#endif
|
||||
|
||||
if (fromwire_channel_reestablish(in_pkt, channel_id,
|
||||
&ignored_u64, &ignored_u64,
|
||||
&ignored_secret, &ignored_pubkey))
|
||||
&ignored_secret, &ignored_pubkey
|
||||
#if EXPERIMENTAL_FEATURES
|
||||
, reestab_tlvs
|
||||
#endif
|
||||
))
|
||||
return true;
|
||||
if (fromwire_open_channel(in_pkt, &ignored_chainhash,
|
||||
channel_id, &ignored_sat,
|
||||
|
||||
Reference in New Issue
Block a user