Skip to content

Commit

Permalink
Update the report type
Browse files Browse the repository at this point in the history
  • Loading branch information
djordon committed Nov 14, 2024
1 parent 68821ff commit 14ba341
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions signer/src/bitcoin/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ pub struct DepositRequestReport {
/// Whether this signer accepted the deposit request or not. This
/// should only be `None` if we do not have a record of the deposit
/// request or if we cannot sign for the deposited funds.
pub is_accepted: Option<bool>,
pub can_accept: Option<bool>,
/// The deposit amount
pub amount: u64,
/// The max fee embedded in the deposit request.
Expand Down Expand Up @@ -305,24 +305,6 @@ impl DepositRequestReport {
DepositRequestStatus::Confirmed(block_height, _) => block_height,
};

match self.can_sign {
// If we are here, we know that we have a record for the
// deposit request, but we have not voted on it yet, so we do
// not know if we can sign for it.
None => return Err(BitcoinDepositInputError::NoVote(self.outpoint)),
// In this case we know that we cannot sign for the deposit
// because it is locked with a public key where the current
// signer is not part of the signing set.
Some(false) => return Err(BitcoinDepositInputError::CannotSignUtxo(self.outpoint)),
// Yay.
Some(true) => (),
}
// If we are here then can_sign is Some(true) so is_accepted is
// Some(_). Let's check whether we rejected this deposit.
if self.is_accepted != Some(true) {
return Err(BitcoinDepositInputError::RejectedRequest(self.outpoint));
}

// We only sweep a deposit if the depositor cannot reclaim the
// deposit within the next DEPOSIT_LOCKTIME_BLOCK_BUFFER blocks.
let deposit_age = chain_tip_height.saturating_sub(confirmed_block_height);
Expand All @@ -339,6 +321,24 @@ impl DepositRequestReport {
}
}

match self.can_sign {
// If we are here, we know that we have a record for the
// deposit request, but we have not voted on it yet, so we do
// not know if we can sign for it.
None => return Err(BitcoinDepositInputError::NoVote(self.outpoint)),
// In this case we know that we cannot sign for the deposit
// because it is locked with a public key where the current
// signer is not part of the signing set.
Some(false) => return Err(BitcoinDepositInputError::CannotSignUtxo(self.outpoint)),
// Yay.
Some(true) => (),
}
// If we are here then can_sign is Some(true) so can_accept is
// Some(_). Let's check whether we rejected this deposit.
if self.can_accept != Some(true) {
return Err(BitcoinDepositInputError::RejectedRequest(self.outpoint));
}

Ok(())
}

Expand Down

0 comments on commit 14ba341

Please sign in to comment.