diff --git a/lib/ckb/api.rb b/lib/ckb/api.rb index 31df7804..d8e1ebb4 100644 --- a/lib/ckb/api.rb +++ b/lib/ckb/api.rb @@ -231,6 +231,30 @@ def index_lock_hash(lock_hash, index_from: "0") Types::LockHashIndexState.from_h(state) end + # @param block_hash [String] 0x... + # + # @return [CKB::Types::BlockHeader] + def get_header(block_hash) + block_header_h = rpc.get_header(block_hash) + Types::BlockHeader.from_h(block_header_h) + end + + # @param block_number [String | Integer] + # + # @return [CKB::Types::BlockHeader] + def get_header_by_number(block_number) + block_header_h = rpc.get_header_by_number(block_number.to_s) + Types::BlockHeader.from_h(block_header_h) + end + + # @param block_hash [String] 0x... + # + # @return [CKB::Types::BlockReward] + def get_cellbase_output_capacity_details(block_hash) + block_reward_h = rpc.get_cellbase_output_capacity_details(block_hash) + Types::BlockReward.from_h(block_reward_h) + end + def inspect "\#" end diff --git a/lib/ckb/rpc.rb b/lib/ckb/rpc.rb index abc6a654..5a6dd235 100644 --- a/lib/ckb/rpc.rb +++ b/lib/ckb/rpc.rb @@ -143,6 +143,18 @@ def index_lock_hash(lock_hash, index_from: '0') rpc_request("index_lock_hash", params: [lock_hash, index_from.to_s]) end + def get_header(block_hash) + rpc_request("get_header", params: [block_hash]) + end + + def get_header_by_number(block_number) + rpc_request("get_header_by_number", params: [block_number.to_s]) + end + + def get_cellbase_output_capacity_details(block_hash) + rpc_request("get_cellbase_output_capacity_details", params: [block_hash]) + end + def inspect "\#" end