mastercoin-wallet 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -2
- data/Gemfile.lock +38 -15
- data/Makefile +13 -1
- data/README.rdoc +7 -2
- data/Rakefile +19 -0
- data/VERSION +1 -1
- data/bin/mastercoin-wallet +1 -1
- data/lib/mastercoin-wallet/builder.rb +254 -0
- data/lib/mastercoin-wallet/gui/bitcoin_offer_window.rb +50 -0
- data/lib/mastercoin-wallet/gui/bitcoin_offer_window.ui +121 -0
- data/lib/mastercoin-wallet/gui/main_window.rb +160 -34
- data/lib/mastercoin-wallet/gui/main_window.ui +356 -0
- data/lib/mastercoin-wallet/gui/purchase_offer_window.rb +60 -0
- data/lib/mastercoin-wallet/gui/purchase_offer_window.ui +142 -0
- data/lib/mastercoin-wallet/gui/selling_offer_window.rb +60 -0
- data/lib/mastercoin-wallet/gui/selling_offer_window.ui +154 -0
- data/lib/mastercoin-wallet/gui/simple_send_window.rb +6 -120
- data/lib/mastercoin-wallet/gui/simple_send_window.ui +7 -0
- data/lib/mastercoin-wallet/gui/ui_bitcoin_offer.rb +113 -0
- data/lib/mastercoin-wallet/gui/ui_main.rb +167 -0
- data/lib/mastercoin-wallet/gui/ui_purchase_offer.rb +140 -0
- data/lib/mastercoin-wallet/gui/ui_selling_offer.rb +155 -0
- data/lib/mastercoin-wallet/gui/ui_simple_send.rb +5 -1
- data/lib/mastercoin-wallet/models/selling_offer.rb +18 -0
- data/lib/mastercoin-wallet/network/selling_offer.rb +15 -0
- data/lib/mastercoin-wallet/network/wallet.rb +32 -0
- data/lib/mastercoin-wallet.rb +27 -4
- data/mastercoin-wallet.gemspec +30 -9
- data/resources/logo.icns +0 -0
- metadata +55 -8
- data/lib/mastercoin-wallet/network.rb +0 -34
@@ -0,0 +1,60 @@
|
|
1
|
+
module MastercoinWallet
|
2
|
+
class PurchaseOfferWindow < Qt::Dialog
|
3
|
+
include Bitcoin::Builder
|
4
|
+
include MastercoinWallet::Builder
|
5
|
+
|
6
|
+
slots 'send_transaction()'
|
7
|
+
|
8
|
+
def initialize(parent=nil, options)
|
9
|
+
super(parent)
|
10
|
+
|
11
|
+
@ui = Ui_PurchaseOffer.new
|
12
|
+
@ui.setupUi(self)
|
13
|
+
|
14
|
+
@amount_input = findChild(Qt::LineEdit, "amount_input")
|
15
|
+
@password_input = findChild(Qt::LineEdit, "password_input")
|
16
|
+
@address_input = findChild(Qt::LineEdit, "address_input")
|
17
|
+
@fee_input = findChild(Qt::LineEdit, "fee_input")
|
18
|
+
|
19
|
+
@amount_input.text = options[:available] if options.has_key?(:available)
|
20
|
+
@address_input.text = options[:address] if options.has_key?(:address)
|
21
|
+
@fee_input.text = options[:fee] if options.has_key?(:fee)
|
22
|
+
|
23
|
+
@submit = findChild(Qt::PushButton, "submit_button")
|
24
|
+
|
25
|
+
@amount_input.validator = Qt::DoubleValidator.new(0.00000001, 10000,8, @amount_input)
|
26
|
+
@fee_input.validator = Qt::DoubleValidator.new(0.00000001, 10000,8, @fee_input)
|
27
|
+
|
28
|
+
@currency_select = findChild(Qt::ComboBox, "currency_box")
|
29
|
+
# Dont allow real coins for now
|
30
|
+
# @currency_select.addItem(tr("Mastercoin"))
|
31
|
+
@currency_select.addItem(tr("Test Mastercoin"))
|
32
|
+
|
33
|
+
@submit.enabled = true
|
34
|
+
|
35
|
+
connect(@submit, SIGNAL('clicked()'), self, SLOT('send_transaction()'))
|
36
|
+
end
|
37
|
+
|
38
|
+
def send_transaction
|
39
|
+
@amount = @amount_input.text()
|
40
|
+
@receiving_address = @address_input.text()
|
41
|
+
@password = @password_input.text()
|
42
|
+
@fee = @fee_input.text()
|
43
|
+
|
44
|
+
unless Bitcoin::valid_address?(@receiving_address)
|
45
|
+
Qt::MessageBox.critical(self, tr("Invalid address"),
|
46
|
+
tr("Please fill in a valid Bitcoin/Mastercoin address"))
|
47
|
+
end
|
48
|
+
|
49
|
+
unless @receiving_address.empty? || @amount.empty? || @password.empty? || @fee.empty?
|
50
|
+
data_keys = Mastercoin::PurchaseOffer.new(currency_id: 2, amount: (@amount.to_f * 1e8).to_i).encode_to_compressed_public_key(MastercoinWallet.config.address)
|
51
|
+
create_transaction_with_keys(data_keys, force_fee: @fee)
|
52
|
+
close()
|
53
|
+
else
|
54
|
+
Qt::MessageBox.critical(self, tr("Invalid form"),
|
55
|
+
tr("Please fill in all required inputs"))
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,142 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<ui version="4.0">
|
3
|
+
<class>PurchaseOffer</class>
|
4
|
+
<widget class="QDialog" name="PurchaseOffer">
|
5
|
+
<property name="geometry">
|
6
|
+
<rect>
|
7
|
+
<x>0</x>
|
8
|
+
<y>0</y>
|
9
|
+
<width>534</width>
|
10
|
+
<height>238</height>
|
11
|
+
</rect>
|
12
|
+
</property>
|
13
|
+
<property name="windowTitle">
|
14
|
+
<string>New Purchase Offer</string>
|
15
|
+
</property>
|
16
|
+
<widget class="QWidget" name="verticalLayoutWidget">
|
17
|
+
<property name="geometry">
|
18
|
+
<rect>
|
19
|
+
<x>9</x>
|
20
|
+
<y>39</y>
|
21
|
+
<width>518</width>
|
22
|
+
<height>148</height>
|
23
|
+
</rect>
|
24
|
+
</property>
|
25
|
+
<layout class="QVBoxLayout" name="verticalLayout">
|
26
|
+
<item>
|
27
|
+
<layout class="QGridLayout" name="gridLayout">
|
28
|
+
<item row="4" column="1">
|
29
|
+
<widget class="QLineEdit" name="password_input">
|
30
|
+
<property name="echoMode">
|
31
|
+
<enum>QLineEdit::Password</enum>
|
32
|
+
</property>
|
33
|
+
</widget>
|
34
|
+
</item>
|
35
|
+
<item row="3" column="1">
|
36
|
+
<widget class="QComboBox" name="currency_box"/>
|
37
|
+
</item>
|
38
|
+
<item row="1" column="0">
|
39
|
+
<widget class="QLabel" name="label_3">
|
40
|
+
<property name="text">
|
41
|
+
<string>Amount</string>
|
42
|
+
</property>
|
43
|
+
</widget>
|
44
|
+
</item>
|
45
|
+
<item row="0" column="0">
|
46
|
+
<widget class="QLabel" name="label_2">
|
47
|
+
<property name="text">
|
48
|
+
<string>Masteroin address</string>
|
49
|
+
</property>
|
50
|
+
</widget>
|
51
|
+
</item>
|
52
|
+
<item row="1" column="1">
|
53
|
+
<widget class="QLineEdit" name="amount_input">
|
54
|
+
<property name="placeholderText">
|
55
|
+
<string/>
|
56
|
+
</property>
|
57
|
+
</widget>
|
58
|
+
</item>
|
59
|
+
<item row="3" column="0">
|
60
|
+
<widget class="QLabel" name="label_4">
|
61
|
+
<property name="text">
|
62
|
+
<string>Currency</string>
|
63
|
+
</property>
|
64
|
+
</widget>
|
65
|
+
</item>
|
66
|
+
<item row="0" column="1">
|
67
|
+
<widget class="QLineEdit" name="address_input">
|
68
|
+
<property name="minimumSize">
|
69
|
+
<size>
|
70
|
+
<width>300</width>
|
71
|
+
<height>0</height>
|
72
|
+
</size>
|
73
|
+
</property>
|
74
|
+
<property name="placeholderText">
|
75
|
+
<string/>
|
76
|
+
</property>
|
77
|
+
</widget>
|
78
|
+
</item>
|
79
|
+
<item row="4" column="0">
|
80
|
+
<widget class="QLabel" name="label_5">
|
81
|
+
<property name="text">
|
82
|
+
<string>Password</string>
|
83
|
+
</property>
|
84
|
+
</widget>
|
85
|
+
</item>
|
86
|
+
<item row="2" column="1">
|
87
|
+
<widget class="QLineEdit" name="fee_input"/>
|
88
|
+
</item>
|
89
|
+
<item row="2" column="0">
|
90
|
+
<widget class="QLabel" name="label_6">
|
91
|
+
<property name="text">
|
92
|
+
<string>Required fee</string>
|
93
|
+
</property>
|
94
|
+
</widget>
|
95
|
+
</item>
|
96
|
+
</layout>
|
97
|
+
</item>
|
98
|
+
</layout>
|
99
|
+
</widget>
|
100
|
+
<widget class="QLabel" name="label">
|
101
|
+
<property name="geometry">
|
102
|
+
<rect>
|
103
|
+
<x>20</x>
|
104
|
+
<y>10</y>
|
105
|
+
<width>161</width>
|
106
|
+
<height>21</height>
|
107
|
+
</rect>
|
108
|
+
</property>
|
109
|
+
<property name="text">
|
110
|
+
<string><html><head/><body><p><span style=" font-size:large; font-weight:600;">New Purchase Offer</span></p></body></html></string>
|
111
|
+
</property>
|
112
|
+
</widget>
|
113
|
+
<widget class="QPushButton" name="submit_button">
|
114
|
+
<property name="enabled">
|
115
|
+
<bool>false</bool>
|
116
|
+
</property>
|
117
|
+
<property name="geometry">
|
118
|
+
<rect>
|
119
|
+
<x>410</x>
|
120
|
+
<y>190</y>
|
121
|
+
<width>114</width>
|
122
|
+
<height>32</height>
|
123
|
+
</rect>
|
124
|
+
</property>
|
125
|
+
<property name="text">
|
126
|
+
<string>Send</string>
|
127
|
+
</property>
|
128
|
+
<property name="autoDefault">
|
129
|
+
<bool>false</bool>
|
130
|
+
</property>
|
131
|
+
</widget>
|
132
|
+
</widget>
|
133
|
+
<tabstops>
|
134
|
+
<tabstop>address_input</tabstop>
|
135
|
+
<tabstop>amount_input</tabstop>
|
136
|
+
<tabstop>currency_box</tabstop>
|
137
|
+
<tabstop>password_input</tabstop>
|
138
|
+
<tabstop>submit_button</tabstop>
|
139
|
+
</tabstops>
|
140
|
+
<resources/>
|
141
|
+
<connections/>
|
142
|
+
</ui>
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module MastercoinWallet
|
2
|
+
class SellingOfferWindow < Qt::Dialog
|
3
|
+
include Bitcoin::Builder
|
4
|
+
include MastercoinWallet::Builder
|
5
|
+
|
6
|
+
slots 'send_transaction()'
|
7
|
+
|
8
|
+
def initialize(parent=nil)
|
9
|
+
super(parent)
|
10
|
+
|
11
|
+
@ui = Ui_SellingOffer.new
|
12
|
+
@ui.setupUi(self)
|
13
|
+
|
14
|
+
@amount_input = findChild(Qt::LineEdit, "amount_input")
|
15
|
+
@btc_input = findChild(Qt::LineEdit, "btc_amount_input")
|
16
|
+
@fee_input = findChild(Qt::LineEdit, "fee_input")
|
17
|
+
@time_input = findChild(Qt::LineEdit, "time_input")
|
18
|
+
@password_input = findChild(Qt::LineEdit, "password_input")
|
19
|
+
|
20
|
+
@submit = findChild(Qt::PushButton, "submit_button")
|
21
|
+
|
22
|
+
@amount_input.validator = Qt::DoubleValidator.new(0.00000001, 10000,8, @amount_input)
|
23
|
+
@btc_input.validator = Qt::DoubleValidator.new(0.00000001, 10000,8, @btc_input)
|
24
|
+
@fee_input.validator = Qt::DoubleValidator.new(0.00000001, 10000,8, @fee_input)
|
25
|
+
@fee_input.text = 0.0001
|
26
|
+
@time_input.validator = Qt::DoubleValidator.new(1, 100,1, @time_input)
|
27
|
+
@time_input.text = 6
|
28
|
+
|
29
|
+
|
30
|
+
@currency_select = findChild(Qt::ComboBox, "currency_box")
|
31
|
+
# Dont allow real coins for now
|
32
|
+
# @currency_select.addItem(tr("Mastercoin"))
|
33
|
+
@currency_select.addItem(tr("Test Mastercoin"))
|
34
|
+
|
35
|
+
@submit.enabled = true
|
36
|
+
|
37
|
+
connect(@submit, SIGNAL('clicked()'), self, SLOT('send_transaction()'))
|
38
|
+
end
|
39
|
+
|
40
|
+
def send_transaction
|
41
|
+
@amount = @amount_input.text()
|
42
|
+
@btc_amount = @btc_input.text()
|
43
|
+
@fee_amount = @fee_input.text()
|
44
|
+
@time = @time_input.text()
|
45
|
+
@password = @password_input.text()
|
46
|
+
|
47
|
+
unless @time.empty? || @fee_amount.empty? || @btc_amount.empty? || @amount.empty? || @password.empty?
|
48
|
+
|
49
|
+
data_keys = Mastercoin::SellingOffer.new(currency_id: 2, amount: (@amount.to_f * 1e8).to_i, bitcoin_amount: (@btc_amount.to_f * 1e8).to_i, time_limit: @time.to_i, transaction_fee: (@fee_amount.to_f * 1e8).to_i).encode_to_compressed_public_key(MastercoinWallet.config.address)
|
50
|
+
|
51
|
+
create_transaction_with_keys(data_keys)
|
52
|
+
close()
|
53
|
+
else
|
54
|
+
Qt::MessageBox.critical(self, tr("Invalid form"),
|
55
|
+
tr("Please fill in all required inputs"))
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,154 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<ui version="4.0">
|
3
|
+
<class>SellingOffer</class>
|
4
|
+
<widget class="QDialog" name="SellingOffer">
|
5
|
+
<property name="geometry">
|
6
|
+
<rect>
|
7
|
+
<x>0</x>
|
8
|
+
<y>0</y>
|
9
|
+
<width>534</width>
|
10
|
+
<height>276</height>
|
11
|
+
</rect>
|
12
|
+
</property>
|
13
|
+
<property name="windowTitle">
|
14
|
+
<string>New Simple Send</string>
|
15
|
+
</property>
|
16
|
+
<widget class="QWidget" name="verticalLayoutWidget">
|
17
|
+
<property name="geometry">
|
18
|
+
<rect>
|
19
|
+
<x>9</x>
|
20
|
+
<y>39</y>
|
21
|
+
<width>518</width>
|
22
|
+
<height>179</height>
|
23
|
+
</rect>
|
24
|
+
</property>
|
25
|
+
<layout class="QVBoxLayout" name="verticalLayout">
|
26
|
+
<item>
|
27
|
+
<layout class="QGridLayout" name="gridLayout">
|
28
|
+
<item row="6" column="1">
|
29
|
+
<widget class="QLineEdit" name="fee_input">
|
30
|
+
<property name="minimumSize">
|
31
|
+
<size>
|
32
|
+
<width>300</width>
|
33
|
+
<height>0</height>
|
34
|
+
</size>
|
35
|
+
</property>
|
36
|
+
<property name="placeholderText">
|
37
|
+
<string/>
|
38
|
+
</property>
|
39
|
+
</widget>
|
40
|
+
</item>
|
41
|
+
<item row="7" column="1">
|
42
|
+
<widget class="QLineEdit" name="password_input">
|
43
|
+
<property name="echoMode">
|
44
|
+
<enum>QLineEdit::Password</enum>
|
45
|
+
</property>
|
46
|
+
</widget>
|
47
|
+
</item>
|
48
|
+
<item row="7" column="0">
|
49
|
+
<widget class="QLabel" name="label_5">
|
50
|
+
<property name="text">
|
51
|
+
<string>Password</string>
|
52
|
+
</property>
|
53
|
+
</widget>
|
54
|
+
</item>
|
55
|
+
<item row="5" column="0">
|
56
|
+
<widget class="QLabel" name="label_6">
|
57
|
+
<property name="text">
|
58
|
+
<string>Time (in blocks)</string>
|
59
|
+
</property>
|
60
|
+
</widget>
|
61
|
+
</item>
|
62
|
+
<item row="1" column="1">
|
63
|
+
<widget class="QLineEdit" name="amount_input">
|
64
|
+
<property name="placeholderText">
|
65
|
+
<string/>
|
66
|
+
</property>
|
67
|
+
</widget>
|
68
|
+
</item>
|
69
|
+
<item row="1" column="0">
|
70
|
+
<widget class="QLabel" name="label_3">
|
71
|
+
<property name="text">
|
72
|
+
<string>Amount to sell</string>
|
73
|
+
</property>
|
74
|
+
</widget>
|
75
|
+
</item>
|
76
|
+
<item row="3" column="0">
|
77
|
+
<widget class="QLabel" name="label_4">
|
78
|
+
<property name="text">
|
79
|
+
<string>Currency</string>
|
80
|
+
</property>
|
81
|
+
</widget>
|
82
|
+
</item>
|
83
|
+
<item row="3" column="1">
|
84
|
+
<widget class="QComboBox" name="currency_box"/>
|
85
|
+
</item>
|
86
|
+
<item row="6" column="0">
|
87
|
+
<widget class="QLabel" name="label_2">
|
88
|
+
<property name="text">
|
89
|
+
<string>Transaction fee</string>
|
90
|
+
</property>
|
91
|
+
</widget>
|
92
|
+
</item>
|
93
|
+
<item row="5" column="1">
|
94
|
+
<widget class="QLineEdit" name="time_input"/>
|
95
|
+
</item>
|
96
|
+
<item row="2" column="1">
|
97
|
+
<widget class="QLineEdit" name="btc_amount_input"/>
|
98
|
+
</item>
|
99
|
+
<item row="2" column="0">
|
100
|
+
<widget class="QLabel" name="label_7">
|
101
|
+
<property name="text">
|
102
|
+
<string>Total amount of BTC</string>
|
103
|
+
</property>
|
104
|
+
</widget>
|
105
|
+
</item>
|
106
|
+
</layout>
|
107
|
+
</item>
|
108
|
+
</layout>
|
109
|
+
</widget>
|
110
|
+
<widget class="QLabel" name="label">
|
111
|
+
<property name="geometry">
|
112
|
+
<rect>
|
113
|
+
<x>10</x>
|
114
|
+
<y>10</y>
|
115
|
+
<width>151</width>
|
116
|
+
<height>21</height>
|
117
|
+
</rect>
|
118
|
+
</property>
|
119
|
+
<property name="text">
|
120
|
+
<string><html><head/><body><p><span style=" font-size:large; font-weight:600;">New Selling Offer</span></p></body></html></string>
|
121
|
+
</property>
|
122
|
+
</widget>
|
123
|
+
<widget class="QPushButton" name="submit_button">
|
124
|
+
<property name="enabled">
|
125
|
+
<bool>false</bool>
|
126
|
+
</property>
|
127
|
+
<property name="geometry">
|
128
|
+
<rect>
|
129
|
+
<x>420</x>
|
130
|
+
<y>230</y>
|
131
|
+
<width>114</width>
|
132
|
+
<height>32</height>
|
133
|
+
</rect>
|
134
|
+
</property>
|
135
|
+
<property name="text">
|
136
|
+
<string>Send</string>
|
137
|
+
</property>
|
138
|
+
<property name="autoDefault">
|
139
|
+
<bool>false</bool>
|
140
|
+
</property>
|
141
|
+
</widget>
|
142
|
+
</widget>
|
143
|
+
<tabstops>
|
144
|
+
<tabstop>amount_input</tabstop>
|
145
|
+
<tabstop>btc_amount_input</tabstop>
|
146
|
+
<tabstop>currency_box</tabstop>
|
147
|
+
<tabstop>time_input</tabstop>
|
148
|
+
<tabstop>fee_input</tabstop>
|
149
|
+
<tabstop>password_input</tabstop>
|
150
|
+
<tabstop>submit_button</tabstop>
|
151
|
+
</tabstops>
|
152
|
+
<resources/>
|
153
|
+
<connections/>
|
154
|
+
</ui>
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module MastercoinWallet
|
2
2
|
class SimpleSendWindow < Qt::Dialog
|
3
3
|
include Bitcoin::Builder
|
4
|
+
include MastercoinWallet::Builder
|
4
5
|
|
5
6
|
slots 'on_amount_input_textChanged(const QString&)',
|
6
7
|
'on_address_input_textChanged(const QString&)',
|
@@ -19,10 +20,6 @@ module MastercoinWallet
|
|
19
20
|
|
20
21
|
@submit = findChild(Qt::PushButton, "submit_button")
|
21
22
|
|
22
|
-
@amount_input.setText("1.337")
|
23
|
-
@address_input.setText("1J2svn2GxYx9LPrpCLFikmzn9kkrXBrk8B")
|
24
|
-
|
25
|
-
|
26
23
|
@amount_input.validator = Qt::DoubleValidator.new(0.00000001, 10000,8, @amount_input)
|
27
24
|
|
28
25
|
|
@@ -40,7 +37,7 @@ module MastercoinWallet
|
|
40
37
|
end
|
41
38
|
|
42
39
|
def on_address_input_textChanged(address)
|
43
|
-
@
|
40
|
+
@receiving_address = address
|
44
41
|
check_valid
|
45
42
|
end
|
46
43
|
|
@@ -50,124 +47,13 @@ module MastercoinWallet
|
|
50
47
|
end
|
51
48
|
|
52
49
|
def send_payment
|
53
|
-
data_key = Mastercoin::SimpleSend.new(currency_id: 2, amount: @amount.to_f * 1e8).encode_to_compressed_public_key
|
54
|
-
|
55
|
-
|
56
|
-
tx_amount = BigDecimal.new("0.00006")
|
57
|
-
mastercoin_tx = (4 * tx_amount)
|
58
|
-
|
59
|
-
result = MastercoinWallet.config.spendable_outputs.find{|x| BigDecimal.new(x[:value]) > (fee + mastercoin_tx)}
|
60
|
-
|
61
|
-
if result.is_a?(Array)
|
62
|
-
output = result[0]
|
63
|
-
else
|
64
|
-
output = result
|
65
|
-
end
|
66
|
-
|
67
|
-
unless output
|
68
|
-
Qt::MessageBox.critical(self, tr("Could not send transaction"),
|
69
|
-
tr("It appears there are no spendable outputs for this address that are big enough to transmit this transaction. Please consolidate some coins and send them to your Mastercoin address."))
|
70
|
-
return
|
71
|
-
end
|
72
|
-
|
73
|
-
change_amount = BigDecimal.new(output["value"]) - fee - mastercoin_tx
|
74
|
-
|
75
|
-
tx = MastercoinWallet.config.bitcoin_transactions.find{|x| x["hash"] == output["prev_out"]["hash"]}
|
76
|
-
if tx.is_a?(Array)
|
77
|
-
tx = tx[0]
|
78
|
-
end
|
79
|
-
|
80
|
-
begin
|
81
|
-
priv_key = MastercoinWallet.config.get_encrypted_key(:private_key, @password)
|
82
|
-
rescue ArgumentError
|
83
|
-
Qt::MessageBox.information(self, tr("Could not send payment."),
|
84
|
-
tr("Could not send payment, wrong password."))
|
85
|
-
return
|
86
|
-
end
|
87
|
-
begin
|
88
|
-
key = Bitcoin::Key.from_base58(priv_key)
|
89
|
-
rescue ArgumentError
|
90
|
-
begin
|
91
|
-
key = Bitcoin::Key.new(priv_key)
|
92
|
-
rescue ArgumentError, OpenSSL::BNError
|
93
|
-
Qt::MessageBox.information(self, tr("Could not send payment."),
|
94
|
-
tr("Could not send payment, wrong password."))
|
95
|
-
return
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
tx = build_tx do |t|
|
100
|
-
t.input do |i|
|
101
|
-
i.prev_out Bitcoin::Protocol::Tx.from_hash(tx)
|
102
|
-
i.prev_out_index output["prev_out"]["n"]
|
103
|
-
i.signature_key key
|
104
|
-
end
|
105
|
-
|
106
|
-
# Change address
|
107
|
-
t.output do |o|
|
108
|
-
o.value change_amount * 1e8
|
109
|
-
|
110
|
-
o.script do |s|
|
111
|
-
s.type :address
|
112
|
-
s.recipient MastercoinWallet.config.address
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
# Receiving address
|
117
|
-
t.output do |o|
|
118
|
-
o.value tx_amount * 1e8
|
119
|
-
|
120
|
-
o.script do |s|
|
121
|
-
s.type :address
|
122
|
-
s.recipient @address
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
# Exodus address
|
127
|
-
t.output do |o|
|
128
|
-
o.value tx_amount * 1e8
|
129
|
-
|
130
|
-
o.script do |s|
|
131
|
-
s.type :address
|
132
|
-
s.recipient Mastercoin::EXODUS_ADDRESS
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
# Data address
|
137
|
-
t.output do |o|
|
138
|
-
o.value (tx_amount) * 2 * 1e8
|
139
|
-
|
140
|
-
o.script do |s|
|
141
|
-
s.type :multisig
|
142
|
-
s.recipient 1, key.pub_uncompressed, data_key
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
tx = Bitcoin::Protocol::Tx.new( tx.to_payload )
|
148
|
-
|
149
|
-
MastercoinWallet.log.debug("TX Made: #{tx.to_hash}")
|
150
|
-
|
151
|
-
transaction_hash = tx.to_payload.unpack("H*").first
|
152
|
-
|
153
|
-
MastercoinWallet.log.debug("If you want to send it by Bitcoind use this")
|
154
|
-
MastercoinWallet.log.debug(transaction_hash)
|
155
|
-
|
156
|
-
remote_transaction = Transaction.new(tx.to_hash["hash"], tx.to_json)
|
157
|
-
response = remote_transaction.create!
|
158
|
-
if response.parsed_response.keys.include?("error")
|
159
|
-
Qt::MessageBox.critical(self, tr("Could not relay transaction"),
|
160
|
-
tr("The remote server could not transmit your transaction at this moment."))
|
161
|
-
return
|
162
|
-
else
|
163
|
-
Qt::MessageBox.information(self, tr("Transaction send"),
|
164
|
-
tr("Your transaction has been offered to the relay server, it should show up within 10 minutes."))
|
165
|
-
end
|
166
|
-
close()
|
50
|
+
data_key = Mastercoin::SimpleSend.new(currency_id: 2, amount: (@amount.to_f * 1e8).to_i).encode_to_compressed_public_key(MastercoinWallet.config.address)
|
51
|
+
create_transaction_with_keys(data_key)
|
52
|
+
close()
|
167
53
|
end
|
168
54
|
|
169
55
|
def check_valid
|
170
|
-
unless Bitcoin::valid_address?(@
|
56
|
+
unless Bitcoin::valid_address?(@receiving_address)
|
171
57
|
invalid!
|
172
58
|
return
|
173
59
|
end
|