xdr

package
Version: v0.0.0-...-d906eff Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2021 License: Apache-2.0 Imports: 21 Imported by: 390

Documentation

Overview

Package xdr contains the generated code for parsing the xdr structures used for stellar.

Package xdr is generated from:

Stellar-SCP.x
Stellar-ledger-entries.x
Stellar-ledger.x
Stellar-overlay.x
Stellar-transaction.x
Stellar-types.x

DO NOT EDIT or your changes may be overwritten

Index

Examples

Constants

View Source
const LiquidityPoolFeeV18 = 30

LiquidityPoolFeeV18 is an XDR Const defines as:

const LIQUIDITY_POOL_FEE_V18 = 30;
View Source
const MaskAccountFlags = 0x7

MaskAccountFlags is an XDR Const defines as:

const MASK_ACCOUNT_FLAGS = 0x7;
View Source
const MaskAccountFlagsV17 = 0xF

MaskAccountFlagsV17 is an XDR Const defines as:

const MASK_ACCOUNT_FLAGS_V17 = 0xF;
View Source
const MaskClaimableBalanceFlags = 0x1

MaskClaimableBalanceFlags is an XDR Const defines as:

const MASK_CLAIMABLE_BALANCE_FLAGS = 0x1;
View Source
const MaskLedgerheaderFlags = 0x7

MaskLedgerheaderFlags is an XDR Const defines as:

const MASK_LEDGERHEADER_FLAGS = 0x7;
View Source
const MaskOfferentryFlags = 1

MaskOfferentryFlags is an XDR Const defines as:

const MASK_OFFERENTRY_FLAGS = 1;
View Source
const MaskTrustlineFlags = 1

MaskTrustlineFlags is an XDR Const defines as:

const MASK_TRUSTLINE_FLAGS = 1;
View Source
const MaskTrustlineFlagsV13 = 3

MaskTrustlineFlagsV13 is an XDR Const defines as:

const MASK_TRUSTLINE_FLAGS_V13 = 3;
View Source
const MaskTrustlineFlagsV17 = 7

MaskTrustlineFlagsV17 is an XDR Const defines as:

const MASK_TRUSTLINE_FLAGS_V17 = 7;
View Source
const MaxOpsPerTx = 100

MaxOpsPerTx is an XDR Const defines as:

const MAX_OPS_PER_TX = 100;
View Source
const MaxSigners = 20

MaxSigners is an XDR Const defines as:

const MAX_SIGNERS = 20;

Variables

View Source
var AssetTypeToString = map[AssetType]string{
	AssetTypeAssetTypeNative:           "native",
	AssetTypeAssetTypeCreditAlphanum4:  "credit_alphanum4",
	AssetTypeAssetTypeCreditAlphanum12: "credit_alphanum12",
}

AssetTypeToString maps an xdr.AssetType to its string representation

View Source
var LiquidityPoolTypeToString = map[LiquidityPoolType]string{
	LiquidityPoolTypeLiquidityPoolConstantProduct: "constant_product",
}

LiquidityPoolTypeToString maps an xdr.LiquidityPoolType to its string representation

View Source
var OperationTypeToStringMap = operationTypeMap
View Source
var StringToAssetType = map[string]AssetType{
	"native":            AssetTypeAssetTypeNative,
	"credit_alphanum4":  AssetTypeAssetTypeCreditAlphanum4,
	"credit_alphanum12": AssetTypeAssetTypeCreditAlphanum12,
}

StringToAssetType maps an strings to its xdr.AssetType representation

View Source
var ValidAssetCode = regexp.MustCompile("^[[:alnum:]]{1,12}$")

Functions

func Marshal

func Marshal(w io.Writer, v interface{}) (int, error)

Marshal writes an xdr element `v` into `w`.

func MarshalBase64

func MarshalBase64(v interface{}) (string, error)

func MarshalFramed

func MarshalFramed(w io.Writer, v interface{}) error

func MarshalHex

func MarshalHex(v interface{}) (string, error)

func ReadFrameLength

func ReadFrameLength(r io.Reader) (uint32, error)

ReadFrameLength returns a length of a framed XDR object.

func SafeUnmarshal

func SafeUnmarshal(data []byte, dest interface{}) error

SafeUnmarshal decodes the provided reader into the destination and verifies that provided bytes are all consumed by the unmarshalling process.

func SafeUnmarshalBase64

func SafeUnmarshalBase64(data string, dest interface{}) error

SafeUnmarshalBase64 first decodes the provided reader from base64 before decoding the xdr into the provided destination. Also ensures that the reader is fully consumed.

func SafeUnmarshalHex

func SafeUnmarshalHex(data string, dest interface{}) error

