Implement TXOutputs

This commit is contained in:
Ivan Kuznetsov 2017-09-17 10:15:58 +07:00
parent 01b9dd2eab
commit 2f54328190
1 changed files with 23 additions and 1 deletions

View File

@ -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()
}