gui: disable replacement fee input if tx is already replaced

This commit is contained in:
pythcoiner 2024-07-19 06:18:25 +02:00
parent 4de0d7bd29
commit ad2c096715
No known key found for this signature in database
GPG Key ID: C1048AEEDF303B88
2 changed files with 24 additions and 7 deletions

View File

@ -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),
)

View File

@ -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<String>) -> 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: