Skip to content

Latest commit

 

History

History
88 lines (44 loc) · 2.37 KB

bitcoin_hash.md

File metadata and controls

88 lines (44 loc) · 2.37 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