@@ -1346,7 +1346,6 @@ const SERIALIZATION_VERSION: u8 = 1;
1346
1346
const MIN_SERIALIZATION_VERSION : u8 = 1 ;
1347
1347
1348
1348
impl < Signer : EcdsaChannelSigner > Writeable for ChannelMonitorImpl < Signer > {
1349
- #[ rustfmt:: skip]
1350
1349
fn write < W : Writer > ( & self , writer : & mut W ) -> Result < ( ) , Error > {
1351
1350
write_ver_prefix ! ( writer, SERIALIZATION_VERSION , MIN_SERIALIZATION_VERSION ) ;
1352
1351
@@ -1356,7 +1355,9 @@ impl<Signer: EcdsaChannelSigner> Writeable for ChannelMonitorImpl<Signer> {
1356
1355
U48 ( self . commitment_transaction_number_obscure_factor ) . write ( writer) ?;
1357
1356
1358
1357
self . destination_script . write ( writer) ?;
1359
- if let Some ( ref broadcasted_holder_revokable_script) = self . broadcasted_holder_revokable_script {
1358
+ if let Some ( ref broadcasted_holder_revokable_script) =
1359
+ self . broadcasted_holder_revokable_script
1360
+ {
1360
1361
writer. write_all ( & [ 0 ; 1 ] ) ?;
1361
1362
broadcasted_holder_revokable_script. 0 . write ( writer) ?;
1362
1363
broadcasted_holder_revokable_script. 1 . write ( writer) ?;
@@ -1419,58 +1420,77 @@ impl<Signer: EcdsaChannelSigner> Writeable for ChannelMonitorImpl<Signer> {
1419
1420
}
1420
1421
}
1421
1422
1422
- writer. write_all ( & ( self . funding . counterparty_claimable_outpoints . len ( ) as u64 ) . to_be_bytes ( ) ) ?;
1423
+ writer. write_all (
1424
+ & ( self . funding . counterparty_claimable_outpoints . len ( ) as u64 ) . to_be_bytes ( ) ,
1425
+ ) ?;
1423
1426
for ( ref txid, ref htlc_infos) in self . funding . counterparty_claimable_outpoints . iter ( ) {
1424
1427
writer. write_all ( & txid[ ..] ) ?;
1425
1428
writer. write_all ( & ( htlc_infos. len ( ) as u64 ) . to_be_bytes ( ) ) ?;
1426
1429
for & ( ref htlc_output, ref htlc_source) in htlc_infos. iter ( ) {
1427
- debug_assert ! ( htlc_source. is_none( ) || Some ( * * txid) == self . funding. current_counterparty_commitment_txid
1430
+ debug_assert ! (
1431
+ htlc_source. is_none( )
1432
+ || Some ( * * txid) == self . funding. current_counterparty_commitment_txid
1428
1433
|| Some ( * * txid) == self . funding. prev_counterparty_commitment_txid,
1429
- "HTLC Sources for all revoked commitment transactions should be none!" ) ;
1434
+ "HTLC Sources for all revoked commitment transactions should be none!"
1435
+ ) ;
1430
1436
serialize_htlc_in_commitment ! ( htlc_output) ;
1431
1437
htlc_source. as_ref ( ) . map ( |b| b. as_ref ( ) ) . write ( writer) ?;
1432
1438
}
1433
1439
}
1434
1440
1435
- writer. write_all ( & ( self . counterparty_commitment_txn_on_chain . len ( ) as u64 ) . to_be_bytes ( ) ) ?;
1441
+ writer
1442
+ . write_all ( & ( self . counterparty_commitment_txn_on_chain . len ( ) as u64 ) . to_be_bytes ( ) ) ?;
1436
1443
for ( ref txid, commitment_number) in self . counterparty_commitment_txn_on_chain . iter ( ) {
1437
1444
writer. write_all ( & txid[ ..] ) ?;
1438
1445
writer. write_all ( & byte_utils:: be48_to_array ( * commitment_number) ) ?;
1439
1446
}
1440
1447
1441
1448
writer. write_all ( & ( self . counterparty_hash_commitment_number . len ( ) as u64 ) . to_be_bytes ( ) ) ?;
1442
- for ( ref payment_hash, commitment_number) in self . counterparty_hash_commitment_number . iter ( ) {
1449
+ for ( ref payment_hash, commitment_number) in self . counterparty_hash_commitment_number . iter ( )
1450
+ {
1443
1451
writer. write_all ( & payment_hash. 0 [ ..] ) ?;
1444
1452
writer. write_all ( & byte_utils:: be48_to_array ( * commitment_number) ) ?;
1445
1453
}
1446
1454
1447
1455
if let Some ( holder_commitment_tx) = & self . funding . prev_holder_commitment_tx {
1448
1456
writer. write_all ( & [ 1 ; 1 ] ) ?;
1449
1457
write_legacy_holder_commitment_data (
1450
- writer, holder_commitment_tx, & self . prev_holder_htlc_data . as_ref ( ) . unwrap ( ) ,
1458
+ writer,
1459
+ holder_commitment_tx,
1460
+ & self . prev_holder_htlc_data . as_ref ( ) . unwrap ( ) ,
1451
1461
) ?;
1452
1462
} else {
1453
1463
writer. write_all ( & [ 0 ; 1 ] ) ?;
1454
1464
}
1455
1465
1456
1466
write_legacy_holder_commitment_data (
1457
- writer, & self . funding . current_holder_commitment_tx , & self . current_holder_htlc_data ,
1467
+ writer,
1468
+ & self . funding . current_holder_commitment_tx ,
1469
+ & self . current_holder_htlc_data ,
1458
1470
) ?;
1459
1471
1460
- writer. write_all ( & byte_utils:: be48_to_array ( self . current_counterparty_commitment_number ) ) ?;
1472
+ writer
1473
+ . write_all ( & byte_utils:: be48_to_array ( self . current_counterparty_commitment_number ) ) ?;
1461
1474
writer. write_all ( & byte_utils:: be48_to_array ( self . current_holder_commitment_number ) ) ?;
1462
1475
1463
1476
writer. write_all ( & ( self . payment_preimages . len ( ) as u64 ) . to_be_bytes ( ) ) ?;
1464
1477
for ( payment_preimage, _) in self . payment_preimages . values ( ) {
1465
1478
writer. write_all ( & payment_preimage. 0 [ ..] ) ?;
1466
1479
}
1467
1480
1468
- writer. write_all ( & ( self . pending_monitor_events . iter ( ) . filter ( |ev| match ev {
1469
- MonitorEvent :: HTLCEvent ( _) => true ,
1470
- MonitorEvent :: HolderForceClosed ( _) => true ,
1471
- MonitorEvent :: HolderForceClosedWithInfo { .. } => true ,
1472
- _ => false ,
1473
- } ) . count ( ) as u64 ) . to_be_bytes ( ) ) ?;
1481
+ writer. write_all (
1482
+ & ( self
1483
+ . pending_monitor_events
1484
+ . iter ( )
1485
+ . filter ( |ev| match ev {
1486
+ MonitorEvent :: HTLCEvent ( _) => true ,
1487
+ MonitorEvent :: HolderForceClosed ( _) => true ,
1488
+ MonitorEvent :: HolderForceClosedWithInfo { .. } => true ,
1489
+ _ => false ,
1490
+ } )
1491
+ . count ( ) as u64 )
1492
+ . to_be_bytes ( ) ,
1493
+ ) ?;
1474
1494
for event in self . pending_monitor_events . iter ( ) {
1475
1495
match event {
1476
1496
MonitorEvent :: HTLCEvent ( upd) => {
@@ -1494,7 +1514,8 @@ impl<Signer: EcdsaChannelSigner> Writeable for ChannelMonitorImpl<Signer> {
1494
1514
self . best_block . block_hash . write ( writer) ?;
1495
1515
writer. write_all ( & self . best_block . height . to_be_bytes ( ) ) ?;
1496
1516
1497
- writer. write_all ( & ( self . onchain_events_awaiting_threshold_conf . len ( ) as u64 ) . to_be_bytes ( ) ) ?;
1517
+ writer
1518
+ . write_all ( & ( self . onchain_events_awaiting_threshold_conf . len ( ) as u64 ) . to_be_bytes ( ) ) ?;
1498
1519
for ref entry in self . onchain_events_awaiting_threshold_conf . iter ( ) {
1499
1520
entry. write ( writer) ?;
1500
1521
}
@@ -1522,7 +1543,7 @@ impl<Signer: EcdsaChannelSigner> Writeable for ChannelMonitorImpl<Signer> {
1522
1543
let mut pending_monitor_events = self . pending_monitor_events . clone ( ) ;
1523
1544
pending_monitor_events. push ( MonitorEvent :: HolderForceClosed ( * outpoint) ) ;
1524
1545
pending_monitor_events
1525
- }
1546
+ } ,
1526
1547
_ => self . pending_monitor_events . clone ( ) ,
1527
1548
} ;
1528
1549
0 commit comments