first block is 1 confirmation (#270)

This commit is contained in:
AntiochP 2017-11-15 08:46:32 -05:00 committed by GitHub
parent f4e7941213
commit 9f7e047aeb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -247,11 +247,13 @@ impl OutputData {
} else if self.status == OutputStatus::Spent && self.height == 0 {
0
} else {
current_height - self.height
// if an output has height n and we are at block n
// then we have a single confirmation (the block it originated in)
1 + (current_height - self.height)
}
}
/// Check if output is eligible for spending based on state and height.
/// Check if output is eligible to spend based on state and height and confirmations
pub fn eligible_to_spend(&self, current_height: u64, minimum_confirmations: u64) -> bool {
if [OutputStatus::Spent, OutputStatus::Locked].contains(&self.status) {
return false;
@ -260,7 +262,7 @@ impl OutputData {
} else if self.lock_height > current_height {
return false;
} else if self.status == OutputStatus::Unspent
&& self.height + minimum_confirmations <= current_height
&& self.num_confirmations(current_height) >= minimum_confirmations
{
return true;
} else if self.status == OutputStatus::Unconfirmed && minimum_confirmations == 0 {