forked from stellar/go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xdr_generated.go
8124 lines (7140 loc) · 206 KB
/
xdr_generated.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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Package xdr is generated from:
//
// xdr/Stellar-types.x
// xdr/Stellar-ledger-entries.x
// xdr/Stellar-transaction.x
// xdr/Stellar-ledger.x
// xdr/Stellar-overlay.x
// xdr/Stellar-SCP.x
//
// DO NOT EDIT or your changes may be overwritten
package xdr
import (
"fmt"
"io"
"github.com/nullstyle/go-xdr/xdr3"
)
// Unmarshal reads an xdr element from `r` into `v`.
func Unmarshal(r io.Reader, v interface{}) (int, error) {
// delegate to xdr package's Unmarshal
return xdr.Unmarshal(r, v)
}
// Marshal writes an xdr element `v` into `w`.
func Marshal(w io.Writer, v interface{}) (int, error) {
// delegate to xdr package's Marshal
return xdr.Marshal(w, v)
}
// Hash is an XDR Typedef defines as:
//
// typedef opaque Hash[32];
//
type Hash [32]byte
// XDRMaxSize implements the Sized interface for Hash
func (e Hash) XDRMaxSize() int {
return 32
}
// Uint256 is an XDR Typedef defines as:
//
// typedef opaque uint256[32];
//
type Uint256 [32]byte
// XDRMaxSize implements the Sized interface for Uint256
func (e Uint256) XDRMaxSize() int {
return 32
}
// Uint32 is an XDR Typedef defines as:
//
// typedef unsigned int uint32;
//
type Uint32 uint32
// Int32 is an XDR Typedef defines as:
//
// typedef int int32;
//
type Int32 int32
// Uint64 is an XDR Typedef defines as:
//
// typedef unsigned hyper uint64;
//
type Uint64 uint64
// Int64 is an XDR Typedef defines as:
//
// typedef hyper int64;
//
type Int64 int64
// CryptoKeyType is an XDR Enum defines as:
//
// enum CryptoKeyType
// {
// KEY_TYPE_ED25519 = 0,
// KEY_TYPE_PRE_AUTH_TX = 1,
// KEY_TYPE_HASH_X = 2
// };
//
type CryptoKeyType int32
const (
CryptoKeyTypeKeyTypeEd25519 CryptoKeyType = 0
CryptoKeyTypeKeyTypePreAuthTx CryptoKeyType = 1
CryptoKeyTypeKeyTypeHashX CryptoKeyType = 2
)
var cryptoKeyTypeMap = map[int32]string{
0: "CryptoKeyTypeKeyTypeEd25519",
1: "CryptoKeyTypeKeyTypePreAuthTx",
2: "CryptoKeyTypeKeyTypeHashX",
}
// ValidEnum validates a proposed value for this enum. Implements
// the Enum interface for CryptoKeyType
func (e CryptoKeyType) ValidEnum(v int32) bool {
_, ok := cryptoKeyTypeMap[v]
return ok
}
// String returns the name of `e`
func (e CryptoKeyType) String() string {
name, _ := cryptoKeyTypeMap[int32(e)]
return name
}
// PublicKeyType is an XDR Enum defines as:
//
// enum PublicKeyType
// {
// PUBLIC_KEY_TYPE_ED25519 = KEY_TYPE_ED25519
// };
//
type PublicKeyType int32
const (
PublicKeyTypePublicKeyTypeEd25519 PublicKeyType = 0
)
var publicKeyTypeMap = map[int32]string{
0: "PublicKeyTypePublicKeyTypeEd25519",
}
// ValidEnum validates a proposed value for this enum. Implements
// the Enum interface for PublicKeyType
func (e PublicKeyType) ValidEnum(v int32) bool {
_, ok := publicKeyTypeMap[v]
return ok
}
// String returns the name of `e`
func (e PublicKeyType) String() string {
name, _ := publicKeyTypeMap[int32(e)]
return name
}
// SignerKeyType is an XDR Enum defines as:
//
// enum SignerKeyType
// {
// SIGNER_KEY_TYPE_ED25519 = KEY_TYPE_ED25519,
// SIGNER_KEY_TYPE_PRE_AUTH_TX = KEY_TYPE_PRE_AUTH_TX,
// SIGNER_KEY_TYPE_HASH_X = KEY_TYPE_HASH_X
// };
//
type SignerKeyType int32
const (
SignerKeyTypeSignerKeyTypeEd25519 SignerKeyType = 0
SignerKeyTypeSignerKeyTypePreAuthTx SignerKeyType = 1
SignerKeyTypeSignerKeyTypeHashX SignerKeyType = 2
)
var signerKeyTypeMap = map[int32]string{
0: "SignerKeyTypeSignerKeyTypeEd25519",
1: "SignerKeyTypeSignerKeyTypePreAuthTx",
2: "SignerKeyTypeSignerKeyTypeHashX",
}
// ValidEnum validates a proposed value for this enum. Implements
// the Enum interface for SignerKeyType
func (e SignerKeyType) ValidEnum(v int32) bool {
_, ok := signerKeyTypeMap[v]
return ok
}
// String returns the name of `e`
func (e SignerKeyType) String() string {
name, _ := signerKeyTypeMap[int32(e)]
return name
}
// PublicKey is an XDR Union defines as:
//
// union PublicKey switch (PublicKeyType type)
// {
// case PUBLIC_KEY_TYPE_ED25519:
// uint256 ed25519;
// };
//
type PublicKey struct {
Type PublicKeyType
Ed25519 *Uint256
}
// SwitchFieldName returns the field name in which this union's
// discriminant is stored
func (u PublicKey) SwitchFieldName() string {
return "Type"
}
// ArmForSwitch returns which field name should be used for storing
// the value for an instance of PublicKey
func (u PublicKey) ArmForSwitch(sw int32) (string, bool) {
switch PublicKeyType(sw) {
case PublicKeyTypePublicKeyTypeEd25519:
return "Ed25519", true
}
return "-", false
}
// NewPublicKey creates a new PublicKey.
func NewPublicKey(aType PublicKeyType, value interface{}) (result PublicKey, err error) {
result.Type = aType
switch PublicKeyType(aType) {
case PublicKeyTypePublicKeyTypeEd25519:
tv, ok := value.(Uint256)
if !ok {
err = fmt.Errorf("invalid value, must be Uint256")
return
}
result.Ed25519 = &tv
}
return
}
// MustEd25519 retrieves the Ed25519 value from the union,
// panicing if the value is not set.
func (u PublicKey) MustEd25519() Uint256 {
val, ok := u.GetEd25519()
if !ok {
panic("arm Ed25519 is not set")
}
return val
}
// GetEd25519 retrieves the Ed25519 value from the union,
// returning ok if the union's switch indicated the value is valid.
func (u PublicKey) GetEd25519() (result Uint256, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "Ed25519" {
result = *u.Ed25519
ok = true
}
return
}
// SignerKey is an XDR Union defines as:
//
// union SignerKey switch (SignerKeyType type)
// {
// case SIGNER_KEY_TYPE_ED25519:
// uint256 ed25519;
// case SIGNER_KEY_TYPE_PRE_AUTH_TX:
// /* Hash of Transaction structure */
// uint256 preAuthTx;
// case SIGNER_KEY_TYPE_HASH_X:
// /* Hash of random 256 bit preimage X */
// uint256 hashX;
// };
//
type SignerKey struct {
Type SignerKeyType
Ed25519 *Uint256
PreAuthTx *Uint256
HashX *Uint256
}
// SwitchFieldName returns the field name in which this union's
// discriminant is stored
func (u SignerKey) SwitchFieldName() string {
return "Type"
}
// ArmForSwitch returns which field name should be used for storing
// the value for an instance of SignerKey
func (u SignerKey) ArmForSwitch(sw int32) (string, bool) {
switch SignerKeyType(sw) {
case SignerKeyTypeSignerKeyTypeEd25519:
return "Ed25519", true
case SignerKeyTypeSignerKeyTypePreAuthTx:
return "PreAuthTx", true
case SignerKeyTypeSignerKeyTypeHashX:
return "HashX", true
}
return "-", false
}
// NewSignerKey creates a new SignerKey.
func NewSignerKey(aType SignerKeyType, value interface{}) (result SignerKey, err error) {
result.Type = aType
switch SignerKeyType(aType) {
case SignerKeyTypeSignerKeyTypeEd25519:
tv, ok := value.(Uint256)
if !ok {
err = fmt.Errorf("invalid value, must be Uint256")
return
}
result.Ed25519 = &tv
case SignerKeyTypeSignerKeyTypePreAuthTx:
tv, ok := value.(Uint256)
if !ok {
err = fmt.Errorf("invalid value, must be Uint256")
return
}
result.PreAuthTx = &tv
case SignerKeyTypeSignerKeyTypeHashX:
tv, ok := value.(Uint256)
if !ok {
err = fmt.Errorf("invalid value, must be Uint256")
return
}
result.HashX = &tv
}
return
}
// MustEd25519 retrieves the Ed25519 value from the union,
// panicing if the value is not set.
func (u SignerKey) MustEd25519() Uint256 {
val, ok := u.GetEd25519()
if !ok {
panic("arm Ed25519 is not set")
}
return val
}
// GetEd25519 retrieves the Ed25519 value from the union,
// returning ok if the union's switch indicated the value is valid.
func (u SignerKey) GetEd25519() (result Uint256, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "Ed25519" {
result = *u.Ed25519
ok = true
}
return
}
// MustPreAuthTx retrieves the PreAuthTx value from the union,
// panicing if the value is not set.
func (u SignerKey) MustPreAuthTx() Uint256 {
val, ok := u.GetPreAuthTx()
if !ok {
panic("arm PreAuthTx is not set")
}
return val
}
// GetPreAuthTx retrieves the PreAuthTx value from the union,
// returning ok if the union's switch indicated the value is valid.
func (u SignerKey) GetPreAuthTx() (result Uint256, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "PreAuthTx" {
result = *u.PreAuthTx
ok = true
}
return
}
// MustHashX retrieves the HashX value from the union,
// panicing if the value is not set.
func (u SignerKey) MustHashX() Uint256 {
val, ok := u.GetHashX()
if !ok {
panic("arm HashX is not set")
}
return val
}
// GetHashX retrieves the HashX value from the union,
// returning ok if the union's switch indicated the value is valid.
func (u SignerKey) GetHashX() (result Uint256, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "HashX" {
result = *u.HashX
ok = true
}
return
}
// Signature is an XDR Typedef defines as:
//
// typedef opaque Signature<64>;
//
type Signature []byte
// XDRMaxSize implements the Sized interface for Signature
func (e Signature) XDRMaxSize() int {
return 64
}
// SignatureHint is an XDR Typedef defines as:
//
// typedef opaque SignatureHint[4];
//
type SignatureHint [4]byte
// XDRMaxSize implements the Sized interface for SignatureHint
func (e SignatureHint) XDRMaxSize() int {
return 4
}
// NodeId is an XDR Typedef defines as:
//
// typedef PublicKey NodeID;
//
type NodeId PublicKey
// SwitchFieldName returns the field name in which this union's
// discriminant is stored
func (u NodeId) SwitchFieldName() string {
return PublicKey(u).SwitchFieldName()
}
// ArmForSwitch returns which field name should be used for storing
// the value for an instance of PublicKey
func (u NodeId) ArmForSwitch(sw int32) (string, bool) {
return PublicKey(u).ArmForSwitch(sw)
}
// NewNodeId creates a new NodeId.
func NewNodeId(aType PublicKeyType, value interface{}) (result NodeId, err error) {
u, err := NewPublicKey(aType, value)
result = NodeId(u)
return
}
// MustEd25519 retrieves the Ed25519 value from the union,
// panicing if the value is not set.
func (u NodeId) MustEd25519() Uint256 {
return PublicKey(u).MustEd25519()
}
// GetEd25519 retrieves the Ed25519 value from the union,
// returning ok if the union's switch indicated the value is valid.
func (u NodeId) GetEd25519() (result Uint256, ok bool) {
return PublicKey(u).GetEd25519()
}
// Curve25519Secret is an XDR Struct defines as:
//
// struct Curve25519Secret
// {
// opaque key[32];
// };
//
type Curve25519Secret struct {
Key [32]byte `xdrmaxsize:"32"`
}
// Curve25519Public is an XDR Struct defines as:
//
// struct Curve25519Public
// {
// opaque key[32];
// };
//
type Curve25519Public struct {
Key [32]byte `xdrmaxsize:"32"`
}
// HmacSha256Key is an XDR Struct defines as:
//
// struct HmacSha256Key
// {
// opaque key[32];
// };
//
type HmacSha256Key struct {
Key [32]byte `xdrmaxsize:"32"`
}
// HmacSha256Mac is an XDR Struct defines as:
//
// struct HmacSha256Mac
// {
// opaque mac[32];
// };
//
type HmacSha256Mac struct {
Mac [32]byte `xdrmaxsize:"32"`
}
// AccountId is an XDR Typedef defines as:
//
// typedef PublicKey AccountID;
//
type AccountId PublicKey
// SwitchFieldName returns the field name in which this union's
// discriminant is stored
func (u AccountId) SwitchFieldName() string {
return PublicKey(u).SwitchFieldName()
}
// ArmForSwitch returns which field name should be used for storing
// the value for an instance of PublicKey
func (u AccountId) ArmForSwitch(sw int32) (string, bool) {
return PublicKey(u).ArmForSwitch(sw)
}
// NewAccountId creates a new AccountId.
func NewAccountId(aType PublicKeyType, value interface{}) (result AccountId, err error) {
u, err := NewPublicKey(aType, value)
result = AccountId(u)
return
}
// MustEd25519 retrieves the Ed25519 value from the union,
// panicing if the value is not set.
func (u AccountId) MustEd25519() Uint256 {
return PublicKey(u).MustEd25519()
}
// GetEd25519 retrieves the Ed25519 value from the union,
// returning ok if the union's switch indicated the value is valid.
func (u AccountId) GetEd25519() (result Uint256, ok bool) {
return PublicKey(u).GetEd25519()
}
// Thresholds is an XDR Typedef defines as:
//
// typedef opaque Thresholds[4];
//
type Thresholds [4]byte
// XDRMaxSize implements the Sized interface for Thresholds
func (e Thresholds) XDRMaxSize() int {
return 4
}
// String32 is an XDR Typedef defines as:
//
// typedef string string32<32>;
//
type String32 string
// XDRMaxSize implements the Sized interface for String32
func (e String32) XDRMaxSize() int {
return 32
}
// String64 is an XDR Typedef defines as:
//
// typedef string string64<64>;
//
type String64 string
// XDRMaxSize implements the Sized interface for String64
func (e String64) XDRMaxSize() int {
return 64
}
// SequenceNumber is an XDR Typedef defines as:
//
// typedef uint64 SequenceNumber;
//
type SequenceNumber Uint64
// DataValue is an XDR Typedef defines as:
//
// typedef opaque DataValue<64>;
//
type DataValue []byte
// XDRMaxSize implements the Sized interface for DataValue
func (e DataValue) XDRMaxSize() int {
return 64
}
// AssetType is an XDR Enum defines as:
//
// enum AssetType
// {
// ASSET_TYPE_NATIVE = 0,
// ASSET_TYPE_CREDIT_ALPHANUM4 = 1,
// ASSET_TYPE_CREDIT_ALPHANUM12 = 2
// };
//
type AssetType int32
const (
AssetTypeAssetTypeNative AssetType = 0
AssetTypeAssetTypeCreditAlphanum4 AssetType = 1
AssetTypeAssetTypeCreditAlphanum12 AssetType = 2
)
var assetTypeMap = map[int32]string{
0: "AssetTypeAssetTypeNative",
1: "AssetTypeAssetTypeCreditAlphanum4",
2: "AssetTypeAssetTypeCreditAlphanum12",
}
// ValidEnum validates a proposed value for this enum. Implements
// the Enum interface for AssetType
func (e AssetType) ValidEnum(v int32) bool {
_, ok := assetTypeMap[v]
return ok
}
// String returns the name of `e`
func (e AssetType) String() string {
name, _ := assetTypeMap[int32(e)]
return name
}
// AssetAlphaNum4 is an XDR NestedStruct defines as:
//
// struct
// {
// opaque assetCode[4]; // 1 to 4 characters
// AccountID issuer;
// }
//
type AssetAlphaNum4 struct {
AssetCode [4]byte `xdrmaxsize:"4"`
Issuer AccountId
}
// AssetAlphaNum12 is an XDR NestedStruct defines as:
//
// struct
// {
// opaque assetCode[12]; // 5 to 12 characters
// AccountID issuer;
// }
//
type AssetAlphaNum12 struct {
AssetCode [12]byte `xdrmaxsize:"12"`
Issuer AccountId
}
// Asset is an XDR Union defines as:
//
// union Asset switch (AssetType type)
// {
// case ASSET_TYPE_NATIVE: // Not credit
// void;
//
// case ASSET_TYPE_CREDIT_ALPHANUM4:
// struct
// {
// opaque assetCode[4]; // 1 to 4 characters
// AccountID issuer;
// } alphaNum4;
//
// case ASSET_TYPE_CREDIT_ALPHANUM12:
// struct
// {
// opaque assetCode[12]; // 5 to 12 characters
// AccountID issuer;
// } alphaNum12;
//
// // add other asset types here in the future
// };
//
type Asset struct {
Type AssetType
AlphaNum4 *AssetAlphaNum4
AlphaNum12 *AssetAlphaNum12
}
// SwitchFieldName returns the field name in which this union's
// discriminant is stored
func (u Asset) SwitchFieldName() string {
return "Type"
}
// ArmForSwitch returns which field name should be used for storing
// the value for an instance of Asset
func (u Asset) ArmForSwitch(sw int32) (string, bool) {
switch AssetType(sw) {
case AssetTypeAssetTypeNative:
return "", true
case AssetTypeAssetTypeCreditAlphanum4:
return "AlphaNum4", true
case AssetTypeAssetTypeCreditAlphanum12:
return "AlphaNum12", true
}
return "-", false
}
// NewAsset creates a new Asset.
func NewAsset(aType AssetType, value interface{}) (result Asset, err error) {
result.Type = aType
switch AssetType(aType) {
case AssetTypeAssetTypeNative:
// void
case AssetTypeAssetTypeCreditAlphanum4:
tv, ok := value.(AssetAlphaNum4)
if !ok {
err = fmt.Errorf("invalid value, must be AssetAlphaNum4")
return
}
result.AlphaNum4 = &tv
case AssetTypeAssetTypeCreditAlphanum12:
tv, ok := value.(AssetAlphaNum12)
if !ok {
err = fmt.Errorf("invalid value, must be AssetAlphaNum12")
return
}
result.AlphaNum12 = &tv
}
return
}
// MustAlphaNum4 retrieves the AlphaNum4 value from the union,
// panicing if the value is not set.
func (u Asset) MustAlphaNum4() AssetAlphaNum4 {
val, ok := u.GetAlphaNum4()
if !ok {
panic("arm AlphaNum4 is not set")
}
return val
}
// GetAlphaNum4 retrieves the AlphaNum4 value from the union,
// returning ok if the union's switch indicated the value is valid.
func (u Asset) GetAlphaNum4() (result AssetAlphaNum4, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "AlphaNum4" {
result = *u.AlphaNum4
ok = true
}
return
}
// MustAlphaNum12 retrieves the AlphaNum12 value from the union,
// panicing if the value is not set.
func (u Asset) MustAlphaNum12() AssetAlphaNum12 {
val, ok := u.GetAlphaNum12()
if !ok {
panic("arm AlphaNum12 is not set")
}
return val
}
// GetAlphaNum12 retrieves the AlphaNum12 value from the union,
// returning ok if the union's switch indicated the value is valid.
func (u Asset) GetAlphaNum12() (result AssetAlphaNum12, ok bool) {
armName, _ := u.ArmForSwitch(int32(u.Type))
if armName == "AlphaNum12" {
result = *u.AlphaNum12
ok = true
}
return
}
// Price is an XDR Struct defines as:
//
// struct Price
// {
// int32 n; // numerator
// int32 d; // denominator
// };
//
type Price struct {
N Int32
D Int32
}
// ThresholdIndexes is an XDR Enum defines as:
//
// enum ThresholdIndexes
// {
// THRESHOLD_MASTER_WEIGHT = 0,
// THRESHOLD_LOW = 1,
// THRESHOLD_MED = 2,
// THRESHOLD_HIGH = 3
// };
//
type ThresholdIndexes int32
const (
ThresholdIndexesThresholdMasterWeight ThresholdIndexes = 0
ThresholdIndexesThresholdLow ThresholdIndexes = 1
ThresholdIndexesThresholdMed ThresholdIndexes = 2
ThresholdIndexesThresholdHigh ThresholdIndexes = 3
)
var thresholdIndexesMap = map[int32]string{
0: "ThresholdIndexesThresholdMasterWeight",
1: "ThresholdIndexesThresholdLow",
2: "ThresholdIndexesThresholdMed",
3: "ThresholdIndexesThresholdHigh",
}
// ValidEnum validates a proposed value for this enum. Implements
// the Enum interface for ThresholdIndexes
func (e ThresholdIndexes) ValidEnum(v int32) bool {
_, ok := thresholdIndexesMap[v]
return ok
}
// String returns the name of `e`
func (e ThresholdIndexes) String() string {
name, _ := thresholdIndexesMap[int32(e)]
return name
}
// LedgerEntryType is an XDR Enum defines as:
//
// enum LedgerEntryType
// {
// ACCOUNT = 0,
// TRUSTLINE = 1,
// OFFER = 2,
// DATA = 3,
// SIGNERS_ACCESS = 4
// };
//
type LedgerEntryType int32
const (
LedgerEntryTypeAccount LedgerEntryType = 0
LedgerEntryTypeTrustline LedgerEntryType = 1
LedgerEntryTypeOffer LedgerEntryType = 2
LedgerEntryTypeData LedgerEntryType = 3
LedgerEntryTypeSignersAccess LedgerEntryType = 4
)
var ledgerEntryTypeMap = map[int32]string{
0: "LedgerEntryTypeAccount",
1: "LedgerEntryTypeTrustline",
2: "LedgerEntryTypeOffer",
3: "LedgerEntryTypeData",
4: "LedgerEntryTypeSignersAccess",
}
// ValidEnum validates a proposed value for this enum. Implements
// the Enum interface for LedgerEntryType
func (e LedgerEntryType) ValidEnum(v int32) bool {
_, ok := ledgerEntryTypeMap[v]
return ok
}
// String returns the name of `e`
func (e LedgerEntryType) String() string {
name, _ := ledgerEntryTypeMap[int32(e)]
return name
}
// Signer is an XDR Struct defines as:
//
// struct Signer
// {
// SignerKey key;
// uint32 weight; // really only need 1byte
// };
//
type Signer struct {
Key SignerKey
Weight Uint32
}
// AccountFlags is an XDR Enum defines as:
//
// enum AccountFlags
// { // masks for each flag
//
// // Flags set on issuer accounts
// // TrustLines are created with authorized set to "false" requiring
// // the issuer to set it for each TrustLine
// AUTH_REQUIRED_FLAG = 0x1,
// // If set, the authorized flag in TrustLines can be cleared
// // otherwise, authorization cannot be revoked
// AUTH_REVOCABLE_FLAG = 0x2,
// // Once set, causes all AUTH_* flags to be read-only
// AUTH_IMMUTABLE_FLAG = 0x4
// };
//
type AccountFlags int32
const (
AccountFlagsAuthRequiredFlag AccountFlags = 1
AccountFlagsAuthRevocableFlag AccountFlags = 2
AccountFlagsAuthImmutableFlag AccountFlags = 4
)
var accountFlagsMap = map[int32]string{
1: "AccountFlagsAuthRequiredFlag",
2: "AccountFlagsAuthRevocableFlag",
4: "AccountFlagsAuthImmutableFlag",
}
// ValidEnum validates a proposed value for this enum. Implements
// the Enum interface for AccountFlags
func (e AccountFlags) ValidEnum(v int32) bool {
_, ok := accountFlagsMap[v]
return ok
}
// String returns the name of `e`
func (e AccountFlags) String() string {
name, _ := accountFlagsMap[int32(e)]
return name
}
// AccountEntryExt is an XDR NestedUnion defines as:
//
// union switch (int v)
// {
// case 0:
// void;
// }
//
type AccountEntryExt struct {
V int32
}
// SwitchFieldName returns the field name in which this union's
// discriminant is stored
func (u AccountEntryExt) SwitchFieldName() string {
return "V"
}
// ArmForSwitch returns which field name should be used for storing
// the value for an instance of AccountEntryExt
func (u AccountEntryExt) ArmForSwitch(sw int32) (string, bool) {
switch int32(sw) {
case 0:
return "", true
}
return "-", false
}
// NewAccountEntryExt creates a new AccountEntryExt.
func NewAccountEntryExt(v int32, value interface{}) (result AccountEntryExt, err error) {
result.V = v
switch int32(v) {
case 0:
// void
}
return
}
// AccountEntry is an XDR Struct defines as:
//
// struct AccountEntry
// {
// AccountID accountID; // master public key for this account
// int64 balance; // in stroops
// SequenceNumber seqNum; // last sequence number used for this account
// uint32 numSubEntries; // number of sub-entries this account has
// // drives the reserve
// AccountID* inflationDest; // Account to vote for during inflation
// uint32 flags; // see AccountFlags
//
// string32 homeDomain; // can be used for reverse federation and memo lookup
//
// // fields used for signatures
// // thresholds stores unsigned bytes: [weight of master|low|medium|high]
// Thresholds thresholds;
//
// Signer signers<20>; // possible signers for this account
//
// // reserved for future use
// union switch (int v)
// {
// case 0:
// void;
// }
// ext;
// };
//
type AccountEntry struct {
AccountId AccountId
Balance Int64
SeqNum SequenceNumber
NumSubEntries Uint32
InflationDest *AccountId
Flags Uint32
HomeDomain String32
Thresholds Thresholds
Signers []Signer `xdrmaxsize:"20"`
Ext AccountEntryExt
}
// TrustLineFlags is an XDR Enum defines as: