diff --git a/src/network.rs b/src/network.rs index c34bd04..385b298 100644 --- a/src/network.rs +++ b/src/network.rs @@ -1,5 +1,7 @@ use anyhow::{Error, Result}; +use rand::{thread_rng, RngCore}; use serde::{Deserialize, Serialize}; +use sp_client::bitcoin::hex::DisplayHex; use sp_client::bitcoin::key::constants::ZERO; use sp_client::bitcoin::OutPoint; use sp_client::silentpayments::bitcoin_hashes::{sha256t_hash_newtype, Hash, HashEngine}; @@ -9,7 +11,6 @@ use crate::crypto::CipherText; const RAWTXTOPIC: &'static str = "rawtx"; const RAWBLOCKTOPIC: &'static str = "rawblock"; -const ANKMAGIC: [u8; 4] = [0x34, 0x6E, 0x6B, 0x30]; #[derive(Debug, Serialize, Deserialize)] pub enum BitcoinTopic { @@ -187,11 +188,14 @@ impl AnkFlag { #[tsify(into_wasm_abi, from_wasm_abi)] pub struct FaucetMessage { pub sp_address: String, + pub commitment: String, } impl FaucetMessage { pub fn new(sp_address: String) -> Self { - Self { sp_address } + let mut buf = [0u8;64]; + thread_rng().fill_bytes(&mut buf); + Self { sp_address, commitment: buf.to_lower_hex_string() } } }