Skip to content

Commit

Permalink
display bitcoin_block_hash for l1 block
Browse files Browse the repository at this point in the history
  • Loading branch information
baichuan3 committed Sep 13, 2024
1 parent c4e7aa2 commit 2e24bfc
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions crates/rooch-rpc-api/src/jsonrpc_types/transaction_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,21 @@ pub struct L1BlockView {
pub chain_id: StrView<u64>,
pub block_height: StrView<u64>,
pub block_hash: BytesView,
pub bitcoin_block_hash: Option<String>,
}

impl From<L1Block> for L1BlockView {
fn from(block: L1Block) -> Self {
Self {
chain_id: block.chain_id.id().into(),
block_height: block.block_height.into(),
bitcoin_block_hash: if block.chain_id.is_bitcoin() {
bitcoin::BlockHash::from_slice(&block.block_hash)
.map(|hash| hash.to_string())
.ok()
} else {
None
},
block_hash: block.block_hash.into(),
}
}
Expand Down

0 comments on commit 2e24bfc

Please sign in to comment.