diff --git a/transaction_output.go b/transaction_output.go index 4d70d74..34dabad 100644 --- a/transaction_output.go +++ b/transaction_output.go @@ -1,6 +1,10 @@ package main -import "bytes" +import ( + "bytes" + "encoding/gob" + "log" +) // TXOutput represents a transaction output type TXOutput struct { @@ -27,3 +31,21 @@ func NewTXOutput(value int, address string) *TXOutput { return txo } + +// TXOutputs collects TXOutput +type TXOutputs struct { + Outputs []TXOutput +} + +// Serialize serializes TXOutputs +func (outs TXOutputs) Serialize() []byte { + var buff bytes.Buffer + + enc := gob.NewEncoder(&buff) + err := enc.Encode(outs) + if err != nil { + log.Panic(err) + } + + return buff.Bytes() +}