Class: Bitcoin::Gui::AddrView

Inherits:
TreeView
  • Object
show all
Defined in:
lib/bitcoin/gui/addr_view.rb

Instance Attribute Summary

Attributes inherited from TreeView

#model, #view

Instance Method Summary collapse

Methods inherited from TreeView

#embed, #format_address_col, #format_bool_col, #format_uptime_col, #format_value_col, #format_version_col, #tree_view_col

Methods included from Helpers

#add_wallet_filters, #dialog, #display_tx, #format_address, #format_uptime, #format_value, #format_version, #message, #method_missing, #wallet_preview

Constructor Details

#initialize(gui) ⇒ AddrView

Returns a new instance of AddrView.



6
7
8
9
10
11
12
# File 'lib/bitcoin/gui/addr_view.rb', line 6

def initialize gui
  super(gui, :addr_view, [
      [GObject::TYPE_STRING, "Address", :format_address_col],
      [GObject::TYPE_STRING],
      [GObject::TYPE_STRING, "Balance", :format_value_col],
      [GObject::TYPE_BOOLEAN, "Mine?"]])
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Bitcoin::Gui::Helpers

Instance Method Details

#update(addrs) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/bitcoin/gui/addr_view.rb', line 14

def update addrs
  EM.defer do
    @model.clear
    addrs.each do |addr|
      row = @model.append(nil)
      @model.set_value(row, 0, addr[:addr])
      @model.set_value(row, 1, addr[:label] || "")
      @model.set_value(row, 3, !!addr[:mine])
      balance = 0
      unconfirmed = @gui.check_unconfirmed.active
      @gui.storage.get_txouts_for_address(addr[:addr]).each do |txout|
        next  if !unconfirmed && !txout.get_tx.get_block
        tx_row = @model.append(row)
        @model.set_value(tx_row, 0, txout.get_tx.hash)
        @model.set_value(tx_row, 2, txout.value.to_s)
        balance += txout.value
        if txin = txout.get_next_in
          tx_row = @model.append(row)
          @model.set_value(tx_row, 0, txin.get_tx.hash)
          @model.set_value(tx_row, 2, (0 - txout.value).to_s)
          balance -= txout.value
        end
      end
      @model.set_value(row, 2, balance.to_s)
    end
    @view.set_model @model
  end
end