go: github.com/stellar/go/build Index | Examples | Files

package build

import "github.com/stellar/go/build"

Package build implements a builder system for constructing various xdr structures used by the stellar network, most importanly transactions.

At the core of this package is the *Builder and *Mutator types. A Builder object (ex. PaymentBuilder, TransactionBuilder) contain an underlying xdr struct that is being iteratively built by having zero or more Mutator structs applied to it. See ExampleTransactionBuilder in main_test.go for an example.

Index

Examples

Package Files

account_merge.go allow_trust.go asset.go change_trust.go create_account.go inflation.go main.go manage_data.go manage_offer.go operation.go payment.go set_options.go testing.go transaction.go transaction_envelope.go util.go

Constants

const (
    // MemoTextMaxLength represents the maximum number of bytes a valid memo of
    // type "MEMO_TEXT" can be.
    MemoTextMaxLength = 28
)

Variables

var (
    // PublicNetwork is a mutator that configures the transaction for submission
    // to the main public stellar network.
    PublicNetwork = Network{network.PublicNetworkPassphrase}

    // TestNetwork is a mutator that configures the transaction for submission
    // to the test stellar network (often called testnet).
    TestNetwork = Network{network.TestNetworkPassphrase}

    // DefaultNetwork is a mutator that configures the
    // transaction for submission to the default stellar
    // network.  Integrators may change this value to
    // another `Network` mutator if they would like to
    // effect the default in a process-global manner.
    // Replace or set your own custom passphrase on this
    // var to set the default network for the process.
    DefaultNetwork = Network{}
)
var MaxLimit = Limit(amount.String(math.MaxInt64))

MaxLimit represents the maximum value that can be passed as trutline Limit

type AccountMergeBuilder Uses

type AccountMergeBuilder struct {
    O           xdr.Operation
    Destination xdr.AccountId
    Err         error
}

AccountMergeBuilder represents a transaction that is being built.

func AccountMerge Uses

func AccountMerge(muts ...interface{}) (result AccountMergeBuilder)

AccountMerge groups the creation of a new AccountMergeBuilder with a call to Mutate.

ExampleAccountMerge creates and signs a simple transaction with AccountMerge operation, and then encodes it into a base64 string capable of being submitted to stellar-core.

Code:

seed := "SDOTALIMPAM2IV65IOZA7KZL7XWZI5BODFXTRVLIHLQZQCKK57PH5F3H"
tx := Transaction(
    SourceAccount{seed},
    Sequence{1},
    TestNetwork,
    AccountMerge(
        Destination{"GBDT3K42LOPSHNAEHEJ6AVPADIJ4MAR64QEKKW2LQPBSKLYD22KUEH4P"},
    ),
)

txe := tx.Sign(seed)
txeB64, _ := txe.Base64()

fmt.Printf("tx base64: %s", txeB64)

Output:

tx base64: AAAAADZY/nWY0gx6beMpf4S8Ur0qHsjA8fbFtBzBx1cbQzHwAAAAZAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAgAAAAARz2rmlufI7QEORPgVeAaE8YCPuQIpVtLg8MlLwPWlUIAAAAAAAAAARtDMfAAAABAh3qZrP5T9Xg0LdzwOLx/eA/B7bzj+8j+s9eXNuu7/Ldch7I6kW5iYz6Vfy32FVnKNtoykToB7nQY2o2vo1tqAw==

func (*AccountMergeBuilder) Mutate Uses

func (b *AccountMergeBuilder) Mutate(muts ...interface{})

Mutate applies the provided mutators to this builder's payment or operation.

func (AccountMergeBuilder) MutateTransaction Uses

func (m AccountMergeBuilder) MutateTransaction(o *TransactionBuilder) error

MutateTransaction for AccountMergeBuilder causes the underylying Destination to be added to the operation list for the provided transaction

type AccountMergeMutator Uses

type AccountMergeMutator interface {
    MutateAccountMerge(*AccountMergeBuilder) error
}

AccountMergeMutator is a interface that wraps the MutateAccountMerge operation. types may implement this interface to specify how they modify an xdr.AccountMergeBuilder object

type AllowTrustAsset Uses

type AllowTrustAsset struct {
    Code string
}

AllowTrustAsset is a mutator capable of setting the asset on an operations that have one.

func (AllowTrustAsset) MutateAllowTrust Uses

func (m AllowTrustAsset) MutateAllowTrust(o *xdr.AllowTrustOp) (err error)

MutateAllowTrust for Asset sets the AllowTrustOp's Asset field

type AllowTrustBuilder Uses

type AllowTrustBuilder struct {
    O   xdr.Operation
    AT  xdr.AllowTrustOp
    Err error
}

AllowTrustBuilder represents a transaction that is being built.

func AllowTrust Uses

func AllowTrust(muts ...interface{}) (result AllowTrustBuilder)

AllowTrust groups the creation of a new AllowTrustBuilder with a call to Mutate.

func (*AllowTrustBuilder) Mutate Uses

func (b *AllowTrustBuilder) Mutate(muts ...interface{})

Mutate applies the provided mutators to this builder's payment or operation.

func (AllowTrustBuilder) MutateTransaction Uses

func (m AllowTrustBuilder) MutateTransaction(o *TransactionBuilder) error

MutateTransaction for AllowTrustBuilder causes the underylying AllowTrustOp to be added to the operation list for the provided transaction

type AllowTrustMutator Uses

type AllowTrustMutator interface {
    MutateAllowTrust(*xdr.AllowTrustOp) error
}

AllowTrustMutator is a interface that wraps the MutateAllowTrust operation. types may implement this interface to specify how they modify an xdr.AllowTrustOp object

type Amount Uses

type Amount string

Amount is a mutator capable of setting the amount

func (Amount) MutateManageOffer Uses

func (m Amount) MutateManageOffer(o interface{}) (err error)

MutateManageOffer for Amount sets the ManageOfferOp's Amount field

type Asset Uses

