Implement TXOutputs
This commit is contained in:
parent
01b9dd2eab
commit
2f54328190
|
@ -1,6 +1,10 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "bytes"
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/gob"
|
||||||
|
"log"
|
||||||
|
)
|
||||||
|
|
||||||
// TXOutput represents a transaction output
|
// TXOutput represents a transaction output
|
||||||
type TXOutput struct {
|
type TXOutput struct {
|
||||||
|
@ -27,3 +31,21 @@ func NewTXOutput(value int, address string) *TXOutput {
|
||||||
|
|
||||||
return txo
|
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()
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue