18 Commits

Author SHA1 Message Date
87027b514b Merge pull request 'Update gems' (#72) from chore/update_gems into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #72
2022-07-27 13:47:33 +00:00
Râu Cao
16ad621365 Update gems
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
In particular Rails due to security updates:

https://rubyonrails.org/2022/7/12/Rails-Versions-7-0-3-1-6-1-6-1-6-0-5-1-and-5-2-8-1-have-been-released
2022-07-27 15:22:24 +02:00
33e87d6472 Merge pull request 'Add BTCPay service, Kredits API' (#71) from feature/community_funds_balance into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #71
Reviewed-by: bumi <bumi@noreply.kosmos.org>
2022-06-12 05:15:05 +00:00
03dc6c7a9c Log unexpected kredits API errors
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2022-05-24 13:42:00 +02:00
897b5bf4ea Specify whole API base URL in config
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2022-05-23 22:49:39 +02:00
caea2d0121 Add kredits API with wallet balance endpoint
All checks were successful
continuous-integration/drone/push Build is passing
2022-05-23 22:47:08 +02:00
e1ff5c479e Initial BTCPay integration 2022-05-23 21:35:03 +02:00
9b3386de30 Update credentials 2022-05-23 18:49:37 +02:00
f2287c1186 Remove separate development credentials files 2022-05-23 18:49:22 +02:00
b29197cf4e Merge pull request 'Various UI improvements' (#70) from feature/ui_improvements into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #70
2022-04-28 13:05:10 +00:00
5c48055ac8 Use feather icon for wallet on dashboard
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
fixes #51
2022-04-28 15:01:20 +02:00
5ead3476b7 Normalize overall (font) size
The entire UI is a bit too large. This normalizes the font size and
dimensions, so it doesn't look zoomed in on most screens.
2022-04-28 14:56:03 +02:00
fbf163740a Merge pull request 'Replace the LDAP production config for the new server' (#69) from chore/new_ldap_server into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #69
2022-04-28 10:11:01 +00:00
Greg Karékinian
1fc1457e97 Replace the LDAP production config for the new server
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Refs kosmos/chef#227
2022-04-28 11:54:14 +02:00
1f57bbd9c2 Merge pull request 'Add admin task to list LndHub balances' (#68) from feature/list_lndhub_balances into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #68
2022-04-18 08:41:40 +00:00
2a2793ae44 Print sum of user balances
All checks were successful
continuous-integration/drone/pr Build is passing
2022-04-12 16:05:46 +02:00
8773bf5f9e Slow down LndHub auth requests in task 2022-04-12 15:42:44 +02:00
d9970c126a List balances of LndHub accounts 2022-04-12 15:36:45 +02:00
17 changed files with 229 additions and 117 deletions

View File

@@ -1,3 +1,4 @@
EJABBERD_API_URL='https://xmpp.kosmos.org/api' EJABBERD_API_URL='https://xmpp.kosmos.org/api'
BTCPAY_API_URL='http://localhost:23001/api/v1'
LNDHUB_API_URL='http://localhost:3023' LNDHUB_API_URL='http://localhost:3023'
LNDHUB_PUBLIC_URL='https://lndhub.kosmos.org' LNDHUB_PUBLIC_URL='https://lndhub.kosmos.org'

View File

@@ -1,3 +1,4 @@
EJABBERD_API_URL='https://xmpp.kosmos.org:5443/api' EJABBERD_API_URL='https://xmpp.kosmos.org:5443/api'
BTCPAY_API_URL='http://10.1.1.163:23001/api/v1'
LNDHUB_API_URL='http://10.1.1.163:3023' LNDHUB_API_URL='http://10.1.1.163:3023'
LNDHUB_PUBLIC_URL='https://lndhub.kosmos.org' LNDHUB_PUBLIC_URL='https://lndhub.kosmos.org'

View File

@@ -1,3 +1,4 @@
EJABBERD_API_URL='http://xmpp.example.com/api' EJABBERD_API_URL='http://xmpp.example.com/api'
BTCPAY_API_URL='http://btcpay.example.com/api/v1'
LNDHUB_API_URL='http://localhost:3023' LNDHUB_API_URL='http://localhost:3023'
LNDHUB_PUBLIC_URL='https://lndhub.kosmos.org' LNDHUB_PUBLIC_URL='https://lndhub.kosmos.org'

View File

@@ -1,77 +1,77 @@
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
actioncable (7.0.2.2) actioncable (7.0.3.1)
actionpack (= 7.0.2.2) actionpack (= 7.0.3.1)
activesupport (= 7.0.2.2) activesupport (= 7.0.3.1)
nio4r (~> 2.0) nio4r (~> 2.0)
websocket-driver (>= 0.6.1) websocket-driver (>= 0.6.1)
actionmailbox (7.0.2.2) actionmailbox (7.0.3.1)
actionpack (= 7.0.2.2) actionpack (= 7.0.3.1)
activejob (= 7.0.2.2) activejob (= 7.0.3.1)
activerecord (= 7.0.2.2) activerecord (= 7.0.3.1)
activestorage (= 7.0.2.2) activestorage (= 7.0.3.1)
activesupport (= 7.0.2.2) activesupport (= 7.0.3.1)
mail (>= 2.7.1) mail (>= 2.7.1)
net-imap net-imap
net-pop net-pop
net-smtp net-smtp
actionmailer (7.0.2.2) actionmailer (7.0.3.1)
actionpack (= 7.0.2.2) actionpack (= 7.0.3.1)
actionview (= 7.0.2.2) actionview (= 7.0.3.1)
activejob (= 7.0.2.2) activejob (= 7.0.3.1)
activesupport (= 7.0.2.2) activesupport (= 7.0.3.1)
mail (~> 2.5, >= 2.5.4) mail (~> 2.5, >= 2.5.4)
net-imap net-imap
net-pop net-pop
net-smtp net-smtp
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
actionpack (7.0.2.2) actionpack (7.0.3.1)
actionview (= 7.0.2.2) actionview (= 7.0.3.1)
activesupport (= 7.0.2.2) activesupport (= 7.0.3.1)
rack (~> 2.0, >= 2.2.0) rack (~> 2.0, >= 2.2.0)
rack-test (>= 0.6.3) rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (7.0.2.2) actiontext (7.0.3.1)
actionpack (= 7.0.2.2) actionpack (= 7.0.3.1)
activerecord (= 7.0.2.2) activerecord (= 7.0.3.1)
activestorage (= 7.0.2.2) activestorage (= 7.0.3.1)
activesupport (= 7.0.2.2) activesupport (= 7.0.3.1)
globalid (>= 0.6.0) globalid (>= 0.6.0)
nokogiri (>= 1.8.5) nokogiri (>= 1.8.5)
actionview (7.0.2.2) actionview (7.0.3.1)
activesupport (= 7.0.2.2) activesupport (= 7.0.3.1)
builder (~> 3.1) builder (~> 3.1)
erubi (~> 1.4) erubi (~> 1.4)
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (7.0.2.2) activejob (7.0.3.1)
activesupport (= 7.0.2.2) activesupport (= 7.0.3.1)
globalid (>= 0.3.6) globalid (>= 0.3.6)
activemodel (7.0.2.2) activemodel (7.0.3.1)
activesupport (= 7.0.2.2) activesupport (= 7.0.3.1)
activerecord (7.0.2.2) activerecord (7.0.3.1)
activemodel (= 7.0.2.2) activemodel (= 7.0.3.1)
activesupport (= 7.0.2.2) activesupport (= 7.0.3.1)
activestorage (7.0.2.2) activestorage (7.0.3.1)
actionpack (= 7.0.2.2) actionpack (= 7.0.3.1)
activejob (= 7.0.2.2) activejob (= 7.0.3.1)
activerecord (= 7.0.2.2) activerecord (= 7.0.3.1)
activesupport (= 7.0.2.2) activesupport (= 7.0.3.1)
marcel (~> 1.0) marcel (~> 1.0)
mini_mime (>= 1.1.0) mini_mime (>= 1.1.0)
activesupport (7.0.2.2) activesupport (7.0.3.1)
concurrent-ruby (~> 1.0, >= 1.0.2) concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2) i18n (>= 1.6, < 2)
minitest (>= 5.1) minitest (>= 5.1)
tzinfo (~> 2.0) tzinfo (~> 2.0)
addressable (2.8.0) addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0) public_suffix (>= 2.0.2, < 5.0)
bcrypt (3.1.16) bcrypt (3.1.18)
bindex (0.8.1) bindex (0.8.1)
builder (3.2.4) builder (3.2.4)
capybara (3.36.0) capybara (3.37.1)
addressable addressable
matrix matrix
mini_mime (>= 0.1.3) mini_mime (>= 0.1.3)
@@ -81,12 +81,12 @@ GEM
regexp_parser (>= 1.5, < 3.0) regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2) xpath (~> 3.2)
chunky_png (1.4.0) chunky_png (1.4.0)
concurrent-ruby (1.1.9) concurrent-ruby (1.1.10)
connection_pool (2.2.5) connection_pool (2.2.5)
crack (0.4.5) crack (0.4.5)
rexml rexml
crass (1.0.6) crass (1.0.6)
cssbundling-rails (1.0.0) cssbundling-rails (1.1.1)
railties (>= 6.0.0) railties (>= 6.0.0)
database_cleaner (2.0.1) database_cleaner (2.0.1)
database_cleaner-active_record (~> 2.0.0) database_cleaner-active_record (~> 2.0.0)
@@ -105,43 +105,41 @@ GEM
net-ldap (>= 0.16.0) net-ldap (>= 0.16.0)
diff-lcs (1.5.0) diff-lcs (1.5.0)
digest (3.1.0) digest (3.1.0)
dotenv (2.7.6) dotenv (2.8.0)
dotenv-rails (2.7.6) dotenv-rails (2.8.0)
dotenv (= 2.7.6) dotenv (= 2.8.0)
railties (>= 3.2) railties (>= 3.2)
e2mmap (0.1.0)
erubi (1.10.0) erubi (1.10.0)
et-orbi (1.2.6) et-orbi (1.2.7)
tzinfo tzinfo
factory_bot (6.2.0) factory_bot (6.2.1)
activesupport (>= 5.0.0) activesupport (>= 5.0.0)
factory_bot_rails (6.2.0) factory_bot_rails (6.2.0)
factory_bot (~> 6.2.0) factory_bot (~> 6.2.0)
railties (>= 5.0.0) railties (>= 5.0.0)
faraday (2.2.0) faraday (2.3.0)
faraday-net_http (~> 2.0) faraday-net_http (~> 2.0)
ruby2_keywords (>= 0.0.4) ruby2_keywords (>= 0.0.4)
faraday-net_http (2.0.1) faraday-net_http (2.0.3)
ffi (1.15.5) ffi (1.15.5)
fugit (1.5.2) fugit (1.5.3)
et-orbi (~> 1.1, >= 1.1.8) et-orbi (~> 1, >= 1.2.7)
raabro (~> 1.4) raabro (~> 1.4)
globalid (1.0.0) globalid (1.0.0)
activesupport (>= 5.0) activesupport (>= 5.0)
hashdiff (1.0.1) hashdiff (1.0.1)
i18n (1.9.1) i18n (1.12.0)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
importmap-rails (1.0.2) importmap-rails (1.1.5)
actionpack (>= 6.0.0) actionpack (>= 6.0.0)
railties (>= 6.0.0) railties (>= 6.0.0)
io-wait (0.2.1)
jbuilder (2.11.5) jbuilder (2.11.5)
actionview (>= 5.0.0) actionview (>= 5.0.0)
activesupport (>= 5.0.0) activesupport (>= 5.0.0)
launchy (2.5.0) launchy (2.5.0)
addressable (~> 2.7) addressable (~> 2.7)
letter_opener (1.7.0) letter_opener (1.8.1)
launchy (~> 2.2) launchy (>= 2.2, < 3)
letter_opener_web (2.0.0) letter_opener_web (2.0.0)
actionmailer (>= 5.2) actionmailer (>= 5.2)
letter_opener (~> 1.7) letter_opener (~> 1.7)
@@ -150,8 +148,8 @@ GEM
listen (3.7.1) listen (3.7.1)
rb-fsevent (~> 0.10, >= 0.10.3) rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10) rb-inotify (~> 0.9, >= 0.9.10)
lockbox (0.6.8) lockbox (1.0.0)
loofah (2.14.0) loofah (2.18.0)
crass (~> 1.0.2) crass (~> 1.0.2)
nokogiri (>= 1.5.9) nokogiri (>= 1.5.9)
mail (2.7.1) mail (2.7.1)
@@ -160,58 +158,57 @@ GEM
matrix (0.4.2) matrix (0.4.2)
method_source (1.0.0) method_source (1.0.0)
mini_mime (1.1.2) mini_mime (1.1.2)
minitest (5.15.0) minitest (5.16.2)
net-imap (0.2.3) net-imap (0.2.3)
digest digest
net-protocol net-protocol
strscan strscan
net-ldap (0.17.0) net-ldap (0.17.1)
net-pop (0.1.1) net-pop (0.1.1)
digest digest
net-protocol net-protocol
timeout timeout
net-protocol (0.1.2) net-protocol (0.1.3)
io-wait
timeout timeout
net-smtp (0.3.1) net-smtp (0.3.1)
digest digest
net-protocol net-protocol
timeout timeout
nio4r (2.5.8) nio4r (2.5.8)
nokogiri (1.13.1-x86_64-linux) nokogiri (1.13.8-x86_64-linux)
racc (~> 1.4) racc (~> 1.4)
orm_adapter (0.5.0) orm_adapter (0.5.0)
pg (1.2.3) pg (1.2.3)
public_suffix (4.0.6) public_suffix (4.0.7)
puma (4.3.11) puma (4.3.12)
nio4r (~> 2.0) nio4r (~> 2.0)
raabro (1.4.0) raabro (1.4.0)
racc (1.6.0) racc (1.6.0)
rack (2.2.3) rack (2.2.4)
rack-test (1.1.0) rack-test (2.0.2)
rack (>= 1.0, < 3) rack (>= 1.3)
rails (7.0.2.2) rails (7.0.3.1)
actioncable (= 7.0.2.2) actioncable (= 7.0.3.1)
actionmailbox (= 7.0.2.2) actionmailbox (= 7.0.3.1)
actionmailer (= 7.0.2.2) actionmailer (= 7.0.3.1)
actionpack (= 7.0.2.2) actionpack (= 7.0.3.1)
actiontext (= 7.0.2.2) actiontext (= 7.0.3.1)
actionview (= 7.0.2.2) actionview (= 7.0.3.1)
activejob (= 7.0.2.2) activejob (= 7.0.3.1)
activemodel (= 7.0.2.2) activemodel (= 7.0.3.1)
activerecord (= 7.0.2.2) activerecord (= 7.0.3.1)
activestorage (= 7.0.2.2) activestorage (= 7.0.3.1)
activesupport (= 7.0.2.2) activesupport (= 7.0.3.1)
bundler (>= 1.15.0) bundler (>= 1.15.0)
railties (= 7.0.2.2) railties (= 7.0.3.1)
rails-dom-testing (2.0.3) rails-dom-testing (2.0.3)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
nokogiri (>= 1.6) nokogiri (>= 1.6)
rails-html-sanitizer (1.4.2) rails-html-sanitizer (1.4.3)
loofah (~> 2.3) loofah (~> 2.3)
railties (7.0.2.2) railties (7.0.3.1)
actionpack (= 7.0.2.2) actionpack (= 7.0.3.1)
activesupport (= 7.0.2.2) activesupport (= 7.0.3.1)
method_source method_source
rake (>= 12.2) rake (>= 12.2)
thor (~> 1.0) thor (~> 1.0)
@@ -220,13 +217,13 @@ GEM
rb-fsevent (0.11.1) rb-fsevent (0.11.1)
rb-inotify (0.10.1) rb-inotify (0.10.1)
ffi (~> 1.0) ffi (~> 1.0)
redis (4.6.0) redis (4.7.1)
regexp_parser (2.2.1) regexp_parser (2.5.0)
responders (3.0.1) responders (3.0.1)
actionpack (>= 5.0) actionpack (>= 5.0)
railties (>= 5.0) railties (>= 5.0)
rexml (3.2.5) rexml (3.2.5)
rqrcode (2.1.1) rqrcode (2.1.2)
chunky_png (~> 1.0) chunky_png (~> 1.0)
rqrcode_core (~> 1.0) rqrcode_core (~> 1.0)
rqrcode_core (1.2.0) rqrcode_core (1.2.0)
@@ -235,10 +232,10 @@ GEM
rspec-expectations (3.11.0) rspec-expectations (3.11.0)
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0) rspec-support (~> 3.11.0)
rspec-mocks (3.11.0) rspec-mocks (3.11.1)
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0) rspec-support (~> 3.11.0)
rspec-rails (5.1.0) rspec-rails (5.1.2)
actionpack (>= 5.2) actionpack (>= 5.2)
activesupport (>= 5.2) activesupport (>= 5.2)
railties (>= 5.2) railties (>= 5.2)
@@ -248,41 +245,38 @@ GEM
rspec-support (~> 3.10) rspec-support (~> 3.10)
rspec-support (3.11.0) rspec-support (3.11.0)
ruby2_keywords (0.0.5) ruby2_keywords (0.0.5)
rufus-scheduler (3.8.1) rufus-scheduler (3.8.2)
fugit (~> 1.1, >= 1.1.6) fugit (~> 1.1, >= 1.1.6)
sidekiq (6.4.1) sidekiq (6.5.1)
connection_pool (>= 2.2.2) connection_pool (>= 2.2.2)
rack (~> 2.0) rack (~> 2.0)
redis (>= 4.2.0) redis (>= 4.2.0)
sidekiq-scheduler (3.1.1) sidekiq-scheduler (4.0.2)
e2mmap redis (>= 4.2.0)
redis (>= 3, < 5)
rufus-scheduler (~> 3.2) rufus-scheduler (~> 3.2)
sidekiq (>= 3) sidekiq (>= 4)
thwait
tilt (>= 1.4.0) tilt (>= 1.4.0)
sprockets (4.0.2) sprockets (4.1.1)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
rack (> 1, < 3) rack (> 1, < 3)
sprockets-rails (3.4.2) sprockets-rails (3.4.2)
actionpack (>= 5.2) actionpack (>= 5.2)
activesupport (>= 5.2) activesupport (>= 5.2)
sprockets (>= 3.0.0) sprockets (>= 3.0.0)
sqlite3 (1.4.2) sqlite3 (1.4.4)
stimulus-rails (1.0.2) stimulus-rails (1.1.0)
railties (>= 6.0.0) railties (>= 6.0.0)
strscan (3.0.1) strscan (3.0.4)
thor (1.2.1) thor (1.2.1)
thwait (0.2.0) tilt (2.0.11)
e2mmap timeout (0.3.0)
tilt (2.0.10) turbo-rails (1.1.1)
timeout (0.2.0)
turbo-rails (1.0.1)
actionpack (>= 6.0.0) actionpack (>= 6.0.0)
activejob (>= 6.0.0)
railties (>= 6.0.0) railties (>= 6.0.0)
tzinfo (2.0.4) tzinfo (2.0.5)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
view_component (2.49.0) view_component (2.62.0)
activesupport (>= 5.0.0, < 8.0) activesupport (>= 5.0.0, < 8.0)
method_source (~> 1.0) method_source (~> 1.0)
warden (1.2.9) warden (1.2.9)
@@ -301,7 +295,7 @@ GEM
websocket-extensions (0.1.5) websocket-extensions (0.1.5)
xpath (3.2.0) xpath (3.2.0)
nokogiri (~> 1.8) nokogiri (~> 1.8)
zeitwerk (2.5.4) zeitwerk (2.6.0)
PLATFORMS PLATFORMS
x86_64-linux x86_64-linux