type Asset struct {
    Code   string
    Issuer string
    Native bool
}

Asset is struct used in path_payment mutators

func CreditAsset Uses

func CreditAsset(code, issuer string) Asset

CreditAsset is a helper method to create credit Asset object

func NativeAsset Uses

func NativeAsset() Asset

NativeAsset is a helper method to create native Asset object

func (Asset) MustXDR Uses

func (a Asset) MustXDR() xdr.Asset

MustXDR is the panicky version of ToXDR

func (Asset) MutateChangeTrust Uses

func (m Asset) MutateChangeTrust(o *xdr.ChangeTrustOp) (err error)

MutateChangeTrust for Asset sets the ChangeTrustOp's Line field

func (Asset) ToXDR Uses

func (a Asset) ToXDR() (xdr.Asset, error)

ToXDR creates xdr.Asset object from build.Asset object

type Authorize Uses

type Authorize struct {
    Value bool
}

Authorize is a mutator capable of setting the `authorize` flag

func (Authorize) MutateAllowTrust Uses

func (m Authorize) MutateAllowTrust(o *xdr.AllowTrustOp) error

MutateAllowTrust for Authorize sets the AllowTrustOp's Authorize field

type AutoSequence Uses

type AutoSequence struct {
    SequenceProvider
}

AutoSequence loads the sequence to use for the transaction from an external provider.

func (AutoSequence) MutateTransaction Uses

func (m AutoSequence) MutateTransaction(o *TransactionBuilder) error

MutateTransaction for AutoSequence loads the sequence and sets it on the tx. NOTE: this mutator assumes that the source account has already been set on the transaction and will error if that has not occurred.

type ChangeTrustBuilder Uses

type ChangeTrustBuilder struct {
    O   xdr.Operation
    CT  xdr.ChangeTrustOp
    Err error
}

ChangeTrustBuilder represents a transaction that is being built.

func ChangeTrust Uses

func ChangeTrust(muts ...interface{}) (result ChangeTrustBuilder)

ChangeTrust groups the creation of a new ChangeTrustBuilder with a call to Mutate.

ExampleChangeTrust creates and signs a simple transaction with ChangeTrust operation, and then encodes it into a base64 string capable of being submitted to stellar-core.

Code:

seed := "SDOTALIMPAM2IV65IOZA7KZL7XWZI5BODFXTRVLIHLQZQCKK57PH5F3H"
tx := Transaction(
    SourceAccount{seed},
    Sequence{1},
    TestNetwork,
    Trust("USD", "GAWSI2JO2CF36Z43UGMUJCDQ2IMR5B3P5TMS7XM7NUTU3JHG3YJUDQXA", Limit("100.25")),
)

txe := tx.Sign(seed)
txeB64, _ := txe.Base64()

fmt.Printf("tx base64: %s", txeB64)

Output:

tx base64: AAAAADZY/nWY0gx6beMpf4S8Ur0qHsjA8fbFtBzBx1cbQzHwAAAAZAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAYAAAABVVNEAAAAAAAtJGku0Iu/Z5uhmUSIcNIZHodv7Nkv3Z9tJ02k5t4TQQAAAAA7wO+gAAAAAAAAAAEbQzHwAAAAQOIy19X38Y3jcFzvhDsmXu6iDzrzb4iwfS2NAq9GGAFiRJUGoFX85vKtlNcXzQppF4X8oIMNPEb74fuZE/N+GAE=

ExampleChangeTrust_maxLimit creates and signs a simple transaction with ChangeTrust operation (maximum limit), and then encodes it into a base64 string capable of being submitted to stellar-core.

Code:

seed := "SDOTALIMPAM2IV65IOZA7KZL7XWZI5BODFXTRVLIHLQZQCKK57PH5F3H"
tx := Transaction(
    SourceAccount{seed},
    Sequence{1},
    TestNetwork,
    Trust("USD", "GAWSI2JO2CF36Z43UGMUJCDQ2IMR5B3P5TMS7XM7NUTU3JHG3YJUDQXA"),
)

txe := tx.Sign(seed)
txeB64, _ := txe.Base64()

fmt.Printf("tx base64: %s", txeB64)

Output:

tx base64: AAAAADZY/nWY0gx6beMpf4S8Ur0qHsjA8fbFtBzBx1cbQzHwAAAAZAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAYAAAABVVNEAAAAAAAtJGku0Iu/Z5uhmUSIcNIZHodv7Nkv3Z9tJ02k5t4TQX//////////AAAAAAAAAAEbQzHwAAAAQJQC6R3RqNaw5rOmaxqpAE0lD5onM/njn9I2RVlhtS2SGi2Z7xm65USYVWXTJFVqTCfTwwu+QXFcOuqgJjVtHAk=

func RemoveTrust Uses

func RemoveTrust(code, issuer string, args ...interface{}) (result ChangeTrustBuilder)

RemoveTrust is a helper that creates ChangeTrustBuilder

ExampleRemoveTrust creates and signs a simple transaction with ChangeTrust operation (remove trust), and then encodes it into a base64 string capable of being submitted to stellar-core.

Code:

seed := "SDOTALIMPAM2IV65IOZA7KZL7XWZI5BODFXTRVLIHLQZQCKK57PH5F3H"
operationSource := "GCVJCNUHSGKOTBBSXZJ7JJZNOSE2YDNGRLIDPMQDUEQWJQSE6QZSDPNU"
tx := Transaction(
    SourceAccount{seed},
    Sequence{1},
    TestNetwork,
    RemoveTrust(
        "USD",
        "GAWSI2JO2CF36Z43UGMUJCDQ2IMR5B3P5TMS7XM7NUTU3JHG3YJUDQXA",
        SourceAccount{operationSource},
    ),
)

txe := tx.Sign(seed)
txeB64, _ := txe.Base64()

fmt.Printf("tx base64: %s", txeB64)

Output:

