use std::env;
use std::process::exit;
use hex::decode;
use reba_client::client::RelayClient;
use secp256k1::SecretKey;
use web3::signing::{Key,
SecretKeyRef};
fn get_env(key: &str) -> String
{
match env::var(key)
{
Ok(val) => val,
Err(_e) => String::new()
}
}
fn main()
{
let pk_str = get_env("PK");
let private_key_bytes: &[u8] = pk_str.as_bytes();
let sk = SecretKey::from_slice(&decode(private_key_bytes).unwrap()).unwrap();
let pk = SecretKeyRef::new(&sk);
let address = pk.address();
let mut client = RelayClient::new(address, &pk).unwrap();
loop
{
let transaction = client.read_tx();
match transaction
{
Some(tx) =>
{
println!("Chain ID: {}", tx.chain_id());
println!("Nonce: {}", tx.nonce());
println!("Value: {}", tx.value());
println!("To: {}", tx.tx_to());
println!("From: {}", tx.tx_from());
println!("Input: {:?}", tx.input());
println!("Gas Limit: {}", tx.gas_limit());
println!("Gas Price: {:?}", tx.gas());
println!("TX Type: {:?}", tx.tx_type());
}
None =>
{
println!("Could not connect to Relay. Are you registered?");
exit(1);
}
}
}
}