From e9922f9fe37a58ae69399265f3e05dcd391b2da4 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 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/node/rest/src/routes.rs b/node/rest/src/routes.rs index 9146beb70c..9459105c31 100644 --- a/node/rest/src/routes.rs +++ b/node/rest/src/routes.rs @@ -313,6 +313,10 @@ 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.