5151#include <wire/peer_wire.h>
5252#include <wire/wire_sync.h>
5353
54+ #define EXPERIMENTAL_UPGRADE_ENABLED 0
55+
5456/* stdin == requests, 3 == peer, 4 = HSM */
5557#define MASTER_FD STDIN_FILENO
5658#define HSM_FD 4
@@ -358,6 +360,7 @@ static bool handle_master_request_later(struct peer *peer, const u8 *msg)
358360 return false;
359361}
360362
363+ #if EXPERIMENTAL_UPGRADE_ENABLED
361364/* Compare, with false if either is NULL */
362365static bool match_type (const u8 * t1 , const u8 * t2 )
363366{
@@ -387,6 +390,7 @@ static void set_channel_type(struct channel *channel, const u8 *type)
387390 wire_sync_write (MASTER_FD ,
388391 take (towire_channeld_upgraded (NULL , channel -> type )));
389392}
393+ #endif
390394
391395static void lock_signer_outpoint (const struct bitcoin_outpoint * outpoint )
392396{
@@ -5254,6 +5258,7 @@ static bool capture_premature_msg(const u8 ***shit_lnd_says, const u8 *msg)
52545258 return true;
52555259}
52565260
5261+ #if EXPERIMENTAL_UPGRADE_ENABLED
52575262/* Unwrap a channel_type into a raw byte array for the wire: can be NULL */
52585263static u8 * to_bytearr (const tal_t * ctx ,
52595264 const struct channel_type * channel_type TAKES )
@@ -5272,6 +5277,7 @@ static u8 *to_bytearr(const tal_t *ctx,
52725277 ret = tal_dup_talarr (ctx , u8 , channel_type -> features );
52735278 return ret ;
52745279}
5280+ #endif
52755281
52765282static void peer_reconnect (struct peer * peer ,
52775283 const struct secret * last_remote_per_commit_secret )
@@ -5309,6 +5315,7 @@ static void peer_reconnect(struct peer *peer,
53095315
53105316 send_tlvs = NULL ;
53115317
5318+ #if EXPERIMENTAL_UPGRADE_ENABLED
53125319 if (peer -> experimental_upgrade ) {
53135320 /* Subtle: we free tmpctx below as we loop, so tal off peer */
53145321 send_tlvs = tlv_channel_reestablish_tlvs_new (peer );
@@ -5347,6 +5354,7 @@ static void peer_reconnect(struct peer *peer,
53475354 peer -> channel )));
53485355 }
53495356 }
5357+ #endif
53505358
53515359 inflight = last_inflight (peer );
53525360
@@ -5400,16 +5408,16 @@ static void peer_reconnect(struct peer *peer,
54005408 & peer -> channel -> funding .txid ));
54015409
54025410 for (size_t i = 0 ; i < tal_count (peer -> splice_state -> inflights ); i ++ ) {
5403- struct inflight * inflight = peer -> splice_state -> inflights [i ];
5404- if (inflight -> locked_scid ) {
5405- send_tlvs -> my_current_funding_locked_txid = & inflight -> outpoint .txid ;
5411+ struct inflight * itr = peer -> splice_state -> inflights [i ];
5412+ if (itr -> locked_scid ) {
5413+ send_tlvs -> my_current_funding_locked_txid = & itr -> outpoint .txid ;
54065414 status_debug ("Overriding send_tlvs->my_current_"
54075415 "funding_locked_txid to %s because"
54085416 " inflight is locked to scid %s" ,
54095417 fmt_bitcoin_txid (tmpctx ,
5410- & inflight -> outpoint .txid ),
5418+ & itr -> outpoint .txid ),
54115419 fmt_short_channel_id (tmpctx ,
5412- * inflight -> locked_scid ));
5420+ * itr -> locked_scid ));
54135421 }
54145422 }
54155423 }
@@ -5601,14 +5609,14 @@ static void peer_reconnect(struct peer *peer,
56015609
56025610 /* Re-send `splice_locked` if an inflight is locked */
56035611 for (size_t i = 0 ; i < tal_count (peer -> splice_state -> inflights ); i ++ ) {
5604- struct inflight * inflight = peer -> splice_state -> inflights [i ];
5605- if (!inflight -> locked_scid )
5612+ struct inflight * itr = peer -> splice_state -> inflights [i ];
5613+ if (!itr -> locked_scid )
56065614 continue ;
56075615
56085616 peer_write (peer -> pps ,
56095617 take (towire_splice_locked (NULL ,
56105618 & peer -> channel_id ,
5611- & inflight -> outpoint .txid )));
5619+ & itr -> outpoint .txid )));
56125620 peer -> splice_state -> locked_ready [LOCAL ] = true;
56135621 }
56145622
@@ -5779,6 +5787,7 @@ static void peer_reconnect(struct peer *peer,
57795787 /* (If we had sent `closing_signed`, we'd be in closingd). */
57805788 maybe_send_shutdown (peer );
57815789
5790+ #if EXPERIMENTAL_UPGRADE_ENABLED
57825791 if (recv_tlvs -> desired_channel_type )
57835792 status_debug ("They sent desired_channel_type [%s]" ,
57845793 fmt_featurebits (tmpctx ,
@@ -5856,6 +5865,7 @@ static void peer_reconnect(struct peer *peer,
58565865 if (type )
58575866 set_channel_type (peer -> channel , type );
58585867 }
5868+ #endif
58595869
58605870 tal_free (send_tlvs );
58615871
0 commit comments