diff --git a/Cargo.lock b/Cargo.lock index e128344af5..5a48731351 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4330,7 +4330,7 @@ dependencies = [ "config", "either", "futures 0.3.17", - "log 0.4.14", + "log", "log-mdc", "num_cpus", "opentelemetry", @@ -4441,7 +4441,7 @@ dependencies = [ "futures 0.3.17", "lazy_static 1.4.0", "lmdb-zero", - "log 0.4.14", + "log", "log-mdc", "multiaddr", "nom 5.1.2", @@ -4493,7 +4493,7 @@ dependencies = [ "lazy_static 1.4.0", "libsqlite3-sys", "lmdb-zero", - "log 0.4.14", + "log", "log-mdc", "petgraph", "pin-project 0.4.28", @@ -4599,7 +4599,7 @@ dependencies = [ "integer-encoding 3.0.2", "lazy_static 1.4.0", "lmdb-zero", - "log 0.4.14", + "log", "log-mdc", "monero", "newtype-ops", diff --git a/applications/tari_stratum_transcoder/src/proxy.rs b/applications/tari_stratum_transcoder/src/proxy.rs index c3ce03ee56..613d3ca66b 100644 --- a/applications/tari_stratum_transcoder/src/proxy.rs +++ b/applications/tari_stratum_transcoder/src/proxy.rs @@ -480,6 +480,64 @@ impl InnerService { proxy::json_response(StatusCode::OK, &json_response) } + async fn handle_get_fee( + &self, + request: Request, + ) -> Result, StratumTranscoderProxyError> { + let request = request.body(); + let transactions = match request["params"]["transactions"].as_array() { + Some(v) => v, + None => { + return proxy::json_response( + StatusCode::OK, + &json_rpc::error_response( + request["id"].as_i64(), + 1, + "`transactions` field is empty or an invalid type for transfer request.", + None, + ), + ) + }, + }; + + let mut grpc_transaction_info = Vec::new(); + for transaction in transactions.iter() { + grpc_transaction_info.push( + transaction["transaction_id"] + .as_str() + .unwrap() + .to_string() + .parse::() + .unwrap(), + ); + } + + let mut client = self.wallet_client.clone(); + + let transaction_info_results = client + .get_transaction_info(grpc::GetTransactionInfoRequest { + transaction_ids: grpc_transaction_info, + }) + .await? + .into_inner(); + let info_results = &transaction_info_results.transactions; + + let mut results = Vec::new(); + for info_result in info_results.iter() { + let result = json!({ + "transaction_id": info_result.tx_id, + "fee": info_result.fee, + }); + results.push(result.as_object().unwrap().clone()); + } + + let json_response = json!({ + "jsonrpc": "2.0", + "result": {"fee_results" : results}, + }); + proxy::json_response(StatusCode::OK, &json_response) + } + async fn handle_transfer( &self, request: Request, @@ -586,6 +644,7 @@ impl InnerService { "getlastblockheader" | "get_last_block_header" => self.handle_get_last_block_header(request).await, "transfer" => self.handle_transfer(request).await, "getbalance" | "get_balance" => self.handle_get_balance(request).await, + "getfee" | "get_fee" => self.handle_get_fee(request).await, _ => { let request = request.body(); proxy_resp = Response::new(standard_error_response(