SafeUnmarshalHex first decodes the provided reader from hex before decoding the xdr into the provided destination. Also ensures that the reader is fully consumed.

func Unmarshal

func Unmarshal(r io.Reader, v interface{}) (int, error)

Unmarshal reads an xdr element from `r` into `v`.

Example

ExampleUnmarshal shows the lowest-level process to decode a base64 envelope encoded in base64.

data := "AAAAAgAAAABi/B0L0JGythwN1lY0aypo19NHxvLCyO5tBEcCVvwF9wAAAAoAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAK6jei3jmoI8TGlD/egc37PXtHKKzWV8wViZBaCu5L5MAAAAADuaygAAAAAAAAAAAVb8BfcAAABACmeyD4/+Oj7llOmTrcjKLHLTQJF0TV/VggCOUZ30ZPgMsQy6A2T//Zdzb7MULVo/Y7kDrqAZRS51rvIp7YMUAA=="

rawr := strings.NewReader(data)
b64r := base64.NewDecoder(base64.StdEncoding, rawr)

var tx TransactionEnvelope
bytesRead, err := Unmarshal(b64r, &tx)

fmt.Printf("read %d bytes\n", bytesRead)

if err != nil {
	log.Fatal(err)
}

operations := tx.Operations()
fmt.Printf("This tx has %d operations\n", len(operations))
Output:

read 196 bytes
This tx has 1 operations

func UnmarshalFramed

func UnmarshalFramed(r io.Reader, v interface{}) (int, error)

XDR and RPC define a (minimal) framing format which our metadata arrives in: a 4-byte big-endian length header that has the high bit set, followed by that length worth of XDR data. Decoding this involves just a little more work than xdr.Unmarshal.

Types

type AccountEntry

type AccountEntry struct {
	AccountId     AccountId
	Balance       Int64
	SeqNum        SequenceNumber
	NumSubEntries Uint32
	InflationDest *AccountId
	Flags         Uint32
	HomeDomain    String32
	Thresholds    Thresholds
	Signers       []Signer `xdrmaxsize:"20"`
	Ext           AccountEntryExt
}

AccountEntry is an XDR Struct defines as:

struct AccountEntry
 {
     AccountID accountID;      // master public key for this account
     int64 balance;            // in stroops
     SequenceNumber seqNum;    // last sequence number used for this account
     uint32 numSubEntries;     // number of sub-entries this account has
                               // drives the reserve
     AccountID* inflationDest; // Account to vote for during inflation
     uint32 flags;             // see AccountFlags

     string32 homeDomain; // can be used for reverse federation and memo lookup

     // fields used for signatures
     // thresholds stores unsigned bytes: [weight of master|low|medium|high]
     Thresholds thresholds;

     Signer signers<MAX_SIGNERS>; // possible signers for this account

     // reserved for future use
     union switch (int v)
     {
     case 0:
         void;
     case 1:
         AccountEntryExtensionV1 v1;
     }
     ext;
 };

func (*AccountEntry) Liabilities

func (account *AccountEntry) Liabilities() Liabilities

Liabilities returns AccountEntry's liabilities

func (AccountEntry) MarshalBinary

func (s AccountEntry) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (*AccountEntry) MasterKeyWeight

func (account *AccountEntry) MasterKeyWeight() byte

func (*AccountEntry) NumSponsored

func (account *AccountEntry) NumSponsored() Uint32

NumSponsored returns NumSponsored value for account.

func (*AccountEntry) NumSponsoring

func (account *AccountEntry) NumSponsoring() Uint32

NumSponsoring returns NumSponsoring value for account.

func (*AccountEntry) SignerSponsoringIDs

func (account *AccountEntry) SignerSponsoringIDs() []SponsorshipDescriptor

SignerSponsoringIDs returns SignerSponsoringIDs value for account. This will return a slice of nil values if V2 extension does not exist.

func (*AccountEntry) SignerSummary

func (account *AccountEntry) SignerSummary() map[string]int32

func (*AccountEntry) SponsorPerSigner

func (account *AccountEntry) SponsorPerSigner() map[string]AccountId

SponsorPerSigner returns a mapping of signer to its sponsor

func (*AccountEntry) ThresholdHigh

func (account *AccountEntry) ThresholdHigh() byte

func (*AccountEntry) ThresholdLow

func (account *AccountEntry) ThresholdLow() byte

func (*AccountEntry) ThresholdMedium

func (account *AccountEntry) ThresholdMedium() byte

func (*AccountEntry) UnmarshalBinary

