Add hash mod
This commit is contained in:
parent
d256ac7074
commit
f4baef4145
20
src/hash.rs
Normal file
20
src/hash.rs
Normal file
@ -0,0 +1,20 @@
|
||||
use sp_client::bitcoin::{
|
||||
consensus::{serialize, Encodable}, hashes::{sha256t_hash_newtype, Hash, HashEngine}, OutPoint
|
||||
};
|
||||
|
||||
sha256t_hash_newtype! {
|
||||
pub struct AnkPcdTag = hash_str("4nk/Pcd");
|
||||
|
||||
#[hash_newtype(forward)]
|
||||
pub struct AnkPcdHash(_);
|
||||
}
|
||||
|
||||
impl AnkPcdHash {
|
||||
pub fn from_pcd_value(value: &[u8], label: &[u8], outpoint: &OutPoint) -> Self {
|
||||
let mut eng = AnkPcdHash::engine();
|
||||
eng.input(value);
|
||||
eng.input(label);
|
||||
serialize(outpoint).consensus_encode(&mut eng).expect("hash engine don't return errors");
|
||||
AnkPcdHash::from_engine(eng)
|
||||
}
|
||||
}
|
@ -16,6 +16,7 @@ pub use wasm_bindgen;
|
||||
|
||||
pub mod crypto;
|
||||
pub mod device;
|
||||
pub mod hash;
|
||||
pub mod error;
|
||||
pub mod network;
|
||||
pub mod pcd;
|
||||
|
Loading…
x
Reference in New Issue
Block a user