parent
f2843cc064
commit
25fffb2c52
@ -133,8 +133,9 @@ impl State for Home {
|
|||||||
let timelock = self.wallet.main_descriptor.first_timelock_value();
|
let timelock = self.wallet.main_descriptor.first_timelock_value();
|
||||||
let seq =
|
let seq =
|
||||||
remaining_sequence(&coin, cache.blockheight as u32, timelock);
|
remaining_sequence(&coin, cache.blockheight as u32, timelock);
|
||||||
// number of block in a day
|
// Warn user for coins that are expiring in less than 10 percent of
|
||||||
if seq <= 144 {
|
// the timelock.
|
||||||
|
if seq <= timelock as u32 * 10 / 100 {
|
||||||
self.expiring_coins.push(coin.outpoint);
|
self.expiring_coins.push(coin.outpoint);
|
||||||
}
|
}
|
||||||
if let Some(last) = &mut self.remaining_sequence {
|
if let Some(last) = &mut self.remaining_sequence {
|
||||||
|
|||||||
@ -230,14 +230,31 @@ pub fn expire_message_units(sequence: u32) -> Vec<String> {
|
|||||||
n_minutes -= n_months * 43830;
|
n_minutes -= n_months * 43830;
|
||||||
let n_days = n_minutes / 1440;
|
let n_days = n_minutes / 1440;
|
||||||
|
|
||||||
[(n_years, "year"), (n_months, "month"), (n_days, "day")]
|
#[allow(clippy::nonminimal_bool)]
|
||||||
.iter()
|
if n_days != 0 || n_months != 0 || n_days != 0 {
|
||||||
.filter_map(|(n, u)| {
|
[(n_years, "year"), (n_months, "month"), (n_days, "day")]
|
||||||
if *n != 0 {
|
.iter()
|
||||||
Some(format!("{} {}{}", n, u, if *n > 1 { "s" } else { "" }))
|
.filter_map(|(n, u)| {
|
||||||
} else {
|
if *n != 0 {
|
||||||
None
|
Some(format!("{} {}{}", n, u, if *n > 1 { "s" } else { "" }))
|
||||||
}
|
} else {
|
||||||
})
|
None
|
||||||
.collect()
|
}
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
|
} else {
|
||||||
|
n_minutes -= n_days * 1440;
|
||||||
|
let n_hours = n_minutes / 60;
|
||||||
|
n_minutes -= n_hours * 60;
|
||||||
|
[(n_hours, "hour"), (n_minutes, "minute")]
|
||||||
|
.iter()
|
||||||
|
.filter_map(|(n, u)| {
|
||||||
|
if *n != 0 {
|
||||||
|
Some(format!("{} {}{}", n, u, if *n > 1 { "s" } else { "" }))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user