@@ -1488,16 +1488,25 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
14881488 let their_pubkeys = self . their_pubkeys . as_ref ( ) . unwrap ( ) ;
14891489 let funding_redeemscript = self . get_funding_redeemscript ( ) ;
14901490 let funding_txo_script = funding_redeemscript. to_v0_p2wsh ( ) ;
1491- self . channel_monitor = Some ( ChannelMonitor :: new ( self . local_keys . clone ( ) ,
1492- & self . shutdown_pubkey , self . our_to_self_delay ,
1493- & self . destination_script , ( funding_txo, funding_txo_script) ,
1494- & their_pubkeys. htlc_basepoint , & their_pubkeys. delayed_payment_basepoint ,
1495- self . their_to_self_delay , funding_redeemscript, self . channel_value_satoshis ,
1496- self . get_commitment_transaction_number_obscure_factor ( ) ,
1497- self . logger . clone ( ) ) ) ;
1498-
1499- self . channel_monitor . as_mut ( ) . unwrap ( ) . provide_latest_remote_commitment_tx_info ( & remote_initial_commitment_tx, Vec :: new ( ) , self . cur_remote_commitment_transaction_number , self . their_cur_commitment_point . unwrap ( ) ) ;
1500- self . channel_monitor . as_mut ( ) . unwrap ( ) . provide_latest_local_commitment_tx_info ( local_initial_commitment_tx, local_keys, self . feerate_per_kw , Vec :: new ( ) ) . unwrap ( ) ;
1491+ macro_rules! create_monitor {
1492+ ( ) => { {
1493+ let mut channel_monitor = ChannelMonitor :: new( self . local_keys. clone( ) ,
1494+ & self . shutdown_pubkey, self . our_to_self_delay,
1495+ & self . destination_script, ( funding_txo, funding_txo_script. clone( ) ) ,
1496+ & their_pubkeys. htlc_basepoint, & their_pubkeys. delayed_payment_basepoint,
1497+ self . their_to_self_delay, funding_redeemscript. clone( ) , self . channel_value_satoshis,
1498+ self . get_commitment_transaction_number_obscure_factor( ) ,
1499+ self . logger. clone( ) ) ;
1500+
1501+ channel_monitor. provide_latest_remote_commitment_tx_info( & remote_initial_commitment_tx, Vec :: new( ) , self . cur_remote_commitment_transaction_number, self . their_cur_commitment_point. unwrap( ) ) ;
1502+ channel_monitor. provide_latest_local_commitment_tx_info( local_initial_commitment_tx. clone( ) , local_keys. clone( ) , self . feerate_per_kw, Vec :: new( ) ) . unwrap( ) ;
1503+ channel_monitor
1504+ } }
1505+ }
1506+
1507+ self . channel_monitor = Some ( create_monitor ! ( ) ) ;
1508+ let channel_monitor = create_monitor ! ( ) ;
1509+
15011510 self . channel_state = ChannelState :: FundingSent as u32 ;
15021511 self . channel_id = funding_txo. to_channel_id ( ) ;
15031512 self . cur_remote_commitment_transaction_number -= 1 ;
@@ -1506,7 +1515,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
15061515 Ok ( ( msgs:: FundingSigned {
15071516 channel_id : self . channel_id ,
15081517 signature : our_signature
1509- } , self . channel_monitor . as_ref ( ) . unwrap ( ) . clone ( ) ) )
1518+ } , channel_monitor) )
15101519 }
15111520
15121521 /// Handles a funding_signed message from the remote end.
@@ -3330,15 +3339,24 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
33303339 let their_pubkeys = self . their_pubkeys . as_ref ( ) . unwrap ( ) ;
33313340 let funding_redeemscript = self . get_funding_redeemscript ( ) ;
33323341 let funding_txo_script = funding_redeemscript. to_v0_p2wsh ( ) ;
3333- self . channel_monitor = Some ( ChannelMonitor :: new ( self . local_keys . clone ( ) ,
3334- & self . shutdown_pubkey , self . our_to_self_delay ,
3335- & self . destination_script , ( funding_txo, funding_txo_script) ,
3336- & their_pubkeys. htlc_basepoint , & their_pubkeys. delayed_payment_basepoint ,
3337- self . their_to_self_delay , funding_redeemscript, self . channel_value_satoshis ,
3338- self . get_commitment_transaction_number_obscure_factor ( ) ,
3339- self . logger . clone ( ) ) ) ;
3340-
3341- self . channel_monitor . as_mut ( ) . unwrap ( ) . provide_latest_remote_commitment_tx_info ( & commitment_tx, Vec :: new ( ) , self . cur_remote_commitment_transaction_number , self . their_cur_commitment_point . unwrap ( ) ) ;
3342+ macro_rules! create_monitor {
3343+ ( ) => { {
3344+ let mut channel_monitor = ChannelMonitor :: new( self . local_keys. clone( ) ,
3345+ & self . shutdown_pubkey, self . our_to_self_delay,
3346+ & self . destination_script, ( funding_txo, funding_txo_script. clone( ) ) ,
3347+ & their_pubkeys. htlc_basepoint, & their_pubkeys. delayed_payment_basepoint,
3348+ self . their_to_self_delay, funding_redeemscript. clone( ) , self . channel_value_satoshis,
3349+ self . get_commitment_transaction_number_obscure_factor( ) ,
3350+ self . logger. clone( ) ) ;
3351+
3352+ channel_monitor. provide_latest_remote_commitment_tx_info( & commitment_tx, Vec :: new( ) , self . cur_remote_commitment_transaction_number, self . their_cur_commitment_point. unwrap( ) ) ;
3353+ channel_monitor
3354+ } }
3355+ }
3356+
3357+ self . channel_monitor = Some ( create_monitor ! ( ) ) ;
3358+ let channel_monitor = create_monitor ! ( ) ;
3359+
33423360 self . channel_state = ChannelState :: FundingCreated as u32 ;
33433361 self . channel_id = funding_txo. to_channel_id ( ) ;
33443362 self . cur_remote_commitment_transaction_number -= 1 ;
@@ -3348,7 +3366,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
33483366 funding_txid : funding_txo. txid ,
33493367 funding_output_index : funding_txo. index ,
33503368 signature : our_signature
3351- } , self . channel_monitor . as_ref ( ) . unwrap ( ) . clone ( ) ) )
3369+ } , channel_monitor) )
33523370 }
33533371
33543372 /// Gets an UnsignedChannelAnnouncement, as well as a signature covering it using our
0 commit comments