lib/lightning/invoice.rb in lightning-invoice-0.1.0 vs lib/lightning/invoice.rb in lightning-invoice-0.1.1

- old
+ new

@@ -30,27 +30,27 @@ data = [] data += Invoice.int_to_array(timestamp) if payment_hash data += [1] data += [1, 20] - data += Invoice.buffer_to_word(payment_hash) + data += Invoice.buffer_to_word(payment_hash.htb) end if description data += [13] description_word = Invoice.buffer_to_word(description) data += Invoice.int_to_array(description_word.size) data += description_word end if pubkey data += [19] data += [1, 21] - data += Invoice.buffer_to_word(pubkey) + data += Invoice.buffer_to_word(pubkey.htb) end if description_hash data += [23] data += [1, 20] - data += Invoice.buffer_to_word(description_hash) + data += Invoice.buffer_to_word(description_hash.htb) end if expiry && expiry != 3600 data += [6] expiry_word = Invoice.int_to_array(expiry) data += Invoice.int_to_array(expiry_word.size) @@ -86,11 +86,11 @@ routing_info.each do |r| tmp += r.to_array end data += Invoice.buffer_to_word(tmp.pack("C*")) end - data += Invoice.buffer_to_word(signature) + data += Invoice.buffer_to_word(signature.htb) Bech32.encode(human, data) end def fallback_address_type(fallback_address) address_types = { @@ -129,17 +129,17 @@ data = tags[index + 3 ... index + 3 + data_length] bytes = to_bytes(data) index += 3 + data_length case type when 1 - message.payment_hash = bytes[0...64].pack("C*") + message.payment_hash = bytes[0...64].pack("C*").bth when 13 message.description = bytes.pack("C*").force_encoding('utf-8') when 19 - message.pubkey = bytes[0...66].pack("C*") + message.pubkey = bytes[0...66].pack("C*").bth when 23 - message.description_hash = bytes[0...64].pack("C*") + message.description_hash = bytes[0...64].pack("C*").bth when 6 message.expiry = to_int(data) when 24 message.min_final_cltv_expiry = to_int(data) when 9 @@ -156,21 +156,21 @@ end when 3 offset = 0 while offset < bytes.size message.routing_info << Lightning::Invoice::RoutingInfo.new( - bytes[offset...offset + 33].pack("C*"), - bytes[offset + 33...offset + 41].pack("C*"), + bytes[offset...offset + 33].pack("C*").bth, + bytes[offset + 33...offset + 41].pack("C*").bth, to_int(bytes[offset + 41...offset + 45]), to_int(bytes[offset + 45...offset + 49]), to_int(bytes[offset + 49...offset + 51]) ) offset += 51 end else end end - message.signature = word_to_buffer(data_part[data_part.size - 104..-1], true) + message.signature = word_to_buffer(data_part[data_part.size - 104..-1], true).bth message end def self.parse_human_readable(human) human.scan(/^([a-zA-Z]+)(\d*)([munp]?)$/)&.first