7 "github.com/vapor/crypto/ed25519/chainkd"
8 chainjson "github.com/vapor/encoding/json"
9 "github.com/vapor/protocol/bc"
10 bytomtypes "github.com/vapor/protocol/bc/types/bytom/types"
13 // Template represents a partially- or fully-signed transaction.
14 type Template struct {
15 Transaction *bytomtypes.Tx `json:"raw_transaction"`
16 SigningInstructions []*SigningInstruction `json:"signing_instructions"`
18 // AllowAdditional affects whether Sign commits to the tx sighash or
19 // to individual details of the tx so far. When true, signatures
20 // commit to tx details, and new details may be added but existing
21 // ones cannot be changed. When false, signatures commit to the tx
22 // as a whole, and any change to the tx invalidates the signature.
23 AllowAdditional bool `json:"allow_additional_actions"`
26 // Hash return sign hash
27 func (t *Template) Hash(idx uint32) bc.Hash {
28 return t.Transaction.SigHash(idx)
31 // Action is a interface
32 type Action interface {
33 Build(context.Context, *TemplateBuilder) error
36 // Receiver encapsulates information about where to send assets.
37 type Receiver struct {
38 ControlProgram chainjson.HexBytes `json:"control_program,omitempty"`
39 Address string `json:"address,omitempty"`
42 // ContractArgument for smart contract
43 type ContractArgument struct {
44 Type string `json:"type"`
45 RawData json.RawMessage `json:"raw_data"`
48 // RawTxSigArgument is signature-related argument for run contract
49 type RawTxSigArgument struct {
50 RootXPub chainkd.XPub `json:"xpub"`
51 Path []chainjson.HexBytes `json:"derivation_path"`
54 // DataArgument is the other argument for run contract
55 type DataArgument struct {
56 Value string `json:"value"`