Skip to content

Commit

Permalink
Don't assume tx have one input and one output
Browse files Browse the repository at this point in the history
  • Loading branch information
polespinasa committed Apr 30, 2024
1 parent 7fbae41 commit ee900c2
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions server/grouphug-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));

Expand Down

0 comments on commit ee900c2

Please sign in to comment.