mastercoin-ruby 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -76,6 +76,10 @@ module Mastercoin
76
76
  result
77
77
  end
78
78
 
79
+ def explain(sending_address= nil)
80
+ puts "Not implemented"
81
+ end
82
+
79
83
 
80
84
  def mangle_key_until_valid(key)
81
85
  key[64..66] = Random.rand(256).to_s(16).rjust(2,"0")
@@ -50,8 +50,8 @@ module Mastercoin
50
50
  Mastercoin::Util.get_sequence(bitcoin_address)
51
51
  end
52
52
 
53
- def explain
54
- "Purchase Offer transaction for %.8f #{self.currency_id_text}." % (self.amount / 1e8)
53
+ def explain(sending_address= nil)
54
+ "Purchase Offer transaction for %.8f #{self.currency_id_text} from #{sending_address}." % (self.amount / 1e8)
55
55
  end
56
56
 
57
57
  def currency_id_text
@@ -39,8 +39,8 @@ module Mastercoin
39
39
  end
40
40
  end
41
41
 
42
- def explain
43
- "Selling Offer of #{(self.amount / 1e8).to_f} #{Mastercoin::CURRENCY_IDS[self.currency_id.to_s]} for #{(self.bitcoin_amount / 1e8).to_f} Bitcoins. Time limit #{self.time_limit}. BTC Fee #{self.transaction_fee}"
42
+ def explain(sending_address)
43
+ "Selling Offer from #{sending_address} of #{(self.amount / 1e8).to_f} #{Mastercoin::CURRENCY_IDS[self.currency_id.to_s]} for #{(self.bitcoin_amount / 1e8).to_f} Bitcoins. Time limit #{self.time_limit}. BTC Fee #{self.transaction_fee}"
44
44
  end
45
45
  end
46
46
  end
@@ -55,8 +55,8 @@ module Mastercoin
55
55
  Mastercoin::TRANSACTION_TYPES.keys.include?(self.transaction_type.to_i.to_s) && Mastercoin::CURRENCY_IDS.keys.include?(self.currency_id.to_s)
56
56
  end
57
57
 
58
- def explain
59
- "SimpleSend transaction for %.8f #{self.currency_id_text}." % (self.amount / 1e8)
58
+ def explain(sending_address = nil, target_address =nil)
59
+ "SimpleSend transaction from #{sending_address} for %.8f #{self.currency_id_text} to #{self.receiving_address || target_address}." % (self.amount / 1e8)
60
60
  end
61
61
 
62
62
  def currency_id_text
@@ -35,13 +35,15 @@ module Mastercoin
35
35
  self.multisig = false
36
36
  end
37
37
 
38
- if multisig
39
- self.btc_tx.outputs.each do |output|
40
- if output.get_address == Mastercoin::EXODUS_ADDRESS
41
- exodus_value = output.value
42
- end
38
+ # This should probably be next up for refactor, smelling code creep!
39
+
40
+ self.btc_tx.outputs.each do |output|
41
+ if output.get_address == Mastercoin::EXODUS_ADDRESS
42
+ exodus_value = output.value
43
43
  end
44
+ end
44
45
 
46
+ if multisig
45
47
  self.btc_tx.outputs.each do |output|
46
48
  if output.script.is_multisig?
47
49
  keys = output.script.get_multisig_pubkeys.collect{|x| x.unpack("H*")[0]}
@@ -69,6 +71,19 @@ module Mastercoin
69
71
  self.target_address = address
70
72
  end
71
73
  end
74
+
75
+ unless self.target_address
76
+ # Find data outputs and brute force receiver
77
+ found = self.btc_tx.outputs.find_all{|x| x.value == exodus_value}.reject do |output|
78
+ output.get_address == Mastercoin::EXODUS_ADDRESS || Mastercoin::SimpleSend.decode_from_address(output.get_address).looks_like_mastercoin? # This looks like a data packet
79
+ end
80
+
81
+ if found.length == 1
82
+ self.target_address = found.first.get_address
83
+ else
84
+ puts "Could not find target address"
85
+ end
86
+ end
72
87
  end
73
88
  raise NoMastercoinTransactionException.new("Could not find a valid looking data-address, invalid.") unless self.data
74
89
  end
@@ -82,7 +97,7 @@ module Mastercoin
82
97
  end
83
98
 
84
99
  def to_s
85
- self.data.explain
100
+ self.data.explain(self.sending_address, self.target_address)
86
101
  end
87
102
  end
88
103
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "mastercoin-ruby"
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Maran"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mastercoin-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -194,7 +194,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
194
194
  version: '0'
195
195
  segments:
196
196
  - 0
197
- hash: 473417032215847410
197
+ hash: 1640464448657650911
198
198
  required_rubygems_version: !ruby/object:Gem::Requirement
199
199
  none: false
200
200
  requirements: