BlockchainScriptHashListUnspentCommand

Struct BlockchainScriptHashListUnspentCommand 

Source
pub struct BlockchainScriptHashListUnspentCommand {
    pub script_hash: String,
}

Fields§

§script_hash: String

Implementations§

Source§

impl BlockchainScriptHashListUnspentCommand

Source

pub fn new(script_hash: &str) -> Self

Examples found in repository?
examples/example.rs (line 30)
11fn main() {
12    let address = "127.0.0.1:50001";
13    let client = Client::new(address);
14
15    // let relay_fee_method = "blockchain.relayfee";
16    //let relay_fee_response = client.raw_call(relay_fee_method, vec![]).unwrap();
17    let response = BlockchainRelayFeeCommand::new().call(&client).unwrap();
18    println!("relay fee result: {:?}", response);
19
20    let p2pkh_address = "mw1Bk1AJSs9zaiL5RaQyp1YGfkuruvZAXR".to_string();
21    let p2pkh_pk_hash = get_public_key_hash_from_address(&p2pkh_address);
22    let p2pkh_script = format!("{}{}{}", "76a914", p2pkh_pk_hash, "88ac");
23    let p2pkh_script_sha256 = bitcoin_utils::sha256_hex(&p2pkh_script);
24    let p2pkh_script_sha256_le = convert_big_endian_hex_to_little_endian(&p2pkh_script_sha256);
25    println!("{}", p2pkh_script_sha256_le);
26    let balance_response = BlockchainScriptHashGetBalanceCommand::new(&p2pkh_script_sha256_le)
27        .call(&client)
28        .unwrap();
29    println!("balance: {:#?}", balance_response);
30    let unspent_response = BlockchainScriptHashListUnspentCommand::new(&p2pkh_script_sha256_le)
31        .call(&client)
32        .unwrap();
33    println!("unspent: {:#?}", unspent_response);
34    let history_response = BlockchainScriptHashGetHistoryCommand::new(&p2pkh_script_sha256_le)
35        .call(&client)
36        .unwrap();
37    println!("history: {:#?}", history_response);
38
39    // let get_balance_method = "blockchain.scripthash.get_balance";
40    // let list_unspent_method = "blockchain.scripthash.listunspent";
41    // let params = vec![Param::String(p2pkh_script_sha256_le.to_string())];
42    // let p2pkh_balance_response = client.raw_call(get_balance_method, params.clone()).unwrap();
43    // println!("get balance result: {:#?}", p2pkh_balance_response);
44    // let p2pkh_list_unspent_response = client
45    //     .raw_call(list_unspent_method, params.clone())
46    //     .unwrap();
47    // println!("list unspent result: {:#?}", p2pkh_list_unspent_response);
48
49    // let p2sh_address = "2MzBNKyJjx44BDJfwEevVzS3Q9Z5kSEYUZB".to_string();
50    // let p2sh_script_hash = get_script_hash_from_p2sh_address(&p2sh_address);
51    // let p2sh_script = format!("{}{}{}", "a914", p2sh_script_hash, "87");
52    // let p2sh_script_sha256 = bitcoin_utils::sha256_hex(&p2sh_script);
53    // let p2sh_script_sha256_le = convert_big_endian_hex_to_little_endian(&p2sh_script_sha256);
54    // println!("{}", p2sh_script_sha256_le);
55
56    // let p2wpkh_address = "tb1qphdqqxupe6dzkz3z58twy5l4s0v24mle5gkp99".to_string();
57    // let p2wpkh_pk_hash = get_public_key_hash_from_address(&p2wpkh_address);
58    // let p2wpkh_script = format!("{}{}", "0014", p2wpkh_pk_hash);
59    // let p2wpkh_script_sha256 = bitcoin_utils::sha256_hex(&p2wpkh_script);
60    // let p2wpkh_script_sha256_le = convert_big_endian_hex_to_little_endian(&p2wpkh_script_sha256);
61    // println!("{}", p2wpkh_script_sha256_le);
62
63    // let p2sh_script =
64    //     "22512086e0338f1a93bf5f1a0ca8bb79ae25da839c98d730d2c08c0171f444d283b090".to_string();
65    // let shaed = bitcoin_utils::sha256_hex(&p2pkh_script);
66    // let shaed_le = convert_big_endian_hex_to_little_endian(&shaed);
67}
Source

