From 54466417d0fa575fb979b0fe7e587c08c286dae3 Mon Sep 17 00:00:00 2001 From: Haruka Date: Tue, 30 Jan 2024 20:03:33 +0900 Subject: [PATCH] check transaction before broadcasting / accepting --- node/rest/src/routes.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/node/rest/src/routes.rs b/node/rest/src/routes.rs index 9146beb70c..ee3367254e 100644 --- a/node/rest/src/routes.rs +++ b/node/rest/src/routes.rs @@ -313,6 +313,11 @@ impl, R: Routing> Rest { State(rest): State, Json(tx): Json>, ) -> Result { + // Check if the transaction is well-formed. + rest.ledger + .check_transaction_basic(&tx, None, &mut rand::thread_rng()) + .map_err(|e| RestError(format!("Invalid transaction: {e}")))?; + // If the consensus module is enabled, add the unconfirmed transaction to the memory pool. if let Some(consensus) = rest.consensus { // Add the unconfirmed transaction to the memory pool.