@@ -1357,7 +1357,6 @@ const SERIALIZATION_VERSION: u8 = 1;
1357
1357
const MIN_SERIALIZATION_VERSION : u8 = 1 ;
1358
1358
1359
1359
impl < Signer : EcdsaChannelSigner > Writeable for ChannelMonitorImpl < Signer > {
1360
- #[ rustfmt:: skip]
1361
1360
fn write < W : Writer > ( & self , writer : & mut W ) -> Result < ( ) , Error > {
1362
1361
write_ver_prefix ! ( writer, SERIALIZATION_VERSION , MIN_SERIALIZATION_VERSION ) ;
1363
1362
@@ -1367,7 +1366,9 @@ impl<Signer: EcdsaChannelSigner> Writeable for ChannelMonitorImpl<Signer> {
1367
1366
U48 ( self . commitment_transaction_number_obscure_factor ) . write ( writer) ?;
1368
1367
1369
1368
self . destination_script . write ( writer) ?;
1370
- if let Some ( ref broadcasted_holder_revokable_script) = self . broadcasted_holder_revokable_script {
1369
+ if let Some ( ref broadcasted_holder_revokable_script) =
1370
+ self . broadcasted_holder_revokable_script
1371
+ {
1371
1372
writer. write_all ( & [ 0 ; 1 ] ) ?;
1372
1373
broadcasted_holder_revokable_script. 0 . write ( writer) ?;
1373
1374
broadcasted_holder_revokable_script. 1 . write ( writer) ?;
@@ -1430,58 +1431,77 @@ impl<Signer: EcdsaChannelSigner> Writeable for ChannelMonitorImpl<Signer> {
1430
1431
}
1431
1432
}
1432
1433
1433
- writer. write_all ( & ( self . funding . counterparty_claimable_outpoints . len ( ) as u64 ) . to_be_bytes ( ) ) ?;
1434
+ writer. write_all (
1435
+ & ( self . funding . counterparty_claimable_outpoints . len ( ) as u64 ) . to_be_bytes ( ) ,
1436
+ ) ?;
1434
1437
for ( ref txid, ref htlc_infos) in self . funding . counterparty_claimable_outpoints . iter ( ) {
1435
1438
writer. write_all ( & txid[ ..] ) ?;
1436
1439
writer. write_all ( & ( htlc_infos. len ( ) as u64 ) . to_be_bytes ( ) ) ?;
1437
1440
for & ( ref htlc_output, ref htlc_source) in htlc_infos. iter ( ) {
1438
- debug_assert ! ( htlc_source. is_none( ) || Some ( * * txid) == self . funding. current_counterparty_commitment_txid
1441
+ debug_assert ! (
1442
+ htlc_source. is_none( )
1443
+ || Some ( * * txid) == self . funding. current_counterparty_commitment_txid
1439
1444
|| Some ( * * txid) == self . funding. prev_counterparty_commitment_txid,
1440
- "HTLC Sources for all revoked commitment transactions should be none!" ) ;
1445
+ "HTLC Sources for all revoked commitment transactions should be none!"
1446
+ ) ;
1441
1447
serialize_htlc_in_commitment ! ( htlc_output) ;
1442
1448
htlc_source. as_ref ( ) . map ( |b| b. as_ref ( ) ) . write ( writer) ?;
1443
1449
}
1444
1450
}
1445
1451
1446
- writer. write_all ( & ( self . counterparty_commitment_txn_on_chain . len ( ) as u64 ) . to_be_bytes ( ) ) ?;
1452
+ writer
1453
+ . write_all ( & ( self . counterparty_commitment_txn_on_chain . len ( ) as u64 ) . to_be_bytes ( ) ) ?;
1447
1454
for ( ref txid, commitment_number) in self . counterparty_commitment_txn_on_chain . iter ( ) {
1448
1455
writer. write_all ( & txid[ ..] ) ?;
1449
1456
writer. write_all ( & byte_utils:: be48_to_array ( * commitment_number) ) ?;
1450
1457
}
1451
1458
1452
1459
writer. write_all ( & ( self . counterparty_hash_commitment_number . len ( ) as u64 ) . to_be_bytes ( ) ) ?;
1453
- for ( ref payment_hash, commitment_number) in self . counterparty_hash_commitment_number . iter ( ) {
1460
+ for ( ref payment_hash, commitment_number) in self . counterparty_hash_commitment_number . iter ( )
1461
+ {
1454
1462
writer. write_all ( & payment_hash. 0 [ ..] ) ?;
1455
1463
writer. write_all ( & byte_utils:: be48_to_array ( * commitment_number) ) ?;
1456
1464
}
1457
1465
1458
1466
if let Some ( holder_commitment_tx) = & self . funding . prev_holder_commitment_tx {
1459
1467
writer. write_all ( & [ 1 ; 1 ] ) ?;
1460
1468
write_legacy_holder_commitment_data (
1461
- writer, holder_commitment_tx, & self . prev_holder_htlc_data . as_ref ( ) . unwrap ( ) ,
1469
+ writer,
1470
+ holder_commitment_tx,
1471
+ & self . prev_holder_htlc_data . as_ref ( ) . unwrap ( ) ,
1462
1472
) ?;
1463
1473
} else {
1464
1474
writer. write_all ( & [ 0 ; 1 ] ) ?;
1465
1475
}
1466
1476
1467
1477
write_legacy_holder_commitment_data (
1468
- writer, & self . funding . current_holder_commitment_tx , & self . current_holder_htlc_data ,
1478
+ writer,
1479
+ & self . funding . current_holder_commitment_tx ,
1480
+ & self . current_holder_htlc_data ,
1469
1481
) ?;
1470
1482
1471
- writer. write_all ( & byte_utils:: be48_to_array ( self . current_counterparty_commitment_number ) ) ?;
1483
+ writer
1484
+ . write_all ( & byte_utils:: be48_to_array ( self . current_counterparty_commitment_number ) ) ?;
1472
1485
writer. write_all ( & byte_utils:: be48_to_array ( self . current_holder_commitment_number ) ) ?;
1473
1486
1474
1487
writer. write_all ( & ( self . payment_preimages . len ( ) as u64 ) . to_be_bytes ( ) ) ?;
1475
1488
for ( payment_preimage, _) in self . payment_preimages . values ( ) {
1476
1489
writer. write_all ( & payment_preimage. 0 [ ..] ) ?;
1477
1490
}
1478
1491
1479
- writer. write_all ( & ( self . pending_monitor_events . iter ( ) . filter ( |ev| match ev {
1480
- MonitorEvent :: HTLCEvent ( _) => true ,
1481
- MonitorEvent :: HolderForceClosed ( _) => true ,
1482
- MonitorEvent :: HolderForceClosedWithInfo { .. } => true ,
1483
- _ => false ,
1484
- } ) . count ( ) as u64 ) . to_be_bytes ( ) ) ?;
1492
+ writer. write_all (
1493
+ & ( self
1494
+ . pending_monitor_events
1495
+ . iter ( )
1496
+ . filter ( |ev| match ev {
1497
+ MonitorEvent :: HTLCEvent ( _) => true ,
1498
+ MonitorEvent :: HolderForceClosed ( _) => true ,
1499
+ MonitorEvent :: HolderForceClosedWithInfo { .. } => true ,
1500
+ _ => false ,
1501
+ } )
1502
+ . count ( ) as u64 )
1503
+ . to_be_bytes ( ) ,
1504
+ ) ?;
1485
1505
for event in self . pending_monitor_events . iter ( ) {
1486
1506
match event {
1487
1507
MonitorEvent :: HTLCEvent ( upd) => {
@@ -1505,7 +1525,8 @@ impl<Signer: EcdsaChannelSigner> Writeable for ChannelMonitorImpl<Signer> {
1505
1525
self . best_block . block_hash . write ( writer) ?;
1506
1526
writer. write_all ( & self . best_block . height . to_be_bytes ( ) ) ?;
1507
1527
1508
- writer. write_all ( & ( self . onchain_events_awaiting_threshold_conf . len ( ) as u64 ) . to_be_bytes ( ) ) ?;
1528
+ writer
1529
+ . write_all ( & ( self . onchain_events_awaiting_threshold_conf . len ( ) as u64 ) . to_be_bytes ( ) ) ?;
1509
1530
for ref entry in self . onchain_events_awaiting_threshold_conf . iter ( ) {
1510
1531
entry. write ( writer) ?;
1511
1532
}
@@ -1533,7 +1554,7 @@ impl<Signer: EcdsaChannelSigner> Writeable for ChannelMonitorImpl<Signer> {
1533
1554
let mut pending_monitor_events = self . pending_monitor_events . clone ( ) ;
1534
1555
pending_monitor_events. push ( MonitorEvent :: HolderForceClosed ( * outpoint) ) ;
1535
1556
pending_monitor_events
1536
- }
1557
+ } ,
1537
1558
_ => self . pending_monitor_events . clone ( ) ,
1538
1559
} ;
1539
1560
0 commit comments