@@ -1471,13 +1471,23 @@ static struct io_plan *handle_new_channel(struct io_conn *conn,
14711471 take (towire_hsm_new_channel_reply (NULL )));
14721472}
14731473
1474+ static bool mem_is_zero (const void * mem , size_t len )
1475+ {
1476+ size_t i ;
1477+ for (i = 0 ; i < len ; ++ i )
1478+ if (((const unsigned char * )mem )[i ])
1479+ return false;
1480+ return true;
1481+ }
1482+
14741483/*~ This is used to provide all unchanging public channel parameters. */
14751484static struct io_plan * handle_ready_channel (struct io_conn * conn ,
14761485 struct client * c ,
14771486 const u8 * msg_in )
14781487{
14791488 bool is_outbound ;
14801489 struct amount_sat channel_value ;
1490+ struct amount_msat push_value ;
14811491 struct bitcoin_txid funding_txid ;
14821492 u16 funding_txout ;
14831493 u16 local_to_self_delay ;
@@ -1489,7 +1499,7 @@ static struct io_plan *handle_ready_channel(struct io_conn *conn,
14891499 bool option_static_remotekey ;
14901500
14911501 if (!fromwire_hsm_ready_channel (tmpctx , msg_in , & is_outbound ,
1492- & channel_value , & funding_txid ,
1502+ & channel_value , & push_value , & funding_txid ,
14931503 & funding_txout , & local_to_self_delay ,
14941504 & local_shutdown_script ,
14951505 & remote_basepoints ,
@@ -1499,6 +1509,15 @@ static struct io_plan *handle_ready_channel(struct io_conn *conn,
14991509 & option_static_remotekey ))
15001510 return bad_req (conn , c , msg_in );
15011511
1512+ /* Fail fast if any values are obviously uninitialized. */
1513+ assert (channel_value .satoshis > 0 );
1514+ assert (push_value .millisatoshis / 1000 <= channel_value .satoshis );
1515+ assert (!mem_is_zero (& funding_txid , sizeof (funding_txid )));
1516+ assert (local_to_self_delay > 0 );
1517+ assert (!mem_is_zero (& remote_basepoints , sizeof (remote_basepoints )));
1518+ assert (!mem_is_zero (& remote_funding_pubkey , sizeof (remote_funding_pubkey )));
1519+ assert (remote_to_self_delay > 0 );
1520+
15021521 return req_reply (conn , c ,
15031522 take (towire_hsm_ready_channel_reply (NULL )));
15041523}
0 commit comments