Merge #228: fix recovery state coins filtering

192072ea257ae50e6c90bda00677b5f07ca9ada9 fix recovery state coins filtering (edouard)

Pull request description:

  Recoverable coins are coins that recovery
  path is available *next* block

ACKs for top commit:
  darosior:
    Not familiar with this code, but it appears it now check whether the timelock will be mature in one block or less. If that is the case then it is consistent with the behaviour of the daemon. utACK 192072ea257ae50e6c90bda00677b5f07ca9ada9.
  edouardparis:
    ACK 192072ea257ae50e6c90bda00677b5f07ca9ada9

Tree-SHA512: 0bf5f39fcf393a16667f498d851a3cd7dd6b0831696db05c27363b6f9d5006225afc919d6a6c4d3992cd3d3ce702bc5a7e0a7e57d9f21234649237ee172f1f2d
This commit is contained in:
edouard 2022-12-15 15:18:01 +01:00
commit 5117b8dc44
No known key found for this signature in database
GPG Key ID: E65F7A089C20DC8F
2 changed files with 17 additions and 5 deletions

View File

@ -44,7 +44,8 @@ impl RecoveryPanel {
let mut recoverable_coins = (0, Amount::from_sat(0));
for coin in coins {
if coin.spend_info.is_none() {
if remaining_sequence(coin, blockheight, timelock) != 0 {
// recoverable coins are coins that can be recoverable next block.
if remaining_sequence(coin, blockheight, timelock) > 1 {
locked_coins.0 += 1;
locked_coins.1 += coin.amount;
} else {
@ -103,8 +104,9 @@ impl State for RecoveryPanel {
self.recoverable_coins = (0, Amount::from_sat(0));
for coin in coins {
if coin.spend_info.is_none() {
// recoverable coins are coins that can be recoverable next block.
if remaining_sequence(&coin, cache.blockheight as u32, self.timelock)
!= 0
> 1
{
self.locked_coins.0 += 1;
self.locked_coins.1 += coin.amount;

View File

@ -82,7 +82,12 @@ pub fn recovery<'a>(
.on_press(Message::Clipboard(psbt.unsigned_tx.txid().to_string()))
.style(button::Style::Border.into()))
)
.push(Row::new().push(text(format!("Fees: {}", recoverable_coins.1 - Amount::from_sat(psbt.unsigned_tx.output[0].value))).small()))
.push_maybe(if recoverable_coins.1.to_sat() > psbt.unsigned_tx.output[0].value {
Some(Row::new()
.push(text(format!("Fees: {}", recoverable_coins.1 - Amount::from_sat(psbt.unsigned_tx.output[0].value))).small()))
} else {
None
})
))
} else {
Column::new()
@ -115,7 +120,12 @@ pub fn recovery<'a>(
.on_press(Message::Clipboard(psbt.unsigned_tx.txid().to_string()))
.style(button::Style::Border.into()))
)
.push(Row::new().push(text(format!("Fees: {}", recoverable_coins.1 - Amount::from_sat(psbt.unsigned_tx.output[0].value))).small()))
.push_maybe(if recoverable_coins.1.to_sat() > psbt.unsigned_tx.output[0].value {
Some(Row::new()
.push(text(format!("Fees: {}", recoverable_coins.1 - Amount::from_sat(psbt.unsigned_tx.output[0].value))).small()))
} else {
None
})
)
)
.push(if !hws.is_empty() {
@ -186,7 +196,7 @@ pub fn recovery<'a>(
)
.width(Length::Units(250)),
)
.push(if feerate.valid && !feerate.value.is_empty() && address.valid && !address.value.is_empty() {
.push(if feerate.valid && !feerate.value.is_empty() && address.valid && !address.value.is_empty() && recoverable_coins.0 != 0 {
button::primary(None, "Next").on_press(Message::Next).width(Length::Units(200))
} else {
button::primary(None, "Next")