Skip to content

Commit

Permalink
invoices-columns: add msats_received column
Browse files Browse the repository at this point in the history
  • Loading branch information
daywalker90 committed Jun 29, 2024
1 parent fc69afb commit 641a393
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Changelog

## [3.3.1] 2024-06-28
## [3.3.1] 2024-06-29

### Added

- ``summars-exclude-states``: added `ONLINE,OFFLINE` states to filter by connection status
- ``summars-forwards-columns``: added ``fee_sats``, ``in_msats``, ``out_msats`` as non-default columns
- ``summars-pays-columns``: added ``fee_sats`` as a new default column and ``msats_requested``, ``msats_sent`` as non-default columns
- ``summars-invoices-columns``: added ``msats_received`` as non-default column

### Changed

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ You can mix these methods and if you set the same option with different methods,
* ``summars-pays-columns`` Comma-separated list of enabled columns in the pays table. Also dictates order of columns. Valid columns: ``completed_at``, ``payment_hash``, ``sats_requested``, ``msats_requested``, ``sats_sent``, ``msats_sent``, ``fee_sats``, ``fee_msats``, ``destination``, ``description``, ``preimage``. Default columns are: ``completed_at``, ``payment_hash``, ``sats_sent``, ``fee_sats``, ``destination``:warning: If you enable the ``description`` field in most cases an extra RPC call is necessary for each displayed payment. This could slow down the response time of ``summars`` if you have alot of payments in your configured time window.
### Invoices table
* ``summars-invoices`` List successfully paid invoices of the last x hours. Default is ``0`` hours (disabled)
* ``summars-invoices-columns`` Comma-separated list of enabled columns in the invoices table. Also dictates order of columns. Valid columns: ``paid_at``, ``label``, ``description``, ``sats_received``, ``payment_hash``, ``preimage``. Default columns are: ``paid_at``, ``label``, ``sats_received``, ``payment_hash``
* ``summars-invoices-columns`` Comma-separated list of enabled columns in the invoices table. Also dictates order of columns. Valid columns: ``paid_at``, ``label``, ``description``, ``sats_received``, ``msats_received``, ``payment_hash``, ``preimage``. Default columns are: ``paid_at``, ``label``, ``sats_received``, ``payment_hash``
* ``summars-invoices-filter-amount-msat`` Filter invoices where **received** amount is smaller than or equal to x msat and show a summary of those invoices instead. Default is ``-1`` (disabled)
### Background tasks
* ``summars-refresh-alias`` How many hours between refreshing the node aliases in memory. Default is ``24`` hours
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ async fn main() -> Result<(), anyhow::Error> {
let opt_invoices_columns: StringConfigOption = ConfigOption::new_str_no_default(
OPT_INVOICES_COLUMNS,
"Enabled columns in the invoices table. Available columns are: \
`paid_at, label, description, sats_received, payment_hash, preimage` \
`paid_at, label, description, sats_received, msats_received, payment_hash, preimage` \
Default is `paid_at, label, sats_received, payment_hash`",
)
.dynamic();
Expand Down
6 changes: 3 additions & 3 deletions src/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ impl Config {
value: {
Invoices::FIELD_NAMES_AS_ARRAY
.into_iter()
.filter(|t| t != &"description" && t != &"preimage")
.filter(|t| {
t != &"description" && t != &"preimage" && t != &"msats_received"
})
.map(|s| s.to_string())
.collect::<Vec<String>>()
},
Expand Down Expand Up @@ -388,8 +390,6 @@ pub struct Invoices {
pub label: String,
#[serde(skip_serializing_if = "String::is_empty")]
pub description: String,
#[tabled(skip)]
#[field_names_as_array(skip)]
pub msats_received: u64,
#[serde(skip_serializing)]
pub sats_received: u64,
Expand Down
6 changes: 6 additions & 0 deletions src/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,12 @@ fn format_invoices(
|s| u64_to_sat_string(config, s.parse::<u64>().unwrap()).unwrap(),
)),
);
invoicestable.with(Modify::new(ByColumnName::new("msats_received")).with(Alignment::right()));
invoicestable.with(
Modify::new(ByColumnName::new("msats_received").not(Rows::first())).with(Format::content(
|s| u64_to_sat_string(config, s.parse::<u64>().unwrap()).unwrap(),
)),
);

invoicestable.with(Panel::header("invoices"));
invoicestable.with(Modify::new(Rows::first()).with(Alignment::center()));
Expand Down

0 comments on commit 641a393

Please sign in to comment.