build

package
v0.0.0-...-3597e88 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

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

Constants

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

Variables

View Source
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{}
)
View Source
var DefaultBaseFee uint64 = 100

DefaultBaseFee is used to calculate the transaction fee by default

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

Functions

This section is empty.

Types

type AccountMergeBuilder

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

AccountMergeBuilder represents a transaction that is being built.

func AccountMerge

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

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

Example

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.

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

if err != nil {
	fmt.Println(err)
	return
}

txe, err := tx.Sign(seed)
if err != nil {
	fmt.Println(err)
	return
}

txeB64, err := txe.Base64()

if err != nil {
	fmt.Println(err)
	return
}

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

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

func (*AccountMergeBuilder) Mutate

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

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

func (AccountMergeBuilder) MutateTransaction

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

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

type AllowTrustAsset struct {
	Code string
}

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

func (AllowTrustAsset) MutateAllowTrust

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

MutateAllowTrust for Asset sets the AllowTrustOp's Asset field

type AllowTrustBuilder

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

AllowTrustBuilder represents a transaction that is being built.

func AllowTrust

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

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

func (*AllowTrustBuilder) Mutate

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

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

func (AllowTrustBuilder) MutateTransaction

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

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

type Amount string

Amount is a mutator capable of setting the amount

func (Amount) MutateManageOffer

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

MutateManageOffer for Amount sets the ManageOfferOp's Amount field

type Asset

type Asset struct {
	Code   string
	Issuer string
	Native bool
}

Asset is struct used in path_payment mutators

func CreditAsset

func CreditAsset(code, issuer string) Asset

CreditAsset is a helper method to create credit Asset object

func NativeAsset

func NativeAsset() Asset

NativeAsset is a helper method to create native Asset object

func (Asset) MustXDR

func (a Asset) MustXDR() xdr.Asset

MustXDR is the panicky version of ToXDR

func (Asset) MutateChangeTrust

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

MutateChangeTrust for Asset sets the ChangeTrustOp's Line field

func (Asset) ToXDR

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

ToXDR creates xdr.Asset object from build.Asset object

type Authorize

type Authorize struct {
	Value bool
}

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

func (Authorize) MutateAllowTrust

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

MutateAllowTrust for Authorize sets the AllowTrustOp's Authorize field

type AutoSequence

type AutoSequence struct {
	SequenceProvider
}

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

func (AutoSequence) MutateTransaction

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 BaseFee

type BaseFee struct {
	Amount uint64
}

BaseFee is a mutator capable of setting the base fee

func (BaseFee) MutateTransaction

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

MutateTransaction for BaseFee sets the base fee

type ChangeTrustBuilder

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

ChangeTrustBuilder represents a transaction that is being built.

func ChangeTrust

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

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

Example

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.

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

if err != nil {
	fmt.Println(err)
	return
}

txe, err := tx.Sign(seed)
if err != nil {
	fmt.Println(err)
	return
}

txeB64, err := txe.Base64()

if err != nil {
	fmt.Println(err)
	return
}

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

tx base64: AAAAADZY/nWY0gx6beMpf4S8Ur0qHsjA8fbFtBzBx1cbQzHwAAAAZAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAYAAAABVVNEAAAAAAAtJGku0Iu/Z5uhmUSIcNIZHodv7Nkv3Z9tJ02k5t4TQQAAAAA7wO+gAAAAAAAAAAEbQzHwAAAAQOIy19X38Y3jcFzvhDsmXu6iDzrzb4iwfS2NAq9GGAFiRJUGoFX85vKtlNcXzQppF4X8oIMNPEb74fuZE/N+GAE=
Example (MaxLimit)

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.

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

if err != nil {
	fmt.Println(err)
	return
}

txe, err := tx.Sign(seed)
if err != nil {
	fmt.Println(err)
	return
}

txeB64, err := txe.Base64()

if err != nil {
	fmt.Println(err)
	return
}

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

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

func RemoveTrust

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

RemoveTrust is a helper that creates ChangeTrustBuilder

Example

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.

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

if err != nil {
	fmt.Println(err)
	return
}

txe, err := tx.Sign(seed)
if err != nil {
	fmt.Println(err)
	return
}

txeB64, err := txe.Base64()

if err != nil {
	fmt.Println(err)
	return
}

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

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

func Trust

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

Trust is a helper that creates ChangeTrustBuilder

func (*ChangeTrustBuilder) Mutate

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

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

func (ChangeTrustBuilder) MutateTransaction

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

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

type ClearFlag int32

ClearFlag is a mutator capable of clearing account flags

func ClearAuthImmutable

func ClearAuthImmutable() ClearFlag

ClearAuthImmutable clears AuthImmutableFlag on SetOptions operation