func (s *AccountEntry) UnmarshalBinary(inp []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler.

type AccountEntryExt

type AccountEntryExt struct {
	V  int32
	V1 *AccountEntryExtensionV1
}

AccountEntryExt is an XDR NestedUnion defines as:

union switch (int v)
     {
     case 0:
         void;
     case 1:
         AccountEntryExtensionV1 v1;
     }

func NewAccountEntryExt

func NewAccountEntryExt(v int32, value interface{}) (result AccountEntryExt, err error)

NewAccountEntryExt creates a new AccountEntryExt.

func (AccountEntryExt) ArmForSwitch

func (u AccountEntryExt) ArmForSwitch(sw int32) (string, bool)

ArmForSwitch returns which field name should be used for storing the value for an instance of AccountEntryExt

func (AccountEntryExt) GetV1

func (u AccountEntryExt) GetV1() (result AccountEntryExtensionV1, ok bool)

GetV1 retrieves the V1 value from the union, returning ok if the union's switch indicated the value is valid.

func (AccountEntryExt) MarshalBinary

func (s AccountEntryExt) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (AccountEntryExt) MustV1

MustV1 retrieves the V1 value from the union, panicing if the value is not set.

func (AccountEntryExt) SwitchFieldName

func (u AccountEntryExt) SwitchFieldName() string

SwitchFieldName returns the field name in which this union's discriminant is stored

func (*AccountEntryExt) UnmarshalBinary

func (s *AccountEntryExt) UnmarshalBinary(inp []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler.

type AccountEntryExtensionV1

type AccountEntryExtensionV1 struct {
	Liabilities Liabilities
	Ext         AccountEntryExtensionV1Ext
}

AccountEntryExtensionV1 is an XDR Struct defines as:

struct AccountEntryExtensionV1
 {
     Liabilities liabilities;

     union switch (int v)
     {
     case 0:
         void;
     case 2:
         AccountEntryExtensionV2 v2;
     }
     ext;
 };

func (AccountEntryExtensionV1) MarshalBinary

func (s AccountEntryExtensionV1) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (*AccountEntryExtensionV1) UnmarshalBinary

func (s *AccountEntryExtensionV1) UnmarshalBinary(inp []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler.

type AccountEntryExtensionV1Ext

type AccountEntryExtensionV1Ext struct {
	V  int32
	V2 *AccountEntryExtensionV2
}

AccountEntryExtensionV1Ext is an XDR NestedUnion defines as:

union switch (int v)
     {
     case 0:
         void;
     case 2:
         AccountEntryExtensionV2 v2;
     }

func NewAccountEntryExtensionV1Ext

func NewAccountEntryExtensionV1Ext(v int32, value interface{}) (result AccountEntryExtensionV1Ext, err error)

NewAccountEntryExtensionV1Ext creates a new AccountEntryExtensionV1Ext.

func (AccountEntryExtensionV1Ext) ArmForSwitch

func (u AccountEntryExtensionV1Ext) ArmForSwitch(sw int32) (string, bool)

ArmForSwitch returns which field name should be used for storing the value for an instance of AccountEntryExtensionV1Ext

func (AccountEntryExtensionV1Ext) GetV2

GetV2 retrieves the V2 value from the union, returning ok if the union's switch indicated the value is valid.

func (AccountEntryExtensionV1Ext) MarshalBinary

func (s AccountEntryExtensionV1Ext) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (AccountEntryExtensionV1Ext) MustV2

MustV2 retrieves the V2 value from the union, panicing if the value is not set.

func (AccountEntryExtensionV1Ext) SwitchFieldName

func (u AccountEntryExtensionV1Ext) SwitchFieldName() string

SwitchFieldName returns the field name in which this union's discriminant is stored

func (*AccountEntryExtensionV1Ext) UnmarshalBinary

func (s *AccountEntryExtensionV1Ext) UnmarshalBinary(inp []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler.

type AccountEntryExtensionV2

type AccountEntryExtensionV2 struct {
	NumSponsored        Uint32
	NumSponsoring       Uint32
	SignerSponsoringIDs []SponsorshipDescriptor `xdrmaxsize:"20"`
	Ext                 AccountEntryExtensionV2Ext
}

AccountEntryExtensionV2 is an XDR Struct defines as:

struct AccountEntryExtensionV2
 {
     uint32 numSponsored;
     uint32 numSponsoring;
     SponsorshipDescriptor signerSponsoringIDs<MAX_SIGNERS>;

     union switch (int v)
     {
     case 0:
         void;
     }
     ext;
 };

func (AccountEntryExtensionV2) MarshalBinary

func (s AccountEntryExtensionV2) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (*AccountEntryExtensionV2) UnmarshalBinary

func (s *AccountEntryExtensionV2) UnmarshalBinary(inp []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler.

type AccountEntryExtensionV2Ext

type AccountEntryExtensionV2Ext struct {
	V int32
}

AccountEntryExtensionV2Ext is an XDR NestedUnion defines as:

union switch (int v)
     {
     case 0:
         void;
     }

func NewAccountEntryExtensionV2Ext

func NewAccountEntryExtensionV2Ext(v int32, value interface{}) (result AccountEntryExtensionV2Ext, err error)

NewAccountEntryExtensionV2Ext creates a new AccountEntryExtensionV2Ext.

func (AccountEntryExtensionV2Ext) ArmForSwitch

func (u AccountEntryExtensionV2Ext) ArmForSwitch(sw int32) (string, bool)

ArmForSwitch returns which field name should be used for storing the value for an instance of AccountEntryExtensionV2Ext

func (AccountEntryExtensionV2Ext) MarshalBinary

func (s AccountEntryExtensionV2Ext) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (AccountEntryExtensionV2Ext) SwitchFieldName

func (u AccountEntryExtensionV2Ext) SwitchFieldName() string

SwitchFieldName returns the field name in which this union's discriminant is stored

func (*AccountEntryExtensionV2Ext) UnmarshalBinary

func (s *AccountEntryExtensionV2Ext) UnmarshalBinary(inp []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler.

type AccountFlags

type AccountFlags int32

AccountFlags is an XDR Enum defines as:

enum AccountFlags
 { // masks for each flag

     // Flags set on issuer accounts
     // TrustLines are created with authorized set to "false" requiring
     // the issuer to set it for each TrustLine
     AUTH_REQUIRED_FLAG = 0x1,
     // If set, the authorized flag in TrustLines can be cleared
     // otherwise, authorization cannot be revoked
     AUTH_REVOCABLE_FLAG = 0x2,
     // Once set, causes all AUTH_* flags to be read-only
     AUTH_IMMUTABLE_FLAG = 0x4,
     // Trustlines are created with clawback enabled set to "true",
     // and claimable balances created from those trustlines are created
     // with clawback enabled set to "true"
     AUTH_CLAWBACK_ENABLED_FLAG = 0x8
 };
const (
	AccountFlagsAuthRequiredFlag        AccountFlags = 1
	AccountFlagsAuthRevocableFlag       AccountFlags = 2
	AccountFlagsAuthImmutableFlag       AccountFlags = 4
	AccountFlagsAuthClawbackEnabledFlag AccountFlags = 8
)

func (AccountFlags) IsAuthClawbackEnabled

func (accountFlags AccountFlags) IsAuthClawbackEnabled() bool

IsAuthClawbackEnabled returns true if the account has the "AUTH_CLAWBACK_ENABLED" option turned on.

func (AccountFlags) IsAuthImmutable

func (accountFlags AccountFlags) IsAuthImmutable() bool

IsAuthImmutable returns true if the account has the "AUTH_IMMUTABLE" option turned on.

func (AccountFlags) IsAuthRequired

func (accountFlags AccountFlags) IsAuthRequired() bool

IsAuthRequired returns true if the account has the "AUTH_REQUIRED" option turned on.

func (AccountFlags) IsAuthRevocable

func (accountFlags AccountFlags) IsAuthRevocable() bool

IsAuthRevocable returns true if the account has the "AUTH_REVOCABLE" option turned on.

func (AccountFlags) MarshalBinary

func (s AccountFlags) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (*AccountFlags) Scan

func (t *AccountFlags) Scan(src interface{}) error

Scan reads from src into an AccountFlags

func (AccountFlags) String

func (e AccountFlags) String() string

String returns the name of `e`

func (*AccountFlags) UnmarshalBinary

func (s *AccountFlags) UnmarshalBinary(inp []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler.

func (AccountFlags) ValidEnum

func (e AccountFlags) ValidEnum(v int32) bool

ValidEnum validates a proposed value for this enum. Implements the Enum interface for AccountFlags

type AccountId

type AccountId PublicKey

AccountId is an XDR Typedef defines as:

typedef PublicKey AccountID;

func AddressToAccountId

func AddressToAccountId(address string) (AccountId, error)

AddressToAccountId returns an AccountId for a given address string. If the address is not valid the error returned will not be nil

func MustAddress

func MustAddress(address string) AccountId

func MustAddressPtr

func MustAddressPtr(address string) *AccountId

func NewAccountId

func NewAccountId(aType PublicKeyType, value interface{}) (result AccountId, err error)

NewAccountId creates a new AccountId.

func (AccountId) Address

func (aid AccountId) Address() string

Address returns the strkey encoded form of this AccountId. This method will panic if the accountid is backed by a public key of an unknown type.

func (AccountId) ArmForSwitch

func (u AccountId) ArmForSwitch(sw int32) (string, bool)

ArmForSwitch returns which field name should be used for storing the value for an instance of PublicKey

func (*AccountId) Equals

func (aid *AccountId) Equals(other AccountId) bool

Equals returns true if `other` is equivalent to `aid`

func (*AccountId) GetAddress

func (aid *AccountId) GetAddress() (string, error)

GetAddress returns the strkey encoded form of this AccountId, and an error if the AccountId is backed by a public key of an unknown type.

func (AccountId) GetEd25519

func (u AccountId) GetEd25519() (result Uint256, ok bool)

GetEd25519 retrieves the Ed25519 value from the union, returning ok if the union's switch indicated the value is valid.

func (AccountId) GoString

func (a AccountId) GoString() string

GoString implements fmt.GoStringer.

func (*AccountId) LedgerKey

func (aid *AccountId) LedgerKey() (ret LedgerKey)

LedgerKey implements the `Keyer` interface

func (AccountId) MarshalBinary

func (s AccountId) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (AccountId) MarshalBinaryCompress

func (aid AccountId) MarshalBinaryCompress() ([]byte, error)

MarshalBinaryCompress marshals AccountId to []byte but unlike MarshalBinary() it removes all unnecessary bytes, exploting the fact that XDR is padding data to 4 bytes in union discriminants etc. It's primary use is in ingest/io.StateReader that keep LedgerKeys in memory so this function decrease memory requirements.

Warning, do not use UnmarshalBinary() on data encoded using this method!

func (AccountId) MustEd25519

func (u AccountId) MustEd25519() Uint256

MustEd25519 retrieves the Ed25519 value from the union, panicing if the value is not set.

func (*AccountId) SetAddress

func (aid *AccountId) SetAddress(address string) error

SetAddress modifies the receiver, setting it's value to the AccountId form of the provided address.

func (AccountId) SwitchFieldName

func (u AccountId) SwitchFieldName() string

SwitchFieldName returns the field name in which this union's discriminant is stored

func (*AccountId) ToMuxedAccount

func (aid *AccountId) ToMuxedAccount() MuxedAccount

ToMuxedAccount transforms an AccountId into a MuxedAccount with a zero memo id

func (*AccountId) UnmarshalBinary

func (s *AccountId) UnmarshalBinary(inp []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler.

type AccountMergeResult

type AccountMergeResult struct {
	Code                 AccountMergeResultCode
	SourceAccountBalance *Int64
}

AccountMergeResult is an XDR Union defines as:

union AccountMergeResult switch (AccountMergeResultCode code)
 {
 case ACCOUNT_MERGE_SUCCESS:
     int64 sourceAccountBalance; // how much got transferred from source account
 default:
     void;
 };

func NewAccountMergeResult

func NewAccountMergeResult(code AccountMergeResultCode, value interface{}) (result AccountMergeResult, err error)

NewAccountMergeResult creates a new AccountMergeResult.

func (AccountMergeResult) ArmForSwitch

func (u AccountMergeResult) ArmForSwitch(sw int32) (string, bool)

ArmForSwitch returns which field name should be used for storing the value for an instance of AccountMergeResult

func (AccountMergeResult) GetSourceAccountBalance

func (u AccountMergeResult) GetSourceAccountBalance() (result Int64, ok bool)

GetSourceAccountBalance retrieves the SourceAccountBalance value from the union, returning ok if the union's switch indicated the value is valid.

func (AccountMergeResult) MarshalBinary

func (s AccountMergeResult) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (AccountMergeResult) MustSourceAccountBalance

func (u AccountMergeResult) MustSourceAccountBalance() Int64

MustSourceAccountBalance retrieves the SourceAccountBalance value from the union, panicing if the value is not set.

func (AccountMergeResult) SwitchFieldName

func (u AccountMergeResult) SwitchFieldName() string

SwitchFieldName returns the field name in which this union's discriminant is stored

func (*AccountMergeResult) UnmarshalBinary

func (s *AccountMergeResult) UnmarshalBinary(inp []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler.

type AccountMergeResultCode

type AccountMergeResultCode int32

AccountMergeResultCode is an XDR Enum defines as:

enum AccountMergeResultCode
 {
     // codes considered as "success" for the operation
     ACCOUNT_MERGE_SUCCESS = 0,
     // codes considered as "failure" for the operation
     ACCOUNT_MERGE_MALFORMED = -1,       // can't merge onto itself
     ACCOUNT_MERGE_NO_ACCOUNT = -2,      // destination does not exist
     ACCOUNT_MERGE_IMMUTABLE_SET = -3,   // source account has AUTH_IMMUTABLE set
     ACCOUNT_MERGE_HAS_SUB_ENTRIES = -4, // account has trust lines/offers
     ACCOUNT_MERGE_SEQNUM_TOO_FAR = -5,  // sequence number is over max allowed
     ACCOUNT_MERGE_DEST_FULL = -6,       // can't add source balance to
                                         // destination balance
     ACCOUNT_MERGE_IS_SPONSOR = -7       // can't merge account that is a sponsor
 };
const (
	AccountMergeResultCodeAccountMergeSuccess       AccountMergeResultCode = 0
	AccountMergeResultCodeAccountMergeMalformed     AccountMergeResultCode = -1
	AccountMergeResultCodeAccountMergeNoAccount     AccountMergeResultCode = -2
	AccountMergeResultCodeAccountMergeImmutableSet  AccountMergeResultCode = -3
	AccountMergeResultCodeAccountMergeHasSubEntries AccountMergeResultCode = -4
	AccountMergeResultCodeAccountMergeSeqnumTooFar  AccountMergeResultCode = -5
	AccountMergeResultCodeAccountMergeDestFull      AccountMergeResultCode = -6
	AccountMergeResultCodeAccountMergeIsSponsor     AccountMergeResultCode = -7
)

func (AccountMergeResultCode) MarshalBinary

func (s AccountMergeResultCode) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (AccountMergeResultCode) String

func (e AccountMergeResultCode) String() string

String returns the name of `e`

func (*AccountMergeResultCode) UnmarshalBinary

func (s *AccountMergeResultCode) UnmarshalBinary(inp []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler.

func (AccountMergeResultCode) ValidEnum

func (e AccountMergeResultCode) ValidEnum(v int32) bool

ValidEnum validates a proposed value for this enum. Implements the Enum interface for AccountMergeResultCode

type AllowTrustOp

type AllowTrustOp struct {
	Trustor   AccountId
	Asset     AssetCode
	Authorize Uint32
}

AllowTrustOp is an XDR Struct defines as:

struct AllowTrustOp
 {
     AccountID trustor;
     AssetCode asset;

     // One of 0, AUTHORIZED_FLAG, or AUTHORIZED_TO_MAINTAIN_LIABILITIES_FLAG
     uint32 authorize;
 };

func (AllowTrustOp) MarshalBinary

func (s AllowTrustOp) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (*AllowTrustOp) UnmarshalBinary

func (s *AllowTrustOp) UnmarshalBinary(inp []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler.

type AllowTrustResult

type AllowTrustResult struct {
	Code AllowTrustResultCode
}

AllowTrustResult is an XDR Union defines as:

union AllowTrustResult switch (AllowTrustResultCode code)
 {
 case ALLOW_TRUST_SUCCESS:
     void;
 default:
     void;
 };

func NewAllowTrustResult

func NewAllowTrustResult(code AllowTrustResultCode, value interface{}) (result AllowTrustResult, err error)

NewAllowTrustResult creates a new AllowTrustResult.

func (AllowTrustResult) ArmForSwitch

func (u AllowTrustResult) ArmForSwitch(sw int32) (string, bool)

ArmForSwitch returns which field name should be used for storing the value for an instance of AllowTrustResult

func (AllowTrustResult) MarshalBinary

func (s AllowTrustResult) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (AllowTrustResult) SwitchFieldName

func (u AllowTrustResult) SwitchFieldName() string

SwitchFieldName returns the field name in which this union's discriminant is stored

func (*AllowTrustResult) UnmarshalBinary

func (s *AllowTrustResult) UnmarshalBinary(inp []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler.

type AllowTrustResultCode

type AllowTrustResultCode int32

AllowTrustResultCode is an XDR Enum defines as:

enum AllowTrustResultCode
 {
     // codes considered as "success" for the operation
     ALLOW_TRUST_SUCCESS = 0,
     // codes considered as "failure" for the operation
     ALLOW_TRUST_MALFORMED = -1,     // asset is not ASSET_TYPE_ALPHANUM
     ALLOW_TRUST_NO_TRUST_LINE = -2, // trustor does not have a trustline
                                     // source account does not require trust
     ALLOW_TRUST_TRUST_NOT_REQUIRED = -3,
     ALLOW_TRUST_CANT_REVOKE = -4,     // source account can't revoke trust,
     ALLOW_TRUST_SELF_NOT_ALLOWED = -5, // trusting self is not allowed
     ALLOW_TRUST_LOW_RESERVE = -6 // claimable balances can't be created
                                  // on revoke due to low reserves
 };
const (
	AllowTrustResultCodeAllowTrustSuccess          AllowTrustResultCode = 0
	AllowTrustResultCodeAllowTrustMalformed        AllowTrustResultCode = -1
	AllowTrustResultCodeAllowTrustNoTrustLine      AllowTrustResultCode = -2
	AllowTrustResultCodeAllowTrustTrustNotRequired AllowTrustResultCode = -3
	AllowTrustResultCodeAllowTrustCantRevoke       AllowTrustResultCode = -4
	AllowTrustResultCodeAllowTrustSelfNotAllowed   AllowTrustResultCode = -5
	AllowTrustResultCodeAllowTrustLowReserve       AllowTrustResultCode = -6
)

func (AllowTrustResultCode) MarshalBinary

func (s AllowTrustResultCode) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (AllowTrustResultCode) String

func (e AllowTrustResultCode) String() string

String returns the name of `e`

func (*AllowTrustResultCode) UnmarshalBinary

func (s *AllowTrustResultCode) UnmarshalBinary(inp []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler.

func (AllowTrustResultCode) ValidEnum

func (e AllowTrustResultCode) ValidEnum(v int32) bool

ValidEnum validates a proposed value for this enum. Implements the Enum interface for AllowTrustResultCode

type AlphaNum12

type AlphaNum12 struct {
	AssetCode AssetCode12
	Issuer    AccountId
}

AlphaNum12 is an XDR Struct defines as:

struct AlphaNum12
 {
     AssetCode12 assetCode;
     AccountID issuer;
 };

func (AlphaNum12) MarshalBinary

func (s AlphaNum12) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (*AlphaNum12) UnmarshalBinary

func (s *AlphaNum12) UnmarshalBinary(inp []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler.

type AlphaNum4

type AlphaNum4 struct {
	AssetCode AssetCode4
	Issuer    AccountId
}

AlphaNum4 is an XDR Struct defines as:

struct AlphaNum4
 {
     AssetCode4 assetCode;
     AccountID issuer;
 };

func (AlphaNum4) MarshalBinary

func (s AlphaNum4) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (*AlphaNum4) UnmarshalBinary

func (s *AlphaNum4) UnmarshalBinary(inp []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler.

type Asset

type Asset struct {
	Type       AssetType
	AlphaNum4  *AlphaNum4
	AlphaNum12 *AlphaNum12
}

Asset is an XDR Union defines as:

union Asset switch (AssetType type)
 {
 case ASSET_TYPE_NATIVE: // Not credit
     void;

 case ASSET_TYPE_CREDIT_ALPHANUM4:
     AlphaNum4 alphaNum4;

 case ASSET_TYPE_CREDIT_ALPHANUM12:
     AlphaNum12 alphaNum12;

     // add other asset types here in the future
 };

func BuildAsset

func BuildAsset(assetType, issuer, code string) (Asset, error)

BuildAsset creates a new asset from a given `assetType`, `code`, and `issuer`.

Valid assetTypes are:

- `native`
- `credit_alphanum4`
- `credit_alphanum12`

func BuildAssets

func BuildAssets(s string) ([]Asset, error)

BuildAssets parses a list of assets from a given string. The string is expected to be a comma separated list of assets encoded in the format (Code:Issuer or "native") defined by SEP-0011 https://github.com/stellar/stellar-protocol/pull/313 If the string is empty, BuildAssets will return an empty list of assets

func MustNewCreditAsset

func MustNewCreditAsset(code string, issuer string) Asset

MustNewCreditAsset returns a new general asset, panicking if it can't.

func MustNewNativeAsset

func MustNewNativeAsset() Asset

MustNewNativeAsset returns a new native asset, panicking if it can't.

func NewAsset

func NewAsset(aType AssetType, value interface{}) (result Asset, err error)

NewAsset creates a new Asset.

func NewCreditAsset

func NewCreditAsset(code string, issuer string) (Asset, error)

NewCreditAsset returns a new general asset, returning an error if it can't.

func (Asset) ArmForSwitch

func (u Asset) ArmForSwitch(sw int32) (string, bool)

ArmForSwitch returns which field name should be used for storing the value for an instance of Asset

func (Asset) Equals

func (a Asset) Equals(other Asset) bool

Equals returns true if `other` is equivalent to `a`

func (Asset) Extract

func (a Asset) Extract(typ interface{}, code interface{}, issuer interface{}) error

Extract is a helper function to extract information from an xdr.Asset structure. It extracts the asset's type to the `typ` input parameter (which must be either a *string or *xdr.AssetType). It also extracts the asset's code and issuer to `code` and `issuer` respectively if they are of type *string and the asset is non-native

func (Asset) GetAlphaNum12

func (u Asset) GetAlphaNum12() (result AlphaNum12, ok bool)

GetAlphaNum12 retrieves the AlphaNum12 value from the union, returning ok if the union's switch indicated the value is valid.

func (Asset) GetAlphaNum4

func (u Asset) GetAlphaNum4() (result AlphaNum4, ok bool)

GetAlphaNum4 retrieves the AlphaNum4 value from the union, returning ok if the union's switch indicated the value is valid.

func (*Asset) GetCode

func (a *Asset) GetCode() string

func (*Asset) GetIssuer

func (a *Asset) GetIssuer() string

func (Asset) GoString

func (a Asset) GoString() string

GoString implements fmt.GoStringer.

func (*Asset) LessThan

func (a *Asset) LessThan(b Asset) bool

func (Asset) MarshalBinary

func (s Asset) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (Asset) MarshalBinaryCompress

func (a Asset) MarshalBinaryCompress() ([]byte, error)

MarshalBinaryCompress marshals Asset to []byte but unlike MarshalBinary() it removes all unnecessary bytes, exploting the fact that XDR is padding data to 4 bytes in union discriminants etc. It's primary use is in ingest/io.StateReader that keep LedgerKeys in memory so this function decrease memory requirements.

Warning, do not use UnmarshalBinary() on data encoded using this method!

func (Asset) MustAlphaNum12

func (u Asset) MustAlphaNum12() AlphaNum12

MustAlphaNum12 retrieves the AlphaNum12 value from the union, panicing if the value is not set.

func (Asset) MustAlphaNum4

func (u Asset) MustAlphaNum4() AlphaNum4

MustAlphaNum4 retrieves the AlphaNum4 value from the union, panicing if the value is not set.

func (Asset) MustExtract

func (a Asset) MustExtract(typ interface{}, code interface{}, issuer interface{})

MustExtract behaves as Extract, but panics if an error occurs.

func (*Asset) Scan

func (t *Asset) Scan(src interface{}) error

Scan reads from src into an Asset

func (*Asset) SetCredit

func (a *Asset) SetCredit(code string, issuer AccountId) error

SetCredit overwrites `a` with a credit asset using `code` and `issuer`. The asset type (CreditAlphanum4 or CreditAlphanum12) is chosen automatically based upon the length of `code`.

func (*Asset) SetNative

func (a *Asset) SetNative() error

SetNative overwrites `a` with the native asset type

func (Asset) String

func (a Asset) String() string

String returns a display friendly form of the asset

func (Asset) StringCanonical

func (a Asset) StringCanonical() string

StringCanonical returns a display friendly form of the asset following its canonical representation

func (Asset) SwitchFieldName

func (u Asset) SwitchFieldName() string

SwitchFieldName returns the field name in which this union's discriminant is stored

func (*Asset) ToAssetCode

func (a *Asset) ToAssetCode(code string) (AssetCode, error)

ToAssetCode for Asset converts the Asset to a corresponding XDR "allow trust" asset, used by the XDR allow trust operation.

func (Asset) ToChangeTrustAsset

func (a Asset) ToChangeTrustAsset() ChangeTrustAsset

ToChangeTrustAsset converts Asset to ChangeTrustAsset.

func (Asset) ToTrustLineAsset

func (a Asset) ToTrustLineAsset() TrustLineAsset

ToTrustLineAsset converts Asset to TrustLineAsset.

func (*Asset) UnmarshalBinary

func (s *Asset) UnmarshalBinary(inp []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler.

func (Asset) Value

func (t Asset) Value() (driver.Value, error)

Value implements the database/sql/driver Valuer interface.

type AssetCode

type AssetCode struct {
	Type        AssetType
	AssetCode4  *AssetCode4
	AssetCode12 *AssetCode12
}

AssetCode is an XDR Union defines as:

union AssetCode switch (AssetType type)
 {
 case ASSET_TYPE_CREDIT_ALPHANUM4:
     AssetCode4 assetCode4;

 case ASSET_TYPE_CREDIT_ALPHANUM12:
     AssetCode12 assetCode12;

     // add other asset types here in the future
 };

func MustNewAssetCodeFromString

func MustNewAssetCodeFromString(code string) AssetCode

MustNewAssetCodeFromString returns a new allow trust asset, panicking if it can't.

func NewAssetCode

func NewAssetCode(aType AssetType, value interface{}) (result AssetCode, err error)

NewAssetCode creates a new AssetCode.

func NewAssetCodeFromString

func NewAssetCodeFromString(code string) (AssetCode, error)

NewAssetCodeFromString returns a new allow trust asset, panicking if it can't.

func (AssetCode) ArmForSwitch

func (u AssetCode) ArmForSwitch(sw int32) (string, bool)

ArmForSwitch returns which field name should be used for storing the value for an instance of AssetCode

func (AssetCode) GetAssetCode12

func (u