tx base64: AAAAADZY/nWY0gx6beMpf4S8Ur0qHsjA8fbFtBzBx1cbQzHwAAAAZAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAQAAAACqkTaHkZTphDK+U/SnLXSJrA2mitA3sgOhIWTCRPQzIQAAAAYAAAABVVNEAAAAAAAtJGku0Iu/Z5uhmUSIcNIZHodv7Nkv3Z9tJ02k5t4TQQAAAAAAAAAAAAAAAAAAAAEbQzHwAAAAQD5FeGBEwJyeauK+WKfcxYBeKw62EtCqvC0p9Z+1cY32fKQ+5Jz9uE1LaDsHW5NurtStKcUTiG5j2qNDf1QpYgw=

func Trust Uses

func Trust(code, issuer string, args ...interface{}) (result ChangeTrustBuilder)

Trust is a helper that creates ChangeTrustBuilder

func (*ChangeTrustBuilder) Mutate Uses

func (b *ChangeTrustBuilder) Mutate(muts ...interface{})

Mutate applies the provided mutators to this builder's payment or operation.

func (ChangeTrustBuilder) MutateTransaction Uses

func (m ChangeTrustBuilder) MutateTransaction(o *TransactionBuilder) error

MutateTransaction for ChangeTrustBuilder causes the underylying CreateAccountOp to be added to the operation list for the provided transaction

type ChangeTrustMutator Uses

type ChangeTrustMutator interface {
    MutateChangeTrust(*xdr.ChangeTrustOp) error
}

ChangeTrustMutator is a interface that wraps the MutateChangeTrust operation. types may implement this interface to specify how they modify an xdr.ChangeTrustOp object

type ClearFlag Uses

type ClearFlag int32

ClearFlag is a mutator capable of clearing account flags

func ClearAuthImmutable Uses

func ClearAuthImmutable() ClearFlag

ClearAuthImmutable clears AuthImmutableFlag on SetOptions operation

func ClearAuthRequired Uses

func ClearAuthRequired() ClearFlag

ClearAuthRequired clears AuthRequiredFlag on SetOptions operation

func ClearAuthRevocable Uses

func ClearAuthRevocable() ClearFlag

ClearAuthRevocable clears AuthRevocableFlag on SetOptions operation

func (ClearFlag) MutateSetOptions Uses

func (m ClearFlag) MutateSetOptions(o *xdr.SetOptionsOp) (err error)

MutateSetOptions for ClearFlag sets the SetOptionsOp's ClearFlags field

func (ClearFlag) MutateTransaction Uses

func (m ClearFlag) MutateTransaction(t *TransactionBuilder) error

MutateTransaction for ClearFlag allows creating an operation using a single mutator

type CreateAccountBuilder Uses

type CreateAccountBuilder struct {
    O   xdr.Operation
    CA  xdr.CreateAccountOp
    Err error
}

CreateAccountBuilder helps to build CreateAccountOp structs.

func CreateAccount Uses

func CreateAccount(muts ...interface{}) (result CreateAccountBuilder)

CreateAccount groups the creation of a new CreateAccountBuilder with a call to Mutate.

func (*CreateAccountBuilder) Mutate Uses

func (b *CreateAccountBuilder) Mutate(muts ...interface{})

Mutate applies the provided mutators to this builder's payment or operation.

func (CreateAccountBuilder) MutateTransaction Uses

func (m CreateAccountBuilder) MutateTransaction(o *TransactionBuilder) error

MutateTransaction for CreateAccountBuilder causes the underylying CreateAccountOp to be added to the operation list for the provided transaction

type CreateAccountMutator Uses

type CreateAccountMutator interface {
    MutateCreateAccount(*xdr.CreateAccountOp) error
}

CreateAccountMutator is a interface that wraps the MutateCreateAccount operation. types may implement this interface to specify how they modify an xdr.PaymentOp object

type CreditAmount Uses

type CreditAmount struct {
    Code   string
    Issuer string
    Amount string
}

CreditAmount is a mutator that configures a payment to be using credit asset and have the amount provided.

func (CreditAmount) MutatePayment Uses

func (m CreditAmount) MutatePayment(o interface{}) (err error)

MutatePayment for Asset sets the PaymentOp's Asset field

type Defaults Uses

type Defaults struct{}

Defaults is a mutator that sets defaults

func (Defaults) MutateTransaction Uses

func (m Defaults) MutateTransaction(o *TransactionBuilder) error

MutateTransaction for Defaults sets reasonable defaults on the transaction being built

type Destination Uses

type Destination struct {
    AddressOrSeed string
}

Destination is a mutator capable of setting the destination on an operations that have one.

func (Destination) MutateAccountMerge Uses

func (m Destination) MutateAccountMerge(o *AccountMergeBuilder) error

MutateAccountMerge for Destination sets the AccountMergeBuilder's Destination field

func (Destination) MutateCreateAccount Uses

func (m Destination) MutateCreateAccount(o *xdr.CreateAccountOp) error

MutateCreateAccount for Destination sets the CreateAccountOp's Destination field

func (Destination) MutatePayment Uses

func (m Destination) MutatePayment(o interface{}) error

MutatePayment for Destination sets the PaymentOp's Destination field

type HomeDomain Uses

type HomeDomain string

HomeDomain is a mutator capable of setting home domain of the account

func (HomeDomain) MutateSetOptions Uses

func (m HomeDomain) MutateSetOptions(o *xdr.SetOptionsOp) (err error)

MutateSetOptions for HomeDomain sets the SetOptionsOp's HomeDomain field

func (HomeDomain) MutateTransaction Uses

func (m HomeDomain) MutateTransaction(t *TransactionBuilder) error

MutateTransaction for HomeDomain allows creating an operation using a single mutator

type InflationBuilder Uses

type InflationBuilder struct {
    O   xdr.Operation
    Err error
}

InflationBuilder represents an operation that is being built.

func Inflation Uses

func Inflation(muts ...interface{}) (result InflationBuilder)

Inflation groups the creation of a new InflationBuilder with a call to Mutate.

