Class: BitWallet::Wallet
- Inherits:
-
Object
- Object
- BitWallet::Wallet
- Defined in:
- lib/bit_wallet/wallet.rb
Instance Method Summary collapse
- #accounts ⇒ Object
- #client ⇒ Object
-
#initialize(config = {}) ⇒ Wallet
constructor
A new instance of Wallet.
- #move(from_account, to_account, amount, min_conf = BitWallet.min_conf, comment = nil) ⇒ Object
- #recent_transactions(options = {}) ⇒ Object
Constructor Details
#initialize(config = {}) ⇒ Wallet
Returns a new instance of Wallet.
4 5 6 |
# File 'lib/bit_wallet/wallet.rb', line 4 def initialize(config={}) @config = config end |
Instance Method Details
#accounts ⇒ Object
8 9 10 |
# File 'lib/bit_wallet/wallet.rb', line 8 def accounts @accounts ||= Accounts.new(self) end |
#client ⇒ Object
49 50 51 |
# File 'lib/bit_wallet/wallet.rb', line 49 def client @client ||= InstantiatesBitcoinClient.execute(@config) end |
#move(from_account, to_account, amount, min_conf = BitWallet.min_conf, comment = nil) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/bit_wallet/wallet.rb', line 26 def move(from_account, to_account, amount, min_conf=BitWallet.min_conf, comment=nil) from_account_str = if from_account.respond_to?(:name) from_account.name else from_account end to_account_str = if to_account.respond_to?(:name) to_account.name else to_account end client.move(from_account_str, to_account_str, amount, min_conf, comment) end |
#recent_transactions(options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/bit_wallet/wallet.rb', line 12 def recent_transactions(={}) count = .delete(:limit) || 10 # FIXME: come up with adapters to abstract the differences between # bitcoind and blockchain.info API api_result = client.listtransactions("*", count) txs = api_result if api_result.is_a?(Hash) txs = api_result.with_indifferent_access.fetch(:transactions) end txs.map do |hash| Transaction.new self, hash end end |