@@ -1403,7 +1403,6 @@ const SERIALIZATION_VERSION: u8 = 1;
1403
1403
const MIN_SERIALIZATION_VERSION : u8 = 1 ;
1404
1404
1405
1405
impl < Signer : EcdsaChannelSigner > Writeable for ChannelMonitorImpl < Signer > {
1406
- #[ rustfmt:: skip]
1407
1406
fn write < W : Writer > ( & self , writer : & mut W ) -> Result < ( ) , Error > {
1408
1407
write_ver_prefix ! ( writer, SERIALIZATION_VERSION , MIN_SERIALIZATION_VERSION ) ;
1409
1408
@@ -1413,7 +1412,9 @@ impl<Signer: EcdsaChannelSigner> Writeable for ChannelMonitorImpl<Signer> {
1413
1412
U48 ( self . commitment_transaction_number_obscure_factor ) . write ( writer) ?;
1414
1413
1415
1414
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
+ {
1417
1418
writer. write_all ( & [ 0 ; 1 ] ) ?;
1418
1419
broadcasted_holder_revokable_script. 0 . write ( writer) ?;
1419
1420
broadcasted_holder_revokable_script. 1 . write ( writer) ?;
@@ -1476,58 +1477,77 @@ impl<Signer: EcdsaChannelSigner> Writeable for ChannelMonitorImpl<Signer> {
1476
1477
}
1477
1478
}
1478
1479
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
+ ) ?;
1480
1483
for ( ref txid, ref htlc_infos) in self . funding . counterparty_claimable_outpoints . iter ( ) {
1481
1484
writer. write_all ( & txid[ ..] ) ?;
1482
1485
writer. write_all ( & ( htlc_infos. len ( ) as u64 ) . to_be_bytes ( ) ) ?;
1483
1486
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
1485
1490
|| 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
+ ) ;
1487
1493
serialize_htlc_in_commitment ! ( htlc_output) ;
1488
1494
htlc_source. as_ref ( ) . map ( |b| b. as_ref ( ) ) . write ( writer) ?;
1489
1495
}
1490
1496
}
1491
1497
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 ( ) ) ?;
1493
1500
for ( ref txid, commitment_number) in self . counterparty_commitment_txn_on_chain . iter ( ) {
1494
1501
writer. write_all ( & txid[ ..] ) ?;
1495
1502
writer. write_all ( & byte_utils:: be48_to_array ( * commitment_number) ) ?;
1496
1503
}
1497
1504
1498
1505
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
+ {
1500
1508
writer. write_all ( & payment_hash. 0 [ ..] ) ?;
1501
1509
writer. write_all ( & byte_utils:: be48_to_array ( * commitment_number) ) ?;
1502
1510
}
1503
1511
1504
1512
if let Some ( holder_commitment_tx) = & self . funding . prev_holder_commitment_tx {
1505
1513
writer. write_all ( & [ 1 ; 1 ] ) ?;
1506
1514
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 ( ) ,
1508
1518
) ?;
1509
1519
} else {
1510
1520
writer. write_all ( & [ 0 ; 1 ] ) ?;
1511
1521
}
1512
1522
1513
1523
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 ,
1515
1527
) ?;
1516
1528
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 ) ) ?;
1518
1531
writer. write_all ( & byte_utils:: be48_to_array ( self . current_holder_commitment_number ) ) ?;
1519
1532
1520
1533
writer. write_all ( & ( self . payment_preimages . len ( ) as u64 ) . to_be_bytes ( ) ) ?;
1521
1534
for ( payment_preimage, _) in self . payment_preimages . values ( ) {
1522
1535
writer. write_all ( & payment_preimage. 0 [ ..] ) ?;
1523
1536
}
1524
1537
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
+ ) ?;
1531
1551
for event in self . pending_monitor_events . iter ( ) {
1532
1552
match event {
1533
1553
MonitorEvent :: HTLCEvent ( upd) => {
@@ -1551,7 +1571,8 @@ impl<Signer: EcdsaChannelSigner> Writeable for ChannelMonitorImpl<Signer> {
1551
1571
self . best_block . block_hash . write ( writer) ?;
1552
1572
writer. write_all ( & self . best_block . height . to_be_bytes ( ) ) ?;
1553
1573
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 ( ) ) ?;
1555
1576
for ref entry in self . onchain_events_awaiting_threshold_conf . iter ( ) {
1556
1577
entry. write ( writer) ?;
1557
1578
}
@@ -1579,7 +1600,7 @@ impl<Signer: EcdsaChannelSigner> Writeable for ChannelMonitorImpl<Signer> {
1579
1600
let mut pending_monitor_events = self . pending_monitor_events . clone ( ) ;
1580
1601
pending_monitor_events. push ( MonitorEvent :: HolderForceClosed ( * outpoint) ) ;
1581
1602
pending_monitor_events
1582
- }
1603
+ } ,
1583
1604
_ => self . pending_monitor_events . clone ( ) ,
1584
1605
} ;
1585
1606
0 commit comments