diff --git a/src/api/recipient.rs b/src/api/recipient.rs index c7b6b7e..00ecd49 100644 --- a/src/api/recipient.rs +++ b/src/api/recipient.rs @@ -29,18 +29,18 @@ pub struct RecipientMemo { } impl RecipientMemo { - pub fn from_recipient(from: &str, r: &Recipient) -> Self { + pub fn from_recipient(from: &str, r: &Recipient) -> anyhow::Result { let memo = if !r.reply_to && r.subject.is_empty() { r.memo.clone() } else { encode_memo(from, r.reply_to, &r.subject, &r.memo) }; - RecipientMemo { + Ok(RecipientMemo { address: r.address.clone(), amount: r.amount, - memo: Memo::from_str(&memo).unwrap(), + memo: Memo::from_str(&memo)?, max_amount_per_note: r.max_amount_per_note, - } + }) } } @@ -107,9 +107,9 @@ pub fn parse_recipients(recipients: &str) -> anyhow::Result> let c = CoinConfig::get_active(); let AccountData { address, .. } = c.db()?.get_account_info(c.id_account)?; let recipients: Vec = serde_json::from_str(recipients)?; - let recipient_memos: Vec<_> = recipients + let recipient_memos: anyhow::Result> = recipients .iter() .map(|r| RecipientMemo::from_recipient(&address, r)) .collect(); - Ok(recipient_memos) + recipient_memos } diff --git a/src/main/rpc.rs b/src/main/rpc.rs index 92da0fd..a1ecff5 100644 --- a/src/main/rpc.rs +++ b/src/main/rpc.rs @@ -15,7 +15,7 @@ use thiserror::Error; use warp_api_ffi::api::payment_uri::PaymentURI; use warp_api_ffi::api::recipient::{Recipient, RecipientMemo, RecipientShort}; use warp_api_ffi::{ - build_tx, get_secret_keys, AccountData, AccountInfo, AccountRec, CoinConfig, KeyPack, + build_tx, get_secret_keys, AccountData, AccountRec, CoinConfig, KeyPack, RaptorQDrops, TransactionPlan, TxRec, }; @@ -104,7 +104,6 @@ async fn main() -> anyhow::Result<()> { split_data, merge_data, derive_keys, - instant_sync, get_tx_plan, build_from_plan, ], @@ -191,9 +190,7 @@ pub fn get_unified_address(t: u8, s: u8, o: u8) -> Result { let address = warp_api_ffi::api::account::get_unified_address( c.coin, c.id_account, - t != 0, - s != 0, - o != 0, + t & s << 1 & o << 2, )?; Ok(address) } @@ -242,7 +239,7 @@ pub async fn create_offline_tx(payment: Json) -> Result = payment + let recipients: anyhow::Result> = payment .recipients .iter() .map(|p| RecipientMemo::from_recipient(&from, p)) @@ -251,7 +248,7 @@ pub async fn create_offline_tx(payment: Json) -> Result, config: &State) -> Result = payment + let recipients: anyhow::Result> = payment .recipients .iter() .map(|p| RecipientMemo::from_recipient(&from, p)) @@ -294,7 +291,7 @@ pub async fn pay(payment: Json, config: &State) -> Result Result<(), Error> { - let c = CoinConfig::get_active(); - let fvk = { - let db = c.db()?; - let AccountData { fvk, .. } = db.get_account_info(c.id_account)?; - fvk - }; - let client = reqwest::Client::new(); - let response = client - .post(format!("https://zec.hanh00.fun/api/scan_fvk?fvk={}", fvk)) - .send() - .await?; - // let r = response.text().await?; - // println!("{}", r); - let account_info: AccountInfo = response.json().await?; - let mut db = c.db().unwrap(); - db.import_from_syncdata(&account_info)?; - Ok(()) -} - #[derive(Deserialize)] #[serde(crate = "rocket::serde")] pub struct Config { diff --git a/src/note_selection/tests.rs b/src/note_selection/tests.rs index c85f678..0b6a320 100644 --- a/src/note_selection/tests.rs +++ b/src/note_selection/tests.rs @@ -728,7 +728,7 @@ fn test_tx_plan() { &Network::MainNetwork, "", 0, - None, + &None, &utxos, &orders, &TransactionBuilderConfig {