func ClearAuthRequired

func ClearAuthRequired() ClearFlag

ClearAuthRequired clears AuthRequiredFlag on SetOptions operation

func ClearAuthRevocable

func ClearAuthRevocable() ClearFlag

ClearAuthRevocable clears AuthRevocableFlag on SetOptions operation

func (ClearFlag) MutateSetOptions

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

MutateSetOptions for ClearFlag sets the SetOptionsOp's ClearFlags field

func (ClearFlag) MutateTransaction

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

MutateTransaction for ClearFlag allows creating an operation using a single mutator

type CreateAccountBuilder

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

CreateAccountBuilder helps to build CreateAccountOp structs.

func CreateAccount

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

CreateAccount groups the creation of a new CreateAccountBuilder with a call to Mutate. Requires the Destination and NativeAmount mutators to be set.

Example

ExampleCreateAccount creates a transaction to fund a new stallar account with a balance. It then encodes the transaction into a base64 string capable of being submitted to stellar-core. It uses the transaction builder system.

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

if err != nil {
	fmt.Println(err)
	return
}

txe, err := tx.Sign(seed)
if err != nil {
	fmt.Println(err)
	return
}

txeB64, err := txe.Base64()

if err != nil {
	fmt.Println(err)
	return
}

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

tx base64: AAAAADZY/nWY0gx6beMpf4S8Ur0qHsjA8fbFtBzBx1cbQzHwAAAAZAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAALSRpLtCLv2eboZlEiHDSGR6Hb+zZL92fbSdNpObeE0EAAAAAHc1lAAAAAAAAAAABG0Mx8AAAAEDiHQEurLITX87zmkEi8Rrcf5wGp1JrLnSDoTJiN+yNjJZVF3WcBJgoGyIJ3NJo+tNmTqALVrJziiiZGdoukxcN

func (*CreateAccountBuilder) Mutate

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

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

func (CreateAccountBuilder) MutateTransaction

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

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

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

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

MutatePayment for Asset sets the PaymentOp's Asset field

type Defaults

type Defaults struct{}

Defaults is a mutator that sets defaults

func (Defaults) MutateTransaction

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

MutateTransaction for Defaults sets reasonable defaults on the transaction being built

type Destination

type Destination struct {
	AddressOrSeed string
}

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

func (Destination) MutateAccountMerge

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

MutateAccountMerge for Destination sets the AccountMergeBuilder's Destination field

func (Destination) MutateCreateAccount

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

MutateCreateAccount for Destination sets the CreateAccountOp's Destination field

func (Destination) MutatePayment

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

MutatePayment for Destination sets the PaymentOp's Destination field

type HomeDomain

type HomeDomain string

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

func (HomeDomain) MutateSetOptions

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

MutateSetOptions for HomeDomain sets the SetOptionsOp's HomeDomain field

func (HomeDomain) MutateTransaction

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

MutateTransaction for HomeDomain allows creating an operation using a single mutator

type InflationBuilder

type InflationBuilder struct {
	O   xdr.Operation
	Err error
}

InflationBuilder represents an operation that is being built.

func Inflation

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

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

Example

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.

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

if err != nil {
	fmt.Println(err)
	return
}

txe, err := tx.Sign(seed)
if err != nil {
	fmt.Println(err)
	return
}

txeB64, err := txe.Base64()

if err != nil {
	fmt.Println(err)
	return
}

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

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

func (*InflationBuilder) Mutate

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

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

func (InflationBuilder) MutateTransaction

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

type InflationDest string

InflationDest is a mutator capable of setting the inflation destination

func (InflationDest) MutateSetOptions

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

MutateSetOptions for InflationDest sets the SetOptionsOp's InflationDest field

func (InflationDest) MutateTransaction

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

MutateTransaction for InflationDest allows creating an operation using a single mutator

type Limit

type Limit Amount

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

func (Limit) MutateChangeTrust

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

MutateChangeTrust for Limit sets the ChangeTrustOp's Limit field

type ManageDataBuilder

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

ManageDataBuilder helps to build ManageDataOp structs.

func ClearData

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

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

func SetData

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

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

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

func (ManageDataBuilder) MutateTransaction

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

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

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

CreateOffer creates a new offer

func CreatePassiveOffer

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

CreatePassiveOffer creates a new passive offer

Example

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.

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

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

if err != nil {
	fmt.Println(err)
	return
}

txe, err := tx.Sign(seed)
if err != nil {
	fmt.Println(err)
	return
}

txeB64, err := txe.Base64()

if err != nil {
	fmt.Println(err)
	return
}

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

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

func DeleteOffer

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

DeleteOffer deletes an existing offer

func ManageOffer

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

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

Example

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.

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

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

if err != nil {
	fmt.Println(err)
	return
}

