@ -235,18 +235,11 @@ static void peer_start_closingd_after_shutdown(struct channel *channel,
channel_set_state ( channel , CHANNELD_SHUTTING_DOWN , CLOSINGD_SIGEXCHANGE ) ;
}
static void handle_error_channel ( struct channel * channel ,
const u8 * msg )
static void forget ( struct channel * channel )
{
struct command * * forgets = tal_steal ( tmpctx , channel - > forgets ) ;
channel - > forgets = tal_arr ( channel , struct command * , 0 ) ;
if ( ! fromwire_channel_send_error_reply ( msg ) ) {
channel_internal_error ( channel , " bad send_error_reply: %s " ,
tal_hex ( tmpctx , msg ) ) ;
return ;
}
/* Forget the channel. */
delete_channel ( channel ) ;
@ -262,6 +255,35 @@ static void handle_error_channel(struct channel *channel,
tal_free ( forgets ) ;
}
static void handle_error_channel ( struct channel * channel ,
const u8 * msg )
{
if ( ! fromwire_channel_send_error_reply ( msg ) ) {
channel_internal_error ( channel , " bad send_error_reply: %s " ,
tal_hex ( tmpctx , msg ) ) ;
return ;
}
forget ( channel ) ;
}
void forget_channel ( struct channel * channel , const char * why )
{
struct channel_id cid ;
derive_channel_id ( & cid , & channel - > funding_txid ,
channel - > funding_outnum ) ;
channel - > error = towire_errorfmt ( channel , & cid , " %s " , why ) ;
/* If the peer is connected, we let them know. Otherwise
* we just directly remove the channel */
if ( channel - > owner )
subd_send_msg ( channel - > owner ,
take ( towire_channel_send_error ( NULL , why ) ) ) ;
else
forget ( channel ) ;
}
static unsigned channel_msg ( struct subd * sd , const u8 * msg , const int * fds )
{
enum channel_wire_type t = fromwire_peektype ( msg ) ;