@@ -6406,31 +6406,46 @@ where
6406
6406
Ok(channel_monitor)
6407
6407
}
6408
6408
6409
- #[rustfmt::skip]
6410
- pub fn commitment_signed<L: Deref>(&mut self, msg: &msgs::CommitmentSigned, logger: &L) -> Result<Option<ChannelMonitorUpdate>, ChannelError>
6411
- where L::Target: Logger
6409
+ pub fn commitment_signed<L: Deref>(
6410
+ &mut self, msg: &msgs::CommitmentSigned, logger: &L,
6411
+ ) -> Result<Option<ChannelMonitorUpdate>, ChannelError>
6412
+ where
6413
+ L::Target: Logger,
6412
6414
{
6413
6415
self.commitment_signed_check_state()?;
6414
6416
6415
6417
if !self.pending_funding.is_empty() {
6416
- return Err(ChannelError::close("Got a single commitment_signed message when expecting a batch".to_owned()));
6418
+ return Err(ChannelError::close(
6419
+ "Got a single commitment_signed message when expecting a batch".to_owned(),
6420
+ ));
6417
6421
}
6418
6422
6419
6423
let updates = self
6420
6424
.context
6421
6425
.validate_commitment_signed(&self.funding, &self.holder_commitment_point, msg, logger)
6422
- .map(|LatestHolderCommitmentTXInfo { commitment_tx, htlc_outputs, nondust_htlc_sources }|
6423
- vec![ChannelMonitorUpdateStep::LatestHolderCommitmentTXInfo {
6424
- commitment_tx, htlc_outputs, claimed_htlcs: vec![], nondust_htlc_sources,
6425
- }]
6426
+ .map(
6427
+ |LatestHolderCommitmentTXInfo {
6428
+ commitment_tx,
6429
+ htlc_outputs,
6430
+ nondust_htlc_sources,
6431
+ }| {
6432
+ vec![ChannelMonitorUpdateStep::LatestHolderCommitmentTXInfo {
6433
+ commitment_tx,
6434
+ htlc_outputs,
6435
+ claimed_htlcs: vec![],
6436
+ nondust_htlc_sources,
6437
+ }]
6438
+ },
6426
6439
)?;
6427
6440
6428
6441
self.commitment_signed_update_monitor(updates, logger)
6429
6442
}
6430
6443
6431
- #[rustfmt::skip]
6432
- pub fn commitment_signed_batch<L: Deref>(&mut self, batch: Vec<msgs::CommitmentSigned>, logger: &L) -> Result<Option<ChannelMonitorUpdate>, ChannelError>
6433
- where L::Target: Logger
6444
+ pub fn commitment_signed_batch<L: Deref>(
6445
+ &mut self, batch: Vec<msgs::CommitmentSigned>, logger: &L,
6446
+ ) -> Result<Option<ChannelMonitorUpdate>, ChannelError>
6447
+ where
6448
+ L::Target: Logger,
6434
6449
{
6435
6450
self.commitment_signed_check_state()?;
6436
6451
@@ -6439,15 +6454,22 @@ where
6439
6454
let funding_txid = match msg.funding_txid {
6440
6455
Some(funding_txid) => funding_txid,
6441
6456
None => {
6442
- return Err(ChannelError::close("Peer sent batched commitment_signed without a funding_txid".to_string()));
6457
+ return Err(ChannelError::close(
6458
+ "Peer sent batched commitment_signed without a funding_txid".to_string(),
6459
+ ));
6443
6460
},
6444
6461
};
6445
6462
6446
6463
match messages.entry(funding_txid) {
6447
- btree_map::Entry::Vacant(entry) => { entry.insert(msg); },
6464
+ btree_map::Entry::Vacant(entry) => {
6465
+ entry.insert(msg);
6466
+ },
6448
6467
btree_map::Entry::Occupied(_) => {
6449
- return Err(ChannelError::close(format!("Peer sent batched commitment_signed with duplicate funding_txid {}", funding_txid)));
6450
- }
6468
+ return Err(ChannelError::close(format!(
6469
+ "Peer sent batched commitment_signed with duplicate funding_txid {}",
6470
+ funding_txid
6471
+ )));
6472
+ },
6451
6473
}
6452
6474
}
6453
6475
@@ -6457,36 +6479,56 @@ where
6457
6479
.chain(self.pending_funding.iter())
6458
6480
.map(|funding| {
6459
6481
let funding_txid = funding.get_funding_txo().unwrap().txid;
6460
- let msg = messages
6461
- .get(&funding_txid)
6462
- .ok_or_else(|| ChannelError::close(format!("Peer did not send a commitment_signed for pending splice transaction: {}", funding_txid)))?;
6482
+ let msg = messages.get(&funding_txid).ok_or_else(|| {
6483
+ ChannelError::close(format!(
6484
+ "Peer did not send a commitment_signed for pending splice transaction: {}",
6485
+ funding_txid
6486
+ ))
6487
+ })?;
6463
6488
self.context
6464
6489
.validate_commitment_signed(funding, &self.holder_commitment_point, msg, logger)
6465
- .map(|LatestHolderCommitmentTXInfo { commitment_tx, htlc_outputs, nondust_htlc_sources }|
6466
- ChannelMonitorUpdateStep::LatestHolderCommitmentTXInfo {
6467
- commitment_tx, htlc_outputs, claimed_htlcs: vec![], nondust_htlc_sources,
6468
- }
6490
+ .map(
6491
+ |LatestHolderCommitmentTXInfo {
6492
+ commitment_tx,
6493
+ htlc_outputs,
6494
+ nondust_htlc_sources,
6495
+ }| ChannelMonitorUpdateStep::LatestHolderCommitmentTXInfo {
6496
+ commitment_tx,
6497
+ htlc_outputs,
6498
+ claimed_htlcs: vec![],
6499
+ nondust_htlc_sources,
6500
+ },
6469
6501
)
6470
- }
6471
- )
6502
+ })
6472
6503
.collect::<Result<Vec<_>, ChannelError>>()?;
6473
6504
6474
6505
self.commitment_signed_update_monitor(updates, logger)
6475
6506
}
6476
6507
6477
- #[rustfmt::skip]
6478
6508
fn commitment_signed_check_state(&self) -> Result<(), ChannelError> {
6479
6509
if self.context.channel_state.is_quiescent() {
6480
- return Err(ChannelError::WarnAndDisconnect("Got commitment_signed message while quiescent".to_owned()));
6510
+ return Err(ChannelError::WarnAndDisconnect(
6511
+ "Got commitment_signed message while quiescent".to_owned(),
6512
+ ));
6481
6513
}
6482
6514
if !matches!(self.context.channel_state, ChannelState::ChannelReady(_)) {
6483
- return Err(ChannelError::close("Got commitment signed message when channel was not in an operational state".to_owned()));
6515
+ return Err(ChannelError::close(
6516
+ "Got commitment signed message when channel was not in an operational state"
6517
+ .to_owned(),
6518
+ ));
6484
6519
}
6485
6520
if self.context.channel_state.is_peer_disconnected() {
6486
- return Err(ChannelError::close("Peer sent commitment_signed when we needed a channel_reestablish".to_owned()));
6521
+ return Err(ChannelError::close(
6522
+ "Peer sent commitment_signed when we needed a channel_reestablish".to_owned(),
6523
+ ));
6487
6524
}
6488
- if self.context.channel_state.is_both_sides_shutdown() && self.context.last_sent_closing_fee.is_some() {
6489
- return Err(ChannelError::close("Peer sent commitment_signed after we'd started exchanging closing_signeds".to_owned()));
6525
+ if self.context.channel_state.is_both_sides_shutdown()
6526
+ && self.context.last_sent_closing_fee.is_some()
6527
+ {
6528
+ return Err(ChannelError::close(
6529
+ "Peer sent commitment_signed after we'd started exchanging closing_signeds"
6530
+ .to_owned(),
6531
+ ));
6490
6532
}
6491
6533
6492
6534
Ok(())
0 commit comments