pub fn send_wallet_payment(api_key: &String, address: &String, amount: f64) -> Option<BackingTx> {
    let json_body = json!({ "address": address,
                            "value": erg_to_nanoerg(amount) });
    let reg = Handlebars::new();
    let pb = reg.render_template(SEND_PAYMENT_TEMPLATE, &json_body).ok()?;
    let endpoint = get_node_ip() + "/wallet/payment/send";
    let client = reqwest::Client::new();
    let hapi_key = HeaderValue::from_str(&api_key).expect("Failed to create header value from api key.");
    let res = client.post(&endpoint)
                .header("accept", "application/json")
                .header("api_key", hapi_key)
                .header(CONTENT_TYPE, "application/json")
                .body(pb)
                .send();

    let mut tx_id = res.ok()?.text().ok()?;
    tx_id.retain(|c| c != '"');

    if tx_id.contains("bad.request") {
        println!("Failed to make payment. This is the error from the ergo node/wallet:\n{}", tx_id);
        std::process::exit(0);
    }

    return Some(BackingTx::new(tx_id, amount));
}
/// Send payment from unlocked wallet to given address via local node api. Returns the box identifier.
Send payment from unlocked wallet to given address via local node api. Returns the box identifier.
Send payment from unlocked wallet to given address via local node api . Returns the box identifier .
pub fn send_wallet_payment(api_key: &String, address: &String, amount: f64) -> Option<BackingTx> {
    let json_body = json!({ "address": address,
                            "value": erg_to_nanoerg(amount) });
    let reg = Handlebars::new();
    let pb = reg.render_template(SEND_PAYMENT_TEMPLATE, &json_body).ok()?;
    let endpoint = get_node_ip() + "/wallet/payment/send";
    let client = reqwest::Client::new();
    let hapi_key = HeaderValue::from_str(&api_key).expect("Failed to create header value from api key.");
    let res = client.post(&endpoint)
                .header("accept", "application/json")
                .header("api_key", hapi_key)
                .header(CONTENT_TYPE, "application/json")
                .body(pb)
                .send();
    let mut tx_id = res.ok()?.text().ok()?;
    tx_id.retain(|c| c != '"');
    if tx_id.contains("bad.request") {
        println!("Failed to make payment. This is the error from the ergo node/wallet:\n{}", tx_id);
        std::process::exit(0);
    }
    return Some(BackingTx::new(tx_id, amount));
}
pub fn send_wallet_payment ( api_key : & String , address : & String , amount : f64 ) -> Option < BackingTx > { let json_body = json ! ( { " " address " " erg_to_nanoerg ( amount ) } ) ; let reg = Handlebars :: new ( ) ; let pb = reg . render_template ( SEND_PAYMENT_TEMPLATE , & json_body ) . ok ( ) ? ; let endpoint = get_node_ip ( ) + " " ; let client = reqwest :: Client :: new ( ) ; let hapi_key = HeaderValue :: from_str ( & api_key ) . expect ( " " ) ; let res = client . post ( & endpoint ) . header ( " " , " " ) . header ( " " , hapi_key ) . header ( CONTENT_TYPE , " " ) . body ( pb ) . send ( ) ; let mut tx_id = res . ok ( ) ? . text ( ) . ok ( ) ? ; tx_id . retain ( | c | c != '"' ) ; if tx_id . contains ( " " ) { println ! ( " \n " tx_id ) ; std :: process :: exit ( 0 ) ; } return Some ( BackingTx :: new ( tx_id , amount ) ) ; }
Send payment from unlocked wallet to given address via local node api.
Send payment from unlocked wallet to given address via local node api .
api_key
&String
address
&String
amount
f64
api_key
&String
address
&String
amount
f64