lib/mastercoin-ruby/simple_send.rb in mastercoin-ruby-0.2.2 vs lib/mastercoin-ruby/simple_send.rb in mastercoin-ruby-0.2.3

- old
+ new

@@ -30,11 +30,12 @@ raw = raw.ljust(62,"0") return raw end def encode_to_address - raw = (self.get_sequence.to_i.to_s(16).rjust(2, "0") + self.transaction_type.to_i.to_s(16).rjust(8,"0") + self.currency_id.to_i.to_s(16).rjust(8, "0") + self.amount.to_i.to_s(16).rjust(16, "0") + "000000") + self.sequence = self.get_sequence(self.receiving_address, true).to_i + raw = (self.sequence.to_s(16).rjust(2, "0") + self.transaction_type.to_i.to_s(16).rjust(8,"0") + self.currency_id.to_i.to_s(16).rjust(8, "0") + self.amount.to_i.to_s(16).rjust(16, "0") + "000000") Bitcoin.hash160_to_address(raw) end def self.decode_from_address(raw_address) simple_send = Mastercoin::SimpleSend.new @@ -44,16 +45,16 @@ simple_send.currency_id = decoded[12..19].to_i(16) simple_send.amount = decoded[20..35].to_i(16) return simple_send end - def get_sequence(bitcoin_address = nil) + def get_sequence(bitcoin_address = nil, encoding = false) bitcoin_address ||= self.receiving_address - Mastercoin::Util.get_sequence(bitcoin_address) + Mastercoin::Util.get_sequence(bitcoin_address, encoding) end def looks_like_mastercoin? - Mastercoin::TRANSACTION_TYPES.keys.include?(self.transaction_type.to_i.to_s) && Mastercoin::CURRENCY_IDS.keys.include?(self.currency_id.to_s) + Mastercoin::TRANSACTION_TYPES.keys.include?(self.transaction_type.to_i.to_s) && Mastercoin::CURRENCY_IDS.keys.include?(self.currency_id.to_s) && (self.amount / 1e8) < (563061 / 2) end def explain(sending_address = nil, target_address =nil) "SimpleSend transaction from #{sending_address} for %.8f #{self.currency_id_text} to #{self.receiving_address || target_address}." % (self.amount / 1e8) end