+var outputTypeMap = map[uint8]func() TypedOutput{
+ OriginalOutputType: func() TypedOutput { return &originalTxOutput{} },
+ VoteOutputType: func() TypedOutput { return &VoteOutput{} },
+}
+
+func parseTypedOutput(r *blockchain.Reader) (TypedOutput, error) {
+ var outType [1]byte
+ if _, err := io.ReadFull(r, outType[:]); err != nil {
+ return nil, errors.Wrap(err, "reading output type")
+ }
+
+ newOutFun, ok := outputTypeMap[outType[0]]
+ if !ok {
+ return nil, fmt.Errorf("unsupported output type %d", outType[0])
+ }
+
+ return newOutFun(), nil
+}
+