@@ -1488,16 +1488,25 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
1488
1488
let their_pubkeys = self . their_pubkeys . as_ref ( ) . unwrap ( ) ;
1489
1489
let funding_redeemscript = self . get_funding_redeemscript ( ) ;
1490
1490
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
+
1501
1510
self . channel_state = ChannelState :: FundingSent as u32 ;
1502
1511
self . channel_id = funding_txo. to_channel_id ( ) ;
1503
1512
self . cur_remote_commitment_transaction_number -= 1 ;
@@ -1506,7 +1515,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
1506
1515
Ok ( ( msgs:: FundingSigned {
1507
1516
channel_id : self . channel_id ,
1508
1517
signature : our_signature
1509
- } , self . channel_monitor . as_ref ( ) . unwrap ( ) . clone ( ) ) )
1518
+ } , channel_monitor) )
1510
1519
}
1511
1520
1512
1521
/// Handles a funding_signed message from the remote end.
@@ -3330,15 +3339,24 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
3330
3339
let their_pubkeys = self . their_pubkeys . as_ref ( ) . unwrap ( ) ;
3331
3340
let funding_redeemscript = self . get_funding_redeemscript ( ) ;
3332
3341
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
+
3342
3360
self . channel_state = ChannelState :: FundingCreated as u32 ;
3343
3361
self . channel_id = funding_txo. to_channel_id ( ) ;
3344
3362
self . cur_remote_commitment_transaction_number -= 1 ;
@@ -3348,7 +3366,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
3348
3366
funding_txid : funding_txo. txid ,
3349
3367
funding_output_index : funding_txo. index ,
3350
3368
signature : our_signature
3351
- } , self . channel_monitor . as_ref ( ) . unwrap ( ) . clone ( ) ) )
3369
+ } , channel_monitor) )
3352
3370
}
3353
3371
3354
3372
/// Gets an UnsignedChannelAnnouncement, as well as a signature covering it using our
0 commit comments