Skip to content

Commit

Permalink
gui: disable replacement fee input if tx is already replaced
Browse files Browse the repository at this point in the history
  • Loading branch information
pythcoiner committed Jul 23, 2024
1 parent e81a2d3 commit 2a30290
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
18 changes: 11 additions & 7 deletions gui/src/app/view/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,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),
)
Expand Down
13 changes: 13 additions & 0 deletions gui/ui/src/component/form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ where
}
}

/// Creates a new [`Form`] that have 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:
Expand Down

0 comments on commit 2a30290

Please sign in to comment.