Skip to content

Commit

Permalink
Merge pull request #848 from nervosnetwork/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
shaojunda authored Oct 21, 2021
2 parents cc94ff6 + 904600c commit dbb47b2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/utils/ckb_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ def self.parse_cellbase_witness(cellbase)
args_offset = [script_serialization[12..15].unpack1("H*")].pack("H*").unpack1("V")
message_bytes = cellbase_witness_serialization[message_offset..-1]
message_serialization = message_bytes[4..-1]
message = "0x#{message_serialization.unpack1('H*')}"
if message_serialization.size > 28
message = "#{message_serialization[0..28]}#{message_serialization[29..-1]&.unpack1("H*")}".to_json.unpack1("H*")
else
message = message_serialization.unpack1("H*")
end
code_hash_serialization = script_serialization[code_hash_offset...hash_type_offset]
hash_type_serialization = script_serialization[hash_type_offset...args_offset]
args_serialization = script_serialization[hash_type_offset + 1..-1]
Expand All @@ -58,7 +62,7 @@ def self.parse_cellbase_witness(cellbase)

hash_type = hash_type_hex == "0x00" ? "data" : "type"
lock = CKB::Types::Script.new(code_hash: code_hash, args: args, hash_type: hash_type)
OpenStruct.new(lock: lock, message: message)
OpenStruct.new(lock: lock, message: "0x#{message}")
end

def self.miner_message(cellbase)
Expand Down

0 comments on commit dbb47b2

Please sign in to comment.