7 "github.com/vapor/crypto/ed25519/chainkd"
8 chainjson "github.com/vapor/encoding/json"
9 "github.com/vapor/protocol/bc"
10 "github.com/vapor/protocol/bc/types"
13 // Template represents a partially- or fully-signed transaction.
14 type Template struct {
15 Transaction *types.Tx `json:"raw_transaction"`
16 SigningInstructions []*SigningInstruction `json:"signing_instructions"`
17 Fee uint64 `json:"fee"`
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
37 // Receiver encapsulates information about where to send assets.
38 type Receiver struct {
39 ControlProgram chainjson.HexBytes `json:"control_program,omitempty"`
40 Address string `json:"address,omitempty"`
43 // ContractArgument for smart contract
44 type ContractArgument struct {
45 Type string `json:"type"`
46 RawData json.RawMessage `json:"raw_data"`
49 // RawTxSigArgument is signature-related argument for run contract
50 type RawTxSigArgument struct {
51 RootXPub chainkd.XPub `json:"xpub"`
52 Path []chainjson.HexBytes `json:"derivation_path"`
55 // DataArgument is the other argument for run contract
56 type DataArgument struct {
57 Value chainjson.HexBytes `json:"value"`
60 // StrArgument is the string argument for run contract
61 type StrArgument struct {
62 Value string `json:"value"`
65 // IntegerArgument is the integer argument for run contract
66 type IntegerArgument struct {
67 Value int64 `json:"value"`
70 // BoolArgument is the boolean argument for run contract
71 type BoolArgument struct {
72 Value bool `json:"value"`
75 // ContractArgument for smart contract
76 type IpfsData struct {
77 Type string `json:"type"`
78 Data string `json:"data"`