Merge #1643: filter for confirmed coins when checking recovery paths

2279b332d4c1fd06c761e841ec15adfc2b5787dc filter for confirmed coins when checking recovery paths (Michael Mallan)

Pull request description:

  This is to fix #1636 and consequently fixes #1102. This PR therefore replaces #1144.

  A wallet containing an unconfirmed coin of timelock 1 will no longer show any recovery paths as available.

  The recovery transaction created by `createrecovery` only includes confirmed coins and so we should only consider these coins when checking for available recovery paths. An unconfirmed coin could not be broadcast in a recovery transaction as it would not yet satisfy the timelock constraint.

ACKs for top commit:
  edouardparis:
    utACK 2279b332d4c1fd06c761e841ec15adfc2b5787dc

Tree-SHA512: e1c1891e8d89a02b4eaacf64758c404b73384fe1c5183a6a21c2ad440ca8898cf68148981bc51d142875ac4458f943459227f0bdc7e04aa9cf2f35c22d33fb81
This commit is contained in:
edouardparis 2025-04-14 14:57:09 +02:00
commit ff693788b2
No known key found for this signature in database
GPG Key ID: E65F7A089C20DC8F

View File

@ -244,7 +244,8 @@ fn recovery_paths(wallet: &Wallet, coins: &[Coin], blockheight: i32) -> Vec<Reco
let (number_of_coins, total_amount) = coins
.iter()
.filter(|coin| {
coin.spend_info.is_none()
coin.block_height.is_some() // only confirmed coins are included in a recovery transaction
&& coin.spend_info.is_none()
&& remaining_sequence(coin, blockheight as u32, sequence) <= 1
})
.fold(