OSDN Git Service

Address (#213)
[bytom/bytom.git] / blockchain / txbuilder / data_witness.go
1 package txbuilder
2
3 import (
4         "encoding/json"
5
6         chainjson "github.com/bytom/encoding/json"
7 )
8
9 type DataWitness chainjson.HexBytes
10
11 func (dw DataWitness) materialize(args *[][]byte) error {
12         *args = append(*args, dw)
13         return nil
14 }
15
16 func (dw DataWitness) MarshalJSON() ([]byte, error) {
17         x := struct {
18                 Type  string             `json:"type"`
19                 Value chainjson.HexBytes `json:"value"`
20         }{
21                 Type:  "data",
22                 Value: chainjson.HexBytes(dw),
23         }
24         return json.Marshal(x)
25 }