View File

@@ -1,4 +1,8 @@
@layer base { @layer base {
html {
font-size: 14px;
}
body { body {
@apply leading-none bg-cover bg-fixed; @apply leading-none bg-cover bg-fixed;
background-image: linear-gradient(35deg, rgba(255,0,255,0.2) 0, rgba(13,79,153,0.8) 100%), url('/img/bg-1.jpg'); background-image: linear-gradient(35deg, rgba(255,0,255,0.2) 0, rgba(13,79,153,0.8) 100%), url('/img/bg-1.jpg');

View File

@@ -0,0 +1,5 @@
class Api::BaseController < ApplicationController
layout false
end

View File

@@ -0,0 +1,13 @@
class Api::KreditsController < Api::BaseController
def onchain_btc_balance
btcpay = BtcPay.new
balance = btcpay.onchain_wallet_balance
render json: balance
rescue => error
Rails.logger.warn "Failed to fetch kredits BTC wallet balance: #{error.message}"
render json: { error: 'Failed to fetch wallet balance' },
status: 500
end
end

32
app/services/btc_pay.rb Normal file
View File

@@ -0,0 +1,32 @@
#
# API Docs: https://docs.btcpayserver.org/API/Greenfield/v1/
#
class BtcPay
def initialize
@base_url = ENV["BTCPAY_API_URL"]
@store_id = Rails.application.credentials.btcpay[:store_id]
@auth_token = Rails.application.credentials.btcpay[:auth_token]
end
def onchain_wallet_balance
res = get "stores/#{@store_id}/payment-methods/onchain/BTC/wallet"
{
balance: res["balance"].to_f,
unconfirmed_balance: res["unconfirmedBalance"].to_f,
confirmed_balance: res["confirmedBalance"].to_f
}
end
private
def get(endpoint)
res = Faraday.get("#{@base_url}/#{endpoint}", {}, {
"Content-Type" => "application/json",
"Accept" => "application/json",
"Authorization" => "token #{@auth_token}"
})
JSON.parse(res.body)
end
end

View File

@@ -25,7 +25,7 @@
</div> </div>
<div> <div>
<h3 class="mb-3.5"> <h3 class="mb-3.5">
<span class="text-yellow-500">🗲</span> <%= render partial: "icons/zap", locals: { custom_class: "text-amber-500 h-4 w-4 inline" } %>
<%= link_to "Lightning Wallet", wallet_path, class: "ks-text-link" %> <%= link_to "Lightning Wallet", wallet_path, class: "ks-text-link" %>
</h3> </h3>
<p class="text-gray-500"> <p class="text-gray-500">

View File

@@ -1 +1 @@
PRI1laGy6XiLpsII0ixFOTCpzzDbrRpIQ7GJ2flvA+UEEiPVQQ4e/pt6ZjumaZ/geTBHCRZklLtS1u6HjucVKHGSR4K/lE1q7u6nfi/wAvwGQdCTJeKf8PetdlsiVZg2OW4Wi2YF7qtb1ipGS/uRlOeLP8JOwp5BNVS1J6tvNX4T5gA7rrB4Cvtfwp1dwLWODHiXbeZK7SN2j7V3NPGZl0LbNg2jquC4DzQOBhMOlwu1IAgOAcqKbHh9tDabpVOcOD5pNSaVaoBO01P8ObbX8x0S0Ug7BPkM5nnyJTQdNH7LHKvtNmrUEk7+fd+VZR6WqEp6SFBoAA7XxvOLy9dIOqvXbAYnrNZX7iI4IpgZWRNIQ7G1qSBjpyPLKC7+nSPmvd4IcgCHVUBdYp0+yYDxLzwuuhPVtyAY4JAIdZY1mhYxx7BzGNiMc3p8AlMS6hPeO9lVQZykViBGnTjR+iah9OQYAihX9FYywtBkNvMXLiYqsVZmv6em9Uk/ivKSIsaFwNwrelCI5H4Q/+/hKFJ1JaMjbYheXCJgcGgfhiC+fIHig/8y8rXd9lWGa1T+PrpA8akcq/K8I6gbxYxpLWcy5Vnz/SyaMurLPVfCq4cD/JfpLSfy0HophaiycZ7D6dr43rnHsPfrt6kveDOgWUK9d7CqHxsWdXbCpJeBoh8/1usIsGsmyhfwHq0dEpRx78bR2EJeM4LOAuQgf69/5rFJydIbXq76l1BftTls1Pgh--OI8c/RQGQ30wT1Ff--M/ltnmdl+FRdlNliTb79lg== oDf4FcihlyfHQuf9SUwfr+UVA0kXoECtHV3vEwtBp2TktCWkWz7SPbSZ2cLT0+EknOKhuI9xutrs311YDU2EzqZba4fZ0+a6/ohVH4jUbk1XfiHZWBp4zh+9TZ5m5Tp2RxcXpdcWPY38mP4zHWFzobTOR/brLjuemozvh8MiBSPY4NN5NR6rbFo87auK6fvYO8ik/1Qwf6pQMoVDjcTh2983po1RU/gSevUmaYsmTTHcQ5T9O9wMIBc101iZyKhkAZG46a6eNYok8yqRm18AHWr+De2j7LlBaqYSz/BZA385RWhhqoeONArwyo3Az30Bv74VttUSJAPurkRg2wDF9t8A+cvf8CeYkZ6u398JLSJbZZ6YdQS5T4IcrnONRXtp3d/m+yw+XEzpluK3MvFbV02AhZk/xzkGK6xonhaTSh1ek9hXoYrUTBzu8HBzXwKjJMnvrAodldu++/rMwLsgVmFHqXC3dydVogatLev8z6ziuGkmeMAR1d9kzGBHM3FWgsWLD7j0Ug7MTMyNWioI3r6J2QTnxkyJGh3pKBlq8Fb/Q0ypERxOfSZVQQh2gB79RMEDIemdCmN5mCU3ojsxqAAip4v9C1BZMWPtom1sHLYQSd9Bh6i0nncrNEtZXcxe5Z8JCWQolHvvfoIF2rfJh2oXYLxNx5n/1fzaoSqBdLBgvsAMA0ZWfV1wa/5V/DCa9vaJjumzHYKcfCCYbVz9PjN9OUSfwrE3nWZu8Y0awsNgmeRQwI10j2+oYYSBp040I05Vj5FM7nCgHLpdupctwaH2/VlIq83OVI6VlbzxYEay7+R5ANmpiJ+vC466DzLv8LAeFOqh/XeNeOITUm9EzhGSgf98yuDc7vsi3gmc2g7atgQ3gpSje6vEfhigm3ukydaGfA==--IYQBMD+Tar1g+srm--01E5mujYFWvcpT8Qd9HxiA==

View File

@@ -1 +0,0 @@
2a8a17892dd9f41ea50c61310c83240b

View File

@@ -1 +0,0 @@
zdpQvlbfqXzaExLzw2LGZkXj97HH42jWZFSTlINpf/HlFr6NubPxLkVxeGsittJj5rm8yL+V21zPxp30Z7Q7R45qyCKFtevtVeqb+u1nZ/FsVfkwb/7wDW9scurgXw==--SB6C0aaNf8qPdteG--9hP+6tpsMnyiAVVvAIq+7w==

View File

@@ -1 +1 @@
xgPOFd8315z7lFtTR5/nD6WDBM2M6Grt/pmkCPdaqlw0WAmFKzbiRGFsXoUQ02JNzvT1/FVtBSsAcyK1Pdr1QQztlWC+/ywaflloMBS4//D8IEXvEgCK6uff5gcf1A==--WbFrw9advCJ4mqsK--HTVHZqO0ddG1toFpY0KKgQ== IIjYiPSeZeMFhH8i8v8akXN4JrtGU+OsMQ8GAao/gVdesggriCBAQ8z+Vd0cmTf1SKYeT3OQDgygEekupr325P4eD9fZ+yi56EA/UMXQXMDVZAvZw7iwvKaOXpqisbWdJnomr1GXrHyR415Ce/Fxft3fgXDwMHJW2u+dDJgpE09uORnB9GXycFwHQmoIdXo=--iQ/Vcm0VcwHgUkwQ--tKHQW/45gM/s/NplqGPaxw==

View File

@@ -46,11 +46,11 @@ test:
# <<: *AUTHORIZATIONS # <<: *AUTHORIZATIONS
production: production:
host: ldap.kosmos.org host: ldap.kosmos.local
port: 636 port: 389
attribute: cn attribute: cn
base: ou=kosmos.org,cn=users,dc=kosmos,dc=org base: ou=kosmos.org,cn=users,dc=kosmos,dc=org
admin_user: <%= Rails.application.credentials.ldap[:username] rescue nil %> admin_user: <%= Rails.application.credentials.ldap[:username] rescue nil %>
admin_password: <%= Rails.application.credentials.ldap[:password] rescue nil %> admin_password: <%= Rails.application.credentials.ldap[:password] rescue nil %>
ssl: simple_tls # ssl: false
# <<: *AUTHORIZATIONS # <<: *AUTHORIZATIONS

View File

@@ -25,6 +25,10 @@ Rails.application.routes.draw do
get 'lnurlpay/:address', to: 'lnurlpay#index', constraints: { address: /[^\/]+/} get 'lnurlpay/:address', to: 'lnurlpay#index', constraints: { address: /[^\/]+/}
get 'lnurlpay/:address/invoice', to: 'lnurlpay#invoice', constraints: { address: /[^\/]+/} get 'lnurlpay/:address/invoice', to: 'lnurlpay#invoice', constraints: { address: /[^\/]+/}
namespace :api do
get 'kredits/onchain_btc_balance', to: 'kredits#onchain_btc_balance'
end
namespace :admin do namespace :admin do
root to: 'dashboard#index' root to: 'dashboard#index'
get 'invitations', to: 'invitations#index' get 'invitations', to: 'invitations#index'

View File

@@ -5,4 +5,20 @@ namespace :lndhub do
CreateLndhubWalletJob.perform_later(user) CreateLndhubWalletJob.perform_later(user)
end end
end end
desc "List wallet balances"
task :balances => :environment do |t, args|
sum = 0
User.all.each do |user|
lndhub = Lndhub.new
auth_token = lndhub.authenticate(user)
data = lndhub.balance(auth_token)
balance = data["BTC"]["AvailableBalance"] rescue nil
if balance && balance > 0
sum += balance
puts "#{user.address}: #{balance} sats"
end
end
puts "--\nSum of user balances: #{sum} sats"
end
end end

View File

@@ -0,0 +1,43 @@
require 'rails_helper'
require 'webmock/rspec'
RSpec.describe "/api/kredits", type: :request do
describe "GET /onchain_btc_balance" do
before do
stub_request(:get, "http://btcpay.example.com/api/v1/stores/123456/payment-methods/onchain/BTC/wallet")
.to_return(status: 200, headers: {}, body: {
balance: 0.91108606,
unconfirmedBalance: 0,
confirmedBalance: 0.91108606
}.to_json)
end
it "returns a formatted result for the onchain wallet balance" do
get api_kredits_onchain_btc_balance_path
expect(response).to have_http_status(:ok)
res = JSON.parse(response.body)
expect(res["balance"]).to eq(0.91108606)
expect(res["unconfirmed_balance"]).to eq(0)
expect(res["confirmed_balance"]).to eq(0.91108606)
end
context "upstream request error" do
before do
stub_request(:get, "http://btcpay.example.com/api/v1/stores/123456/payment-methods/onchain/BTC/wallet")
.to_return(status: 500, headers: {}, body: "")
end
it "returns a formatted error" do
get api_kredits_onchain_btc_balance_path
expect(response).to have_http_status(:server_error)
res = JSON.parse(response.body)
expect(res["error"]).not_to be_nil
end
end
end
end