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