Print sum of user balances
All checks were successful
continuous-integration/drone/pr Build is passing
All checks were successful
continuous-integration/drone/pr Build is passing
This commit is contained in:
parent
8773bf5f9e
commit
2a2793ae44
@ -8,13 +8,17 @@ namespace :lndhub do
|
||||
|
||||
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
|
||||
puts "#{user.address}: #{balance}" if balance && balance > 0
|
||||
sleep 0.5
|
||||
if balance && balance > 0
|
||||
sum += balance
|
||||
puts "#{user.address}: #{balance} sats"
|
||||
end
|
||||
end
|
||||
puts "--\nSum of user balances: #{sum} sats"
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user