From ad2c096715da49223f7c2cf3389e575b7e62a064 Mon Sep 17 00:00:00 2001 From: pythcoiner Date: Fri, 19 Jul 2024 06:18:25 +0200 Subject: [PATCH] gui: disable replacement fee input if tx is already replaced --- liana-gui/src/app/view/transactions.rs | 18 +++++++++++------- liana-ui/src/component/form.rs | 13 +++++++++++++ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/liana-gui/src/app/view/transactions.rs b/liana-gui/src/app/view/transactions.rs index fe57bd8d..fc373c2e 100644 --- a/liana-gui/src/app/view/transactions.rs +++ b/liana-gui/src/app/view/transactions.rs @@ -257,13 +257,17 @@ pub fn create_rbf_modal<'a>( .push(Container::new(p1_bold("Feerate")).padding(10)) .spacing(10) .push( - form::Form::new_trimmed("", feerate, move |msg| { - Message::CreateRbf(CreateRbfMessage::FeerateEdited(msg)) - }) - .warning( - "Feerate must be greater than previous value and \ - less than or equal to 1000 sats/vbyte", - ) + if replacement_txid.is_none() { + form::Form::new_trimmed("", feerate, move |msg| { + Message::CreateRbf(CreateRbfMessage::FeerateEdited(msg)) + }) + .warning( + "Feerate must be greater than previous value and \ + less than or equal to 1000 sats/vbyte", + ) + } else { + form::Form::new_disabled("", feerate) + } .size(P1_SIZE) .padding(10), ) diff --git a/liana-ui/src/component/form.rs b/liana-ui/src/component/form.rs index ad062161..7f8d1516 100644 --- a/liana-ui/src/component/form.rs +++ b/liana-ui/src/component/form.rs @@ -46,6 +46,19 @@ where } } + /// Creates a new [`Form`] that has a disabled input. + /// + /// It expects: + /// - a placeholder + /// - the current value + pub fn new_disabled(placeholder: &str, value: &Value) -> Self { + Self { + input: text_input::TextInput::new(placeholder, &value.value), + warning: None, + valid: value.valid, + } + } + /// Creates a new [`Form`] that trims input values before applying the `on_change` function. /// /// It expects: