Sha256: cfc957a3a2dea88cf31c26812a57b94c6065651837939b999c0c14db26f779be

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 KB

Contents

module MastercoinWallet
  module Network
    class Wallet
      include Observable

      def sync!
#        Thread.new do 
          @address = MastercoinWallet::Address.new(MastercoinWallet::config.address).find

          MastercoinWallet.config.set_key(:balance, (@address["balance"] || 0))
          MastercoinWallet.config.set_key(:test_balance, (@address["test_balance"] || 0))

          ["sold", "bought", "received_transactions","pending_offers", "sent_transactions", "exodus_transactions", "bitcoin_transactions", "spendable_outputs"].each do |x|
            if @address[x]
              MastercoinWallet.config.set_key(x, @address[x])
            end
          end

          if @address["spendable_outputs"]
            MastercoinWallet.config.set_key(:btc_balance, "%.8f" % MastercoinWallet.config.spendable_outputs.inject(0){|sum, x| sum += x["value"].to_f})
          end

          self.changed(true)

          MastercoinWallet.config.save

          notify_observers(true)
        end
      end
#    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mastercoin-wallet-0.0.5 lib/mastercoin-wallet/network/wallet.rb
mastercoin-wallet-0.0.4 lib/mastercoin-wallet/network/wallet.rb
mastercoin-wallet-0.0.3 lib/mastercoin-wallet/network/wallet.rb