1//lint:file-ignore S1005 The issue should be fixed in xdrgen. Unfortunately, there's no way to ignore a single file in staticcheck. 2//lint:file-ignore U1000 fmtTest is not needed anywhere, should be removed in xdrgen. 3// Package xdr is generated from: 4// 5// Stellar-SCP.x 6// Stellar-ledger-entries.x 7// Stellar-ledger.x 8// Stellar-overlay.x 9// Stellar-transaction.x 10// Stellar-types.x 11// 12// DO NOT EDIT or your changes may be overwritten 13package xdr 14 15import ( 16 "bytes" 17 "encoding" 18 "fmt" 19 "io" 20 21 "github.com/stellar/go-xdr/xdr3" 22) 23 24// Unmarshal reads an xdr element from `r` into `v`. 25func Unmarshal(r io.Reader, v interface{}) (int, error) { 26 // delegate to xdr package's Unmarshal 27 return xdr.Unmarshal(r, v) 28} 29 30// Marshal writes an xdr element `v` into `w`. 31func Marshal(w io.Writer, v interface{}) (int, error) { 32 // delegate to xdr package's Marshal 33 return xdr.Marshal(w, v) 34} 35 36// Value is an XDR Typedef defines as: 37// 38// typedef opaque Value<>; 39// 40type Value []byte 41 42// MarshalBinary implements encoding.BinaryMarshaler. 43func (s Value) MarshalBinary() ([]byte, error) { 44 b := new(bytes.Buffer) 45 _, err := Marshal(b, s) 46 return b.Bytes(), err 47} 48 49// UnmarshalBinary implements encoding.BinaryUnmarshaler. 50func (s *Value) UnmarshalBinary(inp []byte) error { 51 _, err := Unmarshal(bytes.NewReader(inp), s) 52 return err 53} 54 55var ( 56 _ encoding.BinaryMarshaler = (*Value)(nil) 57 _ encoding.BinaryUnmarshaler = (*Value)(nil) 58) 59 60// ScpBallot is an XDR Struct defines as: 61// 62// struct SCPBallot 63// { 64// uint32 counter; // n 65// Value value; // x 66// }; 67// 68type ScpBallot struct { 69 Counter Uint32 70 Value Value 71} 72 73// MarshalBinary implements encoding.BinaryMarshaler. 74func (s ScpBallot) MarshalBinary() ([]byte, error) { 75 b := new(bytes.Buffer) 76 _, err := Marshal(b, s) 77 return b.Bytes(), err 78} 79 80// UnmarshalBinary implements encoding.BinaryUnmarshaler. 81func (s *ScpBallot) UnmarshalBinary(inp []byte) error { 82 _, err := Unmarshal(bytes.NewReader(inp), s) 83 return err 84} 85 86var ( 87 _ encoding.BinaryMarshaler = (*ScpBallot)(nil) 88 _ encoding.BinaryUnmarshaler = (*ScpBallot)(nil) 89) 90 91// ScpStatementType is an XDR Enum defines as: 92// 93// enum SCPStatementType 94// { 95// SCP_ST_PREPARE = 0, 96// SCP_ST_CONFIRM = 1, 97// SCP_ST_EXTERNALIZE = 2, 98// SCP_ST_NOMINATE = 3 99// }; 100// 101type ScpStatementType int32 102 103const ( 104 ScpStatementTypeScpStPrepare ScpStatementType = 0 105 ScpStatementTypeScpStConfirm ScpStatementType = 1 106 ScpStatementTypeScpStExternalize ScpStatementType = 2 107 ScpStatementTypeScpStNominate ScpStatementType = 3 108) 109 110var scpStatementTypeMap = map[int32]string{ 111 0: "ScpStatementTypeScpStPrepare", 112 1: "ScpStatementTypeScpStConfirm", 113 2: "ScpStatementTypeScpStExternalize", 114 3: "ScpStatementTypeScpStNominate", 115} 116 117// ValidEnum validates a proposed value for this enum. Implements 118// the Enum interface for ScpStatementType 119func (e ScpStatementType) ValidEnum(v int32) bool { 120 _, ok := scpStatementTypeMap[v] 121 return ok 122} 123 124// String returns the name of `e` 125func (e ScpStatementType) String() string { 126 name, _ := scpStatementTypeMap[int32(e)] 127 return name 128} 129 130// MarshalBinary implements encoding.BinaryMarshaler. 131func (s ScpStatementType) MarshalBinary() ([]byte, error) { 132 b := new(bytes.Buffer) 133 _, err := Marshal(b, s) 134 return b.Bytes(), err 135} 136 137// UnmarshalBinary implements encoding.BinaryUnmarshaler. 138func (s *ScpStatementType) UnmarshalBinary(inp []byte) error { 139 _, err := Unmarshal(bytes.NewReader(inp), s) 140 return err 141} 142 143var ( 144 _ encoding.BinaryMarshaler = (*ScpStatementType)(nil) 145 _ encoding.BinaryUnmarshaler = (*ScpStatementType)(nil) 146) 147 148// ScpNomination is an XDR Struct defines as: 149// 150// struct SCPNomination 151// { 152// Hash quorumSetHash; // D 153// Value votes<>; // X 154// Value accepted<>; // Y 155// }; 156// 157type ScpNomination struct { 158 QuorumSetHash Hash 159 Votes []Value 160 Accepted []Value 161} 162 163// MarshalBinary implements encoding.BinaryMarshaler. 164func (s ScpNomination) MarshalBinary() ([]byte, error) { 165 b := new(bytes.Buffer) 166 _, err := Marshal(b, s) 167 return b.Bytes(), err 168} 169 170// UnmarshalBinary implements encoding.BinaryUnmarshaler. 171func (s *ScpNomination) UnmarshalBinary(inp []byte) error { 172 _, err := Unmarshal(bytes.NewReader(inp), s) 173 return err 174} 175 176var ( 177 _ encoding.BinaryMarshaler = (*ScpNomination)(nil) 178 _ encoding.BinaryUnmarshaler = (*ScpNomination)(nil) 179) 180 181// ScpStatementPrepare is an XDR NestedStruct defines as: 182// 183// struct 184// { 185// Hash quorumSetHash; // D 186// SCPBallot ballot; // b 187// SCPBallot* prepared; // p 188// SCPBallot* preparedPrime; // p' 189// uint32 nC; // c.n 190// uint32 nH; // h.n 191// } 192// 193type ScpStatementPrepare struct { 194 QuorumSetHash Hash 195 Ballot ScpBallot 196 Prepared *ScpBallot 197 PreparedPrime *ScpBallot 198 NC Uint32 199 NH Uint32 200} 201 202// MarshalBinary implements encoding.BinaryMarshaler. 203func (s ScpStatementPrepare) MarshalBinary() ([]byte, error) { 204 b := new(bytes.Buffer) 205 _, err := Marshal(b, s) 206 return b.Bytes(), err 207} 208 209// UnmarshalBinary implements encoding.BinaryUnmarshaler. 210func (s *ScpStatementPrepare) UnmarshalBinary(inp []byte) error { 211 _, err := Unmarshal(bytes.NewReader(inp), s) 212 return err 213} 214 215var ( 216 _ encoding.BinaryMarshaler = (*ScpStatementPrepare)(nil) 217 _ encoding.BinaryUnmarshaler = (*ScpStatementPrepare)(nil) 218) 219 220// ScpStatementConfirm is an XDR NestedStruct defines as: 221// 222// struct 223// { 224// SCPBallot ballot; // b 225// uint32 nPrepared; // p.n 226// uint32 nCommit; // c.n 227// uint32 nH; // h.n 228// Hash quorumSetHash; // D 229// } 230// 231type ScpStatementConfirm struct { 232 Ballot ScpBallot 233 NPrepared Uint32 234 NCommit Uint32 235 NH Uint32 236 QuorumSetHash Hash 237} 238 239// MarshalBinary implements encoding.BinaryMarshaler. 240func (s ScpStatementConfirm) MarshalBinary() ([]byte, error) { 241 b := new(bytes.Buffer) 242 _, err := Marshal(b, s) 243 return b.Bytes(), err 244} 245 246// UnmarshalBinary implements encoding.BinaryUnmarshaler. 247func (s *ScpStatementConfirm) UnmarshalBinary(inp []byte) error { 248 _, err := Unmarshal(bytes.NewReader(inp), s) 249 return err 250} 251 252var ( 253 _ encoding.BinaryMarshaler = (*ScpStatementConfirm)(nil) 254 _ encoding.BinaryUnmarshaler = (*ScpStatementConfirm)(nil) 255) 256 257// ScpStatementExternalize is an XDR NestedStruct defines as: 258// 259// struct 260// { 261// SCPBallot commit; // c 262// uint32 nH; // h.n 263// Hash commitQuorumSetHash; // D used before EXTERNALIZE 264// } 265// 266type ScpStatementExternalize struct { 267 Commit ScpBallot 268 NH Uint32 269 CommitQuorumSetHash Hash 270} 271 272// MarshalBinary implements encoding.BinaryMarshaler. 273func (s ScpStatementExternalize) MarshalBinary() ([]byte, error) { 274 b := new(bytes.Buffer) 275 _, err := Marshal(b, s) 276 return b.Bytes(), err 277} 278 279// UnmarshalBinary implements encoding.BinaryUnmarshaler. 280func (s *ScpStatementExternalize) UnmarshalBinary(inp []byte) error { 281 _, err := Unmarshal(bytes.NewReader(inp), s) 282 return err 283} 284 285var ( 286 _ encoding.BinaryMarshaler = (*ScpStatementExternalize)(nil) 287 _ encoding.BinaryUnmarshaler = (*ScpStatementExternalize)(nil) 288) 289 290// ScpStatementPledges is an XDR NestedUnion defines as: 291// 292// union switch (SCPStatementType type) 293// { 294// case SCP_ST_PREPARE: 295// struct 296// { 297// Hash quorumSetHash; // D 298// SCPBallot ballot; // b 299// SCPBallot* prepared; // p 300// SCPBallot* preparedPrime; // p' 301// uint32 nC; // c.n 302// uint32 nH; // h.n 303// } prepare; 304// case SCP_ST_CONFIRM: 305// struct 306// { 307// SCPBallot ballot; // b 308// uint32 nPrepared; // p.n 309// uint32 nCommit; // c.n 310// uint32 nH; // h.n 311// Hash quorumSetHash; // D 312// } confirm; 313// case SCP_ST_EXTERNALIZE: 314// struct 315// { 316// SCPBallot commit; // c 317// uint32 nH; // h.n 318// Hash commitQuorumSetHash; // D used before EXTERNALIZE 319// } externalize; 320// case SCP_ST_NOMINATE: 321// SCPNomination nominate; 322// } 323// 324type ScpStatementPledges struct { 325 Type ScpStatementType 326 Prepare *ScpStatementPrepare 327 Confirm *ScpStatementConfirm 328 Externalize *ScpStatementExternalize 329 Nominate *ScpNomination 330} 331 332// SwitchFieldName returns the field name in which this union's 333// discriminant is stored 334func (u ScpStatementPledges) SwitchFieldName() string { 335 return "Type" 336} 337 338// ArmForSwitch returns which field name should be used for storing 339// the value for an instance of ScpStatementPledges 340func (u ScpStatementPledges) ArmForSwitch(sw int32) (string, bool) { 341 switch ScpStatementType(sw) { 342 case ScpStatementTypeScpStPrepare: 343 return "Prepare", true 344 case ScpStatementTypeScpStConfirm: 345 return "Confirm", true 346 case ScpStatementTypeScpStExternalize: 347 return "Externalize", true 348 case ScpStatementTypeScpStNominate: 349 return "Nominate", true 350 } 351 return "-", false 352} 353 354// NewScpStatementPledges creates a new ScpStatementPledges. 355func NewScpStatementPledges(aType ScpStatementType, value interface{}) (result ScpStatementPledges, err error) { 356 result.Type = aType 357 switch ScpStatementType(aType) { 358 case ScpStatementTypeScpStPrepare: 359 tv, ok := value.(ScpStatementPrepare) 360 if !ok { 361 err = fmt.Errorf("invalid value, must be ScpStatementPrepare") 362 return 363 } 364 result.Prepare = &tv 365 case ScpStatementTypeScpStConfirm: 366 tv, ok := value.(ScpStatementConfirm) 367 if !ok { 368 err = fmt.Errorf("invalid value, must be ScpStatementConfirm") 369 return 370 } 371 result.Confirm = &tv 372 case ScpStatementTypeScpStExternalize: 373 tv, ok := value.(ScpStatementExternalize) 374 if !ok { 375 err = fmt.Errorf("invalid value, must be ScpStatementExternalize") 376 return 377 } 378 result.Externalize = &tv 379 case ScpStatementTypeScpStNominate: 380 tv, ok := value.(ScpNomination) 381 if !ok { 382 err = fmt.Errorf("invalid value, must be ScpNomination") 383 return 384 } 385 result.Nominate = &tv 386 } 387 return 388} 389 390// MustPrepare retrieves the Prepare value from the union, 391// panicing if the value is not set. 392func (u ScpStatementPledges) MustPrepare() ScpStatementPrepare { 393 val, ok := u.GetPrepare() 394 395 if !ok { 396 panic("arm Prepare is not set") 397 } 398 399 return val 400} 401 402// GetPrepare retrieves the Prepare value from the union, 403// returning ok if the union's switch indicated the value is valid. 404func (u ScpStatementPledges) GetPrepare() (result ScpStatementPrepare, ok bool) { 405 armName, _ := u.ArmForSwitch(int32(u.Type)) 406 407 if armName == "Prepare" { 408 result = *u.Prepare 409 ok = true 410 } 411 412 return 413} 414 415// MustConfirm retrieves the Confirm value from the union, 416// panicing if the value is not set. 417func (u ScpStatementPledges) MustConfirm() ScpStatementConfirm { 418 val, ok := u.GetConfirm() 419 420 if !ok { 421 panic("arm Confirm is not set") 422 } 423 424 return val 425} 426 427// GetConfirm retrieves the Confirm value from the union, 428// returning ok if the union's switch indicated the value is valid. 429func (u ScpStatementPledges) GetConfirm() (result ScpStatementConfirm, ok bool) { 430 armName, _ := u.ArmForSwitch(int32(u.Type)) 431 432 if armName == "Confirm" { 433 result = *u.Confirm 434 ok = true 435 } 436 437 return 438} 439 440// MustExternalize retrieves the Externalize value from the union, 441// panicing if the value is not set. 442func (u ScpStatementPledges) MustExternalize() ScpStatementExternalize { 443 val, ok := u.GetExternalize() 444 445 if !ok { 446 panic("arm Externalize is not set") 447 } 448 449 return val 450} 451 452// GetExternalize retrieves the Externalize value from the union, 453// returning ok if the union's switch indicated the value is valid. 454func (u ScpStatementPledges) GetExternalize() (result ScpStatementExternalize, ok bool) { 455 armName, _ := u.ArmForSwitch(int32(u.Type)) 456 457 if armName == "Externalize" { 458 result = *u.Externalize 459 ok = true 460 } 461 462 return 463} 464 465// MustNominate retrieves the Nominate value from the union, 466// panicing if the value is not set. 467func (u ScpStatementPledges) MustNominate() ScpNomination { 468 val, ok := u.GetNominate() 469 470 if !ok { 471 panic("arm Nominate is not set") 472 } 473 474 return val 475} 476 477// GetNominate retrieves the Nominate value from the union, 478// returning ok if the union's switch indicated the value is valid. 479func (u ScpStatementPledges) GetNominate() (result ScpNomination, ok bool) { 480 armName, _ := u.ArmForSwitch(int32(u.Type)) 481 482 if armName == "Nominate" { 483 result = *u.Nominate 484 ok = true 485 } 486 487 return 488} 489 490// MarshalBinary implements encoding.BinaryMarshaler. 491func (s ScpStatementPledges) MarshalBinary() ([]byte, error) { 492 b := new(bytes.Buffer) 493 _, err := Marshal(b, s) 494 return b.Bytes(), err 495} 496 497// UnmarshalBinary implements encoding.BinaryUnmarshaler. 498func (s *ScpStatementPledges) UnmarshalBinary(inp []byte) error { 499 _, err := Unmarshal(bytes.NewReader(inp), s) 500 return err 501} 502 503var ( 504 _ encoding.BinaryMarshaler = (*ScpStatementPledges)(nil) 505 _ encoding.BinaryUnmarshaler = (*ScpStatementPledges)(nil) 506) 507 508// ScpStatement is an XDR Struct defines as: 509// 510// struct SCPStatement 511// { 512// NodeID nodeID; // v 513// uint64 slotIndex; // i 514// 515// union switch (SCPStatementType type) 516// { 517// case SCP_ST_PREPARE: 518// struct 519// { 520// Hash quorumSetHash; // D 521// SCPBallot ballot; // b 522// SCPBallot* prepared; // p 523// SCPBallot* preparedPrime; // p' 524// uint32 nC; // c.n 525// uint32 nH; // h.n 526// } prepare; 527// case SCP_ST_CONFIRM: 528// struct 529// { 530// SCPBallot ballot; // b 531// uint32 nPrepared; // p.n 532// uint32 nCommit; // c.n 533// uint32 nH; // h.n 534// Hash quorumSetHash; // D 535// } confirm; 536// case SCP_ST_EXTERNALIZE: 537// struct 538// { 539// SCPBallot commit; // c 540// uint32 nH; // h.n 541// Hash commitQuorumSetHash; // D used before EXTERNALIZE 542// } externalize; 543// case SCP_ST_NOMINATE: 544// SCPNomination nominate; 545// } 546// pledges; 547// }; 548// 549type ScpStatement struct { 550 NodeId NodeId 551 SlotIndex Uint64 552 Pledges ScpStatementPledges 553} 554 555// MarshalBinary implements encoding.BinaryMarshaler. 556func (s ScpStatement) MarshalBinary() ([]byte, error) { 557 b := new(bytes.Buffer) 558 _, err := Marshal(b, s) 559 return b.Bytes(), err 560} 561 562// UnmarshalBinary implements encoding.BinaryUnmarshaler. 563func (s *ScpStatement) UnmarshalBinary(inp []byte) error { 564 _, err := Unmarshal(bytes.NewReader(inp), s) 565 return err 566} 567 568var ( 569 _ encoding.BinaryMarshaler = (*ScpStatement)(nil) 570 _ encoding.BinaryUnmarshaler = (*ScpStatement)(nil) 571) 572 573// ScpEnvelope is an XDR Struct defines as: 574// 575// struct SCPEnvelope 576// { 577// SCPStatement statement; 578// Signature signature; 579// }; 580// 581type ScpEnvelope struct { 582 Statement ScpStatement 583 Signature Signature 584} 585 586// MarshalBinary implements encoding.BinaryMarshaler. 587func (s ScpEnvelope) MarshalBinary() ([]byte, error) { 588 b := new(bytes.Buffer) 589 _, err := Marshal(b, s) 590 return b.Bytes(), err 591} 592 593// UnmarshalBinary implements encoding.BinaryUnmarshaler. 594func (s *ScpEnvelope) UnmarshalBinary(inp []byte) error { 595 _, err := Unmarshal(bytes.NewReader(inp), s) 596 return err 597} 598 599var ( 600 _ encoding.BinaryMarshaler = (*ScpEnvelope)(nil) 601 _ encoding.BinaryUnmarshaler = (*ScpEnvelope)(nil) 602) 603 604// ScpQuorumSet is an XDR Struct defines as: 605// 606// struct SCPQuorumSet 607// { 608// uint32 threshold; 609// PublicKey validators<>; 610// SCPQuorumSet innerSets<>; 611// }; 612// 613type ScpQuorumSet struct { 614 Threshold Uint32 615 Validators []PublicKey 616 InnerSets []ScpQuorumSet 617} 618 619// MarshalBinary implements encoding.BinaryMarshaler. 620func (s ScpQuorumSet) MarshalBinary() ([]byte, error) { 621 b := new(bytes.Buffer) 622 _, err := Marshal(b, s) 623 return b.Bytes(), err 624} 625 626// UnmarshalBinary implements encoding.BinaryUnmarshaler. 627func (s *ScpQuorumSet) UnmarshalBinary(inp []byte) error { 628 _, err := Unmarshal(bytes.NewReader(inp), s) 629 return err 630} 631 632var ( 633 _ encoding.BinaryMarshaler = (*ScpQuorumSet)(nil) 634 _ encoding.BinaryUnmarshaler = (*ScpQuorumSet)(nil) 635) 636 637// AccountId is an XDR Typedef defines as: 638// 639// typedef PublicKey AccountID; 640// 641type AccountId PublicKey 642 643// SwitchFieldName returns the field name in which this union's 644// discriminant is stored 645func (u AccountId) SwitchFieldName() string { 646 return PublicKey(u).SwitchFieldName() 647} 648 649// ArmForSwitch returns which field name should be used for storing 650// the value for an instance of PublicKey 651func (u AccountId) ArmForSwitch(sw int32) (string, bool) { 652 return PublicKey(u).ArmForSwitch(sw) 653} 654 655// NewAccountId creates a new AccountId. 656func NewAccountId(aType PublicKeyType, value interface{}) (result AccountId, err error) { 657 u, err := NewPublicKey(aType, value) 658 result = AccountId(u) 659 return 660} 661 662// MustEd25519 retrieves the Ed25519 value from the union, 663// panicing if the value is not set. 664func (u AccountId) MustEd25519() Uint256 { 665 return PublicKey(u).MustEd25519() 666} 667 668// GetEd25519 retrieves the Ed25519 value from the union, 669// returning ok if the union's switch indicated the value is valid. 670func (u AccountId) GetEd25519() (result Uint256, ok bool) { 671 return PublicKey(u).GetEd25519() 672} 673 674// MarshalBinary implements encoding.BinaryMarshaler. 675func (s AccountId) MarshalBinary() ([]byte, error) { 676 b := new(bytes.Buffer) 677 _, err := Marshal(b, s) 678 return b.Bytes(), err 679} 680 681// UnmarshalBinary implements encoding.BinaryUnmarshaler. 682func (s *AccountId) UnmarshalBinary(inp []byte) error { 683 _, err := Unmarshal(bytes.NewReader(inp), s) 684 return err 685} 686 687var ( 688 _ encoding.BinaryMarshaler = (*AccountId)(nil) 689 _ encoding.BinaryUnmarshaler = (*AccountId)(nil) 690) 691 692// Thresholds is an XDR Typedef defines as: 693// 694// typedef opaque Thresholds[4]; 695// 696type Thresholds [4]byte 697 698// XDRMaxSize implements the Sized interface for Thresholds 699func (e Thresholds) XDRMaxSize() int { 700 return 4 701} 702 703// MarshalBinary implements encoding.BinaryMarshaler. 704func (s Thresholds) MarshalBinary() ([]byte, error) { 705 b := new(bytes.Buffer) 706 _, err := Marshal(b, s) 707 return b.Bytes(), err 708} 709 710// UnmarshalBinary implements encoding.BinaryUnmarshaler. 711func (s *Thresholds) UnmarshalBinary(inp []byte) error { 712 _, err := Unmarshal(bytes.NewReader(inp), s) 713 return err 714} 715 716var ( 717 _ encoding.BinaryMarshaler = (*Thresholds)(nil) 718 _ encoding.BinaryUnmarshaler = (*Thresholds)(nil) 719) 720 721// String32 is an XDR Typedef defines as: 722// 723// typedef string string32<32>; 724// 725type String32 string 726 727// XDRMaxSize implements the Sized interface for String32 728func (e String32) XDRMaxSize() int { 729 return 32 730} 731 732// MarshalBinary implements encoding.BinaryMarshaler. 733func (s String32) MarshalBinary() ([]byte, error) { 734 b := new(bytes.Buffer) 735 _, err := Marshal(b, s) 736 return b.Bytes(), err 737} 738 739// UnmarshalBinary implements encoding.BinaryUnmarshaler. 740func (s *String32) UnmarshalBinary(inp []byte) error { 741 _, err := Unmarshal(bytes.NewReader(inp), s) 742 return err 743} 744 745var ( 746 _ encoding.BinaryMarshaler = (*String32)(nil) 747 _ encoding.BinaryUnmarshaler = (*String32)(nil) 748) 749 750// String64 is an XDR Typedef defines as: 751// 752// typedef string string64<64>; 753// 754type String64 string 755 756// XDRMaxSize implements the Sized interface for String64 757func (e String64) XDRMaxSize() int { 758 return 64 759} 760 761// MarshalBinary implements encoding.BinaryMarshaler. 762func (s String64) MarshalBinary() ([]byte, error) { 763 b := new(bytes.Buffer) 764 _, err := Marshal(b, s) 765 return b.Bytes(), err 766} 767 768// UnmarshalBinary implements encoding.BinaryUnmarshaler. 769func (s *String64) UnmarshalBinary(inp []byte) error { 770 _, err := Unmarshal(bytes.NewReader(inp), s) 771 return err 772} 773 774var ( 775 _ encoding.BinaryMarshaler = (*String64)(nil) 776 _ encoding.BinaryUnmarshaler = (*String64)(nil) 777) 778 779// SequenceNumber is an XDR Typedef defines as: 780// 781// typedef int64 SequenceNumber; 782// 783type SequenceNumber Int64 784 785// MarshalBinary implements encoding.BinaryMarshaler. 786func (s SequenceNumber) MarshalBinary() ([]byte, error) { 787 b := new(bytes.Buffer) 788 _, err := Marshal(b, s) 789 return b.Bytes(), err 790} 791 792// UnmarshalBinary implements encoding.BinaryUnmarshaler. 793func (s *SequenceNumber) UnmarshalBinary(inp []byte) error { 794 _, err := Unmarshal(bytes.NewReader(inp), s) 795 return err 796} 797 798var ( 799 _ encoding.BinaryMarshaler = (*SequenceNumber)(nil) 800 _ encoding.BinaryUnmarshaler = (*SequenceNumber)(nil) 801) 802 803// TimePoint is an XDR Typedef defines as: 804// 805// typedef uint64 TimePoint; 806// 807type TimePoint Uint64 808 809// MarshalBinary implements encoding.BinaryMarshaler. 810func (s TimePoint) MarshalBinary() ([]byte, error) { 811 b := new(bytes.Buffer) 812 _, err := Marshal(b, s) 813 return b.Bytes(), err 814} 815 816// UnmarshalBinary implements encoding.BinaryUnmarshaler. 817func (s *TimePoint) UnmarshalBinary(inp []byte) error { 818 _, err := Unmarshal(bytes.NewReader(inp), s) 819 return err 820} 821 822var ( 823 _ encoding.BinaryMarshaler = (*TimePoint)(nil) 824 _ encoding.BinaryUnmarshaler = (*TimePoint)(nil) 825) 826 827// DataValue is an XDR Typedef defines as: 828// 829// typedef opaque DataValue<64>; 830// 831type DataValue []byte 832 833// XDRMaxSize implements the Sized interface for DataValue 834func (e DataValue) XDRMaxSize() int { 835 return 64 836} 837 838// MarshalBinary implements encoding.BinaryMarshaler. 839func (s DataValue) MarshalBinary() ([]byte, error) { 840 b := new(bytes.Buffer) 841 _, err := Marshal(b, s) 842 return b.Bytes(), err 843} 844 845// UnmarshalBinary implements encoding.BinaryUnmarshaler. 846func (s *DataValue) UnmarshalBinary(inp []byte) error { 847 _, err := Unmarshal(bytes.NewReader(inp), s) 848 return err 849} 850 851var ( 852 _ encoding.BinaryMarshaler = (*DataValue)(nil) 853 _ encoding.BinaryUnmarshaler = (*DataValue)(nil) 854) 855 856// AssetCode4 is an XDR Typedef defines as: 857// 858// typedef opaque AssetCode4[4]; 859// 860type AssetCode4 [4]byte 861 862// XDRMaxSize implements the Sized interface for AssetCode4 863func (e AssetCode4) XDRMaxSize() int { 864 return 4 865} 866 867// MarshalBinary implements encoding.BinaryMarshaler. 868func (s AssetCode4) MarshalBinary() ([]byte, error) { 869 b := new(bytes.Buffer) 870 _, err := Marshal(b, s) 871 return b.Bytes(), err 872} 873 874// UnmarshalBinary implements encoding.BinaryUnmarshaler. 875func (s *AssetCode4) UnmarshalBinary(inp []byte) error { 876 _, err := Unmarshal(bytes.NewReader(inp), s) 877 return err 878} 879 880var ( 881 _ encoding.BinaryMarshaler = (*AssetCode4)(nil) 882 _ encoding.BinaryUnmarshaler = (*AssetCode4)(nil) 883) 884 885// AssetCode12 is an XDR Typedef defines as: 886// 887// typedef opaque AssetCode12[12]; 888// 889type AssetCode12 [12]byte 890 891// XDRMaxSize implements the Sized interface for AssetCode12 892func (e AssetCode12) XDRMaxSize() int { 893 return 12 894} 895 896// MarshalBinary implements encoding.BinaryMarshaler. 897func (s AssetCode12) MarshalBinary() ([]byte, error) { 898 b := new(bytes.Buffer) 899 _, err := Marshal(b, s) 900 return b.Bytes(), err 901} 902 903// UnmarshalBinary implements encoding.BinaryUnmarshaler. 904func (s *AssetCode12) UnmarshalBinary(inp []byte) error { 905 _, err := Unmarshal(bytes.NewReader(inp), s) 906 return err 907} 908 909var ( 910 _ encoding.BinaryMarshaler = (*AssetCode12)(nil) 911 _ encoding.BinaryUnmarshaler = (*AssetCode12)(nil) 912) 913 914// AssetType is an XDR Enum defines as: 915// 916// enum AssetType 917// { 918// ASSET_TYPE_NATIVE = 0, 919// ASSET_TYPE_CREDIT_ALPHANUM4 = 1, 920// ASSET_TYPE_CREDIT_ALPHANUM12 = 2 921// }; 922// 923type AssetType int32 924 925const ( 926 AssetTypeAssetTypeNative AssetType = 0 927 AssetTypeAssetTypeCreditAlphanum4 AssetType = 1 928 AssetTypeAssetTypeCreditAlphanum12 AssetType = 2 929) 930 931var assetTypeMap = map[int32]string{ 932 0: "AssetTypeAssetTypeNative", 933 1: "AssetTypeAssetTypeCreditAlphanum4", 934 2: "AssetTypeAssetTypeCreditAlphanum12", 935} 936 937// ValidEnum validates a proposed value for this enum. Implements 938// the Enum interface for AssetType 939func (e AssetType) ValidEnum(v int32) bool { 940 _, ok := assetTypeMap[v] 941 return ok 942} 943 944// String returns the name of `e` 945func (e AssetType) String() string { 946 name, _ := assetTypeMap[int32(e)] 947 return name 948} 949 950// MarshalBinary implements encoding.BinaryMarshaler. 951func (s AssetType) MarshalBinary() ([]byte, error) { 952 b := new(bytes.Buffer) 953 _, err := Marshal(b, s) 954 return b.Bytes(), err 955} 956 957// UnmarshalBinary implements encoding.BinaryUnmarshaler. 958func (s *AssetType) UnmarshalBinary(inp []byte) error { 959 _, err := Unmarshal(bytes.NewReader(inp), s) 960 return err 961} 962 963var ( 964 _ encoding.BinaryMarshaler = (*AssetType)(nil) 965 _ encoding.BinaryUnmarshaler = (*AssetType)(nil) 966) 967 968// AssetAlphaNum4 is an XDR NestedStruct defines as: 969// 970// struct 971// { 972// AssetCode4 assetCode; 973// AccountID issuer; 974// } 975// 976type AssetAlphaNum4 struct { 977 AssetCode AssetCode4 978 Issuer AccountId 979} 980 981// MarshalBinary implements encoding.BinaryMarshaler. 982func (s AssetAlphaNum4) MarshalBinary() ([]byte, error) { 983 b := new(bytes.Buffer) 984 _, err := Marshal(b, s) 985 return b.Bytes(), err 986} 987 988// UnmarshalBinary implements encoding.BinaryUnmarshaler. 989func (s *AssetAlphaNum4) UnmarshalBinary(inp []byte) error { 990 _, err := Unmarshal(bytes.NewReader(inp), s) 991 return err 992} 993 994var ( 995 _ encoding.BinaryMarshaler = (*AssetAlphaNum4)(nil) 996 _ encoding.BinaryUnmarshaler = (*AssetAlphaNum4)(nil) 997) 998 999// AssetAlphaNum12 is an XDR NestedStruct defines as: 1000// 1001// struct 1002// { 1003// AssetCode12 assetCode; 1004// AccountID issuer; 1005// } 1006// 1007type AssetAlphaNum12 struct { 1008 AssetCode AssetCode12 1009 Issuer AccountId 1010} 1011 1012// MarshalBinary implements encoding.BinaryMarshaler. 1013func (s AssetAlphaNum12) MarshalBinary() ([]byte, error) { 1014 b := new(bytes.Buffer) 1015 _, err := Marshal(b, s) 1016 return b.Bytes(), err 1017} 1018 1019// UnmarshalBinary implements encoding.BinaryUnmarshaler. 1020func (s *AssetAlphaNum12) UnmarshalBinary(inp []byte) error { 1021 _, err := Unmarshal(bytes.NewReader(inp), s) 1022 return err 1023} 1024 1025var ( 1026 _ encoding.BinaryMarshaler = (*AssetAlphaNum12)(nil) 1027 _ encoding.BinaryUnmarshaler = (*AssetAlphaNum12)(nil) 1028) 1029 1030// Asset is an XDR Union defines as: 1031// 1032// union Asset switch (AssetType type) 1033// { 1034// case ASSET_TYPE_NATIVE: // Not credit 1035// void; 1036// 1037// case ASSET_TYPE_CREDIT_ALPHANUM4: 1038// struct 1039// { 1040// AssetCode4 assetCode; 1041// AccountID issuer; 1042// } alphaNum4; 1043// 1044// case ASSET_TYPE_CREDIT_ALPHANUM12: 1045// struct 1046// { 1047// AssetCode12 assetCode; 1048// AccountID issuer; 1049// } alphaNum12; 1050// 1051// // add other asset types here in the future 1052// }; 1053// 1054type Asset struct { 1055 Type AssetType 1056 AlphaNum4 *AssetAlphaNum4 1057 AlphaNum12 *AssetAlphaNum12 1058} 1059 1060// SwitchFieldName returns the field name in which this union's 1061// discriminant is stored 1062func (u Asset) SwitchFieldName() string { 1063 return "Type" 1064} 1065 1066// ArmForSwitch returns which field name should be used for storing 1067// the value for an instance of Asset 1068func (u Asset) ArmForSwitch(sw int32) (string, bool) { 1069 switch AssetType(sw) { 1070 case AssetTypeAssetTypeNative: 1071 return "", true 1072 case AssetTypeAssetTypeCreditAlphanum4: 1073 return "AlphaNum4", true 1074 case AssetTypeAssetTypeCreditAlphanum12: 1075 return "AlphaNum12", true 1076 } 1077 return "-", false 1078} 1079 1080// NewAsset creates a new Asset. 1081func NewAsset(aType AssetType, value interface{}) (result Asset, err error) { 1082 result.Type = aType 1083 switch AssetType(aType) { 1084 case AssetTypeAssetTypeNative: 1085 // void 1086 case AssetTypeAssetTypeCreditAlphanum4: 1087 tv, ok := value.(AssetAlphaNum4) 1088 if !ok { 1089 err = fmt.Errorf("invalid value, must be AssetAlphaNum4") 1090 return 1091 } 1092 result.AlphaNum4 = &tv 1093 case AssetTypeAssetTypeCreditAlphanum12: 1094 tv, ok := value.(AssetAlphaNum12) 1095 if !ok { 1096 err = fmt.Errorf("invalid value, must be AssetAlphaNum12") 1097 return 1098 } 1099 result.AlphaNum12 = &tv 1100 } 1101 return 1102} 1103 1104// MustAlphaNum4 retrieves the AlphaNum4 value from the union, 1105// panicing if the value is not set. 1106func (u Asset) MustAlphaNum4() AssetAlphaNum4 { 1107 val, ok := u.GetAlphaNum4() 1108 1109 if !ok { 1110 panic("arm AlphaNum4 is not set") 1111 } 1112 1113 return val 1114} 1115 1116// GetAlphaNum4 retrieves the AlphaNum4 value from the union, 1117// returning ok if the union's switch indicated the value is valid. 1118func (u Asset) GetAlphaNum4() (result AssetAlphaNum4, ok bool) { 1119 armName, _ := u.ArmForSwitch(int32(u.Type)) 1120 1121 if armName == "AlphaNum4" { 1122 result = *u.AlphaNum4 1123 ok = true 1124 } 1125 1126 return 1127} 1128 1129// MustAlphaNum12 retrieves the AlphaNum12 value from the union, 1130// panicing if the value is not set. 1131func (u Asset) MustAlphaNum12() AssetAlphaNum12 { 1132 val, ok := u.GetAlphaNum12() 1133 1134 if !ok { 1135 panic("arm AlphaNum12 is not set") 1136 } 1137 1138 return val 1139} 1140 1141// GetAlphaNum12 retrieves the AlphaNum12 value from the union, 1142// returning ok if the union's switch indicated the value is valid. 1143func (u Asset) GetAlphaNum12() (result AssetAlphaNum12, ok bool) { 1144 armName, _ := u.ArmForSwitch(int32(u.Type)) 1145 1146 if armName == "AlphaNum12" { 1147 result = *u.AlphaNum12 1148 ok = true 1149 } 1150 1151 return 1152} 1153 1154// MarshalBinary implements encoding.BinaryMarshaler. 1155func (s Asset) MarshalBinary() ([]byte, error) { 1156 b := new(bytes.Buffer) 1157 _, err := Marshal(b, s) 1158 return b.Bytes(), err 1159} 1160 1161// UnmarshalBinary implements encoding.BinaryUnmarshaler. 1162func (s *Asset) UnmarshalBinary(inp []byte) error { 1163 _, err := Unmarshal(bytes.NewReader(inp), s) 1164 return err 1165} 1166 1167var ( 1168 _ encoding.BinaryMarshaler = (*Asset)(nil) 1169 _ encoding.BinaryUnmarshaler = (*Asset)(nil) 1170) 1171 1172// Price is an XDR Struct defines as: 1173// 1174// struct Price 1175// { 1176// int32 n; // numerator 1177// int32 d; // denominator 1178// }; 1179// 1180type Price struct { 1181 N Int32 1182 D Int32 1183} 1184 1185// MarshalBinary implements encoding.BinaryMarshaler. 1186func (s Price) MarshalBinary() ([]byte, error) { 1187 b := new(bytes.Buffer) 1188 _, err := Marshal(b, s) 1189 return b.Bytes(), err 1190} 1191 1192// UnmarshalBinary implements encoding.BinaryUnmarshaler. 1193func (s *Price) UnmarshalBinary(inp []byte) error { 1194 _, err := Unmarshal(bytes.NewReader(inp), s) 1195 return err 1196} 1197 1198var ( 1199 _ encoding.BinaryMarshaler = (*Price)(nil) 1200 _ encoding.BinaryUnmarshaler = (*Price)(nil) 1201) 1202 1203// Liabilities is an XDR Struct defines as: 1204// 1205// struct Liabilities 1206// { 1207// int64 buying; 1208// int64 selling; 1209// }; 1210// 1211type Liabilities struct { 1212 Buying Int64 1213 Selling Int64 1214} 1215 1216// MarshalBinary implements encoding.BinaryMarshaler. 1217func (s Liabilities) MarshalBinary() ([]byte, error) { 1218 b := new(bytes.Buffer) 1219 _, err := Marshal(b, s) 1220 return b.Bytes(), err 1221} 1222 1223// UnmarshalBinary implements encoding.BinaryUnmarshaler. 1224func (s *Liabilities) UnmarshalBinary(inp []byte) error { 1225 _, err := Unmarshal(bytes.NewReader(inp), s) 1226 return err 1227} 1228 1229var ( 1230 _ encoding.BinaryMarshaler = (*Liabilities)(nil) 1231 _ encoding.BinaryUnmarshaler = (*Liabilities)(nil) 1232) 1233 1234// ThresholdIndexes is an XDR Enum defines as: 1235// 1236// enum ThresholdIndexes 1237// { 1238// THRESHOLD_MASTER_WEIGHT = 0, 1239// THRESHOLD_LOW = 1, 1240// THRESHOLD_MED = 2, 1241// THRESHOLD_HIGH = 3 1242// }; 1243// 1244type ThresholdIndexes int32 1245 1246const ( 1247 ThresholdIndexesThresholdMasterWeight ThresholdIndexes = 0 1248 ThresholdIndexesThresholdLow ThresholdIndexes = 1 1249 ThresholdIndexesThresholdMed ThresholdIndexes = 2 1250 ThresholdIndexesThresholdHigh ThresholdIndexes = 3 1251) 1252 1253var thresholdIndexesMap = map[int32]string{ 1254 0: "ThresholdIndexesThresholdMasterWeight", 1255 1: "ThresholdIndexesThresholdLow", 1256 2: "ThresholdIndexesThresholdMed", 1257 3: "ThresholdIndexesThresholdHigh", 1258} 1259 1260// ValidEnum validates a proposed value for this enum. Implements 1261// the Enum interface for ThresholdIndexes 1262func (e ThresholdIndexes) ValidEnum(v int32) bool { 1263 _, ok := thresholdIndexesMap[v] 1264 return ok 1265} 1266 1267// String returns the name of `e` 1268func (e ThresholdIndexes) String() string { 1269 name, _ := thresholdIndexesMap[int32(e)] 1270 return name 1271} 1272 1273// MarshalBinary implements encoding.BinaryMarshaler. 1274func (s ThresholdIndexes) MarshalBinary() ([]byte, error) { 1275 b := new(bytes.Buffer) 1276 _, err := Marshal(b, s) 1277 return b.Bytes(), err 1278} 1279 1280// UnmarshalBinary implements encoding.BinaryUnmarshaler. 1281func (s *ThresholdIndexes) UnmarshalBinary(inp []byte) error { 1282 _, err := Unmarshal(bytes.NewReader(inp), s) 1283 return err 1284} 1285 1286var ( 1287 _ encoding.BinaryMarshaler = (*ThresholdIndexes)(nil) 1288 _ encoding.BinaryUnmarshaler = (*ThresholdIndexes)(nil) 1289) 1290 1291// LedgerEntryType is an XDR Enum defines as: 1292// 1293// enum LedgerEntryType 1294// { 1295// ACCOUNT = 0, 1296// TRUSTLINE = 1, 1297// OFFER = 2, 1298// DATA = 3 1299// }; 1300// 1301type LedgerEntryType int32 1302 1303const ( 1304 LedgerEntryTypeAccount LedgerEntryType = 0 1305 LedgerEntryTypeTrustline LedgerEntryType = 1 1306 LedgerEntryTypeOffer LedgerEntryType = 2 1307 LedgerEntryTypeData LedgerEntryType = 3 1308) 1309 1310var ledgerEntryTypeMap = map[int32]string{ 1311 0: "LedgerEntryTypeAccount", 1312 1: "LedgerEntryTypeTrustline", 1313 2: "LedgerEntryTypeOffer", 1314 3: "LedgerEntryTypeData", 1315} 1316 1317// ValidEnum validates a proposed value for this enum. Implements 1318// the Enum interface for LedgerEntryType 1319func (e LedgerEntryType) ValidEnum(v int32) bool { 1320 _, ok := ledgerEntryTypeMap[v] 1321 return ok 1322} 1323 1324// String returns the name of `e` 1325func (e LedgerEntryType) String() string { 1326 name, _ := ledgerEntryTypeMap[int32(e)] 1327 return name 1328} 1329 1330// MarshalBinary implements encoding.BinaryMarshaler. 1331func (s LedgerEntryType) MarshalBinary() ([]byte, error) { 1332 b := new(bytes.Buffer) 1333 _, err := Marshal(b, s) 1334 return b.Bytes(), err 1335} 1336 1337// UnmarshalBinary implements encoding.BinaryUnmarshaler. 1338func (s *LedgerEntryType) UnmarshalBinary(inp []byte) error { 1339 _, err := Unmarshal(bytes.NewReader(inp), s) 1340 return err 1341} 1342 1343var ( 1344 _ encoding.BinaryMarshaler = (*LedgerEntryType)(nil) 1345 _ encoding.BinaryUnmarshaler = (*LedgerEntryType)(nil) 1346) 1347 1348// Signer is an XDR Struct defines as: 1349// 1350// struct Signer 1351// { 1352// SignerKey key; 1353// uint32 weight; // really only need 1 byte 1354// }; 1355// 1356type Signer struct { 1357 Key SignerKey 1358 Weight Uint32 1359} 1360 1361// MarshalBinary implements encoding.BinaryMarshaler. 1362func (s Signer) MarshalBinary() ([]byte, error) { 1363 b := new(bytes.Buffer) 1364 _, err := Marshal(b, s) 1365 return b.Bytes(), err 1366} 1367 1368// UnmarshalBinary implements encoding.BinaryUnmarshaler. 1369func (s *Signer) UnmarshalBinary(inp []byte) error { 1370 _, err := Unmarshal(bytes.NewReader(inp), s) 1371 return err 1372} 1373 1374var ( 1375 _ encoding.BinaryMarshaler = (*Signer)(nil) 1376 _ encoding.BinaryUnmarshaler = (*Signer)(nil) 1377) 1378 1379// AccountFlags is an XDR Enum defines as: 1380// 1381// enum AccountFlags 1382// { // masks for each flag 1383// 1384// // Flags set on issuer accounts 1385// // TrustLines are created with authorized set to "false" requiring 1386// // the issuer to set it for each TrustLine 1387// AUTH_REQUIRED_FLAG = 0x1, 1388// // If set, the authorized flag in TrustLines can be cleared 1389// // otherwise, authorization cannot be revoked 1390// AUTH_REVOCABLE_FLAG = 0x2, 1391// // Once set, causes all AUTH_* flags to be read-only 1392// AUTH_IMMUTABLE_FLAG = 0x4 1393// }; 1394// 1395type AccountFlags int32 1396 1397const ( 1398 AccountFlagsAuthRequiredFlag AccountFlags = 1 1399 AccountFlagsAuthRevocableFlag AccountFlags = 2 1400 AccountFlagsAuthImmutableFlag AccountFlags = 4 1401) 1402 1403var accountFlagsMap = map[int32]string{ 1404 1: "AccountFlagsAuthRequiredFlag", 1405 2: "AccountFlagsAuthRevocableFlag", 1406 4: "AccountFlagsAuthImmutableFlag", 1407} 1408 1409// ValidEnum validates a proposed value for this enum. Implements 1410// the Enum interface for AccountFlags 1411func (e AccountFlags) ValidEnum(v int32) bool { 1412 _, ok := accountFlagsMap[v] 1413 return ok 1414} 1415 1416// String returns the name of `e` 1417func (e AccountFlags) String() string { 1418 name, _ := accountFlagsMap[int32(e)] 1419 return name 1420} 1421 1422// MarshalBinary implements encoding.BinaryMarshaler. 1423func (s AccountFlags) MarshalBinary() ([]byte, error) { 1424 b := new(bytes.Buffer) 1425 _, err := Marshal(b, s) 1426 return b.Bytes(), err 1427} 1428 1429// UnmarshalBinary implements encoding.BinaryUnmarshaler. 1430func (s *AccountFlags) UnmarshalBinary(inp []byte) error { 1431 _, err := Unmarshal(bytes.NewReader(inp), s) 1432 return err 1433} 1434 1435var ( 1436 _ encoding.BinaryMarshaler = (*AccountFlags)(nil) 1437 _ encoding.BinaryUnmarshaler = (*AccountFlags)(nil) 1438) 1439 1440// MaskAccountFlags is an XDR Const defines as: 1441// 1442// const MASK_ACCOUNT_FLAGS = 0x7; 1443// 1444const MaskAccountFlags = 0x7 1445 1446// AccountEntryV1Ext is an XDR NestedUnion defines as: 1447// 1448// union switch (int v) 1449// { 1450// case 0: 1451// void; 1452// } 1453// 1454type AccountEntryV1Ext struct { 1455 V int32 1456} 1457 1458// SwitchFieldName returns the field name in which this union's 1459// discriminant is stored 1460func (u AccountEntryV1Ext) SwitchFieldName() string { 1461 return "V" 1462} 1463 1464// ArmForSwitch returns which field name should be used for storing 1465// the value for an instance of AccountEntryV1Ext 1466func (u AccountEntryV1Ext) ArmForSwitch(sw int32) (string, bool) { 1467 switch int32(sw) { 1468 case 0: 1469 return "", true 1470 } 1471 return "-", false 1472} 1473 1474// NewAccountEntryV1Ext creates a new AccountEntryV1Ext. 1475func NewAccountEntryV1Ext(v int32, value interface{}) (result AccountEntryV1Ext, err error) { 1476 result.V = v 1477 switch int32(v) { 1478 case 0: 1479 // void 1480 } 1481 return 1482} 1483 1484// MarshalBinary implements encoding.BinaryMarshaler. 1485func (s AccountEntryV1Ext) MarshalBinary() ([]byte, error) { 1486 b := new(bytes.Buffer) 1487 _, err := Marshal(b, s) 1488 return b.Bytes(), err 1489} 1490 1491// UnmarshalBinary implements encoding.BinaryUnmarshaler. 1492func (s *AccountEntryV1Ext) UnmarshalBinary(inp []byte) error { 1493 _, err := Unmarshal(bytes.NewReader(inp), s) 1494 return err 1495} 1496 1497var ( 1498 _ encoding.BinaryMarshaler = (*AccountEntryV1Ext)(nil) 1499 _ encoding.BinaryUnmarshaler = (*AccountEntryV1Ext)(nil) 1500) 1501 1502// AccountEntryV1 is an XDR NestedStruct defines as: 1503// 1504// struct 1505// { 1506// Liabilities liabilities; 1507// 1508// union switch (int v) 1509// { 1510// case 0: 1511// void; 1512// } 1513// ext; 1514// } 1515// 1516type AccountEntryV1 struct { 1517 Liabilities Liabilities 1518 Ext AccountEntryV1Ext 1519} 1520 1521// MarshalBinary implements encoding.BinaryMarshaler. 1522func (s AccountEntryV1) MarshalBinary() ([]byte, error) { 1523 b := new(bytes.Buffer) 1524 _, err := Marshal(b, s) 1525 return b.Bytes(), err 1526} 1527 1528// UnmarshalBinary implements encoding.BinaryUnmarshaler. 1529func (s *AccountEntryV1) UnmarshalBinary(inp []byte) error { 1530 _, err := Unmarshal(bytes.NewReader(inp), s) 1531 return err 1532} 1533 1534var ( 1535 _ encoding.BinaryMarshaler = (*AccountEntryV1)(nil) 1536 _ encoding.BinaryUnmarshaler = (*AccountEntryV1)(nil) 1537) 1538 1539// AccountEntryExt is an XDR NestedUnion defines as: 1540// 1541// union switch (int v) 1542// { 1543// case 0: 1544// void; 1545// case 1: 1546// struct 1547// { 1548// Liabilities liabilities; 1549// 1550// union switch (int v) 1551// { 1552// case 0: 1553// void; 1554// } 1555// ext; 1556// } v1; 1557// } 1558// 1559type AccountEntryExt struct { 1560 V int32 1561 V1 *AccountEntryV1 1562} 1563 1564// SwitchFieldName returns the field name in which this union's 1565// discriminant is stored 1566func (u AccountEntryExt) SwitchFieldName() string { 1567 return "V" 1568} 1569 1570// ArmForSwitch returns which field name should be used for storing 1571// the value for an instance of AccountEntryExt 1572func (u AccountEntryExt) ArmForSwitch(sw int32) (string, bool) { 1573 switch int32(sw) { 1574 case 0: 1575 return "", true 1576 case 1: 1577 return "V1", true 1578 } 1579 return "-", false 1580} 1581 1582// NewAccountEntryExt creates a new AccountEntryExt. 1583func NewAccountEntryExt(v int32, value interface{}) (result AccountEntryExt, err error) { 1584 result.V = v 1585 switch int32(v) { 1586 case 0: 1587 // void 1588 case 1: 1589 tv, ok := value.(AccountEntryV1) 1590 if !ok { 1591 err = fmt.Errorf("invalid value, must be AccountEntryV1") 1592 return 1593 } 1594 result.V1 = &tv 1595 } 1596 return 1597} 1598 1599// MustV1 retrieves the V1 value from the union, 1600// panicing if the value is not set. 1601func (u AccountEntryExt) MustV1() AccountEntryV1 { 1602 val, ok := u.GetV1() 1603 1604 if !ok { 1605 panic("arm V1 is not set") 1606 } 1607 1608 return val 1609} 1610 1611// GetV1 retrieves the V1 value from the union, 1612// returning ok if the union's switch indicated the value is valid. 1613func (u AccountEntryExt) GetV1() (result AccountEntryV1, ok bool) { 1614 armName, _ := u.ArmForSwitch(int32(u.V)) 1615 1616 if armName == "V1" { 1617 result = *u.V1 1618 ok = true 1619 } 1620 1621 return 1622} 1623 1624// MarshalBinary implements encoding.BinaryMarshaler. 1625func (s AccountEntryExt) MarshalBinary() ([]byte, error) { 1626 b := new(bytes.Buffer) 1627 _, err := Marshal(b, s) 1628 return b.Bytes(), err 1629} 1630 1631// UnmarshalBinary implements encoding.BinaryUnmarshaler. 1632func (s *AccountEntryExt) UnmarshalBinary(inp []byte) error { 1633 _, err := Unmarshal(bytes.NewReader(inp), s) 1634 return err 1635} 1636 1637var ( 1638 _ encoding.BinaryMarshaler = (*AccountEntryExt)(nil) 1639 _ encoding.BinaryUnmarshaler = (*AccountEntryExt)(nil) 1640) 1641 1642// AccountEntry is an XDR Struct defines as: 1643// 1644// struct AccountEntry 1645// { 1646// AccountID accountID; // master public key for this account 1647// int64 balance; // in stroops 1648// SequenceNumber seqNum; // last sequence number used for this account 1649// uint32 numSubEntries; // number of sub-entries this account has 1650// // drives the reserve 1651// AccountID* inflationDest; // Account to vote for during inflation 1652// uint32 flags; // see AccountFlags 1653// 1654// string32 homeDomain; // can be used for reverse federation and memo lookup 1655// 1656// // fields used for signatures 1657// // thresholds stores unsigned bytes: [weight of master|low|medium|high] 1658// Thresholds thresholds; 1659// 1660// Signer signers<20>; // possible signers for this account 1661// 1662// // reserved for future use 1663// union switch (int v) 1664// { 1665// case 0: 1666// void; 1667// case 1: 1668// struct 1669// { 1670// Liabilities liabilities; 1671// 1672// union switch (int v) 1673// { 1674// case 0: 1675// void; 1676// } 1677// ext; 1678// } v1; 1679// } 1680// ext; 1681// }; 1682// 1683type AccountEntry struct { 1684 AccountId AccountId 1685 Balance Int64 1686 SeqNum SequenceNumber 1687 NumSubEntries Uint32 1688 InflationDest *AccountId 1689 Flags Uint32 1690 HomeDomain String32 1691 Thresholds Thresholds 1692 Signers []Signer `xdrmaxsize:"20"` 1693 Ext AccountEntryExt 1694} 1695 1696// MarshalBinary implements encoding.BinaryMarshaler. 1697func (s AccountEntry) MarshalBinary() ([]byte, error) { 1698 b := new(bytes.Buffer) 1699 _, err := Marshal(b, s) 1700 return b.Bytes(), err 1701} 1702 1703// UnmarshalBinary implements encoding.BinaryUnmarshaler. 1704func (s *AccountEntry) UnmarshalBinary(inp []byte) error { 1705 _, err := Unmarshal(bytes.NewReader(inp), s) 1706 return err 1707} 1708 1709var ( 1710 _ encoding.BinaryMarshaler = (*AccountEntry)(nil) 1711 _ encoding.BinaryUnmarshaler = (*AccountEntry)(nil) 1712) 1713 1714// TrustLineFlags is an XDR Enum defines as: 1715// 1716// enum TrustLineFlags 1717// { 1718// // issuer has authorized account to perform transactions with its credit 1719// AUTHORIZED_FLAG = 1 1720// }; 1721// 1722type TrustLineFlags int32 1723 1724const ( 1725 TrustLineFlagsAuthorizedFlag TrustLineFlags = 1 1726) 1727 1728var trustLineFlagsMap = map[int32]string{ 1729 1: "TrustLineFlagsAuthorizedFlag", 1730} 1731 1732// ValidEnum validates a proposed value for this enum. Implements 1733// the Enum interface for TrustLineFlags 1734func (e TrustLineFlags) ValidEnum(v int32) bool { 1735 _, ok := trustLineFlagsMap[v] 1736 return ok 1737} 1738 1739// String returns the name of `e` 1740func (e TrustLineFlags) String() string { 1741 name, _ := trustLineFlagsMap[int32(e)] 1742 return name 1743} 1744 1745// MarshalBinary implements encoding.BinaryMarshaler. 1746func (s TrustLineFlags) MarshalBinary() ([]byte, error) { 1747 b := new(bytes.Buffer) 1748 _, err := Marshal(b, s) 1749 return b.Bytes(), err 1750} 1751 1752// UnmarshalBinary implements encoding.BinaryUnmarshaler. 1753func (s *TrustLineFlags) UnmarshalBinary(inp []byte) error { 1754 _, err := Unmarshal(bytes.NewReader(inp), s) 1755 return err 1756} 1757 1758var ( 1759 _ encoding.BinaryMarshaler = (*TrustLineFlags)(nil) 1760 _ encoding.BinaryUnmarshaler = (*TrustLineFlags)(nil) 1761) 1762 1763// MaskTrustlineFlags is an XDR Const defines as: 1764// 1765// const MASK_TRUSTLINE_FLAGS = 1; 1766// 1767const MaskTrustlineFlags = 1 1768 1769// TrustLineEntryV1Ext is an XDR NestedUnion defines as: 1770// 1771// union switch (int v) 1772// { 1773// case 0: 1774// void; 1775// } 1776// 1777type TrustLineEntryV1Ext struct { 1778 V int32 1779} 1780 1781// SwitchFieldName returns the field name in which this union's 1782// discriminant is stored 1783func (u TrustLineEntryV1Ext) SwitchFieldName() string { 1784 return "V" 1785} 1786 1787// ArmForSwitch returns which field name should be used for storing 1788// the value for an instance of TrustLineEntryV1Ext 1789func (u TrustLineEntryV1Ext) ArmForSwitch(sw int32) (string, bool) { 1790 switch int32(sw) { 1791 case 0: 1792 return "", true 1793 } 1794 return "-", false 1795} 1796 1797// NewTrustLineEntryV1Ext creates a new TrustLineEntryV1Ext. 1798func NewTrustLineEntryV1Ext(v int32, value interface{}) (result TrustLineEntryV1Ext, err error) { 1799 result.V = v 1800 switch int32(v) { 1801 case 0: 1802 // void 1803 } 1804 return 1805} 1806 1807// MarshalBinary implements encoding.BinaryMarshaler. 1808func (s TrustLineEntryV1Ext) MarshalBinary() ([]byte, error) { 1809 b := new(bytes.Buffer) 1810 _, err := Marshal(b, s) 1811 return b.Bytes(), err 1812} 1813 1814// UnmarshalBinary implements encoding.BinaryUnmarshaler. 1815func (s *TrustLineEntryV1Ext) UnmarshalBinary(inp []byte) error { 1816 _, err := Unmarshal(bytes.NewReader(inp), s) 1817 return err 1818} 1819 1820var ( 1821 _ encoding.BinaryMarshaler = (*TrustLineEntryV1Ext)(nil) 1822 _ encoding.BinaryUnmarshaler = (*TrustLineEntryV1Ext)(nil) 1823) 1824 1825// TrustLineEntryV1 is an XDR NestedStruct defines as: 1826// 1827// struct 1828// { 1829// Liabilities liabilities; 1830// 1831// union switch (int v) 1832// { 1833// case 0: 1834// void; 1835// } 1836// ext; 1837// } 1838// 1839type TrustLineEntryV1 struct { 1840 Liabilities Liabilities 1841 Ext TrustLineEntryV1Ext 1842} 1843 1844// MarshalBinary implements encoding.BinaryMarshaler. 1845func (s TrustLineEntryV1) MarshalBinary() ([]byte, error) { 1846 b := new(bytes.Buffer) 1847 _, err := Marshal(b, s) 1848 return b.Bytes(), err 1849} 1850 1851// UnmarshalBinary implements encoding.BinaryUnmarshaler. 1852func (s *TrustLineEntryV1) UnmarshalBinary(inp []byte) error { 1853 _, err := Unmarshal(bytes.NewReader(inp), s) 1854 return err 1855} 1856 1857var ( 1858 _ encoding.BinaryMarshaler = (*TrustLineEntryV1)(nil) 1859 _ encoding.BinaryUnmarshaler = (*TrustLineEntryV1)(nil) 1860) 1861 1862// TrustLineEntryExt is an XDR NestedUnion defines as: 1863// 1864// union switch (int v) 1865// { 1866// case 0: 1867// void; 1868// case 1: 1869// struct 1870// { 1871// Liabilities liabilities; 1872// 1873// union switch (int v) 1874// { 1875// case 0: 1876// void; 1877// } 1878// ext; 1879// } v1; 1880// } 1881// 1882type TrustLineEntryExt struct { 1883 V int32 1884 V1 *TrustLineEntryV1 1885} 1886 1887// SwitchFieldName returns the field name in which this union's 1888// discriminant is stored 1889func (u TrustLineEntryExt) SwitchFieldName() string { 1890 return "V" 1891} 1892 1893// ArmForSwitch returns which field name should be used for storing 1894// the value for an instance of TrustLineEntryExt 1895func (u TrustLineEntryExt) ArmForSwitch(sw int32) (string, bool) { 1896 switch int32(sw) { 1897 case 0: 1898 return "", true 1899 case 1: 1900 return "V1", true 1901 } 1902 return "-", false 1903} 1904 1905// NewTrustLineEntryExt creates a new TrustLineEntryExt. 1906func NewTrustLineEntryExt(v int32, value interface{}) (result TrustLineEntryExt, err error) { 1907 result.V = v 1908 switch int32(v) { 1909 case 0: 1910 // void 1911 case 1: 1912 tv, ok := value.(TrustLineEntryV1) 1913 if !ok { 1914 err = fmt.Errorf("invalid value, must be TrustLineEntryV1") 1915 return 1916 } 1917 result.V1 = &tv 1918 } 1919 return 1920} 1921 1922// MustV1 retrieves the V1 value from the union, 1923// panicing if the value is not set. 1924func (u TrustLineEntryExt) MustV1() TrustLineEntryV1 { 1925 val, ok := u.GetV1() 1926 1927 if !ok { 1928 panic("arm V1 is not set") 1929 } 1930 1931 return val 1932} 1933 1934// GetV1 retrieves the V1 value from the union, 1935// returning ok if the union's switch indicated the value is valid. 1936func (u TrustLineEntryExt) GetV1() (result TrustLineEntryV1, ok bool) { 1937 armName, _ := u.ArmForSwitch(int32(u.V)) 1938 1939 if armName == "V1" { 1940 result = *u.V1 1941 ok = true 1942 } 1943 1944 return 1945} 1946 1947// MarshalBinary implements encoding.BinaryMarshaler. 1948func (s TrustLineEntryExt) MarshalBinary() ([]byte, error) { 1949 b := new(bytes.Buffer) 1950 _, err := Marshal(b, s) 1951 return b.Bytes(), err 1952} 1953 1954// UnmarshalBinary implements encoding.BinaryUnmarshaler. 1955func (s *TrustLineEntryExt) UnmarshalBinary(inp []byte) error { 1956 _, err := Unmarshal(bytes.NewReader(inp), s) 1957 return err 1958} 1959 1960var ( 1961 _ encoding.BinaryMarshaler = (*TrustLineEntryExt)(nil) 1962 _ encoding.BinaryUnmarshaler = (*TrustLineEntryExt)(nil) 1963) 1964 1965// TrustLineEntry is an XDR Struct defines as: 1966// 1967// struct TrustLineEntry 1968// { 1969// AccountID accountID; // account this trustline belongs to 1970// Asset asset; // type of asset (with issuer) 1971// int64 balance; // how much of this asset the user has. 1972// // Asset defines the unit for this; 1973// 1974// int64 limit; // balance cannot be above this 1975// uint32 flags; // see TrustLineFlags 1976// 1977// // reserved for future use 1978// union switch (int v) 1979// { 1980// case 0: 1981// void; 1982// case 1: 1983// struct 1984// { 1985// Liabilities liabilities; 1986// 1987// union switch (int v) 1988// { 1989// case 0: 1990// void; 1991// } 1992// ext; 1993// } v1; 1994// } 1995// ext; 1996// }; 1997// 1998type TrustLineEntry struct { 1999 AccountId AccountId 2000 Asset Asset 2001 Balance Int64 2002 Limit Int64 2003 Flags Uint32 2004 Ext TrustLineEntryExt 2005} 2006 2007// MarshalBinary implements encoding.BinaryMarshaler. 2008func (s TrustLineEntry) MarshalBinary() ([]byte, error) { 2009 b := new(bytes.Buffer) 2010 _, err := Marshal(b, s) 2011 return b.Bytes(), err 2012} 2013 2014// UnmarshalBinary implements encoding.BinaryUnmarshaler. 2015func (s *TrustLineEntry) UnmarshalBinary(inp []byte) error { 2016 _, err := Unmarshal(bytes.NewReader(inp), s) 2017 return err 2018} 2019 2020var ( 2021 _ encoding.BinaryMarshaler = (*TrustLineEntry)(nil) 2022 _ encoding.BinaryUnmarshaler = (*TrustLineEntry)(nil) 2023) 2024 2025// OfferEntryFlags is an XDR Enum defines as: 2026// 2027// enum OfferEntryFlags 2028// { 2029// // issuer has authorized account to perform transactions with its credit 2030// PASSIVE_FLAG = 1 2031// }; 2032// 2033type OfferEntryFlags int32 2034 2035const ( 2036 OfferEntryFlagsPassiveFlag OfferEntryFlags = 1 2037) 2038 2039var offerEntryFlagsMap = map[int32]string{ 2040 1: "OfferEntryFlagsPassiveFlag", 2041} 2042 2043// ValidEnum validates a proposed value for this enum. Implements 2044// the Enum interface for OfferEntryFlags 2045func (e OfferEntryFlags) ValidEnum(v int32) bool { 2046 _, ok := offerEntryFlagsMap[v] 2047 return ok 2048} 2049 2050// String returns the name of `e` 2051func (e OfferEntryFlags) String() string { 2052 name, _ := offerEntryFlagsMap[int32(e)] 2053 return name 2054} 2055 2056// MarshalBinary implements encoding.BinaryMarshaler. 2057func (s OfferEntryFlags) MarshalBinary() ([]byte, error) { 2058 b := new(bytes.Buffer) 2059 _, err := Marshal(b, s) 2060 return b.Bytes(), err 2061} 2062 2063// UnmarshalBinary implements encoding.BinaryUnmarshaler. 2064func (s *OfferEntryFlags) UnmarshalBinary(inp []byte) error { 2065 _, err := Unmarshal(bytes.NewReader(inp), s) 2066 return err 2067} 2068 2069var ( 2070 _ encoding.BinaryMarshaler = (*OfferEntryFlags)(nil) 2071 _ encoding.BinaryUnmarshaler = (*OfferEntryFlags)(nil) 2072) 2073 2074// MaskOfferentryFlags is an XDR Const defines as: 2075// 2076// const MASK_OFFERENTRY_FLAGS = 1; 2077// 2078const MaskOfferentryFlags = 1 2079 2080// OfferEntryExt is an XDR NestedUnion defines as: 2081// 2082// union switch (int v) 2083// { 2084// case 0: 2085// void; 2086// } 2087// 2088type OfferEntryExt struct { 2089 V int32 2090} 2091 2092// SwitchFieldName returns the field name in which this union's 2093// discriminant is stored 2094func (u OfferEntryExt) SwitchFieldName() string { 2095 return "V" 2096} 2097 2098// ArmForSwitch returns which field name should be used for storing 2099// the value for an instance of OfferEntryExt 2100func (u OfferEntryExt) ArmForSwitch(sw int32) (string, bool) { 2101 switch int32(sw) { 2102 case 0: 2103 return "", true 2104 } 2105 return "-", false 2106} 2107 2108// NewOfferEntryExt creates a new OfferEntryExt. 2109func NewOfferEntryExt(v int32, value interface{}) (result OfferEntryExt, err error) { 2110 result.V = v 2111 switch int32(v) { 2112 case 0: 2113 // void 2114 } 2115 return 2116} 2117 2118// MarshalBinary implements encoding.BinaryMarshaler. 2119func (s OfferEntryExt) MarshalBinary() ([]byte, error) { 2120 b := new(bytes.Buffer) 2121 _, err := Marshal(b, s) 2122 return b.Bytes(), err 2123} 2124 2125// UnmarshalBinary implements encoding.BinaryUnmarshaler. 2126func (s *OfferEntryExt) UnmarshalBinary(inp []byte) error { 2127 _, err := Unmarshal(bytes.NewReader(inp), s) 2128 return err 2129} 2130 2131var ( 2132 _ encoding.BinaryMarshaler = (*OfferEntryExt)(nil) 2133 _ encoding.BinaryUnmarshaler = (*OfferEntryExt)(nil) 2134) 2135 2136// OfferEntry is an XDR Struct defines as: 2137// 2138// struct OfferEntry 2139// { 2140// AccountID sellerID; 2141// int64 offerID; 2142// Asset selling; // A 2143// Asset buying; // B 2144// int64 amount; // amount of A 2145// 2146// /* price for this offer: 2147// price of A in terms of B 2148// price=AmountB/AmountA=priceNumerator/priceDenominator 2149// price is after fees 2150// */ 2151// Price price; 2152// uint32 flags; // see OfferEntryFlags 2153// 2154// // reserved for future use 2155// union switch (int v) 2156// { 2157// case 0: 2158// void; 2159// } 2160// ext; 2161// }; 2162// 2163type OfferEntry struct { 2164 SellerId AccountId 2165 OfferId Int64 2166 Selling Asset 2167 Buying Asset 2168 Amount Int64 2169 Price Price 2170 Flags Uint32 2171 Ext OfferEntryExt 2172} 2173 2174// MarshalBinary implements encoding.BinaryMarshaler. 2175func (s OfferEntry) MarshalBinary() ([]byte, error) { 2176 b := new(bytes.Buffer) 2177 _, err := Marshal(b, s) 2178 return b.Bytes(), err 2179} 2180 2181// UnmarshalBinary implements encoding.BinaryUnmarshaler. 2182func (s *OfferEntry) UnmarshalBinary(inp []byte) error { 2183 _, err := Unmarshal(bytes.NewReader(inp), s) 2184 return err 2185} 2186 2187var ( 2188 _ encoding.BinaryMarshaler = (*OfferEntry)(nil) 2189 _ encoding.BinaryUnmarshaler = (*OfferEntry)(nil) 2190) 2191 2192// DataEntryExt is an XDR NestedUnion defines as: 2193// 2194// union switch (int v) 2195// { 2196// case 0: 2197// void; 2198// } 2199// 2200type DataEntryExt struct { 2201 V int32 2202} 2203 2204// SwitchFieldName returns the field name in which this union's 2205// discriminant is stored 2206func (u DataEntryExt) SwitchFieldName() string { 2207 return "V" 2208} 2209 2210// ArmForSwitch returns which field name should be used for storing 2211// the value for an instance of DataEntryExt 2212func (u DataEntryExt) ArmForSwitch(sw int32) (string, bool) { 2213 switch int32(sw) { 2214 case 0: 2215 return "", true 2216 } 2217 return "-", false 2218} 2219 2220// NewDataEntryExt creates a new DataEntryExt. 2221func NewDataEntryExt(v int32, value interface{}) (result DataEntryExt, err error) { 2222 result.V = v 2223 switch int32(v) { 2224 case 0: 2225 // void 2226 } 2227 return 2228} 2229 2230// MarshalBinary implements encoding.BinaryMarshaler. 2231func (s DataEntryExt) MarshalBinary() ([]byte, error) { 2232 b := new(bytes.Buffer) 2233 _, err := Marshal(b, s) 2234 return b.Bytes(), err 2235} 2236 2237// UnmarshalBinary implements encoding.BinaryUnmarshaler. 2238func (s *DataEntryExt) UnmarshalBinary(inp []byte) error { 2239 _, err := Unmarshal(bytes.NewReader(inp), s) 2240 return err 2241} 2242 2243var ( 2244 _ encoding.BinaryMarshaler = (*DataEntryExt)(nil) 2245 _ encoding.BinaryUnmarshaler = (*DataEntryExt)(nil) 2246) 2247 2248// DataEntry is an XDR Struct defines as: 2249// 2250// struct DataEntry 2251// { 2252// AccountID accountID; // account this data belongs to 2253// string64 dataName; 2254// DataValue dataValue; 2255// 2256// // reserved for future use 2257// union switch (int v) 2258// { 2259// case 0: 2260// void; 2261// } 2262// ext; 2263// }; 2264// 2265type DataEntry struct { 2266 AccountId AccountId 2267 DataName String64 2268 DataValue DataValue 2269 Ext DataEntryExt 2270} 2271 2272// MarshalBinary implements encoding.BinaryMarshaler. 2273func (s DataEntry) MarshalBinary() ([]byte, error) { 2274 b := new(bytes.Buffer) 2275 _, err := Marshal(b, s) 2276 return b.Bytes(), err 2277} 2278 2279// UnmarshalBinary implements encoding.BinaryUnmarshaler. 2280func (s *DataEntry) UnmarshalBinary(inp []byte) error { 2281 _, err := Unmarshal(bytes.NewReader(inp), s) 2282 return err 2283} 2284 2285var ( 2286 _ encoding.BinaryMarshaler = (*DataEntry)(nil) 2287 _ encoding.BinaryUnmarshaler = (*DataEntry)(nil) 2288) 2289 2290// LedgerEntryData is an XDR NestedUnion defines as: 2291// 2292// union switch (LedgerEntryType type) 2293// { 2294// case ACCOUNT: 2295// AccountEntry account; 2296// case TRUSTLINE: 2297// TrustLineEntry trustLine; 2298// case OFFER: 2299// OfferEntry offer; 2300// case DATA: 2301// DataEntry data; 2302// } 2303// 2304type LedgerEntryData struct { 2305 Type LedgerEntryType 2306 Account *AccountEntry 2307 TrustLine *TrustLineEntry 2308 Offer *OfferEntry 2309 Data *DataEntry 2310} 2311 2312// SwitchFieldName returns the field name in which this union's 2313// discriminant is stored 2314func (u LedgerEntryData) SwitchFieldName() string { 2315 return "Type" 2316} 2317 2318// ArmForSwitch returns which field name should be used for storing 2319// the value for an instance of LedgerEntryData 2320func (u LedgerEntryData) ArmForSwitch(sw int32) (string, bool) { 2321 switch LedgerEntryType(sw) { 2322 case LedgerEntryTypeAccount: 2323 return "Account", true 2324 case LedgerEntryTypeTrustline: 2325 return "TrustLine", true 2326 case LedgerEntryTypeOffer: 2327 return "Offer", true 2328 case LedgerEntryTypeData: 2329 return "Data", true 2330 } 2331 return "-", false 2332} 2333 2334// NewLedgerEntryData creates a new LedgerEntryData. 2335func NewLedgerEntryData(aType LedgerEntryType, value interface{}) (result LedgerEntryData, err error) { 2336 result.Type = aType 2337 switch LedgerEntryType(aType) { 2338 case LedgerEntryTypeAccount: 2339 tv, ok := value.(AccountEntry) 2340 if !ok { 2341 err = fmt.Errorf("invalid value, must be AccountEntry") 2342 return 2343 } 2344 result.Account = &tv 2345 case LedgerEntryTypeTrustline: 2346 tv, ok := value.(TrustLineEntry) 2347 if !ok { 2348 err = fmt.Errorf("invalid value, must be TrustLineEntry") 2349 return 2350 } 2351 result.TrustLine = &tv 2352 case LedgerEntryTypeOffer: 2353 tv, ok := value.(OfferEntry) 2354 if !ok { 2355 err = fmt.Errorf("invalid value, must be OfferEntry") 2356 return 2357 } 2358 result.Offer = &tv 2359 case LedgerEntryTypeData: 2360 tv, ok := value.(DataEntry) 2361 if !ok { 2362 err = fmt.Errorf("invalid value, must be DataEntry") 2363 return 2364 } 2365 result.Data = &tv 2366 } 2367 return 2368} 2369 2370// MustAccount retrieves the Account value from the union, 2371// panicing if the value is not set. 2372func (u LedgerEntryData) MustAccount() AccountEntry { 2373 val, ok := u.GetAccount() 2374 2375 if !ok { 2376 panic("arm Account is not set") 2377 } 2378 2379 return val 2380} 2381 2382// GetAccount retrieves the Account value from the union, 2383// returning ok if the union's switch indicated the value is valid. 2384func (u LedgerEntryData) GetAccount() (result AccountEntry, ok bool) { 2385 armName, _ := u.ArmForSwitch(int32(u.Type)) 2386 2387 if armName == "Account" { 2388 result = *u.Account 2389 ok = true 2390 } 2391 2392 return 2393} 2394 2395// MustTrustLine retrieves the TrustLine value from the union, 2396// panicing if the value is not set. 2397func (u LedgerEntryData) MustTrustLine() TrustLineEntry { 2398 val, ok := u.GetTrustLine() 2399 2400 if !ok { 2401 panic("arm TrustLine is not set") 2402 } 2403 2404 return val 2405} 2406 2407// GetTrustLine retrieves the TrustLine value from the union, 2408// returning ok if the union's switch indicated the value is valid. 2409func (u LedgerEntryData) GetTrustLine() (result TrustLineEntry, ok bool) { 2410 armName, _ := u.ArmForSwitch(int32(u.Type)) 2411 2412 if armName == "TrustLine" { 2413 result = *u.TrustLine 2414 ok = true 2415 } 2416 2417 return 2418} 2419 2420// MustOffer retrieves the Offer value from the union, 2421// panicing if the value is not set. 2422func (u LedgerEntryData) MustOffer() OfferEntry { 2423 val, ok := u.GetOffer() 2424 2425 if !ok { 2426 panic("arm Offer is not set") 2427 } 2428 2429 return val 2430} 2431 2432// GetOffer retrieves the Offer value from the union, 2433// returning ok if the union's switch indicated the value is valid. 2434func (u LedgerEntryData) GetOffer() (result OfferEntry, ok bool) { 2435 armName, _ := u.ArmForSwitch(int32(u.Type)) 2436 2437 if armName == "Offer" { 2438 result = *u.Offer 2439 ok = true 2440 } 2441 2442 return 2443} 2444 2445// MustData retrieves the Data value from the union, 2446// panicing if the value is not set. 2447func (u LedgerEntryData) MustData() DataEntry { 2448 val, ok := u.GetData() 2449 2450 if !ok { 2451 panic("arm Data is not set") 2452 } 2453 2454 return val 2455} 2456 2457// GetData retrieves the Data value from the union, 2458// returning ok if the union's switch indicated the value is valid. 2459func (u LedgerEntryData) GetData() (result DataEntry, ok bool) { 2460 armName, _ := u.ArmForSwitch(int32(u.Type)) 2461 2462 if armName == "Data" { 2463 result = *u.Data 2464 ok = true 2465 } 2466 2467 return 2468} 2469 2470// MarshalBinary implements encoding.BinaryMarshaler. 2471func (s LedgerEntryData) MarshalBinary() ([]byte, error) { 2472 b := new(bytes.Buffer) 2473 _, err := Marshal(b, s) 2474 return b.Bytes(), err 2475} 2476 2477// UnmarshalBinary implements encoding.BinaryUnmarshaler. 2478func (s *LedgerEntryData) UnmarshalBinary(inp []byte) error { 2479 _, err := Unmarshal(bytes.NewReader(inp), s) 2480 return err 2481} 2482 2483var ( 2484 _ encoding.BinaryMarshaler = (*LedgerEntryData)(nil) 2485 _ encoding.BinaryUnmarshaler = (*LedgerEntryData)(nil) 2486) 2487 2488// LedgerEntryExt is an XDR NestedUnion defines as: 2489// 2490// union switch (int v) 2491// { 2492// case 0: 2493// void; 2494// } 2495// 2496type LedgerEntryExt struct { 2497 V int32 2498} 2499 2500// SwitchFieldName returns the field name in which this union's 2501// discriminant is stored 2502func (u LedgerEntryExt) SwitchFieldName() string { 2503 return "V" 2504} 2505 2506// ArmForSwitch returns which field name should be used for storing 2507// the value for an instance of LedgerEntryExt 2508func (u LedgerEntryExt) ArmForSwitch(sw int32) (string, bool) { 2509 switch int32(sw) { 2510 case 0: 2511 return "", true 2512 } 2513 return "-", false 2514} 2515 2516// NewLedgerEntryExt creates a new LedgerEntryExt. 2517func NewLedgerEntryExt(v int32, value interface{}) (result LedgerEntryExt, err error) { 2518 result.V = v 2519 switch int32(v) { 2520 case 0: 2521 // void 2522 } 2523 return 2524} 2525 2526// MarshalBinary implements encoding.BinaryMarshaler. 2527func (s LedgerEntryExt) MarshalBinary() ([]byte, error) { 2528 b := new(bytes.Buffer) 2529 _, err := Marshal(b, s) 2530 return b.Bytes(), err 2531} 2532 2533// UnmarshalBinary implements encoding.BinaryUnmarshaler. 2534func (s *LedgerEntryExt) UnmarshalBinary(inp []byte) error { 2535 _, err := Unmarshal(bytes.NewReader(inp), s) 2536 return err 2537} 2538 2539var ( 2540 _ encoding.BinaryMarshaler = (*LedgerEntryExt)(nil) 2541 _ encoding.BinaryUnmarshaler = (*LedgerEntryExt)(nil) 2542) 2543 2544// LedgerEntry is an XDR Struct defines as: 2545// 2546// struct LedgerEntry 2547// { 2548// uint32 lastModifiedLedgerSeq; // ledger the LedgerEntry was last changed 2549// 2550// union switch (LedgerEntryType type) 2551// { 2552// case ACCOUNT: 2553// AccountEntry account; 2554// case TRUSTLINE: 2555// TrustLineEntry trustLine; 2556// case OFFER: 2557// OfferEntry offer; 2558// case DATA: 2559// DataEntry data; 2560// } 2561// data; 2562// 2563// // reserved for future use 2564// union switch (int v) 2565// { 2566// case 0: 2567// void; 2568// } 2569// ext; 2570// }; 2571// 2572type LedgerEntry struct { 2573 LastModifiedLedgerSeq Uint32 2574 Data LedgerEntryData 2575 Ext LedgerEntryExt 2576} 2577 2578// MarshalBinary implements encoding.BinaryMarshaler. 2579func (s LedgerEntry) MarshalBinary() ([]byte, error) { 2580 b := new(bytes.Buffer) 2581 _, err := Marshal(b, s) 2582 return b.Bytes(), err 2583} 2584 2585// UnmarshalBinary implements encoding.BinaryUnmarshaler. 2586func (s *LedgerEntry) UnmarshalBinary(inp []byte) error { 2587 _, err := Unmarshal(bytes.NewReader(inp), s) 2588 return err 2589} 2590 2591var ( 2592 _ encoding.BinaryMarshaler = (*LedgerEntry)(nil) 2593 _ encoding.BinaryUnmarshaler = (*LedgerEntry)(nil) 2594) 2595 2596// EnvelopeType is an XDR Enum defines as: 2597// 2598// enum EnvelopeType 2599// { 2600// ENVELOPE_TYPE_SCP = 1, 2601// ENVELOPE_TYPE_TX = 2, 2602// ENVELOPE_TYPE_AUTH = 3, 2603// ENVELOPE_TYPE_SCPVALUE = 4 2604// }; 2605// 2606type EnvelopeType int32 2607 2608const ( 2609 EnvelopeTypeEnvelopeTypeScp EnvelopeType = 1 2610 EnvelopeTypeEnvelopeTypeTx EnvelopeType = 2 2611 EnvelopeTypeEnvelopeTypeAuth EnvelopeType = 3 2612 EnvelopeTypeEnvelopeTypeScpvalue EnvelopeType = 4 2613) 2614 2615var envelopeTypeMap = map[int32]string{ 2616 1: "EnvelopeTypeEnvelopeTypeScp", 2617 2: "EnvelopeTypeEnvelopeTypeTx", 2618 3: "EnvelopeTypeEnvelopeTypeAuth", 2619 4: "EnvelopeTypeEnvelopeTypeScpvalue", 2620} 2621 2622// ValidEnum validates a proposed value for this enum. Implements 2623// the Enum interface for EnvelopeType 2624func (e EnvelopeType) ValidEnum(v int32) bool { 2625 _, ok := envelopeTypeMap[v] 2626 return ok 2627} 2628 2629// String returns the name of `e` 2630func (e EnvelopeType) String() string { 2631 name, _ := envelopeTypeMap[int32(e)] 2632 return name 2633} 2634 2635// MarshalBinary implements encoding.BinaryMarshaler. 2636func (s EnvelopeType) MarshalBinary() ([]byte, error) { 2637 b := new(bytes.Buffer) 2638 _, err := Marshal(b, s) 2639 return b.Bytes(), err 2640} 2641 2642// UnmarshalBinary implements encoding.BinaryUnmarshaler. 2643func (s *EnvelopeType) UnmarshalBinary(inp []byte) error { 2644 _, err := Unmarshal(bytes.NewReader(inp), s) 2645 return err 2646} 2647 2648var ( 2649 _ encoding.BinaryMarshaler = (*EnvelopeType)(nil) 2650 _ encoding.BinaryUnmarshaler = (*EnvelopeType)(nil) 2651) 2652 2653// UpgradeType is an XDR Typedef defines as: 2654// 2655// typedef opaque UpgradeType<128>; 2656// 2657type UpgradeType []byte 2658 2659// XDRMaxSize implements the Sized interface for UpgradeType 2660func (e UpgradeType) XDRMaxSize() int { 2661 return 128 2662} 2663 2664// MarshalBinary implements encoding.BinaryMarshaler. 2665func (s UpgradeType) MarshalBinary() ([]byte, error) { 2666 b := new(bytes.Buffer) 2667 _, err := Marshal(b, s) 2668 return b.Bytes(), err 2669} 2670 2671// UnmarshalBinary implements encoding.BinaryUnmarshaler. 2672func (s *UpgradeType) UnmarshalBinary(inp []byte) error { 2673 _, err := Unmarshal(bytes.NewReader(inp), s) 2674 return err 2675} 2676 2677var ( 2678 _ encoding.BinaryMarshaler = (*UpgradeType)(nil) 2679 _ encoding.BinaryUnmarshaler = (*UpgradeType)(nil) 2680) 2681 2682// StellarValueType is an XDR Enum defines as: 2683// 2684// enum StellarValueType 2685// { 2686// STELLAR_VALUE_BASIC = 0, 2687// STELLAR_VALUE_SIGNED = 1 2688// }; 2689// 2690type StellarValueType int32 2691 2692const ( 2693 StellarValueTypeStellarValueBasic StellarValueType = 0 2694 StellarValueTypeStellarValueSigned StellarValueType = 1 2695) 2696 2697var stellarValueTypeMap = map[int32]string{ 2698 0: "StellarValueTypeStellarValueBasic", 2699 1: "StellarValueTypeStellarValueSigned", 2700} 2701 2702// ValidEnum validates a proposed value for this enum. Implements 2703// the Enum interface for StellarValueType 2704func (e StellarValueType) ValidEnum(v int32) bool { 2705 _, ok := stellarValueTypeMap[v] 2706 return ok 2707} 2708 2709// String returns the name of `e` 2710func (e StellarValueType) String() string { 2711 name, _ := stellarValueTypeMap[int32(e)] 2712 return name 2713} 2714 2715// MarshalBinary implements encoding.BinaryMarshaler. 2716func (s StellarValueType) MarshalBinary() ([]byte, error) { 2717 b := new(bytes.Buffer) 2718 _, err := Marshal(b, s) 2719 return b.Bytes(), err 2720} 2721 2722// UnmarshalBinary implements encoding.BinaryUnmarshaler. 2723func (s *StellarValueType) UnmarshalBinary(inp []byte) error { 2724 _, err := Unmarshal(bytes.NewReader(inp), s) 2725 return err 2726} 2727 2728var ( 2729 _ encoding.BinaryMarshaler = (*StellarValueType)(nil) 2730 _ encoding.BinaryUnmarshaler = (*StellarValueType)(nil) 2731) 2732 2733// LedgerCloseValueSignature is an XDR Struct defines as: 2734// 2735// struct LedgerCloseValueSignature 2736// { 2737// NodeID nodeID; // which node introduced the value 2738// Signature signature; // nodeID's signature 2739// }; 2740// 2741type LedgerCloseValueSignature struct { 2742 NodeId NodeId 2743 Signature Signature 2744} 2745 2746// MarshalBinary implements encoding.BinaryMarshaler. 2747func (s LedgerCloseValueSignature) MarshalBinary() ([]byte, error) { 2748 b := new(bytes.Buffer) 2749 _, err := Marshal(b, s) 2750 return b.Bytes(), err 2751} 2752 2753// UnmarshalBinary implements encoding.BinaryUnmarshaler. 2754func (s *LedgerCloseValueSignature) UnmarshalBinary(inp []byte) error { 2755 _, err := Unmarshal(bytes.NewReader(inp), s) 2756 return err 2757} 2758 2759var ( 2760 _ encoding.BinaryMarshaler = (*LedgerCloseValueSignature)(nil) 2761 _ encoding.BinaryUnmarshaler = (*LedgerCloseValueSignature)(nil) 2762) 2763 2764// StellarValueExt is an XDR NestedUnion defines as: 2765// 2766// union switch (StellarValueType v) 2767// { 2768// case STELLAR_VALUE_BASIC: 2769// void; 2770// case STELLAR_VALUE_SIGNED: 2771// LedgerCloseValueSignature lcValueSignature; 2772// } 2773// 2774type StellarValueExt struct { 2775 V StellarValueType 2776 LcValueSignature *LedgerCloseValueSignature 2777} 2778 2779// SwitchFieldName returns the field name in which this union's 2780// discriminant is stored 2781func (u StellarValueExt) SwitchFieldName() string { 2782 return "V" 2783} 2784 2785// ArmForSwitch returns which field name should be used for storing 2786// the value for an instance of StellarValueExt 2787func (u StellarValueExt) ArmForSwitch(sw int32) (string, bool) { 2788 switch StellarValueType(sw) { 2789 case StellarValueTypeStellarValueBasic: 2790 return "", true 2791 case StellarValueTypeStellarValueSigned: 2792 return "LcValueSignature", true 2793 } 2794 return "-", false 2795} 2796 2797// NewStellarValueExt creates a new StellarValueExt. 2798func NewStellarValueExt(v StellarValueType, value interface{}) (result StellarValueExt, err error) { 2799 result.V = v 2800 switch StellarValueType(v) { 2801 case StellarValueTypeStellarValueBasic: 2802 // void 2803 case StellarValueTypeStellarValueSigned: 2804 tv, ok := value.(LedgerCloseValueSignature) 2805 if !ok { 2806 err = fmt.Errorf("invalid value, must be LedgerCloseValueSignature") 2807 return 2808 } 2809 result.LcValueSignature = &tv 2810 } 2811 return 2812} 2813 2814// MustLcValueSignature retrieves the LcValueSignature value from the union, 2815// panicing if the value is not set. 2816func (u StellarValueExt) MustLcValueSignature() LedgerCloseValueSignature { 2817 val, ok := u.GetLcValueSignature() 2818 2819 if !ok { 2820 panic("arm LcValueSignature is not set") 2821 } 2822 2823 return val 2824} 2825 2826// GetLcValueSignature retrieves the LcValueSignature value from the union, 2827// returning ok if the union's switch indicated the value is valid. 2828func (u StellarValueExt) GetLcValueSignature() (result LedgerCloseValueSignature, ok bool) { 2829 armName, _ := u.ArmForSwitch(int32(u.V)) 2830 2831 if armName == "LcValueSignature" { 2832 result = *u.LcValueSignature 2833 ok = true 2834 } 2835 2836 return 2837} 2838 2839// MarshalBinary implements encoding.BinaryMarshaler. 2840func (s StellarValueExt) MarshalBinary() ([]byte, error) { 2841 b := new(bytes.Buffer) 2842 _, err := Marshal(b, s) 2843 return b.Bytes(), err 2844} 2845 2846// UnmarshalBinary implements encoding.BinaryUnmarshaler. 2847func (s *StellarValueExt) UnmarshalBinary(inp []byte) error { 2848 _, err := Unmarshal(bytes.NewReader(inp), s) 2849 return err 2850} 2851 2852var ( 2853 _ encoding.BinaryMarshaler = (*StellarValueExt)(nil) 2854 _ encoding.BinaryUnmarshaler = (*StellarValueExt)(nil) 2855) 2856 2857// StellarValue is an XDR Struct defines as: 2858// 2859// struct StellarValue 2860// { 2861// Hash txSetHash; // transaction set to apply to previous ledger 2862// TimePoint closeTime; // network close time 2863// 2864// // upgrades to apply to the previous ledger (usually empty) 2865// // this is a vector of encoded 'LedgerUpgrade' so that nodes can drop 2866// // unknown steps during consensus if needed. 2867// // see notes below on 'LedgerUpgrade' for more detail 2868// // max size is dictated by number of upgrade types (+ room for future) 2869// UpgradeType upgrades<6>; 2870// 2871// // reserved for future use 2872// union switch (StellarValueType v) 2873// { 2874// case STELLAR_VALUE_BASIC: 2875// void; 2876// case STELLAR_VALUE_SIGNED: 2877// LedgerCloseValueSignature lcValueSignature; 2878// } 2879// ext; 2880// }; 2881// 2882type StellarValue struct { 2883 TxSetHash Hash 2884 CloseTime TimePoint 2885 Upgrades []UpgradeType `xdrmaxsize:"6"` 2886 Ext StellarValueExt 2887} 2888 2889// MarshalBinary implements encoding.BinaryMarshaler. 2890func (s StellarValue) MarshalBinary() ([]byte, error) { 2891 b := new(bytes.Buffer) 2892 _, err := Marshal(b, s) 2893 return b.Bytes(), err 2894} 2895 2896// UnmarshalBinary implements encoding.BinaryUnmarshaler. 2897func (s *StellarValue) UnmarshalBinary(inp []byte) error { 2898 _, err := Unmarshal(bytes.NewReader(inp), s) 2899 return err 2900} 2901 2902var ( 2903 _ encoding.BinaryMarshaler = (*StellarValue)(nil) 2904 _ encoding.BinaryUnmarshaler = (*StellarValue)(nil) 2905) 2906 2907// LedgerHeaderExt is an XDR NestedUnion defines as: 2908// 2909// union switch (int v) 2910// { 2911// case 0: 2912// void; 2913// } 2914// 2915type LedgerHeaderExt struct { 2916 V int32 2917} 2918 2919// SwitchFieldName returns the field name in which this union's 2920// discriminant is stored 2921func (u LedgerHeaderExt) SwitchFieldName() string { 2922 return "V" 2923} 2924 2925// ArmForSwitch returns which field name should be used for storing 2926// the value for an instance of LedgerHeaderExt 2927func (u LedgerHeaderExt) ArmForSwitch(sw int32) (string, bool) { 2928 switch int32(sw) { 2929 case 0: 2930 return "", true 2931 } 2932 return "-", false 2933} 2934 2935// NewLedgerHeaderExt creates a new LedgerHeaderExt. 2936func NewLedgerHeaderExt(v int32, value interface{}) (result LedgerHeaderExt, err error) { 2937 result.V = v 2938 switch int32(v) { 2939 case 0: 2940 // void 2941 } 2942 return 2943} 2944 2945// MarshalBinary implements encoding.BinaryMarshaler. 2946func (s LedgerHeaderExt) MarshalBinary() ([]byte, error) { 2947 b := new(bytes.Buffer) 2948 _, err := Marshal(b, s) 2949 return b.Bytes(), err 2950} 2951 2952// UnmarshalBinary implements encoding.BinaryUnmarshaler. 2953func (s *LedgerHeaderExt) UnmarshalBinary(inp []byte) error { 2954 _, err := Unmarshal(bytes.NewReader(inp), s) 2955 return err 2956} 2957 2958var ( 2959 _ encoding.BinaryMarshaler = (*LedgerHeaderExt)(nil) 2960 _ encoding.BinaryUnmarshaler = (*LedgerHeaderExt)(nil) 2961) 2962 2963// LedgerHeader is an XDR Struct defines as: 2964// 2965// struct LedgerHeader 2966// { 2967// uint32 ledgerVersion; // the protocol version of the ledger 2968// Hash previousLedgerHash; // hash of the previous ledger header 2969// StellarValue scpValue; // what consensus agreed to 2970// Hash txSetResultHash; // the TransactionResultSet that led to this ledger 2971// Hash bucketListHash; // hash of the ledger state 2972// 2973// uint32 ledgerSeq; // sequence number of this ledger 2974// 2975// int64 totalCoins; // total number of stroops in existence. 2976// // 10,000,000 stroops in 1 XLM 2977// 2978// int64 feePool; // fees burned since last inflation run 2979// uint32 inflationSeq; // inflation sequence number 2980// 2981// uint64 idPool; // last used global ID, used for generating objects 2982// 2983// uint32 baseFee; // base fee per operation in stroops 2984// uint32 baseReserve; // account base reserve in stroops 2985// 2986// uint32 maxTxSetSize; // maximum size a transaction set can be 2987// 2988// Hash skipList[4]; // hashes of ledgers in the past. allows you to jump back 2989// // in time without walking the chain back ledger by ledger 2990// // each slot contains the oldest ledger that is mod of 2991// // either 50 5000 50000 or 500000 depending on index 2992// // skipList[0] mod(50), skipList[1] mod(5000), etc 2993// 2994// // reserved for future use 2995// union switch (int v) 2996// { 2997// case 0: 2998// void; 2999// } 3000// ext; 3001// }; 3002// 3003type LedgerHeader struct { 3004 LedgerVersion Uint32 3005 PreviousLedgerHash Hash 3006 ScpValue StellarValue 3007 TxSetResultHash Hash 3008 BucketListHash Hash 3009 LedgerSeq Uint32 3010 TotalCoins Int64 3011 FeePool Int64 3012 InflationSeq Uint32 3013 IdPool Uint64 3014 BaseFee Uint32 3015 BaseReserve Uint32 3016 MaxTxSetSize Uint32 3017 SkipList [4]Hash 3018 Ext LedgerHeaderExt 3019} 3020 3021// MarshalBinary implements encoding.BinaryMarshaler. 3022func (s LedgerHeader) MarshalBinary() ([]byte, error) { 3023 b := new(bytes.Buffer) 3024 _, err := Marshal(b, s) 3025 return b.Bytes(), err 3026} 3027 3028// UnmarshalBinary implements encoding.BinaryUnmarshaler. 3029func (s *LedgerHeader) UnmarshalBinary(inp []byte) error { 3030 _, err := Unmarshal(bytes.NewReader(inp), s) 3031 return err 3032} 3033 3034var ( 3035 _ encoding.BinaryMarshaler = (*LedgerHeader)(nil) 3036 _ encoding.BinaryUnmarshaler = (*LedgerHeader)(nil) 3037) 3038 3039// LedgerUpgradeType is an XDR Enum defines as: 3040// 3041// enum LedgerUpgradeType 3042// { 3043// LEDGER_UPGRADE_VERSION = 1, 3044// LEDGER_UPGRADE_BASE_FEE = 2, 3045// LEDGER_UPGRADE_MAX_TX_SET_SIZE = 3, 3046// LEDGER_UPGRADE_BASE_RESERVE = 4 3047// }; 3048// 3049type LedgerUpgradeType int32 3050 3051const ( 3052 LedgerUpgradeTypeLedgerUpgradeVersion LedgerUpgradeType = 1 3053 LedgerUpgradeTypeLedgerUpgradeBaseFee LedgerUpgradeType = 2 3054 LedgerUpgradeTypeLedgerUpgradeMaxTxSetSize LedgerUpgradeType = 3 3055 LedgerUpgradeTypeLedgerUpgradeBaseReserve LedgerUpgradeType = 4 3056) 3057 3058var ledgerUpgradeTypeMap = map[int32]string{ 3059 1: "LedgerUpgradeTypeLedgerUpgradeVersion", 3060 2: "LedgerUpgradeTypeLedgerUpgradeBaseFee", 3061 3: "LedgerUpgradeTypeLedgerUpgradeMaxTxSetSize", 3062 4: "LedgerUpgradeTypeLedgerUpgradeBaseReserve", 3063} 3064 3065// ValidEnum validates a proposed value for this enum. Implements 3066// the Enum interface for LedgerUpgradeType 3067func (e LedgerUpgradeType) ValidEnum(v int32) bool { 3068 _, ok := ledgerUpgradeTypeMap[v] 3069 return ok 3070} 3071 3072// String returns the name of `e` 3073func (e LedgerUpgradeType) String() string { 3074 name, _ := ledgerUpgradeTypeMap[int32(e)] 3075 return name 3076} 3077 3078// MarshalBinary implements encoding.BinaryMarshaler. 3079func (s LedgerUpgradeType) MarshalBinary() ([]byte, error) { 3080 b := new(bytes.Buffer) 3081 _, err := Marshal(b, s) 3082 return b.Bytes(), err 3083} 3084 3085// UnmarshalBinary implements encoding.BinaryUnmarshaler. 3086func (s *LedgerUpgradeType) UnmarshalBinary(inp []byte) error { 3087 _, err := Unmarshal(bytes.NewReader(inp), s) 3088 return err 3089} 3090 3091var ( 3092 _ encoding.BinaryMarshaler = (*LedgerUpgradeType)(nil) 3093 _ encoding.BinaryUnmarshaler = (*LedgerUpgradeType)(nil) 3094) 3095 3096// LedgerUpgrade is an XDR Union defines as: 3097// 3098// union LedgerUpgrade switch (LedgerUpgradeType type) 3099// { 3100// case LEDGER_UPGRADE_VERSION: 3101// uint32 newLedgerVersion; // update ledgerVersion 3102// case LEDGER_UPGRADE_BASE_FEE: 3103// uint32 newBaseFee; // update baseFee 3104// case LEDGER_UPGRADE_MAX_TX_SET_SIZE: 3105// uint32 newMaxTxSetSize; // update maxTxSetSize 3106// case LEDGER_UPGRADE_BASE_RESERVE: 3107// uint32 newBaseReserve; // update baseReserve 3108// }; 3109// 3110type LedgerUpgrade struct { 3111 Type LedgerUpgradeType 3112 NewLedgerVersion *Uint32 3113 NewBaseFee *Uint32 3114 NewMaxTxSetSize *Uint32 3115 NewBaseReserve *Uint32 3116} 3117 3118// SwitchFieldName returns the field name in which this union's 3119// discriminant is stored 3120func (u LedgerUpgrade) SwitchFieldName() string { 3121 return "Type" 3122} 3123 3124// ArmForSwitch returns which field name should be used for storing 3125// the value for an instance of LedgerUpgrade 3126func (u LedgerUpgrade) ArmForSwitch(sw int32) (string, bool) { 3127 switch LedgerUpgradeType(sw) { 3128 case LedgerUpgradeTypeLedgerUpgradeVersion: 3129 return "NewLedgerVersion", true 3130 case LedgerUpgradeTypeLedgerUpgradeBaseFee: 3131 return "NewBaseFee", true 3132 case LedgerUpgradeTypeLedgerUpgradeMaxTxSetSize: 3133 return "NewMaxTxSetSize", true 3134 case LedgerUpgradeTypeLedgerUpgradeBaseReserve: 3135 return "NewBaseReserve", true 3136 } 3137 return "-", false 3138} 3139 3140// NewLedgerUpgrade creates a new LedgerUpgrade. 3141func NewLedgerUpgrade(aType LedgerUpgradeType, value interface{}) (result LedgerUpgrade, err error) { 3142 result.Type = aType 3143 switch LedgerUpgradeType(aType) { 3144 case LedgerUpgradeTypeLedgerUpgradeVersion: 3145 tv, ok := value.(Uint32) 3146 if !ok { 3147 err = fmt.Errorf("invalid value, must be Uint32") 3148 return 3149 } 3150 result.NewLedgerVersion = &tv 3151 case LedgerUpgradeTypeLedgerUpgradeBaseFee: 3152 tv, ok := value.(Uint32) 3153 if !ok { 3154 err = fmt.Errorf("invalid value, must be Uint32") 3155 return 3156 } 3157 result.NewBaseFee = &tv 3158 case LedgerUpgradeTypeLedgerUpgradeMaxTxSetSize: 3159 tv, ok := value.(Uint32) 3160 if !ok { 3161 err = fmt.Errorf("invalid value, must be Uint32") 3162 return 3163 } 3164 result.NewMaxTxSetSize = &tv 3165 case LedgerUpgradeTypeLedgerUpgradeBaseReserve: 3166 tv, ok := value.(Uint32) 3167 if !ok { 3168 err = fmt.Errorf("invalid value, must be Uint32") 3169 return 3170 } 3171 result.NewBaseReserve = &tv 3172 } 3173 return 3174} 3175 3176// MustNewLedgerVersion retrieves the NewLedgerVersion value from the union, 3177// panicing if the value is not set. 3178func (u LedgerUpgrade) MustNewLedgerVersion() Uint32 { 3179 val, ok := u.GetNewLedgerVersion() 3180 3181 if !ok { 3182 panic("arm NewLedgerVersion is not set") 3183 } 3184 3185 return val 3186} 3187 3188// GetNewLedgerVersion retrieves the NewLedgerVersion value from the union, 3189// returning ok if the union's switch indicated the value is valid. 3190func (u LedgerUpgrade) GetNewLedgerVersion() (result Uint32, ok bool) { 3191 armName, _ := u.ArmForSwitch(int32(u.Type)) 3192 3193 if armName == "NewLedgerVersion" { 3194 result = *u.NewLedgerVersion 3195 ok = true 3196 } 3197 3198 return 3199} 3200 3201// MustNewBaseFee retrieves the NewBaseFee value from the union, 3202// panicing if the value is not set. 3203func (u LedgerUpgrade) MustNewBaseFee() Uint32 { 3204 val, ok := u.GetNewBaseFee() 3205 3206 if !ok { 3207 panic("arm NewBaseFee is not set") 3208 } 3209 3210 return val 3211} 3212 3213// GetNewBaseFee retrieves the NewBaseFee value from the union, 3214// returning ok if the union's switch indicated the value is valid. 3215func (u LedgerUpgrade) GetNewBaseFee() (result Uint32, ok bool) { 3216 armName, _ := u.ArmForSwitch(int32(u.Type)) 3217 3218 if armName == "NewBaseFee" { 3219 result = *u.NewBaseFee 3220 ok = true 3221 } 3222 3223 return 3224} 3225 3226// MustNewMaxTxSetSize retrieves the NewMaxTxSetSize value from the union, 3227// panicing if the value is not set. 3228func (u LedgerUpgrade) MustNewMaxTxSetSize() Uint32 { 3229 val, ok := u.GetNewMaxTxSetSize() 3230 3231 if !ok { 3232 panic("arm NewMaxTxSetSize is not set") 3233 } 3234 3235 return val 3236} 3237 3238// GetNewMaxTxSetSize retrieves the NewMaxTxSetSize value from the union, 3239// returning ok if the union's switch indicated the value is valid. 3240func (u LedgerUpgrade) GetNewMaxTxSetSize() (result Uint32, ok bool) { 3241 armName, _ := u.ArmForSwitch(int32(u.Type)) 3242 3243 if armName == "NewMaxTxSetSize" { 3244 result = *u.NewMaxTxSetSize 3245 ok = true 3246 } 3247 3248 return 3249} 3250 3251// MustNewBaseReserve retrieves the NewBaseReserve value from the union, 3252// panicing if the value is not set. 3253func (u LedgerUpgrade) MustNewBaseReserve() Uint32 { 3254 val, ok := u.GetNewBaseReserve() 3255 3256 if !ok { 3257 panic("arm NewBaseReserve is not set") 3258 } 3259 3260 return val 3261} 3262 3263// GetNewBaseReserve retrieves the NewBaseReserve value from the union, 3264// returning ok if the union's switch indicated the value is valid. 3265func (u LedgerUpgrade) GetNewBaseReserve() (result Uint32, ok bool) { 3266 armName, _ := u.ArmForSwitch(int32(u.Type)) 3267 3268 if armName == "NewBaseReserve" { 3269 result = *u.NewBaseReserve 3270 ok = true 3271 } 3272 3273 return 3274} 3275 3276// MarshalBinary implements encoding.BinaryMarshaler. 3277func (s LedgerUpgrade) MarshalBinary() ([]byte, error) { 3278 b := new(bytes.Buffer) 3279 _, err := Marshal(b, s) 3280 return b.Bytes(), err 3281} 3282 3283// UnmarshalBinary implements encoding.BinaryUnmarshaler. 3284func (s *LedgerUpgrade) UnmarshalBinary(inp []byte) error { 3285 _, err := Unmarshal(bytes.NewReader(inp), s) 3286 return err 3287} 3288 3289var ( 3290 _ encoding.BinaryMarshaler = (*LedgerUpgrade)(nil) 3291 _ encoding.BinaryUnmarshaler = (*LedgerUpgrade)(nil) 3292) 3293 3294// LedgerKeyAccount is an XDR NestedStruct defines as: 3295// 3296// struct 3297// { 3298// AccountID accountID; 3299// } 3300// 3301type LedgerKeyAccount struct { 3302 AccountId AccountId 3303} 3304 3305// MarshalBinary implements encoding.BinaryMarshaler. 3306func (s LedgerKeyAccount) MarshalBinary() ([]byte, error) { 3307 b := new(bytes.Buffer) 3308 _, err := Marshal(b, s) 3309 return b.Bytes(), err 3310} 3311 3312// UnmarshalBinary implements encoding.BinaryUnmarshaler. 3313func (s *LedgerKeyAccount) UnmarshalBinary(inp []byte) error { 3314 _, err := Unmarshal(bytes.NewReader(inp), s) 3315 return err 3316} 3317 3318var ( 3319 _ encoding.BinaryMarshaler = (*LedgerKeyAccount)(nil) 3320 _ encoding.BinaryUnmarshaler = (*LedgerKeyAccount)(nil) 3321) 3322 3323// LedgerKeyTrustLine is an XDR NestedStruct defines as: 3324// 3325// struct 3326// { 3327// AccountID accountID; 3328// Asset asset; 3329// } 3330// 3331type LedgerKeyTrustLine struct { 3332 AccountId AccountId 3333 Asset Asset 3334} 3335 3336// MarshalBinary implements encoding.BinaryMarshaler. 3337func (s LedgerKeyTrustLine) MarshalBinary() ([]byte, error) { 3338 b := new(bytes.Buffer) 3339 _, err := Marshal(b, s) 3340 return b.Bytes(), err 3341} 3342 3343// UnmarshalBinary implements encoding.BinaryUnmarshaler. 3344func (s *LedgerKeyTrustLine) UnmarshalBinary(inp []byte) error { 3345 _, err := Unmarshal(bytes.NewReader(inp), s) 3346 return err 3347} 3348 3349var ( 3350 _ encoding.BinaryMarshaler = (*LedgerKeyTrustLine)(nil) 3351 _ encoding.BinaryUnmarshaler = (*LedgerKeyTrustLine)(nil) 3352) 3353 3354// LedgerKeyOffer is an XDR NestedStruct defines as: 3355// 3356// struct 3357// { 3358// AccountID sellerID; 3359// int64 offerID; 3360// } 3361// 3362type LedgerKeyOffer struct { 3363 SellerId AccountId 3364 OfferId Int64 3365} 3366 3367// MarshalBinary implements encoding.BinaryMarshaler. 3368func (s LedgerKeyOffer) MarshalBinary() ([]byte, error) { 3369 b := new(bytes.Buffer) 3370 _, err := Marshal(b, s) 3371 return b.Bytes(), err 3372} 3373 3374// UnmarshalBinary implements encoding.BinaryUnmarshaler. 3375func (s *LedgerKeyOffer) UnmarshalBinary(inp []byte) error { 3376 _, err := Unmarshal(bytes.NewReader(inp), s) 3377 return err 3378} 3379 3380var ( 3381 _ encoding.BinaryMarshaler = (*LedgerKeyOffer)(nil) 3382 _ encoding.BinaryUnmarshaler = (*LedgerKeyOffer)(nil) 3383) 3384 3385// LedgerKeyData is an XDR NestedStruct defines as: 3386// 3387// struct 3388// { 3389// AccountID accountID; 3390// string64 dataName; 3391// } 3392// 3393type LedgerKeyData struct { 3394 AccountId AccountId 3395 DataName String64 3396} 3397 3398// MarshalBinary implements encoding.BinaryMarshaler. 3399func (s LedgerKeyData) MarshalBinary() ([]byte, error) { 3400 b := new(bytes.Buffer) 3401 _, err := Marshal(b, s) 3402 return b.Bytes(), err 3403} 3404 3405// UnmarshalBinary implements encoding.BinaryUnmarshaler. 3406func (s *LedgerKeyData) UnmarshalBinary(inp []byte) error { 3407 _, err := Unmarshal(bytes.NewReader(inp), s) 3408 return err 3409} 3410 3411var ( 3412 _ encoding.BinaryMarshaler = (*LedgerKeyData)(nil) 3413 _ encoding.BinaryUnmarshaler = (*LedgerKeyData)(nil) 3414) 3415 3416// LedgerKey is an XDR Union defines as: 3417// 3418// union LedgerKey switch (LedgerEntryType type) 3419// { 3420// case ACCOUNT: 3421// struct 3422// { 3423// AccountID accountID; 3424// } account; 3425// 3426// case TRUSTLINE: 3427// struct 3428// { 3429// AccountID accountID; 3430// Asset asset; 3431// } trustLine; 3432// 3433// case OFFER: 3434// struct 3435// { 3436// AccountID sellerID; 3437// int64 offerID; 3438// } offer; 3439// 3440// case DATA: 3441// struct 3442// { 3443// AccountID accountID; 3444// string64 dataName; 3445// } data; 3446// }; 3447// 3448type LedgerKey struct { 3449 Type LedgerEntryType 3450 Account *LedgerKeyAccount 3451 TrustLine *LedgerKeyTrustLine 3452 Offer *LedgerKeyOffer 3453 Data *LedgerKeyData 3454} 3455 3456// SwitchFieldName returns the field name in which this union's 3457// discriminant is stored 3458func (u LedgerKey) SwitchFieldName() string { 3459 return "Type" 3460} 3461 3462// ArmForSwitch returns which field name should be used for storing 3463// the value for an instance of LedgerKey 3464func (u LedgerKey) ArmForSwitch(sw int32) (string, bool) { 3465 switch LedgerEntryType(sw) { 3466 case LedgerEntryTypeAccount: 3467 return "Account", true 3468 case LedgerEntryTypeTrustline: 3469 return "TrustLine", true 3470 case LedgerEntryTypeOffer: 3471 return "Offer", true 3472 case LedgerEntryTypeData: 3473 return "Data", true 3474 } 3475 return "-", false 3476} 3477 3478// NewLedgerKey creates a new LedgerKey. 3479func NewLedgerKey(aType LedgerEntryType, value interface{}) (result LedgerKey, err error) { 3480 result.Type = aType 3481 switch LedgerEntryType(aType) { 3482 case LedgerEntryTypeAccount: 3483 tv, ok := value.(LedgerKeyAccount) 3484 if !ok { 3485 err = fmt.Errorf("invalid value, must be LedgerKeyAccount") 3486 return 3487 } 3488 result.Account = &tv 3489 case LedgerEntryTypeTrustline: 3490 tv, ok := value.(LedgerKeyTrustLine) 3491 if !ok { 3492 err = fmt.Errorf("invalid value, must be LedgerKeyTrustLine") 3493 return 3494 } 3495 result.TrustLine = &tv 3496 case LedgerEntryTypeOffer: 3497 tv, ok := value.(LedgerKeyOffer) 3498 if !ok { 3499 err = fmt.Errorf("invalid value, must be LedgerKeyOffer") 3500 return 3501 } 3502 result.Offer = &tv 3503 case LedgerEntryTypeData: 3504 tv, ok := value.(LedgerKeyData) 3505 if !ok { 3506 err = fmt.Errorf("invalid value, must be LedgerKeyData") 3507 return 3508 } 3509 result.Data = &tv 3510 } 3511 return 3512} 3513 3514// MustAccount retrieves the Account value from the union, 3515// panicing if the value is not set. 3516func (u LedgerKey) MustAccount() LedgerKeyAccount { 3517 val, ok := u.GetAccount() 3518 3519 if !ok { 3520 panic("arm Account is not set") 3521 } 3522 3523 return val 3524} 3525 3526// GetAccount retrieves the Account value from the union, 3527// returning ok if the union's switch indicated the value is valid. 3528func (u LedgerKey) GetAccount() (result LedgerKeyAccount, ok bool) { 3529 armName, _ := u.ArmForSwitch(int32(u.Type)) 3530 3531 if armName == "Account" { 3532 result = *u.Account 3533 ok = true 3534 } 3535 3536 return 3537} 3538 3539// MustTrustLine retrieves the TrustLine value from the union, 3540// panicing if the value is not set. 3541func (u LedgerKey) MustTrustLine() LedgerKeyTrustLine { 3542 val, ok := u.GetTrustLine() 3543 3544 if !ok { 3545 panic("arm TrustLine is not set") 3546 } 3547 3548 return val 3549} 3550 3551// GetTrustLine retrieves the TrustLine value from the union, 3552// returning ok if the union's switch indicated the value is valid. 3553func (u LedgerKey) GetTrustLine() (result LedgerKeyTrustLine, ok bool) { 3554 armName, _ := u.ArmForSwitch(int32(u.Type)) 3555 3556 if armName == "TrustLine" { 3557 result = *u.TrustLine 3558 ok = true 3559 } 3560 3561 return 3562} 3563 3564// MustOffer retrieves the Offer value from the union, 3565// panicing if the value is not set. 3566func (u LedgerKey) MustOffer() LedgerKeyOffer { 3567 val, ok := u.GetOffer() 3568 3569 if !ok { 3570 panic("arm Offer is not set") 3571 } 3572 3573 return val 3574} 3575 3576// GetOffer retrieves the Offer value from the union, 3577// returning ok if the union's switch indicated the value is valid. 3578func (u LedgerKey) GetOffer() (result LedgerKeyOffer, ok bool) { 3579 armName, _ := u.ArmForSwitch(int32(u.Type)) 3580 3581 if armName == "Offer" { 3582 result = *u.Offer 3583 ok = true 3584 } 3585 3586 return 3587} 3588 3589// MustData retrieves the Data value from the union, 3590// panicing if the value is not set. 3591func (u LedgerKey) MustData() LedgerKeyData { 3592 val, ok := u.GetData() 3593 3594 if !ok { 3595 panic("arm Data is not set") 3596 } 3597 3598 return val 3599} 3600 3601// GetData retrieves the Data value from the union, 3602// returning ok if the union's switch indicated the value is valid. 3603func (u LedgerKey) GetData() (result LedgerKeyData, ok bool) { 3604 armName, _ := u.ArmForSwitch(int32(u.Type)) 3605 3606 if armName == "Data" { 3607 result = *u.Data 3608 ok = true 3609 } 3610 3611 return 3612} 3613 3614// MarshalBinary implements encoding.BinaryMarshaler. 3615func (s LedgerKey) MarshalBinary() ([]byte, error) { 3616 b := new(bytes.Buffer) 3617 _, err := Marshal(b, s) 3618 return b.Bytes(), err 3619} 3620 3621// UnmarshalBinary implements encoding.BinaryUnmarshaler. 3622func (s *LedgerKey) UnmarshalBinary(inp []byte) error { 3623 _, err := Unmarshal(bytes.NewReader(inp), s) 3624 return err 3625} 3626 3627var ( 3628 _ encoding.BinaryMarshaler = (*LedgerKey)(nil) 3629 _ encoding.BinaryUnmarshaler = (*LedgerKey)(nil) 3630) 3631 3632// BucketEntryType is an XDR Enum defines as: 3633// 3634// enum BucketEntryType 3635// { 3636// METAENTRY = 3637// -1, // At-and-after protocol 11: bucket metadata, should come first. 3638// LIVEENTRY = 0, // Before protocol 11: created-or-updated; 3639// // At-and-after protocol 11: only updated. 3640// DEADENTRY = 1, 3641// INITENTRY = 2 // At-and-after protocol 11: only created. 3642// }; 3643// 3644type BucketEntryType int32 3645 3646const ( 3647 BucketEntryTypeMetaentry BucketEntryType = -1 3648 BucketEntryTypeLiveentry BucketEntryType = 0 3649 BucketEntryTypeDeadentry BucketEntryType = 1 3650 BucketEntryTypeInitentry BucketEntryType = 2 3651) 3652 3653var bucketEntryTypeMap = map[int32]string{ 3654 -1: "BucketEntryTypeMetaentry", 3655 0: "BucketEntryTypeLiveentry", 3656 1: "BucketEntryTypeDeadentry", 3657 2: "BucketEntryTypeInitentry", 3658} 3659 3660// ValidEnum validates a proposed value for this enum. Implements 3661// the Enum interface for BucketEntryType 3662func (e BucketEntryType) ValidEnum(v int32) bool { 3663 _, ok := bucketEntryTypeMap[v] 3664 return ok 3665} 3666 3667// String returns the name of `e` 3668func (e BucketEntryType) String() string { 3669 name, _ := bucketEntryTypeMap[int32(e)] 3670 return name 3671} 3672 3673// MarshalBinary implements encoding.BinaryMarshaler. 3674func (s BucketEntryType) MarshalBinary() ([]byte, error) { 3675 b := new(bytes.Buffer) 3676 _, err := Marshal(b, s) 3677 return b.Bytes(), err 3678} 3679 3680// UnmarshalBinary implements encoding.BinaryUnmarshaler. 3681func (s *BucketEntryType) UnmarshalBinary(inp []byte) error { 3682 _, err := Unmarshal(bytes.NewReader(inp), s) 3683 return err 3684} 3685 3686var ( 3687 _ encoding.BinaryMarshaler = (*BucketEntryType)(nil) 3688 _ encoding.BinaryUnmarshaler = (*BucketEntryType)(nil) 3689) 3690 3691// BucketMetadataExt is an XDR NestedUnion defines as: 3692// 3693// union switch (int v) 3694// { 3695// case 0: 3696// void; 3697// } 3698// 3699type BucketMetadataExt struct { 3700 V int32 3701} 3702 3703// SwitchFieldName returns the field name in which this union's 3704// discriminant is stored 3705func (u BucketMetadataExt) SwitchFieldName() string { 3706 return "V" 3707} 3708 3709// ArmForSwitch returns which field name should be used for storing 3710// the value for an instance of BucketMetadataExt 3711func (u BucketMetadataExt) ArmForSwitch(sw int32) (string, bool) { 3712 switch int32(sw) { 3713 case 0: 3714 return "", true 3715 } 3716 return "-", false 3717} 3718 3719// NewBucketMetadataExt creates a new BucketMetadataExt. 3720func NewBucketMetadataExt(v int32, value interface{}) (result BucketMetadataExt, err error) { 3721 result.V = v 3722 switch int32(v) { 3723 case 0: 3724 // void 3725 } 3726 return 3727} 3728 3729// MarshalBinary implements encoding.BinaryMarshaler. 3730func (s BucketMetadataExt) MarshalBinary() ([]byte, error) { 3731 b := new(bytes.Buffer) 3732 _, err := Marshal(b, s) 3733 return b.Bytes(), err 3734} 3735 3736// UnmarshalBinary implements encoding.BinaryUnmarshaler. 3737func (s *BucketMetadataExt) UnmarshalBinary(inp []byte) error { 3738 _, err := Unmarshal(bytes.NewReader(inp), s) 3739 return err 3740} 3741 3742var ( 3743 _ encoding.BinaryMarshaler = (*BucketMetadataExt)(nil) 3744 _ encoding.BinaryUnmarshaler = (*BucketMetadataExt)(nil) 3745) 3746 3747// BucketMetadata is an XDR Struct defines as: 3748// 3749// struct BucketMetadata 3750// { 3751// // Indicates the protocol version used to create / merge this bucket. 3752// uint32 ledgerVersion; 3753// 3754// // reserved for future use 3755// union switch (int v) 3756// { 3757// case 0: 3758// void; 3759// } 3760// ext; 3761// }; 3762// 3763type BucketMetadata struct { 3764 LedgerVersion Uint32 3765 Ext BucketMetadataExt 3766} 3767 3768// MarshalBinary implements encoding.BinaryMarshaler. 3769func (s BucketMetadata) MarshalBinary() ([]byte, error) { 3770 b := new(bytes.Buffer) 3771 _, err := Marshal(b, s) 3772 return b.Bytes(), err 3773} 3774 3775// UnmarshalBinary implements encoding.BinaryUnmarshaler. 3776func (s *BucketMetadata) UnmarshalBinary(inp []byte) error { 3777 _, err := Unmarshal(bytes.NewReader(inp), s) 3778 return err 3779} 3780 3781var ( 3782 _ encoding.BinaryMarshaler = (*BucketMetadata)(nil) 3783 _ encoding.BinaryUnmarshaler = (*BucketMetadata)(nil) 3784) 3785 3786// BucketEntry is an XDR Union defines as: 3787// 3788// union BucketEntry switch (BucketEntryType type) 3789// { 3790// case LIVEENTRY: 3791// case INITENTRY: 3792// LedgerEntry liveEntry; 3793// 3794// case DEADENTRY: 3795// LedgerKey deadEntry; 3796// case METAENTRY: 3797// BucketMetadata metaEntry; 3798// }; 3799// 3800type BucketEntry struct { 3801 Type BucketEntryType 3802 LiveEntry *LedgerEntry 3803 DeadEntry *LedgerKey 3804 MetaEntry *BucketMetadata 3805} 3806 3807// SwitchFieldName returns the field name in which this union's 3808// discriminant is stored 3809func (u BucketEntry) SwitchFieldName() string { 3810 return "Type" 3811} 3812 3813// ArmForSwitch returns which field name should be used for storing 3814// the value for an instance of BucketEntry 3815func (u BucketEntry) ArmForSwitch(sw int32) (string, bool) { 3816 switch BucketEntryType(sw) { 3817 case BucketEntryTypeLiveentry: 3818 return "LiveEntry", true 3819 case BucketEntryTypeInitentry: 3820 return "LiveEntry", true 3821 case BucketEntryTypeDeadentry: 3822 return "DeadEntry", true 3823 case BucketEntryTypeMetaentry: 3824 return "MetaEntry", true 3825 } 3826 return "-", false 3827} 3828 3829// NewBucketEntry creates a new BucketEntry. 3830func NewBucketEntry(aType BucketEntryType, value interface{}) (result BucketEntry, err error) { 3831 result.Type = aType 3832 switch BucketEntryType(aType) { 3833 case BucketEntryTypeLiveentry: 3834 tv, ok := value.(LedgerEntry) 3835 if !ok { 3836 err = fmt.Errorf("invalid value, must be LedgerEntry") 3837 return 3838 } 3839 result.LiveEntry = &tv 3840 case BucketEntryTypeInitentry: 3841 tv, ok := value.(LedgerEntry) 3842 if !ok { 3843 err = fmt.Errorf("invalid value, must be LedgerEntry") 3844 return 3845 } 3846 result.LiveEntry = &tv 3847 case BucketEntryTypeDeadentry: 3848 tv, ok := value.(LedgerKey) 3849 if !ok { 3850 err = fmt.Errorf("invalid value, must be LedgerKey") 3851 return 3852 } 3853 result.DeadEntry = &tv 3854 case BucketEntryTypeMetaentry: 3855 tv, ok := value.(BucketMetadata) 3856 if !ok { 3857 err = fmt.Errorf("invalid value, must be BucketMetadata") 3858 return 3859 } 3860 result.MetaEntry = &tv 3861 } 3862 return 3863} 3864 3865// MustLiveEntry retrieves the LiveEntry value from the union, 3866// panicing if the value is not set. 3867func (u BucketEntry) MustLiveEntry() LedgerEntry { 3868 val, ok := u.GetLiveEntry() 3869 3870 if !ok { 3871 panic("arm LiveEntry is not set") 3872 } 3873 3874 return val 3875} 3876 3877// GetLiveEntry retrieves the LiveEntry value from the union, 3878// returning ok if the union's switch indicated the value is valid. 3879func (u BucketEntry) GetLiveEntry() (result LedgerEntry, ok bool) { 3880 armName, _ := u.ArmForSwitch(int32(u.Type)) 3881 3882 if armName == "LiveEntry" { 3883 result = *u.LiveEntry 3884 ok = true 3885 } 3886 3887 return 3888} 3889 3890// MustDeadEntry retrieves the DeadEntry value from the union, 3891// panicing if the value is not set. 3892func (u BucketEntry) MustDeadEntry() LedgerKey { 3893 val, ok := u.GetDeadEntry() 3894 3895 if !ok { 3896 panic("arm DeadEntry is not set") 3897 } 3898 3899 return val 3900} 3901 3902// GetDeadEntry retrieves the DeadEntry value from the union, 3903// returning ok if the union's switch indicated the value is valid. 3904func (u BucketEntry) GetDeadEntry() (result LedgerKey, ok bool) { 3905 armName, _ := u.ArmForSwitch(int32(u.Type)) 3906 3907 if armName == "DeadEntry" { 3908 result = *u.DeadEntry 3909 ok = true 3910 } 3911 3912 return 3913} 3914 3915// MustMetaEntry retrieves the MetaEntry value from the union, 3916// panicing if the value is not set. 3917func (u BucketEntry) MustMetaEntry() BucketMetadata { 3918 val, ok := u.GetMetaEntry() 3919 3920 if !ok { 3921 panic("arm MetaEntry is not set") 3922 } 3923 3924 return val 3925} 3926 3927// GetMetaEntry retrieves the MetaEntry value from the union, 3928// returning ok if the union's switch indicated the value is valid. 3929func (u BucketEntry) GetMetaEntry() (result BucketMetadata, ok bool) { 3930 armName, _ := u.ArmForSwitch(int32(u.Type)) 3931 3932 if armName == "MetaEntry" { 3933 result = *u.MetaEntry 3934 ok = true 3935 } 3936 3937 return 3938} 3939 3940// MarshalBinary implements encoding.BinaryMarshaler. 3941func (s BucketEntry) MarshalBinary() ([]byte, error) { 3942 b := new(bytes.Buffer) 3943 _, err := Marshal(b, s) 3944 return b.Bytes(), err 3945} 3946 3947// UnmarshalBinary implements encoding.BinaryUnmarshaler. 3948func (s *BucketEntry) UnmarshalBinary(inp []byte) error { 3949 _, err := Unmarshal(bytes.NewReader(inp), s) 3950 return err 3951} 3952 3953var ( 3954 _ encoding.BinaryMarshaler = (*BucketEntry)(nil) 3955 _ encoding.BinaryUnmarshaler = (*BucketEntry)(nil) 3956) 3957 3958// TransactionSet is an XDR Struct defines as: 3959// 3960// struct TransactionSet 3961// { 3962// Hash previousLedgerHash; 3963// TransactionEnvelope txs<>; 3964// }; 3965// 3966type TransactionSet struct { 3967 PreviousLedgerHash Hash 3968 Txs []TransactionEnvelope 3969} 3970 3971// MarshalBinary implements encoding.BinaryMarshaler. 3972func (s TransactionSet) MarshalBinary() ([]byte, error) { 3973 b := new(bytes.Buffer) 3974 _, err := Marshal(b, s) 3975 return b.Bytes(), err 3976} 3977 3978// UnmarshalBinary implements encoding.BinaryUnmarshaler. 3979func (s *TransactionSet) UnmarshalBinary(inp []byte) error { 3980 _, err := Unmarshal(bytes.NewReader(inp), s) 3981 return err 3982} 3983 3984var ( 3985 _ encoding.BinaryMarshaler = (*TransactionSet)(nil) 3986 _ encoding.BinaryUnmarshaler = (*TransactionSet)(nil) 3987) 3988 3989// TransactionResultPair is an XDR Struct defines as: 3990// 3991// struct TransactionResultPair 3992// { 3993// Hash transactionHash; 3994// TransactionResult result; // result for the transaction 3995// }; 3996// 3997type TransactionResultPair struct { 3998 TransactionHash Hash 3999 Result TransactionResult 4000} 4001 4002// MarshalBinary implements encoding.BinaryMarshaler. 4003func (s TransactionResultPair) MarshalBinary() ([]byte, error) { 4004 b := new(bytes.Buffer) 4005 _, err := Marshal(b, s) 4006 return b.Bytes(), err 4007} 4008 4009// UnmarshalBinary implements encoding.BinaryUnmarshaler. 4010func (s *TransactionResultPair) UnmarshalBinary(inp []byte) error { 4011 _, err := Unmarshal(bytes.NewReader(inp), s) 4012 return err 4013} 4014 4015var ( 4016 _ encoding.BinaryMarshaler = (*TransactionResultPair)(nil) 4017 _ encoding.BinaryUnmarshaler = (*TransactionResultPair)(nil) 4018) 4019 4020// TransactionResultSet is an XDR Struct defines as: 4021// 4022// struct TransactionResultSet 4023// { 4024// TransactionResultPair results<>; 4025// }; 4026// 4027type TransactionResultSet struct { 4028 Results []TransactionResultPair 4029} 4030 4031// MarshalBinary implements encoding.BinaryMarshaler. 4032func (s TransactionResultSet) MarshalBinary() ([]byte, error) { 4033 b := new(bytes.Buffer) 4034 _, err := Marshal(b, s) 4035 return b.Bytes(), err 4036} 4037 4038// UnmarshalBinary implements encoding.BinaryUnmarshaler. 4039func (s *TransactionResultSet) UnmarshalBinary(inp []byte) error { 4040 _, err := Unmarshal(bytes.NewReader(inp), s) 4041 return err 4042} 4043 4044var ( 4045 _ encoding.BinaryMarshaler = (*TransactionResultSet)(nil) 4046 _ encoding.BinaryUnmarshaler = (*TransactionResultSet)(nil) 4047) 4048 4049// TransactionHistoryEntryExt is an XDR NestedUnion defines as: 4050// 4051// union switch (int v) 4052// { 4053// case 0: 4054// void; 4055// } 4056// 4057type TransactionHistoryEntryExt struct { 4058 V int32 4059} 4060 4061// SwitchFieldName returns the field name in which this union's 4062// discriminant is stored 4063func (u TransactionHistoryEntryExt) SwitchFieldName() string { 4064 return "V" 4065} 4066 4067// ArmForSwitch returns which field name should be used for storing 4068// the value for an instance of TransactionHistoryEntryExt 4069func (u TransactionHistoryEntryExt) ArmForSwitch(sw int32) (string, bool) { 4070 switch int32(sw) { 4071 case 0: 4072 return "", true 4073 } 4074 return "-", false 4075} 4076 4077// NewTransactionHistoryEntryExt creates a new TransactionHistoryEntryExt. 4078func NewTransactionHistoryEntryExt(v int32, value interface{}) (result TransactionHistoryEntryExt, err error) { 4079 result.V = v 4080 switch int32(v) { 4081 case 0: 4082 // void 4083 } 4084 return 4085} 4086 4087// MarshalBinary implements encoding.BinaryMarshaler. 4088func (s TransactionHistoryEntryExt) MarshalBinary() ([]byte, error) { 4089 b := new(bytes.Buffer) 4090 _, err := Marshal(b, s) 4091 return b.Bytes(), err 4092} 4093 4094// UnmarshalBinary implements encoding.BinaryUnmarshaler. 4095func (s *TransactionHistoryEntryExt) UnmarshalBinary(inp []byte) error { 4096 _, err := Unmarshal(bytes.NewReader(inp), s) 4097 return err 4098} 4099 4100var ( 4101 _ encoding.BinaryMarshaler = (*TransactionHistoryEntryExt)(nil) 4102 _ encoding.BinaryUnmarshaler = (*TransactionHistoryEntryExt)(nil) 4103) 4104 4105// TransactionHistoryEntry is an XDR Struct defines as: 4106// 4107// struct TransactionHistoryEntry 4108// { 4109// uint32 ledgerSeq; 4110// TransactionSet txSet; 4111// 4112// // reserved for future use 4113// union switch (int v) 4114// { 4115// case 0: 4116// void; 4117// } 4118// ext; 4119// }; 4120// 4121type TransactionHistoryEntry struct { 4122 LedgerSeq Uint32 4123 TxSet TransactionSet 4124 Ext TransactionHistoryEntryExt 4125} 4126 4127// MarshalBinary implements encoding.BinaryMarshaler. 4128func (s TransactionHistoryEntry) MarshalBinary() ([]byte, error) { 4129 b := new(bytes.Buffer) 4130 _, err := Marshal(b, s) 4131 return b.Bytes(), err 4132} 4133 4134// UnmarshalBinary implements encoding.BinaryUnmarshaler. 4135func (s *TransactionHistoryEntry) UnmarshalBinary(inp []byte) error { 4136 _, err := Unmarshal(bytes.NewReader(inp), s) 4137 return err 4138} 4139 4140var ( 4141 _ encoding.BinaryMarshaler = (*TransactionHistoryEntry)(nil) 4142 _ encoding.BinaryUnmarshaler = (*TransactionHistoryEntry)(nil) 4143) 4144 4145// TransactionHistoryResultEntryExt is an XDR NestedUnion defines as: 4146// 4147// union switch (int v) 4148// { 4149// case 0: 4150// void; 4151// } 4152// 4153type TransactionHistoryResultEntryExt struct { 4154 V int32 4155} 4156 4157// SwitchFieldName returns the field name in which this union's 4158// discriminant is stored 4159func (u TransactionHistoryResultEntryExt) SwitchFieldName() string { 4160 return "V" 4161} 4162 4163// ArmForSwitch returns which field name should be used for storing 4164// the value for an instance of TransactionHistoryResultEntryExt 4165func (u TransactionHistoryResultEntryExt) ArmForSwitch(sw int32) (string, bool) { 4166 switch int32(sw) { 4167 case 0: 4168 return "", true 4169 } 4170 return "-", false 4171} 4172 4173// NewTransactionHistoryResultEntryExt creates a new TransactionHistoryResultEntryExt. 4174func NewTransactionHistoryResultEntryExt(v int32, value interface{}) (result TransactionHistoryResultEntryExt, err error) { 4175 result.V = v 4176 switch int32(v) { 4177 case 0: 4178 // void 4179 } 4180 return 4181} 4182 4183// MarshalBinary implements encoding.BinaryMarshaler. 4184func (s TransactionHistoryResultEntryExt) MarshalBinary() ([]byte, error) { 4185 b := new(bytes.Buffer) 4186 _, err := Marshal(b, s) 4187 return b.Bytes(), err 4188} 4189 4190// UnmarshalBinary implements encoding.BinaryUnmarshaler. 4191func (s *TransactionHistoryResultEntryExt) UnmarshalBinary(inp []byte) error { 4192 _, err := Unmarshal(bytes.NewReader(inp), s) 4193 return err 4194} 4195 4196var ( 4197 _ encoding.BinaryMarshaler = (*TransactionHistoryResultEntryExt)(nil) 4198 _ encoding.BinaryUnmarshaler = (*TransactionHistoryResultEntryExt)(nil) 4199) 4200 4201// TransactionHistoryResultEntry is an XDR Struct defines as: 4202// 4203// struct TransactionHistoryResultEntry 4204// { 4205// uint32 ledgerSeq; 4206// TransactionResultSet txResultSet; 4207// 4208// // reserved for future use 4209// union switch (int v) 4210// { 4211// case 0: 4212// void; 4213// } 4214// ext; 4215// }; 4216// 4217type TransactionHistoryResultEntry struct { 4218 LedgerSeq Uint32 4219 TxResultSet TransactionResultSet 4220 Ext TransactionHistoryResultEntryExt 4221} 4222 4223// MarshalBinary implements encoding.BinaryMarshaler. 4224func (s TransactionHistoryResultEntry) MarshalBinary() ([]byte, error) { 4225 b := new(bytes.Buffer) 4226 _, err := Marshal(b, s) 4227 return b.Bytes(), err 4228} 4229 4230// UnmarshalBinary implements encoding.BinaryUnmarshaler. 4231func (s *TransactionHistoryResultEntry) UnmarshalBinary(inp []byte) error { 4232 _, err := Unmarshal(bytes.NewReader(inp), s) 4233 return err 4234} 4235 4236var ( 4237 _ encoding.BinaryMarshaler = (*TransactionHistoryResultEntry)(nil) 4238 _ encoding.BinaryUnmarshaler = (*TransactionHistoryResultEntry)(nil) 4239) 4240 4241// LedgerHeaderHistoryEntryExt is an XDR NestedUnion defines as: 4242// 4243// union switch (int v) 4244// { 4245// case 0: 4246// void; 4247// } 4248// 4249type LedgerHeaderHistoryEntryExt struct { 4250 V int32 4251} 4252 4253// SwitchFieldName returns the field name in which this union's 4254// discriminant is stored 4255func (u LedgerHeaderHistoryEntryExt) SwitchFieldName() string { 4256 return "V" 4257} 4258 4259// ArmForSwitch returns which field name should be used for storing 4260// the value for an instance of LedgerHeaderHistoryEntryExt 4261func (u LedgerHeaderHistoryEntryExt) ArmForSwitch(sw int32) (string, bool) { 4262 switch int32(sw) { 4263 case 0: 4264 return "", true 4265 } 4266 return "-", false 4267} 4268 4269// NewLedgerHeaderHistoryEntryExt creates a new LedgerHeaderHistoryEntryExt. 4270func NewLedgerHeaderHistoryEntryExt(v int32, value interface{}) (result LedgerHeaderHistoryEntryExt, err error) { 4271 result.V = v 4272 switch int32(v) { 4273 case 0: 4274 // void 4275 } 4276 return 4277} 4278 4279// MarshalBinary implements encoding.BinaryMarshaler. 4280func (s LedgerHeaderHistoryEntryExt) MarshalBinary() ([]byte, error) { 4281 b := new(bytes.Buffer) 4282 _, err := Marshal(b, s) 4283 return b.Bytes(), err 4284} 4285 4286// UnmarshalBinary implements encoding.BinaryUnmarshaler. 4287func (s *LedgerHeaderHistoryEntryExt) UnmarshalBinary(inp []byte) error { 4288 _, err := Unmarshal(bytes.NewReader(inp), s) 4289 return err 4290} 4291 4292var ( 4293 _ encoding.BinaryMarshaler = (*LedgerHeaderHistoryEntryExt)(nil) 4294 _ encoding.BinaryUnmarshaler = (*LedgerHeaderHistoryEntryExt)(nil) 4295) 4296 4297// LedgerHeaderHistoryEntry is an XDR Struct defines as: 4298// 4299// struct LedgerHeaderHistoryEntry 4300// { 4301// Hash hash; 4302// LedgerHeader header; 4303// 4304// // reserved for future use 4305// union switch (int v) 4306// { 4307// case 0: 4308// void; 4309// } 4310// ext; 4311// }; 4312// 4313type LedgerHeaderHistoryEntry struct { 4314 Hash Hash 4315 Header LedgerHeader 4316 Ext LedgerHeaderHistoryEntryExt 4317} 4318 4319// MarshalBinary implements encoding.BinaryMarshaler. 4320func (s LedgerHeaderHistoryEntry) MarshalBinary() ([]byte, error) { 4321 b := new(bytes.Buffer) 4322 _, err := Marshal(b, s) 4323 return b.Bytes(), err 4324} 4325 4326// UnmarshalBinary implements encoding.BinaryUnmarshaler. 4327func (s *LedgerHeaderHistoryEntry) UnmarshalBinary(inp []byte) error { 4328 _, err := Unmarshal(bytes.NewReader(inp), s) 4329 return err 4330} 4331 4332var ( 4333 _ encoding.BinaryMarshaler = (*LedgerHeaderHistoryEntry)(nil) 4334 _ encoding.BinaryUnmarshaler = (*LedgerHeaderHistoryEntry)(nil) 4335) 4336 4337// LedgerScpMessages is an XDR Struct defines as: 4338// 4339// struct LedgerSCPMessages 4340// { 4341// uint32 ledgerSeq; 4342// SCPEnvelope messages<>; 4343// }; 4344// 4345type LedgerScpMessages struct { 4346 LedgerSeq Uint32 4347 Messages []ScpEnvelope 4348} 4349 4350// MarshalBinary implements encoding.BinaryMarshaler. 4351func (s LedgerScpMessages) MarshalBinary() ([]byte, error) { 4352 b := new(bytes.Buffer) 4353 _, err := Marshal(b, s) 4354 return b.Bytes(), err 4355} 4356 4357// UnmarshalBinary implements encoding.BinaryUnmarshaler. 4358func (s *LedgerScpMessages) UnmarshalBinary(inp []byte) error { 4359 _, err := Unmarshal(bytes.NewReader(inp), s) 4360 return err 4361} 4362 4363var ( 4364 _ encoding.BinaryMarshaler = (*LedgerScpMessages)(nil) 4365 _ encoding.BinaryUnmarshaler = (*LedgerScpMessages)(nil) 4366) 4367 4368// ScpHistoryEntryV0 is an XDR Struct defines as: 4369// 4370// struct SCPHistoryEntryV0 4371// { 4372// SCPQuorumSet quorumSets<>; // additional quorum sets used by ledgerMessages 4373// LedgerSCPMessages ledgerMessages; 4374// }; 4375// 4376type ScpHistoryEntryV0 struct { 4377 QuorumSets []ScpQuorumSet 4378 LedgerMessages LedgerScpMessages 4379} 4380 4381// MarshalBinary implements encoding.BinaryMarshaler. 4382func (s ScpHistoryEntryV0) MarshalBinary() ([]byte, error) { 4383 b := new(bytes.Buffer) 4384 _, err := Marshal(b, s) 4385 return b.Bytes(), err 4386} 4387 4388// UnmarshalBinary implements encoding.BinaryUnmarshaler. 4389func (s *ScpHistoryEntryV0) UnmarshalBinary(inp []byte) error { 4390 _, err := Unmarshal(bytes.NewReader(inp), s) 4391 return err 4392} 4393 4394var ( 4395 _ encoding.BinaryMarshaler = (*ScpHistoryEntryV0)(nil) 4396 _ encoding.BinaryUnmarshaler = (*ScpHistoryEntryV0)(nil) 4397) 4398 4399// ScpHistoryEntry is an XDR Union defines as: 4400// 4401// union SCPHistoryEntry switch (int v) 4402// { 4403// case 0: 4404// SCPHistoryEntryV0 v0; 4405// }; 4406// 4407type ScpHistoryEntry struct { 4408 V int32 4409 V0 *ScpHistoryEntryV0 4410} 4411 4412// SwitchFieldName returns the field name in which this union's 4413// discriminant is stored 4414func (u ScpHistoryEntry) SwitchFieldName() string { 4415 return "V" 4416} 4417 4418// ArmForSwitch returns which field name should be used for storing 4419// the value for an instance of ScpHistoryEntry 4420func (u ScpHistoryEntry) ArmForSwitch(sw int32) (string, bool) { 4421 switch int32(sw) { 4422 case 0: 4423 return "V0", true 4424 } 4425 return "-", false 4426} 4427 4428// NewScpHistoryEntry creates a new ScpHistoryEntry. 4429func NewScpHistoryEntry(v int32, value interface{}) (result ScpHistoryEntry, err error) { 4430 result.V = v 4431 switch int32(v) { 4432 case 0: 4433 tv, ok := value.(ScpHistoryEntryV0) 4434 if !ok { 4435 err = fmt.Errorf("invalid value, must be ScpHistoryEntryV0") 4436 return 4437 } 4438 result.V0 = &tv 4439 } 4440 return 4441} 4442 4443// MustV0 retrieves the V0 value from the union, 4444// panicing if the value is not set. 4445func (u ScpHistoryEntry) MustV0() ScpHistoryEntryV0 { 4446 val, ok := u.GetV0() 4447 4448 if !ok { 4449 panic("arm V0 is not set") 4450 } 4451 4452 return val 4453} 4454 4455// GetV0 retrieves the V0 value from the union, 4456// returning ok if the union's switch indicated the value is valid. 4457func (u ScpHistoryEntry) GetV0() (result ScpHistoryEntryV0, ok bool) { 4458 armName, _ := u.ArmForSwitch(int32(u.V)) 4459 4460 if armName == "V0" { 4461 result = *u.V0 4462 ok = true 4463 } 4464 4465 return 4466} 4467 4468// MarshalBinary implements encoding.BinaryMarshaler. 4469func (s ScpHistoryEntry) MarshalBinary() ([]byte, error) { 4470 b := new(bytes.Buffer) 4471 _, err := Marshal(b, s) 4472 return b.Bytes(), err 4473} 4474 4475// UnmarshalBinary implements encoding.BinaryUnmarshaler. 4476func (s *ScpHistoryEntry) UnmarshalBinary(inp []byte) error { 4477 _, err := Unmarshal(bytes.NewReader(inp), s) 4478 return err 4479} 4480 4481var ( 4482 _ encoding.BinaryMarshaler = (*ScpHistoryEntry)(nil) 4483 _ encoding.BinaryUnmarshaler = (*ScpHistoryEntry)(nil) 4484) 4485 4486// LedgerEntryChangeType is an XDR Enum defines as: 4487// 4488// enum LedgerEntryChangeType 4489// { 4490// LEDGER_ENTRY_CREATED = 0, // entry was added to the ledger 4491// LEDGER_ENTRY_UPDATED = 1, // entry was modified in the ledger 4492// LEDGER_ENTRY_REMOVED = 2, // entry was removed from the ledger 4493// LEDGER_ENTRY_STATE = 3 // value of the entry 4494// }; 4495// 4496type LedgerEntryChangeType int32 4497 4498const ( 4499 LedgerEntryChangeTypeLedgerEntryCreated LedgerEntryChangeType = 0 4500 LedgerEntryChangeTypeLedgerEntryUpdated LedgerEntryChangeType = 1 4501 LedgerEntryChangeTypeLedgerEntryRemoved LedgerEntryChangeType = 2 4502 LedgerEntryChangeTypeLedgerEntryState LedgerEntryChangeType = 3 4503) 4504 4505var ledgerEntryChangeTypeMap = map[int32]string{ 4506 0: "LedgerEntryChangeTypeLedgerEntryCreated", 4507 1: "LedgerEntryChangeTypeLedgerEntryUpdated", 4508 2: "LedgerEntryChangeTypeLedgerEntryRemoved", 4509 3: "LedgerEntryChangeTypeLedgerEntryState", 4510} 4511 4512// ValidEnum validates a proposed value for this enum. Implements 4513// the Enum interface for LedgerEntryChangeType 4514func (e LedgerEntryChangeType) ValidEnum(v int32) bool { 4515 _, ok := ledgerEntryChangeTypeMap[v] 4516 return ok 4517} 4518 4519// String returns the name of `e` 4520func (e LedgerEntryChangeType) String() string { 4521 name, _ := ledgerEntryChangeTypeMap[int32(e)] 4522 return name 4523} 4524 4525// MarshalBinary implements encoding.BinaryMarshaler. 4526func (s LedgerEntryChangeType) MarshalBinary() ([]byte, error) { 4527 b := new(bytes.Buffer) 4528 _, err := Marshal(b, s) 4529 return b.Bytes(), err 4530} 4531 4532// UnmarshalBinary implements encoding.BinaryUnmarshaler. 4533func (s *LedgerEntryChangeType) UnmarshalBinary(inp []byte) error { 4534 _, err := Unmarshal(bytes.NewReader(inp), s) 4535 return err 4536} 4537 4538var ( 4539 _ encoding.BinaryMarshaler = (*LedgerEntryChangeType)(nil) 4540 _ encoding.BinaryUnmarshaler = (*LedgerEntryChangeType)(nil) 4541) 4542 4543// LedgerEntryChange is an XDR Union defines as: 4544// 4545// union LedgerEntryChange switch (LedgerEntryChangeType type) 4546// { 4547// case LEDGER_ENTRY_CREATED: 4548// LedgerEntry created; 4549// case LEDGER_ENTRY_UPDATED: 4550// LedgerEntry updated; 4551// case LEDGER_ENTRY_REMOVED: 4552// LedgerKey removed; 4553// case LEDGER_ENTRY_STATE: 4554// LedgerEntry state; 4555// }; 4556// 4557type LedgerEntryChange struct { 4558 Type LedgerEntryChangeType 4559 Created *LedgerEntry 4560 Updated *LedgerEntry 4561 Removed *LedgerKey 4562 State *LedgerEntry 4563} 4564 4565// SwitchFieldName returns the field name in which this union's 4566// discriminant is stored 4567func (u LedgerEntryChange) SwitchFieldName() string { 4568 return "Type" 4569} 4570 4571// ArmForSwitch returns which field name should be used for storing 4572// the value for an instance of LedgerEntryChange 4573func (u LedgerEntryChange) ArmForSwitch(sw int32) (string, bool) { 4574 switch LedgerEntryChangeType(sw) { 4575 case LedgerEntryChangeTypeLedgerEntryCreated: 4576 return "Created", true 4577 case LedgerEntryChangeTypeLedgerEntryUpdated: 4578 return "Updated", true 4579 case LedgerEntryChangeTypeLedgerEntryRemoved: 4580 return "Removed", true 4581 case LedgerEntryChangeTypeLedgerEntryState: 4582 return "State", true 4583 } 4584 return "-", false 4585} 4586 4587// NewLedgerEntryChange creates a new LedgerEntryChange. 4588func NewLedgerEntryChange(aType LedgerEntryChangeType, value interface{}) (result LedgerEntryChange, err error) { 4589 result.Type = aType 4590 switch LedgerEntryChangeType(aType) { 4591 case LedgerEntryChangeTypeLedgerEntryCreated: 4592 tv, ok := value.(LedgerEntry) 4593 if !ok { 4594 err = fmt.Errorf("invalid value, must be LedgerEntry") 4595 return 4596 } 4597 result.Created = &tv 4598 case LedgerEntryChangeTypeLedgerEntryUpdated: 4599 tv, ok := value.(LedgerEntry) 4600 if !ok { 4601 err = fmt.Errorf("invalid value, must be LedgerEntry") 4602 return 4603 } 4604 result.Updated = &tv 4605 case LedgerEntryChangeTypeLedgerEntryRemoved: 4606 tv, ok := value.(LedgerKey) 4607 if !ok { 4608 err = fmt.Errorf("invalid value, must be LedgerKey") 4609 return 4610 } 4611 result.Removed = &tv 4612 case LedgerEntryChangeTypeLedgerEntryState: 4613 tv, ok := value.(LedgerEntry) 4614 if !ok { 4615 err = fmt.Errorf("invalid value, must be LedgerEntry") 4616 return 4617 } 4618 result.State = &tv 4619 } 4620 return 4621} 4622 4623// MustCreated retrieves the Created value from the union, 4624// panicing if the value is not set. 4625func (u LedgerEntryChange) MustCreated() LedgerEntry { 4626 val, ok := u.GetCreated() 4627 4628 if !ok { 4629 panic("arm Created is not set") 4630 } 4631 4632 return val 4633} 4634 4635// GetCreated retrieves the Created value from the union, 4636// returning ok if the union's switch indicated the value is valid. 4637func (u LedgerEntryChange) GetCreated() (result LedgerEntry, ok bool) { 4638 armName, _ := u.ArmForSwitch(int32(u.Type)) 4639 4640 if armName == "Created" { 4641 result = *u.Created 4642 ok = true 4643 } 4644 4645 return 4646} 4647 4648// MustUpdated retrieves the Updated value from the union, 4649// panicing if the value is not set. 4650func (u LedgerEntryChange) MustUpdated() LedgerEntry { 4651 val, ok := u.GetUpdated() 4652 4653 if !ok { 4654 panic("arm Updated is not set") 4655 } 4656 4657 return val 4658} 4659 4660// GetUpdated retrieves the Updated value from the union, 4661// returning ok if the union's switch indicated the value is valid. 4662func (u LedgerEntryChange) GetUpdated() (result LedgerEntry, ok bool) { 4663 armName, _ := u.ArmForSwitch(int32(u.Type)) 4664 4665 if armName == "Updated" { 4666 result = *u.Updated 4667 ok = true 4668 } 4669 4670 return 4671} 4672 4673// MustRemoved retrieves the Removed value from the union, 4674// panicing if the value is not set. 4675func (u LedgerEntryChange) MustRemoved() LedgerKey { 4676 val, ok := u.GetRemoved() 4677 4678 if !ok { 4679 panic("arm Removed is not set") 4680 } 4681 4682 return val 4683} 4684 4685// GetRemoved retrieves the Removed value from the union, 4686// returning ok if the union's switch indicated the value is valid. 4687func (u LedgerEntryChange) GetRemoved() (result LedgerKey, ok bool) { 4688 armName, _ := u.ArmForSwitch(int32(u.Type)) 4689 4690 if armName == "Removed" { 4691 result = *u.Removed 4692 ok = true 4693 } 4694 4695 return 4696} 4697 4698// MustState retrieves the State value from the union, 4699// panicing if the value is not set. 4700func (u LedgerEntryChange) MustState() LedgerEntry { 4701 val, ok := u.GetState() 4702 4703 if !ok { 4704 panic("arm State is not set") 4705 } 4706 4707 return val 4708} 4709 4710// GetState retrieves the State value from the union, 4711// returning ok if the union's switch indicated the value is valid. 4712func (u LedgerEntryChange) GetState() (result LedgerEntry, ok bool) { 4713 armName, _ := u.ArmForSwitch(int32(u.Type)) 4714 4715 if armName == "State" { 4716 result = *u.State 4717 ok = true 4718 } 4719 4720 return 4721} 4722 4723// MarshalBinary implements encoding.BinaryMarshaler. 4724func (s LedgerEntryChange) MarshalBinary() ([]byte, error) { 4725 b := new(bytes.Buffer) 4726 _, err := Marshal(b, s) 4727 return b.Bytes(), err 4728} 4729 4730// UnmarshalBinary implements encoding.BinaryUnmarshaler. 4731func (s *LedgerEntryChange) UnmarshalBinary(inp []byte) error { 4732 _, err := Unmarshal(bytes.NewReader(inp), s) 4733 return err 4734} 4735 4736var ( 4737 _ encoding.BinaryMarshaler = (*LedgerEntryChange)(nil) 4738 _ encoding.BinaryUnmarshaler = (*LedgerEntryChange)(nil) 4739) 4740 4741// LedgerEntryChanges is an XDR Typedef defines as: 4742// 4743// typedef LedgerEntryChange LedgerEntryChanges<>; 4744// 4745type LedgerEntryChanges []LedgerEntryChange 4746 4747// MarshalBinary implements encoding.BinaryMarshaler. 4748func (s LedgerEntryChanges) MarshalBinary() ([]byte, error) { 4749 b := new(bytes.Buffer) 4750 _, err := Marshal(b, s) 4751 return b.Bytes(), err 4752} 4753 4754// UnmarshalBinary implements encoding.BinaryUnmarshaler. 4755func (s *LedgerEntryChanges) UnmarshalBinary(inp []byte) error { 4756 _, err := Unmarshal(bytes.NewReader(inp), s) 4757 return err 4758} 4759 4760var ( 4761 _ encoding.BinaryMarshaler = (*LedgerEntryChanges)(nil) 4762 _ encoding.BinaryUnmarshaler = (*LedgerEntryChanges)(nil) 4763) 4764 4765// OperationMeta is an XDR Struct defines as: 4766// 4767// struct OperationMeta 4768// { 4769// LedgerEntryChanges changes; 4770// }; 4771// 4772type OperationMeta struct { 4773 Changes LedgerEntryChanges 4774} 4775 4776// MarshalBinary implements encoding.BinaryMarshaler. 4777func (s OperationMeta) MarshalBinary() ([]byte, error) { 4778 b := new(bytes.Buffer) 4779 _, err := Marshal(b, s) 4780 return b.Bytes(), err 4781} 4782 4783// UnmarshalBinary implements encoding.BinaryUnmarshaler. 4784func (s *OperationMeta) UnmarshalBinary(inp []byte) error { 4785 _, err := Unmarshal(bytes.NewReader(inp), s) 4786 return err 4787} 4788 4789var ( 4790 _ encoding.BinaryMarshaler = (*OperationMeta)(nil) 4791 _ encoding.BinaryUnmarshaler = (*OperationMeta)(nil) 4792) 4793 4794// TransactionMetaV1 is an XDR Struct defines as: 4795// 4796// struct TransactionMetaV1 4797// { 4798// LedgerEntryChanges txChanges; // tx level changes if any 4799// OperationMeta operations<>; // meta for each operation 4800// }; 4801// 4802type TransactionMetaV1 struct { 4803 TxChanges LedgerEntryChanges 4804 Operations []OperationMeta 4805} 4806 4807// MarshalBinary implements encoding.BinaryMarshaler. 4808func (s TransactionMetaV1) MarshalBinary() ([]byte, error) { 4809 b := new(bytes.Buffer) 4810 _, err := Marshal(b, s) 4811 return b.Bytes(), err 4812} 4813 4814// UnmarshalBinary implements encoding.BinaryUnmarshaler. 4815func (s *TransactionMetaV1) UnmarshalBinary(inp []byte) error { 4816 _, err := Unmarshal(bytes.NewReader(inp), s) 4817 return err 4818} 4819 4820var ( 4821 _ encoding.BinaryMarshaler = (*TransactionMetaV1)(nil) 4822 _ encoding.BinaryUnmarshaler = (*TransactionMetaV1)(nil) 4823) 4824 4825// TransactionMeta is an XDR Union defines as: 4826// 4827// union TransactionMeta switch (int v) 4828// { 4829// case 0: 4830// OperationMeta operations<>; 4831// case 1: 4832// TransactionMetaV1 v1; 4833// }; 4834// 4835type TransactionMeta struct { 4836 V int32 4837 Operations *[]OperationMeta 4838 V1 *TransactionMetaV1 4839} 4840 4841// SwitchFieldName returns the field name in which this union's 4842// discriminant is stored 4843func (u TransactionMeta) SwitchFieldName() string { 4844 return "V" 4845} 4846 4847// ArmForSwitch returns which field name should be used for storing 4848// the value for an instance of TransactionMeta 4849func (u TransactionMeta) ArmForSwitch(sw int32) (string, bool) { 4850 switch int32(sw) { 4851 case 0: 4852 return "Operations", true 4853 case 1: 4854 return "V1", true 4855 } 4856 return "-", false 4857} 4858 4859// NewTransactionMeta creates a new TransactionMeta. 4860func NewTransactionMeta(v int32, value interface{}) (result TransactionMeta, err error) { 4861 result.V = v 4862 switch int32(v) { 4863 case 0: 4864 tv, ok := value.([]OperationMeta) 4865 if !ok { 4866 err = fmt.Errorf("invalid value, must be []OperationMeta") 4867 return 4868 } 4869 result.Operations = &tv 4870 case 1: 4871 tv, ok := value.(TransactionMetaV1) 4872 if !ok { 4873 err = fmt.Errorf("invalid value, must be TransactionMetaV1") 4874 return 4875 } 4876 result.V1 = &tv 4877 } 4878 return 4879} 4880 4881// MustOperations retrieves the Operations value from the union, 4882// panicing if the value is not set. 4883func (u TransactionMeta) MustOperations() []OperationMeta { 4884 val, ok := u.GetOperations() 4885 4886 if !ok { 4887 panic("arm Operations is not set") 4888 } 4889 4890 return val 4891} 4892 4893// GetOperations retrieves the Operations value from the union, 4894// returning ok if the union's switch indicated the value is valid. 4895func (u TransactionMeta) GetOperations() (result []OperationMeta, ok bool) { 4896 armName, _ := u.ArmForSwitch(int32(u.V)) 4897 4898 if armName == "Operations" { 4899 result = *u.Operations 4900 ok = true 4901 } 4902 4903 return 4904} 4905 4906// MustV1 retrieves the V1 value from the union, 4907// panicing if the value is not set. 4908func (u TransactionMeta) MustV1() TransactionMetaV1 { 4909 val, ok := u.GetV1() 4910 4911 if !ok { 4912 panic("arm V1 is not set") 4913 } 4914 4915 return val 4916} 4917 4918// GetV1 retrieves the V1 value from the union, 4919// returning ok if the union's switch indicated the value is valid. 4920func (u TransactionMeta) GetV1() (result TransactionMetaV1, ok bool) { 4921 armName, _ := u.ArmForSwitch(int32(u.V)) 4922 4923 if armName == "V1" { 4924 result = *u.V1 4925 ok = true 4926 } 4927 4928 return 4929} 4930 4931// MarshalBinary implements encoding.BinaryMarshaler. 4932func (s TransactionMeta) MarshalBinary() ([]byte, error) { 4933 b := new(bytes.Buffer) 4934 _, err := Marshal(b, s) 4935 return b.Bytes(), err 4936} 4937 4938// UnmarshalBinary implements encoding.BinaryUnmarshaler. 4939func (s *TransactionMeta) UnmarshalBinary(inp []byte) error { 4940 _, err := Unmarshal(bytes.NewReader(inp), s) 4941 return err 4942} 4943 4944var ( 4945 _ encoding.BinaryMarshaler = (*TransactionMeta)(nil) 4946 _ encoding.BinaryUnmarshaler = (*TransactionMeta)(nil) 4947) 4948 4949// ErrorCode is an XDR Enum defines as: 4950// 4951// enum ErrorCode 4952// { 4953// ERR_MISC = 0, // Unspecific error 4954// ERR_DATA = 1, // Malformed data 4955// ERR_CONF = 2, // Misconfiguration error 4956// ERR_AUTH = 3, // Authentication failure 4957// ERR_LOAD = 4 // System overloaded 4958// }; 4959// 4960type ErrorCode int32 4961 4962const ( 4963 ErrorCodeErrMisc ErrorCode = 0 4964 ErrorCodeErrData ErrorCode = 1 4965 ErrorCodeErrConf ErrorCode = 2 4966 ErrorCodeErrAuth ErrorCode = 3 4967 ErrorCodeErrLoad ErrorCode = 4 4968) 4969 4970var errorCodeMap = map[int32]string{ 4971 0: "ErrorCodeErrMisc", 4972 1: "ErrorCodeErrData", 4973 2: "ErrorCodeErrConf", 4974 3: "ErrorCodeErrAuth", 4975 4: "ErrorCodeErrLoad", 4976} 4977 4978// ValidEnum validates a proposed value for this enum. Implements 4979// the Enum interface for ErrorCode 4980func (e ErrorCode) ValidEnum(v int32) bool { 4981 _, ok := errorCodeMap[v] 4982 return ok 4983} 4984 4985// String returns the name of `e` 4986func (e ErrorCode) String() string { 4987 name, _ := errorCodeMap[int32(e)] 4988 return name 4989} 4990 4991// MarshalBinary implements encoding.BinaryMarshaler. 4992func (s ErrorCode) MarshalBinary() ([]byte, error) { 4993 b := new(bytes.Buffer) 4994 _, err := Marshal(b, s) 4995 return b.Bytes(), err 4996} 4997 4998// UnmarshalBinary implements encoding.BinaryUnmarshaler. 4999func (s *ErrorCode) UnmarshalBinary(inp []byte) error { 5000 _, err := Unmarshal(bytes.NewReader(inp), s) 5001 return err 5002} 5003 5004var ( 5005 _ encoding.BinaryMarshaler = (*ErrorCode)(nil) 5006 _ encoding.BinaryUnmarshaler = (*ErrorCode)(nil) 5007) 5008 5009// Error is an XDR Struct defines as: 5010// 5011// struct Error 5012// { 5013// ErrorCode code; 5014// string msg<100>; 5015// }; 5016// 5017type Error struct { 5018 Code ErrorCode 5019 Msg string `xdrmaxsize:"100"` 5020} 5021 5022// MarshalBinary implements encoding.BinaryMarshaler. 5023func (s Error) MarshalBinary() ([]byte, error) { 5024 b := new(bytes.Buffer) 5025 _, err := Marshal(b, s) 5026 return b.Bytes(), err 5027} 5028 5029// UnmarshalBinary implements encoding.BinaryUnmarshaler. 5030func (s *Error) UnmarshalBinary(inp []byte) error { 5031 _, err := Unmarshal(bytes.NewReader(inp), s) 5032 return err 5033} 5034 5035var ( 5036 _ encoding.BinaryMarshaler = (*Error)(nil) 5037 _ encoding.BinaryUnmarshaler = (*Error)(nil) 5038) 5039 5040// AuthCert is an XDR Struct defines as: 5041// 5042// struct AuthCert 5043// { 5044// Curve25519Public pubkey; 5045// uint64 expiration; 5046// Signature sig; 5047// }; 5048// 5049type AuthCert struct { 5050 Pubkey Curve25519Public 5051 Expiration Uint64 5052 Sig Signature 5053} 5054 5055// MarshalBinary implements encoding.BinaryMarshaler. 5056func (s AuthCert) MarshalBinary() ([]byte, error) { 5057 b := new(bytes.Buffer) 5058 _, err := Marshal(b, s) 5059 return b.Bytes(), err 5060} 5061 5062// UnmarshalBinary implements encoding.BinaryUnmarshaler. 5063func (s *AuthCert) UnmarshalBinary(inp []byte) error { 5064 _, err := Unmarshal(bytes.NewReader(inp), s) 5065 return err 5066} 5067 5068var ( 5069 _ encoding.BinaryMarshaler = (*AuthCert)(nil) 5070 _ encoding.BinaryUnmarshaler = (*AuthCert)(nil) 5071) 5072 5073// Hello is an XDR Struct defines as: 5074// 5075// struct Hello 5076// { 5077// uint32 ledgerVersion; 5078// uint32 overlayVersion; 5079// uint32 overlayMinVersion; 5080// Hash networkID; 5081// string versionStr<100>; 5082// int listeningPort; 5083// NodeID peerID; 5084// AuthCert cert; 5085// uint256 nonce; 5086// }; 5087// 5088type Hello struct { 5089 LedgerVersion Uint32 5090 OverlayVersion Uint32 5091 OverlayMinVersion Uint32 5092 NetworkId Hash 5093 VersionStr string `xdrmaxsize:"100"` 5094 ListeningPort int32 5095 PeerId NodeId 5096 Cert AuthCert 5097 Nonce Uint256 5098} 5099 5100// MarshalBinary implements encoding.BinaryMarshaler. 5101func (s Hello) MarshalBinary() ([]byte, error) { 5102 b := new(bytes.Buffer) 5103 _, err := Marshal(b, s) 5104 return b.Bytes(), err 5105} 5106 5107// UnmarshalBinary implements encoding.BinaryUnmarshaler. 5108func (s *Hello) UnmarshalBinary(inp []byte) error { 5109 _, err := Unmarshal(bytes.NewReader(inp), s) 5110 return err 5111} 5112 5113var ( 5114 _ encoding.BinaryMarshaler = (*Hello)(nil) 5115 _ encoding.BinaryUnmarshaler = (*Hello)(nil) 5116) 5117 5118// Auth is an XDR Struct defines as: 5119// 5120// struct Auth 5121// { 5122// // Empty message, just to confirm 5123// // establishment of MAC keys. 5124// int unused; 5125// }; 5126// 5127type Auth struct { 5128 Unused int32 5129} 5130 5131// MarshalBinary implements encoding.BinaryMarshaler. 5132func (s Auth) MarshalBinary() ([]byte, error) { 5133 b := new(bytes.Buffer) 5134 _, err := Marshal(b, s) 5135 return b.Bytes(), err 5136} 5137 5138// UnmarshalBinary implements encoding.BinaryUnmarshaler. 5139func (s *Auth) UnmarshalBinary(inp []byte) error { 5140 _, err := Unmarshal(bytes.NewReader(inp), s) 5141 return err 5142} 5143 5144var ( 5145 _ encoding.BinaryMarshaler = (*Auth)(nil) 5146 _ encoding.BinaryUnmarshaler = (*Auth)(nil) 5147) 5148 5149// IpAddrType is an XDR Enum defines as: 5150// 5151// enum IPAddrType 5152// { 5153// IPv4 = 0, 5154// IPv6 = 1 5155// }; 5156// 5157type IpAddrType int32 5158 5159const ( 5160 IpAddrTypeIPv4 IpAddrType = 0 5161 IpAddrTypeIPv6 IpAddrType = 1 5162) 5163 5164var ipAddrTypeMap = map[int32]string{ 5165 0: "IpAddrTypeIPv4", 5166 1: "IpAddrTypeIPv6", 5167} 5168 5169// ValidEnum validates a proposed value for this enum. Implements 5170// the Enum interface for IpAddrType 5171func (e IpAddrType) ValidEnum(v int32) bool { 5172 _, ok := ipAddrTypeMap[v] 5173 return ok 5174} 5175 5176// String returns the name of `e` 5177func (e IpAddrType) String() string { 5178 name, _ := ipAddrTypeMap[int32(e)] 5179 return name 5180} 5181 5182// MarshalBinary implements encoding.BinaryMarshaler. 5183func (s IpAddrType) MarshalBinary() ([]byte, error) { 5184 b := new(bytes.Buffer) 5185 _, err := Marshal(b, s) 5186 return b.Bytes(), err 5187} 5188 5189// UnmarshalBinary implements encoding.BinaryUnmarshaler. 5190func (s *IpAddrType) UnmarshalBinary(inp []byte) error { 5191 _, err := Unmarshal(bytes.NewReader(inp), s) 5192 return err 5193} 5194 5195var ( 5196 _ encoding.BinaryMarshaler = (*IpAddrType)(nil) 5197 _ encoding.BinaryUnmarshaler = (*IpAddrType)(nil) 5198) 5199 5200// PeerAddressIp is an XDR NestedUnion defines as: 5201// 5202// union switch (IPAddrType type) 5203// { 5204// case IPv4: 5205// opaque ipv4[4]; 5206// case IPv6: 5207// opaque ipv6[16]; 5208// } 5209// 5210type PeerAddressIp struct { 5211 Type IpAddrType 5212 Ipv4 *[4]byte `xdrmaxsize:"4"` 5213 Ipv6 *[16]byte `xdrmaxsize:"16"` 5214} 5215 5216// SwitchFieldName returns the field name in which this union's 5217// discriminant is stored 5218func (u PeerAddressIp) SwitchFieldName() string { 5219 return "Type" 5220} 5221 5222// ArmForSwitch returns which field name should be used for storing 5223// the value for an instance of PeerAddressIp 5224func (u PeerAddressIp) ArmForSwitch(sw int32) (string, bool) { 5225 switch IpAddrType(sw) { 5226 case IpAddrTypeIPv4: 5227 return "Ipv4", true 5228 case IpAddrTypeIPv6: 5229 return "Ipv6", true 5230 } 5231 return "-", false 5232} 5233 5234// NewPeerAddressIp creates a new PeerAddressIp. 5235func NewPeerAddressIp(aType IpAddrType, value interface{}) (result PeerAddressIp, err error) { 5236 result.Type = aType 5237 switch IpAddrType(aType) { 5238 case IpAddrTypeIPv4: 5239 tv, ok := value.([4]byte) 5240 if !ok { 5241 err = fmt.Errorf("invalid value, must be [4]byte") 5242 return 5243 } 5244 result.Ipv4 = &tv 5245 case IpAddrTypeIPv6: 5246 tv, ok := value.([16]byte) 5247 if !ok { 5248 err = fmt.Errorf("invalid value, must be [16]byte") 5249 return 5250 } 5251 result.Ipv6 = &tv 5252 } 5253 return 5254} 5255 5256// MustIpv4 retrieves the Ipv4 value from the union, 5257// panicing if the value is not set. 5258func (u PeerAddressIp) MustIpv4() [4]byte { 5259 val, ok := u.GetIpv4() 5260 5261 if !ok { 5262 panic("arm Ipv4 is not set") 5263 } 5264 5265 return val 5266} 5267 5268// GetIpv4 retrieves the Ipv4 value from the union, 5269// returning ok if the union's switch indicated the value is valid. 5270func (u PeerAddressIp) GetIpv4() (result [4]byte, ok bool) { 5271 armName, _ := u.ArmForSwitch(int32(u.Type)) 5272 5273 if armName == "Ipv4" { 5274 result = *u.Ipv4 5275 ok = true 5276 } 5277 5278 return 5279} 5280 5281// MustIpv6 retrieves the Ipv6 value from the union, 5282// panicing if the value is not set. 5283func (u PeerAddressIp) MustIpv6() [16]byte { 5284 val, ok := u.GetIpv6() 5285 5286 if !ok { 5287 panic("arm Ipv6 is not set") 5288 } 5289 5290 return val 5291} 5292 5293// GetIpv6 retrieves the Ipv6 value from the union, 5294// returning ok if the union's switch indicated the value is valid. 5295func (u PeerAddressIp) GetIpv6() (result [16]byte, ok bool) { 5296 armName, _ := u.ArmForSwitch(int32(u.Type)) 5297 5298 if armName == "Ipv6" { 5299 result = *u.Ipv6 5300 ok = true 5301 } 5302 5303 return 5304} 5305 5306// MarshalBinary implements encoding.BinaryMarshaler. 5307func (s PeerAddressIp) MarshalBinary() ([]byte, error) { 5308 b := new(bytes.Buffer) 5309 _, err := Marshal(b, s) 5310 return b.Bytes(), err 5311} 5312 5313// UnmarshalBinary implements encoding.BinaryUnmarshaler. 5314func (s *PeerAddressIp) UnmarshalBinary(inp []byte) error { 5315 _, err := Unmarshal(bytes.NewReader(inp), s) 5316 return err 5317} 5318 5319var ( 5320 _ encoding.BinaryMarshaler = (*PeerAddressIp)(nil) 5321 _ encoding.BinaryUnmarshaler = (*PeerAddressIp)(nil) 5322) 5323 5324// PeerAddress is an XDR Struct defines as: 5325// 5326// struct PeerAddress 5327// { 5328// union switch (IPAddrType type) 5329// { 5330// case IPv4: 5331// opaque ipv4[4]; 5332// case IPv6: 5333// opaque ipv6[16]; 5334// } 5335// ip; 5336// uint32 port; 5337// uint32 numFailures; 5338// }; 5339// 5340type PeerAddress struct { 5341 Ip PeerAddressIp 5342 Port Uint32 5343 NumFailures Uint32 5344} 5345 5346// MarshalBinary implements encoding.BinaryMarshaler. 5347func (s PeerAddress) MarshalBinary() ([]byte, error) { 5348 b := new(bytes.Buffer) 5349 _, err := Marshal(b, s) 5350 return b.Bytes(), err 5351} 5352 5353// UnmarshalBinary implements encoding.BinaryUnmarshaler. 5354func (s *PeerAddress) UnmarshalBinary(inp []byte) error { 5355 _, err := Unmarshal(bytes.NewReader(inp), s) 5356 return err 5357} 5358 5359var ( 5360 _ encoding.BinaryMarshaler = (*PeerAddress)(nil) 5361 _ encoding.BinaryUnmarshaler = (*PeerAddress)(nil) 5362) 5363 5364// MessageType is an XDR Enum defines as: 5365// 5366// enum MessageType 5367// { 5368// ERROR_MSG = 0, 5369// AUTH = 2, 5370// DONT_HAVE = 3, 5371// 5372// GET_PEERS = 4, // gets a list of peers this guy knows about 5373// PEERS = 5, 5374// 5375// GET_TX_SET = 6, // gets a particular txset by hash 5376// TX_SET = 7, 5377// 5378// TRANSACTION = 8, // pass on a tx you have heard about 5379// 5380// // SCP 5381// GET_SCP_QUORUMSET = 9, 5382// SCP_QUORUMSET = 10, 5383// SCP_MESSAGE = 11, 5384// GET_SCP_STATE = 12, 5385// 5386// // new messages 5387// HELLO = 13 5388// }; 5389// 5390type MessageType int32 5391 5392const ( 5393 MessageTypeErrorMsg MessageType = 0 5394 MessageTypeAuth MessageType = 2 5395 MessageTypeDontHave MessageType = 3 5396 MessageTypeGetPeers MessageType = 4 5397 MessageTypePeers MessageType = 5 5398 MessageTypeGetTxSet MessageType = 6 5399 MessageTypeTxSet MessageType = 7 5400 MessageTypeTransaction MessageType = 8 5401 MessageTypeGetScpQuorumset MessageType = 9 5402 MessageTypeScpQuorumset MessageType = 10 5403 MessageTypeScpMessage MessageType = 11 5404 MessageTypeGetScpState MessageType = 12 5405 MessageTypeHello MessageType = 13 5406) 5407 5408var messageTypeMap = map[int32]string{ 5409 0: "MessageTypeErrorMsg", 5410 2: "MessageTypeAuth", 5411 3: "MessageTypeDontHave", 5412 4: "MessageTypeGetPeers", 5413 5: "MessageTypePeers", 5414 6: "MessageTypeGetTxSet", 5415 7: "MessageTypeTxSet", 5416 8: "MessageTypeTransaction", 5417 9: "MessageTypeGetScpQuorumset", 5418 10: "MessageTypeScpQuorumset", 5419 11: "MessageTypeScpMessage", 5420 12: "MessageTypeGetScpState", 5421 13: "MessageTypeHello", 5422} 5423 5424// ValidEnum validates a proposed value for this enum. Implements 5425// the Enum interface for MessageType 5426func (e MessageType) ValidEnum(v int32) bool { 5427 _, ok := messageTypeMap[v] 5428 return ok 5429} 5430 5431// String returns the name of `e` 5432func (e MessageType) String() string { 5433 name, _ := messageTypeMap[int32(e)] 5434 return name 5435} 5436 5437// MarshalBinary implements encoding.BinaryMarshaler. 5438func (s MessageType) MarshalBinary() ([]byte, error) { 5439 b := new(bytes.Buffer) 5440 _, err := Marshal(b, s) 5441 return b.Bytes(), err 5442} 5443 5444// UnmarshalBinary implements encoding.BinaryUnmarshaler. 5445func (s *MessageType) UnmarshalBinary(inp []byte) error { 5446 _, err := Unmarshal(bytes.NewReader(inp), s) 5447 return err 5448} 5449 5450var ( 5451 _ encoding.BinaryMarshaler = (*MessageType)(nil) 5452 _ encoding.BinaryUnmarshaler = (*MessageType)(nil) 5453) 5454 5455// DontHave is an XDR Struct defines as: 5456// 5457// struct DontHave 5458// { 5459// MessageType type; 5460// uint256 reqHash; 5461// }; 5462// 5463type DontHave struct { 5464 Type MessageType 5465 ReqHash Uint256 5466} 5467 5468// MarshalBinary implements encoding.BinaryMarshaler. 5469func (s DontHave) MarshalBinary() ([]byte, error) { 5470 b := new(bytes.Buffer) 5471 _, err := Marshal(b, s) 5472 return b.Bytes(), err 5473} 5474 5475// UnmarshalBinary implements encoding.BinaryUnmarshaler. 5476func (s *DontHave) UnmarshalBinary(inp []byte) error { 5477 _, err := Unmarshal(bytes.NewReader(inp), s) 5478 return err 5479} 5480 5481var ( 5482 _ encoding.BinaryMarshaler = (*DontHave)(nil) 5483 _ encoding.BinaryUnmarshaler = (*DontHave)(nil) 5484) 5485 5486// StellarMessage is an XDR Union defines as: 5487// 5488// union StellarMessage switch (MessageType type) 5489// { 5490// case ERROR_MSG: 5491// Error error; 5492// case HELLO: 5493// Hello hello; 5494// case AUTH: 5495// Auth auth; 5496// case DONT_HAVE: 5497// DontHave dontHave; 5498// case GET_PEERS: 5499// void; 5500// case PEERS: 5501// PeerAddress peers<100>; 5502// 5503// case GET_TX_SET: 5504// uint256 txSetHash; 5505// case TX_SET: 5506// TransactionSet txSet; 5507// 5508// case TRANSACTION: 5509// TransactionEnvelope transaction; 5510// 5511// // SCP 5512// case GET_SCP_QUORUMSET: 5513// uint256 qSetHash; 5514// case SCP_QUORUMSET: 5515// SCPQuorumSet qSet; 5516// case SCP_MESSAGE: 5517// SCPEnvelope envelope; 5518// case GET_SCP_STATE: 5519// uint32 getSCPLedgerSeq; // ledger seq requested ; if 0, requests the latest 5520// }; 5521// 5522type StellarMessage struct { 5523 Type MessageType 5524 Error *Error 5525 Hello *Hello 5526 Auth *Auth 5527 DontHave *DontHave 5528 Peers *[]PeerAddress `xdrmaxsize:"100"` 5529 TxSetHash *Uint256 5530 TxSet *TransactionSet 5531 Transaction *TransactionEnvelope 5532 QSetHash *Uint256 5533 QSet *ScpQuorumSet 5534 Envelope *ScpEnvelope 5535 GetScpLedgerSeq *Uint32 5536} 5537 5538// SwitchFieldName returns the field name in which this union's 5539// discriminant is stored 5540func (u StellarMessage) SwitchFieldName() string { 5541 return "Type" 5542} 5543 5544// ArmForSwitch returns which field name should be used for storing 5545// the value for an instance of StellarMessage 5546func (u StellarMessage) ArmForSwitch(sw int32) (string, bool) { 5547 switch MessageType(sw) { 5548 case MessageTypeErrorMsg: 5549 return "Error", true 5550 case MessageTypeHello: 5551 return "Hello", true 5552 case MessageTypeAuth: 5553 return "Auth", true 5554 case MessageTypeDontHave: 5555 return "DontHave", true 5556 case MessageTypeGetPeers: 5557 return "", true 5558 case MessageTypePeers: 5559 return "Peers", true 5560 case MessageTypeGetTxSet: 5561 return "TxSetHash", true 5562 case MessageTypeTxSet: 5563 return "TxSet", true 5564 case MessageTypeTransaction: 5565 return "Transaction", true 5566 case MessageTypeGetScpQuorumset: 5567 return "QSetHash", true 5568 case MessageTypeScpQuorumset: 5569 return "QSet", true 5570 case MessageTypeScpMessage: 5571 return "Envelope", true 5572 case MessageTypeGetScpState: 5573 return "GetScpLedgerSeq", true 5574 } 5575 return "-", false 5576} 5577 5578// NewStellarMessage creates a new StellarMessage. 5579func NewStellarMessage(aType MessageType, value interface{}) (result StellarMessage, err error) { 5580 result.Type = aType 5581 switch MessageType(aType) { 5582 case MessageTypeErrorMsg: 5583 tv, ok := value.(Error) 5584 if !ok { 5585 err = fmt.Errorf("invalid value, must be Error") 5586 return 5587 } 5588 result.Error = &tv 5589 case MessageTypeHello: 5590 tv, ok := value.(Hello) 5591 if !ok { 5592 err = fmt.Errorf("invalid value, must be Hello") 5593 return 5594 } 5595 result.Hello = &tv 5596 case MessageTypeAuth: 5597 tv, ok := value.(Auth) 5598 if !ok { 5599 err = fmt.Errorf("invalid value, must be Auth") 5600 return 5601 } 5602 result.Auth = &tv 5603 case MessageTypeDontHave: 5604 tv, ok := value.(DontHave) 5605 if !ok { 5606 err = fmt.Errorf("invalid value, must be DontHave") 5607 return 5608 } 5609 result.DontHave = &tv 5610 case MessageTypeGetPeers: 5611 // void 5612 case MessageTypePeers: 5613 tv, ok := value.([]PeerAddress) 5614 if !ok { 5615 err = fmt.Errorf("invalid value, must be []PeerAddress") 5616 return 5617 } 5618 result.Peers = &tv 5619 case MessageTypeGetTxSet: 5620 tv, ok := value.(Uint256) 5621 if !ok { 5622 err = fmt.Errorf("invalid value, must be Uint256") 5623 return 5624 } 5625 result.TxSetHash = &tv 5626 case MessageTypeTxSet: 5627 tv, ok := value.(TransactionSet) 5628 if !ok { 5629 err = fmt.Errorf("invalid value, must be TransactionSet") 5630 return 5631 } 5632 result.TxSet = &tv 5633 case MessageTypeTransaction: 5634 tv, ok := value.(TransactionEnvelope) 5635 if !ok { 5636 err = fmt.Errorf("invalid value, must be TransactionEnvelope") 5637 return 5638 } 5639 result.Transaction = &tv 5640 case MessageTypeGetScpQuorumset: 5641 tv, ok := value.(Uint256) 5642 if !ok { 5643 err = fmt.Errorf("invalid value, must be Uint256") 5644 return 5645 } 5646 result.QSetHash = &tv 5647 case MessageTypeScpQuorumset: 5648 tv, ok := value.(ScpQuorumSet) 5649 if !ok { 5650 err = fmt.Errorf("invalid value, must be ScpQuorumSet") 5651 return 5652 } 5653 result.QSet = &tv 5654 case MessageTypeScpMessage: 5655 tv, ok := value.(ScpEnvelope) 5656 if !ok { 5657 err = fmt.Errorf("invalid value, must be ScpEnvelope") 5658 return 5659 } 5660 result.Envelope = &tv 5661 case MessageTypeGetScpState: 5662 tv, ok := value.(Uint32) 5663 if !ok { 5664 err = fmt.Errorf("invalid value, must be Uint32") 5665 return 5666 } 5667 result.GetScpLedgerSeq = &tv 5668 } 5669 return 5670} 5671 5672// MustError retrieves the Error value from the union, 5673// panicing if the value is not set. 5674func (u StellarMessage) MustError() Error { 5675 val, ok := u.GetError() 5676 5677 if !ok { 5678 panic("arm Error is not set") 5679 } 5680 5681 return val 5682} 5683 5684// GetError retrieves the Error value from the union, 5685// returning ok if the union's switch indicated the value is valid. 5686func (u StellarMessage) GetError() (result Error, ok bool) { 5687 armName, _ := u.ArmForSwitch(int32(u.Type)) 5688 5689 if armName == "Error" { 5690 result = *u.Error 5691 ok = true 5692 } 5693 5694 return 5695} 5696 5697// MustHello retrieves the Hello value from the union, 5698// panicing if the value is not set. 5699func (u StellarMessage) MustHello() Hello { 5700 val, ok := u.GetHello() 5701 5702 if !ok { 5703 panic("arm Hello is not set") 5704 } 5705 5706 return val 5707} 5708 5709// GetHello retrieves the Hello value from the union, 5710// returning ok if the union's switch indicated the value is valid. 5711func (u StellarMessage) GetHello() (result Hello, ok bool) { 5712 armName, _ := u.ArmForSwitch(int32(u.Type)) 5713 5714 if armName == "Hello" { 5715 result = *u.Hello 5716 ok = true 5717 } 5718 5719 return 5720} 5721 5722// MustAuth retrieves the Auth value from the union, 5723// panicing if the value is not set. 5724func (u StellarMessage) MustAuth() Auth { 5725 val, ok := u.GetAuth() 5726 5727 if !ok { 5728 panic("arm Auth is not set") 5729 } 5730 5731 return val 5732} 5733 5734// GetAuth retrieves the Auth value from the union, 5735// returning ok if the union's switch indicated the value is valid. 5736func (u StellarMessage) GetAuth() (result Auth, ok bool) { 5737 armName, _ := u.ArmForSwitch(int32(u.Type)) 5738 5739 if armName == "Auth" { 5740 result = *u.Auth 5741 ok = true 5742 } 5743 5744 return 5745} 5746 5747// MustDontHave retrieves the DontHave value from the union, 5748// panicing if the value is not set. 5749func (u StellarMessage) MustDontHave() DontHave { 5750 val, ok := u.GetDontHave() 5751 5752 if !ok { 5753 panic("arm DontHave is not set") 5754 } 5755 5756 return val 5757} 5758 5759// GetDontHave retrieves the DontHave value from the union, 5760// returning ok if the union's switch indicated the value is valid. 5761func (u StellarMessage) GetDontHave() (result DontHave, ok bool) { 5762 armName, _ := u.ArmForSwitch(int32(u.Type)) 5763 5764 if armName == "DontHave" { 5765 result = *u.DontHave 5766 ok = true 5767 } 5768 5769 return 5770} 5771 5772// MustPeers retrieves the Peers value from the union, 5773// panicing if the value is not set. 5774func (u StellarMessage) MustPeers() []PeerAddress { 5775 val, ok := u.GetPeers() 5776 5777 if !ok { 5778 panic("arm Peers is not set") 5779 } 5780 5781 return val 5782} 5783 5784// GetPeers retrieves the Peers value from the union, 5785// returning ok if the union's switch indicated the value is valid. 5786func (u StellarMessage) GetPeers() (result []PeerAddress, ok bool) { 5787 armName, _ := u.ArmForSwitch(int32(u.Type)) 5788 5789 if armName == "Peers" { 5790 result = *u.Peers 5791 ok = true 5792 } 5793 5794 return 5795} 5796 5797// MustTxSetHash retrieves the TxSetHash value from the union, 5798// panicing if the value is not set. 5799func (u StellarMessage) MustTxSetHash() Uint256 { 5800 val, ok := u.GetTxSetHash() 5801 5802 if !ok { 5803 panic("arm TxSetHash is not set") 5804 } 5805 5806 return val 5807} 5808 5809// GetTxSetHash retrieves the TxSetHash value from the union, 5810// returning ok if the union's switch indicated the value is valid. 5811func (u StellarMessage) GetTxSetHash() (result Uint256, ok bool) { 5812 armName, _ := u.ArmForSwitch(int32(u.Type)) 5813 5814 if armName == "TxSetHash" { 5815 result = *u.TxSetHash 5816 ok = true 5817 } 5818 5819 return 5820} 5821 5822// MustTxSet retrieves the TxSet value from the union, 5823// panicing if the value is not set. 5824func (u StellarMessage) MustTxSet() TransactionSet { 5825 val, ok := u.GetTxSet() 5826 5827 if !ok { 5828 panic("arm TxSet is not set") 5829 } 5830 5831 return val 5832} 5833 5834// GetTxSet retrieves the TxSet value from the union, 5835// returning ok if the union's switch indicated the value is valid. 5836func (u StellarMessage) GetTxSet() (result TransactionSet, ok bool) { 5837 armName, _ := u.ArmForSwitch(int32(u.Type)) 5838 5839 if armName == "TxSet" { 5840 result = *u.TxSet 5841 ok = true 5842 } 5843 5844 return 5845} 5846 5847// MustTransaction retrieves the Transaction value from the union, 5848// panicing if the value is not set. 5849func (u StellarMessage) MustTransaction() TransactionEnvelope { 5850 val, ok := u.GetTransaction() 5851 5852 if !ok { 5853 panic("arm Transaction is not set") 5854 } 5855 5856 return val 5857} 5858 5859// GetTransaction retrieves the Transaction value from the union, 5860// returning ok if the union's switch indicated the value is valid. 5861func (u StellarMessage) GetTransaction() (result TransactionEnvelope, ok bool) { 5862 armName, _ := u.ArmForSwitch(int32(u.Type)) 5863 5864 if armName == "Transaction" { 5865 result = *u.Transaction 5866 ok = true 5867 } 5868 5869 return 5870} 5871 5872// MustQSetHash retrieves the QSetHash value from the union, 5873// panicing if the value is not set. 5874func (u StellarMessage) MustQSetHash() Uint256 { 5875 val, ok := u.GetQSetHash() 5876 5877 if !ok { 5878 panic("arm QSetHash is not set") 5879 } 5880 5881 return val 5882} 5883 5884// GetQSetHash retrieves the QSetHash value from the union, 5885// returning ok if the union's switch indicated the value is valid. 5886func (u StellarMessage) GetQSetHash() (result Uint256, ok bool) { 5887 armName, _ := u.ArmForSwitch(int32(u.Type)) 5888 5889 if armName == "QSetHash" { 5890 result = *u.QSetHash 5891 ok = true 5892 } 5893 5894 return 5895} 5896 5897// MustQSet retrieves the QSet value from the union, 5898// panicing if the value is not set. 5899func (u StellarMessage) MustQSet() ScpQuorumSet { 5900 val, ok := u.GetQSet() 5901 5902 if !ok { 5903 panic("arm QSet is not set") 5904 } 5905 5906 return val 5907} 5908 5909// GetQSet retrieves the QSet value from the union, 5910// returning ok if the union's switch indicated the value is valid. 5911func (u StellarMessage) GetQSet() (result ScpQuorumSet, ok bool) { 5912 armName, _ := u.ArmForSwitch(int32(u.Type)) 5913 5914 if armName == "QSet" { 5915 result = *u.QSet 5916 ok = true 5917 } 5918 5919 return 5920} 5921 5922// MustEnvelope retrieves the Envelope value from the union, 5923// panicing if the value is not set. 5924func (u StellarMessage) MustEnvelope() ScpEnvelope { 5925 val, ok := u.GetEnvelope() 5926 5927 if !ok { 5928 panic("arm Envelope is not set") 5929 } 5930 5931 return val 5932} 5933 5934// GetEnvelope retrieves the Envelope value from the union, 5935// returning ok if the union's switch indicated the value is valid. 5936func (u StellarMessage) GetEnvelope() (result ScpEnvelope, ok bool) { 5937 armName, _ := u.ArmForSwitch(int32(u.Type)) 5938 5939 if armName == "Envelope" { 5940 result = *u.Envelope 5941 ok = true 5942 } 5943 5944 return 5945} 5946 5947// MustGetScpLedgerSeq retrieves the GetScpLedgerSeq value from the union, 5948// panicing if the value is not set. 5949func (u StellarMessage) MustGetScpLedgerSeq() Uint32 { 5950 val, ok := u.GetGetScpLedgerSeq() 5951 5952 if !ok { 5953 panic("arm GetScpLedgerSeq is not set") 5954 } 5955 5956 return val 5957} 5958 5959// GetGetScpLedgerSeq retrieves the GetScpLedgerSeq value from the union, 5960// returning ok if the union's switch indicated the value is valid. 5961func (u StellarMessage) GetGetScpLedgerSeq() (result Uint32, ok bool) { 5962 armName, _ := u.ArmForSwitch(int32(u.Type)) 5963 5964 if armName == "GetScpLedgerSeq" { 5965 result = *u.GetScpLedgerSeq 5966 ok = true 5967 } 5968 5969 return 5970} 5971 5972// MarshalBinary implements encoding.BinaryMarshaler. 5973func (s StellarMessage) MarshalBinary() ([]byte, error) { 5974 b := new(bytes.Buffer) 5975 _, err := Marshal(b, s) 5976 return b.Bytes(), err 5977} 5978 5979// UnmarshalBinary implements encoding.BinaryUnmarshaler. 5980func (s *StellarMessage) UnmarshalBinary(inp []byte) error { 5981 _, err := Unmarshal(bytes.NewReader(inp), s) 5982 return err 5983} 5984 5985var ( 5986 _ encoding.BinaryMarshaler = (*StellarMessage)(nil) 5987 _ encoding.BinaryUnmarshaler = (*StellarMessage)(nil) 5988) 5989 5990// AuthenticatedMessageV0 is an XDR NestedStruct defines as: 5991// 5992// struct 5993// { 5994// uint64 sequence; 5995// StellarMessage message; 5996// HmacSha256Mac mac; 5997// } 5998// 5999type AuthenticatedMessageV0 struct { 6000 Sequence Uint64 6001 Message StellarMessage 6002 Mac HmacSha256Mac 6003} 6004 6005// MarshalBinary implements encoding.BinaryMarshaler. 6006func (s AuthenticatedMessageV0) MarshalBinary() ([]byte, error) { 6007 b := new(bytes.Buffer) 6008 _, err := Marshal(b, s) 6009 return b.Bytes(), err 6010} 6011 6012// UnmarshalBinary implements encoding.BinaryUnmarshaler. 6013func (s *AuthenticatedMessageV0) UnmarshalBinary(inp []byte) error { 6014 _, err := Unmarshal(bytes.NewReader(inp), s) 6015 return err 6016} 6017 6018var ( 6019 _ encoding.BinaryMarshaler = (*AuthenticatedMessageV0)(nil) 6020 _ encoding.BinaryUnmarshaler = (*AuthenticatedMessageV0)(nil) 6021) 6022 6023// AuthenticatedMessage is an XDR Union defines as: 6024// 6025// union AuthenticatedMessage switch (uint32 v) 6026// { 6027// case 0: 6028// struct 6029// { 6030// uint64 sequence; 6031// StellarMessage message; 6032// HmacSha256Mac mac; 6033// } v0; 6034// }; 6035// 6036type AuthenticatedMessage struct { 6037 V Uint32 6038 V0 *AuthenticatedMessageV0 6039} 6040 6041// SwitchFieldName returns the field name in which this union's 6042// discriminant is stored 6043func (u AuthenticatedMessage) SwitchFieldName() string { 6044 return "V" 6045} 6046 6047// ArmForSwitch returns which field name should be used for storing 6048// the value for an instance of AuthenticatedMessage 6049func (u AuthenticatedMessage) ArmForSwitch(sw int32) (string, bool) { 6050 switch Uint32(sw) { 6051 case 0: 6052 return "V0", true 6053 } 6054 return "-", false 6055} 6056 6057// NewAuthenticatedMessage creates a new AuthenticatedMessage. 6058func NewAuthenticatedMessage(v Uint32, value interface{}) (result AuthenticatedMessage, err error) { 6059 result.V = v 6060 switch Uint32(v) { 6061 case 0: 6062 tv, ok := value.(AuthenticatedMessageV0) 6063 if !ok { 6064 err = fmt.Errorf("invalid value, must be AuthenticatedMessageV0") 6065 return 6066 } 6067 result.V0 = &tv 6068 } 6069 return 6070} 6071 6072// MustV0 retrieves the V0 value from the union, 6073// panicing if the value is not set. 6074func (u AuthenticatedMessage) MustV0() AuthenticatedMessageV0 { 6075 val, ok := u.GetV0() 6076 6077 if !ok { 6078 panic("arm V0 is not set") 6079 } 6080 6081 return val 6082} 6083 6084// GetV0 retrieves the V0 value from the union, 6085// returning ok if the union's switch indicated the value is valid. 6086func (u AuthenticatedMessage) GetV0() (result AuthenticatedMessageV0, ok bool) { 6087 armName, _ := u.ArmForSwitch(int32(u.V)) 6088 6089 if armName == "V0" { 6090 result = *u.V0 6091 ok = true 6092 } 6093 6094 return 6095} 6096 6097// MarshalBinary implements encoding.BinaryMarshaler. 6098func (s AuthenticatedMessage) MarshalBinary() ([]byte, error) { 6099 b := new(bytes.Buffer) 6100 _, err := Marshal(b, s) 6101 return b.Bytes(), err 6102} 6103 6104// UnmarshalBinary implements encoding.BinaryUnmarshaler. 6105func (s *AuthenticatedMessage) UnmarshalBinary(inp []byte) error { 6106 _, err := Unmarshal(bytes.NewReader(inp), s) 6107 return err 6108} 6109 6110var ( 6111 _ encoding.BinaryMarshaler = (*AuthenticatedMessage)(nil) 6112 _ encoding.BinaryUnmarshaler = (*AuthenticatedMessage)(nil) 6113) 6114 6115// DecoratedSignature is an XDR Struct defines as: 6116// 6117// struct DecoratedSignature 6118// { 6119// SignatureHint hint; // last 4 bytes of the public key, used as a hint 6120// Signature signature; // actual signature 6121// }; 6122// 6123type DecoratedSignature struct { 6124 Hint SignatureHint 6125 Signature Signature 6126} 6127 6128// MarshalBinary implements encoding.BinaryMarshaler. 6129func (s DecoratedSignature) MarshalBinary() ([]byte, error) { 6130 b := new(bytes.Buffer) 6131 _, err := Marshal(b, s) 6132 return b.Bytes(), err 6133} 6134 6135// UnmarshalBinary implements encoding.BinaryUnmarshaler. 6136func (s *DecoratedSignature) UnmarshalBinary(inp []byte) error { 6137 _, err := Unmarshal(bytes.NewReader(inp), s) 6138 return err 6139} 6140 6141var ( 6142 _ encoding.BinaryMarshaler = (*DecoratedSignature)(nil) 6143 _ encoding.BinaryUnmarshaler = (*DecoratedSignature)(nil) 6144) 6145 6146// OperationType is an XDR Enum defines as: 6147// 6148// enum OperationType 6149// { 6150// CREATE_ACCOUNT = 0, 6151// PAYMENT = 1, 6152// PATH_PAYMENT_STRICT_RECEIVE = 2, 6153// MANAGE_SELL_OFFER = 3, 6154// CREATE_PASSIVE_SELL_OFFER = 4, 6155// SET_OPTIONS = 5, 6156// CHANGE_TRUST = 6, 6157// ALLOW_TRUST = 7, 6158// ACCOUNT_MERGE = 8, 6159// INFLATION = 9, 6160// MANAGE_DATA = 10, 6161// BUMP_SEQUENCE = 11, 6162// MANAGE_BUY_OFFER = 12, 6163// PATH_PAYMENT_STRICT_SEND = 13 6164// }; 6165// 6166type OperationType int32 6167 6168const ( 6169 OperationTypeCreateAccount OperationType = 0 6170 OperationTypePayment OperationType = 1 6171 OperationTypePathPaymentStrictReceive OperationType = 2 6172 OperationTypeManageSellOffer OperationType = 3 6173 OperationTypeCreatePassiveSellOffer OperationType = 4 6174 OperationTypeSetOptions OperationType = 5 6175 OperationTypeChangeTrust OperationType = 6 6176 OperationTypeAllowTrust OperationType = 7 6177 OperationTypeAccountMerge OperationType = 8 6178 OperationTypeInflation OperationType = 9 6179 OperationTypeManageData OperationType = 10 6180 OperationTypeBumpSequence OperationType = 11 6181 OperationTypeManageBuyOffer OperationType = 12 6182 OperationTypePathPaymentStrictSend OperationType = 13 6183) 6184 6185var operationTypeMap = map[int32]string{ 6186 0: "OperationTypeCreateAccount", 6187 1: "OperationTypePayment", 6188 2: "OperationTypePathPaymentStrictReceive", 6189 3: "OperationTypeManageSellOffer", 6190 4: "OperationTypeCreatePassiveSellOffer", 6191 5: "OperationTypeSetOptions", 6192 6: "OperationTypeChangeTrust", 6193 7: "OperationTypeAllowTrust", 6194 8: "OperationTypeAccountMerge", 6195 9: "OperationTypeInflation", 6196 10: "OperationTypeManageData", 6197 11: "OperationTypeBumpSequence", 6198 12: "OperationTypeManageBuyOffer", 6199 13: "OperationTypePathPaymentStrictSend", 6200} 6201 6202// ValidEnum validates a proposed value for this enum. Implements 6203// the Enum interface for OperationType 6204func (e OperationType) ValidEnum(v int32) bool { 6205 _, ok := operationTypeMap[v] 6206 return ok 6207} 6208 6209// String returns the name of `e` 6210func (e OperationType) String() string { 6211 name, _ := operationTypeMap[int32(e)] 6212 return name 6213} 6214 6215// MarshalBinary implements encoding.BinaryMarshaler. 6216func (s OperationType) MarshalBinary() ([]byte, error) { 6217 b := new(bytes.Buffer) 6218 _, err := Marshal(b, s) 6219 return b.Bytes(), err 6220} 6221 6222// UnmarshalBinary implements encoding.BinaryUnmarshaler. 6223func (s *OperationType) UnmarshalBinary(inp []byte) error { 6224 _, err := Unmarshal(bytes.NewReader(inp), s) 6225 return err 6226} 6227 6228var ( 6229 _ encoding.BinaryMarshaler = (*OperationType)(nil) 6230 _ encoding.BinaryUnmarshaler = (*OperationType)(nil) 6231) 6232 6233// CreateAccountOp is an XDR Struct defines as: 6234// 6235// struct CreateAccountOp 6236// { 6237// AccountID destination; // account to create 6238// int64 startingBalance; // amount they end up with 6239// }; 6240// 6241type CreateAccountOp struct { 6242 Destination AccountId 6243 StartingBalance Int64 6244} 6245 6246// MarshalBinary implements encoding.BinaryMarshaler. 6247func (s CreateAccountOp) MarshalBinary() ([]byte, error) { 6248 b := new(bytes.Buffer) 6249 _, err := Marshal(b, s) 6250 return b.Bytes(), err 6251} 6252 6253// UnmarshalBinary implements encoding.BinaryUnmarshaler. 6254func (s *CreateAccountOp) UnmarshalBinary(inp []byte) error { 6255 _, err := Unmarshal(bytes.NewReader(inp), s) 6256 return err 6257} 6258 6259var ( 6260 _ encoding.BinaryMarshaler = (*CreateAccountOp)(nil) 6261 _ encoding.BinaryUnmarshaler = (*CreateAccountOp)(nil) 6262) 6263 6264// PaymentOp is an XDR Struct defines as: 6265// 6266// struct PaymentOp 6267// { 6268// AccountID destination; // recipient of the payment 6269// Asset asset; // what they end up with 6270// int64 amount; // amount they end up with 6271// }; 6272// 6273type PaymentOp struct { 6274 Destination AccountId 6275 Asset Asset 6276 Amount Int64 6277} 6278 6279// MarshalBinary implements encoding.BinaryMarshaler. 6280func (s PaymentOp) MarshalBinary() ([]byte, error) { 6281 b := new(bytes.Buffer) 6282 _, err := Marshal(b, s) 6283 return b.Bytes(), err 6284} 6285 6286// UnmarshalBinary implements encoding.BinaryUnmarshaler. 6287func (s *PaymentOp) UnmarshalBinary(inp []byte) error { 6288 _, err := Unmarshal(bytes.NewReader(inp), s) 6289 return err 6290} 6291 6292var ( 6293 _ encoding.BinaryMarshaler = (*PaymentOp)(nil) 6294 _ encoding.BinaryUnmarshaler = (*PaymentOp)(nil) 6295) 6296 6297// PathPaymentStrictReceiveOp is an XDR Struct defines as: 6298// 6299// struct PathPaymentStrictReceiveOp 6300// { 6301// Asset sendAsset; // asset we pay with 6302// int64 sendMax; // the maximum amount of sendAsset to 6303// // send (excluding fees). 6304// // The operation will fail if can't be met 6305// 6306// AccountID destination; // recipient of the payment 6307// Asset destAsset; // what they end up with 6308// int64 destAmount; // amount they end up with 6309// 6310// Asset path<5>; // additional hops it must go through to get there 6311// }; 6312// 6313type PathPaymentStrictReceiveOp struct { 6314 SendAsset Asset 6315 SendMax Int64 6316 Destination AccountId 6317 DestAsset Asset 6318 DestAmount Int64 6319 Path []Asset `xdrmaxsize:"5"` 6320} 6321 6322// MarshalBinary implements encoding.BinaryMarshaler. 6323func (s PathPaymentStrictReceiveOp) MarshalBinary() ([]byte, error) { 6324 b := new(bytes.Buffer) 6325 _, err := Marshal(b, s) 6326 return b.Bytes(), err 6327} 6328 6329// UnmarshalBinary implements encoding.BinaryUnmarshaler. 6330func (s *PathPaymentStrictReceiveOp) UnmarshalBinary(inp []byte) error { 6331 _, err := Unmarshal(bytes.NewReader(inp), s) 6332 return err 6333} 6334 6335var ( 6336 _ encoding.BinaryMarshaler = (*PathPaymentStrictReceiveOp)(nil) 6337 _ encoding.BinaryUnmarshaler = (*PathPaymentStrictReceiveOp)(nil) 6338) 6339 6340// PathPaymentStrictSendOp is an XDR Struct defines as: 6341// 6342// struct PathPaymentStrictSendOp 6343// { 6344// Asset sendAsset; // asset we pay with 6345// int64 sendAmount; // amount of sendAsset to send (excluding fees) 6346// 6347// AccountID destination; // recipient of the payment 6348// Asset destAsset; // what they end up with 6349// int64 destMin; // the minimum amount of dest asset to 6350// // be received 6351// // The operation will fail if it can't be met 6352// 6353// Asset path<5>; // additional hops it must go through to get there 6354// }; 6355// 6356type PathPaymentStrictSendOp struct { 6357 SendAsset Asset 6358 SendAmount Int64 6359 Destination AccountId 6360 DestAsset Asset 6361 DestMin Int64 6362 Path []Asset `xdrmaxsize:"5"` 6363} 6364 6365// MarshalBinary implements encoding.BinaryMarshaler. 6366func (s PathPaymentStrictSendOp) MarshalBinary() ([]byte, error) { 6367 b := new(bytes.Buffer) 6368 _, err := Marshal(b, s) 6369 return b.Bytes(), err 6370} 6371 6372// UnmarshalBinary implements encoding.BinaryUnmarshaler. 6373func (s *PathPaymentStrictSendOp) UnmarshalBinary(inp []byte) error { 6374 _, err := Unmarshal(bytes.NewReader(inp), s) 6375 return err 6376} 6377 6378var ( 6379 _ encoding.BinaryMarshaler = (*PathPaymentStrictSendOp)(nil) 6380 _ encoding.BinaryUnmarshaler = (*PathPaymentStrictSendOp)(nil) 6381) 6382 6383// ManageSellOfferOp is an XDR Struct defines as: 6384// 6385// struct ManageSellOfferOp 6386// { 6387// Asset selling; 6388// Asset buying; 6389// int64 amount; // amount being sold. if set to 0, delete the offer 6390// Price price; // price of thing being sold in terms of what you are buying 6391// 6392// // 0=create a new offer, otherwise edit an existing offer 6393// int64 offerID; 6394// }; 6395// 6396type ManageSellOfferOp struct { 6397 Selling Asset 6398 Buying Asset 6399 Amount Int64 6400 Price Price 6401 OfferId Int64 6402} 6403 6404// MarshalBinary implements encoding.BinaryMarshaler. 6405func (s ManageSellOfferOp) MarshalBinary() ([]byte, error) { 6406 b := new(bytes.Buffer) 6407 _, err := Marshal(b, s) 6408 return b.Bytes(), err 6409} 6410 6411// UnmarshalBinary implements encoding.BinaryUnmarshaler. 6412func (s *ManageSellOfferOp) UnmarshalBinary(inp []byte) error { 6413 _, err := Unmarshal(bytes.NewReader(inp), s) 6414 return err 6415} 6416 6417var ( 6418 _ encoding.BinaryMarshaler = (*ManageSellOfferOp)(nil) 6419 _ encoding.BinaryUnmarshaler = (*ManageSellOfferOp)(nil) 6420) 6421 6422// ManageBuyOfferOp is an XDR Struct defines as: 6423// 6424// struct ManageBuyOfferOp 6425// { 6426// Asset selling; 6427// Asset buying; 6428// int64 buyAmount; // amount being bought. if set to 0, delete the offer 6429// Price price; // price of thing being bought in terms of what you are 6430// // selling 6431// 6432// // 0=create a new offer, otherwise edit an existing offer 6433// int64 offerID; 6434// }; 6435// 6436type ManageBuyOfferOp struct { 6437 Selling Asset 6438 Buying Asset 6439 BuyAmount Int64 6440 Price Price 6441 OfferId Int64 6442} 6443 6444// MarshalBinary implements encoding.BinaryMarshaler. 6445func (s ManageBuyOfferOp) MarshalBinary() ([]byte, error) { 6446 b := new(bytes.Buffer) 6447 _, err := Marshal(b, s) 6448 return b.Bytes(), err 6449} 6450 6451// UnmarshalBinary implements encoding.BinaryUnmarshaler. 6452func (s *ManageBuyOfferOp) UnmarshalBinary(inp []byte) error { 6453 _, err := Unmarshal(bytes.NewReader(inp), s) 6454 return err 6455} 6456 6457var ( 6458 _ encoding.BinaryMarshaler = (*ManageBuyOfferOp)(nil) 6459 _ encoding.BinaryUnmarshaler = (*ManageBuyOfferOp)(nil) 6460) 6461 6462// CreatePassiveSellOfferOp is an XDR Struct defines as: 6463// 6464// struct CreatePassiveSellOfferOp 6465// { 6466// Asset selling; // A 6467// Asset buying; // B 6468// int64 amount; // amount taker gets. if set to 0, delete the offer 6469// Price price; // cost of A in terms of B 6470// }; 6471// 6472type CreatePassiveSellOfferOp struct { 6473 Selling Asset 6474 Buying Asset 6475 Amount Int64 6476 Price Price 6477} 6478 6479// MarshalBinary implements encoding.BinaryMarshaler. 6480func (s CreatePassiveSellOfferOp) MarshalBinary() ([]byte, error) { 6481 b := new(bytes.Buffer) 6482 _, err := Marshal(b, s) 6483 return b.Bytes(), err 6484} 6485 6486// UnmarshalBinary implements encoding.BinaryUnmarshaler. 6487func (s *CreatePassiveSellOfferOp) UnmarshalBinary(inp []byte) error { 6488 _, err := Unmarshal(bytes.NewReader(inp), s) 6489 return err 6490} 6491 6492var ( 6493 _ encoding.BinaryMarshaler = (*CreatePassiveSellOfferOp)(nil) 6494 _ encoding.BinaryUnmarshaler = (*CreatePassiveSellOfferOp)(nil) 6495) 6496 6497// SetOptionsOp is an XDR Struct defines as: 6498// 6499// struct SetOptionsOp 6500// { 6501// AccountID* inflationDest; // sets the inflation destination 6502// 6503// uint32* clearFlags; // which flags to clear 6504// uint32* setFlags; // which flags to set 6505// 6506// // account threshold manipulation 6507// uint32* masterWeight; // weight of the master account 6508// uint32* lowThreshold; 6509// uint32* medThreshold; 6510// uint32* highThreshold; 6511// 6512// string32* homeDomain; // sets the home domain 6513// 6514// // Add, update or remove a signer for the account 6515// // signer is deleted if the weight is 0 6516// Signer* signer; 6517// }; 6518// 6519type SetOptionsOp struct { 6520 InflationDest *AccountId 6521 ClearFlags *Uint32 6522 SetFlags *Uint32 6523 MasterWeight *Uint32 6524 LowThreshold *Uint32 6525 MedThreshold *Uint32 6526 HighThreshold *Uint32 6527 HomeDomain *String32 6528 Signer *Signer 6529} 6530 6531// MarshalBinary implements encoding.BinaryMarshaler. 6532func (s SetOptionsOp) MarshalBinary() ([]byte, error) { 6533 b := new(bytes.Buffer) 6534 _, err := Marshal(b, s) 6535 return b.Bytes(), err 6536} 6537 6538// UnmarshalBinary implements encoding.BinaryUnmarshaler. 6539func (s *SetOptionsOp) UnmarshalBinary(inp []byte) error { 6540 _, err := Unmarshal(bytes.NewReader(inp), s) 6541 return err 6542} 6543 6544var ( 6545 _ encoding.BinaryMarshaler = (*SetOptionsOp)(nil) 6546 _ encoding.BinaryUnmarshaler = (*SetOptionsOp)(nil) 6547) 6548 6549// ChangeTrustOp is an XDR Struct defines as: 6550// 6551// struct ChangeTrustOp 6552// { 6553// Asset line; 6554// 6555// // if limit is set to 0, deletes the trust line 6556// int64 limit; 6557// }; 6558// 6559type ChangeTrustOp struct { 6560 Line Asset 6561 Limit Int64 6562} 6563 6564// MarshalBinary implements encoding.BinaryMarshaler. 6565func (s ChangeTrustOp) MarshalBinary() ([]byte, error) { 6566 b := new(bytes.Buffer) 6567 _, err := Marshal(b, s) 6568 return b.Bytes(), err 6569} 6570 6571// UnmarshalBinary implements encoding.BinaryUnmarshaler. 6572func (s *ChangeTrustOp) UnmarshalBinary(inp []byte) error { 6573 _, err := Unmarshal(bytes.NewReader(inp), s) 6574 return err 6575} 6576 6577var ( 6578 _ encoding.BinaryMarshaler = (*ChangeTrustOp)(nil) 6579 _ encoding.BinaryUnmarshaler = (*ChangeTrustOp)(nil) 6580) 6581 6582// AllowTrustOpAsset is an XDR NestedUnion defines as: 6583// 6584// union switch (AssetType type) 6585// { 6586// // ASSET_TYPE_NATIVE is not allowed 6587// case ASSET_TYPE_CREDIT_ALPHANUM4: 6588// AssetCode4 assetCode4; 6589// 6590// case ASSET_TYPE_CREDIT_ALPHANUM12: 6591// AssetCode12 assetCode12; 6592// 6593// // add other asset types here in the future 6594// } 6595// 6596type AllowTrustOpAsset struct { 6597 Type AssetType 6598 AssetCode4 *AssetCode4 6599 AssetCode12 *AssetCode12 6600} 6601 6602// SwitchFieldName returns the field name in which this union's 6603// discriminant is stored 6604func (u AllowTrustOpAsset) SwitchFieldName() string { 6605 return "Type" 6606} 6607 6608// ArmForSwitch returns which field name should be used for storing 6609// the value for an instance of AllowTrustOpAsset 6610func (u AllowTrustOpAsset) ArmForSwitch(sw int32) (string, bool) { 6611 switch AssetType(sw) { 6612 case AssetTypeAssetTypeCreditAlphanum4: 6613 return "AssetCode4", true 6614 case AssetTypeAssetTypeCreditAlphanum12: 6615 return "AssetCode12", true 6616 } 6617 return "-", false 6618} 6619 6620// NewAllowTrustOpAsset creates a new AllowTrustOpAsset. 6621func NewAllowTrustOpAsset(aType AssetType, value interface{}) (result AllowTrustOpAsset, err error) { 6622 result.Type = aType 6623 switch AssetType(aType) { 6624 case AssetTypeAssetTypeCreditAlphanum4: 6625 tv, ok := value.(AssetCode4) 6626 if !ok { 6627 err = fmt.Errorf("invalid value, must be AssetCode4") 6628 return 6629 } 6630 result.AssetCode4 = &tv 6631 case AssetTypeAssetTypeCreditAlphanum12: 6632 tv, ok := value.(AssetCode12) 6633 if !ok { 6634 err = fmt.Errorf("invalid value, must be AssetCode12") 6635 return 6636 } 6637 result.AssetCode12 = &tv 6638 } 6639 return 6640} 6641 6642// MustAssetCode4 retrieves the AssetCode4 value from the union, 6643// panicing if the value is not set. 6644func (u AllowTrustOpAsset) MustAssetCode4() AssetCode4 { 6645 val, ok := u.GetAssetCode4() 6646 6647 if !ok { 6648 panic("arm AssetCode4 is not set") 6649 } 6650 6651 return val 6652} 6653 6654// GetAssetCode4 retrieves the AssetCode4 value from the union, 6655// returning ok if the union's switch indicated the value is valid. 6656func (u AllowTrustOpAsset) GetAssetCode4() (result AssetCode4, ok bool) { 6657 armName, _ := u.ArmForSwitch(int32(u.Type)) 6658 6659 if armName == "AssetCode4" { 6660 result = *u.AssetCode4 6661 ok = true 6662 } 6663 6664 return 6665} 6666 6667// MustAssetCode12 retrieves the AssetCode12 value from the union, 6668// panicing if the value is not set. 6669func (u AllowTrustOpAsset) MustAssetCode12() AssetCode12 { 6670 val, ok := u.GetAssetCode12() 6671 6672 if !ok { 6673 panic("arm AssetCode12 is not set") 6674 } 6675 6676 return val 6677} 6678 6679// GetAssetCode12 retrieves the AssetCode12 value from the union, 6680// returning ok if the union's switch indicated the value is valid. 6681func (u AllowTrustOpAsset) GetAssetCode12() (result AssetCode12, ok bool) { 6682 armName, _ := u.ArmForSwitch(int32(u.Type)) 6683 6684 if armName == "AssetCode12" { 6685 result = *u.AssetCode12 6686 ok = true 6687 } 6688 6689 return 6690} 6691 6692// MarshalBinary implements encoding.BinaryMarshaler. 6693func (s AllowTrustOpAsset) MarshalBinary() ([]byte, error) { 6694 b := new(bytes.Buffer) 6695 _, err := Marshal(b, s) 6696 return b.Bytes(), err 6697} 6698 6699// UnmarshalBinary implements encoding.BinaryUnmarshaler. 6700func (s *AllowTrustOpAsset) UnmarshalBinary(inp []byte) error { 6701 _, err := Unmarshal(bytes.NewReader(inp), s) 6702 return err 6703} 6704 6705var ( 6706 _ encoding.BinaryMarshaler = (*AllowTrustOpAsset)(nil) 6707 _ encoding.BinaryUnmarshaler = (*AllowTrustOpAsset)(nil) 6708) 6709 6710// AllowTrustOp is an XDR Struct defines as: 6711// 6712// struct AllowTrustOp 6713// { 6714// AccountID trustor; 6715// union switch (AssetType type) 6716// { 6717// // ASSET_TYPE_NATIVE is not allowed 6718// case ASSET_TYPE_CREDIT_ALPHANUM4: 6719// AssetCode4 assetCode4; 6720// 6721// case ASSET_TYPE_CREDIT_ALPHANUM12: 6722// AssetCode12 assetCode12; 6723// 6724// // add other asset types here in the future 6725// } 6726// asset; 6727// 6728// bool authorize; 6729// }; 6730// 6731type AllowTrustOp struct { 6732 Trustor AccountId 6733 Asset AllowTrustOpAsset 6734 Authorize bool 6735} 6736 6737// MarshalBinary implements encoding.BinaryMarshaler. 6738func (s AllowTrustOp) MarshalBinary() ([]byte, error) { 6739 b := new(bytes.Buffer) 6740 _, err := Marshal(b, s) 6741 return b.Bytes(), err 6742} 6743 6744// UnmarshalBinary implements encoding.BinaryUnmarshaler. 6745func (s *AllowTrustOp) UnmarshalBinary(inp []byte) error { 6746 _, err := Unmarshal(bytes.NewReader(inp), s) 6747 return err 6748} 6749 6750var ( 6751 _ encoding.BinaryMarshaler = (*AllowTrustOp)(nil) 6752 _ encoding.BinaryUnmarshaler = (*AllowTrustOp)(nil) 6753) 6754 6755// ManageDataOp is an XDR Struct defines as: 6756// 6757// struct ManageDataOp 6758// { 6759// string64 dataName; 6760// DataValue* dataValue; // set to null to clear 6761// }; 6762// 6763type ManageDataOp struct { 6764 DataName String64 6765 DataValue *DataValue 6766} 6767 6768// MarshalBinary implements encoding.BinaryMarshaler. 6769func (s ManageDataOp) MarshalBinary() ([]byte, error) { 6770 b := new(bytes.Buffer) 6771 _, err := Marshal(b, s) 6772 return b.Bytes(), err 6773} 6774 6775// UnmarshalBinary implements encoding.BinaryUnmarshaler. 6776func (s *ManageDataOp) UnmarshalBinary(inp []byte) error { 6777 _, err := Unmarshal(bytes.NewReader(inp), s) 6778 return err 6779} 6780 6781var ( 6782 _ encoding.BinaryMarshaler = (*ManageDataOp)(nil) 6783 _ encoding.BinaryUnmarshaler = (*ManageDataOp)(nil) 6784) 6785 6786// BumpSequenceOp is an XDR Struct defines as: 6787// 6788// struct BumpSequenceOp 6789// { 6790// SequenceNumber bumpTo; 6791// }; 6792// 6793type BumpSequenceOp struct { 6794 BumpTo SequenceNumber 6795} 6796 6797// MarshalBinary implements encoding.BinaryMarshaler. 6798func (s BumpSequenceOp) MarshalBinary() ([]byte, error) { 6799 b := new(bytes.Buffer) 6800 _, err := Marshal(b, s) 6801 return b.Bytes(), err 6802} 6803 6804// UnmarshalBinary implements encoding.BinaryUnmarshaler. 6805func (s *BumpSequenceOp) UnmarshalBinary(inp []byte) error { 6806 _, err := Unmarshal(bytes.NewReader(inp), s) 6807 return err 6808} 6809 6810var ( 6811 _ encoding.BinaryMarshaler = (*BumpSequenceOp)(nil) 6812 _ encoding.BinaryUnmarshaler = (*BumpSequenceOp)(nil) 6813) 6814 6815// OperationBody is an XDR NestedUnion defines as: 6816// 6817// union switch (OperationType type) 6818// { 6819// case CREATE_ACCOUNT: 6820// CreateAccountOp createAccountOp; 6821// case PAYMENT: 6822// PaymentOp paymentOp; 6823// case PATH_PAYMENT_STRICT_RECEIVE: 6824// PathPaymentStrictReceiveOp pathPaymentStrictReceiveOp; 6825// case MANAGE_SELL_OFFER: 6826// ManageSellOfferOp manageSellOfferOp; 6827// case CREATE_PASSIVE_SELL_OFFER: 6828// CreatePassiveSellOfferOp createPassiveSellOfferOp; 6829// case SET_OPTIONS: 6830// SetOptionsOp setOptionsOp; 6831// case CHANGE_TRUST: 6832// ChangeTrustOp changeTrustOp; 6833// case ALLOW_TRUST: 6834// AllowTrustOp allowTrustOp; 6835// case ACCOUNT_MERGE: 6836// AccountID destination; 6837// case INFLATION: 6838// void; 6839// case MANAGE_DATA: 6840// ManageDataOp manageDataOp; 6841// case BUMP_SEQUENCE: 6842// BumpSequenceOp bumpSequenceOp; 6843// case MANAGE_BUY_OFFER: 6844// ManageBuyOfferOp manageBuyOfferOp; 6845// case PATH_PAYMENT_STRICT_SEND: 6846// PathPaymentStrictSendOp pathPaymentStrictSendOp; 6847// } 6848// 6849type OperationBody struct { 6850 Type OperationType 6851 CreateAccountOp *CreateAccountOp 6852 PaymentOp *PaymentOp 6853 PathPaymentStrictReceiveOp *PathPaymentStrictReceiveOp 6854 ManageSellOfferOp *ManageSellOfferOp 6855 CreatePassiveSellOfferOp *CreatePassiveSellOfferOp 6856 SetOptionsOp *SetOptionsOp 6857 ChangeTrustOp *ChangeTrustOp 6858 AllowTrustOp *AllowTrustOp 6859 Destination *AccountId 6860 ManageDataOp *ManageDataOp 6861 BumpSequenceOp *BumpSequenceOp 6862 ManageBuyOfferOp *ManageBuyOfferOp 6863 PathPaymentStrictSendOp *PathPaymentStrictSendOp 6864} 6865 6866// SwitchFieldName returns the field name in which this union's 6867// discriminant is stored 6868func (u OperationBody) SwitchFieldName() string { 6869 return "Type" 6870} 6871 6872// ArmForSwitch returns which field name should be used for storing 6873// the value for an instance of OperationBody 6874func (u OperationBody) ArmForSwitch(sw int32) (string, bool) { 6875 switch OperationType(sw) { 6876 case OperationTypeCreateAccount: 6877 return "CreateAccountOp", true 6878 case OperationTypePayment: 6879 return "PaymentOp", true 6880 case OperationTypePathPaymentStrictReceive: 6881 return "PathPaymentStrictReceiveOp", true 6882 case OperationTypeManageSellOffer: 6883 return "ManageSellOfferOp", true 6884 case OperationTypeCreatePassiveSellOffer: 6885 return "CreatePassiveSellOfferOp", true 6886 case OperationTypeSetOptions: 6887 return "SetOptionsOp", true 6888 case OperationTypeChangeTrust: 6889 return "ChangeTrustOp", true 6890 case OperationTypeAllowTrust: 6891 return "AllowTrustOp", true 6892 case OperationTypeAccountMerge: 6893 return "Destination", true 6894 case OperationTypeInflation: 6895 return "", true 6896 case OperationTypeManageData: 6897 return "ManageDataOp", true 6898 case OperationTypeBumpSequence: 6899 return "BumpSequenceOp", true 6900 case OperationTypeManageBuyOffer: 6901 return "ManageBuyOfferOp", true 6902 case OperationTypePathPaymentStrictSend: 6903 return "PathPaymentStrictSendOp", true 6904 } 6905 return "-", false 6906} 6907 6908// NewOperationBody creates a new OperationBody. 6909func NewOperationBody(aType OperationType, value interface{}) (result OperationBody, err error) { 6910 result.Type = aType 6911 switch OperationType(aType) { 6912 case OperationTypeCreateAccount: 6913 tv, ok := value.(CreateAccountOp) 6914 if !ok { 6915 err = fmt.Errorf("invalid value, must be CreateAccountOp") 6916 return 6917 } 6918 result.CreateAccountOp = &tv 6919 case OperationTypePayment: 6920 tv, ok := value.(PaymentOp) 6921 if !ok { 6922 err = fmt.Errorf("invalid value, must be PaymentOp") 6923 return 6924 } 6925 result.PaymentOp = &tv 6926 case OperationTypePathPaymentStrictReceive: 6927 tv, ok := value.(PathPaymentStrictReceiveOp) 6928 if !ok { 6929 err = fmt.Errorf("invalid value, must be PathPaymentStrictReceiveOp") 6930 return 6931 } 6932 result.PathPaymentStrictReceiveOp = &tv 6933 case OperationTypeManageSellOffer: 6934 tv, ok := value.(ManageSellOfferOp) 6935 if !ok { 6936 err = fmt.Errorf("invalid value, must be ManageSellOfferOp") 6937 return 6938 } 6939 result.ManageSellOfferOp = &tv 6940 case OperationTypeCreatePassiveSellOffer: 6941 tv, ok := value.(CreatePassiveSellOfferOp) 6942 if !ok { 6943 err = fmt.Errorf("invalid value, must be CreatePassiveSellOfferOp") 6944 return 6945 } 6946 result.CreatePassiveSellOfferOp = &tv 6947 case OperationTypeSetOptions: 6948 tv, ok := value.(SetOptionsOp) 6949 if !ok { 6950 err = fmt.Errorf("invalid value, must be SetOptionsOp") 6951 return 6952 } 6953 result.SetOptionsOp = &tv 6954 case OperationTypeChangeTrust: 6955 tv, ok := value.(ChangeTrustOp) 6956 if !ok { 6957 err = fmt.Errorf("invalid value, must be ChangeTrustOp") 6958 return 6959 } 6960 result.ChangeTrustOp = &tv 6961 case OperationTypeAllowTrust: 6962 tv, ok := value.(AllowTrustOp) 6963 if !ok { 6964 err = fmt.Errorf("invalid value, must be AllowTrustOp") 6965 return 6966 } 6967 result.AllowTrustOp = &tv 6968 case OperationTypeAccountMerge: 6969 tv, ok := value.(AccountId) 6970 if !ok { 6971 err = fmt.Errorf("invalid value, must be AccountId") 6972 return 6973 } 6974 result.Destination = &tv 6975 case OperationTypeInflation: 6976 // void 6977 case OperationTypeManageData: 6978 tv, ok := value.(ManageDataOp) 6979 if !ok { 6980 err = fmt.Errorf("invalid value, must be ManageDataOp") 6981 return 6982 } 6983 result.ManageDataOp = &tv 6984 case OperationTypeBumpSequence: 6985 tv, ok := value.(BumpSequenceOp) 6986 if !ok { 6987 err = fmt.Errorf("invalid value, must be BumpSequenceOp") 6988 return 6989 } 6990 result.BumpSequenceOp = &tv 6991 case OperationTypeManageBuyOffer: 6992 tv, ok := value.(ManageBuyOfferOp) 6993 if !ok { 6994 err = fmt.Errorf("invalid value, must be ManageBuyOfferOp") 6995 return 6996 } 6997 result.ManageBuyOfferOp = &tv 6998 case OperationTypePathPaymentStrictSend: 6999 tv, ok := value.(PathPaymentStrictSendOp) 7000 if !ok { 7001 err = fmt.Errorf("invalid value, must be PathPaymentStrictSendOp") 7002 return 7003 } 7004 result.PathPaymentStrictSendOp = &tv 7005 } 7006 return 7007} 7008 7009// MustCreateAccountOp retrieves the CreateAccountOp value from the union, 7010// panicing if the value is not set. 7011func (u OperationBody) MustCreateAccountOp() CreateAccountOp { 7012 val, ok := u.GetCreateAccountOp() 7013 7014 if !ok { 7015 panic("arm CreateAccountOp is not set") 7016 } 7017 7018 return val 7019} 7020 7021// GetCreateAccountOp retrieves the CreateAccountOp value from the union, 7022// returning ok if the union's switch indicated the value is valid. 7023func (u OperationBody) GetCreateAccountOp() (result CreateAccountOp, ok bool) { 7024 armName, _ := u.ArmForSwitch(int32(u.Type)) 7025 7026 if armName == "CreateAccountOp" { 7027 result = *u.CreateAccountOp 7028 ok = true 7029 } 7030 7031 return 7032} 7033 7034// MustPaymentOp retrieves the PaymentOp value from the union, 7035// panicing if the value is not set. 7036func (u OperationBody) MustPaymentOp() PaymentOp { 7037 val, ok := u.GetPaymentOp() 7038 7039 if !ok { 7040 panic("arm PaymentOp is not set") 7041 } 7042 7043 return val 7044} 7045 7046// GetPaymentOp retrieves the PaymentOp value from the union, 7047// returning ok if the union's switch indicated the value is valid. 7048func (u OperationBody) GetPaymentOp() (result PaymentOp, ok bool) { 7049 armName, _ := u.ArmForSwitch(int32(u.Type)) 7050 7051 if armName == "PaymentOp" { 7052 result = *u.PaymentOp 7053 ok = true 7054 } 7055 7056 return 7057} 7058 7059// MustPathPaymentStrictReceiveOp retrieves the PathPaymentStrictReceiveOp value from the union, 7060// panicing if the value is not set. 7061func (u OperationBody) MustPathPaymentStrictReceiveOp() PathPaymentStrictReceiveOp { 7062 val, ok := u.GetPathPaymentStrictReceiveOp() 7063 7064 if !ok { 7065 panic("arm PathPaymentStrictReceiveOp is not set") 7066 } 7067 7068 return val 7069} 7070 7071// GetPathPaymentStrictReceiveOp retrieves the PathPaymentStrictReceiveOp value from the union, 7072// returning ok if the union's switch indicated the value is valid. 7073func (u OperationBody) GetPathPaymentStrictReceiveOp() (result PathPaymentStrictReceiveOp, ok bool) { 7074 armName, _ := u.ArmForSwitch(int32(u.Type)) 7075 7076 if armName == "PathPaymentStrictReceiveOp" { 7077 result = *u.PathPaymentStrictReceiveOp 7078 ok = true 7079 } 7080 7081 return 7082} 7083 7084// MustManageSellOfferOp retrieves the ManageSellOfferOp value from the union, 7085// panicing if the value is not set. 7086func (u OperationBody) MustManageSellOfferOp() ManageSellOfferOp { 7087 val, ok := u.GetManageSellOfferOp() 7088 7089 if !ok { 7090 panic("arm ManageSellOfferOp is not set") 7091 } 7092 7093 return val 7094} 7095 7096// GetManageSellOfferOp retrieves the ManageSellOfferOp value from the union, 7097// returning ok if the union's switch indicated the value is valid. 7098func (u OperationBody) GetManageSellOfferOp() (result ManageSellOfferOp, ok bool) { 7099 armName, _ := u.ArmForSwitch(int32(u.Type)) 7100 7101 if armName == "ManageSellOfferOp" { 7102 result = *u.ManageSellOfferOp 7103 ok = true 7104 } 7105 7106 return 7107} 7108 7109// MustCreatePassiveSellOfferOp retrieves the CreatePassiveSellOfferOp value from the union, 7110// panicing if the value is not set. 7111func (u OperationBody) MustCreatePassiveSellOfferOp() CreatePassiveSellOfferOp { 7112 val, ok := u.GetCreatePassiveSellOfferOp() 7113 7114 if !ok { 7115 panic("arm CreatePassiveSellOfferOp is not set") 7116 } 7117 7118 return val 7119} 7120 7121// GetCreatePassiveSellOfferOp retrieves the CreatePassiveSellOfferOp value from the union, 7122// returning ok if the union's switch indicated the value is valid. 7123func (u OperationBody) GetCreatePassiveSellOfferOp() (result CreatePassiveSellOfferOp, ok bool) { 7124 armName, _ := u.ArmForSwitch(int32(u.Type)) 7125 7126 if armName == "CreatePassiveSellOfferOp" { 7127 result = *u.CreatePassiveSellOfferOp 7128 ok = true 7129 } 7130 7131 return 7132} 7133 7134// MustSetOptionsOp retrieves the SetOptionsOp value from the union, 7135// panicing if the value is not set. 7136func (u OperationBody) MustSetOptionsOp() SetOptionsOp { 7137 val, ok := u.GetSetOptionsOp() 7138 7139 if !ok { 7140 panic("arm SetOptionsOp is not set") 7141 } 7142 7143 return val 7144} 7145 7146// GetSetOptionsOp retrieves the SetOptionsOp value from the union, 7147// returning ok if the union's switch indicated the value is valid. 7148func (u OperationBody) GetSetOptionsOp() (result SetOptionsOp, ok bool) { 7149 armName, _ := u.ArmForSwitch(int32(u.Type)) 7150 7151 if armName == "SetOptionsOp" { 7152 result = *u.SetOptionsOp 7153 ok = true 7154 } 7155 7156 return 7157} 7158 7159// MustChangeTrustOp retrieves the ChangeTrustOp value from the union, 7160// panicing if the value is not set. 7161func (u OperationBody) MustChangeTrustOp() ChangeTrustOp { 7162 val, ok := u.GetChangeTrustOp() 7163 7164 if !ok { 7165 panic("arm ChangeTrustOp is not set") 7166 } 7167 7168 return val 7169} 7170 7171// GetChangeTrustOp retrieves the ChangeTrustOp value from the union, 7172// returning ok if the union's switch indicated the value is valid. 7173func (u OperationBody) GetChangeTrustOp() (result ChangeTrustOp, ok bool) { 7174 armName, _ := u.ArmForSwitch(int32(u.Type)) 7175 7176 if armName == "ChangeTrustOp" { 7177 result = *u.ChangeTrustOp 7178 ok = true 7179 } 7180 7181 return 7182} 7183 7184// MustAllowTrustOp retrieves the AllowTrustOp value from the union, 7185// panicing if the value is not set. 7186func (u OperationBody) MustAllowTrustOp() AllowTrustOp { 7187 val, ok := u.GetAllowTrustOp() 7188 7189 if !ok { 7190 panic("arm AllowTrustOp is not set") 7191 } 7192 7193 return val 7194} 7195 7196// GetAllowTrustOp retrieves the AllowTrustOp value from the union, 7197// returning ok if the union's switch indicated the value is valid. 7198func (u OperationBody) GetAllowTrustOp() (result AllowTrustOp, ok bool) { 7199 armName, _ := u.ArmForSwitch(int32(u.Type)) 7200 7201 if armName == "AllowTrustOp" { 7202 result = *u.AllowTrustOp 7203 ok = true 7204 } 7205 7206 return 7207} 7208 7209// MustDestination retrieves the Destination value from the union, 7210// panicing if the value is not set. 7211func (u OperationBody) MustDestination() AccountId { 7212 val, ok := u.GetDestination() 7213 7214 if !ok { 7215 panic("arm Destination is not set") 7216 } 7217 7218 return val 7219} 7220 7221// GetDestination retrieves the Destination value from the union, 7222// returning ok if the union's switch indicated the value is valid. 7223func (u OperationBody) GetDestination() (result AccountId, ok bool) { 7224 armName, _ := u.ArmForSwitch(int32(u.Type)) 7225 7226 if armName == "Destination" { 7227 result = *u.Destination 7228 ok = true 7229 } 7230 7231 return 7232} 7233 7234// MustManageDataOp retrieves the ManageDataOp value from the union, 7235// panicing if the value is not set. 7236func (u OperationBody) MustManageDataOp() ManageDataOp { 7237 val, ok := u.GetManageDataOp() 7238 7239 if !ok { 7240 panic("arm ManageDataOp is not set") 7241 } 7242 7243 return val 7244} 7245 7246// GetManageDataOp retrieves the ManageDataOp value from the union, 7247// returning ok if the union's switch indicated the value is valid. 7248func (u OperationBody) GetManageDataOp() (result ManageDataOp, ok bool) { 7249 armName, _ := u.ArmForSwitch(int32(u.Type)) 7250 7251 if armName == "ManageDataOp" { 7252 result = *u.ManageDataOp 7253 ok = true 7254 } 7255 7256 return 7257} 7258 7259// MustBumpSequenceOp retrieves the BumpSequenceOp value from the union, 7260// panicing if the value is not set. 7261func (u OperationBody) MustBumpSequenceOp() BumpSequenceOp { 7262 val, ok := u.GetBumpSequenceOp() 7263 7264 if !ok { 7265 panic("arm BumpSequenceOp is not set") 7266 } 7267 7268 return val 7269} 7270 7271// GetBumpSequenceOp retrieves the BumpSequenceOp value from the union, 7272// returning ok if the union's switch indicated the value is valid. 7273func (u OperationBody) GetBumpSequenceOp() (result BumpSequenceOp, ok bool) { 7274 armName, _ := u.ArmForSwitch(int32(u.Type)) 7275 7276 if armName == "BumpSequenceOp" { 7277 result = *u.BumpSequenceOp 7278 ok = true 7279 } 7280 7281 return 7282} 7283 7284// MustManageBuyOfferOp retrieves the ManageBuyOfferOp value from the union, 7285// panicing if the value is not set. 7286func (u OperationBody) MustManageBuyOfferOp() ManageBuyOfferOp { 7287 val, ok := u.GetManageBuyOfferOp() 7288 7289 if !ok { 7290 panic("arm ManageBuyOfferOp is not set") 7291 } 7292 7293 return val 7294} 7295 7296// GetManageBuyOfferOp retrieves the ManageBuyOfferOp value from the union, 7297// returning ok if the union's switch indicated the value is valid. 7298func (u OperationBody) GetManageBuyOfferOp() (result ManageBuyOfferOp, ok bool) { 7299 armName, _ := u.ArmForSwitch(int32(u.Type)) 7300 7301 if armName == "ManageBuyOfferOp" { 7302 result = *u.ManageBuyOfferOp 7303 ok = true 7304 } 7305 7306 return 7307} 7308 7309// MustPathPaymentStrictSendOp retrieves the PathPaymentStrictSendOp value from the union, 7310// panicing if the value is not set. 7311func (u OperationBody) MustPathPaymentStrictSendOp() PathPaymentStrictSendOp { 7312 val, ok := u.GetPathPaymentStrictSendOp() 7313 7314 if !ok { 7315 panic("arm PathPaymentStrictSendOp is not set") 7316 } 7317 7318 return val 7319} 7320 7321// GetPathPaymentStrictSendOp retrieves the PathPaymentStrictSendOp value from the union, 7322// returning ok if the union's switch indicated the value is valid. 7323func (u OperationBody) GetPathPaymentStrictSendOp() (result PathPaymentStrictSendOp, ok bool) { 7324 armName, _ := u.ArmForSwitch(int32(u.Type)) 7325 7326 if armName == "PathPaymentStrictSendOp" { 7327 result = *u.PathPaymentStrictSendOp 7328 ok = true 7329 } 7330 7331 return 7332} 7333 7334// MarshalBinary implements encoding.BinaryMarshaler. 7335func (s OperationBody) MarshalBinary() ([]byte, error) { 7336 b := new(bytes.Buffer) 7337 _, err := Marshal(b, s) 7338 return b.Bytes(), err 7339} 7340 7341// UnmarshalBinary implements encoding.BinaryUnmarshaler. 7342func (s *OperationBody) UnmarshalBinary(inp []byte) error { 7343 _, err := Unmarshal(bytes.NewReader(inp), s) 7344 return err 7345} 7346 7347var ( 7348 _ encoding.BinaryMarshaler = (*OperationBody)(nil) 7349 _ encoding.BinaryUnmarshaler = (*OperationBody)(nil) 7350) 7351 7352// Operation is an XDR Struct defines as: 7353// 7354// struct Operation 7355// { 7356// // sourceAccount is the account used to run the operation 7357// // if not set, the runtime defaults to "sourceAccount" specified at 7358// // the transaction level 7359// AccountID* sourceAccount; 7360// 7361// union switch (OperationType type) 7362// { 7363// case CREATE_ACCOUNT: 7364// CreateAccountOp createAccountOp; 7365// case PAYMENT: 7366// PaymentOp paymentOp; 7367// case PATH_PAYMENT_STRICT_RECEIVE: 7368// PathPaymentStrictReceiveOp pathPaymentStrictReceiveOp; 7369// case MANAGE_SELL_OFFER: 7370// ManageSellOfferOp manageSellOfferOp; 7371// case CREATE_PASSIVE_SELL_OFFER: 7372// CreatePassiveSellOfferOp createPassiveSellOfferOp; 7373// case SET_OPTIONS: 7374// SetOptionsOp setOptionsOp; 7375// case CHANGE_TRUST: 7376// ChangeTrustOp changeTrustOp; 7377// case ALLOW_TRUST: 7378// AllowTrustOp allowTrustOp; 7379// case ACCOUNT_MERGE: 7380// AccountID destination; 7381// case INFLATION: 7382// void; 7383// case MANAGE_DATA: 7384// ManageDataOp manageDataOp; 7385// case BUMP_SEQUENCE: 7386// BumpSequenceOp bumpSequenceOp; 7387// case MANAGE_BUY_OFFER: 7388// ManageBuyOfferOp manageBuyOfferOp; 7389// case PATH_PAYMENT_STRICT_SEND: 7390// PathPaymentStrictSendOp pathPaymentStrictSendOp; 7391// } 7392// body; 7393// }; 7394// 7395type Operation struct { 7396 SourceAccount *AccountId 7397 Body OperationBody 7398} 7399 7400// MarshalBinary implements encoding.BinaryMarshaler. 7401func (s Operation) MarshalBinary() ([]byte, error) { 7402 b := new(bytes.Buffer) 7403 _, err := Marshal(b, s) 7404 return b.Bytes(), err 7405} 7406 7407// UnmarshalBinary implements encoding.BinaryUnmarshaler. 7408func (s *Operation) UnmarshalBinary(inp []byte) error { 7409 _, err := Unmarshal(bytes.NewReader(inp), s) 7410 return err 7411} 7412 7413var ( 7414 _ encoding.BinaryMarshaler = (*Operation)(nil) 7415 _ encoding.BinaryUnmarshaler = (*Operation)(nil) 7416) 7417 7418// MemoType is an XDR Enum defines as: 7419// 7420// enum MemoType 7421// { 7422// MEMO_NONE = 0, 7423// MEMO_TEXT = 1, 7424// MEMO_ID = 2, 7425// MEMO_HASH = 3, 7426// MEMO_RETURN = 4 7427// }; 7428// 7429type MemoType int32 7430 7431const ( 7432 MemoTypeMemoNone MemoType = 0 7433 MemoTypeMemoText MemoType = 1 7434 MemoTypeMemoId MemoType = 2 7435 MemoTypeMemoHash MemoType = 3 7436 MemoTypeMemoReturn MemoType = 4 7437) 7438 7439var memoTypeMap = map[int32]string{ 7440 0: "MemoTypeMemoNone", 7441 1: "MemoTypeMemoText", 7442 2: "MemoTypeMemoId", 7443 3: "MemoTypeMemoHash", 7444 4: "MemoTypeMemoReturn", 7445} 7446 7447// ValidEnum validates a proposed value for this enum. Implements 7448// the Enum interface for MemoType 7449func (e MemoType) ValidEnum(v int32) bool { 7450 _, ok := memoTypeMap[v] 7451 return ok 7452} 7453 7454// String returns the name of `e` 7455func (e MemoType) String() string { 7456 name, _ := memoTypeMap[int32(e)] 7457 return name 7458} 7459 7460// MarshalBinary implements encoding.BinaryMarshaler. 7461func (s MemoType) MarshalBinary() ([]byte, error) { 7462 b := new(bytes.Buffer) 7463 _, err := Marshal(b, s) 7464 return b.Bytes(), err 7465} 7466 7467// UnmarshalBinary implements encoding.BinaryUnmarshaler. 7468func (s *MemoType) UnmarshalBinary(inp []byte) error { 7469 _, err := Unmarshal(bytes.NewReader(inp), s) 7470 return err 7471} 7472 7473var ( 7474 _ encoding.BinaryMarshaler = (*MemoType)(nil) 7475 _ encoding.BinaryUnmarshaler = (*MemoType)(nil) 7476) 7477 7478// Memo is an XDR Union defines as: 7479// 7480// union Memo switch (MemoType type) 7481// { 7482// case MEMO_NONE: 7483// void; 7484// case MEMO_TEXT: 7485// string text<28>; 7486// case MEMO_ID: 7487// uint64 id; 7488// case MEMO_HASH: 7489// Hash hash; // the hash of what to pull from the content server 7490// case MEMO_RETURN: 7491// Hash retHash; // the hash of the tx you are rejecting 7492// }; 7493// 7494type Memo struct { 7495 Type MemoType 7496 Text *string `xdrmaxsize:"28"` 7497 Id *Uint64 7498 Hash *Hash 7499 RetHash *Hash 7500} 7501 7502// SwitchFieldName returns the field name in which this union's 7503// discriminant is stored 7504func (u Memo) SwitchFieldName() string { 7505 return "Type" 7506} 7507 7508// ArmForSwitch returns which field name should be used for storing 7509// the value for an instance of Memo 7510func (u Memo) ArmForSwitch(sw int32) (string, bool) { 7511 switch MemoType(sw) { 7512 case MemoTypeMemoNone: 7513 return "", true 7514 case MemoTypeMemoText: 7515 return "Text", true 7516 case MemoTypeMemoId: 7517 return "Id", true 7518 case MemoTypeMemoHash: 7519 return "Hash", true 7520 case MemoTypeMemoReturn: 7521 return "RetHash", true 7522 } 7523 return "-", false 7524} 7525 7526// NewMemo creates a new Memo. 7527func NewMemo(aType MemoType, value interface{}) (result Memo, err error) { 7528 result.Type = aType 7529 switch MemoType(aType) { 7530 case MemoTypeMemoNone: 7531 // void 7532 case MemoTypeMemoText: 7533 tv, ok := value.(string) 7534 if !ok { 7535 err = fmt.Errorf("invalid value, must be string") 7536 return 7537 } 7538 result.Text = &tv 7539 case MemoTypeMemoId: 7540 tv, ok := value.(Uint64) 7541 if !ok { 7542 err = fmt.Errorf("invalid value, must be Uint64") 7543 return 7544 } 7545 result.Id = &tv 7546 case MemoTypeMemoHash: 7547 tv, ok := value.(Hash) 7548 if !ok { 7549 err = fmt.Errorf("invalid value, must be Hash") 7550 return 7551 } 7552 result.Hash = &tv 7553 case MemoTypeMemoReturn: 7554 tv, ok := value.(Hash) 7555 if !ok { 7556 err = fmt.Errorf("invalid value, must be Hash") 7557 return 7558 } 7559 result.RetHash = &tv 7560 } 7561 return 7562} 7563 7564// MustText retrieves the Text value from the union, 7565// panicing if the value is not set. 7566func (u Memo) MustText() string { 7567 val, ok := u.GetText() 7568 7569 if !ok { 7570 panic("arm Text is not set") 7571 } 7572 7573 return val 7574} 7575 7576// GetText retrieves the Text value from the union, 7577// returning ok if the union's switch indicated the value is valid. 7578func (u Memo) GetText() (result string, ok bool) { 7579 armName, _ := u.ArmForSwitch(int32(u.Type)) 7580 7581 if armName == "Text" { 7582 result = *u.Text 7583 ok = true 7584 } 7585 7586 return 7587} 7588 7589// MustId retrieves the Id value from the union, 7590// panicing if the value is not set. 7591func (u Memo) MustId() Uint64 { 7592 val, ok := u.GetId() 7593 7594 if !ok { 7595 panic("arm Id is not set") 7596 } 7597 7598 return val 7599} 7600 7601// GetId retrieves the Id value from the union, 7602// returning ok if the union's switch indicated the value is valid. 7603func (u Memo) GetId() (result Uint64, ok bool) { 7604 armName, _ := u.ArmForSwitch(int32(u.Type)) 7605 7606 if armName == "Id" { 7607 result = *u.Id 7608 ok = true 7609 } 7610 7611 return 7612} 7613 7614// MustHash retrieves the Hash value from the union, 7615// panicing if the value is not set. 7616func (u Memo) MustHash() Hash { 7617 val, ok := u.GetHash() 7618 7619 if !ok { 7620 panic("arm Hash is not set") 7621 } 7622 7623 return val 7624} 7625 7626// GetHash retrieves the Hash value from the union, 7627// returning ok if the union's switch indicated the value is valid. 7628func (u Memo) GetHash() (result Hash, ok bool) { 7629 armName, _ := u.ArmForSwitch(int32(u.Type)) 7630 7631 if armName == "Hash" { 7632 result = *u.Hash 7633 ok = true 7634 } 7635 7636 return 7637} 7638 7639// MustRetHash retrieves the RetHash value from the union, 7640// panicing if the value is not set. 7641func (u Memo) MustRetHash() Hash { 7642 val, ok := u.GetRetHash() 7643 7644 if !ok { 7645 panic("arm RetHash is not set") 7646 } 7647 7648 return val 7649} 7650 7651// GetRetHash retrieves the RetHash value from the union, 7652// returning ok if the union's switch indicated the value is valid. 7653func (u Memo) GetRetHash() (result Hash, ok bool) { 7654 armName, _ := u.ArmForSwitch(int32(u.Type)) 7655 7656 if armName == "RetHash" { 7657 result = *u.RetHash 7658 ok = true 7659 } 7660 7661 return 7662} 7663 7664// MarshalBinary implements encoding.BinaryMarshaler. 7665func (s Memo) MarshalBinary() ([]byte, error) { 7666 b := new(bytes.Buffer) 7667 _, err := Marshal(b, s) 7668 return b.Bytes(), err 7669} 7670 7671// UnmarshalBinary implements encoding.BinaryUnmarshaler. 7672func (s *Memo) UnmarshalBinary(inp []byte) error { 7673 _, err := Unmarshal(bytes.NewReader(inp), s) 7674 return err 7675} 7676 7677var ( 7678 _ encoding.BinaryMarshaler = (*Memo)(nil) 7679 _ encoding.BinaryUnmarshaler = (*Memo)(nil) 7680) 7681 7682// TimeBounds is an XDR Struct defines as: 7683// 7684// struct TimeBounds 7685// { 7686// TimePoint minTime; 7687// TimePoint maxTime; // 0 here means no maxTime 7688// }; 7689// 7690type TimeBounds struct { 7691 MinTime TimePoint 7692 MaxTime TimePoint 7693} 7694 7695// MarshalBinary implements encoding.BinaryMarshaler. 7696func (s TimeBounds) MarshalBinary() ([]byte, error) { 7697 b := new(bytes.Buffer) 7698 _, err := Marshal(b, s) 7699 return b.Bytes(), err 7700} 7701 7702// UnmarshalBinary implements encoding.BinaryUnmarshaler. 7703func (s *TimeBounds) UnmarshalBinary(inp []byte) error { 7704 _, err := Unmarshal(bytes.NewReader(inp), s) 7705 return err 7706} 7707 7708var ( 7709 _ encoding.BinaryMarshaler = (*TimeBounds)(nil) 7710 _ encoding.BinaryUnmarshaler = (*TimeBounds)(nil) 7711) 7712 7713// MaxOpsPerTx is an XDR Const defines as: 7714// 7715// const MAX_OPS_PER_TX = 100; 7716// 7717const MaxOpsPerTx = 100 7718 7719// TransactionExt is an XDR NestedUnion defines as: 7720// 7721// union switch (int v) 7722// { 7723// case 0: 7724// void; 7725// } 7726// 7727type TransactionExt struct { 7728 V int32 7729} 7730 7731// SwitchFieldName returns the field name in which this union's 7732// discriminant is stored 7733func (u TransactionExt) SwitchFieldName() string { 7734 return "V" 7735} 7736 7737// ArmForSwitch returns which field name should be used for storing 7738// the value for an instance of TransactionExt 7739func (u TransactionExt) ArmForSwitch(sw int32) (string, bool) { 7740 switch int32(sw) { 7741 case 0: 7742 return "", true 7743 } 7744 return "-", false 7745} 7746 7747// NewTransactionExt creates a new TransactionExt. 7748func NewTransactionExt(v int32, value interface{}) (result TransactionExt, err error) { 7749 result.V = v 7750 switch int32(v) { 7751 case 0: 7752 // void 7753 } 7754 return 7755} 7756 7757// MarshalBinary implements encoding.BinaryMarshaler. 7758func (s TransactionExt) MarshalBinary() ([]byte, error) { 7759 b := new(bytes.Buffer) 7760 _, err := Marshal(b, s) 7761 return b.Bytes(), err 7762} 7763 7764// UnmarshalBinary implements encoding.BinaryUnmarshaler. 7765func (s *TransactionExt) UnmarshalBinary(inp []byte) error { 7766 _, err := Unmarshal(bytes.NewReader(inp), s) 7767 return err 7768} 7769 7770var ( 7771 _ encoding.BinaryMarshaler = (*TransactionExt)(nil) 7772 _ encoding.BinaryUnmarshaler = (*TransactionExt)(nil) 7773) 7774 7775// Transaction is an XDR Struct defines as: 7776// 7777// struct Transaction 7778// { 7779// // account used to run the transaction 7780// AccountID sourceAccount; 7781// 7782// // the fee the sourceAccount will pay 7783// uint32 fee; 7784// 7785// // sequence number to consume in the account 7786// SequenceNumber seqNum; 7787// 7788// // validity range (inclusive) for the last ledger close time 7789// TimeBounds* timeBounds; 7790// 7791// Memo memo; 7792// 7793// Operation operations<MAX_OPS_PER_TX>; 7794// 7795// // reserved for future use 7796// union switch (int v) 7797// { 7798// case 0: 7799// void; 7800// } 7801// ext; 7802// }; 7803// 7804type Transaction struct { 7805 SourceAccount AccountId 7806 Fee Uint32 7807 SeqNum SequenceNumber 7808 TimeBounds *TimeBounds 7809 Memo Memo 7810 Operations []Operation `xdrmaxsize:"100"` 7811 Ext TransactionExt 7812} 7813 7814// MarshalBinary implements encoding.BinaryMarshaler. 7815func (s Transaction) MarshalBinary() ([]byte, error) { 7816 b := new(bytes.Buffer) 7817 _, err := Marshal(b, s) 7818 return b.Bytes(), err 7819} 7820 7821// UnmarshalBinary implements encoding.BinaryUnmarshaler. 7822func (s *Transaction) UnmarshalBinary(inp []byte) error { 7823 _, err := Unmarshal(bytes.NewReader(inp), s) 7824 return err 7825} 7826 7827var ( 7828 _ encoding.BinaryMarshaler = (*Transaction)(nil) 7829 _ encoding.BinaryUnmarshaler = (*Transaction)(nil) 7830) 7831 7832// TransactionSignaturePayloadTaggedTransaction is an XDR NestedUnion defines as: 7833// 7834// union switch (EnvelopeType type) 7835// { 7836// case ENVELOPE_TYPE_TX: 7837// Transaction tx; 7838// /* All other values of type are invalid */ 7839// } 7840// 7841type TransactionSignaturePayloadTaggedTransaction struct { 7842 Type EnvelopeType 7843 Tx *Transaction 7844} 7845 7846// SwitchFieldName returns the field name in which this union's 7847// discriminant is stored 7848func (u TransactionSignaturePayloadTaggedTransaction) SwitchFieldName() string { 7849 return "Type" 7850} 7851 7852// ArmForSwitch returns which field name should be used for storing 7853// the value for an instance of TransactionSignaturePayloadTaggedTransaction 7854func (u TransactionSignaturePayloadTaggedTransaction) ArmForSwitch(sw int32) (string, bool) { 7855 switch EnvelopeType(sw) { 7856 case EnvelopeTypeEnvelopeTypeTx: 7857 return "Tx", true 7858 } 7859 return "-", false 7860} 7861 7862// NewTransactionSignaturePayloadTaggedTransaction creates a new TransactionSignaturePayloadTaggedTransaction. 7863func NewTransactionSignaturePayloadTaggedTransaction(aType EnvelopeType, value interface{}) (result TransactionSignaturePayloadTaggedTransaction, err error) { 7864 result.Type = aType 7865 switch EnvelopeType(aType) { 7866 case EnvelopeTypeEnvelopeTypeTx: 7867 tv, ok := value.(Transaction) 7868 if !ok { 7869 err = fmt.Errorf("invalid value, must be Transaction") 7870 return 7871 } 7872 result.Tx = &tv 7873 } 7874 return 7875} 7876 7877// MustTx retrieves the Tx value from the union, 7878// panicing if the value is not set. 7879func (u TransactionSignaturePayloadTaggedTransaction) MustTx() Transaction { 7880 val, ok := u.GetTx() 7881 7882 if !ok { 7883 panic("arm Tx is not set") 7884 } 7885 7886 return val 7887} 7888 7889// GetTx retrieves the Tx value from the union, 7890// returning ok if the union's switch indicated the value is valid. 7891func (u TransactionSignaturePayloadTaggedTransaction) GetTx() (result Transaction, ok bool) { 7892 armName, _ := u.ArmForSwitch(int32(u.Type)) 7893 7894 if armName == "Tx" { 7895 result = *u.Tx 7896 ok = true 7897 } 7898 7899 return 7900} 7901 7902// MarshalBinary implements encoding.BinaryMarshaler. 7903func (s TransactionSignaturePayloadTaggedTransaction) MarshalBinary() ([]byte, error) { 7904 b := new(bytes.Buffer) 7905 _, err := Marshal(b, s) 7906 return b.Bytes(), err 7907} 7908 7909// UnmarshalBinary implements encoding.BinaryUnmarshaler. 7910func (s *TransactionSignaturePayloadTaggedTransaction) UnmarshalBinary(inp []byte) error { 7911 _, err := Unmarshal(bytes.NewReader(inp), s) 7912 return err 7913} 7914 7915var ( 7916 _ encoding.BinaryMarshaler = (*TransactionSignaturePayloadTaggedTransaction)(nil) 7917 _ encoding.BinaryUnmarshaler = (*TransactionSignaturePayloadTaggedTransaction)(nil) 7918) 7919 7920// TransactionSignaturePayload is an XDR Struct defines as: 7921// 7922// struct TransactionSignaturePayload 7923// { 7924// Hash networkId; 7925// union switch (EnvelopeType type) 7926// { 7927// case ENVELOPE_TYPE_TX: 7928// Transaction tx; 7929// /* All other values of type are invalid */ 7930// } 7931// taggedTransaction; 7932// }; 7933// 7934type TransactionSignaturePayload struct { 7935 NetworkId Hash 7936 TaggedTransaction TransactionSignaturePayloadTaggedTransaction 7937} 7938 7939// MarshalBinary implements encoding.BinaryMarshaler. 7940func (s TransactionSignaturePayload) MarshalBinary() ([]byte, error) { 7941 b := new(bytes.Buffer) 7942 _, err := Marshal(b, s) 7943 return b.Bytes(), err 7944} 7945 7946// UnmarshalBinary implements encoding.BinaryUnmarshaler. 7947func (s *TransactionSignaturePayload) UnmarshalBinary(inp []byte) error { 7948 _, err := Unmarshal(bytes.NewReader(inp), s) 7949 return err 7950} 7951 7952var ( 7953 _ encoding.BinaryMarshaler = (*TransactionSignaturePayload)(nil) 7954 _ encoding.BinaryUnmarshaler = (*TransactionSignaturePayload)(nil) 7955) 7956 7957// TransactionEnvelope is an XDR Struct defines as: 7958// 7959// struct TransactionEnvelope 7960// { 7961// Transaction tx; 7962// /* Each decorated signature is a signature over the SHA256 hash of 7963// * a TransactionSignaturePayload */ 7964// DecoratedSignature signatures<20>; 7965// }; 7966// 7967type TransactionEnvelope struct { 7968 Tx Transaction 7969 Signatures []DecoratedSignature `xdrmaxsize:"20"` 7970} 7971 7972// MarshalBinary implements encoding.BinaryMarshaler. 7973func (s TransactionEnvelope) MarshalBinary() ([]byte, error) { 7974 b := new(bytes.Buffer) 7975 _, err := Marshal(b, s) 7976 return b.Bytes(), err 7977} 7978 7979// UnmarshalBinary implements encoding.BinaryUnmarshaler. 7980func (s *TransactionEnvelope) UnmarshalBinary(inp []byte) error { 7981 _, err := Unmarshal(bytes.NewReader(inp), s) 7982 return err 7983} 7984 7985var ( 7986 _ encoding.BinaryMarshaler = (*TransactionEnvelope)(nil) 7987 _ encoding.BinaryUnmarshaler = (*TransactionEnvelope)(nil) 7988) 7989 7990// ClaimOfferAtom is an XDR Struct defines as: 7991// 7992// struct ClaimOfferAtom 7993// { 7994// // emitted to identify the offer 7995// AccountID sellerID; // Account that owns the offer 7996// int64 offerID; 7997// 7998// // amount and asset taken from the owner 7999// Asset assetSold; 8000// int64 amountSold; 8001// 8002// // amount and asset sent to the owner 8003// Asset assetBought; 8004// int64 amountBought; 8005// }; 8006// 8007type ClaimOfferAtom struct { 8008 SellerId AccountId 8009 OfferId Int64 8010 AssetSold Asset 8011 AmountSold Int64 8012 AssetBought Asset 8013 AmountBought Int64 8014} 8015 8016// MarshalBinary implements encoding.BinaryMarshaler. 8017func (s ClaimOfferAtom) MarshalBinary() ([]byte, error) { 8018 b := new(bytes.Buffer) 8019 _, err := Marshal(b, s) 8020 return b.Bytes(), err 8021} 8022 8023// UnmarshalBinary implements encoding.BinaryUnmarshaler. 8024func (s *ClaimOfferAtom) UnmarshalBinary(inp []byte) error { 8025 _, err := Unmarshal(bytes.NewReader(inp), s) 8026 return err 8027} 8028 8029var ( 8030 _ encoding.BinaryMarshaler = (*ClaimOfferAtom)(nil) 8031 _ encoding.BinaryUnmarshaler = (*ClaimOfferAtom)(nil) 8032) 8033 8034// CreateAccountResultCode is an XDR Enum defines as: 8035// 8036// enum CreateAccountResultCode 8037// { 8038// // codes considered as "success" for the operation 8039// CREATE_ACCOUNT_SUCCESS = 0, // account was created 8040// 8041// // codes considered as "failure" for the operation 8042// CREATE_ACCOUNT_MALFORMED = -1, // invalid destination 8043// CREATE_ACCOUNT_UNDERFUNDED = -2, // not enough funds in source account 8044// CREATE_ACCOUNT_LOW_RESERVE = 8045// -3, // would create an account below the min reserve 8046// CREATE_ACCOUNT_ALREADY_EXIST = -4 // account already exists 8047// }; 8048// 8049type CreateAccountResultCode int32 8050 8051const ( 8052 CreateAccountResultCodeCreateAccountSuccess CreateAccountResultCode = 0 8053 CreateAccountResultCodeCreateAccountMalformed CreateAccountResultCode = -1 8054 CreateAccountResultCodeCreateAccountUnderfunded CreateAccountResultCode = -2 8055 CreateAccountResultCodeCreateAccountLowReserve CreateAccountResultCode = -3 8056 CreateAccountResultCodeCreateAccountAlreadyExist CreateAccountResultCode = -4 8057) 8058 8059var createAccountResultCodeMap = map[int32]string{ 8060 0: "CreateAccountResultCodeCreateAccountSuccess", 8061 -1: "CreateAccountResultCodeCreateAccountMalformed", 8062 -2: "CreateAccountResultCodeCreateAccountUnderfunded", 8063 -3: "CreateAccountResultCodeCreateAccountLowReserve", 8064 -4: "CreateAccountResultCodeCreateAccountAlreadyExist", 8065} 8066 8067// ValidEnum validates a proposed value for this enum. Implements 8068// the Enum interface for CreateAccountResultCode 8069func (e CreateAccountResultCode) ValidEnum(v int32) bool { 8070 _, ok := createAccountResultCodeMap[v] 8071 return ok 8072} 8073 8074// String returns the name of `e` 8075func (e CreateAccountResultCode) String() string { 8076 name, _ := createAccountResultCodeMap[int32(e)] 8077 return name 8078} 8079 8080// MarshalBinary implements encoding.BinaryMarshaler. 8081func (s CreateAccountResultCode) MarshalBinary() ([]byte, error) { 8082 b := new(bytes.Buffer) 8083 _, err := Marshal(b, s) 8084 return b.Bytes(), err 8085} 8086 8087// UnmarshalBinary implements encoding.BinaryUnmarshaler. 8088func (s *CreateAccountResultCode) UnmarshalBinary(inp []byte) error { 8089 _, err := Unmarshal(bytes.NewReader(inp), s) 8090 return err 8091} 8092 8093var ( 8094 _ encoding.BinaryMarshaler = (*CreateAccountResultCode)(nil) 8095 _ encoding.BinaryUnmarshaler = (*CreateAccountResultCode)(nil) 8096) 8097 8098// CreateAccountResult is an XDR Union defines as: 8099// 8100// union CreateAccountResult switch (CreateAccountResultCode code) 8101// { 8102// case CREATE_ACCOUNT_SUCCESS: 8103// void; 8104// default: 8105// void; 8106// }; 8107// 8108type CreateAccountResult struct { 8109 Code CreateAccountResultCode 8110} 8111 8112// SwitchFieldName returns the field name in which this union's 8113// discriminant is stored 8114func (u CreateAccountResult) SwitchFieldName() string { 8115 return "Code" 8116} 8117 8118// ArmForSwitch returns which field name should be used for storing 8119// the value for an instance of CreateAccountResult 8120func (u CreateAccountResult) ArmForSwitch(sw int32) (string, bool) { 8121 switch CreateAccountResultCode(sw) { 8122 case CreateAccountResultCodeCreateAccountSuccess: 8123 return "", true 8124 default: 8125 return "", true 8126 } 8127} 8128 8129// NewCreateAccountResult creates a new CreateAccountResult. 8130func NewCreateAccountResult(code CreateAccountResultCode, value interface{}) (result CreateAccountResult, err error) { 8131 result.Code = code 8132 switch CreateAccountResultCode(code) { 8133 case CreateAccountResultCodeCreateAccountSuccess: 8134 // void 8135 default: 8136 // void 8137 } 8138 return 8139} 8140 8141// MarshalBinary implements encoding.BinaryMarshaler. 8142func (s CreateAccountResult) MarshalBinary() ([]byte, error) { 8143 b := new(bytes.Buffer) 8144 _, err := Marshal(b, s) 8145 return b.Bytes(), err 8146} 8147 8148// UnmarshalBinary implements encoding.BinaryUnmarshaler. 8149func (s *CreateAccountResult) UnmarshalBinary(inp []byte) error { 8150 _, err := Unmarshal(bytes.NewReader(inp), s) 8151 return err 8152} 8153 8154var ( 8155 _ encoding.BinaryMarshaler = (*CreateAccountResult)(nil) 8156 _ encoding.BinaryUnmarshaler = (*CreateAccountResult)(nil) 8157) 8158 8159// PaymentResultCode is an XDR Enum defines as: 8160// 8161// enum PaymentResultCode 8162// { 8163// // codes considered as "success" for the operation 8164// PAYMENT_SUCCESS = 0, // payment successfuly completed 8165// 8166// // codes considered as "failure" for the operation 8167// PAYMENT_MALFORMED = -1, // bad input 8168// PAYMENT_UNDERFUNDED = -2, // not enough funds in source account 8169// PAYMENT_SRC_NO_TRUST = -3, // no trust line on source account 8170// PAYMENT_SRC_NOT_AUTHORIZED = -4, // source not authorized to transfer 8171// PAYMENT_NO_DESTINATION = -5, // destination account does not exist 8172// PAYMENT_NO_TRUST = -6, // destination missing a trust line for asset 8173// PAYMENT_NOT_AUTHORIZED = -7, // destination not authorized to hold asset 8174// PAYMENT_LINE_FULL = -8, // destination would go above their limit 8175// PAYMENT_NO_ISSUER = -9 // missing issuer on asset 8176// }; 8177// 8178type PaymentResultCode int32 8179 8180const ( 8181 PaymentResultCodePaymentSuccess PaymentResultCode = 0 8182 PaymentResultCodePaymentMalformed PaymentResultCode = -1 8183 PaymentResultCodePaymentUnderfunded PaymentResultCode = -2 8184 PaymentResultCodePaymentSrcNoTrust PaymentResultCode = -3 8185 PaymentResultCodePaymentSrcNotAuthorized PaymentResultCode = -4 8186 PaymentResultCodePaymentNoDestination PaymentResultCode = -5 8187 PaymentResultCodePaymentNoTrust PaymentResultCode = -6 8188 PaymentResultCodePaymentNotAuthorized PaymentResultCode = -7 8189 PaymentResultCodePaymentLineFull PaymentResultCode = -8 8190 PaymentResultCodePaymentNoIssuer PaymentResultCode = -9 8191) 8192 8193var paymentResultCodeMap = map[int32]string{ 8194 0: "PaymentResultCodePaymentSuccess", 8195 -1: "PaymentResultCodePaymentMalformed", 8196 -2: "PaymentResultCodePaymentUnderfunded", 8197 -3: "PaymentResultCodePaymentSrcNoTrust", 8198 -4: "PaymentResultCodePaymentSrcNotAuthorized", 8199 -5: "PaymentResultCodePaymentNoDestination", 8200 -6: "PaymentResultCodePaymentNoTrust", 8201 -7: "PaymentResultCodePaymentNotAuthorized", 8202 -8: "PaymentResultCodePaymentLineFull", 8203 -9: "PaymentResultCodePaymentNoIssuer", 8204} 8205 8206// ValidEnum validates a proposed value for this enum. Implements 8207// the Enum interface for PaymentResultCode 8208func (e PaymentResultCode) ValidEnum(v int32) bool { 8209 _, ok := paymentResultCodeMap[v] 8210 return ok 8211} 8212 8213// String returns the name of `e` 8214func (e PaymentResultCode) String() string { 8215 name, _ := paymentResultCodeMap[int32(e)] 8216 return name 8217} 8218 8219// MarshalBinary implements encoding.BinaryMarshaler. 8220func (s PaymentResultCode) MarshalBinary() ([]byte, error) { 8221 b := new(bytes.Buffer) 8222 _, err := Marshal(b, s) 8223 return b.Bytes(), err 8224} 8225 8226// UnmarshalBinary implements encoding.BinaryUnmarshaler. 8227func (s *PaymentResultCode) UnmarshalBinary(inp []byte) error { 8228 _, err := Unmarshal(bytes.NewReader(inp), s) 8229 return err 8230} 8231 8232var ( 8233 _ encoding.BinaryMarshaler = (*PaymentResultCode)(nil) 8234 _ encoding.BinaryUnmarshaler = (*PaymentResultCode)(nil) 8235) 8236 8237// PaymentResult is an XDR Union defines as: 8238// 8239// union PaymentResult switch (PaymentResultCode code) 8240// { 8241// case PAYMENT_SUCCESS: 8242// void; 8243// default: 8244// void; 8245// }; 8246// 8247type PaymentResult struct { 8248 Code PaymentResultCode 8249} 8250 8251// SwitchFieldName returns the field name in which this union's 8252// discriminant is stored 8253func (u PaymentResult) SwitchFieldName() string { 8254 return "Code" 8255} 8256 8257// ArmForSwitch returns which field name should be used for storing 8258// the value for an instance of PaymentResult 8259func (u PaymentResult) ArmForSwitch(sw int32) (string, bool) { 8260 switch PaymentResultCode(sw) { 8261 case PaymentResultCodePaymentSuccess: 8262 return "", true 8263 default: 8264 return "", true 8265 } 8266} 8267 8268// NewPaymentResult creates a new PaymentResult. 8269func NewPaymentResult(code PaymentResultCode, value interface{}) (result PaymentResult, err error) { 8270 result.Code = code 8271 switch PaymentResultCode(code) { 8272 case PaymentResultCodePaymentSuccess: 8273 // void 8274 default: 8275 // void 8276 } 8277 return 8278} 8279 8280// MarshalBinary implements encoding.BinaryMarshaler. 8281func (s PaymentResult) MarshalBinary() ([]byte, error) { 8282 b := new(bytes.Buffer) 8283 _, err := Marshal(b, s) 8284 return b.Bytes(), err 8285} 8286 8287// UnmarshalBinary implements encoding.BinaryUnmarshaler. 8288func (s *PaymentResult) UnmarshalBinary(inp []byte) error { 8289 _, err := Unmarshal(bytes.NewReader(inp), s) 8290 return err 8291} 8292 8293var ( 8294 _ encoding.BinaryMarshaler = (*PaymentResult)(nil) 8295 _ encoding.BinaryUnmarshaler = (*PaymentResult)(nil) 8296) 8297 8298// PathPaymentStrictReceiveResultCode is an XDR Enum defines as: 8299// 8300// enum PathPaymentStrictReceiveResultCode 8301// { 8302// // codes considered as "success" for the operation 8303// PATH_PAYMENT_STRICT_RECEIVE_SUCCESS = 0, // success 8304// 8305// // codes considered as "failure" for the operation 8306// PATH_PAYMENT_STRICT_RECEIVE_MALFORMED = -1, // bad input 8307// PATH_PAYMENT_STRICT_RECEIVE_UNDERFUNDED = -2, // not enough funds in source account 8308// PATH_PAYMENT_STRICT_RECEIVE_SRC_NO_TRUST = -3, // no trust line on source account 8309// PATH_PAYMENT_STRICT_RECEIVE_SRC_NOT_AUTHORIZED = -4, // source not authorized to transfer 8310// PATH_PAYMENT_STRICT_RECEIVE_NO_DESTINATION = -5, // destination account does not exist 8311// PATH_PAYMENT_STRICT_RECEIVE_NO_TRUST = -6, // dest missing a trust line for asset 8312// PATH_PAYMENT_STRICT_RECEIVE_NOT_AUTHORIZED = -7, // dest not authorized to hold asset 8313// PATH_PAYMENT_STRICT_RECEIVE_LINE_FULL = -8, // dest would go above their limit 8314// PATH_PAYMENT_STRICT_RECEIVE_NO_ISSUER = -9, // missing issuer on one asset 8315// PATH_PAYMENT_STRICT_RECEIVE_TOO_FEW_OFFERS = -10, // not enough offers to satisfy path 8316// PATH_PAYMENT_STRICT_RECEIVE_OFFER_CROSS_SELF = -11, // would cross one of its own offers 8317// PATH_PAYMENT_STRICT_RECEIVE_OVER_SENDMAX = -12 // could not satisfy sendmax 8318// }; 8319// 8320type PathPaymentStrictReceiveResultCode int32 8321 8322const ( 8323 PathPaymentStrictReceiveResultCodePathPaymentStrictReceiveSuccess PathPaymentStrictReceiveResultCode = 0 8324 PathPaymentStrictReceiveResultCodePathPaymentStrictReceiveMalformed PathPaymentStrictReceiveResultCode = -1 8325 PathPaymentStrictReceiveResultCodePathPaymentStrictReceiveUnderfunded PathPaymentStrictReceiveResultCode = -2 8326 PathPaymentStrictReceiveResultCodePathPaymentStrictReceiveSrcNoTrust PathPaymentStrictReceiveResultCode = -3 8327 PathPaymentStrictReceiveResultCodePathPaymentStrictReceiveSrcNotAuthorized PathPaymentStrictReceiveResultCode = -4 8328 PathPaymentStrictReceiveResultCodePathPaymentStrictReceiveNoDestination PathPaymentStrictReceiveResultCode = -5 8329 PathPaymentStrictReceiveResultCodePathPaymentStrictReceiveNoTrust PathPaymentStrictReceiveResultCode = -6 8330 PathPaymentStrictReceiveResultCodePathPaymentStrictReceiveNotAuthorized PathPaymentStrictReceiveResultCode = -7 8331 PathPaymentStrictReceiveResultCodePathPaymentStrictReceiveLineFull PathPaymentStrictReceiveResultCode = -8 8332 PathPaymentStrictReceiveResultCodePathPaymentStrictReceiveNoIssuer PathPaymentStrictReceiveResultCode = -9 8333 PathPaymentStrictReceiveResultCodePathPaymentStrictReceiveTooFewOffers PathPaymentStrictReceiveResultCode = -10 8334 PathPaymentStrictReceiveResultCodePathPaymentStrictReceiveOfferCrossSelf PathPaymentStrictReceiveResultCode = -11 8335 PathPaymentStrictReceiveResultCodePathPaymentStrictReceiveOverSendmax PathPaymentStrictReceiveResultCode = -12 8336) 8337 8338var pathPaymentStrictReceiveResultCodeMap = map[int32]string{ 8339 0: "PathPaymentStrictReceiveResultCodePathPaymentStrictReceiveSuccess", 8340 -1: "PathPaymentStrictReceiveResultCodePathPaymentStrictReceiveMalformed", 8341 -2: "PathPaymentStrictReceiveResultCodePathPaymentStrictReceiveUnderfunded", 8342 -3: "PathPaymentStrictReceiveResultCodePathPaymentStrictReceiveSrcNoTrust", 8343 -4: "PathPaymentStrictReceiveResultCodePathPaymentStrictReceiveSrcNotAuthorized", 8344 -5: "PathPaymentStrictReceiveResultCodePathPaymentStrictReceiveNoDestination", 8345 -6: "PathPaymentStrictReceiveResultCodePathPaymentStrictReceiveNoTrust", 8346 -7: "PathPaymentStrictReceiveResultCodePathPaymentStrictReceiveNotAuthorized", 8347 -8: "PathPaymentStrictReceiveResultCodePathPaymentStrictReceiveLineFull", 8348 -9: "PathPaymentStrictReceiveResultCodePathPaymentStrictReceiveNoIssuer", 8349 -10: "PathPaymentStrictReceiveResultCodePathPaymentStrictReceiveTooFewOffers", 8350 -11: "PathPaymentStrictReceiveResultCodePathPaymentStrictReceiveOfferCrossSelf", 8351 -12: "PathPaymentStrictReceiveResultCodePathPaymentStrictReceiveOverSendmax", 8352} 8353 8354// ValidEnum validates a proposed value for this enum. Implements 8355// the Enum interface for PathPaymentStrictReceiveResultCode 8356func (e PathPaymentStrictReceiveResultCode) ValidEnum(v int32) bool { 8357 _, ok := pathPaymentStrictReceiveResultCodeMap[v] 8358 return ok 8359} 8360 8361// String returns the name of `e` 8362func (e PathPaymentStrictReceiveResultCode) String() string { 8363 name, _ := pathPaymentStrictReceiveResultCodeMap[int32(e)] 8364 return name 8365} 8366 8367// MarshalBinary implements encoding.BinaryMarshaler. 8368func (s PathPaymentStrictReceiveResultCode) MarshalBinary() ([]byte, error) { 8369 b := new(bytes.Buffer) 8370 _, err := Marshal(b, s) 8371 return b.Bytes(), err 8372} 8373 8374// UnmarshalBinary implements encoding.BinaryUnmarshaler. 8375func (s *PathPaymentStrictReceiveResultCode) UnmarshalBinary(inp []byte) error { 8376 _, err := Unmarshal(bytes.NewReader(inp), s) 8377 return err 8378} 8379 8380var ( 8381 _ encoding.BinaryMarshaler = (*PathPaymentStrictReceiveResultCode)(nil) 8382 _ encoding.BinaryUnmarshaler = (*PathPaymentStrictReceiveResultCode)(nil) 8383) 8384 8385// SimplePaymentResult is an XDR Struct defines as: 8386// 8387// struct SimplePaymentResult 8388// { 8389// AccountID destination; 8390// Asset asset; 8391// int64 amount; 8392// }; 8393// 8394type SimplePaymentResult struct { 8395 Destination AccountId 8396 Asset Asset 8397 Amount Int64 8398} 8399 8400// MarshalBinary implements encoding.BinaryMarshaler. 8401func (s SimplePaymentResult) MarshalBinary() ([]byte, error) { 8402 b := new(bytes.Buffer) 8403 _, err := Marshal(b, s) 8404 return b.Bytes(), err 8405} 8406 8407// UnmarshalBinary implements encoding.BinaryUnmarshaler. 8408func (s *SimplePaymentResult) UnmarshalBinary(inp []byte) error { 8409 _, err := Unmarshal(bytes.NewReader(inp), s) 8410 return err 8411} 8412 8413var ( 8414 _ encoding.BinaryMarshaler = (*SimplePaymentResult)(nil) 8415 _ encoding.BinaryUnmarshaler = (*SimplePaymentResult)(nil) 8416) 8417 8418// PathPaymentStrictReceiveResultSuccess is an XDR NestedStruct defines as: 8419// 8420// struct 8421// { 8422// ClaimOfferAtom offers<>; 8423// SimplePaymentResult last; 8424// } 8425// 8426type PathPaymentStrictReceiveResultSuccess struct { 8427 Offers []ClaimOfferAtom 8428 Last SimplePaymentResult 8429} 8430 8431// MarshalBinary implements encoding.BinaryMarshaler. 8432func (s PathPaymentStrictReceiveResultSuccess) MarshalBinary() ([]byte, error) { 8433 b := new(bytes.Buffer) 8434 _, err := Marshal(b, s) 8435 return b.Bytes(), err 8436} 8437 8438// UnmarshalBinary implements encoding.BinaryUnmarshaler. 8439func (s *PathPaymentStrictReceiveResultSuccess) UnmarshalBinary(inp []byte) error { 8440 _, err := Unmarshal(bytes.NewReader(inp), s) 8441 return err 8442} 8443 8444var ( 8445 _ encoding.BinaryMarshaler = (*PathPaymentStrictReceiveResultSuccess)(nil) 8446 _ encoding.BinaryUnmarshaler = (*PathPaymentStrictReceiveResultSuccess)(nil) 8447) 8448 8449// PathPaymentStrictReceiveResult is an XDR Union defines as: 8450// 8451// union PathPaymentStrictReceiveResult switch (PathPaymentStrictReceiveResultCode code) 8452// { 8453// case PATH_PAYMENT_STRICT_RECEIVE_SUCCESS: 8454// struct 8455// { 8456// ClaimOfferAtom offers<>; 8457// SimplePaymentResult last; 8458// } success; 8459// case PATH_PAYMENT_STRICT_RECEIVE_NO_ISSUER: 8460// Asset noIssuer; // the asset that caused the error 8461// default: 8462// void; 8463// }; 8464// 8465type PathPaymentStrictReceiveResult struct { 8466 Code PathPaymentStrictReceiveResultCode 8467 Success *PathPaymentStrictReceiveResultSuccess 8468 NoIssuer *Asset 8469} 8470 8471// SwitchFieldName returns the field name in which this union's 8472// discriminant is stored 8473func (u PathPaymentStrictReceiveResult) SwitchFieldName() string { 8474 return "Code" 8475} 8476 8477// ArmForSwitch returns which field name should be used for storing 8478// the value for an instance of PathPaymentStrictReceiveResult 8479func (u PathPaymentStrictReceiveResult) ArmForSwitch(sw int32) (string, bool) { 8480 switch PathPaymentStrictReceiveResultCode(sw) { 8481 case PathPaymentStrictReceiveResultCodePathPaymentStrictReceiveSuccess: 8482 return "Success", true 8483 case PathPaymentStrictReceiveResultCodePathPaymentStrictReceiveNoIssuer: 8484 return "NoIssuer", true 8485 default: 8486 return "", true 8487 } 8488} 8489 8490// NewPathPaymentStrictReceiveResult creates a new PathPaymentStrictReceiveResult. 8491func NewPathPaymentStrictReceiveResult(code PathPaymentStrictReceiveResultCode, value interface{}) (result PathPaymentStrictReceiveResult, err error) { 8492 result.Code = code 8493 switch PathPaymentStrictReceiveResultCode(code) { 8494 case PathPaymentStrictReceiveResultCodePathPaymentStrictReceiveSuccess: 8495 tv, ok := value.(PathPaymentStrictReceiveResultSuccess) 8496 if !ok { 8497 err = fmt.Errorf("invalid value, must be PathPaymentStrictReceiveResultSuccess") 8498 return 8499 } 8500 result.Success = &tv 8501 case PathPaymentStrictReceiveResultCodePathPaymentStrictReceiveNoIssuer: 8502 tv, ok := value.(Asset) 8503 if !ok { 8504 err = fmt.Errorf("invalid value, must be Asset") 8505 return 8506 } 8507 result.NoIssuer = &tv 8508 default: 8509 // void 8510 } 8511 return 8512} 8513 8514// MustSuccess retrieves the Success value from the union, 8515// panicing if the value is not set. 8516func (u PathPaymentStrictReceiveResult) MustSuccess() PathPaymentStrictReceiveResultSuccess { 8517 val, ok := u.GetSuccess() 8518 8519 if !ok { 8520 panic("arm Success is not set") 8521 } 8522 8523 return val 8524} 8525 8526// GetSuccess retrieves the Success value from the union, 8527// returning ok if the union's switch indicated the value is valid. 8528func (u PathPaymentStrictReceiveResult) GetSuccess() (result PathPaymentStrictReceiveResultSuccess, ok bool) { 8529 armName, _ := u.ArmForSwitch(int32(u.Code)) 8530 8531 if armName == "Success" { 8532 result = *u.Success 8533 ok = true 8534 } 8535 8536 return 8537} 8538 8539// MustNoIssuer retrieves the NoIssuer value from the union, 8540// panicing if the value is not set. 8541func (u PathPaymentStrictReceiveResult) MustNoIssuer() Asset { 8542 val, ok := u.GetNoIssuer() 8543 8544 if !ok { 8545 panic("arm NoIssuer is not set") 8546 } 8547 8548 return val 8549} 8550 8551// GetNoIssuer retrieves the NoIssuer value from the union, 8552// returning ok if the union's switch indicated the value is valid. 8553func (u PathPaymentStrictReceiveResult) GetNoIssuer() (result Asset, ok bool) { 8554 armName, _ := u.ArmForSwitch(int32(u.Code)) 8555 8556 if armName == "NoIssuer" { 8557 result = *u.NoIssuer 8558 ok = true 8559 } 8560 8561 return 8562} 8563 8564// MarshalBinary implements encoding.BinaryMarshaler. 8565func (s PathPaymentStrictReceiveResult) MarshalBinary() ([]byte, error) { 8566 b := new(bytes.Buffer) 8567 _, err := Marshal(b, s) 8568 return b.Bytes(), err 8569} 8570 8571// UnmarshalBinary implements encoding.BinaryUnmarshaler. 8572func (s *PathPaymentStrictReceiveResult) UnmarshalBinary(inp []byte) error { 8573 _, err := Unmarshal(bytes.NewReader(inp), s) 8574 return err 8575} 8576 8577var ( 8578 _ encoding.BinaryMarshaler = (*PathPaymentStrictReceiveResult)(nil) 8579 _ encoding.BinaryUnmarshaler = (*PathPaymentStrictReceiveResult)(nil) 8580) 8581 8582// PathPaymentStrictSendResultCode is an XDR Enum defines as: 8583// 8584// enum PathPaymentStrictSendResultCode 8585// { 8586// // codes considered as "success" for the operation 8587// PATH_PAYMENT_STRICT_SEND_SUCCESS = 0, // success 8588// 8589// // codes considered as "failure" for the operation 8590// PATH_PAYMENT_STRICT_SEND_MALFORMED = -1, // bad input 8591// PATH_PAYMENT_STRICT_SEND_UNDERFUNDED = -2, // not enough funds in source account 8592// PATH_PAYMENT_STRICT_SEND_SRC_NO_TRUST = -3, // no trust line on source account 8593// PATH_PAYMENT_STRICT_SEND_SRC_NOT_AUTHORIZED = -4, // source not authorized to transfer 8594// PATH_PAYMENT_STRICT_SEND_NO_DESTINATION = -5, // destination account does not exist 8595// PATH_PAYMENT_STRICT_SEND_NO_TRUST = -6, // dest missing a trust line for asset 8596// PATH_PAYMENT_STRICT_SEND_NOT_AUTHORIZED = -7, // dest not authorized to hold asset 8597// PATH_PAYMENT_STRICT_SEND_LINE_FULL = -8, // dest would go above their limit 8598// PATH_PAYMENT_STRICT_SEND_NO_ISSUER = -9, // missing issuer on one asset 8599// PATH_PAYMENT_STRICT_SEND_TOO_FEW_OFFERS = -10, // not enough offers to satisfy path 8600// PATH_PAYMENT_STRICT_SEND_OFFER_CROSS_SELF = -11, // would cross one of its own offers 8601// PATH_PAYMENT_STRICT_SEND_UNDER_DESTMIN = -12 // could not satisfy destMin 8602// }; 8603// 8604type PathPaymentStrictSendResultCode int32 8605 8606const ( 8607 PathPaymentStrictSendResultCodePathPaymentStrictSendSuccess PathPaymentStrictSendResultCode = 0 8608 PathPaymentStrictSendResultCodePathPaymentStrictSendMalformed PathPaymentStrictSendResultCode = -1 8609 PathPaymentStrictSendResultCodePathPaymentStrictSendUnderfunded PathPaymentStrictSendResultCode = -2 8610 PathPaymentStrictSendResultCodePathPaymentStrictSendSrcNoTrust PathPaymentStrictSendResultCode = -3 8611 PathPaymentStrictSendResultCodePathPaymentStrictSendSrcNotAuthorized PathPaymentStrictSendResultCode = -4 8612 PathPaymentStrictSendResultCodePathPaymentStrictSendNoDestination PathPaymentStrictSendResultCode = -5 8613 PathPaymentStrictSendResultCodePathPaymentStrictSendNoTrust PathPaymentStrictSendResultCode = -6 8614 PathPaymentStrictSendResultCodePathPaymentStrictSendNotAuthorized PathPaymentStrictSendResultCode = -7 8615 PathPaymentStrictSendResultCodePathPaymentStrictSendLineFull PathPaymentStrictSendResultCode = -8 8616 PathPaymentStrictSendResultCodePathPaymentStrictSendNoIssuer PathPaymentStrictSendResultCode = -9 8617 PathPaymentStrictSendResultCodePathPaymentStrictSendTooFewOffers PathPaymentStrictSendResultCode = -10 8618 PathPaymentStrictSendResultCodePathPaymentStrictSendOfferCrossSelf PathPaymentStrictSendResultCode = -11 8619 PathPaymentStrictSendResultCodePathPaymentStrictSendUnderDestmin PathPaymentStrictSendResultCode = -12 8620) 8621 8622var pathPaymentStrictSendResultCodeMap = map[int32]string{ 8623 0: "PathPaymentStrictSendResultCodePathPaymentStrictSendSuccess", 8624 -1: "PathPaymentStrictSendResultCodePathPaymentStrictSendMalformed", 8625 -2: "PathPaymentStrictSendResultCodePathPaymentStrictSendUnderfunded", 8626 -3: "PathPaymentStrictSendResultCodePathPaymentStrictSendSrcNoTrust", 8627 -4: "PathPaymentStrictSendResultCodePathPaymentStrictSendSrcNotAuthorized", 8628 -5: "PathPaymentStrictSendResultCodePathPaymentStrictSendNoDestination", 8629 -6: "PathPaymentStrictSendResultCodePathPaymentStrictSendNoTrust", 8630 -7: "PathPaymentStrictSendResultCodePathPaymentStrictSendNotAuthorized", 8631 -8: "PathPaymentStrictSendResultCodePathPaymentStrictSendLineFull", 8632 -9: "PathPaymentStrictSendResultCodePathPaymentStrictSendNoIssuer", 8633 -10: "PathPaymentStrictSendResultCodePathPaymentStrictSendTooFewOffers", 8634 -11: "PathPaymentStrictSendResultCodePathPaymentStrictSendOfferCrossSelf", 8635 -12: "PathPaymentStrictSendResultCodePathPaymentStrictSendUnderDestmin", 8636} 8637 8638// ValidEnum validates a proposed value for this enum. Implements 8639// the Enum interface for PathPaymentStrictSendResultCode 8640func (e PathPaymentStrictSendResultCode) ValidEnum(v int32) bool { 8641 _, ok := pathPaymentStrictSendResultCodeMap[v] 8642 return ok 8643} 8644 8645// String returns the name of `e` 8646func (e PathPaymentStrictSendResultCode) String() string { 8647 name, _ := pathPaymentStrictSendResultCodeMap[int32(e)] 8648 return name 8649} 8650 8651// MarshalBinary implements encoding.BinaryMarshaler. 8652func (s PathPaymentStrictSendResultCode) MarshalBinary() ([]byte, error) { 8653 b := new(bytes.Buffer) 8654 _, err := Marshal(b, s) 8655 return b.Bytes(), err 8656} 8657 8658// UnmarshalBinary implements encoding.BinaryUnmarshaler. 8659func (s *PathPaymentStrictSendResultCode) UnmarshalBinary(inp []byte) error { 8660 _, err := Unmarshal(bytes.NewReader(inp), s) 8661 return err 8662} 8663 8664var ( 8665 _ encoding.BinaryMarshaler = (*PathPaymentStrictSendResultCode)(nil) 8666 _ encoding.BinaryUnmarshaler = (*PathPaymentStrictSendResultCode)(nil) 8667) 8668 8669// PathPaymentStrictSendResultSuccess is an XDR NestedStruct defines as: 8670// 8671// struct 8672// { 8673// ClaimOfferAtom offers<>; 8674// SimplePaymentResult last; 8675// } 8676// 8677type PathPaymentStrictSendResultSuccess struct { 8678 Offers []ClaimOfferAtom 8679 Last SimplePaymentResult 8680} 8681 8682// MarshalBinary implements encoding.BinaryMarshaler. 8683func (s PathPaymentStrictSendResultSuccess) MarshalBinary() ([]byte, error) { 8684 b := new(bytes.Buffer) 8685 _, err := Marshal(b, s) 8686 return b.Bytes(), err 8687} 8688 8689// UnmarshalBinary implements encoding.BinaryUnmarshaler. 8690func (s *PathPaymentStrictSendResultSuccess) UnmarshalBinary(inp []byte) error { 8691 _, err := Unmarshal(bytes.NewReader(inp), s) 8692 return err 8693} 8694 8695var ( 8696 _ encoding.BinaryMarshaler = (*PathPaymentStrictSendResultSuccess)(nil) 8697 _ encoding.BinaryUnmarshaler = (*PathPaymentStrictSendResultSuccess)(nil) 8698) 8699 8700// PathPaymentStrictSendResult is an XDR Union defines as: 8701// 8702// union PathPaymentStrictSendResult switch (PathPaymentStrictSendResultCode code) 8703// { 8704// case PATH_PAYMENT_STRICT_SEND_SUCCESS: 8705// struct 8706// { 8707// ClaimOfferAtom offers<>; 8708// SimplePaymentResult last; 8709// } success; 8710// case PATH_PAYMENT_STRICT_SEND_NO_ISSUER: 8711// Asset noIssuer; // the asset that caused the error 8712// default: 8713// void; 8714// }; 8715// 8716type PathPaymentStrictSendResult struct { 8717 Code PathPaymentStrictSendResultCode 8718 Success *PathPaymentStrictSendResultSuccess 8719 NoIssuer *Asset 8720} 8721 8722// SwitchFieldName returns the field name in which this union's 8723// discriminant is stored 8724func (u PathPaymentStrictSendResult) SwitchFieldName() string { 8725 return "Code" 8726} 8727 8728// ArmForSwitch returns which field name should be used for storing 8729// the value for an instance of PathPaymentStrictSendResult 8730func (u PathPaymentStrictSendResult) ArmForSwitch(sw int32) (string, bool) { 8731 switch PathPaymentStrictSendResultCode(sw) { 8732 case PathPaymentStrictSendResultCodePathPaymentStrictSendSuccess: 8733 return "Success", true 8734 case PathPaymentStrictSendResultCodePathPaymentStrictSendNoIssuer: 8735 return "NoIssuer", true 8736 default: 8737 return "", true 8738 } 8739} 8740 8741// NewPathPaymentStrictSendResult creates a new PathPaymentStrictSendResult. 8742func NewPathPaymentStrictSendResult(code PathPaymentStrictSendResultCode, value interface{}) (result PathPaymentStrictSendResult, err error) { 8743 result.Code = code 8744 switch PathPaymentStrictSendResultCode(code) { 8745 case PathPaymentStrictSendResultCodePathPaymentStrictSendSuccess: 8746 tv, ok := value.(PathPaymentStrictSendResultSuccess) 8747 if !ok { 8748 err = fmt.Errorf("invalid value, must be PathPaymentStrictSendResultSuccess") 8749 return 8750 } 8751 result.Success = &tv 8752 case PathPaymentStrictSendResultCodePathPaymentStrictSendNoIssuer: 8753 tv, ok := value.(Asset) 8754 if !ok { 8755 err = fmt.Errorf("invalid value, must be Asset") 8756 return 8757 } 8758 result.NoIssuer = &tv 8759 default: 8760 // void 8761 } 8762 return 8763} 8764 8765// MustSuccess retrieves the Success value from the union, 8766// panicing if the value is not set. 8767func (u PathPaymentStrictSendResult) MustSuccess() PathPaymentStrictSendResultSuccess { 8768 val, ok := u.GetSuccess() 8769 8770 if !ok { 8771 panic("arm Success is not set") 8772 } 8773 8774 return val 8775} 8776 8777// GetSuccess retrieves the Success value from the union, 8778// returning ok if the union's switch indicated the value is valid. 8779func (u PathPaymentStrictSendResult) GetSuccess() (result PathPaymentStrictSendResultSuccess, ok bool) { 8780 armName, _ := u.ArmForSwitch(int32(u.Code)) 8781 8782 if armName == "Success" { 8783 result = *u.Success 8784 ok = true 8785 } 8786 8787 return 8788} 8789 8790// MustNoIssuer retrieves the NoIssuer value from the union, 8791// panicing if the value is not set. 8792func (u PathPaymentStrictSendResult) MustNoIssuer() Asset { 8793 val, ok := u.GetNoIssuer() 8794 8795 if !ok { 8796 panic("arm NoIssuer is not set") 8797 } 8798 8799 return val 8800} 8801 8802// GetNoIssuer retrieves the NoIssuer value from the union, 8803// returning ok if the union's switch indicated the value is valid. 8804func (u PathPaymentStrictSendResult) GetNoIssuer() (result Asset, ok bool) { 8805 armName, _ := u.ArmForSwitch(int32(u.Code)) 8806 8807 if armName == "NoIssuer" { 8808 result = *u.NoIssuer 8809 ok = true 8810 } 8811 8812 return 8813} 8814 8815// MarshalBinary implements encoding.BinaryMarshaler. 8816func (s PathPaymentStrictSendResult) MarshalBinary() ([]byte, error) { 8817 b := new(bytes.Buffer) 8818 _, err := Marshal(b, s) 8819 return b.Bytes(), err 8820} 8821 8822// UnmarshalBinary implements encoding.BinaryUnmarshaler. 8823func (s *PathPaymentStrictSendResult) UnmarshalBinary(inp []byte) error { 8824 _, err := Unmarshal(bytes.NewReader(inp), s) 8825 return err 8826} 8827 8828var ( 8829 _ encoding.BinaryMarshaler = (*PathPaymentStrictSendResult)(nil) 8830 _ encoding.BinaryUnmarshaler = (*PathPaymentStrictSendResult)(nil) 8831) 8832 8833// ManageSellOfferResultCode is an XDR Enum defines as: 8834// 8835// enum ManageSellOfferResultCode 8836// { 8837// // codes considered as "success" for the operation 8838// MANAGE_SELL_OFFER_SUCCESS = 0, 8839// 8840// // codes considered as "failure" for the operation 8841// MANAGE_SELL_OFFER_MALFORMED = -1, // generated offer would be invalid 8842// MANAGE_SELL_OFFER_SELL_NO_TRUST = -2, // no trust line for what we're selling 8843// MANAGE_SELL_OFFER_BUY_NO_TRUST = -3, // no trust line for what we're buying 8844// MANAGE_SELL_OFFER_SELL_NOT_AUTHORIZED = -4, // not authorized to sell 8845// MANAGE_SELL_OFFER_BUY_NOT_AUTHORIZED = -5, // not authorized to buy 8846// MANAGE_SELL_OFFER_LINE_FULL = -6, // can't receive more of what it's buying 8847// MANAGE_SELL_OFFER_UNDERFUNDED = -7, // doesn't hold what it's trying to sell 8848// MANAGE_SELL_OFFER_CROSS_SELF = -8, // would cross an offer from the same user 8849// MANAGE_SELL_OFFER_SELL_NO_ISSUER = -9, // no issuer for what we're selling 8850// MANAGE_SELL_OFFER_BUY_NO_ISSUER = -10, // no issuer for what we're buying 8851// 8852// // update errors 8853// MANAGE_SELL_OFFER_NOT_FOUND = -11, // offerID does not match an existing offer 8854// 8855// MANAGE_SELL_OFFER_LOW_RESERVE = -12 // not enough funds to create a new Offer 8856// }; 8857// 8858type ManageSellOfferResultCode int32 8859 8860const ( 8861 ManageSellOfferResultCodeManageSellOfferSuccess ManageSellOfferResultCode = 0 8862 ManageSellOfferResultCodeManageSellOfferMalformed ManageSellOfferResultCode = -1 8863 ManageSellOfferResultCodeManageSellOfferSellNoTrust ManageSellOfferResultCode = -2 8864 ManageSellOfferResultCodeManageSellOfferBuyNoTrust ManageSellOfferResultCode = -3 8865 ManageSellOfferResultCodeManageSellOfferSellNotAuthorized ManageSellOfferResultCode = -4 8866 ManageSellOfferResultCodeManageSellOfferBuyNotAuthorized ManageSellOfferResultCode = -5 8867 ManageSellOfferResultCodeManageSellOfferLineFull ManageSellOfferResultCode = -6 8868 ManageSellOfferResultCodeManageSellOfferUnderfunded ManageSellOfferResultCode = -7 8869 ManageSellOfferResultCodeManageSellOfferCrossSelf ManageSellOfferResultCode = -8 8870 ManageSellOfferResultCodeManageSellOfferSellNoIssuer ManageSellOfferResultCode = -9 8871 ManageSellOfferResultCodeManageSellOfferBuyNoIssuer ManageSellOfferResultCode = -10 8872 ManageSellOfferResultCodeManageSellOfferNotFound ManageSellOfferResultCode = -11 8873 ManageSellOfferResultCodeManageSellOfferLowReserve ManageSellOfferResultCode = -12 8874) 8875 8876var manageSellOfferResultCodeMap = map[int32]string{ 8877 0: "ManageSellOfferResultCodeManageSellOfferSuccess", 8878 -1: "ManageSellOfferResultCodeManageSellOfferMalformed", 8879 -2: "ManageSellOfferResultCodeManageSellOfferSellNoTrust", 8880 -3: "ManageSellOfferResultCodeManageSellOfferBuyNoTrust", 8881 -4: "ManageSellOfferResultCodeManageSellOfferSellNotAuthorized", 8882 -5: "ManageSellOfferResultCodeManageSellOfferBuyNotAuthorized", 8883 -6: "ManageSellOfferResultCodeManageSellOfferLineFull", 8884 -7: "ManageSellOfferResultCodeManageSellOfferUnderfunded", 8885 -8: "ManageSellOfferResultCodeManageSellOfferCrossSelf", 8886 -9: "ManageSellOfferResultCodeManageSellOfferSellNoIssuer", 8887 -10: "ManageSellOfferResultCodeManageSellOfferBuyNoIssuer", 8888 -11: "ManageSellOfferResultCodeManageSellOfferNotFound", 8889 -12: "ManageSellOfferResultCodeManageSellOfferLowReserve", 8890} 8891 8892// ValidEnum validates a proposed value for this enum. Implements 8893// the Enum interface for ManageSellOfferResultCode 8894func (e ManageSellOfferResultCode) ValidEnum(v int32) bool { 8895 _, ok := manageSellOfferResultCodeMap[v] 8896 return ok 8897} 8898 8899// String returns the name of `e` 8900func (e ManageSellOfferResultCode) String() string { 8901 name, _ := manageSellOfferResultCodeMap[int32(e)] 8902 return name 8903} 8904 8905// MarshalBinary implements encoding.BinaryMarshaler. 8906func (s ManageSellOfferResultCode) MarshalBinary() ([]byte, error) { 8907 b := new(bytes.Buffer) 8908 _, err := Marshal(b, s) 8909 return b.Bytes(), err 8910} 8911 8912// UnmarshalBinary implements encoding.BinaryUnmarshaler. 8913func (s *ManageSellOfferResultCode) UnmarshalBinary(inp []byte) error { 8914 _, err := Unmarshal(bytes.NewReader(inp), s) 8915 return err 8916} 8917 8918var ( 8919 _ encoding.BinaryMarshaler = (*ManageSellOfferResultCode)(nil) 8920 _ encoding.BinaryUnmarshaler = (*ManageSellOfferResultCode)(nil) 8921) 8922 8923// ManageOfferEffect is an XDR Enum defines as: 8924// 8925// enum ManageOfferEffect 8926// { 8927// MANAGE_OFFER_CREATED = 0, 8928// MANAGE_OFFER_UPDATED = 1, 8929// MANAGE_OFFER_DELETED = 2 8930// }; 8931// 8932type ManageOfferEffect int32 8933 8934const ( 8935 ManageOfferEffectManageOfferCreated ManageOfferEffect = 0 8936 ManageOfferEffectManageOfferUpdated ManageOfferEffect = 1 8937 ManageOfferEffectManageOfferDeleted ManageOfferEffect = 2 8938) 8939 8940var manageOfferEffectMap = map[int32]string{ 8941 0: "ManageOfferEffectManageOfferCreated", 8942 1: "ManageOfferEffectManageOfferUpdated", 8943 2: "ManageOfferEffectManageOfferDeleted", 8944} 8945 8946// ValidEnum validates a proposed value for this enum. Implements 8947// the Enum interface for ManageOfferEffect 8948func (e ManageOfferEffect) ValidEnum(v int32) bool { 8949 _, ok := manageOfferEffectMap[v] 8950 return ok 8951} 8952 8953// String returns the name of `e` 8954func (e ManageOfferEffect) String() string { 8955 name, _ := manageOfferEffectMap[int32(e)] 8956 return name 8957} 8958 8959// MarshalBinary implements encoding.BinaryMarshaler. 8960func (s ManageOfferEffect) MarshalBinary() ([]byte, error) { 8961 b := new(bytes.Buffer) 8962 _, err := Marshal(b, s) 8963 return b.Bytes(), err 8964} 8965 8966// UnmarshalBinary implements encoding.BinaryUnmarshaler. 8967func (s *ManageOfferEffect) UnmarshalBinary(inp []byte) error { 8968 _, err := Unmarshal(bytes.NewReader(inp), s) 8969 return err 8970} 8971 8972var ( 8973 _ encoding.BinaryMarshaler = (*ManageOfferEffect)(nil) 8974 _ encoding.BinaryUnmarshaler = (*ManageOfferEffect)(nil) 8975) 8976 8977// ManageOfferSuccessResultOffer is an XDR NestedUnion defines as: 8978// 8979// union switch (ManageOfferEffect effect) 8980// { 8981// case MANAGE_OFFER_CREATED: 8982// case MANAGE_OFFER_UPDATED: 8983// OfferEntry offer; 8984// default: 8985// void; 8986// } 8987// 8988type ManageOfferSuccessResultOffer struct { 8989 Effect ManageOfferEffect 8990 Offer *OfferEntry 8991} 8992 8993// SwitchFieldName returns the field name in which this union's 8994// discriminant is stored 8995func (u ManageOfferSuccessResultOffer) SwitchFieldName() string { 8996 return "Effect" 8997} 8998 8999// ArmForSwitch returns which field name should be used for storing 9000// the value for an instance of ManageOfferSuccessResultOffer 9001func (u ManageOfferSuccessResultOffer) ArmForSwitch(sw int32) (string, bool) { 9002 switch ManageOfferEffect(sw) { 9003 case ManageOfferEffectManageOfferCreated: 9004 return "Offer", true 9005 case ManageOfferEffectManageOfferUpdated: 9006 return "Offer", true 9007 default: 9008 return "", true 9009 } 9010} 9011 9012// NewManageOfferSuccessResultOffer creates a new ManageOfferSuccessResultOffer. 9013func NewManageOfferSuccessResultOffer(effect ManageOfferEffect, value interface{}) (result ManageOfferSuccessResultOffer, err error) { 9014 result.Effect = effect 9015 switch ManageOfferEffect(effect) { 9016 case ManageOfferEffectManageOfferCreated: 9017 tv, ok := value.(OfferEntry) 9018 if !ok { 9019 err = fmt.Errorf("invalid value, must be OfferEntry") 9020 return 9021 } 9022 result.Offer = &tv 9023 case ManageOfferEffectManageOfferUpdated: 9024 tv, ok := value.(OfferEntry) 9025 if !ok { 9026 err = fmt.Errorf("invalid value, must be OfferEntry") 9027 return 9028 } 9029 result.Offer = &tv 9030 default: 9031 // void 9032 } 9033 return 9034} 9035 9036// MustOffer retrieves the Offer value from the union, 9037// panicing if the value is not set. 9038func (u ManageOfferSuccessResultOffer) MustOffer() OfferEntry { 9039 val, ok := u.GetOffer() 9040 9041 if !ok { 9042 panic("arm Offer is not set") 9043 } 9044 9045 return val 9046} 9047 9048// GetOffer retrieves the Offer value from the union, 9049// returning ok if the union's switch indicated the value is valid. 9050func (u ManageOfferSuccessResultOffer) GetOffer() (result OfferEntry, ok bool) { 9051 armName, _ := u.ArmForSwitch(int32(u.Effect)) 9052 9053 if armName == "Offer" { 9054 result = *u.Offer 9055 ok = true 9056 } 9057 9058 return 9059} 9060 9061// MarshalBinary implements encoding.BinaryMarshaler. 9062func (s ManageOfferSuccessResultOffer) MarshalBinary() ([]byte, error) { 9063 b := new(bytes.Buffer) 9064 _, err := Marshal(b, s) 9065 return b.Bytes(), err 9066} 9067 9068// UnmarshalBinary implements encoding.BinaryUnmarshaler. 9069func (s *ManageOfferSuccessResultOffer) UnmarshalBinary(inp []byte) error { 9070 _, err := Unmarshal(bytes.NewReader(inp), s) 9071 return err 9072} 9073 9074var ( 9075 _ encoding.BinaryMarshaler = (*ManageOfferSuccessResultOffer)(nil) 9076 _ encoding.BinaryUnmarshaler = (*ManageOfferSuccessResultOffer)(nil) 9077) 9078 9079// ManageOfferSuccessResult is an XDR Struct defines as: 9080// 9081// struct ManageOfferSuccessResult 9082// { 9083// // offers that got claimed while creating this offer 9084// ClaimOfferAtom offersClaimed<>; 9085// 9086// union switch (ManageOfferEffect effect) 9087// { 9088// case MANAGE_OFFER_CREATED: 9089// case MANAGE_OFFER_UPDATED: 9090// OfferEntry offer; 9091// default: 9092// void; 9093// } 9094// offer; 9095// }; 9096// 9097type ManageOfferSuccessResult struct { 9098 OffersClaimed []ClaimOfferAtom 9099 Offer ManageOfferSuccessResultOffer 9100} 9101 9102// MarshalBinary implements encoding.BinaryMarshaler. 9103func (s ManageOfferSuccessResult) MarshalBinary() ([]byte, error) { 9104 b := new(bytes.Buffer) 9105 _, err := Marshal(b, s) 9106 return b.Bytes(), err 9107} 9108 9109// UnmarshalBinary implements encoding.BinaryUnmarshaler. 9110func (s *ManageOfferSuccessResult) UnmarshalBinary(inp []byte) error { 9111 _, err := Unmarshal(bytes.NewReader(inp), s) 9112 return err 9113} 9114 9115var ( 9116 _ encoding.BinaryMarshaler = (*ManageOfferSuccessResult)(nil) 9117 _ encoding.BinaryUnmarshaler = (*ManageOfferSuccessResult)(nil) 9118) 9119 9120// ManageSellOfferResult is an XDR Union defines as: 9121// 9122// union ManageSellOfferResult switch (ManageSellOfferResultCode code) 9123// { 9124// case MANAGE_SELL_OFFER_SUCCESS: 9125// ManageOfferSuccessResult success; 9126// default: 9127// void; 9128// }; 9129// 9130type ManageSellOfferResult struct { 9131 Code ManageSellOfferResultCode 9132 Success *ManageOfferSuccessResult 9133} 9134 9135// SwitchFieldName returns the field name in which this union's 9136// discriminant is stored 9137func (u ManageSellOfferResult) SwitchFieldName() string { 9138 return "Code" 9139} 9140 9141// ArmForSwitch returns which field name should be used for storing 9142// the value for an instance of ManageSellOfferResult 9143func (u ManageSellOfferResult) ArmForSwitch(sw int32) (string, bool) { 9144 switch ManageSellOfferResultCode(sw) { 9145 case ManageSellOfferResultCodeManageSellOfferSuccess: 9146 return "Success", true 9147 default: 9148 return "", true 9149 } 9150} 9151 9152// NewManageSellOfferResult creates a new ManageSellOfferResult. 9153func NewManageSellOfferResult(code ManageSellOfferResultCode, value interface{}) (result ManageSellOfferResult, err error) { 9154 result.Code = code 9155 switch ManageSellOfferResultCode(code) { 9156 case ManageSellOfferResultCodeManageSellOfferSuccess: 9157 tv, ok := value.(ManageOfferSuccessResult) 9158 if !ok { 9159 err = fmt.Errorf("invalid value, must be ManageOfferSuccessResult") 9160 return 9161 } 9162 result.Success = &tv 9163 default: 9164 // void 9165 } 9166 return 9167} 9168 9169// MustSuccess retrieves the Success value from the union, 9170// panicing if the value is not set. 9171func (u ManageSellOfferResult) MustSuccess() ManageOfferSuccessResult { 9172 val, ok := u.GetSuccess() 9173 9174 if !ok { 9175 panic("arm Success is not set") 9176 } 9177 9178 return val 9179} 9180 9181// GetSuccess retrieves the Success value from the union, 9182// returning ok if the union's switch indicated the value is valid. 9183func (u ManageSellOfferResult) GetSuccess() (result ManageOfferSuccessResult, ok bool) { 9184 armName, _ := u.ArmForSwitch(int32(u.Code)) 9185 9186 if armName == "Success" { 9187 result = *u.Success 9188 ok = true 9189 } 9190 9191 return 9192} 9193 9194// MarshalBinary implements encoding.BinaryMarshaler. 9195func (s ManageSellOfferResult) MarshalBinary() ([]byte, error) { 9196 b := new(bytes.Buffer) 9197 _, err := Marshal(b, s) 9198 return b.Bytes(), err 9199} 9200 9201// UnmarshalBinary implements encoding.BinaryUnmarshaler. 9202func (s *ManageSellOfferResult) UnmarshalBinary(inp []byte) error { 9203 _, err := Unmarshal(bytes.NewReader(inp), s) 9204 return err 9205} 9206 9207var ( 9208 _ encoding.BinaryMarshaler = (*ManageSellOfferResult)(nil) 9209 _ encoding.BinaryUnmarshaler = (*ManageSellOfferResult)(nil) 9210) 9211 9212// ManageBuyOfferResultCode is an XDR Enum defines as: 9213// 9214// enum ManageBuyOfferResultCode 9215// { 9216// // codes considered as "success" for the operation 9217// MANAGE_BUY_OFFER_SUCCESS = 0, 9218// 9219// // codes considered as "failure" for the operation 9220// MANAGE_BUY_OFFER_MALFORMED = -1, // generated offer would be invalid 9221// MANAGE_BUY_OFFER_SELL_NO_TRUST = -2, // no trust line for what we're selling 9222// MANAGE_BUY_OFFER_BUY_NO_TRUST = -3, // no trust line for what we're buying 9223// MANAGE_BUY_OFFER_SELL_NOT_AUTHORIZED = -4, // not authorized to sell 9224// MANAGE_BUY_OFFER_BUY_NOT_AUTHORIZED = -5, // not authorized to buy 9225// MANAGE_BUY_OFFER_LINE_FULL = -6, // can't receive more of what it's buying 9226// MANAGE_BUY_OFFER_UNDERFUNDED = -7, // doesn't hold what it's trying to sell 9227// MANAGE_BUY_OFFER_CROSS_SELF = -8, // would cross an offer from the same user 9228// MANAGE_BUY_OFFER_SELL_NO_ISSUER = -9, // no issuer for what we're selling 9229// MANAGE_BUY_OFFER_BUY_NO_ISSUER = -10, // no issuer for what we're buying 9230// 9231// // update errors 9232// MANAGE_BUY_OFFER_NOT_FOUND = -11, // offerID does not match an existing offer 9233// 9234// MANAGE_BUY_OFFER_LOW_RESERVE = -12 // not enough funds to create a new Offer 9235// }; 9236// 9237type ManageBuyOfferResultCode int32 9238 9239const ( 9240 ManageBuyOfferResultCodeManageBuyOfferSuccess ManageBuyOfferResultCode = 0 9241 ManageBuyOfferResultCodeManageBuyOfferMalformed ManageBuyOfferResultCode = -1 9242 ManageBuyOfferResultCodeManageBuyOfferSellNoTrust ManageBuyOfferResultCode = -2 9243 ManageBuyOfferResultCodeManageBuyOfferBuyNoTrust ManageBuyOfferResultCode = -3 9244 ManageBuyOfferResultCodeManageBuyOfferSellNotAuthorized ManageBuyOfferResultCode = -4 9245 ManageBuyOfferResultCodeManageBuyOfferBuyNotAuthorized ManageBuyOfferResultCode = -5 9246 ManageBuyOfferResultCodeManageBuyOfferLineFull ManageBuyOfferResultCode = -6 9247 ManageBuyOfferResultCodeManageBuyOfferUnderfunded ManageBuyOfferResultCode = -7 9248 ManageBuyOfferResultCodeManageBuyOfferCrossSelf ManageBuyOfferResultCode = -8 9249 ManageBuyOfferResultCodeManageBuyOfferSellNoIssuer ManageBuyOfferResultCode = -9 9250 ManageBuyOfferResultCodeManageBuyOfferBuyNoIssuer ManageBuyOfferResultCode = -10 9251 ManageBuyOfferResultCodeManageBuyOfferNotFound ManageBuyOfferResultCode = -11 9252 ManageBuyOfferResultCodeManageBuyOfferLowReserve ManageBuyOfferResultCode = -12 9253) 9254 9255var manageBuyOfferResultCodeMap = map[int32]string{ 9256 0: "ManageBuyOfferResultCodeManageBuyOfferSuccess", 9257 -1: "ManageBuyOfferResultCodeManageBuyOfferMalformed", 9258 -2: "ManageBuyOfferResultCodeManageBuyOfferSellNoTrust", 9259 -3: "ManageBuyOfferResultCodeManageBuyOfferBuyNoTrust", 9260 -4: "ManageBuyOfferResultCodeManageBuyOfferSellNotAuthorized", 9261 -5: "ManageBuyOfferResultCodeManageBuyOfferBuyNotAuthorized", 9262 -6: "ManageBuyOfferResultCodeManageBuyOfferLineFull", 9263 -7: "ManageBuyOfferResultCodeManageBuyOfferUnderfunded", 9264 -8: "ManageBuyOfferResultCodeManageBuyOfferCrossSelf", 9265 -9: "ManageBuyOfferResultCodeManageBuyOfferSellNoIssuer", 9266 -10: "ManageBuyOfferResultCodeManageBuyOfferBuyNoIssuer", 9267 -11: "ManageBuyOfferResultCodeManageBuyOfferNotFound", 9268 -12: "ManageBuyOfferResultCodeManageBuyOfferLowReserve", 9269} 9270 9271// ValidEnum validates a proposed value for this enum. Implements 9272// the Enum interface for ManageBuyOfferResultCode 9273func (e ManageBuyOfferResultCode) ValidEnum(v int32) bool { 9274 _, ok := manageBuyOfferResultCodeMap[v] 9275 return ok 9276} 9277 9278// String returns the name of `e` 9279func (e ManageBuyOfferResultCode) String() string { 9280 name, _ := manageBuyOfferResultCodeMap[int32(e)] 9281 return name 9282} 9283 9284// MarshalBinary implements encoding.BinaryMarshaler. 9285func (s ManageBuyOfferResultCode) MarshalBinary() ([]byte, error) { 9286 b := new(bytes.Buffer) 9287 _, err := Marshal(b, s) 9288 return b.Bytes(), err 9289} 9290 9291// UnmarshalBinary implements encoding.BinaryUnmarshaler. 9292func (s *ManageBuyOfferResultCode) UnmarshalBinary(inp []byte) error { 9293 _, err := Unmarshal(bytes.NewReader(inp), s) 9294 return err 9295} 9296 9297var ( 9298 _ encoding.BinaryMarshaler = (*ManageBuyOfferResultCode)(nil) 9299 _ encoding.BinaryUnmarshaler = (*ManageBuyOfferResultCode)(nil) 9300) 9301 9302// ManageBuyOfferResult is an XDR Union defines as: 9303// 9304// union ManageBuyOfferResult switch (ManageBuyOfferResultCode code) 9305// { 9306// case MANAGE_BUY_OFFER_SUCCESS: 9307// ManageOfferSuccessResult success; 9308// default: 9309// void; 9310// }; 9311// 9312type ManageBuyOfferResult struct { 9313 Code ManageBuyOfferResultCode 9314 Success *ManageOfferSuccessResult 9315} 9316 9317// SwitchFieldName returns the field name in which this union's 9318// discriminant is stored 9319func (u ManageBuyOfferResult) SwitchFieldName() string { 9320 return "Code" 9321} 9322 9323// ArmForSwitch returns which field name should be used for storing 9324// the value for an instance of ManageBuyOfferResult 9325func (u ManageBuyOfferResult) ArmForSwitch(sw int32) (string, bool) { 9326 switch ManageBuyOfferResultCode(sw) { 9327 case ManageBuyOfferResultCodeManageBuyOfferSuccess: 9328 return "Success", true 9329 default: 9330 return "", true 9331 } 9332} 9333 9334// NewManageBuyOfferResult creates a new ManageBuyOfferResult. 9335func NewManageBuyOfferResult(code ManageBuyOfferResultCode, value interface{}) (result ManageBuyOfferResult, err error) { 9336 result.Code = code 9337 switch ManageBuyOfferResultCode(code) { 9338 case ManageBuyOfferResultCodeManageBuyOfferSuccess: 9339 tv, ok := value.(ManageOfferSuccessResult) 9340 if !ok { 9341 err = fmt.Errorf("invalid value, must be ManageOfferSuccessResult") 9342 return 9343 } 9344 result.Success = &tv 9345 default: 9346 // void 9347 } 9348 return 9349} 9350 9351// MustSuccess retrieves the Success value from the union, 9352// panicing if the value is not set. 9353func (u ManageBuyOfferResult) MustSuccess() ManageOfferSuccessResult { 9354 val, ok := u.GetSuccess() 9355 9356 if !ok { 9357 panic("arm Success is not set") 9358 } 9359 9360 return val 9361} 9362 9363// GetSuccess retrieves the Success value from the union, 9364// returning ok if the union's switch indicated the value is valid. 9365func (u ManageBuyOfferResult) GetSuccess() (result ManageOfferSuccessResult, ok bool) { 9366 armName, _ := u.ArmForSwitch(int32(u.Code)) 9367 9368 if armName == "Success" { 9369 result = *u.Success 9370 ok = true 9371 } 9372 9373 return 9374} 9375 9376// MarshalBinary implements encoding.BinaryMarshaler. 9377func (s ManageBuyOfferResult) MarshalBinary() ([]byte, error) { 9378 b := new(bytes.Buffer) 9379 _, err := Marshal(b, s) 9380 return b.Bytes(), err 9381} 9382 9383// UnmarshalBinary implements encoding.BinaryUnmarshaler. 9384func (s *ManageBuyOfferResult) UnmarshalBinary(inp []byte) error { 9385 _, err := Unmarshal(bytes.NewReader(inp), s) 9386 return err 9387} 9388 9389var ( 9390 _ encoding.BinaryMarshaler = (*ManageBuyOfferResult)(nil) 9391 _ encoding.BinaryUnmarshaler = (*ManageBuyOfferResult)(nil) 9392) 9393 9394// SetOptionsResultCode is an XDR Enum defines as: 9395// 9396// enum SetOptionsResultCode 9397// { 9398// // codes considered as "success" for the operation 9399// SET_OPTIONS_SUCCESS = 0, 9400// // codes considered as "failure" for the operation 9401// SET_OPTIONS_LOW_RESERVE = -1, // not enough funds to add a signer 9402// SET_OPTIONS_TOO_MANY_SIGNERS = -2, // max number of signers already reached 9403// SET_OPTIONS_BAD_FLAGS = -3, // invalid combination of clear/set flags 9404// SET_OPTIONS_INVALID_INFLATION = -4, // inflation account does not exist 9405// SET_OPTIONS_CANT_CHANGE = -5, // can no longer change this option 9406// SET_OPTIONS_UNKNOWN_FLAG = -6, // can't set an unknown flag 9407// SET_OPTIONS_THRESHOLD_OUT_OF_RANGE = -7, // bad value for weight/threshold 9408// SET_OPTIONS_BAD_SIGNER = -8, // signer cannot be masterkey 9409// SET_OPTIONS_INVALID_HOME_DOMAIN = -9 // malformed home domain 9410// }; 9411// 9412type SetOptionsResultCode int32 9413 9414const ( 9415 SetOptionsResultCodeSetOptionsSuccess SetOptionsResultCode = 0 9416 SetOptionsResultCodeSetOptionsLowReserve SetOptionsResultCode = -1 9417 SetOptionsResultCodeSetOptionsTooManySigners SetOptionsResultCode = -2 9418 SetOptionsResultCodeSetOptionsBadFlags SetOptionsResultCode = -3 9419 SetOptionsResultCodeSetOptionsInvalidInflation SetOptionsResultCode = -4 9420 SetOptionsResultCodeSetOptionsCantChange SetOptionsResultCode = -5 9421 SetOptionsResultCodeSetOptionsUnknownFlag SetOptionsResultCode = -6 9422 SetOptionsResultCodeSetOptionsThresholdOutOfRange SetOptionsResultCode = -7 9423 SetOptionsResultCodeSetOptionsBadSigner SetOptionsResultCode = -8 9424 SetOptionsResultCodeSetOptionsInvalidHomeDomain SetOptionsResultCode = -9 9425) 9426 9427var setOptionsResultCodeMap = map[int32]string{ 9428 0: "SetOptionsResultCodeSetOptionsSuccess", 9429 -1: "SetOptionsResultCodeSetOptionsLowReserve", 9430 -2: "SetOptionsResultCodeSetOptionsTooManySigners", 9431 -3: "SetOptionsResultCodeSetOptionsBadFlags", 9432 -4: "SetOptionsResultCodeSetOptionsInvalidInflation", 9433 -5: "SetOptionsResultCodeSetOptionsCantChange", 9434 -6: "SetOptionsResultCodeSetOptionsUnknownFlag", 9435 -7: "SetOptionsResultCodeSetOptionsThresholdOutOfRange", 9436 -8: "SetOptionsResultCodeSetOptionsBadSigner", 9437 -9: "SetOptionsResultCodeSetOptionsInvalidHomeDomain", 9438} 9439 9440// ValidEnum validates a proposed value for this enum. Implements 9441// the Enum interface for SetOptionsResultCode 9442func (e SetOptionsResultCode) ValidEnum(v int32) bool { 9443 _, ok := setOptionsResultCodeMap[v] 9444 return ok 9445} 9446 9447// String returns the name of `e` 9448func (e SetOptionsResultCode) String() string { 9449 name, _ := setOptionsResultCodeMap[int32(e)] 9450 return name 9451} 9452 9453// MarshalBinary implements encoding.BinaryMarshaler. 9454func (s SetOptionsResultCode) MarshalBinary() ([]byte, error) { 9455 b := new(bytes.Buffer) 9456 _, err := Marshal(b, s) 9457 return b.Bytes(), err 9458} 9459 9460// UnmarshalBinary implements encoding.BinaryUnmarshaler. 9461func (s *SetOptionsResultCode) UnmarshalBinary(inp []byte) error { 9462 _, err := Unmarshal(bytes.NewReader(inp), s) 9463 return err 9464} 9465 9466var ( 9467 _ encoding.BinaryMarshaler = (*SetOptionsResultCode)(nil) 9468 _ encoding.BinaryUnmarshaler = (*SetOptionsResultCode)(nil) 9469) 9470 9471// SetOptionsResult is an XDR Union defines as: 9472// 9473// union SetOptionsResult switch (SetOptionsResultCode code) 9474// { 9475// case SET_OPTIONS_SUCCESS: 9476// void; 9477// default: 9478// void; 9479// }; 9480// 9481type SetOptionsResult struct { 9482 Code SetOptionsResultCode 9483} 9484 9485// SwitchFieldName returns the field name in which this union's 9486// discriminant is stored 9487func (u SetOptionsResult) SwitchFieldName() string { 9488 return "Code" 9489} 9490 9491// ArmForSwitch returns which field name should be used for storing 9492// the value for an instance of SetOptionsResult 9493func (u SetOptionsResult) ArmForSwitch(sw int32) (string, bool) { 9494 switch SetOptionsResultCode(sw) { 9495 case SetOptionsResultCodeSetOptionsSuccess: 9496 return "", true 9497 default: 9498 return "", true 9499 } 9500} 9501 9502// NewSetOptionsResult creates a new SetOptionsResult. 9503func NewSetOptionsResult(code SetOptionsResultCode, value interface{}) (result SetOptionsResult, err error) { 9504 result.Code = code 9505 switch SetOptionsResultCode(code) { 9506 case SetOptionsResultCodeSetOptionsSuccess: 9507 // void 9508 default: 9509 // void 9510 } 9511 return 9512} 9513 9514// MarshalBinary implements encoding.BinaryMarshaler. 9515func (s SetOptionsResult) MarshalBinary() ([]byte, error) { 9516 b := new(bytes.Buffer) 9517 _, err := Marshal(b, s) 9518 return b.Bytes(), err 9519} 9520 9521// UnmarshalBinary implements encoding.BinaryUnmarshaler. 9522func (s *SetOptionsResult) UnmarshalBinary(inp []byte) error { 9523 _, err := Unmarshal(bytes.NewReader(inp), s) 9524 return err 9525} 9526 9527var ( 9528 _ encoding.BinaryMarshaler = (*SetOptionsResult)(nil) 9529 _ encoding.BinaryUnmarshaler = (*SetOptionsResult)(nil) 9530) 9531 9532// ChangeTrustResultCode is an XDR Enum defines as: 9533// 9534// enum ChangeTrustResultCode 9535// { 9536// // codes considered as "success" for the operation 9537// CHANGE_TRUST_SUCCESS = 0, 9538// // codes considered as "failure" for the operation 9539// CHANGE_TRUST_MALFORMED = -1, // bad input 9540// CHANGE_TRUST_NO_ISSUER = -2, // could not find issuer 9541// CHANGE_TRUST_INVALID_LIMIT = -3, // cannot drop limit below balance 9542// // cannot create with a limit of 0 9543// CHANGE_TRUST_LOW_RESERVE = 9544// -4, // not enough funds to create a new trust line, 9545// CHANGE_TRUST_SELF_NOT_ALLOWED = -5 // trusting self is not allowed 9546// }; 9547// 9548type ChangeTrustResultCode int32 9549 9550const ( 9551 ChangeTrustResultCodeChangeTrustSuccess ChangeTrustResultCode = 0 9552 ChangeTrustResultCodeChangeTrustMalformed ChangeTrustResultCode = -1 9553 ChangeTrustResultCodeChangeTrustNoIssuer ChangeTrustResultCode = -2 9554 ChangeTrustResultCodeChangeTrustInvalidLimit ChangeTrustResultCode = -3 9555 ChangeTrustResultCodeChangeTrustLowReserve ChangeTrustResultCode = -4 9556 ChangeTrustResultCodeChangeTrustSelfNotAllowed ChangeTrustResultCode = -5 9557) 9558 9559var changeTrustResultCodeMap = map[int32]string{ 9560 0: "ChangeTrustResultCodeChangeTrustSuccess", 9561 -1: "ChangeTrustResultCodeChangeTrustMalformed", 9562 -2: "ChangeTrustResultCodeChangeTrustNoIssuer", 9563 -3: "ChangeTrustResultCodeChangeTrustInvalidLimit", 9564 -4: "ChangeTrustResultCodeChangeTrustLowReserve", 9565 -5: "ChangeTrustResultCodeChangeTrustSelfNotAllowed", 9566} 9567 9568// ValidEnum validates a proposed value for this enum. Implements 9569// the Enum interface for ChangeTrustResultCode 9570func (e ChangeTrustResultCode) ValidEnum(v int32) bool { 9571 _, ok := changeTrustResultCodeMap[v] 9572 return ok 9573} 9574 9575// String returns the name of `e` 9576func (e ChangeTrustResultCode) String() string { 9577 name, _ := changeTrustResultCodeMap[int32(e)] 9578 return name 9579} 9580 9581// MarshalBinary implements encoding.BinaryMarshaler. 9582func (s ChangeTrustResultCode) MarshalBinary() ([]byte, error) { 9583 b := new(bytes.Buffer) 9584 _, err := Marshal(b, s) 9585 return b.Bytes(), err 9586} 9587 9588// UnmarshalBinary implements encoding.BinaryUnmarshaler. 9589func (s *ChangeTrustResultCode) UnmarshalBinary(inp []byte) error { 9590 _, err := Unmarshal(bytes.NewReader(inp), s) 9591 return err 9592} 9593 9594var ( 9595 _ encoding.BinaryMarshaler = (*ChangeTrustResultCode)(nil) 9596 _ encoding.BinaryUnmarshaler = (*ChangeTrustResultCode)(nil) 9597) 9598 9599// ChangeTrustResult is an XDR Union defines as: 9600// 9601// union ChangeTrustResult switch (ChangeTrustResultCode code) 9602// { 9603// case CHANGE_TRUST_SUCCESS: 9604// void; 9605// default: 9606// void; 9607// }; 9608// 9609type ChangeTrustResult struct { 9610 Code ChangeTrustResultCode 9611} 9612 9613// SwitchFieldName returns the field name in which this union's 9614// discriminant is stored 9615func (u ChangeTrustResult) SwitchFieldName() string { 9616 return "Code" 9617} 9618 9619// ArmForSwitch returns which field name should be used for storing 9620// the value for an instance of ChangeTrustResult 9621func (u ChangeTrustResult) ArmForSwitch(sw int32) (string, bool) { 9622 switch ChangeTrustResultCode(sw) { 9623 case ChangeTrustResultCodeChangeTrustSuccess: 9624 return "", true 9625 default: 9626 return "", true 9627 } 9628} 9629 9630// NewChangeTrustResult creates a new ChangeTrustResult. 9631func NewChangeTrustResult(code ChangeTrustResultCode, value interface{}) (result ChangeTrustResult, err error) { 9632 result.Code = code 9633 switch ChangeTrustResultCode(code) { 9634 case ChangeTrustResultCodeChangeTrustSuccess: 9635 // void 9636 default: 9637 // void 9638 } 9639 return 9640} 9641 9642// MarshalBinary implements encoding.BinaryMarshaler. 9643func (s ChangeTrustResult) MarshalBinary() ([]byte, error) { 9644 b := new(bytes.Buffer) 9645 _, err := Marshal(b, s) 9646 return b.Bytes(), err 9647} 9648 9649// UnmarshalBinary implements encoding.BinaryUnmarshaler. 9650func (s *ChangeTrustResult) UnmarshalBinary(inp []byte) error { 9651 _, err := Unmarshal(bytes.NewReader(inp), s) 9652 return err 9653} 9654 9655var ( 9656 _ encoding.BinaryMarshaler = (*ChangeTrustResult)(nil) 9657 _ encoding.BinaryUnmarshaler = (*ChangeTrustResult)(nil) 9658) 9659 9660// AllowTrustResultCode is an XDR Enum defines as: 9661// 9662// enum AllowTrustResultCode 9663// { 9664// // codes considered as "success" for the operation 9665// ALLOW_TRUST_SUCCESS = 0, 9666// // codes considered as "failure" for the operation 9667// ALLOW_TRUST_MALFORMED = -1, // asset is not ASSET_TYPE_ALPHANUM 9668// ALLOW_TRUST_NO_TRUST_LINE = -2, // trustor does not have a trustline 9669// // source account does not require trust 9670// ALLOW_TRUST_TRUST_NOT_REQUIRED = -3, 9671// ALLOW_TRUST_CANT_REVOKE = -4, // source account can't revoke trust, 9672// ALLOW_TRUST_SELF_NOT_ALLOWED = -5 // trusting self is not allowed 9673// }; 9674// 9675type AllowTrustResultCode int32 9676 9677const ( 9678 AllowTrustResultCodeAllowTrustSuccess AllowTrustResultCode = 0 9679 AllowTrustResultCodeAllowTrustMalformed AllowTrustResultCode = -1 9680 AllowTrustResultCodeAllowTrustNoTrustLine AllowTrustResultCode = -2 9681 AllowTrustResultCodeAllowTrustTrustNotRequired AllowTrustResultCode = -3 9682 AllowTrustResultCodeAllowTrustCantRevoke AllowTrustResultCode = -4 9683 AllowTrustResultCodeAllowTrustSelfNotAllowed AllowTrustResultCode = -5 9684) 9685 9686var allowTrustResultCodeMap = map[int32]string{ 9687 0: "AllowTrustResultCodeAllowTrustSuccess", 9688 -1: "AllowTrustResultCodeAllowTrustMalformed", 9689 -2: "AllowTrustResultCodeAllowTrustNoTrustLine", 9690 -3: "AllowTrustResultCodeAllowTrustTrustNotRequired", 9691 -4: "AllowTrustResultCodeAllowTrustCantRevoke", 9692 -5: "AllowTrustResultCodeAllowTrustSelfNotAllowed", 9693} 9694 9695// ValidEnum validates a proposed value for this enum. Implements 9696// the Enum interface for AllowTrustResultCode 9697func (e AllowTrustResultCode) ValidEnum(v int32) bool { 9698 _, ok := allowTrustResultCodeMap[v] 9699 return ok 9700} 9701 9702// String returns the name of `e` 9703func (e AllowTrustResultCode) String() string { 9704 name, _ := allowTrustResultCodeMap[int32(e)] 9705 return name 9706} 9707 9708// MarshalBinary implements encoding.BinaryMarshaler. 9709func (s AllowTrustResultCode) MarshalBinary() ([]byte, error) { 9710 b := new(bytes.Buffer) 9711 _, err := Marshal(b, s) 9712 return b.Bytes(), err 9713} 9714 9715// UnmarshalBinary implements encoding.BinaryUnmarshaler. 9716func (s *AllowTrustResultCode) UnmarshalBinary(inp []byte) error { 9717 _, err := Unmarshal(bytes.NewReader(inp), s) 9718 return err 9719} 9720 9721var ( 9722 _ encoding.BinaryMarshaler = (*AllowTrustResultCode)(nil) 9723 _ encoding.BinaryUnmarshaler = (*AllowTrustResultCode)(nil) 9724) 9725 9726// AllowTrustResult is an XDR Union defines as: 9727// 9728// union AllowTrustResult switch (AllowTrustResultCode code) 9729// { 9730// case ALLOW_TRUST_SUCCESS: 9731// void; 9732// default: 9733// void; 9734// }; 9735// 9736type AllowTrustResult struct { 9737 Code AllowTrustResultCode 9738} 9739 9740// SwitchFieldName returns the field name in which this union's 9741// discriminant is stored 9742func (u AllowTrustResult) SwitchFieldName() string { 9743 return "Code" 9744} 9745 9746// ArmForSwitch returns which field name should be used for storing 9747// the value for an instance of AllowTrustResult 9748func (u AllowTrustResult) ArmForSwitch(sw int32) (string, bool) { 9749 switch AllowTrustResultCode(sw) { 9750 case AllowTrustResultCodeAllowTrustSuccess: 9751 return "", true 9752 default: 9753 return "", true 9754 } 9755} 9756 9757// NewAllowTrustResult creates a new AllowTrustResult. 9758func NewAllowTrustResult(code AllowTrustResultCode, value interface{}) (result AllowTrustResult, err error) { 9759 result.Code = code 9760 switch AllowTrustResultCode(code) { 9761 case AllowTrustResultCodeAllowTrustSuccess: 9762 // void 9763 default: 9764 // void 9765 } 9766 return 9767} 9768 9769// MarshalBinary implements encoding.BinaryMarshaler. 9770func (s AllowTrustResult) MarshalBinary() ([]byte, error) { 9771 b := new(bytes.Buffer) 9772 _, err := Marshal(b, s) 9773 return b.Bytes(), err 9774} 9775 9776// UnmarshalBinary implements encoding.BinaryUnmarshaler. 9777func (s *AllowTrustResult) UnmarshalBinary(inp []byte) error { 9778 _, err := Unmarshal(bytes.NewReader(inp), s) 9779 return err 9780} 9781 9782var ( 9783 _ encoding.BinaryMarshaler = (*AllowTrustResult)(nil) 9784 _ encoding.BinaryUnmarshaler = (*AllowTrustResult)(nil) 9785) 9786 9787// AccountMergeResultCode is an XDR Enum defines as: 9788// 9789// enum AccountMergeResultCode 9790// { 9791// // codes considered as "success" for the operation 9792// ACCOUNT_MERGE_SUCCESS = 0, 9793// // codes considered as "failure" for the operation 9794// ACCOUNT_MERGE_MALFORMED = -1, // can't merge onto itself 9795// ACCOUNT_MERGE_NO_ACCOUNT = -2, // destination does not exist 9796// ACCOUNT_MERGE_IMMUTABLE_SET = -3, // source account has AUTH_IMMUTABLE set 9797// ACCOUNT_MERGE_HAS_SUB_ENTRIES = -4, // account has trust lines/offers 9798// ACCOUNT_MERGE_SEQNUM_TOO_FAR = -5, // sequence number is over max allowed 9799// ACCOUNT_MERGE_DEST_FULL = -6 // can't add source balance to 9800// // destination balance 9801// }; 9802// 9803type AccountMergeResultCode int32 9804 9805const ( 9806 AccountMergeResultCodeAccountMergeSuccess AccountMergeResultCode = 0 9807 AccountMergeResultCodeAccountMergeMalformed AccountMergeResultCode = -1 9808 AccountMergeResultCodeAccountMergeNoAccount AccountMergeResultCode = -2 9809 AccountMergeResultCodeAccountMergeImmutableSet AccountMergeResultCode = -3 9810 AccountMergeResultCodeAccountMergeHasSubEntries AccountMergeResultCode = -4 9811 AccountMergeResultCodeAccountMergeSeqnumTooFar AccountMergeResultCode = -5 9812 AccountMergeResultCodeAccountMergeDestFull AccountMergeResultCode = -6 9813) 9814 9815var accountMergeResultCodeMap = map[int32]string{ 9816 0: "AccountMergeResultCodeAccountMergeSuccess", 9817 -1: "AccountMergeResultCodeAccountMergeMalformed", 9818 -2: "AccountMergeResultCodeAccountMergeNoAccount", 9819 -3: "AccountMergeResultCodeAccountMergeImmutableSet", 9820 -4: "AccountMergeResultCodeAccountMergeHasSubEntries", 9821 -5: "AccountMergeResultCodeAccountMergeSeqnumTooFar", 9822 -6: "AccountMergeResultCodeAccountMergeDestFull", 9823} 9824 9825// ValidEnum validates a proposed value for this enum. Implements 9826// the Enum interface for AccountMergeResultCode 9827func (e AccountMergeResultCode) ValidEnum(v int32) bool { 9828 _, ok := accountMergeResultCodeMap[v] 9829 return ok 9830} 9831 9832// String returns the name of `e` 9833func (e AccountMergeResultCode) String() string { 9834 name, _ := accountMergeResultCodeMap[int32(e)] 9835 return name 9836} 9837 9838// MarshalBinary implements encoding.BinaryMarshaler. 9839func (s AccountMergeResultCode) MarshalBinary() ([]byte, error) { 9840 b := new(bytes.Buffer) 9841 _, err := Marshal(b, s) 9842 return b.Bytes(), err 9843} 9844 9845// UnmarshalBinary implements encoding.BinaryUnmarshaler. 9846func (s *AccountMergeResultCode) UnmarshalBinary(inp []byte) error { 9847 _, err := Unmarshal(bytes.NewReader(inp), s) 9848 return err 9849} 9850 9851var ( 9852 _ encoding.BinaryMarshaler = (*AccountMergeResultCode)(nil) 9853 _ encoding.BinaryUnmarshaler = (*AccountMergeResultCode)(nil) 9854) 9855 9856// AccountMergeResult is an XDR Union defines as: 9857// 9858// union AccountMergeResult switch (AccountMergeResultCode code) 9859// { 9860// case ACCOUNT_MERGE_SUCCESS: 9861// int64 sourceAccountBalance; // how much got transfered from source account 9862// default: 9863// void; 9864// }; 9865// 9866type AccountMergeResult struct { 9867 Code AccountMergeResultCode 9868 SourceAccountBalance *Int64 9869} 9870 9871// SwitchFieldName returns the field name in which this union's 9872// discriminant is stored 9873func (u AccountMergeResult) SwitchFieldName() string { 9874 return "Code" 9875} 9876 9877// ArmForSwitch returns which field name should be used for storing 9878// the value for an instance of AccountMergeResult 9879func (u AccountMergeResult) ArmForSwitch(sw int32) (string, bool) { 9880 switch AccountMergeResultCode(sw) { 9881 case AccountMergeResultCodeAccountMergeSuccess: 9882 return "SourceAccountBalance", true 9883 default: 9884 return "", true 9885 } 9886} 9887 9888// NewAccountMergeResult creates a new AccountMergeResult. 9889func NewAccountMergeResult(code AccountMergeResultCode, value interface{}) (result AccountMergeResult, err error) { 9890 result.Code = code 9891 switch AccountMergeResultCode(code) { 9892 case AccountMergeResultCodeAccountMergeSuccess: 9893 tv, ok := value.(Int64) 9894 if !ok { 9895 err = fmt.Errorf("invalid value, must be Int64") 9896 return 9897 } 9898 result.SourceAccountBalance = &tv 9899 default: 9900 // void 9901 } 9902 return 9903} 9904 9905// MustSourceAccountBalance retrieves the SourceAccountBalance value from the union, 9906// panicing if the value is not set. 9907func (u AccountMergeResult) MustSourceAccountBalance() Int64 { 9908 val, ok := u.GetSourceAccountBalance() 9909 9910 if !ok { 9911 panic("arm SourceAccountBalance is not set") 9912 } 9913 9914 return val 9915} 9916 9917// GetSourceAccountBalance retrieves the SourceAccountBalance value from the union, 9918// returning ok if the union's switch indicated the value is valid. 9919func (u AccountMergeResult) GetSourceAccountBalance() (result Int64, ok bool) { 9920 armName, _ := u.ArmForSwitch(int32(u.Code)) 9921 9922 if armName == "SourceAccountBalance" { 9923 result = *u.SourceAccountBalance 9924 ok = true 9925 } 9926 9927 return 9928} 9929 9930// MarshalBinary implements encoding.BinaryMarshaler. 9931func (s AccountMergeResult) MarshalBinary() ([]byte, error) { 9932 b := new(bytes.Buffer) 9933 _, err := Marshal(b, s) 9934 return b.Bytes(), err 9935} 9936 9937// UnmarshalBinary implements encoding.BinaryUnmarshaler. 9938func (s *AccountMergeResult) UnmarshalBinary(inp []byte) error { 9939 _, err := Unmarshal(bytes.NewReader(inp), s) 9940 return err 9941} 9942 9943var ( 9944 _ encoding.BinaryMarshaler = (*AccountMergeResult)(nil) 9945 _ encoding.BinaryUnmarshaler = (*AccountMergeResult)(nil) 9946) 9947 9948// InflationResultCode is an XDR Enum defines as: 9949// 9950// enum InflationResultCode 9951// { 9952// // codes considered as "success" for the operation 9953// INFLATION_SUCCESS = 0, 9954// // codes considered as "failure" for the operation 9955// INFLATION_NOT_TIME = -1 9956// }; 9957// 9958type InflationResultCode int32 9959 9960const ( 9961 InflationResultCodeInflationSuccess InflationResultCode = 0 9962 InflationResultCodeInflationNotTime InflationResultCode = -1 9963) 9964 9965var inflationResultCodeMap = map[int32]string{ 9966 0: "InflationResultCodeInflationSuccess", 9967 -1: "InflationResultCodeInflationNotTime", 9968} 9969 9970// ValidEnum validates a proposed value for this enum. Implements 9971// the Enum interface for InflationResultCode 9972func (e InflationResultCode) ValidEnum(v int32) bool { 9973 _, ok := inflationResultCodeMap[v] 9974 return ok 9975} 9976 9977// String returns the name of `e` 9978func (e InflationResultCode) String() string { 9979 name, _ := inflationResultCodeMap[int32(e)] 9980 return name 9981} 9982 9983// MarshalBinary implements encoding.BinaryMarshaler. 9984func (s InflationResultCode) MarshalBinary() ([]byte, error) { 9985 b := new(bytes.Buffer) 9986 _, err := Marshal(b, s) 9987 return b.Bytes(), err 9988} 9989 9990// UnmarshalBinary implements encoding.BinaryUnmarshaler. 9991func (s *InflationResultCode) UnmarshalBinary(inp []byte) error { 9992 _, err := Unmarshal(bytes.NewReader(inp), s) 9993 return err 9994} 9995 9996var ( 9997 _ encoding.BinaryMarshaler = (*InflationResultCode)(nil) 9998 _ encoding.BinaryUnmarshaler = (*InflationResultCode)(nil) 9999) 10000 10001// InflationPayout is an XDR Struct defines as: 10002// 10003// struct InflationPayout // or use PaymentResultAtom to limit types? 10004// { 10005// AccountID destination; 10006// int64 amount; 10007// }; 10008// 10009type InflationPayout struct { 10010 Destination AccountId 10011 Amount Int64 10012} 10013 10014// MarshalBinary implements encoding.BinaryMarshaler. 10015func (s InflationPayout) MarshalBinary() ([]byte, error) { 10016 b := new(bytes.Buffer) 10017 _, err := Marshal(b, s) 10018 return b.Bytes(), err 10019} 10020 10021// UnmarshalBinary implements encoding.BinaryUnmarshaler. 10022func (s *InflationPayout) UnmarshalBinary(inp []byte) error { 10023 _, err := Unmarshal(bytes.NewReader(inp), s) 10024 return err 10025} 10026 10027var ( 10028 _ encoding.BinaryMarshaler = (*InflationPayout)(nil) 10029 _ encoding.BinaryUnmarshaler = (*InflationPayout)(nil) 10030) 10031 10032// InflationResult is an XDR Union defines as: 10033// 10034// union InflationResult switch (InflationResultCode code) 10035// { 10036// case INFLATION_SUCCESS: 10037// InflationPayout payouts<>; 10038// default: 10039// void; 10040// }; 10041// 10042type InflationResult struct { 10043 Code InflationResultCode 10044 Payouts *[]InflationPayout 10045} 10046 10047// SwitchFieldName returns the field name in which this union's 10048// discriminant is stored 10049func (u InflationResult) SwitchFieldName() string { 10050 return "Code" 10051} 10052 10053// ArmForSwitch returns which field name should be used for storing 10054// the value for an instance of InflationResult 10055func (u InflationResult) ArmForSwitch(sw int32) (string, bool) { 10056 switch InflationResultCode(sw) { 10057 case InflationResultCodeInflationSuccess: 10058 return "Payouts", true 10059 default: 10060 return "", true 10061 } 10062} 10063 10064// NewInflationResult creates a new InflationResult. 10065func NewInflationResult(code InflationResultCode, value interface{}) (result InflationResult, err error) { 10066 result.Code = code 10067 switch InflationResultCode(code) { 10068 case InflationResultCodeInflationSuccess: 10069 tv, ok := value.([]InflationPayout) 10070 if !ok { 10071 err = fmt.Errorf("invalid value, must be []InflationPayout") 10072 return 10073 } 10074 result.Payouts = &tv 10075 default: 10076 // void 10077 } 10078 return 10079} 10080 10081// MustPayouts retrieves the Payouts value from the union, 10082// panicing if the value is not set. 10083func (u InflationResult) MustPayouts() []InflationPayout { 10084 val, ok := u.GetPayouts() 10085 10086 if !ok { 10087 panic("arm Payouts is not set") 10088 } 10089 10090 return val 10091} 10092 10093// GetPayouts retrieves the Payouts value from the union, 10094// returning ok if the union's switch indicated the value is valid. 10095func (u InflationResult) GetPayouts() (result []InflationPayout, ok bool) { 10096 armName, _ := u.ArmForSwitch(int32(u.Code)) 10097 10098 if armName == "Payouts" { 10099 result = *u.Payouts 10100 ok = true 10101 } 10102 10103 return 10104} 10105 10106// MarshalBinary implements encoding.BinaryMarshaler. 10107func (s InflationResult) MarshalBinary() ([]byte, error) { 10108 b := new(bytes.Buffer) 10109 _, err := Marshal(b, s) 10110 return b.Bytes(), err 10111} 10112 10113// UnmarshalBinary implements encoding.BinaryUnmarshaler. 10114func (s *InflationResult) UnmarshalBinary(inp []byte) error { 10115 _, err := Unmarshal(bytes.NewReader(inp), s) 10116 return err 10117} 10118 10119var ( 10120 _ encoding.BinaryMarshaler = (*InflationResult)(nil) 10121 _ encoding.BinaryUnmarshaler = (*InflationResult)(nil) 10122) 10123 10124// ManageDataResultCode is an XDR Enum defines as: 10125// 10126// enum ManageDataResultCode 10127// { 10128// // codes considered as "success" for the operation 10129// MANAGE_DATA_SUCCESS = 0, 10130// // codes considered as "failure" for the operation 10131// MANAGE_DATA_NOT_SUPPORTED_YET = 10132// -1, // The network hasn't moved to this protocol change yet 10133// MANAGE_DATA_NAME_NOT_FOUND = 10134// -2, // Trying to remove a Data Entry that isn't there 10135// MANAGE_DATA_LOW_RESERVE = -3, // not enough funds to create a new Data Entry 10136// MANAGE_DATA_INVALID_NAME = -4 // Name not a valid string 10137// }; 10138// 10139type ManageDataResultCode int32 10140 10141const ( 10142 ManageDataResultCodeManageDataSuccess ManageDataResultCode = 0 10143 ManageDataResultCodeManageDataNotSupportedYet ManageDataResultCode = -1 10144 ManageDataResultCodeManageDataNameNotFound ManageDataResultCode = -2 10145 ManageDataResultCodeManageDataLowReserve ManageDataResultCode = -3 10146 ManageDataResultCodeManageDataInvalidName ManageDataResultCode = -4 10147) 10148 10149var manageDataResultCodeMap = map[int32]string{ 10150 0: "ManageDataResultCodeManageDataSuccess", 10151 -1: "ManageDataResultCodeManageDataNotSupportedYet", 10152 -2: "ManageDataResultCodeManageDataNameNotFound", 10153 -3: "ManageDataResultCodeManageDataLowReserve", 10154 -4: "ManageDataResultCodeManageDataInvalidName", 10155} 10156 10157// ValidEnum validates a proposed value for this enum. Implements 10158// the Enum interface for ManageDataResultCode 10159func (e ManageDataResultCode) ValidEnum(v int32) bool { 10160 _, ok := manageDataResultCodeMap[v] 10161 return ok 10162} 10163 10164// String returns the name of `e` 10165func (e ManageDataResultCode) String() string { 10166 name, _ := manageDataResultCodeMap[int32(e)] 10167 return name 10168} 10169 10170// MarshalBinary implements encoding.BinaryMarshaler. 10171func (s ManageDataResultCode) MarshalBinary() ([]byte, error) { 10172 b := new(bytes.Buffer) 10173 _, err := Marshal(b, s) 10174 return b.Bytes(), err 10175} 10176 10177// UnmarshalBinary implements encoding.BinaryUnmarshaler. 10178func (s *ManageDataResultCode) UnmarshalBinary(inp []byte) error { 10179 _, err := Unmarshal(bytes.NewReader(inp), s) 10180 return err 10181} 10182 10183var ( 10184 _ encoding.BinaryMarshaler = (*ManageDataResultCode)(nil) 10185 _ encoding.BinaryUnmarshaler = (*ManageDataResultCode)(nil) 10186) 10187 10188// ManageDataResult is an XDR Union defines as: 10189// 10190// union ManageDataResult switch (ManageDataResultCode code) 10191// { 10192// case MANAGE_DATA_SUCCESS: 10193// void; 10194// default: 10195// void; 10196// }; 10197// 10198type ManageDataResult struct { 10199 Code ManageDataResultCode 10200} 10201 10202// SwitchFieldName returns the field name in which this union's 10203// discriminant is stored 10204func (u ManageDataResult) SwitchFieldName() string { 10205 return "Code" 10206} 10207 10208// ArmForSwitch returns which field name should be used for storing 10209// the value for an instance of ManageDataResult 10210func (u ManageDataResult) ArmForSwitch(sw int32) (string, bool) { 10211 switch ManageDataResultCode(sw) { 10212 case ManageDataResultCodeManageDataSuccess: 10213 return "", true 10214 default: 10215 return "", true 10216 } 10217} 10218 10219// NewManageDataResult creates a new ManageDataResult. 10220func NewManageDataResult(code ManageDataResultCode, value interface{}) (result ManageDataResult, err error) { 10221 result.Code = code 10222 switch ManageDataResultCode(code) { 10223 case ManageDataResultCodeManageDataSuccess: 10224 // void 10225 default: 10226 // void 10227 } 10228 return 10229} 10230 10231// MarshalBinary implements encoding.BinaryMarshaler. 10232func (s ManageDataResult) MarshalBinary() ([]byte, error) { 10233 b := new(bytes.Buffer) 10234 _, err := Marshal(b, s) 10235 return b.Bytes(), err 10236} 10237 10238// UnmarshalBinary implements encoding.BinaryUnmarshaler. 10239func (s *ManageDataResult) UnmarshalBinary(inp []byte) error { 10240 _, err := Unmarshal(bytes.NewReader(inp), s) 10241 return err 10242} 10243 10244var ( 10245 _ encoding.BinaryMarshaler = (*ManageDataResult)(nil) 10246 _ encoding.BinaryUnmarshaler = (*ManageDataResult)(nil) 10247) 10248 10249// BumpSequenceResultCode is an XDR Enum defines as: 10250// 10251// enum BumpSequenceResultCode 10252// { 10253// // codes considered as "success" for the operation 10254// BUMP_SEQUENCE_SUCCESS = 0, 10255// // codes considered as "failure" for the operation 10256// BUMP_SEQUENCE_BAD_SEQ = -1 // `bumpTo` is not within bounds 10257// }; 10258// 10259type BumpSequenceResultCode int32 10260 10261const ( 10262 BumpSequenceResultCodeBumpSequenceSuccess BumpSequenceResultCode = 0 10263 BumpSequenceResultCodeBumpSequenceBadSeq BumpSequenceResultCode = -1 10264) 10265 10266var bumpSequenceResultCodeMap = map[int32]string{ 10267 0: "BumpSequenceResultCodeBumpSequenceSuccess", 10268 -1: "BumpSequenceResultCodeBumpSequenceBadSeq", 10269} 10270 10271// ValidEnum validates a proposed value for this enum. Implements 10272// the Enum interface for BumpSequenceResultCode 10273func (e BumpSequenceResultCode) ValidEnum(v int32) bool { 10274 _, ok := bumpSequenceResultCodeMap[v] 10275 return ok 10276} 10277 10278// String returns the name of `e` 10279func (e BumpSequenceResultCode) String() string { 10280 name, _ := bumpSequenceResultCodeMap[int32(e)] 10281 return name 10282} 10283 10284// MarshalBinary implements encoding.BinaryMarshaler. 10285func (s BumpSequenceResultCode) MarshalBinary() ([]byte, error) { 10286 b := new(bytes.Buffer) 10287 _, err := Marshal(b, s) 10288 return b.Bytes(), err 10289} 10290 10291// UnmarshalBinary implements encoding.BinaryUnmarshaler. 10292func (s *BumpSequenceResultCode) UnmarshalBinary(inp []byte) error { 10293 _, err := Unmarshal(bytes.NewReader(inp), s) 10294 return err 10295} 10296 10297var ( 10298 _ encoding.BinaryMarshaler = (*BumpSequenceResultCode)(nil) 10299 _ encoding.BinaryUnmarshaler = (*BumpSequenceResultCode)(nil) 10300) 10301 10302// BumpSequenceResult is an XDR Union defines as: 10303// 10304// union BumpSequenceResult switch (BumpSequenceResultCode code) 10305// { 10306// case BUMP_SEQUENCE_SUCCESS: 10307// void; 10308// default: 10309// void; 10310// }; 10311// 10312type BumpSequenceResult struct { 10313 Code BumpSequenceResultCode 10314} 10315 10316// SwitchFieldName returns the field name in which this union's 10317// discriminant is stored 10318func (u BumpSequenceResult) SwitchFieldName() string { 10319 return "Code" 10320} 10321 10322// ArmForSwitch returns which field name should be used for storing 10323// the value for an instance of BumpSequenceResult 10324func (u BumpSequenceResult) ArmForSwitch(sw int32) (string, bool) { 10325 switch BumpSequenceResultCode(sw) { 10326 case BumpSequenceResultCodeBumpSequenceSuccess: 10327 return "", true 10328 default: 10329 return "", true 10330 } 10331} 10332 10333// NewBumpSequenceResult creates a new BumpSequenceResult. 10334func NewBumpSequenceResult(code BumpSequenceResultCode, value interface{}) (result BumpSequenceResult, err error) { 10335 result.Code = code 10336 switch BumpSequenceResultCode(code) { 10337 case BumpSequenceResultCodeBumpSequenceSuccess: 10338 // void 10339 default: 10340 // void 10341 } 10342 return 10343} 10344 10345// MarshalBinary implements encoding.BinaryMarshaler. 10346func (s BumpSequenceResult) MarshalBinary() ([]byte, error) { 10347 b := new(bytes.Buffer) 10348 _, err := Marshal(b, s) 10349 return b.Bytes(), err 10350} 10351 10352// UnmarshalBinary implements encoding.BinaryUnmarshaler. 10353func (s *BumpSequenceResult) UnmarshalBinary(inp []byte) error { 10354 _, err := Unmarshal(bytes.NewReader(inp), s) 10355 return err 10356} 10357 10358var ( 10359 _ encoding.BinaryMarshaler = (*BumpSequenceResult)(nil) 10360 _ encoding.BinaryUnmarshaler = (*BumpSequenceResult)(nil) 10361) 10362 10363// OperationResultCode is an XDR Enum defines as: 10364// 10365// enum OperationResultCode 10366// { 10367// opINNER = 0, // inner object result is valid 10368// 10369// opBAD_AUTH = -1, // too few valid signatures / wrong network 10370// opNO_ACCOUNT = -2, // source account was not found 10371// opNOT_SUPPORTED = -3, // operation not supported at this time 10372// opTOO_MANY_SUBENTRIES = -4, // max number of subentries already reached 10373// opEXCEEDED_WORK_LIMIT = -5 // operation did too much work 10374// }; 10375// 10376type OperationResultCode int32 10377 10378const ( 10379 OperationResultCodeOpInner OperationResultCode = 0 10380 OperationResultCodeOpBadAuth OperationResultCode = -1 10381 OperationResultCodeOpNoAccount OperationResultCode = -2 10382 OperationResultCodeOpNotSupported OperationResultCode = -3 10383 OperationResultCodeOpTooManySubentries OperationResultCode = -4 10384 OperationResultCodeOpExceededWorkLimit OperationResultCode = -5 10385) 10386 10387var operationResultCodeMap = map[int32]string{ 10388 0: "OperationResultCodeOpInner", 10389 -1: "OperationResultCodeOpBadAuth", 10390 -2: "OperationResultCodeOpNoAccount", 10391 -3: "OperationResultCodeOpNotSupported", 10392 -4: "OperationResultCodeOpTooManySubentries", 10393 -5: "OperationResultCodeOpExceededWorkLimit", 10394} 10395 10396// ValidEnum validates a proposed value for this enum. Implements 10397// the Enum interface for OperationResultCode 10398func (e OperationResultCode) ValidEnum(v int32) bool { 10399 _, ok := operationResultCodeMap[v] 10400 return ok 10401} 10402 10403// String returns the name of `e` 10404func (e OperationResultCode) String() string { 10405 name, _ := operationResultCodeMap[int32(e)] 10406 return name 10407} 10408 10409// MarshalBinary implements encoding.BinaryMarshaler. 10410func (s OperationResultCode) MarshalBinary() ([]byte, error) { 10411 b := new(bytes.Buffer) 10412 _, err := Marshal(b, s) 10413 return b.Bytes(), err 10414} 10415 10416// UnmarshalBinary implements encoding.BinaryUnmarshaler. 10417func (s *OperationResultCode) UnmarshalBinary(inp []byte) error { 10418 _, err := Unmarshal(bytes.NewReader(inp), s) 10419 return err 10420} 10421 10422var ( 10423 _ encoding.BinaryMarshaler = (*OperationResultCode)(nil) 10424 _ encoding.BinaryUnmarshaler = (*OperationResultCode)(nil) 10425) 10426 10427// OperationResultTr is an XDR NestedUnion defines as: 10428// 10429// union switch (OperationType type) 10430// { 10431// case CREATE_ACCOUNT: 10432// CreateAccountResult createAccountResult; 10433// case PAYMENT: 10434// PaymentResult paymentResult; 10435// case PATH_PAYMENT_STRICT_RECEIVE: 10436// PathPaymentStrictReceiveResult pathPaymentStrictReceiveResult; 10437// case MANAGE_SELL_OFFER: 10438// ManageSellOfferResult manageSellOfferResult; 10439// case CREATE_PASSIVE_SELL_OFFER: 10440// ManageSellOfferResult createPassiveSellOfferResult; 10441// case SET_OPTIONS: 10442// SetOptionsResult setOptionsResult; 10443// case CHANGE_TRUST: 10444// ChangeTrustResult changeTrustResult; 10445// case ALLOW_TRUST: 10446// AllowTrustResult allowTrustResult; 10447// case ACCOUNT_MERGE: 10448// AccountMergeResult accountMergeResult; 10449// case INFLATION: 10450// InflationResult inflationResult; 10451// case MANAGE_DATA: 10452// ManageDataResult manageDataResult; 10453// case BUMP_SEQUENCE: 10454// BumpSequenceResult bumpSeqResult; 10455// case MANAGE_BUY_OFFER: 10456// ManageBuyOfferResult manageBuyOfferResult; 10457// case PATH_PAYMENT_STRICT_SEND: 10458// PathPaymentStrictSendResult pathPaymentStrictSendResult; 10459// } 10460// 10461type OperationResultTr struct { 10462 Type OperationType 10463 CreateAccountResult *CreateAccountResult 10464 PaymentResult *PaymentResult 10465 PathPaymentStrictReceiveResult *PathPaymentStrictReceiveResult 10466 ManageSellOfferResult *ManageSellOfferResult 10467 CreatePassiveSellOfferResult *ManageSellOfferResult 10468 SetOptionsResult *SetOptionsResult 10469 ChangeTrustResult *ChangeTrustResult 10470 AllowTrustResult *AllowTrustResult 10471 AccountMergeResult *AccountMergeResult 10472 InflationResult *InflationResult 10473 ManageDataResult *ManageDataResult 10474 BumpSeqResult *BumpSequenceResult 10475 ManageBuyOfferResult *ManageBuyOfferResult 10476 PathPaymentStrictSendResult *PathPaymentStrictSendResult 10477} 10478 10479// SwitchFieldName returns the field name in which this union's 10480// discriminant is stored 10481func (u OperationResultTr) SwitchFieldName() string { 10482 return "Type" 10483} 10484 10485// ArmForSwitch returns which field name should be used for storing 10486// the value for an instance of OperationResultTr 10487func (u OperationResultTr) ArmForSwitch(sw int32) (string, bool) { 10488 switch OperationType(sw) { 10489 case OperationTypeCreateAccount: 10490 return "CreateAccountResult", true 10491 case OperationTypePayment: 10492 return "PaymentResult", true 10493 case OperationTypePathPaymentStrictReceive: 10494 return "PathPaymentStrictReceiveResult", true 10495 case OperationTypeManageSellOffer: 10496 return "ManageSellOfferResult", true 10497 case OperationTypeCreatePassiveSellOffer: 10498 return "CreatePassiveSellOfferResult", true 10499 case OperationTypeSetOptions: 10500 return "SetOptionsResult", true 10501 case OperationTypeChangeTrust: 10502 return "ChangeTrustResult", true 10503 case OperationTypeAllowTrust: 10504 return "AllowTrustResult", true 10505 case OperationTypeAccountMerge: 10506 return "AccountMergeResult", true 10507 case OperationTypeInflation: 10508 return "InflationResult", true 10509 case OperationTypeManageData: 10510 return "ManageDataResult", true 10511 case OperationTypeBumpSequence: 10512 return "BumpSeqResult", true 10513 case OperationTypeManageBuyOffer: 10514 return "ManageBuyOfferResult", true 10515 case OperationTypePathPaymentStrictSend: 10516 return "PathPaymentStrictSendResult", true 10517 } 10518 return "-", false 10519} 10520 10521// NewOperationResultTr creates a new OperationResultTr. 10522func NewOperationResultTr(aType OperationType, value interface{}) (result OperationResultTr, err error) { 10523 result.Type = aType 10524 switch OperationType(aType) { 10525 case OperationTypeCreateAccount: 10526 tv, ok := value.(CreateAccountResult) 10527 if !ok { 10528 err = fmt.Errorf("invalid value, must be CreateAccountResult") 10529 return 10530 } 10531 result.CreateAccountResult = &tv 10532 case OperationTypePayment: 10533 tv, ok := value.(PaymentResult) 10534 if !ok { 10535 err = fmt.Errorf("invalid value, must be PaymentResult") 10536 return 10537 } 10538 result.PaymentResult = &tv 10539 case OperationTypePathPaymentStrictReceive: 10540 tv, ok := value.(PathPaymentStrictReceiveResult) 10541 if !ok { 10542 err = fmt.Errorf("invalid value, must be PathPaymentStrictReceiveResult") 10543 return 10544 } 10545 result.PathPaymentStrictReceiveResult = &tv 10546 case OperationTypeManageSellOffer: 10547 tv, ok := value.(ManageSellOfferResult) 10548 if !ok { 10549 err = fmt.Errorf("invalid value, must be ManageSellOfferResult") 10550 return 10551 } 10552 result.ManageSellOfferResult = &tv 10553 case OperationTypeCreatePassiveSellOffer: 10554 tv, ok := value.(ManageSellOfferResult) 10555 if !ok { 10556 err = fmt.Errorf("invalid value, must be ManageSellOfferResult") 10557 return 10558 } 10559 result.CreatePassiveSellOfferResult = &tv 10560 case OperationTypeSetOptions: 10561 tv, ok := value.(SetOptionsResult) 10562 if !ok { 10563 err = fmt.Errorf("invalid value, must be SetOptionsResult") 10564 return 10565 } 10566 result.SetOptionsResult = &tv 10567 case OperationTypeChangeTrust: 10568 tv, ok := value.(ChangeTrustResult) 10569 if !ok { 10570 err = fmt.Errorf("invalid value, must be ChangeTrustResult") 10571 return 10572 } 10573 result.ChangeTrustResult = &tv 10574 case OperationTypeAllowTrust: 10575 tv, ok := value.(AllowTrustResult) 10576 if !ok { 10577 err = fmt.Errorf("invalid value, must be AllowTrustResult") 10578 return 10579 } 10580 result.AllowTrustResult = &tv 10581 case OperationTypeAccountMerge: 10582 tv, ok := value.(AccountMergeResult) 10583 if !ok { 10584 err = fmt.Errorf("invalid value, must be AccountMergeResult") 10585 return 10586 } 10587 result.AccountMergeResult = &tv 10588 case OperationTypeInflation: 10589 tv, ok := value.(InflationResult) 10590 if !ok { 10591 err = fmt.Errorf("invalid value, must be InflationResult") 10592 return 10593 } 10594 result.InflationResult = &tv 10595 case OperationTypeManageData: 10596 tv, ok := value.(ManageDataResult) 10597 if !ok { 10598 err = fmt.Errorf("invalid value, must be ManageDataResult") 10599 return 10600 } 10601 result.ManageDataResult = &tv 10602 case OperationTypeBumpSequence: 10603 tv, ok := value.(BumpSequenceResult) 10604 if !ok { 10605 err = fmt.Errorf("invalid value, must be BumpSequenceResult") 10606 return 10607 } 10608 result.BumpSeqResult = &tv 10609 case OperationTypeManageBuyOffer: 10610 tv, ok := value.(ManageBuyOfferResult) 10611 if !ok { 10612 err = fmt.Errorf("invalid value, must be ManageBuyOfferResult") 10613 return 10614 } 10615 result.ManageBuyOfferResult = &tv 10616 case OperationTypePathPaymentStrictSend: 10617 tv, ok := value.(PathPaymentStrictSendResult) 10618 if !ok { 10619 err = fmt.Errorf("invalid value, must be PathPaymentStrictSendResult") 10620 return 10621 } 10622 result.PathPaymentStrictSendResult = &tv 10623 } 10624 return 10625} 10626 10627// MustCreateAccountResult retrieves the CreateAccountResult value from the union, 10628// panicing if the value is not set. 10629func (u OperationResultTr) MustCreateAccountResult() CreateAccountResult { 10630 val, ok := u.GetCreateAccountResult() 10631 10632 if !ok { 10633 panic("arm CreateAccountResult is not set") 10634 } 10635 10636 return val 10637} 10638 10639// GetCreateAccountResult retrieves the CreateAccountResult value from the union, 10640// returning ok if the union's switch indicated the value is valid. 10641func (u OperationResultTr) GetCreateAccountResult() (result CreateAccountResult, ok bool) { 10642 armName, _ := u.ArmForSwitch(int32(u.Type)) 10643 10644 if armName == "CreateAccountResult" { 10645 result = *u.CreateAccountResult 10646 ok = true 10647 } 10648 10649 return 10650} 10651 10652// MustPaymentResult retrieves the PaymentResult value from the union, 10653// panicing if the value is not set. 10654func (u OperationResultTr) MustPaymentResult() PaymentResult { 10655 val, ok := u.GetPaymentResult() 10656 10657 if !ok { 10658 panic("arm PaymentResult is not set") 10659 } 10660 10661 return val 10662} 10663 10664// GetPaymentResult retrieves the PaymentResult value from the union, 10665// returning ok if the union's switch indicated the value is valid. 10666func (u OperationResultTr) GetPaymentResult() (result PaymentResult, ok bool) { 10667 armName, _ := u.ArmForSwitch(int32(u.Type)) 10668 10669 if armName == "PaymentResult" { 10670 result = *u.PaymentResult 10671 ok = true 10672 } 10673 10674 return 10675} 10676 10677// MustPathPaymentStrictReceiveResult retrieves the PathPaymentStrictReceiveResult value from the union, 10678// panicing if the value is not set. 10679func (u OperationResultTr) MustPathPaymentStrictReceiveResult() PathPaymentStrictReceiveResult { 10680 val, ok := u.GetPathPaymentStrictReceiveResult() 10681 10682 if !ok { 10683 panic("arm PathPaymentStrictReceiveResult is not set") 10684 } 10685 10686 return val 10687} 10688 10689// GetPathPaymentStrictReceiveResult retrieves the PathPaymentStrictReceiveResult value from the union, 10690// returning ok if the union's switch indicated the value is valid. 10691func (u OperationResultTr) GetPathPaymentStrictReceiveResult() (result PathPaymentStrictReceiveResult, ok bool) { 10692 armName, _ := u.ArmForSwitch(int32(u.Type)) 10693 10694 if armName == "PathPaymentStrictReceiveResult" { 10695 result = *u.PathPaymentStrictReceiveResult 10696 ok = true 10697 } 10698 10699 return 10700} 10701 10702// MustManageSellOfferResult retrieves the ManageSellOfferResult value from the union, 10703// panicing if the value is not set. 10704func (u OperationResultTr) MustManageSellOfferResult() ManageSellOfferResult { 10705 val, ok := u.GetManageSellOfferResult() 10706 10707 if !ok { 10708 panic("arm ManageSellOfferResult is not set") 10709 } 10710 10711 return val 10712} 10713 10714// GetManageSellOfferResult retrieves the ManageSellOfferResult value from the union, 10715// returning ok if the union's switch indicated the value is valid. 10716func (u OperationResultTr) GetManageSellOfferResult() (result ManageSellOfferResult, ok bool) { 10717 armName, _ := u.ArmForSwitch(int32(u.Type)) 10718 10719 if armName == "ManageSellOfferResult" { 10720 result = *u.ManageSellOfferResult 10721 ok = true 10722 } 10723 10724 return 10725} 10726 10727// MustCreatePassiveSellOfferResult retrieves the CreatePassiveSellOfferResult value from the union, 10728// panicing if the value is not set. 10729func (u OperationResultTr) MustCreatePassiveSellOfferResult() ManageSellOfferResult { 10730 val, ok := u.GetCreatePassiveSellOfferResult() 10731 10732 if !ok { 10733 panic("arm CreatePassiveSellOfferResult is not set") 10734 } 10735 10736 return val 10737} 10738 10739// GetCreatePassiveSellOfferResult retrieves the CreatePassiveSellOfferResult value from the union, 10740// returning ok if the union's switch indicated the value is valid. 10741func (u OperationResultTr) GetCreatePassiveSellOfferResult() (result ManageSellOfferResult, ok bool) { 10742 armName, _ := u.ArmForSwitch(int32(u.Type)) 10743 10744 if armName == "CreatePassiveSellOfferResult" { 10745 result = *u.CreatePassiveSellOfferResult 10746 ok = true 10747 } 10748 10749 return 10750} 10751 10752// MustSetOptionsResult retrieves the SetOptionsResult value from the union, 10753// panicing if the value is not set. 10754func (u OperationResultTr) MustSetOptionsResult() SetOptionsResult { 10755 val, ok := u.GetSetOptionsResult() 10756 10757 if !ok { 10758 panic("arm SetOptionsResult is not set") 10759 } 10760 10761 return val 10762} 10763 10764// GetSetOptionsResult retrieves the SetOptionsResult value from the union, 10765// returning ok if the union's switch indicated the value is valid. 10766func (u OperationResultTr) GetSetOptionsResult() (result SetOptionsResult, ok bool) { 10767 armName, _ := u.ArmForSwitch(int32(u.Type)) 10768 10769 if armName == "SetOptionsResult" { 10770 result = *u.SetOptionsResult 10771 ok = true 10772 } 10773 10774 return 10775} 10776 10777// MustChangeTrustResult retrieves the ChangeTrustResult value from the union, 10778// panicing if the value is not set. 10779func (u OperationResultTr) MustChangeTrustResult() ChangeTrustResult { 10780 val, ok := u.GetChangeTrustResult() 10781 10782 if !ok { 10783 panic("arm ChangeTrustResult is not set") 10784 } 10785 10786 return val 10787} 10788 10789// GetChangeTrustResult retrieves the ChangeTrustResult value from the union, 10790// returning ok if the union's switch indicated the value is valid. 10791func (u OperationResultTr) GetChangeTrustResult() (result ChangeTrustResult, ok bool) { 10792 armName, _ := u.ArmForSwitch(int32(u.Type)) 10793 10794 if armName == "ChangeTrustResult" { 10795 result = *u.ChangeTrustResult 10796 ok = true 10797 } 10798 10799 return 10800} 10801 10802// MustAllowTrustResult retrieves the AllowTrustResult value from the union, 10803// panicing if the value is not set. 10804func (u OperationResultTr) MustAllowTrustResult() AllowTrustResult { 10805 val, ok := u.GetAllowTrustResult() 10806 10807 if !ok { 10808 panic("arm AllowTrustResult is not set") 10809 } 10810 10811 return val 10812} 10813 10814// GetAllowTrustResult retrieves the AllowTrustResult value from the union, 10815// returning ok if the union's switch indicated the value is valid. 10816func (u OperationResultTr) GetAllowTrustResult() (result AllowTrustResult, ok bool) { 10817 armName, _ := u.ArmForSwitch(int32(u.Type)) 10818 10819 if armName == "AllowTrustResult" { 10820 result = *u.AllowTrustResult 10821 ok = true 10822 } 10823 10824 return 10825} 10826 10827// MustAccountMergeResult retrieves the AccountMergeResult value from the union, 10828// panicing if the value is not set. 10829func (u OperationResultTr) MustAccountMergeResult() AccountMergeResult { 10830 val, ok := u.GetAccountMergeResult() 10831 10832 if !ok { 10833 panic("arm AccountMergeResult is not set") 10834 } 10835 10836 return val 10837} 10838 10839// GetAccountMergeResult retrieves the AccountMergeResult value from the union, 10840// returning ok if the union's switch indicated the value is valid. 10841func (u OperationResultTr) GetAccountMergeResult() (result AccountMergeResult, ok bool) { 10842 armName, _ := u.ArmForSwitch(int32(u.Type)) 10843 10844 if armName == "AccountMergeResult" { 10845 result = *u.AccountMergeResult 10846 ok = true 10847 } 10848 10849 return 10850} 10851 10852// MustInflationResult retrieves the InflationResult value from the union, 10853// panicing if the value is not set. 10854func (u OperationResultTr) MustInflationResult() InflationResult { 10855 val, ok := u.GetInflationResult() 10856 10857 if !ok { 10858 panic("arm InflationResult is not set") 10859 } 10860 10861 return val 10862} 10863 10864// GetInflationResult retrieves the InflationResult value from the union, 10865// returning ok if the union's switch indicated the value is valid. 10866func (u OperationResultTr) GetInflationResult() (result InflationResult, ok bool) { 10867 armName, _ := u.ArmForSwitch(int32(u.Type)) 10868 10869 if armName == "InflationResult" { 10870 result = *u.InflationResult 10871 ok = true 10872 } 10873 10874 return 10875} 10876 10877// MustManageDataResult retrieves the ManageDataResult value from the union, 10878// panicing if the value is not set. 10879func (u OperationResultTr) MustManageDataResult() ManageDataResult { 10880 val, ok := u.GetManageDataResult() 10881 10882 if !ok { 10883 panic("arm ManageDataResult is not set") 10884 } 10885 10886 return val 10887} 10888 10889// GetManageDataResult retrieves the ManageDataResult value from the union, 10890// returning ok if the union's switch indicated the value is valid. 10891func (u OperationResultTr) GetManageDataResult() (result ManageDataResult, ok bool) { 10892 armName, _ := u.ArmForSwitch(int32(u.Type)) 10893 10894 if armName == "ManageDataResult" { 10895 result = *u.ManageDataResult 10896 ok = true 10897 } 10898 10899 return 10900} 10901 10902// MustBumpSeqResult retrieves the BumpSeqResult value from the union, 10903// panicing if the value is not set. 10904func (u OperationResultTr) MustBumpSeqResult() BumpSequenceResult { 10905 val, ok := u.GetBumpSeqResult() 10906 10907 if !ok { 10908 panic("arm BumpSeqResult is not set") 10909 } 10910 10911 return val 10912} 10913 10914// GetBumpSeqResult retrieves the BumpSeqResult value from the union, 10915// returning ok if the union's switch indicated the value is valid. 10916func (u OperationResultTr) GetBumpSeqResult() (result BumpSequenceResult, ok bool) { 10917 armName, _ := u.ArmForSwitch(int32(u.Type)) 10918 10919 if armName == "BumpSeqResult" { 10920 result = *u.BumpSeqResult 10921 ok = true 10922 } 10923 10924 return 10925} 10926 10927// MustManageBuyOfferResult retrieves the ManageBuyOfferResult value from the union, 10928// panicing if the value is not set. 10929func (u OperationResultTr) MustManageBuyOfferResult() ManageBuyOfferResult { 10930 val, ok := u.GetManageBuyOfferResult() 10931 10932 if !ok { 10933 panic("arm ManageBuyOfferResult is not set") 10934 } 10935 10936 return val 10937} 10938 10939// GetManageBuyOfferResult retrieves the ManageBuyOfferResult value from the union, 10940// returning ok if the union's switch indicated the value is valid. 10941func (u OperationResultTr) GetManageBuyOfferResult() (result ManageBuyOfferResult, ok bool) { 10942 armName, _ := u.ArmForSwitch(int32(u.Type)) 10943 10944 if armName == "ManageBuyOfferResult" { 10945 result = *u.ManageBuyOfferResult 10946 ok = true 10947 } 10948 10949 return 10950} 10951 10952// MustPathPaymentStrictSendResult retrieves the PathPaymentStrictSendResult value from the union, 10953// panicing if the value is not set. 10954func (u OperationResultTr) MustPathPaymentStrictSendResult() PathPaymentStrictSendResult { 10955 val, ok := u.GetPathPaymentStrictSendResult() 10956 10957 if !ok { 10958 panic("arm PathPaymentStrictSendResult is not set") 10959 } 10960 10961 return val 10962} 10963 10964// GetPathPaymentStrictSendResult retrieves the PathPaymentStrictSendResult value from the union, 10965// returning ok if the union's switch indicated the value is valid. 10966func (u OperationResultTr) GetPathPaymentStrictSendResult() (result PathPaymentStrictSendResult, ok bool) { 10967 armName, _ := u.ArmForSwitch(int32(u.Type)) 10968 10969 if armName == "PathPaymentStrictSendResult" { 10970 result = *u.PathPaymentStrictSendResult 10971 ok = true 10972 } 10973 10974 return 10975} 10976 10977// MarshalBinary implements encoding.BinaryMarshaler. 10978func (s OperationResultTr) MarshalBinary() ([]byte, error) { 10979 b := new(bytes.Buffer) 10980 _, err := Marshal(b, s) 10981 return b.Bytes(), err 10982} 10983 10984// UnmarshalBinary implements encoding.BinaryUnmarshaler. 10985func (s *OperationResultTr) UnmarshalBinary(inp []byte) error { 10986 _, err := Unmarshal(bytes.NewReader(inp), s) 10987 return err 10988} 10989 10990var ( 10991 _ encoding.BinaryMarshaler = (*OperationResultTr)(nil) 10992 _ encoding.BinaryUnmarshaler = (*OperationResultTr)(nil) 10993) 10994 10995// OperationResult is an XDR Union defines as: 10996// 10997// union OperationResult switch (OperationResultCode code) 10998// { 10999// case opINNER: 11000// union switch (OperationType type) 11001// { 11002// case CREATE_ACCOUNT: 11003// CreateAccountResult createAccountResult; 11004// case PAYMENT: 11005// PaymentResult paymentResult; 11006// case PATH_PAYMENT_STRICT_RECEIVE: 11007// PathPaymentStrictReceiveResult pathPaymentStrictReceiveResult; 11008// case MANAGE_SELL_OFFER: 11009// ManageSellOfferResult manageSellOfferResult; 11010// case CREATE_PASSIVE_SELL_OFFER: 11011// ManageSellOfferResult createPassiveSellOfferResult; 11012// case SET_OPTIONS: 11013// SetOptionsResult setOptionsResult; 11014// case CHANGE_TRUST: 11015// ChangeTrustResult changeTrustResult; 11016// case ALLOW_TRUST: 11017// AllowTrustResult allowTrustResult; 11018// case ACCOUNT_MERGE: 11019// AccountMergeResult accountMergeResult; 11020// case INFLATION: 11021// InflationResult inflationResult; 11022// case MANAGE_DATA: 11023// ManageDataResult manageDataResult; 11024// case BUMP_SEQUENCE: 11025// BumpSequenceResult bumpSeqResult; 11026// case MANAGE_BUY_OFFER: 11027// ManageBuyOfferResult manageBuyOfferResult; 11028// case PATH_PAYMENT_STRICT_SEND: 11029// PathPaymentStrictSendResult pathPaymentStrictSendResult; 11030// } 11031// tr; 11032// default: 11033// void; 11034// }; 11035// 11036type OperationResult struct { 11037 Code OperationResultCode 11038 Tr *OperationResultTr 11039} 11040 11041// SwitchFieldName returns the field name in which this union's 11042// discriminant is stored 11043func (u OperationResult) SwitchFieldName() string { 11044 return "Code" 11045} 11046 11047// ArmForSwitch returns which field name should be used for storing 11048// the value for an instance of OperationResult 11049func (u OperationResult) ArmForSwitch(sw int32) (string, bool) { 11050 switch OperationResultCode(sw) { 11051 case OperationResultCodeOpInner: 11052 return "Tr", true 11053 default: 11054 return "", true 11055 } 11056} 11057 11058// NewOperationResult creates a new OperationResult. 11059func NewOperationResult(code OperationResultCode, value interface{}) (result OperationResult, err error) { 11060 result.Code = code 11061 switch OperationResultCode(code) { 11062 case OperationResultCodeOpInner: 11063 tv, ok := value.(OperationResultTr) 11064 if !ok { 11065 err = fmt.Errorf("invalid value, must be OperationResultTr") 11066 return 11067 } 11068 result.Tr = &tv 11069 default: 11070 // void 11071 } 11072 return 11073} 11074 11075// MustTr retrieves the Tr value from the union, 11076// panicing if the value is not set. 11077func (u OperationResult) MustTr() OperationResultTr { 11078 val, ok := u.GetTr() 11079 11080 if !ok { 11081 panic("arm Tr is not set") 11082 } 11083 11084 return val 11085} 11086 11087// GetTr retrieves the Tr value from the union, 11088// returning ok if the union's switch indicated the value is valid. 11089func (u OperationResult) GetTr() (result OperationResultTr, ok bool) { 11090 armName, _ := u.ArmForSwitch(int32(u.Code)) 11091 11092 if armName == "Tr" { 11093 result = *u.Tr 11094 ok = true 11095 } 11096 11097 return 11098} 11099 11100// MarshalBinary implements encoding.BinaryMarshaler. 11101func (s OperationResult) MarshalBinary() ([]byte, error) { 11102 b := new(bytes.Buffer) 11103 _, err := Marshal(b, s) 11104 return b.Bytes(), err 11105} 11106 11107// UnmarshalBinary implements encoding.BinaryUnmarshaler. 11108func (s *OperationResult) UnmarshalBinary(inp []byte) error { 11109 _, err := Unmarshal(bytes.NewReader(inp), s) 11110 return err 11111} 11112 11113var ( 11114 _ encoding.BinaryMarshaler = (*OperationResult)(nil) 11115 _ encoding.BinaryUnmarshaler = (*OperationResult)(nil) 11116) 11117 11118// TransactionResultCode is an XDR Enum defines as: 11119// 11120// enum TransactionResultCode 11121// { 11122// txSUCCESS = 0, // all operations succeeded 11123// 11124// txFAILED = -1, // one of the operations failed (none were applied) 11125// 11126// txTOO_EARLY = -2, // ledger closeTime before minTime 11127// txTOO_LATE = -3, // ledger closeTime after maxTime 11128// txMISSING_OPERATION = -4, // no operation was specified 11129// txBAD_SEQ = -5, // sequence number does not match source account 11130// 11131// txBAD_AUTH = -6, // too few valid signatures / wrong network 11132// txINSUFFICIENT_BALANCE = -7, // fee would bring account below reserve 11133// txNO_ACCOUNT = -8, // source account not found 11134// txINSUFFICIENT_FEE = -9, // fee is too small 11135// txBAD_AUTH_EXTRA = -10, // unused signatures attached to transaction 11136// txINTERNAL_ERROR = -11 // an unknown error occured 11137// }; 11138// 11139type TransactionResultCode int32 11140 11141const ( 11142 TransactionResultCodeTxSuccess TransactionResultCode = 0 11143 TransactionResultCodeTxFailed TransactionResultCode = -1 11144 TransactionResultCodeTxTooEarly TransactionResultCode = -2 11145 TransactionResultCodeTxTooLate TransactionResultCode = -3 11146 TransactionResultCodeTxMissingOperation TransactionResultCode = -4 11147 TransactionResultCodeTxBadSeq TransactionResultCode = -5 11148 TransactionResultCodeTxBadAuth TransactionResultCode = -6 11149 TransactionResultCodeTxInsufficientBalance TransactionResultCode = -7 11150 TransactionResultCodeTxNoAccount TransactionResultCode = -8 11151 TransactionResultCodeTxInsufficientFee TransactionResultCode = -9 11152 TransactionResultCodeTxBadAuthExtra TransactionResultCode = -10 11153 TransactionResultCodeTxInternalError TransactionResultCode = -11 11154) 11155 11156var transactionResultCodeMap = map[int32]string{ 11157 0: "TransactionResultCodeTxSuccess", 11158 -1: "TransactionResultCodeTxFailed", 11159 -2: "TransactionResultCodeTxTooEarly", 11160 -3: "TransactionResultCodeTxTooLate", 11161 -4: "TransactionResultCodeTxMissingOperation", 11162 -5: "TransactionResultCodeTxBadSeq", 11163 -6: "TransactionResultCodeTxBadAuth", 11164 -7: "TransactionResultCodeTxInsufficientBalance", 11165 -8: "TransactionResultCodeTxNoAccount", 11166 -9: "TransactionResultCodeTxInsufficientFee", 11167 -10: "TransactionResultCodeTxBadAuthExtra", 11168 -11: "TransactionResultCodeTxInternalError", 11169} 11170 11171// ValidEnum validates a proposed value for this enum. Implements 11172// the Enum interface for TransactionResultCode 11173func (e TransactionResultCode) ValidEnum(v int32) bool { 11174 _, ok := transactionResultCodeMap[v] 11175 return ok 11176} 11177 11178// String returns the name of `e` 11179func (e TransactionResultCode) String() string { 11180 name, _ := transactionResultCodeMap[int32(e)] 11181 return name 11182} 11183 11184// MarshalBinary implements encoding.BinaryMarshaler. 11185func (s TransactionResultCode) MarshalBinary() ([]byte, error) { 11186 b := new(bytes.Buffer) 11187 _, err := Marshal(b, s) 11188 return b.Bytes(), err 11189} 11190 11191// UnmarshalBinary implements encoding.BinaryUnmarshaler. 11192func (s *TransactionResultCode) UnmarshalBinary(inp []byte) error { 11193 _, err := Unmarshal(bytes.NewReader(inp), s) 11194 return err 11195} 11196 11197var ( 11198 _ encoding.BinaryMarshaler = (*TransactionResultCode)(nil) 11199 _ encoding.BinaryUnmarshaler = (*TransactionResultCode)(nil) 11200) 11201 11202// TransactionResultResult is an XDR NestedUnion defines as: 11203// 11204// union switch (TransactionResultCode code) 11205// { 11206// case txSUCCESS: 11207// case txFAILED: 11208// OperationResult results<>; 11209// default: 11210// void; 11211// } 11212// 11213type TransactionResultResult struct { 11214 Code TransactionResultCode 11215 Results *[]OperationResult 11216} 11217 11218// SwitchFieldName returns the field name in which this union's 11219// discriminant is stored 11220func (u TransactionResultResult) SwitchFieldName() string { 11221 return "Code" 11222} 11223 11224// ArmForSwitch returns which field name should be used for storing 11225// the value for an instance of TransactionResultResult 11226func (u TransactionResultResult) ArmForSwitch(sw int32) (string, bool) { 11227 switch TransactionResultCode(sw) { 11228 case TransactionResultCodeTxSuccess: 11229 return "Results", true 11230 case TransactionResultCodeTxFailed: 11231 return "Results", true 11232 default: 11233 return "", true 11234 } 11235} 11236 11237// NewTransactionResultResult creates a new TransactionResultResult. 11238func NewTransactionResultResult(code TransactionResultCode, value interface{}) (result TransactionResultResult, err error) { 11239 result.Code = code 11240 switch TransactionResultCode(code) { 11241 case TransactionResultCodeTxSuccess: 11242 tv, ok := value.([]OperationResult) 11243 if !ok { 11244 err = fmt.Errorf("invalid value, must be []OperationResult") 11245 return 11246 } 11247 result.Results = &tv 11248 case TransactionResultCodeTxFailed: 11249 tv, ok := value.([]OperationResult) 11250 if !ok { 11251 err = fmt.Errorf("invalid value, must be []OperationResult") 11252 return 11253 } 11254 result.Results = &tv 11255 default: 11256 // void 11257 } 11258 return 11259} 11260 11261// MustResults retrieves the Results value from the union, 11262// panicing if the value is not set. 11263func (u TransactionResultResult) MustResults() []OperationResult { 11264 val, ok := u.GetResults() 11265 11266 if !ok { 11267 panic("arm Results is not set") 11268 } 11269 11270 return val 11271} 11272 11273// GetResults retrieves the Results value from the union, 11274// returning ok if the union's switch indicated the value is valid. 11275func (u TransactionResultResult) GetResults() (result []OperationResult, ok bool) { 11276 armName, _ := u.ArmForSwitch(int32(u.Code)) 11277 11278 if armName == "Results" { 11279 result = *u.Results 11280 ok = true 11281 } 11282 11283 return 11284} 11285 11286// MarshalBinary implements encoding.BinaryMarshaler. 11287func (s TransactionResultResult) MarshalBinary() ([]byte, error) { 11288 b := new(bytes.Buffer) 11289 _, err := Marshal(b, s) 11290 return b.Bytes(), err 11291} 11292 11293// UnmarshalBinary implements encoding.BinaryUnmarshaler. 11294func (s *TransactionResultResult) UnmarshalBinary(inp []byte) error { 11295 _, err := Unmarshal(bytes.NewReader(inp), s) 11296 return err 11297} 11298 11299var ( 11300 _ encoding.BinaryMarshaler = (*TransactionResultResult)(nil) 11301 _ encoding.BinaryUnmarshaler = (*TransactionResultResult)(nil) 11302) 11303 11304// TransactionResultExt is an XDR NestedUnion defines as: 11305// 11306// union switch (int v) 11307// { 11308// case 0: 11309// void; 11310// } 11311// 11312type TransactionResultExt struct { 11313 V int32 11314} 11315 11316// SwitchFieldName returns the field name in which this union's 11317// discriminant is stored 11318func (u TransactionResultExt) SwitchFieldName() string { 11319 return "V" 11320} 11321 11322// ArmForSwitch returns which field name should be used for storing 11323// the value for an instance of TransactionResultExt 11324func (u TransactionResultExt) ArmForSwitch(sw int32) (string, bool) { 11325 switch int32(sw) { 11326 case 0: 11327 return "", true 11328 } 11329 return "-", false 11330} 11331 11332// NewTransactionResultExt creates a new TransactionResultExt. 11333func NewTransactionResultExt(v int32, value interface{}) (result TransactionResultExt, err error) { 11334 result.V = v 11335 switch int32(v) { 11336 case 0: 11337 // void 11338 } 11339 return 11340} 11341 11342// MarshalBinary implements encoding.BinaryMarshaler. 11343func (s TransactionResultExt) MarshalBinary() ([]byte, error) { 11344 b := new(bytes.Buffer) 11345 _, err := Marshal(b, s) 11346 return b.Bytes(), err 11347} 11348 11349// UnmarshalBinary implements encoding.BinaryUnmarshaler. 11350func (s *TransactionResultExt) UnmarshalBinary(inp []byte) error { 11351 _, err := Unmarshal(bytes.NewReader(inp), s) 11352 return err 11353} 11354 11355var ( 11356 _ encoding.BinaryMarshaler = (*TransactionResultExt)(nil) 11357 _ encoding.BinaryUnmarshaler = (*TransactionResultExt)(nil) 11358) 11359 11360// TransactionResult is an XDR Struct defines as: 11361// 11362// struct TransactionResult 11363// { 11364// int64 feeCharged; // actual fee charged for the transaction 11365// 11366// union switch (TransactionResultCode code) 11367// { 11368// case txSUCCESS: 11369// case txFAILED: 11370// OperationResult results<>; 11371// default: 11372// void; 11373// } 11374// result; 11375// 11376// // reserved for future use 11377// union switch (int v) 11378// { 11379// case 0: 11380// void; 11381// } 11382// ext; 11383// }; 11384// 11385type TransactionResult struct { 11386 FeeCharged Int64 11387 Result TransactionResultResult 11388 Ext TransactionResultExt 11389} 11390 11391// MarshalBinary implements encoding.BinaryMarshaler. 11392func (s TransactionResult) MarshalBinary() ([]byte, error) { 11393 b := new(bytes.Buffer) 11394 _, err := Marshal(b, s) 11395 return b.Bytes(), err 11396} 11397 11398// UnmarshalBinary implements encoding.BinaryUnmarshaler. 11399func (s *TransactionResult) UnmarshalBinary(inp []byte) error { 11400 _, err := Unmarshal(bytes.NewReader(inp), s) 11401 return err 11402} 11403 11404var ( 11405 _ encoding.BinaryMarshaler = (*TransactionResult)(nil) 11406 _ encoding.BinaryUnmarshaler = (*TransactionResult)(nil) 11407) 11408 11409// Hash is an XDR Typedef defines as: 11410// 11411// typedef opaque Hash[32]; 11412// 11413type Hash [32]byte 11414 11415// XDRMaxSize implements the Sized interface for Hash 11416func (e Hash) XDRMaxSize() int { 11417 return 32 11418} 11419 11420// MarshalBinary implements encoding.BinaryMarshaler. 11421func (s Hash) MarshalBinary() ([]byte, error) { 11422 b := new(bytes.Buffer) 11423 _, err := Marshal(b, s) 11424 return b.Bytes(), err 11425} 11426 11427// UnmarshalBinary implements encoding.BinaryUnmarshaler. 11428func (s *Hash) UnmarshalBinary(inp []byte) error { 11429 _, err := Unmarshal(bytes.NewReader(inp), s) 11430 return err 11431} 11432 11433var ( 11434 _ encoding.BinaryMarshaler = (*Hash)(nil) 11435 _ encoding.BinaryUnmarshaler = (*Hash)(nil) 11436) 11437 11438// Uint256 is an XDR Typedef defines as: 11439// 11440// typedef opaque uint256[32]; 11441// 11442type Uint256 [32]byte 11443 11444// XDRMaxSize implements the Sized interface for Uint256 11445func (e Uint256) XDRMaxSize() int { 11446 return 32 11447} 11448 11449// MarshalBinary implements encoding.BinaryMarshaler. 11450func (s Uint256) MarshalBinary() ([]byte, error) { 11451 b := new(bytes.Buffer) 11452 _, err := Marshal(b, s) 11453 return b.Bytes(), err 11454} 11455 11456// UnmarshalBinary implements encoding.BinaryUnmarshaler. 11457func (s *Uint256) UnmarshalBinary(inp []byte) error { 11458 _, err := Unmarshal(bytes.NewReader(inp), s) 11459 return err 11460} 11461 11462var ( 11463 _ encoding.BinaryMarshaler = (*Uint256)(nil) 11464 _ encoding.BinaryUnmarshaler = (*Uint256)(nil) 11465) 11466 11467// Uint32 is an XDR Typedef defines as: 11468// 11469// typedef unsigned int uint32; 11470// 11471type Uint32 uint32 11472 11473// MarshalBinary implements encoding.BinaryMarshaler. 11474func (s Uint32) MarshalBinary() ([]byte, error) { 11475 b := new(bytes.Buffer) 11476 _, err := Marshal(b, s) 11477 return b.Bytes(), err 11478} 11479 11480// UnmarshalBinary implements encoding.BinaryUnmarshaler. 11481func (s *Uint32) UnmarshalBinary(inp []byte) error { 11482 _, err := Unmarshal(bytes.NewReader(inp), s) 11483 return err 11484} 11485 11486var ( 11487 _ encoding.BinaryMarshaler = (*Uint32)(nil) 11488 _ encoding.BinaryUnmarshaler = (*Uint32)(nil) 11489) 11490 11491// Int32 is an XDR Typedef defines as: 11492// 11493// typedef int int32; 11494// 11495type Int32 int32 11496 11497// MarshalBinary implements encoding.BinaryMarshaler. 11498func (s Int32) MarshalBinary() ([]byte, error) { 11499 b := new(bytes.Buffer) 11500 _, err := Marshal(b, s) 11501 return b.Bytes(), err 11502} 11503 11504// UnmarshalBinary implements encoding.BinaryUnmarshaler. 11505func (s *Int32) UnmarshalBinary(inp []byte) error { 11506 _, err := Unmarshal(bytes.NewReader(inp), s) 11507 return err 11508} 11509 11510var ( 11511 _ encoding.BinaryMarshaler = (*Int32)(nil) 11512 _ encoding.BinaryUnmarshaler = (*Int32)(nil) 11513) 11514 11515// Uint64 is an XDR Typedef defines as: 11516// 11517// typedef unsigned hyper uint64; 11518// 11519type Uint64 uint64 11520 11521// MarshalBinary implements encoding.BinaryMarshaler. 11522func (s Uint64) MarshalBinary() ([]byte, error) { 11523 b := new(bytes.Buffer) 11524 _, err := Marshal(b, s) 11525 return b.Bytes(), err 11526} 11527 11528// UnmarshalBinary implements encoding.BinaryUnmarshaler. 11529func (s *Uint64) UnmarshalBinary(inp []byte) error { 11530 _, err := Unmarshal(bytes.NewReader(inp), s) 11531 return err 11532} 11533 11534var ( 11535 _ encoding.BinaryMarshaler = (*Uint64)(nil) 11536 _ encoding.BinaryUnmarshaler = (*Uint64)(nil) 11537) 11538 11539// Int64 is an XDR Typedef defines as: 11540// 11541// typedef hyper int64; 11542// 11543type Int64 int64 11544 11545// MarshalBinary implements encoding.BinaryMarshaler. 11546func (s Int64) MarshalBinary() ([]byte, error) { 11547 b := new(bytes.Buffer) 11548 _, err := Marshal(b, s) 11549 return b.Bytes(), err 11550} 11551 11552// UnmarshalBinary implements encoding.BinaryUnmarshaler. 11553func (s *Int64) UnmarshalBinary(inp []byte) error { 11554 _, err := Unmarshal(bytes.NewReader(inp), s) 11555 return err 11556} 11557 11558var ( 11559 _ encoding.BinaryMarshaler = (*Int64)(nil) 11560 _ encoding.BinaryUnmarshaler = (*Int64)(nil) 11561) 11562 11563// CryptoKeyType is an XDR Enum defines as: 11564// 11565// enum CryptoKeyType 11566// { 11567// KEY_TYPE_ED25519 = 0, 11568// KEY_TYPE_PRE_AUTH_TX = 1, 11569// KEY_TYPE_HASH_X = 2 11570// }; 11571// 11572type CryptoKeyType int32 11573 11574const ( 11575 CryptoKeyTypeKeyTypeEd25519 CryptoKeyType = 0 11576 CryptoKeyTypeKeyTypePreAuthTx CryptoKeyType = 1 11577 CryptoKeyTypeKeyTypeHashX CryptoKeyType = 2 11578) 11579 11580var cryptoKeyTypeMap = map[int32]string{ 11581 0: "CryptoKeyTypeKeyTypeEd25519", 11582 1: "CryptoKeyTypeKeyTypePreAuthTx", 11583 2: "CryptoKeyTypeKeyTypeHashX", 11584} 11585 11586// ValidEnum validates a proposed value for this enum. Implements 11587// the Enum interface for CryptoKeyType 11588func (e CryptoKeyType) ValidEnum(v int32) bool { 11589 _, ok := cryptoKeyTypeMap[v] 11590 return ok 11591} 11592 11593// String returns the name of `e` 11594func (e CryptoKeyType) String() string { 11595 name, _ := cryptoKeyTypeMap[int32(e)] 11596 return name 11597} 11598 11599// MarshalBinary implements encoding.BinaryMarshaler. 11600func (s CryptoKeyType) MarshalBinary() ([]byte, error) { 11601 b := new(bytes.Buffer) 11602 _, err := Marshal(b, s) 11603 return b.Bytes(), err 11604} 11605 11606// UnmarshalBinary implements encoding.BinaryUnmarshaler. 11607func (s *CryptoKeyType) UnmarshalBinary(inp []byte) error { 11608 _, err := Unmarshal(bytes.NewReader(inp), s) 11609 return err 11610} 11611 11612var ( 11613 _ encoding.BinaryMarshaler = (*CryptoKeyType)(nil) 11614 _ encoding.BinaryUnmarshaler = (*CryptoKeyType)(nil) 11615) 11616 11617// PublicKeyType is an XDR Enum defines as: 11618// 11619// enum PublicKeyType 11620// { 11621// PUBLIC_KEY_TYPE_ED25519 = KEY_TYPE_ED25519 11622// }; 11623// 11624type PublicKeyType int32 11625 11626const ( 11627 PublicKeyTypePublicKeyTypeEd25519 PublicKeyType = 0 11628) 11629 11630var publicKeyTypeMap = map[int32]string{ 11631 0: "PublicKeyTypePublicKeyTypeEd25519", 11632} 11633 11634// ValidEnum validates a proposed value for this enum. Implements 11635// the Enum interface for PublicKeyType 11636func (e PublicKeyType) ValidEnum(v int32) bool { 11637 _, ok := publicKeyTypeMap[v] 11638 return ok 11639} 11640 11641// String returns the name of `e` 11642func (e PublicKeyType) String() string { 11643 name, _ := publicKeyTypeMap[int32(e)] 11644 return name 11645} 11646 11647// MarshalBinary implements encoding.BinaryMarshaler. 11648func (s PublicKeyType) MarshalBinary() ([]byte, error) { 11649 b := new(bytes.Buffer) 11650 _, err := Marshal(b, s) 11651 return b.Bytes(), err 11652} 11653 11654// UnmarshalBinary implements encoding.BinaryUnmarshaler. 11655func (s *PublicKeyType) UnmarshalBinary(inp []byte) error { 11656 _, err := Unmarshal(bytes.NewReader(inp), s) 11657 return err 11658} 11659 11660var ( 11661 _ encoding.BinaryMarshaler = (*PublicKeyType)(nil) 11662 _ encoding.BinaryUnmarshaler = (*PublicKeyType)(nil) 11663) 11664 11665// SignerKeyType is an XDR Enum defines as: 11666// 11667// enum SignerKeyType 11668// { 11669// SIGNER_KEY_TYPE_ED25519 = KEY_TYPE_ED25519, 11670// SIGNER_KEY_TYPE_PRE_AUTH_TX = KEY_TYPE_PRE_AUTH_TX, 11671// SIGNER_KEY_TYPE_HASH_X = KEY_TYPE_HASH_X 11672// }; 11673// 11674type SignerKeyType int32 11675 11676const ( 11677 SignerKeyTypeSignerKeyTypeEd25519 SignerKeyType = 0 11678 SignerKeyTypeSignerKeyTypePreAuthTx SignerKeyType = 1 11679 SignerKeyTypeSignerKeyTypeHashX SignerKeyType = 2 11680) 11681 11682var signerKeyTypeMap = map[int32]string{ 11683 0: "SignerKeyTypeSignerKeyTypeEd25519", 11684 1: "SignerKeyTypeSignerKeyTypePreAuthTx", 11685 2: "SignerKeyTypeSignerKeyTypeHashX", 11686} 11687 11688// ValidEnum validates a proposed value for this enum. Implements 11689// the Enum interface for SignerKeyType 11690func (e SignerKeyType) ValidEnum(v int32) bool { 11691 _, ok := signerKeyTypeMap[v] 11692 return ok 11693} 11694 11695// String returns the name of `e` 11696func (e SignerKeyType) String() string { 11697 name, _ := signerKeyTypeMap[int32(e)] 11698 return name 11699} 11700 11701// MarshalBinary implements encoding.BinaryMarshaler. 11702func (s SignerKeyType) MarshalBinary() ([]byte, error) { 11703 b := new(bytes.Buffer) 11704 _, err := Marshal(b, s) 11705 return b.Bytes(), err 11706} 11707 11708// UnmarshalBinary implements encoding.BinaryUnmarshaler. 11709func (s *SignerKeyType) UnmarshalBinary(inp []byte) error { 11710 _, err := Unmarshal(bytes.NewReader(inp), s) 11711 return err 11712} 11713 11714var ( 11715 _ encoding.BinaryMarshaler = (*SignerKeyType)(nil) 11716 _ encoding.BinaryUnmarshaler = (*SignerKeyType)(nil) 11717) 11718 11719// PublicKey is an XDR Union defines as: 11720// 11721// union PublicKey switch (PublicKeyType type) 11722// { 11723// case PUBLIC_KEY_TYPE_ED25519: 11724// uint256 ed25519; 11725// }; 11726// 11727type PublicKey struct { 11728 Type PublicKeyType 11729 Ed25519 *Uint256 11730} 11731 11732// SwitchFieldName returns the field name in which this union's 11733// discriminant is stored 11734func (u PublicKey) SwitchFieldName() string { 11735 return "Type" 11736} 11737 11738// ArmForSwitch returns which field name should be used for storing 11739// the value for an instance of PublicKey 11740func (u PublicKey) ArmForSwitch(sw int32) (string, bool) { 11741 switch PublicKeyType(sw) { 11742 case PublicKeyTypePublicKeyTypeEd25519: 11743 return "Ed25519", true 11744 } 11745 return "-", false 11746} 11747 11748// NewPublicKey creates a new PublicKey. 11749func NewPublicKey(aType PublicKeyType, value interface{}) (result PublicKey, err error) { 11750 result.Type = aType 11751 switch PublicKeyType(aType) { 11752 case PublicKeyTypePublicKeyTypeEd25519: 11753 tv, ok := value.(Uint256) 11754 if !ok { 11755 err = fmt.Errorf("invalid value, must be Uint256") 11756 return 11757 } 11758 result.Ed25519 = &tv 11759 } 11760 return 11761} 11762 11763// MustEd25519 retrieves the Ed25519 value from the union, 11764// panicing if the value is not set. 11765func (u PublicKey) MustEd25519() Uint256 { 11766 val, ok := u.GetEd25519() 11767 11768 if !ok { 11769 panic("arm Ed25519 is not set") 11770 } 11771 11772 return val 11773} 11774 11775// GetEd25519 retrieves the Ed25519 value from the union, 11776// returning ok if the union's switch indicated the value is valid. 11777func (u PublicKey) GetEd25519() (result Uint256, ok bool) { 11778 armName, _ := u.ArmForSwitch(int32(u.Type)) 11779 11780 if armName == "Ed25519" { 11781 result = *u.Ed25519 11782 ok = true 11783 } 11784 11785 return 11786} 11787 11788// MarshalBinary implements encoding.BinaryMarshaler. 11789func (s PublicKey) MarshalBinary() ([]byte, error) { 11790 b := new(bytes.Buffer) 11791 _, err := Marshal(b, s) 11792 return b.Bytes(), err 11793} 11794 11795// UnmarshalBinary implements encoding.BinaryUnmarshaler. 11796func (s *PublicKey) UnmarshalBinary(inp []byte) error { 11797 _, err := Unmarshal(bytes.NewReader(inp), s) 11798 return err 11799} 11800 11801var ( 11802 _ encoding.BinaryMarshaler = (*PublicKey)(nil) 11803 _ encoding.BinaryUnmarshaler = (*PublicKey)(nil) 11804) 11805 11806// SignerKey is an XDR Union defines as: 11807// 11808// union SignerKey switch (SignerKeyType type) 11809// { 11810// case SIGNER_KEY_TYPE_ED25519: 11811// uint256 ed25519; 11812// case SIGNER_KEY_TYPE_PRE_AUTH_TX: 11813// /* SHA-256 Hash of TransactionSignaturePayload structure */ 11814// uint256 preAuthTx; 11815// case SIGNER_KEY_TYPE_HASH_X: 11816// /* Hash of random 256 bit preimage X */ 11817// uint256 hashX; 11818// }; 11819// 11820type SignerKey struct { 11821 Type SignerKeyType 11822 Ed25519 *Uint256 11823 PreAuthTx *Uint256 11824 HashX *Uint256 11825} 11826 11827// SwitchFieldName returns the field name in which this union's 11828// discriminant is stored 11829func (u SignerKey) SwitchFieldName() string { 11830 return "Type" 11831} 11832 11833// ArmForSwitch returns which field name should be used for storing 11834// the value for an instance of SignerKey 11835func (u SignerKey) ArmForSwitch(sw int32) (string, bool) { 11836 switch SignerKeyType(sw) { 11837 case SignerKeyTypeSignerKeyTypeEd25519: 11838 return "Ed25519", true 11839 case SignerKeyTypeSignerKeyTypePreAuthTx: 11840 return "PreAuthTx", true 11841 case SignerKeyTypeSignerKeyTypeHashX: 11842 return "HashX", true 11843 } 11844 return "-", false 11845} 11846 11847// NewSignerKey creates a new SignerKey. 11848func NewSignerKey(aType SignerKeyType, value interface{}) (result SignerKey, err error) { 11849 result.Type = aType 11850 switch SignerKeyType(aType) { 11851 case SignerKeyTypeSignerKeyTypeEd25519: 11852 tv, ok := value.(Uint256) 11853 if !ok { 11854 err = fmt.Errorf("invalid value, must be Uint256") 11855 return 11856 } 11857 result.Ed25519 = &tv 11858 case SignerKeyTypeSignerKeyTypePreAuthTx: 11859 tv, ok := value.(Uint256) 11860 if !ok { 11861 err = fmt.Errorf("invalid value, must be Uint256") 11862 return 11863 } 11864 result.PreAuthTx = &tv 11865 case SignerKeyTypeSignerKeyTypeHashX: 11866 tv, ok := value.(Uint256) 11867 if !ok { 11868 err = fmt.Errorf("invalid value, must be Uint256") 11869 return 11870 } 11871 result.HashX = &tv 11872 } 11873 return 11874} 11875 11876// MustEd25519 retrieves the Ed25519 value from the union, 11877// panicing if the value is not set. 11878func (u SignerKey) MustEd25519() Uint256 { 11879 val, ok := u.GetEd25519() 11880 11881 if !ok { 11882 panic("arm Ed25519 is not set") 11883 } 11884 11885 return val 11886} 11887 11888// GetEd25519 retrieves the Ed25519 value from the union, 11889// returning ok if the union's switch indicated the value is valid. 11890func (u SignerKey) GetEd25519() (result Uint256, ok bool) { 11891 armName, _ := u.ArmForSwitch(int32(u.Type)) 11892 11893 if armName == "Ed25519" { 11894 result = *u.Ed25519 11895 ok = true 11896 } 11897 11898 return 11899} 11900 11901// MustPreAuthTx retrieves the PreAuthTx value from the union, 11902// panicing if the value is not set. 11903func (u SignerKey) MustPreAuthTx() Uint256 { 11904 val, ok := u.GetPreAuthTx() 11905 11906 if !ok { 11907 panic("arm PreAuthTx is not set") 11908 } 11909 11910 return val 11911} 11912 11913// GetPreAuthTx retrieves the PreAuthTx value from the union, 11914// returning ok if the union's switch indicated the value is valid. 11915func (u SignerKey) GetPreAuthTx() (result Uint256, ok bool) { 11916 armName, _ := u.ArmForSwitch(int32(u.Type)) 11917 11918 if armName == "PreAuthTx" { 11919 result = *u.PreAuthTx 11920 ok = true 11921 } 11922 11923 return 11924} 11925 11926// MustHashX retrieves the HashX value from the union, 11927// panicing if the value is not set. 11928func (u SignerKey) MustHashX() Uint256 { 11929 val, ok := u.GetHashX() 11930 11931 if !ok { 11932 panic("arm HashX is not set") 11933 } 11934 11935 return val 11936} 11937 11938// GetHashX retrieves the HashX value from the union, 11939// returning ok if the union's switch indicated the value is valid. 11940func (u SignerKey) GetHashX() (result Uint256, ok bool) { 11941 armName, _ := u.ArmForSwitch(int32(u.Type)) 11942 11943 if armName == "HashX" { 11944 result = *u.HashX 11945 ok = true 11946 } 11947 11948 return 11949} 11950 11951// MarshalBinary implements encoding.BinaryMarshaler. 11952func (s SignerKey) MarshalBinary() ([]byte, error) { 11953 b := new(bytes.Buffer) 11954 _, err := Marshal(b, s) 11955 return b.Bytes(), err 11956} 11957 11958// UnmarshalBinary implements encoding.BinaryUnmarshaler. 11959func (s *SignerKey) UnmarshalBinary(inp []byte) error { 11960 _, err := Unmarshal(bytes.NewReader(inp), s) 11961 return err 11962} 11963 11964var ( 11965 _ encoding.BinaryMarshaler = (*SignerKey)(nil) 11966 _ encoding.BinaryUnmarshaler = (*SignerKey)(nil) 11967) 11968 11969// Signature is an XDR Typedef defines as: 11970// 11971// typedef opaque Signature<64>; 11972// 11973type Signature []byte 11974 11975// XDRMaxSize implements the Sized interface for Signature 11976func (e Signature) XDRMaxSize() int { 11977 return 64 11978} 11979 11980// MarshalBinary implements encoding.BinaryMarshaler. 11981func (s Signature) MarshalBinary() ([]byte, error) { 11982 b := new(bytes.Buffer) 11983 _, err := Marshal(b, s) 11984 return b.Bytes(), err 11985} 11986 11987// UnmarshalBinary implements encoding.BinaryUnmarshaler. 11988func (s *Signature) UnmarshalBinary(inp []byte) error { 11989 _, err := Unmarshal(bytes.NewReader(inp), s) 11990 return err 11991} 11992 11993var ( 11994 _ encoding.BinaryMarshaler = (*Signature)(nil) 11995 _ encoding.BinaryUnmarshaler = (*Signature)(nil) 11996) 11997 11998// SignatureHint is an XDR Typedef defines as: 11999// 12000// typedef opaque SignatureHint[4]; 12001// 12002type SignatureHint [4]byte 12003 12004// XDRMaxSize implements the Sized interface for SignatureHint 12005func (e SignatureHint) XDRMaxSize() int { 12006 return 4 12007} 12008 12009// MarshalBinary implements encoding.BinaryMarshaler. 12010func (s SignatureHint) MarshalBinary() ([]byte, error) { 12011 b := new(bytes.Buffer) 12012 _, err := Marshal(b, s) 12013 return b.Bytes(), err 12014} 12015 12016// UnmarshalBinary implements encoding.BinaryUnmarshaler. 12017func (s *SignatureHint) UnmarshalBinary(inp []byte) error { 12018 _, err := Unmarshal(bytes.NewReader(inp), s) 12019 return err 12020} 12021 12022var ( 12023 _ encoding.BinaryMarshaler = (*SignatureHint)(nil) 12024 _ encoding.BinaryUnmarshaler = (*SignatureHint)(nil) 12025) 12026 12027// NodeId is an XDR Typedef defines as: 12028// 12029// typedef PublicKey NodeID; 12030// 12031type NodeId PublicKey 12032 12033// SwitchFieldName returns the field name in which this union's 12034// discriminant is stored 12035func (u NodeId) SwitchFieldName() string { 12036 return PublicKey(u).SwitchFieldName() 12037} 12038 12039// ArmForSwitch returns which field name should be used for storing 12040// the value for an instance of PublicKey 12041func (u NodeId) ArmForSwitch(sw int32) (string, bool) { 12042 return PublicKey(u).ArmForSwitch(sw) 12043} 12044 12045// NewNodeId creates a new NodeId. 12046func NewNodeId(aType PublicKeyType, value interface{}) (result NodeId, err error) { 12047 u, err := NewPublicKey(aType, value) 12048 result = NodeId(u) 12049 return 12050} 12051 12052// MustEd25519 retrieves the Ed25519 value from the union, 12053// panicing if the value is not set. 12054func (u NodeId) MustEd25519() Uint256 { 12055 return PublicKey(u).MustEd25519() 12056} 12057 12058// GetEd25519 retrieves the Ed25519 value from the union, 12059// returning ok if the union's switch indicated the value is valid. 12060func (u NodeId) GetEd25519() (result Uint256, ok bool) { 12061 return PublicKey(u).GetEd25519() 12062} 12063 12064// MarshalBinary implements encoding.BinaryMarshaler. 12065func (s NodeId) MarshalBinary() ([]byte, error) { 12066 b := new(bytes.Buffer) 12067 _, err := Marshal(b, s) 12068 return b.Bytes(), err 12069} 12070 12071// UnmarshalBinary implements encoding.BinaryUnmarshaler. 12072func (s *NodeId) UnmarshalBinary(inp []byte) error { 12073 _, err := Unmarshal(bytes.NewReader(inp), s) 12074 return err 12075} 12076 12077var ( 12078 _ encoding.BinaryMarshaler = (*NodeId)(nil) 12079 _ encoding.BinaryUnmarshaler = (*NodeId)(nil) 12080) 12081 12082// Curve25519Secret is an XDR Struct defines as: 12083// 12084// struct Curve25519Secret 12085// { 12086// opaque key[32]; 12087// }; 12088// 12089type Curve25519Secret struct { 12090 Key [32]byte `xdrmaxsize:"32"` 12091} 12092 12093// MarshalBinary implements encoding.BinaryMarshaler. 12094func (s Curve25519Secret) MarshalBinary() ([]byte, error) { 12095 b := new(bytes.Buffer) 12096 _, err := Marshal(b, s) 12097 return b.Bytes(), err 12098} 12099 12100// UnmarshalBinary implements encoding.BinaryUnmarshaler. 12101func (s *Curve25519Secret) UnmarshalBinary(inp []byte) error { 12102 _, err := Unmarshal(bytes.NewReader(inp), s) 12103 return err 12104} 12105 12106var ( 12107 _ encoding.BinaryMarshaler = (*Curve25519Secret)(nil) 12108 _ encoding.BinaryUnmarshaler = (*Curve25519Secret)(nil) 12109) 12110 12111// Curve25519Public is an XDR Struct defines as: 12112// 12113// struct Curve25519Public 12114// { 12115// opaque key[32]; 12116// }; 12117// 12118type Curve25519Public struct { 12119 Key [32]byte `xdrmaxsize:"32"` 12120} 12121 12122// MarshalBinary implements encoding.BinaryMarshaler. 12123func (s Curve25519Public) MarshalBinary() ([]byte, error) { 12124 b := new(bytes.Buffer) 12125 _, err := Marshal(b, s) 12126 return b.Bytes(), err 12127} 12128 12129// UnmarshalBinary implements encoding.BinaryUnmarshaler. 12130func (s *Curve25519Public) UnmarshalBinary(inp []byte) error { 12131 _, err := Unmarshal(bytes.NewReader(inp), s) 12132 return err 12133} 12134 12135var ( 12136 _ encoding.BinaryMarshaler = (*Curve25519Public)(nil) 12137 _ encoding.BinaryUnmarshaler = (*Curve25519Public)(nil) 12138) 12139 12140// HmacSha256Key is an XDR Struct defines as: 12141// 12142// struct HmacSha256Key 12143// { 12144// opaque key[32]; 12145// }; 12146// 12147type HmacSha256Key struct { 12148 Key [32]byte `xdrmaxsize:"32"` 12149} 12150 12151// MarshalBinary implements encoding.BinaryMarshaler. 12152func (s HmacSha256Key) MarshalBinary() ([]byte, error) { 12153 b := new(bytes.Buffer) 12154 _, err := Marshal(b, s) 12155 return b.Bytes(), err 12156} 12157 12158// UnmarshalBinary implements encoding.BinaryUnmarshaler. 12159func (s *HmacSha256Key) UnmarshalBinary(inp []byte) error { 12160 _, err := Unmarshal(bytes.NewReader(inp), s) 12161 return err 12162} 12163 12164var ( 12165 _ encoding.BinaryMarshaler = (*HmacSha256Key)(nil) 12166 _ encoding.BinaryUnmarshaler = (*HmacSha256Key)(nil) 12167) 12168 12169// HmacSha256Mac is an XDR Struct defines as: 12170// 12171// struct HmacSha256Mac 12172// { 12173// opaque mac[32]; 12174// }; 12175// 12176type HmacSha256Mac struct { 12177 Mac [32]byte `xdrmaxsize:"32"` 12178} 12179 12180// MarshalBinary implements encoding.BinaryMarshaler. 12181func (s HmacSha256Mac) MarshalBinary() ([]byte, error) { 12182 b := new(bytes.Buffer) 12183 _, err := Marshal(b, s) 12184 return b.Bytes(), err 12185} 12186 12187// UnmarshalBinary implements encoding.BinaryUnmarshaler. 12188func (s *HmacSha256Mac) UnmarshalBinary(inp []byte) error { 12189 _, err := Unmarshal(bytes.NewReader(inp), s) 12190 return err 12191} 12192 12193var ( 12194 _ encoding.BinaryMarshaler = (*HmacSha256Mac)(nil) 12195 _ encoding.BinaryUnmarshaler = (*HmacSha256Mac)(nil) 12196) 12197 12198var fmtTest = fmt.Sprint("this is a dummy usage of fmt") 12199