add Address in TXOut

This commit is contained in:
Wei Yang 2017-10-19 21:48:55 +08:00
parent 36cfffcb64
commit 01d18ce4d5
2 changed files with 4 additions and 2 deletions

View File

@ -105,6 +105,7 @@ func (tx Transaction) String() string {
lines = append(lines, fmt.Sprintf(" Output %d:", i))
lines = append(lines, fmt.Sprintf(" Value: %d", output.Value))
lines = append(lines, fmt.Sprintf(" Script: %x", output.PubKeyHash))
lines = append(lines, fmt.Sprintf(" Addr : %s", output.Address))
}
return strings.Join(lines, "\n")
@ -120,7 +121,7 @@ func (tx *Transaction) TrimmedCopy() Transaction {
}
for _, vout := range tx.Vout {
outputs = append(outputs, TXOutput{vout.Value, vout.PubKeyHash})
outputs = append(outputs, TXOutput{vout.Value, vout.PubKeyHash, vout.Address})
}
txCopy := Transaction{tx.ID, inputs, outputs}

View File

@ -10,6 +10,7 @@ import (
type TXOutput struct {
Value int
PubKeyHash []byte
Address string
}
// Lock signs the output
@ -26,7 +27,7 @@ func (out *TXOutput) IsLockedWithKey(pubKeyHash []byte) bool {
// NewTXOutput create a new TXOutput
func NewTXOutput(value int, address string) *TXOutput {
txo := &TXOutput{value, nil}
txo := &TXOutput{value, nil, address}
txo.Lock([]byte(address))
return txo