txe, err := tx.Sign(seed)
if err != nil {
	fmt.Println(err)
	return
}

txeB64, err := txe.Base64()

if err != nil {
	fmt.Println(err)
	return
}

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

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

func UpdateOffer

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

UpdateOffer updates an existing offer

func (*ManageOfferBuilder) Mutate

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

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

func (ManageOfferBuilder) MutateTransaction

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

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

type MasterWeight uint32

MasterWeight is a mutator that sets account's master weight

func (MasterWeight) MutateSetOptions

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

MutateSetOptions for MasterWeight sets the SetOptionsOp's MasterWeight field

func (MasterWeight) MutateTransaction

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

MutateTransaction for MasterWeight allows creating an operation using a single mutator

type MemoHash

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

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

MutateTransaction for MemoHash sets the memo.

type MemoID

type MemoID struct {
	Value uint64
}

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

func (MemoID) MutateTransaction

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

MutateTransaction for MemoID sets the memo.

type MemoReturn

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

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

MutateTransaction for MemoReturn sets the memo.

type MemoText

type MemoText struct {
	Value string
}

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

func (MemoText) MutateTransaction

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

MutateTransaction for MemoText sets the memo.

type MockSequenceProvider

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

MockSequenceProvider is a mock sequence provider.

func (*MockSequenceProvider) SequenceForAccount

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

SequenceForAccount implements `SequenceProvider`

type NativeAmount

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

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

MutateCreateAccount for NativeAmount sets the CreateAccountOp's StartingBalance field

func (NativeAmount) MutatePayment

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

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

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

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

func (Network) MutateTransaction

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

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

type OfferID

type OfferID uint64

OfferID is a mutator that sets offer ID on offer operations

func (OfferID) MutateManageOffer

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

MutateManageOffer for OfferID sets the ManageOfferOp's OfferID field

type OperationMutator

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

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

func PayWith(sendAsset Asset, maxAmount string) PayWithPath

PayWith is a helper to create PayWithPath struct

func (PayWithPath) MutatePayment

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

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

func (PayWithPath) Through

func (pathSend PayWithPath) Through(asset Asset) PayWithPath

Through appends a new asset to the path

type PaymentBuilder

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

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

Payment groups the creation of a new PaymentBuilder with a call to Mutate. Requires the Destination and NativeAmount mutators to be set.

Example

ExamplePayment creates and signs a native-asset Payment, encodes it into a base64 string capable of being submitted to stellar-core. It uses the transaction builder system.

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

if err != nil {
	fmt.Println(err)
	return
}

txe, err := tx.Sign(seed)
if err != nil {
	fmt.Println(err)
	return
}

txeB64, err := txe.Base64()

if err != nil {
	fmt.Println(err)
	return
}

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

tx base64: AAAAADZY/nWY0gx6beMpf4S8Ur0qHsjA8fbFtBzBx1cbQzHwAAAAZAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAALSRpLtCLv2eboZlEiHDSGR6Hb+zZL92fbSdNpObeE0EAAAAAAAAAAB3NZQAAAAAAAAAAARtDMfAAAABA2oIeQxoJl53RMRWFeLB865zcky39f2gf2PmUubCuJYccEePRSrTC8QQrMOgGwD8a6oe8dgltvezdDsmmXBPyBw==

func (*PaymentBuilder) Mutate

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

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

func (PaymentBuilder) MutateTransaction

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

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

type Price string

Price is a mutator that sets price on offer operations

type Rate

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

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

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

type Sequence

type Sequence struct {
	Sequence uint64
}

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

func (Sequence) MutateTransaction

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

MutateTransaction for Sequence sets the SeqNum on the transaction.

type SequenceProvider

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

type SetFlag int32

SetFlag is a mutator capable of setting account flags

func SetAuthImmutable

func SetAuthImmutable() SetFlag

SetAuthImmutable sets AuthImmutableFlag on SetOptions operation

func SetAuthRequired

func SetAuthRequired() SetFlag

SetAuthRequired sets AuthRequiredFlag on SetOptions operation

func SetAuthRevocable

func SetAuthRevocable() SetFlag

SetAuthRevocable sets AuthRevocableFlag on SetOptions operation

func (SetFlag) MutateSetOptions

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

MutateSetOptions for SetFlag sets the SetOptionsOp's SetFlags field

func (SetFlag) MutateTransaction

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

MutateTransaction for SetFlag allows creating an operation using a single mutator

type SetOptionsBuilder

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

SetOptionsBuilder represents a transaction that is being built.

func SetOptions

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

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

Example

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.

seed := "SDOTALIMPAM2IV65IOZA7KZL7XWZI5BODFXTRVLIHLQZQCKK57PH5F3H"
tx, err := 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),
	),
)

