Skip to content

Commit 35bd8c3

Browse files
committed
Simplify ChannelMonitor Storage updates a bit
1 parent 90d2ca3 commit 35bd8c3

File tree

1 file changed

+10
-28
lines changed

1 file changed

+10
-28
lines changed

src/ln/channelmonitor.rs

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -613,24 +613,15 @@ impl ChannelMonitor {
613613
/// provides slightly better privacy.
614614
/// It's the responsibility of the caller to register outpoint and script with passing the former
615615
/// value as key to add_update_monitor.
616-
pub(super) fn set_funding_info(&mut self, funding_info: (OutPoint, Script)) {
617-
self.key_storage = match self.key_storage {
618-
Storage::Local { ref revocation_base_key, ref htlc_base_key, ref delayed_payment_base_key, ref payment_base_key, ref shutdown_pubkey, ref prev_latest_per_commitment_point, ref latest_per_commitment_point, .. } => {
619-
Storage::Local {
620-
revocation_base_key: *revocation_base_key,
621-
htlc_base_key: *htlc_base_key,
622-
delayed_payment_base_key: *delayed_payment_base_key,
623-
payment_base_key: *payment_base_key,
624-
shutdown_pubkey: *shutdown_pubkey,
625-
prev_latest_per_commitment_point: *prev_latest_per_commitment_point,
626-
latest_per_commitment_point: *latest_per_commitment_point,
627-
funding_info: Some(funding_info.clone()),
628-
}
616+
pub(super) fn set_funding_info(&mut self, new_funding_info: (OutPoint, Script)) {
617+
match self.key_storage {
618+
Storage::Local { ref mut funding_info, .. } => {
619+
*funding_info = Some(new_funding_info);
629620
},
630621
Storage::Watchtower { .. } => {
631-
unimplemented!();
622+
panic!("Channel somehow ended up with its internal ChannelMonitor being in Watchtower mode?");
632623
}
633-
};
624+
}
634625
}
635626

636627
/// We log these base keys at channel opening to being able to rebuild redeemscript in case of leaked revoked commit tx
@@ -644,21 +635,12 @@ impl ChannelMonitor {
644635
}
645636

646637
pub(super) fn unset_funding_info(&mut self) {
647-
self.key_storage = match self.key_storage {
648-
Storage::Local { ref revocation_base_key, ref htlc_base_key, ref delayed_payment_base_key, ref payment_base_key, ref shutdown_pubkey, ref prev_latest_per_commitment_point, ref latest_per_commitment_point, .. } => {
649-
Storage::Local {
650-
revocation_base_key: *revocation_base_key,
651-
htlc_base_key: *htlc_base_key,
652-
delayed_payment_base_key: *delayed_payment_base_key,
653-
payment_base_key: *payment_base_key,
654-
shutdown_pubkey: *shutdown_pubkey,
655-
prev_latest_per_commitment_point: *prev_latest_per_commitment_point,
656-
latest_per_commitment_point: *latest_per_commitment_point,
657-
funding_info: None,
658-
}
638+
match self.key_storage {
639+
Storage::Local { ref mut funding_info, .. } => {
640+
*funding_info = None;
659641
},
660642
Storage::Watchtower { .. } => {
661-
unimplemented!();
643+
panic!("Channel somehow ended up with its internal ChannelMonitor being in Watchtower mode?");
662644
},
663645
}
664646
}

0 commit comments

Comments
 (0)