From b05b0f14e5e08ab32e78ea263531d8a587c5b184 Mon Sep 17 00:00:00 2001 From: jp1ac4 <121959000+jp1ac4@users.noreply.github.com> Date: Thu, 18 Jan 2024 16:00:35 +0000 Subject: [PATCH] commands: add ancestor info for user-selected unconfirmed coins --- src/commands/mod.rs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 06ccae39..83a1f87e 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -487,11 +487,21 @@ 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) + } else { + None + }; coin_to_candidate( - &c, /*must_select=*/ true, /*sequence=*/ None, - /*ancestor_info=*/ None, + &c, + /*must_select=*/ true, + /*sequence=*/ None, + ancestor_info, ) }) .collect() @@ -805,6 +815,10 @@ impl DaemonControl { let mut candidate_coins: Vec = prev_coins .values() .map(|c| { + // In case any previous coins are unconfirmed, we don't include their ancestor info + // in the candidate as the replacement fee and feerate will be higher and any + // additional fee to pay for ancestors should already have been taken into account + // when including these coins in the previous transaction. coin_to_candidate( c, /*must_select=*/ !is_cancel, /*sequence=*/ None, /*ancestor_info=*/ None,