Created
August 14, 2014 17:32
-
-
Save donpdonp/c926ec50d5b0c8644919 to your computer and use it in GitHub Desktop.
wallet dump balance check
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
## Query the balance of every address in a wallet dump/backup | |
## $ bitcoin-cli dumpwallet ~/wallet.dump | |
## $ ./wbc.rb ~/wallet.dump | |
require 'open-uri' | |
satoshi = 0.00000001 | |
addresses = File.open(ARGV[0]).read.gsub("\n"," ").split.map{|a| a.split('=')}.select{|a| a[0]=='addr'}.map{|a|a[1]} | |
puts "Checking balances of #{addresses.size} addresses with blockchain.info" | |
addresses.map!{|a| [a,open("https://blockchain.info/q/addressbalance/#{a}").read.to_i]} | |
addresses.sort{|a| a[1]}.each {|a| puts "#{a[0]} #{a[1]*satoshi}" } | |
total = addresses.reduce(0){|t,a| t+a[1]} | |
puts "Total: #{total*satoshi}BTC" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment