class MastercoinWallet::FirstRunWindow
Public Class Methods
new(parent=nil)
click to toggle source
Calls superclass method
# File lib/mastercoin-wallet/gui/first_run_window.rb, line 8 def initialize(parent=nil) super(parent) setWindowTitle(tr("Mastercoin wallet - First run")) @ui = Ui_FirstRunWindow.new @ui.setupUi(self) @password_input = findChild(Qt::LineEdit, "password_input") @password_confirmation_input = findChild(Qt::LineEdit, "repeat_password_input") @private_key = findChild(Qt::LineEdit, "private_key_input") @submit = findChild(Qt::PushButton, "submit_button") @error_label = findChild(Qt::Label, "fault") @address_label = findChild(Qt::Label, "address") connect(@submit, SIGNAL('clicked()'), self, SLOT('create_and_save_config()')) end
Public Instance Methods
check_valid()
click to toggle source
# File lib/mastercoin-wallet/gui/first_run_window.rb, line 36 def check_valid valid = true unless @password_confirmation == @password @error_label.setText("Password does not match confirmation.") invalid! return else @error_label.setText("Password matches confirmation.") end if @password.length < 8 @error_label.setText("Please use at least 8 characters for your password.") invalid! return end unless @priv_key invalid! return end valid! end
create_and_save_config()
click to toggle source
# File lib/mastercoin-wallet/gui/first_run_window.rb, line 26 def create_and_save_config MastercoinWallet.config.set_encrypted_key(:private_key, @priv_key, @password) MastercoinWallet.config.set_key(:address, @address) MastercoinWallet.config.save Qt::MessageBox.information(self, tr("First run complete"), tr("Congratulations you have now setup your wallet. The application will now shut down please reboot to make use of your Mastercoin wallet.")) $qApp.quit() end
invalid!()
click to toggle source
# File lib/mastercoin-wallet/gui/first_run_window.rb, line 61 def invalid! @submit.enabled = false end
on_password_input_textChanged(text)
click to toggle source
# File lib/mastercoin-wallet/gui/first_run_window.rb, line 69 def on_password_input_textChanged(text) @password = text check_valid end
on_private_key_input_textChanged(text)
click to toggle source
# File lib/mastercoin-wallet/gui/first_run_window.rb, line 79 def on_private_key_input_textChanged(text) @priv_key = text begin @address = Bitcoin::Key.from_base58(@priv_key).addr @address_label.setText("Address for private key: #{@address}") check_valid rescue ArgumentError, RuntimeError, OpenSSL::BNError begin @address = Bitcoin::Key.new(@priv_key).addr @address_label.setText("Address for private key: #{@address}") check_valid rescue RuntimeError, OpenSSL::BNError @address_label.setText("Cannot get Bitcoin address from private key.") invalid! end end end
on_repeat_password_input_textChanged(text)
click to toggle source
# File lib/mastercoin-wallet/gui/first_run_window.rb, line 74 def on_repeat_password_input_textChanged(text) @password_confirmation = text check_valid end
valid!()
click to toggle source
# File lib/mastercoin-wallet/gui/first_run_window.rb, line 65 def valid! @submit.enabled = true end