From 9965826ede044fedb8c97c3fa9f879db1f51f8d2 Mon Sep 17 00:00:00 2001 From: lance Date: Wed, 8 Apr 2020 17:21:33 -0700 Subject: [PATCH] pulling extra info for tx --- src/data_types.rs | 18 +++++++++++++----- src/main.rs | 10 ++++++++-- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/data_types.rs b/src/data_types.rs index 0cc7a46..646842b 100644 --- a/src/data_types.rs +++ b/src/data_types.rs @@ -128,6 +128,14 @@ pub struct GetTransactionsTxs { pub double_spend_seen: bool, pub in_pool: bool, pub output_indices: Option>, + pub as_json: String, + pub as_json_full: Option +} + +impl GetTransactionsTxs { + pub fn process(&mut self) { + self.as_json_full = Some(serde_json::from_str(&self.as_json).unwrap()) + } } #[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug)] @@ -199,19 +207,19 @@ pub struct TransactionJSON { #[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug)] pub struct TransactionInputs { - pub key: PreviousTransactionKey + pub key: Option } #[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug)] pub struct PreviousTransactionKey { - pub amount: u32, + pub amount: u64, pub key_offsets: Vec, pub k_image: String } #[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug)] pub struct TransactionOutputs { - pub amount: u32, + pub amount: u64, pub target: OutputStealthAddress } @@ -223,6 +231,6 @@ pub struct OutputStealthAddress { #[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug)] pub struct RingSignatures { pub r#type: u32, - pub txnFee: u64, - pub outPk: Vec + pub txnFee: Option, + pub outPk: Option> } diff --git a/src/main.rs b/src/main.rs index eae9324..57dcf9a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -88,9 +88,15 @@ fn get_block_by_height(block_height: String) -> Template { #[get("/transaction/")] fn get_transaction_by_hash(tx_hash: String) -> Template { - let params: JsonValue = json!({"txs_hashes": [&tx_hash]}); - let res: GetTransactions = issue_raw_rpc(&"get_transactions", params) + let params: JsonValue = json!({ + "txs_hashes": [&tx_hash], + "decode_as_json": true + }); + let mut res: GetTransactions = issue_raw_rpc(&"get_transactions", params) .send().unwrap().json().unwrap(); + for f in &mut res.txs { + f.process(); + }; let context = json!({ "tx_info": res.txs, "tx_hash": tx_hash