if err != nil {
	fmt.Println(err)
	return
}

txe, err := tx.Sign(seed)
if err != nil {
	fmt.Println(err)
	return
}

txeB64, err := txe.Base64()

if err != nil {
	fmt.Println(err)
	return
}

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

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

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.

seed := "SDOTALIMPAM2IV65IOZA7KZL7XWZI5BODFXTRVLIHLQZQCKK57PH5F3H"
tx, err := 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"),
)

if err != nil {
	fmt.Println(err)
	return
}

txe, err := tx.Sign(seed)
if err != nil {
	fmt.Println(err)
	return
}

txeB64, err := txe.Base64()

if err != nil {
	fmt.Println(err)
	return
}

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

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

func (*SetOptionsBuilder) Mutate

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

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

func (SetOptionsBuilder) MutateTransaction

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

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

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

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

MutateTransactionEnvelope adds a signature to the provided envelope

type Signer

type Signer struct {
	Address string
	Weight  uint32
}

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

func AddSigner

func AddSigner(address string, weight uint32) Signer

AddSigner creates Signer mutator that sets account's signer

func RemoveSigner

func RemoveSigner(address string) Signer

RemoveSigner creates Signer mutator that removes account's signer

func (Signer) MutateSetOptions

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

MutateSetOptions for Signer sets the SetOptionsOp's signer field

func (Signer) MutateTransaction

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

MutateTransaction for Signer allows creating an operation using a single mutator

type SourceAccount

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

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

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

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

Thresholds is a mutator capable of setting account thresholds

func SetHighThreshold

func SetHighThreshold(value uint32) Thresholds

SetHighThreshold creates Thresholds mutator that sets account's high threshold

func SetLowThreshold

func SetLowThreshold(value uint32) Thresholds

SetLowThreshold creates Thresholds mutator that sets account's low threshold

func SetMediumThreshold

func SetMediumThreshold(value uint32) Thresholds

SetMediumThreshold creates Thresholds mutator that sets account's medium threshold

func SetThresholds

func SetThresholds(low, medium, high uint32) Thresholds

SetThresholds creates Thresholds mutator

func (Thresholds) MutateSetOptions

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

MutateSetOptions for Thresholds sets the SetOptionsOp's thresholds fields

func (Thresholds) MutateTransaction

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

MutateTransaction for Thresholds allows creating an operation using a single mutator

type Timebounds

type Timebounds struct {
	MinTime uint64
	MaxTime uint64
}

func (Timebounds) MutateTransaction

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

type TransactionBuilder

type TransactionBuilder struct {
	TX                *xdr.Transaction
	NetworkPassphrase string
	BaseFee           uint64
}

TransactionBuilder represents a Transaction that is being constructed.

Example

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

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

if err != nil {
	fmt.Println(err)
	return
}

txe, err := tx.Sign(seed)
if err != nil {
	fmt.Println(err)
	return
}

txeB64, err := txe.Base64()

if err != nil {
	fmt.Println(err)
	return
}

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

tx base64: AAAAADZY/nWY0gx6beMpf4S8Ur0qHsjA8fbFtBzBx1cbQzHwAAAAZAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAALSRpLtCLv2eboZlEiHDSGR6Hb+zZL92fbSdNpObeE0EAAAAAAAAAAB3NZQAAAAAAAAAAARtDMfAAAABA2oIeQxoJl53RMRWFeLB865zcky39f2gf2PmUubCuJYccEePRSrTC8QQrMOgGwD8a6oe8dgltvezdDsmmXBPyBw==

func Transaction

func Transaction(muts ...TransactionMutator) (*TransactionBuilder, error)

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

func (*TransactionBuilder) Hash

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

Hash returns the hash of this builder's transaction.

func (*TransactionBuilder) HashHex

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

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

func (*TransactionBuilder) Mutate

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

Mutate applies the provided TransactionMutators to this builder's transaction

func (*TransactionBuilder) MutateTransactionEnvelope

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

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

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

TransactionEnvelopeBuilder helps you build a TransactionEnvelope

func (*TransactionEnvelopeBuilder) Base64

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

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

Bytes encodes the builder's underlying envelope to XDR

func (*TransactionEnvelopeBuilder) Init

func (b *TransactionEnvelopeBuilder) Init()

func (*TransactionEnvelopeBuilder) Mutate

Mutate applies the provided TransactionEnvelopeMutators to this builder's envelope

func (*TransactionEnvelopeBuilder) MutateTX

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

type TransactionEnvelopeMutator

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

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

type Trustor struct {
	Address string
}

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

func (Trustor) MutateAllowTrust

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

MutateAllowTrust for Trustor sets the AllowTrustOp's Trustor field

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL