-
Notifications
You must be signed in to change notification settings - Fork 4
/
tx_proposal.go
161 lines (135 loc) · 4.07 KB
/
tx_proposal.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
package api
import (
"strconv"
account "github.com/MixinNetwork/mobilecoin-account"
)
type MaskedValue uint64
func (mv MaskedValue) MarshalJSON() ([]byte, error) {
s := strconv.FormatUint(uint64(mv), 10)
return []byte(strconv.Quote(s)), nil
}
func (mv *MaskedValue) UnmarshalJSON(data []byte) error {
dd, err := strconv.Unquote(string(data))
if err != nil {
return err
}
u, err := strconv.ParseUint(dd, 10, 64)
if err != nil {
return err
}
*mv = MaskedValue(u)
return nil
}
type FeeValue uint64
func (fv FeeValue) MarshalJSON() ([]byte, error) {
s := strconv.FormatUint(uint64(fv), 10)
return []byte(strconv.Quote(s)), nil
}
func (fv *FeeValue) UnmarshalJSON(data []byte) error {
dd, err := strconv.Unquote(string(data))
if err != nil {
return err
}
u, err := strconv.ParseUint(dd, 10, 64)
if err != nil {
return err
}
*fv = FeeValue(u)
return nil
}
type TombstoneValue uint64
func (tv TombstoneValue) MarshalJSON() ([]byte, error) {
s := strconv.FormatUint(uint64(tv), 10)
return []byte(strconv.Quote(s)), nil
}
func (tv *TombstoneValue) UnmarshalJSON(data []byte) error {
dd, err := strconv.Unquote(string(data))
if err != nil {
return err
}
u, err := strconv.ParseUint(dd, 10, 64)
if err != nil {
return err
}
*tv = TombstoneValue(u)
return nil
}
type Amount struct {
Commitment string `json:"commitment"`
MaskedValue MaskedValue `json:"masked_value"`
MaskedTokenID string `json:"masked_token_id"`
Version int64 `json:"version"`
}
type TxOut struct {
Amount *Amount `json:"masked_amount"`
TargetKey string `json:"target_key"`
PublicKey string `json:"public_key"`
EFogHint string `json:"e_fog_hint"`
EMemo string `json:"e_memo"`
}
type Range struct {
From string `json:"from"`
To string `json:"to"`
}
type TxOutMembershipElement struct {
Range *Range `json:"range"`
Hash string `json:"hash"`
}
type TxOutMembershipProof struct {
Index string `json:"index"`
HighestIndex string `json:"highest_index"`
Elements []*TxOutMembershipElement `json:"elements"`
}
type TxOutWithProof struct {
TxOut *TxOut `json:"tx_out"`
Proof *TxOutMembershipProof `json:"proof"`
}
type Proofs struct {
Ring []*TxOutWithProof `json:"ring"`
Rings [][]*TxOutWithProof `json:"rings"`
}
type TxIn struct {
Ring []*TxOut `json:"ring"`
Proofs []*TxOutMembershipProof `json:"proofs"`
}
type TxPrefix struct {
Inputs []*TxIn `json:"inputs"`
Outputs []*TxOut `json:"outputs"`
Fee FeeValue `json:"fee"`
TombstoneBlock TombstoneValue `json:"tombstone_block"`
}
type RingMLSAG struct {
CZero string `json:"c_zero"`
Responses []string `json:"responses"`
KeyImage string `json:"key_image"`
}
type SignatureRctBulletproofs struct {
RingSignatures []*RingMLSAG `json:"ring_signatures"`
PseudoOutputCommitments []string `json:"pseudo_output_commitments"`
RangeProofs string `json:"range_proofs"`
}
type Tx struct {
Prefix *TxPrefix `json:"prefix"`
Signature *SignatureRctBulletproofs `json:"signature"`
}
type UnspentTxOut struct {
TxOut *TxOut `json:"tx_out"`
SubaddressIndex uint64 `json:"subaddress_index"`
KeyImage string `json:"key_image"`
Value string `json:"value"`
AttemptedSpendHeight uint64 `json:"attempted_spend_height"`
AttemptedSpendTombstone uint64 `json:"attempted_spend_tombstone"`
MonitorId string `json:"monitor_id"`
}
type Outlay struct {
Value string `json:"value"`
Receiver *account.PublicAddress `json:"receiver"`
}
type TxProposal struct {
InputList []*UnspentTxOut `json:"input_list"`
OutlayList []*Outlay `json:"outlay_list"`
Tx *Tx `json:"tx"`
Fee uint64 `json:"fee"`
OutlayIndexToTxOutIndex [][]int `json:"outlay_index_to_tx_out_index"`
OutlayConfirmationNumbers [][]int `json:"outlay_confirmation_numbers"`
}