pub fn call( &self, client: &Client, ) -> Result<BlockchainScriptHashListUnspentCommandResponse, Error>

Examples found in repository?
examples/example.rs (line 31)
11fn main() {
12    let address = "127.0.0.1:50001";
13    let client = Client::new(address);
14
15    // let relay_fee_method = "blockchain.relayfee";
16    //let relay_fee_response = client.raw_call(relay_fee_method, vec![]).unwrap();
17    let response = BlockchainRelayFeeCommand::new().call(&client).unwrap();
18    println!("relay fee result: {:?}", response);
19
20    let p2pkh_address = "mw1Bk1AJSs9zaiL5RaQyp1YGfkuruvZAXR".to_string();
21    let p2pkh_pk_hash = get_public_key_hash_from_address(&p2pkh_address);
22    let p2pkh_script = format!("{}{}{}", "76a914", p2pkh_pk_hash, "88ac");
23    let p2pkh_script_sha256 = bitcoin_utils::sha256_hex(&p2pkh_script);
24    let p2pkh_script_sha256_le = convert_big_endian_hex_to_little_endian(&p2pkh_script_sha256);
25    println!("{}", p2pkh_script_sha256_le);
26    let balance_response = BlockchainScriptHashGetBalanceCommand::new(&p2pkh_script_sha256_le)
27        .call(&client)
28        .unwrap();
29    println!("balance: {:#?}", balance_response);
30    let unspent_response = BlockchainScriptHashListUnspentCommand::new(&p2pkh_script_sha256_le)
31        .call(&client)
32        .unwrap();
33    println!("unspent: {:#?}", unspent_response);
34    let history_response = BlockchainScriptHashGetHistoryCommand::new(&p2pkh_script_sha256_le)
35        .call(&client)
36        .unwrap();
37    println!("history: {:#?}", history_response);
38
39    // let get_balance_method = "blockchain.scripthash.get_balance";
40    // let list_unspent_method = "blockchain.scripthash.listunspent";
41    // let params = vec![Param::String(p2pkh_script_sha256_le.to_string())];
42    // let p2pkh_balance_response = client.raw_call(get_balance_method, params.clone()).unwrap();
43    // println!("get balance result: {:#?}", p2pkh_balance_response);
44    // let p2pkh_list_unspent_response = client
45    //     .raw_call(list_unspent_method, params.clone())
46    //     .unwrap();
47    // println!("list unspent result: {:#?}", p2pkh_list_unspent_response);
48
49    // let p2sh_address = "2MzBNKyJjx44BDJfwEevVzS3Q9Z5kSEYUZB".to_string();
50    // let p2sh_script_hash = get_script_hash_from_p2sh_address(&p2sh_address);
51    // let p2sh_script = format!("{}{}{}", "a914", p2sh_script_hash, "87");
52    // let p2sh_script_sha256 = bitcoin_utils::sha256_hex(&p2sh_script);
53    // let p2sh_script_sha256_le = convert_big_endian_hex_to_little_endian(&p2sh_script_sha256);
54    // println!("{}", p2sh_script_sha256_le);
55
56    // let p2wpkh_address = "tb1qphdqqxupe6dzkz3z58twy5l4s0v24mle5gkp99".to_string();
57    // let p2wpkh_pk_hash = get_public_key_hash_from_address(&p2wpkh_address);
58    // let p2wpkh_script = format!("{}{}", "0014", p2wpkh_pk_hash);
59    // let p2wpkh_script_sha256 = bitcoin_utils::sha256_hex(&p2wpkh_script);
60    // let p2wpkh_script_sha256_le = convert_big_endian_hex_to_little_endian(&p2wpkh_script_sha256);
61    // println!("{}", p2wpkh_script_sha256_le);
62
63    // let p2sh_script =
64    //     "22512086e0338f1a93bf5f1a0ca8bb79ae25da839c98d730d2c08c0171f444d283b090".to_string();
65    // let shaed = bitcoin_utils::sha256_hex(&p2pkh_script);
66    // let shaed_le = convert_big_endian_hex_to_little_endian(&shaed);
67}

Trait Implementations§

Source§

impl Debug for BlockchainScriptHashListUnspentCommand

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for BlockchainScriptHashListUnspentCommand

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for BlockchainScriptHashListUnspentCommand

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,