@ -108,25 +108,17 @@ static u8 *closing_read_peer_msg(const tal_t *ctx,
}
}
static void do_reconnect ( struct per_peer_state * pps ,
const struct channel_id * channel_id ,
const u64 next_index [ NUM_SIDES ] ,
u64 revocations_received ,
const u8 * channel_reestablish ,
const u8 * final_scriptpubkey ,
const struct secret * last_remote_per_commit_secret )
static struct pubkey get_per_commitment_point ( u64 commitment_number )
{
u8 * msg ;
struct channel_id their_channel_id ;
u64 next_local_commitment_number , next_remote_revocation_number ;
struct pubkey my_current_per_commitment_point ;
struct pubkey commitment_point ;
struct secret * s ;
/* Our current per-commitment point is the commitment point in the last
* received signed commitment ; HSM gives us that and the previous
* secret ( which we don ' t need ) . */
msg = towire_hsm_get_per_commitment_point ( NULL ,
next_index [ LOCAL ] - 1 ) ;
commitment_number ) ;
if ( ! wire_sync_write ( HSM_FD , take ( msg ) ) )
status_failed ( STATUS_FAIL_HSM_IO ,
" Writing get_per_commitment_point to HSM: %s " ,
@ -138,11 +130,29 @@ static void do_reconnect(struct per_peer_state *pps,
" Reading resp get_per_commitment_point reply: %s " ,
strerror ( errno ) ) ;
if ( ! fromwire_hsm_get_per_commitment_point_reply ( tmpctx , msg ,
& my_current_per_ commitment_point ,
& s ) )
& commitment_point ,
& s ) )
status_failed ( STATUS_FAIL_HSM_IO ,
" Bad per_commitment_point reply %s " ,
tal_hex ( tmpctx , msg ) ) ;
" Bad per_commitment_point reply %s " ,
tal_hex ( tmpctx , msg ) ) ;
return commitment_point ;
}
static void do_reconnect ( struct per_peer_state * pps ,
const struct channel_id * channel_id ,
const u64 next_index [ NUM_SIDES ] ,
u64 revocations_received ,
const u8 * channel_reestablish ,
const u8 * final_scriptpubkey ,
const struct secret * last_remote_per_commit_secret )
{
u8 * msg ;
struct channel_id their_channel_id ;
u64 next_local_commitment_number , next_remote_revocation_number ;
struct pubkey my_current_per_commitment_point , next_commitment_point ;
my_current_per_commitment_point = get_per_commitment_point ( next_index [ LOCAL ] - 1 ) ;
/* BOLT #2:
*
@ -207,8 +217,20 @@ static void do_reconnect(struct per_peer_state *pps,
msg = towire_shutdown ( NULL , channel_id , final_scriptpubkey ) ;
sync_crypto_write ( pps , take ( msg ) ) ;
/* FIXME: Spec says to re-xmit funding_locked here if we haven't
* done any updates . */
/* BOLT #2:
*
* A node :
* . . .
* - if ` next_commitment_number ` is 1 in both the ` channel_reestablish ` it sent and received :
* - MUST retransmit ` funding_locked ` .
*/
if ( next_index [ REMOTE ] = = 1 & & next_index [ LOCAL ] = = 1 ) {
status_debug ( " Retransmitting funding_locked for channel %s " ,
type_to_string ( tmpctx , struct channel_id , channel_id ) ) ;
next_commitment_point = get_per_commitment_point ( next_index [ LOCAL ] ) ;
msg = towire_funding_locked ( NULL , channel_id , & next_commitment_point ) ;
sync_crypto_write ( pps , take ( msg ) ) ;
}
}
static void send_offer ( struct per_peer_state * pps ,