mastercoin-wallet 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +14 -1
- data/VERSION +1 -1
- data/bin/console +15 -0
- data/lib/mastercoin-wallet/builder.rb +59 -29
- data/lib/mastercoin-wallet/config.rb +2 -2
- data/lib/mastercoin-wallet/gui/main_window.rb +11 -14
- data/lib/mastercoin-wallet/gui/main_window.ui +2 -2
- data/lib/mastercoin-wallet/gui/ui_main.rb +3 -3
- data/lib/mastercoin-wallet/network/wallet.rb +1 -0
- data/lib/mastercoin-wallet/util.rb +15 -0
- data/lib/mastercoin-wallet.rb +1 -1
- data/mastercoin-wallet.gemspec +5 -3
- metadata +6 -3
data/README.rdoc
CHANGED
@@ -14,13 +14,26 @@ Dependencies will differ based on your operating system.
|
|
14
14
|
=== OS X
|
15
15
|
Install {homebrew}[http://brew.sh/] if you haven't got it yet.
|
16
16
|
|
17
|
-
* brew install qt
|
17
|
+
* brew install qt cmake
|
18
18
|
|
19
19
|
=== Debian/Ubuntu
|
20
20
|
These instructions might not be complete. Additional instructions welcome.
|
21
21
|
|
22
22
|
* apt-get install libqt4-gui libqt4-dev cake
|
23
23
|
|
24
|
+
=== Windows
|
25
|
+
These instructions might also not be complete.
|
26
|
+
|
27
|
+
* Download and install Win32 OpenSSL from: http://slproweb.com/products/Win32OpenSSL.html
|
28
|
+
* Install Ruby via http://rubyinstaller.org/downloads/
|
29
|
+
* Install the DevKit on that same page, make sure you use the proper one for the ruby version you installed.
|
30
|
+
* Make sure you follow {these instructions}[https://github.com/oneclick/rubyinstaller/wiki/Development-Kit] on how to properly configure the DevKit
|
31
|
+
* Start a command prompt with ruby and type "gem install mastercoin-wallet"
|
32
|
+
|
33
|
+
This last step should hopefully not be needed anymore but for now we need a custom patched bitcoin-ruby for Windows
|
34
|
+
* {Download the updated bitcoin-ruby gem}[https://dl.dropboxusercontent.com/u/374/bitcoin-ruby-0.0.2.gem] and install it using gem install bitcoin-ruby-0.0.2.gem
|
35
|
+
* Go back to the ruby command prompt and type mastercoin-wallet to start it
|
36
|
+
|
24
37
|
== Installation
|
25
38
|
Once the depencies are installed you can just do gem install mastercoin-wallet to install the wallet. Start it by issuing mastercoin-wallet from a terminal.
|
26
39
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.6
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$:.unshift( File.expand_path("../../lib", __FILE__) )
|
3
|
+
require 'mastercoin-wallet'
|
4
|
+
include MastercoinWallet
|
5
|
+
|
6
|
+
require 'irb'
|
7
|
+
require 'irb/completion'
|
8
|
+
def reload(require_regex)
|
9
|
+
$".grep(/^#{require_regex}/).each {|e| $".delete(e) && require(e) }
|
10
|
+
end
|
11
|
+
def reload!
|
12
|
+
$".grep(/mastercoin/).each {|e| $".delete(e) && require(e) }
|
13
|
+
end
|
14
|
+
IRB.start
|
15
|
+
|
@@ -55,10 +55,10 @@ module MastercoinWallet
|
|
55
55
|
end
|
56
56
|
begin
|
57
57
|
key = Bitcoin::Key.from_base58(priv_key)
|
58
|
-
rescue ArgumentError
|
58
|
+
rescue ArgumentError, RuntimeError
|
59
59
|
begin
|
60
60
|
key = Bitcoin::Key.new(priv_key)
|
61
|
-
rescue ArgumentError, OpenSSL::BNError
|
61
|
+
rescue ArgumentError, OpenSSL::BNError, RuntimeError
|
62
62
|
Qt::MessageBox.information(self, tr("Could not send payment."),
|
63
63
|
tr("Could not send payment, wrong password."))
|
64
64
|
return
|
@@ -103,26 +103,41 @@ module MastercoinWallet
|
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
|
-
|
106
|
+
transmit!(tx)
|
107
|
+
end
|
107
108
|
|
108
|
-
|
109
|
+
def pick_outputs(required_amount)
|
110
|
+
used_outputs = MastercoinWallet.config.created_transactions.collect{|x| x["in"][0]["prev_out"] }
|
111
|
+
usuable_outputs = MastercoinWallet.config.spendable_outputs.find{|x| BigDecimal.new(x[:value]) > BigDecimal.new(required_amount.to_s) }
|
109
112
|
|
110
|
-
|
113
|
+
#puts "Found these total: #{usuable_outputs}"
|
114
|
+
#puts "These are used #{used_outputs}"
|
111
115
|
|
112
|
-
|
113
|
-
|
114
|
-
|
116
|
+
usuable_outputs = [usuable_outputs] if usuable_outputs.is_a?(Hash)
|
117
|
+
usuable_outputs.reject!{|x| puts x; used_outputs.include?(x["prev_out"])}
|
118
|
+
#puts "Left with these: #{usuable_outputs}"
|
115
119
|
|
116
|
-
|
117
|
-
|
118
|
-
if
|
119
|
-
|
120
|
-
|
121
|
-
|
120
|
+
if usuable_outputs.empty?
|
121
|
+
# Outputs are saved in order so the last output should always the one that's unused, make sure it's an output for thist address and that it's big enough
|
122
|
+
if MastercoinWallet.config.created_transactions.last["out"].first["address"] == MastercoinWallet.config.address && MastercoinWallet.config.created_transactions.last["out"].first["value"].to_f >= BigDecimal.new(required_amount)
|
123
|
+
# We are taking an full transaction and building a spendable output based on the details we have
|
124
|
+
output = MastercoinWallet.config.created_transactions.last["out"].first.reverse_merge({prev_out: {hash: MastercoinWallet.config.created_transactions.last["hash"], n: 0}})
|
125
|
+
tx = MastercoinWallet.config.created_transactions.last
|
126
|
+
return output,tx
|
122
127
|
else
|
123
|
-
|
124
|
-
|
128
|
+
return nil, nil
|
129
|
+
end
|
130
|
+
else
|
131
|
+
if usuable_outputs.is_a?(Array)
|
132
|
+
usuable_outputs = usuable_outputs[0]
|
133
|
+
end
|
134
|
+
|
135
|
+
tx = MastercoinWallet.config.bitcoin_transactions.find{|x| x["hash"] == usuable_outputs["prev_out"]["hash"]}
|
136
|
+
if tx.is_a?(Array)
|
137
|
+
tx = tx[0]
|
125
138
|
end
|
139
|
+
return usuable_outputs, tx
|
140
|
+
end
|
126
141
|
end
|
127
142
|
|
128
143
|
def create_transaction_with_keys(data_keys, options = {})
|
@@ -136,13 +151,10 @@ module MastercoinWallet
|
|
136
151
|
self.set_fee
|
137
152
|
end
|
138
153
|
|
139
|
-
|
154
|
+
required_amount = (self.fee + self.mastercoin_tx)
|
155
|
+
output, tx = pick_outputs(required_amount)
|
140
156
|
|
141
|
-
|
142
|
-
ouput = valid_output[0]
|
143
|
-
else
|
144
|
-
output = valid_output
|
145
|
-
end
|
157
|
+
# puts "Using output: #{output} and Tx: #{tx}"
|
146
158
|
|
147
159
|
unless output
|
148
160
|
Qt::MessageBox.critical(self, tr("Could not send transaction"),
|
@@ -152,10 +164,6 @@ module MastercoinWallet
|
|
152
164
|
|
153
165
|
change_amount = BigDecimal.new(output["value"]) - fee - mastercoin_tx
|
154
166
|
|
155
|
-
tx = MastercoinWallet.config.bitcoin_transactions.find{|x| x["hash"] == output["prev_out"]["hash"]}
|
156
|
-
if tx.is_a?(Array)
|
157
|
-
tx = tx[0]
|
158
|
-
end
|
159
167
|
|
160
168
|
begin
|
161
169
|
priv_key = MastercoinWallet.config.get_encrypted_key(:private_key, @password)
|
@@ -166,16 +174,23 @@ module MastercoinWallet
|
|
166
174
|
end
|
167
175
|
begin
|
168
176
|
key = Bitcoin::Key.from_base58(priv_key)
|
169
|
-
rescue ArgumentError
|
177
|
+
rescue ArgumentError, RuntimeError
|
170
178
|
begin
|
171
179
|
key = Bitcoin::Key.new(priv_key)
|
172
|
-
rescue ArgumentError, OpenSSL::BNError
|
180
|
+
rescue ArgumentError, OpenSSL::BNError, RuntimeError
|
173
181
|
Qt::MessageBox.information(self, tr("Could not send payment."),
|
174
182
|
tr("Could not send payment, wrong password."))
|
175
183
|
return
|
176
184
|
end
|
177
185
|
end
|
178
|
-
|
186
|
+
|
187
|
+
begin
|
188
|
+
public_keys.insert(0, key.pub_compressed)
|
189
|
+
rescue RuntimeError => e
|
190
|
+
Qt::MessageBox.information(self, tr("Could not send payment."),
|
191
|
+
tr("Something went wrong while trying to generate your public key. Please report this: #{e}"))
|
192
|
+
return
|
193
|
+
end
|
179
194
|
|
180
195
|
|
181
196
|
tx = build_tx do |t|
|
@@ -227,7 +242,10 @@ module MastercoinWallet
|
|
227
242
|
end
|
228
243
|
end
|
229
244
|
end
|
245
|
+
transmit!(tx)
|
246
|
+
end
|
230
247
|
|
248
|
+
def transmit!(tx)
|
231
249
|
tx = Bitcoin::Protocol::Tx.new( tx.to_payload )
|
232
250
|
|
233
251
|
MastercoinWallet.log.debug("TX Made: #{tx.to_hash}")
|
@@ -245,6 +263,18 @@ module MastercoinWallet
|
|
245
263
|
tr("The remote server could not transmit your transaction at this moment. #{response.parsed_response}"))
|
246
264
|
return
|
247
265
|
else
|
266
|
+
sent_transactions = MastercoinWallet.config.get_key("created_transactions")
|
267
|
+
sent_transactions ||= []
|
268
|
+
sent_transactions << tx.to_hash(with_address: true)
|
269
|
+
|
270
|
+
#transactions = MastercoinWallet.config.get_key("bitcoin_transactions")
|
271
|
+
#transactions ||= []
|
272
|
+
#transactions << tx
|
273
|
+
#transactions = MastercoinWallet.config.set_key!("bitcoin_transactions", transactions)
|
274
|
+
|
275
|
+
|
276
|
+
MastercoinWallet.config.set_key!(:created_transactions, sent_transactions)
|
277
|
+
|
248
278
|
Qt::MessageBox.information(self, tr("Transaction send"),
|
249
279
|
tr("Your transaction with hash #{tx.to_hash["hash"]} has been offered to the relay server, it should show up within 10 minutes."))
|
250
280
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module MastercoinWallet
|
2
2
|
class Config
|
3
3
|
attr_accessor :options
|
4
|
-
DEFAULT = ActiveSupport::HashWithIndifferentAccess.new(balance: 0, test_balance: 0, spendable_outputs: [], bitcoin_transactions: [], exodus_transactions: [], sent_transactions: [], received_transactions: [], btc_balance: 0)
|
4
|
+
DEFAULT = ActiveSupport::HashWithIndifferentAccess.new(balance: 0, test_balance: 0, spendable_outputs: [], bought_transactions:[], created_transactions: [], sold_transactions: [], bitcoin_transactions: [], exodus_transactions: [], sent_transactions: [], received_transactions: [], btc_balance: 0)
|
5
5
|
|
6
6
|
def initialize
|
7
7
|
self.ensure_config!
|
@@ -11,7 +11,7 @@ module MastercoinWallet
|
|
11
11
|
if config.empty?
|
12
12
|
self.options = DEFAULT
|
13
13
|
else
|
14
|
-
self.options = ActiveSupport::HashWithIndifferentAccess.new(JSON.load(config))
|
14
|
+
self.options = ActiveSupport::HashWithIndifferentAccess.new(JSON.load(config)).reverse_merge(DEFAULT)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module MastercoinWallet
|
2
2
|
class MainWindow < Qt::Dialog
|
3
|
+
include MastercoinWallet::Util
|
4
|
+
|
3
5
|
slots 'new_simple_send()', 'new_selling_offer()', 'new_purchase_offer()', 'create_order(QTreeWidgetItem *, int)', 'sync()', 'create_bitcoin_tx(QTreeWidgetItem *, int)'
|
4
6
|
|
5
7
|
def create_order(item, position)
|
@@ -26,7 +28,7 @@ module MastercoinWallet
|
|
26
28
|
@ui = Ui_MainWindow.new
|
27
29
|
@ui.setupUi(self)
|
28
30
|
|
29
|
-
setWindowTitle(tr("Mastercoin wallet - v0.0.
|
31
|
+
setWindowTitle(tr("Mastercoin wallet - v0.0.6"))
|
30
32
|
|
31
33
|
@rows = []
|
32
34
|
|
@@ -111,22 +113,17 @@ module MastercoinWallet
|
|
111
113
|
update_balance
|
112
114
|
end
|
113
115
|
|
114
|
-
|
115
|
-
def coin_name(currency_id)
|
116
|
-
if currency_id.to_s == "1"
|
117
|
-
"MSC"
|
118
|
-
else
|
119
|
-
"Test MSC"
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
116
|
def add_row(item, type)
|
124
117
|
row = Qt::TreeWidgetItem.new
|
125
|
-
|
118
|
+
if type == "Sent"
|
119
|
+
row.setText(0, item["receiving_address"])
|
120
|
+
else
|
121
|
+
row.setText(0, item["address"])
|
122
|
+
end
|
126
123
|
row.setText(1, item["amount"])
|
127
124
|
row.setText(2, type)
|
128
125
|
row.setText(3, coin_name(item["currency_id"]))
|
129
|
-
row.setText(4, item["tx_date"])
|
126
|
+
row.setText(4, get_date(item["tx_date"]))
|
130
127
|
return row
|
131
128
|
end
|
132
129
|
|
@@ -187,12 +184,12 @@ module MastercoinWallet
|
|
187
184
|
end
|
188
185
|
end
|
189
186
|
if MastercoinWallet.config.has_key?(:bought)
|
190
|
-
MastercoinWallet.config.
|
187
|
+
MastercoinWallet.config.bought_transactions.each do |x|
|
191
188
|
@rows << add_row(x, "Bought")
|
192
189
|
end
|
193
190
|
end
|
194
191
|
if MastercoinWallet.config.has_key?(:sold)
|
195
|
-
MastercoinWallet.config.
|
192
|
+
MastercoinWallet.config.sold_transactions.each do |x|
|
196
193
|
@rows << add_row(x, "Sold")
|
197
194
|
end
|
198
195
|
end
|
@@ -35,7 +35,7 @@
|
|
35
35
|
</sizepolicy>
|
36
36
|
</property>
|
37
37
|
<property name="currentIndex">
|
38
|
-
<number>
|
38
|
+
<number>0</number>
|
39
39
|
</property>
|
40
40
|
<widget class="QWidget" name="tab">
|
41
41
|
<attribute name="title">
|
@@ -98,7 +98,7 @@
|
|
98
98
|
<rect>
|
99
99
|
<x>220</x>
|
100
100
|
<y>40</y>
|
101
|
-
<width>
|
101
|
+
<width>491</width>
|
102
102
|
<height>51</height>
|
103
103
|
</rect>
|
104
104
|
</property>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
=begin
|
2
2
|
** Form generated from reading ui file 'main_window.ui'
|
3
3
|
**
|
4
|
-
** Created:
|
4
|
+
** Created: Thu Nov 7 21:47:28 2013
|
5
5
|
** by: Qt User Interface Compiler version 4.8.4
|
6
6
|
**
|
7
7
|
** WARNING! All changes made in this file will be lost when recompiling ui file!
|
@@ -59,7 +59,7 @@ class Ui_MainWindow
|
|
59
59
|
@bitcoinLabel.geometry = Qt::Rect.new(10, 70, 171, 19)
|
60
60
|
@mscAddressLabel = Qt::Label.new(@tab)
|
61
61
|
@mscAddressLabel.objectName = "mscAddressLabel"
|
62
|
-
@mscAddressLabel.geometry = Qt::Rect.new(220, 40,
|
62
|
+
@mscAddressLabel.geometry = Qt::Rect.new(220, 40, 491, 51)
|
63
63
|
@font = Qt::Font.new
|
64
64
|
@font.family = "Verdana"
|
65
65
|
@font.pointSize = 24
|
@@ -109,7 +109,7 @@ class Ui_MainWindow
|
|
109
109
|
|
110
110
|
retranslateUi(mainWindow)
|
111
111
|
|
112
|
-
@mainTab.setCurrentIndex(
|
112
|
+
@mainTab.setCurrentIndex(0)
|
113
113
|
|
114
114
|
|
115
115
|
Qt::MetaObject.connectSlotsByName(mainWindow)
|
@@ -9,6 +9,7 @@ module MastercoinWallet
|
|
9
9
|
|
10
10
|
MastercoinWallet.config.set_key(:balance, (@address["balance"] || 0))
|
11
11
|
MastercoinWallet.config.set_key(:test_balance, (@address["test_balance"] || 0))
|
12
|
+
MastercoinWallet.config.set_key(:created_transactions, []) if MastercoinWallet.config.get_key(:created_transactions).blank?
|
12
13
|
|
13
14
|
["sold", "bought", "received_transactions","pending_offers", "sent_transactions", "exodus_transactions", "bitcoin_transactions", "spendable_outputs"].each do |x|
|
14
15
|
if @address[x]
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module MastercoinWallet
|
2
|
+
module Util
|
3
|
+
def get_date(date)
|
4
|
+
Time.strptime(date, "%Y-%m-%dT%H:%M:%S.000Z").strftime("%d-%m-%Y %H:%M:%S")
|
5
|
+
end
|
6
|
+
|
7
|
+
def coin_name(currency_id)
|
8
|
+
if currency_id.to_s == "1"
|
9
|
+
"MSC"
|
10
|
+
else
|
11
|
+
"Test MSC"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/mastercoin-wallet.rb
CHANGED
@@ -15,7 +15,7 @@ module MastercoinWallet
|
|
15
15
|
|
16
16
|
autoload :Address, 'mastercoin-wallet/models/address'
|
17
17
|
autoload :Transaction, 'mastercoin-wallet/models/transaction'
|
18
|
-
|
18
|
+
autoload :Util, 'mastercoin-wallet/util'
|
19
19
|
|
20
20
|
autoload :MainWindow, 'mastercoin-wallet/gui/main_window'
|
21
21
|
autoload :FirstRunWindow, 'mastercoin-wallet/gui/first_run_window'
|
data/mastercoin-wallet.gemspec
CHANGED
@@ -5,14 +5,14 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "mastercoin-wallet"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Maran"]
|
12
|
-
s.date = "2013-11-
|
12
|
+
s.date = "2013-11-07"
|
13
13
|
s.description = "Mastercoin wallet using QT bindings to create a useful gui wallet"
|
14
14
|
s.email = "maran.hidskes@gmail.com"
|
15
|
-
s.executables = ["mastercoin-wallet"]
|
15
|
+
s.executables = ["console", "mastercoin-wallet"]
|
16
16
|
s.extra_rdoc_files = [
|
17
17
|
"LICENSE.txt",
|
18
18
|
"README.rdoc"
|
@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
|
|
26
26
|
"README.rdoc",
|
27
27
|
"Rakefile",
|
28
28
|
"VERSION",
|
29
|
+
"bin/console",
|
29
30
|
"bin/mastercoin-wallet",
|
30
31
|
"lib/.DS_Store",
|
31
32
|
"lib/mastercoin-wallet.rb",
|
@@ -55,6 +56,7 @@ Gem::Specification.new do |s|
|
|
55
56
|
"lib/mastercoin-wallet/models/transaction.rb",
|
56
57
|
"lib/mastercoin-wallet/network/selling_offer.rb",
|
57
58
|
"lib/mastercoin-wallet/network/wallet.rb",
|
59
|
+
"lib/mastercoin-wallet/util.rb",
|
58
60
|
"mastercoin-wallet.gemspec",
|
59
61
|
"resources/images.qrc",
|
60
62
|
"resources/logo.icns",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mastercoin-wallet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-11-
|
12
|
+
date: 2013-11-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mastercoin-ruby
|
@@ -174,6 +174,7 @@ dependencies:
|
|
174
174
|
description: Mastercoin wallet using QT bindings to create a useful gui wallet
|
175
175
|
email: maran.hidskes@gmail.com
|
176
176
|
executables:
|
177
|
+
- console
|
177
178
|
- mastercoin-wallet
|
178
179
|
extensions: []
|
179
180
|
extra_rdoc_files:
|
@@ -188,6 +189,7 @@ files:
|
|
188
189
|
- README.rdoc
|
189
190
|
- Rakefile
|
190
191
|
- VERSION
|
192
|
+
- bin/console
|
191
193
|
- bin/mastercoin-wallet
|
192
194
|
- lib/.DS_Store
|
193
195
|
- lib/mastercoin-wallet.rb
|
@@ -217,6 +219,7 @@ files:
|
|
217
219
|
- lib/mastercoin-wallet/models/transaction.rb
|
218
220
|
- lib/mastercoin-wallet/network/selling_offer.rb
|
219
221
|
- lib/mastercoin-wallet/network/wallet.rb
|
222
|
+
- lib/mastercoin-wallet/util.rb
|
220
223
|
- mastercoin-wallet.gemspec
|
221
224
|
- resources/images.qrc
|
222
225
|
- resources/logo.icns
|
@@ -238,7 +241,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
238
241
|
version: '0'
|
239
242
|
segments:
|
240
243
|
- 0
|
241
|
-
hash: -
|
244
|
+
hash: -1967742424752974739
|
242
245
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
243
246
|
none: false
|
244
247
|
requirements:
|