pub struct BlockchainRelayFeeCommand {}Implementations§
Source§impl BlockchainRelayFeeCommand
impl BlockchainRelayFeeCommand
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
examples/example.rs (line 17)
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}Sourcepub fn call(
&self,
client: &Client,
) -> Result<BlockchainRelayFeeCommandResponse, Error>
pub fn call( &self, client: &Client, ) -> Result<BlockchainRelayFeeCommandResponse, Error>
Examples found in repository?
examples/example.rs (line 17)
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}Auto Trait Implementations§
impl Freeze for BlockchainRelayFeeCommand
impl RefUnwindSafe for BlockchainRelayFeeCommand
impl Send for BlockchainRelayFeeCommand
impl Sync for BlockchainRelayFeeCommand
impl Unpin for BlockchainRelayFeeCommand
impl UnwindSafe for BlockchainRelayFeeCommand
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more