Class: MastercoinWallet::SimpleSendWindow

Inherits:
Qt::Dialog
  • Object
show all
Includes:
Bitcoin::Builder, Builder
Defined in:
lib/mastercoin-wallet/gui/simple_send_window.rb

Instance Attribute Summary

Attributes included from Builder

#btc_amount, #fee, #mastercoin_tx, #tx_amount

Instance Method Summary collapse

Methods included from Builder

#create_bitcoin_transaction_for, #create_transaction_with_keys, #pick_outputs, #set_fee, #transmit!

Constructor Details

#initialize(parent = nil) ⇒ SimpleSendWindow

TODO: TRY TO REDEEM MULTISIGS



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/mastercoin-wallet/gui/simple_send_window.rb', line 12

def initialize(parent=nil)
  super(parent)

  @ui = Ui_SimpleSend.new
  @ui.setupUi(self)

  @amount_input = findChild(Qt::LineEdit, "amount_input")
  @address_input = findChild(Qt::LineEdit, "address_input")

  @submit = findChild(Qt::PushButton, "submit_button")

  @amount_input.validator = Qt::DoubleValidator.new(0.00000001, 10000,8, @amount_input)


  @currency_select = findChild(Qt::ComboBox, "currency_box")

  @currency_select.addItem(tr("Mastercoin"))
  @currency_select.addItem(tr("Test Mastercoin"))

  connect(@submit, SIGNAL('clicked()'), self, SLOT('send_payment()'))
end

Instance Method Details

#check_validObject



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/mastercoin-wallet/gui/simple_send_window.rb', line 63

def check_valid
  unless Bitcoin::valid_address?(@receiving_address)
    invalid! 
    return
  end

  if @amount.nil?
    invalid! 
    return
  end

  if @password.nil? || (@password && @password.length < 7)
    invalid!
    return
  end

  valid!
end

#invalid!Object



82
83
84
# File 'lib/mastercoin-wallet/gui/simple_send_window.rb', line 82

def invalid!
  @submit.enabled = false
end

#on_address_input_textChanged(address) ⇒ Object



39
40
41
42
# File 'lib/mastercoin-wallet/gui/simple_send_window.rb', line 39

def on_address_input_textChanged(address)
  @receiving_address = address
  check_valid
end

#on_amount_input_textChanged(amount) ⇒ Object



34
35
36
37
# File 'lib/mastercoin-wallet/gui/simple_send_window.rb', line 34

def on_amount_input_textChanged(amount)
  @amount = amount
  check_valid
end

#on_password_input_textChanged(password) ⇒ Object



44
45
46
47
# File 'lib/mastercoin-wallet/gui/simple_send_window.rb', line 44

def on_password_input_textChanged(password)
  @password = password
  check_valid
end

#send_paymentObject



49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/mastercoin-wallet/gui/simple_send_window.rb', line 49

def send_payment
  if @currency_select.currentText() == "Mastercoin"
    currency_id = 1
  elsif @currency_select.currentText() == "Test Mastercoin"
    currency_id = 2
  else
    raise "How did you get here? ^_^"
  end

  data_key = Mastercoin::SimpleSend.new(currency_id: currency_id, amount: (BigDecimal.new(@amount.to_s)* 1e8).to_i).encode_to_compressed_public_key(MastercoinWallet.config.address)
  create_transaction_with_keys(data_key)
  close()
end

#valid!Object



86
87
88
# File 'lib/mastercoin-wallet/gui/simple_send_window.rb', line 86

def valid!
  @submit.enabled = true
end