Jeiwan / blockchain_go

A simplified blockchain implementation in Golang
4.14k stars 1.17k forks source link

used UTXO_set index directly to set TxInput.Vout was a bug. #54

Open benni82 opened 5 years ago

benni82 commented 5 years ago

acc, validOutputs := UTXOSet.FindSpendableOutputs(pubKeyHash, amount)

    if acc < amount {
        log.Panic("ERROR: Not enough funds")
    }

    // Build a list of inputs
    for txid, outs := range validOutputs {
        txID, err := hex.DecodeString(txid)
        if err != nil {
            log.Panic(err)
        }

        for _, out := range outs {
            input := TXInput{txID, out, nil, wallet.PublicKey}
            inputs = append(inputs, input)
        }
    }

used UTXO_set index directly to set TxInput.Vout was a bug. because exist TxOutput has been used, the TxOutput index is different from UTXO_set index

vectorsss commented 5 years ago

I meet the same problem. By reference to your pull now the problem has been solved. Thank you very much.