ExampleInflation creates and signs a simple transaction with Inflation operation, and then encodes it into a base64 string capable of being submitted to stellar-core.

Code:

seed := "SDOTALIMPAM2IV65IOZA7KZL7XWZI5BODFXTRVLIHLQZQCKK57PH5F3H"
tx := Transaction(
    SourceAccount{seed},
    Sequence{1},
    TestNetwork,
    Inflation(),
)

txe := tx.Sign(seed)
txeB64, _ := txe.Base64()

fmt.Printf("tx base64: %s", txeB64)

Output:

tx base64: AAAAADZY/nWY0gx6beMpf4S8Ur0qHsjA8fbFtBzBx1cbQzHwAAAAZAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAkAAAAAAAAAARtDMfAAAABAzzDG4V7KzynWY0ER/V4HH0WgDvl3hrIizDcKW3qEQY4Ib3yXufVvdbzsET/Dj5js5dgDkcYgikHwRCpqi/J8BQ==

func (*InflationBuilder) Mutate Uses

func (b *InflationBuilder) Mutate(muts ...interface{})

Mutate applies the provided mutators to this builder's operation.

func (InflationBuilder) MutateTransaction Uses

func (m InflationBuilder) MutateTransaction(o *TransactionBuilder) error

MutateTransaction for InflationBuilder causes the underylying InflationOp to be added to the operation list for the provided transaction

type InflationDest Uses

type InflationDest string

InflationDest is a mutator capable of setting the inflation destination

func (InflationDest) MutateSetOptions Uses

func (m InflationDest) MutateSetOptions(o *xdr.SetOptionsOp) (err error)

MutateSetOptions for InflationDest sets the SetOptionsOp's InflationDest field

func (InflationDest) MutateTransaction Uses

func (m InflationDest) MutateTransaction(t *TransactionBuilder) error

MutateTransaction for InflationDest allows creating an operation using a single mutator

type Limit Uses

type Limit Amount

Limit is a mutator that sets a limit on the change_trust operation

func (Limit) MutateChangeTrust Uses

func (m Limit) MutateChangeTrust(o *xdr.ChangeTrustOp) (err error)

MutateChangeTrust for Limit sets the ChangeTrustOp's Limit field

type ManageDataBuilder Uses

type ManageDataBuilder struct {
    O   xdr.Operation
    MD  xdr.ManageDataOp
    Err error
}

ManageDataBuilder helps to build ManageDataOp structs.

func ClearData Uses

func ClearData(name string, muts ...interface{}) (result ManageDataBuilder)

ClearData removes a key/value pair associated with the source account

func SetData Uses

func SetData(name string, value []byte, muts ...interface{}) (result ManageDataBuilder)

SetData sets a key/value pair associated with the source account, updating it if one already exists.

func (*ManageDataBuilder) Mutate Uses

func (b *ManageDataBuilder) Mutate(muts ...interface{})

Mutate applies the provided mutators to this builder's payment or operation.

func (ManageDataBuilder) MutateTransaction Uses

func (m ManageDataBuilder) MutateTransaction(o *TransactionBuilder) error

MutateTransaction for ManageDataBuilder causes the underylying ManageData to be added to the operation list for the provided transaction

type ManageOfferBuilder Uses

type ManageOfferBuilder struct {
    PassiveOffer bool
    O            xdr.Operation
    MO           xdr.ManageOfferOp
    PO           xdr.CreatePassiveOfferOp
    Err          error
}

ManageOfferBuilder represents a transaction that is being built.

func CreateOffer Uses

func CreateOffer(rate Rate, amount Amount) (result ManageOfferBuilder)

CreateOffer creates a new offer

func CreatePassiveOffer Uses

func CreatePassiveOffer(rate Rate, amount Amount) (result ManageOfferBuilder)

CreatePassiveOffer creates a new passive offer

ExampleCreatePassiveOffer creates and signs a simple transaction with CreatePassiveOffer operation, and then encodes it into a base64 string capable of being submitted to stellar-core.

Code:

rate := Rate{
    Selling: NativeAsset(),
    Buying:  CreditAsset("USD", "GAWSI2JO2CF36Z43UGMUJCDQ2IMR5B3P5TMS7XM7NUTU3JHG3YJUDQXA"),
    Price:   Price("125.12"),
}

seed := "SDOTALIMPAM2IV65IOZA7KZL7XWZI5BODFXTRVLIHLQZQCKK57PH5F3H"
tx := Transaction(
    SourceAccount{seed},
    Sequence{1},
    TestNetwork,
    CreatePassiveOffer(rate, "20"),
)

txe := tx.Sign(seed)
txeB64, _ := txe.Base64()

fmt.Printf("tx base64: %s", txeB64)

Output:

tx base64: AAAAADZY/nWY0gx6beMpf4S8Ur0qHsjA8fbFtBzBx1cbQzHwAAAAZAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAQAAAAAAAAAAVVTRAAAAAAALSRpLtCLv2eboZlEiHDSGR6Hb+zZL92fbSdNpObeE0EAAAAAC+vCAAAADDgAAAAZAAAAAAAAAAEbQzHwAAAAQHv/1xLn+ArfIUoWjn3V0zVka6tulqMYx4zJZhGqdmTw8iCXY0ZtHS+y+7YGgR3vM1DpKOdvWTmhee+sCXIppQA=

func DeleteOffer Uses

func DeleteOffer(rate Rate, offerID OfferID) (result ManageOfferBuilder)

DeleteOffer deletes an existing offer

func ManageOffer Uses

func ManageOffer(passiveOffer bool, muts ...interface{}) (result ManageOfferBuilder)

ManageOffer groups the creation of a new ManageOfferBuilder with a call to Mutate.

ExampleManageOffer creates and signs a simple transaction with ManageOffer operations, and then encodes it into a base64 string capable of being submitted to stellar-core.

Code:

