OSDN Git Service

Merge pull request #41 from Bytom/dev
[bytom/vapor.git] / claim / bytom / mainchain / data_witness.go
1 package mainchain
2
3 import (
4         "encoding/json"
5
6         chainjson "github.com/vapor/encoding/json"
7 )
8
9 // DataWitness used sign transaction
10 type DataWitness chainjson.HexBytes
11
12 func (dw DataWitness) Materialize(args *[][]byte) error {
13         *args = append(*args, dw)
14         return nil
15 }
16
17 // MarshalJSON marshal DataWitness
18 func (dw DataWitness) MarshalJSON() ([]byte, error) {
19         x := struct {
20                 Type  string             `json:"type"`
21                 Value chainjson.HexBytes `json:"value"`
22         }{
23                 Type:  "data",
24                 Value: chainjson.HexBytes(dw),
25         }
26         return json.Marshal(x)
27 }