From ee900c24cde88c67f5e705db80b19356967fa488 Mon Sep 17 00:00:00 2001 From: Pol Espinasa Date: Tue, 30 Apr 2024 20:41:24 +0200 Subject: [PATCH] Don't assume tx have one input and one output --- server/grouphug-server/src/main.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/server/grouphug-server/src/main.rs b/server/grouphug-server/src/main.rs index a22c90e..8457e8e 100644 --- a/server/grouphug-server/src/main.rs +++ b/server/grouphug-server/src/main.rs @@ -70,19 +70,19 @@ fn check_double_spending_other_group(tx_hex: &str) -> (bool, String) { }; - // We asume we will never see a transaction with more than one input - // (This is checked before this function is called) - let txin = &tx.input[0]; - // Lock the global groups and iterate over them let groups = GLOBAL_GROUPS.lock().unwrap(); - for group in groups.iter() { - // Checks if a tx input is in the group - if group.contains_txin(&txin) { - eprintln!("Transaction was rejected, Error: transaction input is already in a group\n"); - return (true, String::from("Transaction input is already in a group")); + + for txin in tx.input.iter(){ + for group in groups.iter() { + // Checks if a tx input is in the group + if group.contains_txin(&txin) { + eprintln!("Transaction was rejected, Error: transaction input is already in a group\n"); + return (true, String::from("Transaction input is already in a group")); + } } } + return (false, String::from("Ok\n"));