rate := Rate{
    Selling: NativeAsset(),
    Buying:  CreditAsset("USD", "GAWSI2JO2CF36Z43UGMUJCDQ2IMR5B3P5TMS7XM7NUTU3JHG3YJUDQXA"),
    Price:   Price("125.12"),
}

seed := "SDOTALIMPAM2IV65IOZA7KZL7XWZI5BODFXTRVLIHLQZQCKK57PH5F3H"
tx := Transaction(
    SourceAccount{seed},
    Sequence{1},
    TestNetwork,
    CreateOffer(rate, "20"),
    UpdateOffer(rate, "40", OfferID(2)),
    DeleteOffer(rate, OfferID(1)),
)

txe := tx.Sign(seed)
txeB64, _ := txe.Base64()

fmt.Printf("tx base64: %s", txeB64)

Output:

tx base64: AAAAADZY/nWY0gx6beMpf4S8Ur0qHsjA8fbFtBzBx1cbQzHwAAABLAAAAAAAAAABAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAVVTRAAAAAAALSRpLtCLv2eboZlEiHDSGR6Hb+zZL92fbSdNpObeE0EAAAAAC+vCAAAADDgAAAAZAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAABVVNEAAAAAAAtJGku0Iu/Z5uhmUSIcNIZHodv7Nkv3Z9tJ02k5t4TQQAAAAAX14QAAAAMOAAAABkAAAAAAAAAAgAAAAAAAAADAAAAAAAAAAFVU0QAAAAAAC0kaS7Qi79nm6GZRIhw0hkeh2/s2S/dn20nTaTm3hNBAAAAAAAAAAAAAAw4AAAAGQAAAAAAAAABAAAAAAAAAAEbQzHwAAAAQBfosk+t8qpULHP4ppNX2xVPih8lmnbHFZdeuxSP6pgpCCX05S7zZ4PsjVQY2nOnLru6mBTc1r8So+vxHs3FXAc=

func UpdateOffer Uses

func UpdateOffer(rate Rate, amount Amount, offerID OfferID) (result ManageOfferBuilder)

UpdateOffer updates an existing offer

func (*ManageOfferBuilder) Mutate Uses

func (b *ManageOfferBuilder) Mutate(muts ...interface{})

Mutate applies the provided mutators to this builder's offer or operation.

func (ManageOfferBuilder) MutateTransaction Uses

func (m ManageOfferBuilder) MutateTransaction(o *TransactionBuilder) error

MutateTransaction for ManageOfferBuilder causes the underylying ManageData to be added to the operation list for the provided transaction

type ManageOfferMutator Uses

type ManageOfferMutator interface {
    MutateManageOffer(interface{}) error
}

ManageOfferMutator is a interface that wraps the MutateManageOffer operation. types may implement this interface to specify how they modify an xdr.ManageOfferOp object

type MasterWeight Uses

type MasterWeight uint32

MasterWeight is a mutator that sets account's master weight

func (MasterWeight) MutateSetOptions Uses

func (m MasterWeight) MutateSetOptions(o *xdr.SetOptionsOp) (err error)

MutateSetOptions for MasterWeight sets the SetOptionsOp's MasterWeight field

func (MasterWeight) MutateTransaction Uses

func (m MasterWeight) MutateTransaction(t *TransactionBuilder) error

MutateTransaction for MasterWeight allows creating an operation using a single mutator

type MemoHash Uses

type MemoHash struct {
    Value xdr.Hash
}

MemoHash is a mutator that sets a memo on the mutated transaction of type MEMO_HASH.

func (MemoHash) MutateTransaction Uses

func (m MemoHash) MutateTransaction(o *TransactionBuilder) (err error)

MutateTransaction for MemoHash sets the memo.

type MemoID Uses

type MemoID struct {
    Value uint64
}

MemoID is a mutator that sets a memo on the mutated transaction of type MEMO_ID.

func (MemoID) MutateTransaction Uses

func (m MemoID) MutateTransaction(o *TransactionBuilder) (err error)

MutateTransaction for MemoID sets the memo.

type MemoReturn Uses

type MemoReturn struct {
    Value xdr.Hash
}

MemoReturn is a mutator that sets a memo on the mutated transaction of type MEMO_RETURN.

func (MemoReturn) MutateTransaction Uses

func (m MemoReturn) MutateTransaction(o *TransactionBuilder) (err error)

MutateTransaction for MemoReturn sets the memo.

type MemoText Uses

type MemoText struct {
    Value string
}

MemoText is a mutator that sets a memo on the mutated transaction of type MEMO_TEXT.

func (MemoText) MutateTransaction Uses

func (m MemoText) MutateTransaction(o *TransactionBuilder) (err error)

MutateTransaction for MemoText sets the memo.

type MockSequenceProvider Uses

type MockSequenceProvider struct {
    Data map[string]xdr.SequenceNumber
}

MockSequenceProvider is a mock sequence provider.

func (*MockSequenceProvider) SequenceForAccount Uses

func (sp *MockSequenceProvider) SequenceForAccount(
    accountID string,
) (xdr.SequenceNumber, error)

SequenceForAccount implements `SequenceProvider`

type NativeAmount Uses

type NativeAmount struct {
    Amount string
}

NativeAmount is a mutator that configures a payment to be using native currency and have the amount provided (in lumens).

func (NativeAmount) MutateCreateAccount Uses

func (m NativeAmount) MutateCreateAccount(o *xdr.CreateAccountOp) (err error)

MutateCreateAccount for NativeAmount sets the CreateAccountOp's StartingBalance field

func (NativeAmount) MutatePayment Uses

func (m NativeAmount) MutatePayment(o interface{}) (err error)

MutatePayment for NativeAmount sets the PaymentOp's currency field to native and sets its amount to the provided integer

type Network Uses

type Network struct {
    Passphrase string
}

Network establishes the stellar network that a transaction should apply to. This modifier influences how a transaction is hashed for the purposes of signature generation.

func (*Network) ID Uses

func (n *Network) ID() [32]byte

ID returns the network ID derived from this struct's Passphrase

