@@ -1506,13 +1506,23 @@ static struct io_plan *handle_new_channel(struct io_conn *conn,
15061506 take (towire_hsm_new_channel_reply (NULL )));
15071507}
15081508
1509+ static bool mem_is_zero (const void * mem , size_t len )
1510+ {
1511+ size_t i ;
1512+ for (i = 0 ; i < len ; ++ i )
1513+ if (((const unsigned char * )mem )[i ])
1514+ return false;
1515+ return true;
1516+ }
1517+
15091518/*~ This is used to provide all unchanging public channel parameters. */
15101519static struct io_plan * handle_ready_channel (struct io_conn * conn ,
15111520 struct client * c ,
15121521 const u8 * msg_in )
15131522{
15141523 bool is_outbound ;
15151524 struct amount_sat channel_value ;
1525+ struct amount_msat push_value ;
15161526 struct bitcoin_txid funding_txid ;
15171527 u16 funding_txout ;
15181528 u16 local_to_self_delay ;
@@ -1524,7 +1534,7 @@ static struct io_plan *handle_ready_channel(struct io_conn *conn,
15241534 bool option_static_remotekey ;
15251535
15261536 if (!fromwire_hsm_ready_channel (tmpctx , msg_in , & is_outbound ,
1527- & channel_value , & funding_txid ,
1537+ & channel_value , & push_value , & funding_txid ,
15281538 & funding_txout , & local_to_self_delay ,
15291539 & local_shutdown_script ,
15301540 & remote_basepoints ,
@@ -1534,6 +1544,15 @@ static struct io_plan *handle_ready_channel(struct io_conn *conn,
15341544 & option_static_remotekey ))
15351545 return bad_req (conn , c , msg_in );
15361546
1547+ /* Fail fast if any values are obviously uninitialized. */
1548+ assert (channel_value .satoshis > 0 );
1549+ assert (push_value .millisatoshis / 1000 <= channel_value .satoshis );
1550+ assert (!mem_is_zero (& funding_txid , sizeof (funding_txid )));
1551+ assert (local_to_self_delay > 0 );
1552+ assert (!mem_is_zero (& remote_basepoints , sizeof (remote_basepoints )));
1553+ assert (!mem_is_zero (& remote_funding_pubkey , sizeof (remote_funding_pubkey )));
1554+ assert (remote_to_self_delay > 0 );
1555+
15371556 return req_reply (conn , c ,
15381557 take (towire_hsm_ready_channel_reply (NULL )));
15391558}
0 commit comments