Skip to content

Latest commit

 

History

History
102 lines (51 loc) · 2.77 KB

File metadata and controls

102 lines (51 loc) · 2.77 KB

Module 0x4::bitcoin_hash

Constants

const ErrorInvalidHex: u64 = 1;

Function from_ascii_bytes

Convert an ascii hex string bytes to Bitcoin Hash Because Bitcoin Hash hex is reversed, we need to reverse the bytes Abort if the input is not a valid hex

public fun from_ascii_bytes(bytes: &vector<u8>): address

Function from_ascii_bytes_option

Convert an ascii hex string bytes to Bitcoin Hash Because Bitcoin Hash hex is reversed, we need to reverse the bytes Return None if the input is not a valid hex

public fun from_ascii_bytes_option(bytes: &vector<u8>): option::Option<address>

Function to_string

Convert Bitcoin Hash to hex string Because Bitcoin Hash hex is reversed, we need to reverse the bytes

public fun to_string(hash: address): string::String

Function sha256d

Bitcoin hash is double sha256 of the input

public fun sha256d(input: vector<u8>): address

Function sha256d_concat

Concatenate two hashes and compute double SHA256 Used for Merkle tree verification

public fun sha256d_concat(left: address, right: address): address