Skip to content

Commit

Permalink
feat: display weight, #inputs, #outputs in wallet for txn (#3393)
Browse files Browse the repository at this point in the history
Description
---
Wallet displays details contributing to the chosen fee

Motivation and Context
---
![image](https://user-images.githubusercontent.com/1057902/135245173-81b6048c-b719-4cbd-b97d-4800b6dbae9f.png)
Extra space not in screenshot added

How Has This Been Tested?
---
Manually
  • Loading branch information
sdbondi committed Sep 30, 2021
1 parent ff782bc commit 6d57cbd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,23 @@ impl TransactionsTab {
};
let direction = Span::styled(format!("{}", tx.direction), Style::default().fg(Color::White));
let amount = Span::styled(format!("{}", tx.amount), Style::default().fg(Color::White));
let fee = Span::styled(format!("{}", tx.fee), Style::default().fg(Color::White));
let fee_details = if tx.is_coinbase() {
Span::raw("")
} else {
Span::styled(
format!(
" (weight: {}g, #inputs: {}, #outputs: {})",
tx.transaction.calculate_weight(),
tx.transaction.body.inputs().len(),
tx.transaction.body.outputs().len()
),
Style::default().fg(Color::Gray),
)
};
let fee = Spans::from(vec![
Span::styled(format!("{}", tx.fee), Style::default().fg(Color::White)),
fee_details,
]);
let status_msg = if tx.cancelled {
"Cancelled".to_string()
} else if !tx.valid {
Expand All @@ -341,11 +357,11 @@ impl TransactionsTab {
format!("{}", local_time.format("%Y-%m-%d %H:%M:%S")),
Style::default().fg(Color::White),
);
let excess_hex = if tx.transaction.body.kernels().is_empty() {
"".to_string()
} else {
tx.transaction.body.kernels()[0].excess_sig.get_signature().to_hex()
};
let excess_hex = tx
.transaction
.first_kernel_excess_sig()
.map(|s| s.get_signature().to_hex())
.unwrap_or_default();
let excess = Span::styled(excess_hex.as_str(), Style::default().fg(Color::White));
let confirmation_count = app_state.get_confirmations(&tx.tx_id);
let confirmations_msg = if tx.status == TransactionStatus::MinedConfirmed && !tx.cancelled {
Expand Down
4 changes: 4 additions & 0 deletions base_layer/wallet/src/transaction_service/storage/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@ impl CompletedTransaction {
mined_height: None,
}
}

pub fn is_coinbase(&self) -> bool {
self.status == TransactionStatus::Coinbase
}
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
Expand Down

0 comments on commit 6d57cbd

Please sign in to comment.