From ab4822c660e1422de94b3dce3ae31be010cdafd9 Mon Sep 17 00:00:00 2001 From: "hinto.janai" Date: Fri, 13 Dec 2024 15:16:26 -0500 Subject: [PATCH] !! --- binaries/cuprated/src/rpc/other.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/binaries/cuprated/src/rpc/other.rs b/binaries/cuprated/src/rpc/other.rs index 8bdf727..03597ba 100644 --- a/binaries/cuprated/src/rpc/other.rs +++ b/binaries/cuprated/src/rpc/other.rs @@ -142,19 +142,26 @@ async fn get_transactions( txpool::txs_by_hash(&mut state.txpool_read, missed_txs, include_sensitive_txs).await? }; - let (txs, txs_as_json) = { + let (txs, txs_as_json, txs_as_hex) = { // Prepare the final JSON output. let len = txs_in_blockchain.len() + txs_in_pool.len(); let mut txs = Vec::with_capacity(len); let mut txs_as_json = Vec::with_capacity(if request.decode_as_json { len } else { 0 }); + let mut txs_as_hex = vec![]; // Map all blockchain transactions. for tx in txs_in_blockchain { let tx_hash = Hex(tx.tx_hash); - let pruned_as_hex = hex::encode(tx.pruned_blob); - let prunable_as_hex = hex::encode(tx.prunable_blob); let prunable_hash = Hex(tx.prunable_hash); + let (pruned_as_hex, prunable_as_hex) = if tx.pruned_blob.is_empty() { + (String::new(), String::new()) + } else { + (hex::encode(tx.pruned_blob), hex::encode(tx.prunable_blob)) + }; + + txs_as_hex.push(pruned_as_hex.clone()); + let as_json = if request.decode_as_json { let tx = Transaction::read(&mut tx.tx_blob.as_slice())?; let json_type = cuprate_types::json::tx::Transaction::from(tx); @@ -204,6 +211,7 @@ async fn get_transactions( let pruned_as_hex = String::new(); let prunable_as_hex = String::new(); let prunable_hash = Hex([0; 32]); + txs_as_hex.push(pruned_as_hex.clone()); let as_json = if request.decode_as_json { let json_type = cuprate_types::json::tx::Transaction::from(tx); @@ -234,12 +242,12 @@ async fn get_transactions( txs.push(tx); } - (txs, txs_as_json) + (txs, txs_as_json, txs_as_hex) }; Ok(GetTransactionsResponse { base: AccessResponseBase::OK, - txs_as_hex: vec![], + txs_as_hex, txs_as_json, missed_tx, txs,