diff --git a/lib/ckb/api.rb b/lib/ckb/api.rb index 7a4d4c67..84e19853 100644 --- a/lib/ckb/api.rb +++ b/lib/ckb/api.rb @@ -135,11 +135,11 @@ def get_live_cell(out_point, with_data = false) # # @return [String] tx_hash def send_transaction(transaction) - rpc.send_transaction(transaction.to_h) + rpc.send_transaction(transaction.to_raw_transaction_h) end def compute_transaction_hash(transaction) - rpc.compute_transaction_hash(transaction.to_h) + rpc.compute_transaction_hash(transaction.to_raw_transaction_h) end def compute_script_hash(script) @@ -195,7 +195,7 @@ def get_peers_state # # @return [CKB::Types::DryRunResult] def dry_run_transaction(transaction) - result = rpc.dry_run_transaction(transaction.to_h) + result = rpc.dry_run_transaction(transaction.to_raw_transaction_h) Types::DryRunResult.from_h(result) end diff --git a/lib/ckb/types/transaction.rb b/lib/ckb/types/transaction.rb index 2fea9e5f..6401c987 100644 --- a/lib/ckb/types/transaction.rb +++ b/lib/ckb/types/transaction.rb @@ -76,6 +76,18 @@ def to_h hash end + def to_raw_transaction_h + { + version: Utils.to_hex(@version), + cell_deps: @cell_deps.map(&:to_h), + header_deps: @header_deps, + inputs: @inputs.map(&:to_h), + outputs: @outputs.map(&:to_h), + outputs_data: @outputs_data, + witnesses: @witnesses.map(&:to_h) + } + end + def compute_hash raw_transaction_serializer = CKB::Serializers::RawTransactionSerializer.new(self) blake2b = CKB::Blake2b.new