From d9970c126a0b62dba43d0ac361eeb23fde538eb3 Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Tue, 12 Apr 2022 15:36:45 +0200 Subject: [PATCH] List balances of LndHub accounts --- lib/tasks/lndhub.rake | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/tasks/lndhub.rake b/lib/tasks/lndhub.rake index 5b30082..bee07d1 100644 --- a/lib/tasks/lndhub.rake +++ b/lib/tasks/lndhub.rake @@ -5,4 +5,15 @@ namespace :lndhub do CreateLndhubWalletJob.perform_later(user) end end + + desc "List wallet balances" + task :balances => :environment do |t, args| + 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 + end + end end