Skip to content

Commit

Permalink
Merge pull request #1634 from nervosnetwork/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith-CY authored Feb 21, 2024
2 parents e3cc632 + 589b80f commit d77219e
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions app/utils/ckb_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def self.generate_lock_script_from_cellbase(cellbase)
# TODO: find the RPC document url
# @param [CKB::Types::CellbaseWitness] cellbase
# @return [OpenStruct(lock, message)]
# message struct: versionbit | binary_version | message
def self.parse_cellbase_witness(cellbase)
cellbase_witness = cellbase.witnesses.first.delete_prefix("0x")
cellbase_witness_serialization = [cellbase_witness].pack("H*")
Expand All @@ -58,11 +59,7 @@ 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..]
message_serialization = message_bytes[4..]
message = if message_serialization.size > 28
"#{message_serialization[0..28]}#{message_serialization[29..]&.unpack1('H*')}".to_json.unpack1("H*")
else
message_serialization.unpack1("H*")
end
message = message_serialization.unpack1("H*")
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..]
Expand Down

0 comments on commit d77219e

Please sign in to comment.