diff --git a/gui/src/app/state/recovery.rs b/gui/src/app/state/recovery.rs index f056eacab..18623837c 100644 --- a/gui/src/app/state/recovery.rs +++ b/gui/src/app/state/recovery.rs @@ -162,14 +162,7 @@ impl State for RecoveryPanel { .any(|input| input.previous_output == coin.outpoint) }) .collect(); - Ok(SpendTx::new( - None, - psbt, - coins, - &desc, - desc.max_sat_vbytes(), - network, - )) + Ok(SpendTx::new(None, psbt, coins, &desc, network)) }, Message::Recovery, ); diff --git a/gui/src/app/state/spend/step.rs b/gui/src/app/state/spend/step.rs index 75577ebe4..0fecbb0dd 100644 --- a/gui/src/app/state/spend/step.rs +++ b/gui/src/app/state/spend/step.rs @@ -516,7 +516,6 @@ impl Step for SaveSpend { psbt, draft.inputs.clone(), &self.wallet.main_descriptor, - self.wallet.main_descriptor.max_sat_vbytes(), draft.network, ); tx.labels = draft.labels.clone(); diff --git a/gui/src/daemon/mod.rs b/gui/src/daemon/mod.rs index dd5619933..12e46f3a0 100644 --- a/gui/src/daemon/mod.rs +++ b/gui/src/daemon/mod.rs @@ -106,7 +106,6 @@ pub trait Daemon: Debug { tx.psbt, coins, &info.descriptors.main, - info.descriptors.main.max_sat_vbytes(), info.network, )); } diff --git a/gui/src/daemon/model.rs b/gui/src/daemon/model.rs index 7c63cdc20..7d7ff0260 100644 --- a/gui/src/daemon/model.rs +++ b/gui/src/daemon/model.rs @@ -58,12 +58,12 @@ pub enum SpendStatus { impl SpendTx { pub fn new( updated_at: Option, - mut psbt: Psbt, + psbt: Psbt, coins: Vec, desc: &LianaDescriptor, - max_sat_vbytes: usize, network: Network, ) -> Self { + let max_sat_vbytes = desc.max_sat_vbytes(); let mut change_indexes = Vec::new(); let (change_amount, spend_amount) = psbt.unsigned_tx.output.iter().enumerate().fold( (Amount::from_sat(0), Amount::from_sat(0)), @@ -97,8 +97,6 @@ impl SpendTx { .partial_spend_info(&psbt) .expect("PSBT must be generated by Liana"); - remove_useless_bip32_derivation(&coins, &desc.policy(), &sigs, &mut psbt); - Self { labels: HashMap::new(), kind: if spend_amount == Amount::from_sat(0) { @@ -219,59 +217,6 @@ impl Labelled for SpendTx { } } -/// we remove all bip32_derivation that are not possible to use for the current primary path -/// or the enabled recovery paths. -/// Todo: maybe fix it upstream in lianad -fn remove_useless_bip32_derivation( - coins: &[Coin], - policy: &LianaPolicy, - spend_info: &PartialSpendInfo, - psbt: &mut Psbt, -) { - let enabled_recovery_paths = spend_info.recovery_paths(); - let mut origins: Vec>> = policy - .recovery_paths() - .iter() - .filter_map(|(timelock, path)| { - if enabled_recovery_paths.get(timelock).is_some() { - Some(path.thresh_origins().1) - } else { - None - } - }) - .collect(); - origins.push(policy.primary_path().thresh_origins().1); - for (i, input) in psbt.inputs.iter_mut().enumerate() { - // remove bip32_derivation only for our coins. - if psbt - .unsigned_tx - .input - .get(i) - .map(|input| { - coins - .iter() - .any(|coin| coin.outpoint == input.previous_output) - }) - .unwrap_or(false) - { - input.bip32_derivation.retain(|_, (fg, path)| { - for origin in &origins { - if let Some(parents) = origin.get(fg) { - let path = path.to_string(); - if parents - .iter() - .any(|parent| path.contains(&parent.to_string())) - { - return true; - } - } - } - false - }) - } - } -} - #[derive(Debug, Clone)] pub struct HistoryTransaction { pub network: Network,