From 34849b28b0a9e5e84c9193ecda744e466d243995 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Mon, 1 May 2023 15:15:23 +0200 Subject: [PATCH 1/4] WIP show fees of Lightning transactions --- app/controllers/wallet_controller.rb | 1 + app/views/wallet/transactions.html.erb | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/wallet_controller.rb b/app/controllers/wallet_controller.rb index a7920d4..07de29b 100644 --- a/app/controllers/wallet_controller.rb +++ b/app/controllers/wallet_controller.rb @@ -78,6 +78,7 @@ class WalletController < ApplicationController tx["received"] = true else tx["amount_sats"] = tx["value"] || tx["amt"] + tx["fee"] = tx["type"] == "paid_invoice" ? tx["fee"] : nil tx["datetime"] = Time.at(tx["timestamp"].to_i) tx["title"] = tx["type"] == "paid_invoice" ? "Sent" : "Received" tx["description"] = tx["memo"] || tx["description"] diff --git a/app/views/wallet/transactions.html.erb b/app/views/wallet/transactions.html.erb index 44859e3..5ebc2cc 100644 --- a/app/views/wallet/transactions.html.erb +++ b/app/views/wallet/transactions.html.erb @@ -35,7 +35,8 @@

- <%= tx["datetime"].strftime("%B %e, %H:%M") %> + <%= tx["datetime"].strftime("%B %e, %H:%M") -%> + <% if tx["fee"] && (tx["fee"] > 0) %>, Fee: <%= tx["fee"] %> sats<% end %>

From 67a9fc02d77b2c0b668b21973565bbc7eb6d3907 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Mon, 1 May 2023 16:13:41 +0200 Subject: [PATCH 2/4] Rename Wallet to Lightning Network, move to Services --- app/controllers/dashboard_controller.rb | 2 +- .../lightning_controller.rb} | 4 ++-- app/views/dashboard/index.html.erb | 4 ++-- .../lightning_sats_received.text.erb | 2 +- .../{wallet => services/lightning}/index.html.erb | 4 ++-- .../lightning}/transactions.html.erb | 4 ++-- app/views/shared/_main_nav.html.erb | 8 +++----- app/views/shared/_tabnav_lightning.html.erb | 14 ++++++++++++++ app/views/shared/_tabnav_wallet.html.erb | 14 -------------- config/routes.rb | 8 ++++++++ 10 files changed, 35 insertions(+), 29 deletions(-) rename app/controllers/{wallet_controller.rb => services/lightning_controller.rb} (96%) rename app/views/{wallet => services/lightning}/index.html.erb (97%) rename app/views/{wallet => services/lightning}/transactions.html.erb (95%) create mode 100644 app/views/shared/_tabnav_lightning.html.erb delete mode 100644 app/views/shared/_tabnav_wallet.html.erb diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index 49c0764..3f9c14e 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -2,6 +2,6 @@ class DashboardController < ApplicationController before_action :require_user_signed_in def index - @current_section = :dashboard + @current_section = :services end end diff --git a/app/controllers/wallet_controller.rb b/app/controllers/services/lightning_controller.rb similarity index 96% rename from app/controllers/wallet_controller.rb rename to app/controllers/services/lightning_controller.rb index 07de29b..a6b7381 100644 --- a/app/controllers/wallet_controller.rb +++ b/app/controllers/services/lightning_controller.rb @@ -1,6 +1,6 @@ require "rqrcode" -class WalletController < ApplicationController +class Services::LightningController < ApplicationController before_action :require_user_signed_in before_action :authenticate_with_lndhub before_action :set_current_section @@ -42,7 +42,7 @@ class WalletController < ApplicationController end def set_current_section - @current_section = :wallet + @current_section = :services end def fetch_balance diff --git a/app/views/dashboard/index.html.erb b/app/views/dashboard/index.html.erb index 9e24f78..8b90fc0 100644 --- a/app/views/dashboard/index.html.erb +++ b/app/views/dashboard/index.html.erb @@ -43,9 +43,9 @@
- <%= link_to wallet_path, + <%= link_to services_lightning_index_path, class: "block h-full px-6 py-6 rounded-md" do %> -

Wallet

+

Lightning Network

Send and receive sats over the Bitcoin Lightning Network

diff --git a/app/views/notification_mailer/lightning_sats_received.text.erb b/app/views/notification_mailer/lightning_sats_received.text.erb index 1e122d4..22becf6 100644 --- a/app/views/notification_mailer/lightning_sats_received.text.erb +++ b/app/views/notification_mailer/lightning_sats_received.text.erb @@ -1,3 +1,3 @@ You just received <%= number_with_delimiter @amount_sats %> sats in your Lightning account (<%= @user.address %>). Check your wallet app, or open the account page for details: -<%= wallet_transactions_url %> +<%= transactions_lightning_index_url %> diff --git a/app/views/wallet/index.html.erb b/app/views/services/lightning/index.html.erb similarity index 97% rename from app/views/wallet/index.html.erb rename to app/views/services/lightning/index.html.erb index 4a4a37f..fda9558 100644 --- a/app/views/wallet/index.html.erb +++ b/app/views/services/lightning/index.html.erb @@ -1,9 +1,9 @@ -<%= render HeaderComponent.new(title: "Wallet") %> +<%= render HeaderComponent.new(title: "Lightning Network") %> <%= render MainSimpleComponent.new do %> <%= render WalletSummaryComponent.new(balance: @balance) %> - <%= render partial: "shared/tabnav_wallet" %> + <%= render partial: "shared/tabnav_lightning" %>

