github.com/Bytom/bytom@v1.1.2-0.20210127130405-ae40204c0b09/blockchain/txbuilder/data_witness.go (about)

     1  package txbuilder
     2  
     3  import (
     4  	"encoding/json"
     5  
     6  	chainjson "github.com/bytom/bytom/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  }