add tx retrieval function (#1295)

Web-Wallet support updates
This commit is contained in:
Yeastplume 2018-07-24 20:49:29 +01:00 committed by GitHub
parent 724b19e648
commit 70b97b0a06
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -32,7 +32,7 @@ use keychain::Keychain;
use libtx::slate::Slate; use libtx::slate::Slate;
use libwallet::api::{APIForeign, APIOwner}; use libwallet::api::{APIForeign, APIOwner};
use libwallet::types::{ use libwallet::types::{
BlockFees, CbData, OutputData, SendTXArgs, WalletBackend, WalletClient, WalletInfo, BlockFees, CbData, OutputData, SendTXArgs, TxLogEntry, WalletBackend, WalletClient, WalletInfo,
}; };
use libwallet::{Error, ErrorKind}; use libwallet::{Error, ErrorKind};
@ -166,6 +166,20 @@ where
api.retrieve_outputs(false, update_from_node, None) api.retrieve_outputs(false, update_from_node, None)
} }
fn retrieve_txs(
&self,
req: &mut Request,
api: &mut APIOwner<T, C, K>,
) -> Result<(bool, Vec<TxLogEntry>), Error> {
let mut update_from_node = false;
if let Ok(params) = req.get_ref::<UrlEncodedQuery>() {
if let Some(_) = params.get("refresh") {
update_from_node = true;
}
}
api.retrieve_txs(update_from_node, None)
}
fn retrieve_summary_info( fn retrieve_summary_info(
&self, &self,
req: &mut Request, req: &mut Request,
@ -198,6 +212,8 @@ where
match *path_elems.last().unwrap() { match *path_elems.last().unwrap() {
"retrieve_outputs" => json_response(&self.retrieve_outputs(req, api) "retrieve_outputs" => json_response(&self.retrieve_outputs(req, api)
.map_err(|e| IronError::new(Fail::compat(e), status::BadRequest))?), .map_err(|e| IronError::new(Fail::compat(e), status::BadRequest))?),
"retrieve_txs" => json_response(&self.retrieve_txs(req, api)
.map_err(|e| IronError::new(Fail::compat(e), status::BadRequest))?),
"retrieve_summary_info" => json_response(&self.retrieve_summary_info(req, api) "retrieve_summary_info" => json_response(&self.retrieve_summary_info(req, api)
.map_err(|e| IronError::new(Fail::compat(e), status::BadRequest))?), .map_err(|e| IronError::new(Fail::compat(e), status::BadRequest))?),
"node_height" => json_response(&self.node_height(req, api) "node_height" => json_response(&self.node_height(req, api)