func (Network) MutateTransaction Uses

func (m Network) MutateTransaction(o *TransactionBuilder) error

MutateTransaction for Network sets the Network ID to use when signing this transaction

type OfferID Uses

type OfferID uint64

OfferID is a mutator that sets offer ID on offer operations

func (OfferID) MutateManageOffer Uses

func (m OfferID) MutateManageOffer(o interface{}) (err error)

MutateManageOffer for OfferID sets the ManageOfferOp's OfferID field

type OperationMutator Uses

type OperationMutator interface {
    MutateOperation(*xdr.Operation) error
}

OperationMutator is a interface that wraps the MutateOperation operation. types may implement this interface to specify how they modify an xdr.Operation object

type PayWithPath Uses

type PayWithPath struct {
    Asset
    MaxAmount string
    Path      []Asset
}

PayWithPath is a mutator that configures a path_payment's send asset and max amount

func PayWith Uses

func PayWith(sendAsset Asset, maxAmount string) PayWithPath

PayWith is a helper to create PayWithPath struct

func (PayWithPath) MutatePayment Uses

func (m PayWithPath) MutatePayment(o interface{}) (err error)

MutatePayment for PayWithPath sets the PathPaymentOp's SendAsset, SendMax and Path fields

func (PayWithPath) Through Uses

func (pathSend PayWithPath) Through(asset Asset) PayWithPath

Through appends a new asset to the path

type PaymentBuilder Uses

type PaymentBuilder struct {
    PathPayment bool
    O           xdr.Operation
    P           xdr.PaymentOp
    PP          xdr.PathPaymentOp
    Err         error
}

PaymentBuilder represents a transaction that is being built.

func Payment Uses

func Payment(muts ...interface{}) (result PaymentBuilder)

Payment groups the creation of a new PaymentBuilder with a call to Mutate.

func (*PaymentBuilder) Mutate Uses

func (b *PaymentBuilder) Mutate(muts ...interface{})

Mutate applies the provided mutators to this builder's payment or operation.

func (PaymentBuilder) MutateTransaction Uses

func (m PaymentBuilder) MutateTransaction(o *TransactionBuilder) error

MutateTransaction for PaymentBuilder causes the underylying PaymentOp or PathPaymentOp to be added to the operation list for the provided transaction

type PaymentMutator Uses

type PaymentMutator interface {
    MutatePayment(interface{}) error
}

PaymentMutator is a interface that wraps the MutatePayment operation. types may implement this interface to specify how they modify an xdr.PaymentOp object

type Price Uses

type Price string

Price is a mutator that sets price on offer operations

type Rate Uses

type Rate struct {
    Selling Asset
    Buying  Asset
    Price
}

Rate is a mutator that sets selling/buying asset and price on offer operations

func (Rate) MutateManageOffer Uses

func (m Rate) MutateManageOffer(o interface{}) (err error)

MutateManageOffer for Rate sets the ManageOfferOp's selling, buying and price fields

type Sequence Uses

type Sequence struct {
    Sequence uint64
}

Sequence is a mutator that sets the sequence number on a transaction

func (Sequence) MutateTransaction Uses

func (m Sequence) MutateTransaction(o *TransactionBuilder) error

MutateTransaction for Sequence sets the SeqNum on the transaction.

type SequenceProvider Uses

type SequenceProvider interface {
    SequenceForAccount(aid string) (xdr.SequenceNumber, error)
}

SequenceProvider is the interface that other packages may implement to be used with the `AutoSequence` mutator.

type SetFlag Uses

type SetFlag int32

SetFlag is a mutator capable of setting account flags

func SetAuthImmutable Uses

func SetAuthImmutable() SetFlag

SetAuthImmutable sets AuthImmutableFlag on SetOptions operation

func SetAuthRequired Uses

func SetAuthRequired() SetFlag

SetAuthRequired sets AuthRequiredFlag on SetOptions operation

func SetAuthRevocable Uses

func SetAuthRevocable() SetFlag

SetAuthRevocable sets AuthRevocableFlag on SetOptions operation

func (SetFlag) MutateSetOptions Uses

func (m SetFlag) MutateSetOptions(o *xdr.SetOptionsOp) (err error)

MutateSetOptions for SetFlag sets the SetOptionsOp's SetFlags field

func (SetFlag) MutateTransaction Uses

func (m SetFlag) MutateTransaction(t *TransactionBuilder) error

MutateTransaction for SetFlag allows creating an operation using a single mutator

type SetOptionsBuilder Uses

type SetOptionsBuilder struct {
    O   xdr.Operation
    SO  xdr.SetOptionsOp
    Err error
}

SetOptionsBuilder represents a transaction that is being built.

func SetOptions Uses

func SetOptions(muts ...interface{}) (result SetOptionsBuilder)

SetOptions groups the creation of a new SetOptions with a call to Mutate.

ExampleSetOptions creates and signs a simple transaction with SetOptions operation, and then encodes it into a base64 string capable of being submitted to stellar-core.

Code:

seed := "SDOTALIMPAM2IV65IOZA7KZL7XWZI5BODFXTRVLIHLQZQCKK57PH5F3H"
tx := Transaction(
    SourceAccount{seed},
    Sequence{1},
    TestNetwork,
    SetOptions(
        InflationDest("GCT7S5BA6ZC7SV7GGEMEYJTWOBYTBOA7SC4JEYP7IAEDG7HQNIWKRJ4G"),
        SetAuthRequired(),
        SetAuthRevocable(),
        SetAuthImmutable(),
        ClearAuthRequired(),
        ClearAuthRevocable(),
        ClearAuthImmutable(),
        MasterWeight(1),
        SetThresholds(2, 3, 4),
        HomeDomain("stellar.org"),
        AddSigner("GC6DDGPXVWXD5V6XOWJ7VUTDYI7VKPV2RAJWBVBHR47OPV5NASUNHTJW", 5),
    ),
)

txe := tx.Sign(seed)
txeB64, _ := txe.Base64()

