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