@@ -1481,16 +1481,25 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
14811481 let their_pubkeys = self . their_pubkeys . as_ref ( ) . unwrap ( ) ;
14821482 let funding_redeemscript = self . get_funding_redeemscript ( ) ;
14831483 let funding_txo_script = funding_redeemscript. to_v0_p2wsh ( ) ;
1484- self . channel_monitor = Some ( ChannelMonitor :: new ( self . local_keys . clone ( ) ,
1485- & self . shutdown_pubkey , self . our_to_self_delay ,
1486- & self . destination_script , ( funding_txo, funding_txo_script) ,
1487- & their_pubkeys. htlc_basepoint , & their_pubkeys. delayed_payment_basepoint ,
1488- self . their_to_self_delay , funding_redeemscript, self . channel_value_satoshis ,
1489- self . get_commitment_transaction_number_obscure_factor ( ) ,
1490- self . logger . clone ( ) ) ) ;
1491-
1492- 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 ( ) ) ;
1493- 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 ( ) ;
1484+ macro_rules! create_monitor {
1485+ ( ) => { {
1486+ let mut channel_monitor = ChannelMonitor :: new( self . local_keys. clone( ) ,
1487+ & self . shutdown_pubkey, self . our_to_self_delay,
1488+ & self . destination_script, ( funding_txo, funding_txo_script. clone( ) ) ,
1489+ & their_pubkeys. htlc_basepoint, & their_pubkeys. delayed_payment_basepoint,
1490+ self . their_to_self_delay, funding_redeemscript. clone( ) , self . channel_value_satoshis,
1491+ self . get_commitment_transaction_number_obscure_factor( ) ,
1492+ self . logger. clone( ) ) ;
1493+
1494+ 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( ) ) ;
1495+ channel_monitor. provide_latest_local_commitment_tx_info( local_initial_commitment_tx. clone( ) , local_keys. clone( ) , self . feerate_per_kw, Vec :: new( ) ) . unwrap( ) ;
1496+ channel_monitor
1497+ } }
1498+ }
1499+
1500+ self . channel_monitor = Some ( create_monitor ! ( ) ) ;
1501+ let channel_monitor = create_monitor ! ( ) ;
1502+
14941503 self . channel_state = ChannelState :: FundingSent as u32 ;
14951504 self . channel_id = funding_txo. to_channel_id ( ) ;
14961505 self . cur_remote_commitment_transaction_number -= 1 ;
@@ -1499,7 +1508,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
14991508 Ok ( ( msgs:: FundingSigned {
15001509 channel_id : self . channel_id ,
15011510 signature : our_signature
1502- } , self . channel_monitor . as_ref ( ) . unwrap ( ) . clone ( ) ) )
1511+ } , channel_monitor) )
15031512 }
15041513
15051514 /// Handles a funding_signed message from the remote end.
@@ -3323,15 +3332,24 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
33233332 let their_pubkeys = self . their_pubkeys . as_ref ( ) . unwrap ( ) ;
33243333 let funding_redeemscript = self . get_funding_redeemscript ( ) ;
33253334 let funding_txo_script = funding_redeemscript. to_v0_p2wsh ( ) ;
3326- self . channel_monitor = Some ( ChannelMonitor :: new ( self . local_keys . clone ( ) ,
3327- & self . shutdown_pubkey , self . our_to_self_delay ,
3328- & self . destination_script , ( funding_txo, funding_txo_script) ,
3329- & their_pubkeys. htlc_basepoint , & their_pubkeys. delayed_payment_basepoint ,
3330- self . their_to_self_delay , funding_redeemscript, self . channel_value_satoshis ,
3331- self . get_commitment_transaction_number_obscure_factor ( ) ,
3332- self . logger . clone ( ) ) ) ;
3333-
3334- 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 ( ) ) ;
3335+ macro_rules! create_monitor {
3336+ ( ) => { {
3337+ let mut channel_monitor = ChannelMonitor :: new( self . local_keys. clone( ) ,
3338+ & self . shutdown_pubkey, self . our_to_self_delay,
3339+ & self . destination_script, ( funding_txo, funding_txo_script. clone( ) ) ,
3340+ & their_pubkeys. htlc_basepoint, & their_pubkeys. delayed_payment_basepoint,
3341+ self . their_to_self_delay, funding_redeemscript. clone( ) , self . channel_value_satoshis,
3342+ self . get_commitment_transaction_number_obscure_factor( ) ,
3343+ self . logger. clone( ) ) ;
3344+
3345+ channel_monitor. provide_latest_remote_commitment_tx_info( & commitment_tx, Vec :: new( ) , self . cur_remote_commitment_transaction_number, self . their_cur_commitment_point. unwrap( ) ) ;
3346+ channel_monitor
3347+ } }
3348+ }
3349+
3350+ self . channel_monitor = Some ( create_monitor ! ( ) ) ;
3351+ let channel_monitor = create_monitor ! ( ) ;
3352+
33353353 self . channel_state = ChannelState :: FundingCreated as u32 ;
33363354 self . channel_id = funding_txo. to_channel_id ( ) ;
33373355 self . cur_remote_commitment_transaction_number -= 1 ;
@@ -3341,7 +3359,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
33413359 funding_txid : funding_txo. txid ,
33423360 funding_output_index : funding_txo. index ,
33433361 signature : our_signature
3344- } , self . channel_monitor . as_ref ( ) . unwrap ( ) . clone ( ) ) )
3362+ } , channel_monitor) )
33453363 }
33463364
33473365 /// Gets an UnsignedChannelAnnouncement, as well as a signature covering it using our
0 commit comments