fmt.Printf("tx base64: %s", txeB64)

Output:

tx base64: AAAAADZY/nWY0gx6beMpf4S8Ur0qHsjA8fbFtBzBx1cbQzHwAAAAZAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAUAAAABAAAAAKf5dCD2RflX5jEYTCZ2cHEwuB+QuJJh/0AIM3zwaiyoAAAAAQAAAAcAAAABAAAABwAAAAEAAAABAAAAAQAAAAIAAAABAAAAAwAAAAEAAAAEAAAAAQAAAAtzdGVsbGFyLm9yZwAAAAABAAAAALwxmfetrj7X13WT+tJjwj9VPrqIE2DUJ48+59etBKjTAAAABQAAAAAAAAABG0Mx8AAAAECZF17pOfZcyc7YJXMyx++PMydIvL6g2yZcPDY8h4+tmlz+3rsE6uuX0R6xfgNnuMntvK4YMmaOvp4DvaZMMNoA

ExampleSetOptions_manyOperations creates and signs a simple transaction with many SetOptions operations, and then encodes it into a base64 string capable of being submitted to stellar-core.

Code:

seed := "SDOTALIMPAM2IV65IOZA7KZL7XWZI5BODFXTRVLIHLQZQCKK57PH5F3H"
tx := Transaction(
    SourceAccount{seed},
    Sequence{1},
    TestNetwork,
    InflationDest("GCT7S5BA6ZC7SV7GGEMEYJTWOBYTBOA7SC4JEYP7IAEDG7HQNIWKRJ4G"),
    SetAuthRequired(),
    SetAuthRevocable(),
    SetAuthImmutable(),
    ClearAuthRequired(),
    ClearAuthRevocable(),
    ClearAuthImmutable(),
    MasterWeight(1),
    SetThresholds(2, 3, 4),
    HomeDomain("stellar.org"),
    RemoveSigner("GC6DDGPXVWXD5V6XOWJ7VUTDYI7VKPV2RAJWBVBHR47OPV5NASUNHTJW"),
)

txe := tx.Sign(seed)
txeB64, _ := txe.Base64()

fmt.Printf("tx base64: %s", txeB64)

Output:

tx base64: AAAAADZY/nWY0gx6beMpf4S8Ur0qHsjA8fbFtBzBx1cbQzHwAAAETAAAAAAAAAABAAAAAAAAAAAAAAALAAAAAAAAAAUAAAABAAAAAKf5dCD2RflX5jEYTCZ2cHEwuB+QuJJh/0AIM3zwaiyoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAQAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAABAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAABAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAEAAAADAAAAAQAAAAQAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAALc3RlbGxhci5vcmcAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAALwxmfetrj7X13WT+tJjwj9VPrqIE2DUJ48+59etBKjTAAAAAAAAAAAAAAABG0Mx8AAAAEAOXsLbFo3e8fpqyeZEHGP9o/IrQDQRyof+DA1EeUkvUGbNhy57xXcpMhZpRtwXThWBYx4za4q+TRrnoZQtezgN

func (*SetOptionsBuilder) Mutate Uses

func (b *SetOptionsBuilder) Mutate(muts ...interface{})

Mutate applies the provided mutators to this builder's payment or operation.

func (SetOptionsBuilder) MutateTransaction Uses

func (m SetOptionsBuilder) MutateTransaction(o *TransactionBuilder) error

MutateTransaction for SetOptionsBuilder causes the underylying SetOptionsOp to be added to the operation list for the provided transaction

type SetOptionsMutator Uses

type SetOptionsMutator interface {
    MutateSetOptions(*xdr.SetOptionsOp) error
}

SetOptionsMutator is a interface that wraps the MutateSetOptions operation. types may implement this interface to specify how they modify an xdr.SetOptionsOp object

type Sign Uses

type Sign struct {
    Seed string
}

Sign is a mutator that contributes a signature of the provided envelope's transaction with the configured key

func (Sign) MutateTransactionEnvelope Uses

func (m Sign) MutateTransactionEnvelope(txe *TransactionEnvelopeBuilder) error

MutateTransactionEnvelope adds a signature to the provided envelope

type Signer Uses

type Signer struct {
    Address string
    Weight  uint32
}

Signer is a mutator capable of adding, updating and deleting an account signer

func AddSigner Uses

func AddSigner(address string, weight uint32) Signer

AddSigner creates Signer mutator that sets account's signer

func RemoveSigner Uses

func RemoveSigner(address string) Signer

RemoveSigner creates Signer mutator that removes account's signer

func (Signer) MutateSetOptions Uses

func (m Signer) MutateSetOptions(o *xdr.SetOptionsOp) error

MutateSetOptions for Signer sets the SetOptionsOp's signer field

func (Signer) MutateTransaction Uses

func (m Signer) MutateTransaction(t *TransactionBuilder) error

MutateTransaction for Signer allows creating an operation using a single mutator

type SourceAccount Uses

type SourceAccount struct {
    AddressOrSeed string
}

SourceAccount is a mutator capable of setting the source account on an xdr.Operation and an xdr.Transaction

func (SourceAccount) MutateOperation Uses

func (m SourceAccount) MutateOperation(o *xdr.Operation) error

MutateOperation for SourceAccount sets the operation's SourceAccount to the pubilic key for the address provided

func (SourceAccount) MutateTransaction Uses

func (m SourceAccount) MutateTransaction(o *TransactionBuilder) error

MutateTransaction for SourceAccount sets the transaction's SourceAccount to the pubilic key for the address provided

type Thresholds Uses

type Thresholds struct {
    Low    *uint32
    Medium *uint32
    High   *uint32
}

Thresholds is a mutator capable of setting account thresholds

func SetHighThreshold Uses

func SetHighThreshold(value uint32) Thresholds

SetHighThreshold creates Thresholds mutator that sets account's high threshold

func SetLowThreshold Uses

func SetLowThreshold(value uint32) Thresholds

