mastercoin-ruby 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.5
1
+ 0.2.6
@@ -13,7 +13,7 @@ module Mastercoin
13
13
 
14
14
  desc "decode_from_address <address>", "Decodes a simple send based on a address"
15
15
  def decode_from_address(address)
16
- puts Mastercoin::SimpleSend.decode_from_address(address).to_s
16
+ puts Mastercoin::SimpleSend.decode_from_address(address).explain
17
17
  end
18
18
 
19
19
  desc "encode_to_public_key <options>", "Encodes the parameters into a public key"
@@ -62,6 +62,7 @@ module Mastercoin
62
62
  # Do nothing yet; this is simply the exodus address
63
63
  elsif Mastercoin::SimpleSend.decode_from_address(output.get_address).looks_like_mastercoin? # This looks like a data packet
64
64
  Mastercoin.log.debug "Found data for address #{output.get_address}"
65
+ raise NoMastercoinTransactionException.new("More then one data-addresses found, invalidating.") if self.data.present?
65
66
  self.data = Mastercoin::SimpleSend.decode_from_address(output.get_address)
66
67
  end
67
68
  end
@@ -80,19 +81,32 @@ module Mastercoin
80
81
  end
81
82
 
82
83
  unless self.target_address
83
- Mastercoin.log.debug "Target address not found attempting peek & decode."
84
+ Mastercoin.log.debug "Target address not found attempting 'peek & decode' Level 1, checking exodus-sized outputs."
84
85
  # Find data outputs and brute force receiver
85
86
  found = exodus_size_outputs.reject do |output|
86
87
  output.get_address == Mastercoin::EXODUS_ADDRESS || Mastercoin::SimpleSend.decode_from_address(output.get_address).looks_like_mastercoin? # This looks like a data packet
87
88
  end
88
89
 
89
90
  if found.length == 1
91
+ Mastercoin.log.debug "Only one possible target left; found target address."
90
92
  self.target_address = found.first.get_address
91
93
  else
92
- raise NoMastercoinTransactionException.new("Could not find a recipient address.") unless self.data
94
+ Mastercoin.log.debug "Target address not found attempting 'peek & decode' Level 2, checking all-non exodus-sized outputs."
95
+
96
+ self.btc_tx.outputs.each do |output|
97
+ address = output.get_address
98
+ sequence = Mastercoin::Util.get_sequence(address)
99
+ Mastercoin.log.debug "Sequence: #{sequence} for #{address}"
100
+
101
+ if (self.data.sequence.to_i + 1).to_s == sequence.to_s
102
+ self.target_address = address
103
+ Mastercoin.log.debug "Target address found #{self.target_address}"
104
+ end
105
+ end
93
106
  end
94
107
  end
95
108
  end
109
+ raise NoMastercoinTransactionException.new("Could not find valid looking target address, invalid") unless self.target_address
96
110
  raise NoMastercoinTransactionException.new("Could not find a valid looking data-address, invalid.") unless self.data
97
111
  end
98
112
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "mastercoin-ruby"
8
- s.version = "0.2.5"
8
+ s.version = "0.2.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-12-30"
12
+ s.date = "2014-01-11"
13
13
  s.description = "Basic implementation of the Mastercoin protocol."
14
14
  s.email = "maran.hidskes@gmail.com"
15
15
  s.executables = ["exodus_payment", "mastercoin-console", "mastercoin_transaction", "simple_send", "wallet.rb"]
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.5
4
+ version: 0.2.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-12-30 00:00:00.000000000 Z
12
+ date: 2014-01-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bitcoin-ruby
@@ -194,7 +194,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
194
194
  version: '0'
195
195
  segments:
196
196
  - 0
197
- hash: 1760560904608188435
197
+ hash: 3390840139407744307
198
198
  required_rubygems_version: !ruby/object:Gem::Requirement
199
199
  none: false
200
200
  requirements: