Sha256: bfd1f722faff99e74bd8becd890c90b433c57bb3bfb255487545fdbc88b9b7fe

Contents?: true

Size: 1.14 KB

Versions: 8

Compression:

Stored size: 1.14 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))
          MastercoinWallet.config.set_key(:created_transactions, []) if MastercoinWallet.config.get_key(:created_transactions).blank?

          ["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

8 entries across 8 versions & 1 rubygems

Version Path
mastercoin-wallet-0.0.13 lib/mastercoin-wallet/network/wallet.rb
mastercoin-wallet-0.0.12 lib/mastercoin-wallet/network/wallet.rb
mastercoin-wallet-0.0.11 lib/mastercoin-wallet/network/wallet.rb
mastercoin-wallet-0.0.10 lib/mastercoin-wallet/network/wallet.rb
mastercoin-wallet-0.0.9 lib/mastercoin-wallet/network/wallet.rb
mastercoin-wallet-0.0.8 lib/mastercoin-wallet/network/wallet.rb
mastercoin-wallet-0.0.7 lib/mastercoin-wallet/network/wallet.rb
mastercoin-wallet-0.0.6 lib/mastercoin-wallet/network/wallet.rb