Skip to content

Commit

Permalink
opening: pass two messages to channeld to send to peer
Browse files Browse the repository at this point in the history
v2 of channel establishment, in the accpeter case, now sends 2 messages
to our peer after saving the information to disk (our commitment
signatures and our funding transaction signatures)
  • Loading branch information
niftynei authored and rustyrussell committed Sep 9, 2020
1 parent 0643945 commit d6558de
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 26 deletions.
13 changes: 8 additions & 5 deletions channeld/channeld.c
Original file line number Diff line number Diff line change
Expand Up @@ -3205,7 +3205,7 @@ static void init_channel(struct peer *peer)
enum side opener;
struct existing_htlc **htlcs;
bool reconnected;
u8 *funding_signed;
u8 *fwd_msg_1, *fwd_msg_2;
const u8 *msg;
struct fee_states *fee_states;
u32 minimum_depth;
Expand Down Expand Up @@ -3266,7 +3266,8 @@ static void init_channel(struct peer *peer)
&peer->shutdown_sent[REMOTE],
&peer->final_scriptpubkey,
&peer->channel_flags,
&funding_signed,
&fwd_msg_1,
&fwd_msg_2,
&peer->announce_depth_reached,
&last_remote_per_commit_secret,
&peer->their_features,
Expand Down Expand Up @@ -3368,9 +3369,11 @@ static void init_channel(struct peer *peer)
if (reconnected)
peer_reconnect(peer, &last_remote_per_commit_secret);

/* If we have a funding_signed message, send that immediately */
if (funding_signed)
sync_crypto_write(peer->pps, take(funding_signed));
/* If we have a messages to send, send them immediately */
if (fwd_msg_1)
sync_crypto_write(peer->pps, take(fwd_msg_1));
if (fwd_msg_2)
sync_crypto_write(peer->pps, take(fwd_msg_2));

/* Reenable channel */
channel_announcement_negotiate(peer);
Expand Down
2 changes: 2 additions & 0 deletions channeld/channeld_wire.csv
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ msgdata,channeld_init,final_scriptpubkey,u8,final_scriptpubkey_len
msgdata,channeld_init,flags,u8,
msgdata,channeld_init,init_peer_pkt_len,u16,
msgdata,channeld_init,init_peer_pkt,u8,init_peer_pkt_len
msgdata,channeld_init,init_peer_pkt_two_len,u16,
msgdata,channeld_init,init_peer_pkt_two,u8,init_peer_pkt_two_len
msgdata,channeld_init,reached_announce_depth,bool,
msgdata,channeld_init,last_remote_secret,secret,
msgdata,channeld_init,flen,u16,
Expand Down
14 changes: 11 additions & 3 deletions channeld/channeld_wiregen.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions channeld/channeld_wiregen.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions lightningd/channel_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,8 @@ static unsigned channel_msg(struct subd *sd, const u8 *msg, const int *fds)

void peer_start_channeld(struct channel *channel,
struct per_peer_state *pps,
const u8 **fwd_msgs,
const u8 *fwd_msg_1,
const u8 *fwd_msg_2,
bool reconnected)
{
u8 *initmsg;
Expand Down Expand Up @@ -556,8 +557,8 @@ void peer_start_channeld(struct channel *channel,
channel->shutdown_scriptpubkey[REMOTE] != NULL,
channel->shutdown_scriptpubkey[LOCAL],
channel->channel_flags,
/* FIXME: pass set of msgs */
fwd_msgs ? fwd_msgs[0] : NULL,
fwd_msg_1,
fwd_msg_2,
reached_announce_depth,
&last_remote_per_commit_secret,
channel->peer->their_features,
Expand Down
3 changes: 2 additions & 1 deletion lightningd/channel_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ struct peer;

void peer_start_channeld(struct channel *channel,
struct per_peer_state *pps,
const u8 **fwd_msgs,
const u8 *fwd_msg_1,
const u8 *fwd_msg_2,
bool reconnected);

/* Returns true if subd told, otherwise false. */
Expand Down
Loading

0 comments on commit d6558de

Please sign in to comment.