OP_EQUALVERIFY Problem
So... I found out what was wrong. The problem was in this part of the code when i was adding the inputs. I was adding an index to each input based on which number of input it was. 

for(var a = 0; a &lt; input_utxos.length ; a++){
    tx.addInput(input_utxos[a].tx,a)
    sum_outputs+=parseInt(input_utxos[a].amount);
}


but the index i was supossed to send was actually the index on the transaction outputs. so it had to be like this

for(var a = 0; a &lt; input_utxos.length ; a++){
    tx.addInput(input_utxos[a].tx,input_utxos[a].n)
    sum_outputs+=parseInt(input_utxos[a].amount);
}


The index was gettable from the api that provided me all the utxos for an account. In this case, it was called n and was inside the transaction object itself.