Print sum of user balances
All checks were successful
continuous-integration/drone/pr Build is passing

This commit is contained in:
Basti 2022-04-12 16:04:19 +02:00
parent 8773bf5f9e
commit 2a2793ae44
Signed by untrusted user: basti
GPG Key ID: 9F88009D31D99C72

View File

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