Lightning Address

diff --git a/app/views/wallet/transactions.html.erb b/app/views/services/lightning/transactions.html.erb similarity index 95% rename from app/views/wallet/transactions.html.erb rename to app/views/services/lightning/transactions.html.erb index 5ebc2cc..cba8d3b 100644 --- a/app/views/wallet/transactions.html.erb +++ b/app/views/services/lightning/transactions.html.erb @@ -1,9 +1,9 @@ -<%= render HeaderComponent.new(title: "Wallet") %> +<%= render HeaderComponent.new(title: "Lightning Network") %> <%= render MainSimpleComponent.new do %> <%= render WalletSummaryComponent.new(balance: @balance) %> - <%= render partial: "shared/tabnav_wallet" %> + <%= render partial: "shared/tabnav_lightning" %>
diff --git a/app/views/shared/_main_nav.html.erb b/app/views/shared/_main_nav.html.erb index 7f5ee02..7fb011b 100644 --- a/app/views/shared/_main_nav.html.erb +++ b/app/views/shared/_main_nav.html.erb @@ -1,10 +1,8 @@ <%= link_to "Services", root_path, - class: main_nav_class(@current_section, :dashboard) %> -<%= link_to "Contributions", contributions_donations_path, - class: main_nav_class(@current_section, :contributions) %> + class: main_nav_class(@current_section, :services) %> <%= link_to "Invitations", invitations_path, class: main_nav_class(@current_section, :invitations) %> -<%= link_to "Wallet", wallet_path, - class: main_nav_class(@current_section, :wallet) %> +<%= link_to "Contributions", contributions_donations_path, + class: main_nav_class(@current_section, :contributions) %> <%= link_to "Settings", settings_path, class: main_nav_class(@current_section, :settings) %> diff --git a/app/views/shared/_tabnav_lightning.html.erb b/app/views/shared/_tabnav_lightning.html.erb new file mode 100644 index 0000000..b9f6f09 --- /dev/null +++ b/app/views/shared/_tabnav_lightning.html.erb @@ -0,0 +1,14 @@ +
+
+ +
+
diff --git a/app/views/shared/_tabnav_wallet.html.erb b/app/views/shared/_tabnav_wallet.html.erb deleted file mode 100644 index abdc5ad..0000000 --- a/app/views/shared/_tabnav_wallet.html.erb +++ /dev/null @@ -1,14 +0,0 @@ -
-
- -
-
diff --git a/config/routes.rb b/config/routes.rb index fdc8454..be4195b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -21,6 +21,14 @@ Rails.application.routes.draw do get 'wallet', to: 'wallet#index' get 'wallet/transactions', to: 'wallet#transactions' + namespace :services do + resources :lightning, only: [:index] do + collection do + get 'transactions' + end + end + end + resources :settings, param: 'section', only: ['index', 'show', 'update'] do collection do post 'reset_password' From f1ae5667de679dae33f608a409eecb203bfe4e43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Wed, 3 May 2023 12:51:22 +0200 Subject: [PATCH 3/4] Shape tx details UI a bit --- app/views/services/lightning/transactions.html.erb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/views/services/lightning/transactions.html.erb b/app/views/services/lightning/transactions.html.erb index cba8d3b..0f11698 100644 --- a/app/views/services/lightning/transactions.html.erb +++ b/app/views/services/lightning/transactions.html.erb @@ -27,7 +27,7 @@

"> <%= tx["received"] ? "+" : "" %><%= number_with_delimiter tx["amount_sats"] %> - + sats

@@ -36,7 +36,9 @@

<%= tx["datetime"].strftime("%B %e, %H:%M") -%> - <% if tx["fee"] && (tx["fee"] > 0) %>, Fee: <%= tx["fee"] %> sats<% end %> + <% if tx["fee"] && (tx["fee"] > 0) %> + ~ Fee: <%= pluralize tx["fee"], "sat" %> + <% end %>

From ce7387a409fcbd4a653862e165865a672c5418d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Wed, 3 May 2023 21:54:33 +0200 Subject: [PATCH 4/4] Remove obsolete routes --- config/routes.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index be4195b..c8dd8a4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -18,9 +18,6 @@ Rails.application.routes.draw do resources :invitations, only: ['index', 'show', 'create', 'destroy'] - get 'wallet', to: 'wallet#index' - get 'wallet/transactions', to: 'wallet#transactions' - namespace :services do resources :lightning, only: [:index] do collection do