Give tx fee in /transaction

This commit is contained in:
Artur
2025-06-05 16:25:39 -03:00
parent b7f0c23975
commit 755303a470
3 changed files with 11 additions and 0 deletions

1
Cargo.lock generated
View File

@@ -1948,6 +1948,7 @@ dependencies = [
"clap",
"cuprate-blockchain",
"cuprate-database",
"cuprate-helper",
"cuprate-types",
"derive_more",
"hex",

View File

@@ -7,6 +7,7 @@ edition = "2024"
cuprate-blockchain = { path = "./external/cuprate/storage/blockchain", features = ["serde"] }
cuprate-database = { path = "./external/cuprate/storage/database", features = ["serde"] }
cuprate-types = { path = "./external/cuprate/types/types", features = ["serde"] }
cuprate-helper = { path = "./external/cuprate/helper", features = ["serde"] }
monero-serai = { git = "https://github.com/Cuprate/serai.git", rev = "e6ae8c2", default-features = false }
hex = "0.4.3"
actix-web = "4.10.2"

View File

@@ -1,5 +1,6 @@
use cuprate_blockchain::{config::ConfigBuilder, ops, tables::{OpenTables, Tables}, types::PreRctOutputId} ;
use cuprate_database::{ConcreteEnv, DatabaseRo, Env, EnvInner, RuntimeError};
use cuprate_helper::tx::tx_fee;
use cuprate_types::json::tx::Transaction;
use hex::{FromHex, FromHexError};
use actix_web::{error, get, http::StatusCode, web::{self}, App, HttpResponse, HttpServer, Responder};
@@ -101,6 +102,7 @@ struct TransactionResponse {
pub confirmation_height: usize,
pub timestamp: u64,
pub weight: usize,
pub fee: u64,
pub inputs: Vec<TransactionInput>,
pub outputs: Vec<TransactionOutput>,
pub extra: String,
@@ -152,6 +154,7 @@ async fn get_tx(
}
)?;
let mixin_tx_block = new_tables.block_infos().get(&(output.height as usize))?;
let mixin_tx_hash: [u8; 32] = if output.tx_idx == mixin_tx_block.mining_tx_index {
let tx_blob = new_tables.tx_blobs().get(&output.tx_idx)?;
@@ -195,6 +198,8 @@ async fn get_tx(
})
}
let fee = tx_fee(&tx);
TransactionResponse {
hash: tx_hash.clone(),
version: prefix.version,
@@ -203,6 +208,7 @@ async fn get_tx(
confirmation_height: tx_height,
timestamp: tx_block.timestamp,
weight: tx.weight(),
fee,
extra: hex::encode(prefix.extra),
outputs,
inputs: inputs?,
@@ -268,6 +274,8 @@ async fn get_tx(
})
}
let fee = tx_fee(&tx);
TransactionResponse {
hash: tx_hash.clone(),
version: prefix.version,
@@ -276,6 +284,7 @@ async fn get_tx(
confirmation_height: tx_height,
timestamp: tx_block.timestamp,
weight: tx.weight(),
fee,
extra: hex::encode(prefix.extra),
outputs,
inputs: inputs?,