add Address in TXOut
This commit is contained in:
parent
36cfffcb64
commit
01d18ce4d5
|
@ -105,6 +105,7 @@ func (tx Transaction) String() string {
|
||||||
lines = append(lines, fmt.Sprintf(" Output %d:", i))
|
lines = append(lines, fmt.Sprintf(" Output %d:", i))
|
||||||
lines = append(lines, fmt.Sprintf(" Value: %d", output.Value))
|
lines = append(lines, fmt.Sprintf(" Value: %d", output.Value))
|
||||||
lines = append(lines, fmt.Sprintf(" Script: %x", output.PubKeyHash))
|
lines = append(lines, fmt.Sprintf(" Script: %x", output.PubKeyHash))
|
||||||
|
lines = append(lines, fmt.Sprintf(" Addr : %s", output.Address))
|
||||||
}
|
}
|
||||||
|
|
||||||
return strings.Join(lines, "\n")
|
return strings.Join(lines, "\n")
|
||||||
|
@ -120,7 +121,7 @@ func (tx *Transaction) TrimmedCopy() Transaction {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, vout := range tx.Vout {
|
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}
|
txCopy := Transaction{tx.ID, inputs, outputs}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
type TXOutput struct {
|
type TXOutput struct {
|
||||||
Value int
|
Value int
|
||||||
PubKeyHash []byte
|
PubKeyHash []byte
|
||||||
|
Address string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lock signs the output
|
// Lock signs the output
|
||||||
|
@ -26,7 +27,7 @@ func (out *TXOutput) IsLockedWithKey(pubKeyHash []byte) bool {
|
||||||
|
|
||||||
// NewTXOutput create a new TXOutput
|
// NewTXOutput create a new TXOutput
|
||||||
func NewTXOutput(value int, address string) *TXOutput {
|
func NewTXOutput(value int, address string) *TXOutput {
|
||||||
txo := &TXOutput{value, nil}
|
txo := &TXOutput{value, nil, address}
|
||||||
txo.Lock([]byte(address))
|
txo.Lock([]byte(address))
|
||||||
|
|
||||||
return txo
|
return txo
|
||||||
|
|
Loading…
Reference in New Issue