Skip to content

Commit

Permalink
gui(transactions): get prev feerate from tx instead of param
Browse files Browse the repository at this point in the history
  • Loading branch information
jp1ac4 committed Feb 1, 2024
1 parent dc817de commit fde28bf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion gui/src/app/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ pub enum Message {
PendingTransactions(Result<Vec<HistoryTransaction>, Error>),
LabelsUpdated(Result<HashMap<String, Option<String>>, Error>),
BroadcastModal(Result<HashSet<Txid>, Error>),
RbfModal(HistoryTransaction, bool, u64, Result<HashSet<Txid>, Error>),
RbfModal(HistoryTransaction, bool, Result<HashSet<Txid>, Error>),
}
20 changes: 10 additions & 10 deletions gui/src/app/state/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,9 @@ impl State for TransactionsPanel {
}
}
},
Message::RbfModal(tx, is_cancel, prev_feerate_vb, res) => match res {
Message::RbfModal(tx, is_cancel, res) => match res {
Ok(descendant_txids) => {
let modal =
CreateRbfModal::new(tx, is_cancel, prev_feerate_vb, descendant_txids);
let modal = CreateRbfModal::new(tx, is_cancel, descendant_txids);
self.create_rbf_modal = Some(modal);
}
Err(e) => {
Expand All @@ -134,11 +133,7 @@ impl State for TransactionsPanel {
Message::View(view::Message::CreateRbf(view::CreateRbfMessage::New(is_cancel))) => {
if let Some(idx) = self.selected_tx {
if let Some(tx) = self.pending_txs.get(idx) {
if let Some(fee_amount) = tx.fee_amount {
let prev_feerate_vb = fee_amount
.to_sat()
.checked_div(tx.tx.vsize().try_into().unwrap())
.unwrap();
if tx.fee_amount.is_some() {
let tx = tx.clone();
let txid = tx.tx.txid();
return Command::perform(
Expand All @@ -161,7 +156,7 @@ impl State for TransactionsPanel {
})
.map_err(|e| e.into())
},
move |res| Message::RbfModal(tx, is_cancel, prev_feerate_vb, res),
move |res| Message::RbfModal(tx, is_cancel, res),
);
}
}
Expand Down Expand Up @@ -297,9 +292,14 @@ impl CreateRbfModal {
fn new(
tx: model::HistoryTransaction,
is_cancel: bool,
prev_feerate_vb: u64,
descendant_txids: HashSet<Txid>,
) -> Self {
let prev_feerate_vb = tx
.fee_amount
.expect("rbf should only be used on a transaction with fee amount set")
.to_sat()
.checked_div(tx.tx.vsize().try_into().expect("vsize must fit in u64"))
.expect("transaction vsize must be positive");
let min_feerate_vb = prev_feerate_vb.checked_add(1).unwrap();
Self {
tx,
Expand Down

0 comments on commit fde28bf

Please sign in to comment.