mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-02-25 15:20:24 +01:00
Simplify ChannelMonitor Storage updates a bit
This commit is contained in:
parent
90d2ca37e7
commit
35bd8c31e8
1 changed files with 10 additions and 28 deletions
|
@ -613,24 +613,15 @@ impl ChannelMonitor {
|
||||||
/// provides slightly better privacy.
|
/// provides slightly better privacy.
|
||||||
/// It's the responsibility of the caller to register outpoint and script with passing the former
|
/// It's the responsibility of the caller to register outpoint and script with passing the former
|
||||||
/// value as key to add_update_monitor.
|
/// value as key to add_update_monitor.
|
||||||
pub(super) fn set_funding_info(&mut self, funding_info: (OutPoint, Script)) {
|
pub(super) fn set_funding_info(&mut self, new_funding_info: (OutPoint, Script)) {
|
||||||
self.key_storage = match self.key_storage {
|
match self.key_storage {
|
||||||
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, .. } => {
|
Storage::Local { ref mut funding_info, .. } => {
|
||||||
Storage::Local {
|
*funding_info = Some(new_funding_info);
|
||||||
revocation_base_key: *revocation_base_key,
|
|
||||||
htlc_base_key: *htlc_base_key,
|
|
||||||
delayed_payment_base_key: *delayed_payment_base_key,
|
|
||||||
payment_base_key: *payment_base_key,
|
|
||||||
shutdown_pubkey: *shutdown_pubkey,
|
|
||||||
prev_latest_per_commitment_point: *prev_latest_per_commitment_point,
|
|
||||||
latest_per_commitment_point: *latest_per_commitment_point,
|
|
||||||
funding_info: Some(funding_info.clone()),
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
Storage::Watchtower { .. } => {
|
Storage::Watchtower { .. } => {
|
||||||
unimplemented!();
|
panic!("Channel somehow ended up with its internal ChannelMonitor being in Watchtower mode?");
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// We log these base keys at channel opening to being able to rebuild redeemscript in case of leaked revoked commit tx
|
/// 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 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn unset_funding_info(&mut self) {
|
pub(super) fn unset_funding_info(&mut self) {
|
||||||
self.key_storage = match self.key_storage {
|
match self.key_storage {
|
||||||
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, .. } => {
|
Storage::Local { ref mut funding_info, .. } => {
|
||||||
Storage::Local {
|
*funding_info = None;
|
||||||
revocation_base_key: *revocation_base_key,
|
|
||||||
htlc_base_key: *htlc_base_key,
|
|
||||||
delayed_payment_base_key: *delayed_payment_base_key,
|
|
||||||
payment_base_key: *payment_base_key,
|
|
||||||
shutdown_pubkey: *shutdown_pubkey,
|
|
||||||
prev_latest_per_commitment_point: *prev_latest_per_commitment_point,
|
|
||||||
latest_per_commitment_point: *latest_per_commitment_point,
|
|
||||||
funding_info: None,
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
Storage::Watchtower { .. } => {
|
Storage::Watchtower { .. } => {
|
||||||
unimplemented!();
|
panic!("Channel somehow ended up with its internal ChannelMonitor being in Watchtower mode?");
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue