diff --git a/lib/ckb/api.rb b/lib/ckb/api.rb index cf4f0839..dbdc2aef 100644 --- a/lib/ckb/api.rb +++ b/lib/ckb/api.rb @@ -21,9 +21,9 @@ def initialize(host: DEFAULT_URL, mode: MODE::TESTNET) if mode == MODE::TESTNET # For testnet chain, we can assume the first cell of the first transaction # in the genesis block contains default lock script we can use here. - system_cell_transaction = genesis_block[:commit_transactions][0] + system_cell_transaction = genesis_block[:transactions][0] out_point = { - hash: system_cell_transaction[:hash], + tx_hash: system_cell_transaction[:hash], index: 0 } cell_data = CKB::Utils.hex_to_bin(system_cell_transaction[:outputs][0][:data]) diff --git a/lib/ckb/transaction.rb b/lib/ckb/transaction.rb index 3799e637..12674894 100644 --- a/lib/ckb/transaction.rb +++ b/lib/ckb/transaction.rb @@ -56,7 +56,7 @@ def signature_hex(key) blake2b = CKB::Blake2b.new inputs.each do |input| previous_output = input[:previous_output] - blake2b.update(Utils.hex_to_bin(previous_output[:hash])) + blake2b.update(Utils.hex_to_bin(previous_output[:tx_hash])) blake2b.update(previous_output[:index].to_s) end outputs.each do |output| diff --git a/lib/ckb/utils.rb b/lib/ckb/utils.rb index 0e9b2c73..a9d86481 100644 --- a/lib/ckb/utils.rb +++ b/lib/ckb/utils.rb @@ -20,7 +20,7 @@ def self.hex_to_bin(hex) def self.json_script_to_type_hash(script) blake2b = CKB::Blake2b.new - blake2b << hex_to_bin(script[:binary_hash]) if script[:binary_hash] + blake2b << hex_to_bin(script[:code_hash]) if script[:code_hash] args = script[:args] || [] args.each do |arg| blake2b << hex_to_bin(arg) @@ -31,7 +31,7 @@ def self.json_script_to_type_hash(script) def self.generate_lock(target_pubkey_blake160, system_script_cell_hash) target_pubkey_blake160_bin = CKB::Utils.hex_to_bin(target_pubkey_blake160) { - binary_hash: system_script_cell_hash, + code_hash: system_script_cell_hash, args: [ # There are 2 conversions from binary to hex string here: # 1. The inner unpack1 is required since the deployed lock script diff --git a/lib/ckb/wallet.rb b/lib/ckb/wallet.rb index 5fbffc67..04907fef 100644 --- a/lib/ckb/wallet.rb +++ b/lib/ckb/wallet.rb @@ -87,7 +87,7 @@ def get_transaction(hash) def block_assembler_config %( [block_assembler] -binary_hash = "#{lock[:binary_hash]}" +code_hash = "#{lock[:code_hash]}" args = #{lock[:args]} ).strip end @@ -113,7 +113,7 @@ def gather_inputs(capacity, min_capacity) input = { previous_output: cell[:out_point], args: [], - valid_since: "0" + since: "0" } pubkeys << pubkey inputs << input diff --git a/spec/ckb/api_spec.rb b/spec/ckb/api_spec.rb index f94ffafc..bc457767 100644 --- a/spec/ckb/api_spec.rb +++ b/spec/ckb/api_spec.rb @@ -40,7 +40,7 @@ end it "get transaction" do - tx = api.genesis_block[:"commit_transactions"].first + tx = api.genesis_block[:transactions].first result = api.get_transaction(tx[:hash]) expect(result).not_to be nil expect(result[:hash]).to eq tx[:hash] diff --git a/spec/ckb/utils_spec.rb b/spec/ckb/utils_spec.rb index d4a1f29a..bbfc2502 100644 --- a/spec/ckb/utils_spec.rb +++ b/spec/ckb/utils_spec.rb @@ -19,7 +19,7 @@ def always_success_json_object ) always_success_cell_hash = Utils.bin_to_hex(hash_bin) { - binary_hash: always_success_cell_hash, + code_hash: always_success_cell_hash, args: [] } end