@@ -1403,7 +1403,6 @@ const SERIALIZATION_VERSION: u8 = 1;
14031403const MIN_SERIALIZATION_VERSION : u8 = 1 ;
14041404
14051405impl < Signer : EcdsaChannelSigner > Writeable for ChannelMonitorImpl < Signer > {
1406- #[ rustfmt:: skip]
14071406 fn write < W : Writer > ( & self , writer : & mut W ) -> Result < ( ) , Error > {
14081407 write_ver_prefix ! ( writer, SERIALIZATION_VERSION , MIN_SERIALIZATION_VERSION ) ;
14091408
@@ -1413,7 +1412,9 @@ impl<Signer: EcdsaChannelSigner> Writeable for ChannelMonitorImpl<Signer> {
14131412 U48 ( self . commitment_transaction_number_obscure_factor ) . write ( writer) ?;
14141413
14151414 self . destination_script . write ( writer) ?;
1416- if let Some ( ref broadcasted_holder_revokable_script) = self . broadcasted_holder_revokable_script {
1415+ if let Some ( ref broadcasted_holder_revokable_script) =
1416+ self . broadcasted_holder_revokable_script
1417+ {
14171418 writer. write_all ( & [ 0 ; 1 ] ) ?;
14181419 broadcasted_holder_revokable_script. 0 . write ( writer) ?;
14191420 broadcasted_holder_revokable_script. 1 . write ( writer) ?;
@@ -1476,58 +1477,77 @@ impl<Signer: EcdsaChannelSigner> Writeable for ChannelMonitorImpl<Signer> {
14761477 }
14771478 }
14781479
1479- writer. write_all ( & ( self . funding . counterparty_claimable_outpoints . len ( ) as u64 ) . to_be_bytes ( ) ) ?;
1480+ writer. write_all (
1481+ & ( self . funding . counterparty_claimable_outpoints . len ( ) as u64 ) . to_be_bytes ( ) ,
1482+ ) ?;
14801483 for ( ref txid, ref htlc_infos) in self . funding . counterparty_claimable_outpoints . iter ( ) {
14811484 writer. write_all ( & txid[ ..] ) ?;
14821485 writer. write_all ( & ( htlc_infos. len ( ) as u64 ) . to_be_bytes ( ) ) ?;
14831486 for & ( ref htlc_output, ref htlc_source) in htlc_infos. iter ( ) {
1484- debug_assert ! ( htlc_source. is_none( ) || Some ( * * txid) == self . funding. current_counterparty_commitment_txid
1487+ debug_assert ! (
1488+ htlc_source. is_none( )
1489+ || Some ( * * txid) == self . funding. current_counterparty_commitment_txid
14851490 || Some ( * * txid) == self . funding. prev_counterparty_commitment_txid,
1486- "HTLC Sources for all revoked commitment transactions should be none!" ) ;
1491+ "HTLC Sources for all revoked commitment transactions should be none!"
1492+ ) ;
14871493 serialize_htlc_in_commitment ! ( htlc_output) ;
14881494 htlc_source. as_ref ( ) . map ( |b| b. as_ref ( ) ) . write ( writer) ?;
14891495 }
14901496 }
14911497
1492- writer. write_all ( & ( self . counterparty_commitment_txn_on_chain . len ( ) as u64 ) . to_be_bytes ( ) ) ?;
1498+ writer
1499+ . write_all ( & ( self . counterparty_commitment_txn_on_chain . len ( ) as u64 ) . to_be_bytes ( ) ) ?;
14931500 for ( ref txid, commitment_number) in self . counterparty_commitment_txn_on_chain . iter ( ) {
14941501 writer. write_all ( & txid[ ..] ) ?;
14951502 writer. write_all ( & byte_utils:: be48_to_array ( * commitment_number) ) ?;
14961503 }
14971504
14981505 writer. write_all ( & ( self . counterparty_hash_commitment_number . len ( ) as u64 ) . to_be_bytes ( ) ) ?;
1499- for ( ref payment_hash, commitment_number) in self . counterparty_hash_commitment_number . iter ( ) {
1506+ for ( ref payment_hash, commitment_number) in self . counterparty_hash_commitment_number . iter ( )
1507+ {
15001508 writer. write_all ( & payment_hash. 0 [ ..] ) ?;
15011509 writer. write_all ( & byte_utils:: be48_to_array ( * commitment_number) ) ?;
15021510 }
15031511
15041512 if let Some ( holder_commitment_tx) = & self . funding . prev_holder_commitment_tx {
15051513 writer. write_all ( & [ 1 ; 1 ] ) ?;
15061514 write_legacy_holder_commitment_data (
1507- writer, holder_commitment_tx, & self . prev_holder_htlc_data . as_ref ( ) . unwrap ( ) ,
1515+ writer,
1516+ holder_commitment_tx,
1517+ & self . prev_holder_htlc_data . as_ref ( ) . unwrap ( ) ,
15081518 ) ?;
15091519 } else {
15101520 writer. write_all ( & [ 0 ; 1 ] ) ?;
15111521 }
15121522
15131523 write_legacy_holder_commitment_data (
1514- writer, & self . funding . current_holder_commitment_tx , & self . current_holder_htlc_data ,
1524+ writer,
1525+ & self . funding . current_holder_commitment_tx ,
1526+ & self . current_holder_htlc_data ,
15151527 ) ?;
15161528
1517- writer. write_all ( & byte_utils:: be48_to_array ( self . current_counterparty_commitment_number ) ) ?;
1529+ writer
1530+ . write_all ( & byte_utils:: be48_to_array ( self . current_counterparty_commitment_number ) ) ?;
15181531 writer. write_all ( & byte_utils:: be48_to_array ( self . current_holder_commitment_number ) ) ?;
15191532
15201533 writer. write_all ( & ( self . payment_preimages . len ( ) as u64 ) . to_be_bytes ( ) ) ?;
15211534 for ( payment_preimage, _) in self . payment_preimages . values ( ) {
15221535 writer. write_all ( & payment_preimage. 0 [ ..] ) ?;
15231536 }
15241537
1525- writer. write_all ( & ( self . pending_monitor_events . iter ( ) . filter ( |ev| match ev {
1526- MonitorEvent :: HTLCEvent ( _) => true ,
1527- MonitorEvent :: HolderForceClosed ( _) => true ,
1528- MonitorEvent :: HolderForceClosedWithInfo { .. } => true ,
1529- _ => false ,
1530- } ) . count ( ) as u64 ) . to_be_bytes ( ) ) ?;
1538+ writer. write_all (
1539+ & ( self
1540+ . pending_monitor_events
1541+ . iter ( )
1542+ . filter ( |ev| match ev {
1543+ MonitorEvent :: HTLCEvent ( _) => true ,
1544+ MonitorEvent :: HolderForceClosed ( _) => true ,
1545+ MonitorEvent :: HolderForceClosedWithInfo { .. } => true ,
1546+ _ => false ,
1547+ } )
1548+ . count ( ) as u64 )
1549+ . to_be_bytes ( ) ,
1550+ ) ?;
15311551 for event in self . pending_monitor_events . iter ( ) {
15321552 match event {
15331553 MonitorEvent :: HTLCEvent ( upd) => {
@@ -1551,7 +1571,8 @@ impl<Signer: EcdsaChannelSigner> Writeable for ChannelMonitorImpl<Signer> {
15511571 self . best_block . block_hash . write ( writer) ?;
15521572 writer. write_all ( & self . best_block . height . to_be_bytes ( ) ) ?;
15531573
1554- writer. write_all ( & ( self . onchain_events_awaiting_threshold_conf . len ( ) as u64 ) . to_be_bytes ( ) ) ?;
1574+ writer
1575+ . write_all ( & ( self . onchain_events_awaiting_threshold_conf . len ( ) as u64 ) . to_be_bytes ( ) ) ?;
15551576 for ref entry in self . onchain_events_awaiting_threshold_conf . iter ( ) {
15561577 entry. write ( writer) ?;
15571578 }
@@ -1579,7 +1600,7 @@ impl<Signer: EcdsaChannelSigner> Writeable for ChannelMonitorImpl<Signer> {
15791600 let mut pending_monitor_events = self . pending_monitor_events . clone ( ) ;
15801601 pending_monitor_events. push ( MonitorEvent :: HolderForceClosed ( * outpoint) ) ;
15811602 pending_monitor_events
1582- }
1603+ } ,
15831604 _ => self . pending_monitor_events . clone ( ) ,
15841605 } ;
15851606
0 commit comments