use super::*;
pub async fn wallet_backup(api: &Factom)
-> Result<ApiResponse<WalletBackup>>
{
let req = ApiRequest::new("wallet-backup");
let response = walletd_call(api, req).await;
parse(response).await
}
pub async fn wallet_balances(api: &Factom)
-> Result<ApiResponse<WalletBalances>>
{
let req = ApiRequest::new("wallet-balances");
let response = walletd_call(api, req).await;
parse(response).await
}
pub async fn unlock_wallet(
api: &Factom,
passphrase :&str,
timeout: usize
) -> Result<ApiResponse<UnlockWallet>>
{
let mut req = ApiRequest::new("unlock-wallet");
req.params.insert("passphrase".to_string(), json!(passphrase));
req.params.insert("timeout".to_string(), json!(timeout));
let response = walletd_call(api, req).await;
parse(response).await
}
pub async fn wallet_height(api: &Factom)
-> Result<ApiResponse<Height>>
{
let req = ApiRequest::new("get-height");
let response = walletd_call(api, req).await;
parse(response).await
}
pub async fn wallet_properties(api: &Factom)
-> Result<ApiResponse<Properties>>
{
let req = ApiRequest::new("properties");
let response = walletd_call(api, req).await;
parse(response).await
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct UnlockWallet {
pub success: bool,
pub unlockeduntil: i64,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct WalletBackup {
#[serde(rename = "wallet-seed")]
pub wallet_seed: String,
pub addresses: Vec<Address>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Address {
pub public: String,
pub secret: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct WalletBalances {
pub fctaccountbalances: Fctaccountbalances,
pub ecaccountbalances: Ecaccountbalances,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Fctaccountbalances {
pub ack: i64,
pub saved: i64,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Ecaccountbalances {
pub ack: i64,
pub saved: i64,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct SignData {
pub pubkey: String,
pub signature: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Properties {
pub walletversion: String,
pub walletapiversion: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Height {
pub height: i64,
}