Skip to content

Commit

Permalink
Validate state in request_unbond
Browse files Browse the repository at this point in the history
  • Loading branch information
mappum committed Sep 29, 2024
1 parent d09096e commit 7e7fcdb
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/babylon/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ impl Delegation {
stake_amount / 1_000_000 // TODO: get covnersion from bitcoin config
}

#[allow(clippy::too_many_arguments)]
pub fn relay_staking_tx(
&mut self,
headers: &HeaderQueue,
Expand Down Expand Up @@ -717,6 +718,17 @@ impl Delegation {
btc: &Bitcoin,
params: &Params,
) -> Result<()> {
if self.requested_unbond {
return Err(Error::Orga(orga::Error::App(
"Delegation already requested unbond".to_string(),
)));
}
if self.status() == DelegationStatus::Withdrawn {
return Err(Error::Orga(orga::Error::App(
"Delegation already withdrawn".to_string(),
)));
}

self.requested_unbond = true;

match self.status() {
Expand Down Expand Up @@ -802,6 +814,7 @@ impl Delegation {
Ok(())
}

#[allow(clippy::too_many_arguments)]
pub fn relay_unbonding_tx(
&mut self,
headers: &HeaderQueue,
Expand Down

0 comments on commit 7e7fcdb

Please sign in to comment.