diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 51f0fc062..2c71f9e43 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -506,11 +506,23 @@ impl DaemonControl { } } coins - .into_values() - .map(|c| { + .into_iter() + .map(|(op, c)| { + let ancestor_info = if c.block_info.is_none() { + // We include any non-change coins here as they have been selected by the caller. + // If the unconfirmed coin's transaction is no longer in the mempool, keep the + // coin as a candidate but without any ancestor info (same as confirmed candidate). + self.bitcoin + .mempool_entry(&op.txid) + .map(AncestorInfo::from_mempool_entry) + } else { + None + }; coin_to_candidate( - &c, /*must_select=*/ true, /*sequence=*/ None, - /*ancestor_info=*/ None, + &c, + /*must_select=*/ true, + /*sequence=*/ None, + ancestor_info, ) }) .collect()