forked from ArkEcosystem/go-crypto
/
structs.go
143 lines (123 loc) · 4.5 KB
/
structs.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// This file is part of PHANTOM Go Crypto.
//
// (c) PhantomChain <info@phantom.org>
//
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
package crypto
import (
"encoding/json"
"strconv"
"time"
"github.com/btcsuite/btcd/btcec"
)
type FlexToshi uint64
type Network struct {
Epoch time.Time
Version byte
Wif byte
}
type PrivateKey struct {
*btcec.PrivateKey
PublicKey *PublicKey
}
type PublicKey struct {
*btcec.PublicKey
isCompressed bool
Network *Network
}
type TransactionTypes struct {
Transfer byte
SecondSignatureRegistration byte
DelegateRegistration byte
Vote byte
MultiSignatureRegistration byte
Ipfs byte
TimelockTransfer byte
MultiPayment byte
DelegateResignation byte
}
type TransactionFees struct {
Transfer FlexToshi
SecondSignatureRegistration FlexToshi
DelegateRegistration FlexToshi
Vote FlexToshi
MultiSignatureRegistration FlexToshi
Ipfs FlexToshi
TimelockTransfer FlexToshi
MultiPayment FlexToshi
DelegateResignation FlexToshi
}
func (fi *FlexToshi) UnmarshalJSON(b []byte) error {
if b[0] != '"' {
return json.Unmarshal(b, (*uint64)(fi))
}
var s string
if err := json.Unmarshal(b, &s); err != nil {
return err
}
i, err := strconv.ParseInt(s, 10, 64)
if err != nil {
return err
}
*fi = FlexToshi(i)
return nil
}
type Transaction struct {
Amount FlexToshi `json:"amount,omitempty"`
Asset *TransactionAsset `json:"asset,omitempty"`
Expiration uint32 `json:"expiration,omitempty"`
Fee FlexToshi `json:"fee,omitempty"`
Id string `json:"id,omitempty"`
Network byte `json:"network,omitempty"`
RecipientId string `json:"recipientId,omitempty"`
SecondSenderPublicKey string `json:"secondSenderPublicKey,omitempty"`
SecondSignature string `json:"secondSignature,omitempty"`
SenderPublicKey string `json:"senderPublicKey,omitempty"`
Serialized string `json:"serialized,omitempty"`
Signature string `json:"signature,omitempty"`
Signatures []string `json:"signatures,omitempty"`
SignSignature string `json:"signSignature,omitempty"`
Timelock uint32 `json:"timelock,omitempty"`
TimelockType string `json:"timelockType,omitempty"`
Timestamp int32 `json:"timestamp,omitempty"`
Type byte `json:"type"`
VendorField string `json:"vendorField,omitempty"`
VendorFieldHex string `json:"vendorFieldHex,omitempty"`
Version byte `json:"version,omitempty"`
}
type Message struct {
Message string `json:"message"`
PublicKey string `json:"publickey"`
Signature string `json:"signature"`
}
////////////////////////////////////////////////////////////////////////////////
// TRANSACTION ASSETS //////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
type TransactionAsset struct {
Votes []string `json:"votes,omitempty"`
Dag string `json:"dag,omitempty"`
Signature *SecondSignatureRegistrationAsset `json:"signature,omitempty"`
Delegate *DelegateAsset `json:"delegate,omitempty"`
MultiSignature *MultiSignatureRegistrationAsset `json:"multisignature,omitempty"`
Ipfs *IpfsAsset `json:"ipfs,omitempty"`
Payments []*MultiPaymentAsset `json:"payments,omitempty"`
}
type SecondSignatureRegistrationAsset struct {
PublicKey string `json:"publicKey,omitempty"`
}
type DelegateAsset struct {
Username string `json:"username,omitempty"`
}
type MultiSignatureRegistrationAsset struct {
Min byte `json:"min,omitempty"`
Keysgroup []string `json:"keysgroup,omitempty"`
Lifetime byte `json:"lifetime,omitempty"`
}
type IpfsAsset struct {
Dag string `json:"dag,omitempty"`
}
type MultiPaymentAsset struct {
Amount FlexToshi `json:"amount,omitempty"`
RecipientId string `json:"recipientId,omitempty"`
}