pulling extra info for tx

master
lance 5 years ago
parent 8465ac9f69
commit 9965826ede

@ -128,6 +128,14 @@ pub struct GetTransactionsTxs {
pub double_spend_seen: bool, pub double_spend_seen: bool,
pub in_pool: bool, pub in_pool: bool,
pub output_indices: Option<Vec<u32>>, pub output_indices: Option<Vec<u32>>,
pub as_json: String,
pub as_json_full: Option<TransactionJSON>
}
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)] #[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug)]
@ -199,19 +207,19 @@ pub struct TransactionJSON {
#[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug)] #[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug)]
pub struct TransactionInputs { pub struct TransactionInputs {
pub key: PreviousTransactionKey pub key: Option<PreviousTransactionKey>
} }
#[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug)] #[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug)]
pub struct PreviousTransactionKey { pub struct PreviousTransactionKey {
pub amount: u32, pub amount: u64,
pub key_offsets: Vec<u32>, pub key_offsets: Vec<u32>,
pub k_image: String pub k_image: String
} }
#[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug)] #[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug)]
pub struct TransactionOutputs { pub struct TransactionOutputs {
pub amount: u32, pub amount: u64,
pub target: OutputStealthAddress pub target: OutputStealthAddress
} }
@ -223,6 +231,6 @@ pub struct OutputStealthAddress {
#[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug)] #[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug)]
pub struct RingSignatures { pub struct RingSignatures {
pub r#type: u32, pub r#type: u32,
pub txnFee: u64, pub txnFee: Option<u64>,
pub outPk: Vec<String> pub outPk: Option<Vec<String>>
} }

@ -88,9 +88,15 @@ fn get_block_by_height(block_height: String) -> Template {
#[get("/transaction/<tx_hash>")] #[get("/transaction/<tx_hash>")]
fn get_transaction_by_hash(tx_hash: String) -> Template { fn get_transaction_by_hash(tx_hash: String) -> Template {
let params: JsonValue = json!({"txs_hashes": [&tx_hash]}); let params: JsonValue = json!({
let res: GetTransactions = issue_raw_rpc(&"get_transactions", params) "txs_hashes": [&tx_hash],
"decode_as_json": true
});
let mut res: GetTransactions = issue_raw_rpc(&"get_transactions", params)
.send().unwrap().json().unwrap(); .send().unwrap().json().unwrap();
for f in &mut res.txs {
f.process();
};
let context = json!({ let context = json!({
"tx_info": res.txs, "tx_info": res.txs,
"tx_hash": tx_hash "tx_hash": tx_hash

Loading…
Cancel
Save