@@ -1481,16 +1481,25 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
1481
1481
let their_pubkeys = self . their_pubkeys . as_ref ( ) . unwrap ( ) ;
1482
1482
let funding_redeemscript = self . get_funding_redeemscript ( ) ;
1483
1483
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
+
1494
1503
self . channel_state = ChannelState :: FundingSent as u32 ;
1495
1504
self . channel_id = funding_txo. to_channel_id ( ) ;
1496
1505
self . cur_remote_commitment_transaction_number -= 1 ;
@@ -1499,7 +1508,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
1499
1508
Ok ( ( msgs:: FundingSigned {
1500
1509
channel_id : self . channel_id ,
1501
1510
signature : our_signature
1502
- } , self . channel_monitor . as_ref ( ) . unwrap ( ) . clone ( ) ) )
1511
+ } , channel_monitor) )
1503
1512
}
1504
1513
1505
1514
/// Handles a funding_signed message from the remote end.
@@ -3323,15 +3332,24 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
3323
3332
let their_pubkeys = self . their_pubkeys . as_ref ( ) . unwrap ( ) ;
3324
3333
let funding_redeemscript = self . get_funding_redeemscript ( ) ;
3325
3334
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
+
3335
3353
self . channel_state = ChannelState :: FundingCreated as u32 ;
3336
3354
self . channel_id = funding_txo. to_channel_id ( ) ;
3337
3355
self . cur_remote_commitment_transaction_number -= 1 ;
@@ -3341,7 +3359,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
3341
3359
funding_txid : funding_txo. txid ,
3342
3360
funding_output_index : funding_txo. index ,
3343
3361
signature : our_signature
3344
- } , self . channel_monitor . as_ref ( ) . unwrap ( ) . clone ( ) ) )
3362
+ } , channel_monitor) )
3345
3363
}
3346
3364
3347
3365
/// Gets an UnsignedChannelAnnouncement, as well as a signature covering it using our
0 commit comments