Skip to content

Commit

Permalink
feat: update send_transaction rpc
Browse files Browse the repository at this point in the history
BREAKING CHANGE: add outputs_validator to send_transaction rpc
  • Loading branch information
shaojunda committed Feb 3, 2020
1 parent 7894ed8 commit 295869f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
6 changes: 4 additions & 2 deletions lib/ckb/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,10 @@ def get_live_cell(out_point, with_data = false)
# @param transaction [CKB::Types::Transaction]
#
# @return [String] tx_hash
def send_transaction(transaction)
rpc.send_transaction(transaction.to_raw_transaction_h)
def send_transaction(transaction, outputs_validator = "default")
raise ArgumentError, "Invalid outputs_validator, outputs_validator should be `default` or `passthrough`" unless %w(default passthrough).include?(outputs_validator)

rpc.send_transaction(transaction.to_raw_transaction_h, outputs_validator)
end

def compute_transaction_hash(transaction)
Expand Down
6 changes: 4 additions & 2 deletions lib/ckb/rpc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ def get_live_cell(out_point, with_data = false)
rpc_request("get_live_cell", params: [out_point, with_data])
end

def send_transaction(transaction)
rpc_request("send_transaction", params: [transaction])
def send_transaction(transaction, outputs_validator = "default")
raise ArgumentError, "Invalid outputs_validator, outputs_validator should be `default` or `passthrough`" unless %w(default passthrough).include?(outputs_validator)

rpc_request("send_transaction", params: [transaction, outputs_validator])
end

def local_node_info
Expand Down
8 changes: 4 additions & 4 deletions lib/ckb/wallet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ def generate_tx(target_address, capacity, data = "0x", key: nil, fee: 0, use_dep
# @param data [String] "0x..."
# @param key [CKB::Key | String] Key or private key hex string
# @param fee [Integer] transaction fee, in shannon
def send_capacity(target_address, capacity, data = "0x", key: nil, fee: 0)
def send_capacity(target_address, capacity, data = "0x", key: nil, fee: 0, outputs_validator: "default")
tx = generate_tx(target_address, capacity, data, key: key, fee: fee)
send_transaction(tx)
send_transaction(tx, outputs_validator)
end

# @param capacity [Integer]
Expand Down Expand Up @@ -360,8 +360,8 @@ def lock
private

# @param transaction [CKB::Transaction]
def send_transaction(transaction)
api.send_transaction(transaction)
def send_transaction(transaction, outputs_validator = "default")
api.send_transaction(transaction, outputs_validator)
end

# @param capacity [Integer]
Expand Down

0 comments on commit 295869f

Please sign in to comment.