Fix some initializations

This commit is contained in:
Ivan Kuznetsov 2017-09-10 14:11:21 +07:00
parent bf8c5d22e1
commit 7b6d5695d3
1 changed files with 5 additions and 5 deletions

View File

@ -70,10 +70,10 @@ func (tx *Transaction) Sign(privKey ecdsa.PrivateKey, prevTXs map[string]Transac
for inID, vin := range txCopy.Vin {
prevTx := prevTXs[hex.EncodeToString(vin.Txid)]
txCopy.Vin[inID].Signature = []byte{}
txCopy.Vin[inID].Signature = nil
txCopy.Vin[inID].PubKey = prevTx.Vout[vin.Vout].PubKeyHash
txCopy.ID = txCopy.Hash()
txCopy.Vin[inID].PubKey = []byte{}
txCopy.Vin[inID].PubKey = nil
r, s, err := ecdsa.Sign(rand.Reader, &privKey, txCopy.ID)
if err != nil {
@ -115,7 +115,7 @@ func (tx *Transaction) TrimmedCopy() Transaction {
var outputs []TXOutput
for _, vin := range tx.Vin {
inputs = append(inputs, TXInput{vin.Txid, vin.Vout, []byte{}})
inputs = append(inputs, TXInput{vin.Txid, vin.Vout, nil, nil})
}
for _, vout := range tx.Vout {
@ -176,7 +176,7 @@ func NewCoinbaseTX(to, data string) *Transaction {
data = fmt.Sprintf("Reward to '%s'", to)
}
txin := TXInput{[]byte{}, -1, []byte(data)}
txin := TXInput{[]byte{}, -1, nil, []byte(data)}
txout := NewTXOutput(subsidy, to)
tx := Transaction{nil, []TXInput{txin}, []TXOutput{*txout}}
tx.ID = tx.Hash()
@ -209,7 +209,7 @@ func NewUTXOTransaction(from, to string, amount int, bc *Blockchain) *Transactio
}
for _, out := range outs {
input := TXInput{txID, out, wallet.PublicKey}
input := TXInput{txID, out, nil, wallet.PublicKey}
inputs = append(inputs, input)
}
}