SetLowThreshold creates Thresholds mutator that sets account's low threshold

func SetMediumThreshold Uses

func SetMediumThreshold(value uint32) Thresholds

SetMediumThreshold creates Thresholds mutator that sets account's medium threshold

func SetThresholds Uses

func SetThresholds(low, medium, high uint32) Thresholds

SetThresholds creates Thresholds mutator

func (Thresholds) MutateSetOptions Uses

func (m Thresholds) MutateSetOptions(o *xdr.SetOptionsOp) (err error)

MutateSetOptions for Thresholds sets the SetOptionsOp's thresholds fields

func (Thresholds) MutateTransaction Uses

func (m Thresholds) MutateTransaction(t *TransactionBuilder) error

MutateTransaction for Thresholds allows creating an operation using a single mutator

type TransactionBuilder Uses

type TransactionBuilder struct {
    TX                *xdr.Transaction
    NetworkPassphrase string
    Err               error
}

TransactionBuilder represents a Transaction that is being constructed.

ExampleTransactionBuilder creates and signs a simple transaction, and then encodes it into a base64 string capable of being submitted to stellar-core.

It uses the transaction builder system

Code:

seed := "SDOTALIMPAM2IV65IOZA7KZL7XWZI5BODFXTRVLIHLQZQCKK57PH5F3H"
tx := Transaction(
    SourceAccount{seed},
    Sequence{1},
    TestNetwork,
    Payment(
        Destination{"GAWSI2JO2CF36Z43UGMUJCDQ2IMR5B3P5TMS7XM7NUTU3JHG3YJUDQXA"},
        NativeAmount{"50"},
    ),
)

txe := tx.Sign(seed)
txeB64, _ := txe.Base64()

fmt.Printf("tx base64: %s", txeB64)

Output:

tx base64: AAAAADZY/nWY0gx6beMpf4S8Ur0qHsjA8fbFtBzBx1cbQzHwAAAAZAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAALSRpLtCLv2eboZlEiHDSGR6Hb+zZL92fbSdNpObeE0EAAAAAAAAAAB3NZQAAAAAAAAAAARtDMfAAAABA2oIeQxoJl53RMRWFeLB865zcky39f2gf2PmUubCuJYccEePRSrTC8QQrMOgGwD8a6oe8dgltvezdDsmmXBPyBw==

func Transaction Uses

func Transaction(muts ...TransactionMutator) (result *TransactionBuilder)

Transaction groups the creation of a new TransactionBuilder with a call to Mutate.

func (*TransactionBuilder) Hash Uses

func (b *TransactionBuilder) Hash() ([32]byte, error)

Hash returns the hash of this builder's transaction.

func (*TransactionBuilder) HashHex Uses

func (b *TransactionBuilder) HashHex() (string, error)

HashHex returns the hex-encoded hash of this builder's transaction

func (*TransactionBuilder) Mutate Uses

func (b *TransactionBuilder) Mutate(muts ...TransactionMutator)

Mutate applies the provided TransactionMutators to this builder's transaction

func (*TransactionBuilder) MutateTransactionEnvelope Uses

func (m *TransactionBuilder) MutateTransactionEnvelope(txe *TransactionEnvelopeBuilder) error

MutateTransactionEnvelope for TransactionBuilder causes the underylying transaction to be set as the provided envelope's Tx field

func (*TransactionBuilder) Sign Uses

func (b *TransactionBuilder) Sign(signers ...string) (result TransactionEnvelopeBuilder)

Sign returns an new TransactionEnvelopeBuilder using this builder's transaction as the basis and with signatures of that transaction from the provided Signers.

type TransactionEnvelopeBuilder Uses

type TransactionEnvelopeBuilder struct {
    E   *xdr.TransactionEnvelope
    Err error
    // contains filtered or unexported fields
}

TransactionEnvelopeBuilder helps you build a TransactionEnvelope

func (*TransactionEnvelopeBuilder) Base64 Uses

func (b *TransactionEnvelopeBuilder) Base64() (string, error)

Base64 returns a string which is the xdr-then-base64-encoded form of the builder's underlying transaction envelope

func (*TransactionEnvelopeBuilder) Bytes Uses

func (b *TransactionEnvelopeBuilder) Bytes() ([]byte, error)

Bytes encodes the builder's underlying envelope to XDR

func (*TransactionEnvelopeBuilder) Init Uses

func (b *TransactionEnvelopeBuilder) Init()

func (*TransactionEnvelopeBuilder) Mutate Uses

func (b *TransactionEnvelopeBuilder) Mutate(muts ...TransactionEnvelopeMutator)

Mutate applies the provided TransactionEnvelopeMutators to this builder's envelope

func (*TransactionEnvelopeBuilder) MutateTX Uses

func (b *TransactionEnvelopeBuilder) MutateTX(muts ...TransactionMutator)

MutateTX runs Mutate on the underlying transaction using the provided mutators.

type TransactionEnvelopeMutator Uses

type TransactionEnvelopeMutator interface {
    MutateTransactionEnvelope(*TransactionEnvelopeBuilder) error
}

TransactionEnvelopeMutator is a interface that wraps the MutateTransactionEnvelope operation. types may implement this interface to specify how they modify an xdr.TransactionEnvelope object

type TransactionMutator Uses

type TransactionMutator interface {
    MutateTransaction(*TransactionBuilder) error
}

TransactionMutator is a interface that wraps the MutateTransaction operation. types may implement this interface to specify how they modify an xdr.Transaction object

type Trustor Uses

type Trustor struct {
    Address string
}

Trustor is a mutator capable of setting the trustor on allow_trust operation.

func (Trustor) MutateAllowTrust Uses

func (m Trustor) MutateAllowTrust(o *xdr.AllowTrustOp) error

MutateAllowTrust for Trustor sets the AllowTrustOp's Trustor field

Package build imports 11 packages (graph) and is imported by 9 packages. Updated 2017-10-03. Refresh now. Tools for package owners.