Documentation
¶
Overview ¶
Package txnbuild implements transactions and operations on the Stellar network. This library provides an interface to the Stellar transaction model. It supports the building of Go applications on top of the Stellar network (https://www.stellar.org/). Transactions constructed by this library may be submitted to any Horizon instance for processing onto the ledger, using any Stellar SDK client. The recommended client for Go programmers is horizonclient (https://github.com/stellar/go/tree/master/clients/horizonclient). Together, these two libraries provide a complete Stellar SDK. For more information and further examples, see https://github.com/stellar/go/blob/master/docs/reference/readme.md
Index ¶
- Constants
- Variables
- func SetOpSourceAccount(op *xdr.Operation, sourceAccount string)
- type Account
- type AccountMerge
- type AllowTrustdeprecated
- type Asset
- type AssetAmount
- type AssetType
- type Assets
- type BasicAsset
- type BumpSequence
- type ChangeTrust
- type ChangeTrustAsset
- type ChangeTrustAssetWrapper
- type CreditAsset
- func (ca CreditAsset) GetCode() string
- func (ca CreditAsset) GetIssuer() string
- func (ca CreditAsset) GetType() (AssetType, error)
- func (ca CreditAsset) IsNative() bool
- func (ca CreditAsset) LessThan(other Asset) bool
- func (ca CreditAsset) MustToAsset() Asset
- func (ca CreditAsset) MustToChangeTrustAsset() ChangeTrustAsset
- func (ca CreditAsset) MustToTrustLineAsset() TrustLineAsset
- func (ca CreditAsset) ToAsset() (Asset, error)
- func (ca CreditAsset) ToChangeTrustAsset() (ChangeTrustAsset, error)
- func (ca CreditAsset) ToTrustLineAsset() (TrustLineAsset, error)
- func (ca CreditAsset) ToXDR() (xdr.Asset, error)
- type FeeBumpTransaction
- func (t *FeeBumpTransaction) AddSignatureBase64(network, publicKey, signature string) (*FeeBumpTransaction, error)
- func (t *FeeBumpTransaction) AddSignatureDecorated(signature ...xdr.DecoratedSignature) (*FeeBumpTransaction, error)
- func (t *FeeBumpTransaction) Base64() (string, error)
- func (t *FeeBumpTransaction) BaseFee() int64
- func (t *FeeBumpTransaction) ClearSignatures() (*FeeBumpTransaction, error)
- func (t *FeeBumpTransaction) FeeAccount() string
- func (t *FeeBumpTransaction) Hash(networkStr string) ([32]byte, error)
- func (t *FeeBumpTransaction) HashHex(network string) (string, error)
- func (t *FeeBumpTransaction) InnerTransaction() *Transaction
- func (t *FeeBumpTransaction) MarshalBinary() ([]byte, error)
- func (t *FeeBumpTransaction) MarshalText() ([]byte, error)
- func (t *FeeBumpTransaction) MaxFee() int64
- func (t *FeeBumpTransaction) Sign(network string, kps ...*keypair.Full) (*FeeBumpTransaction, error)
- func (t *FeeBumpTransaction) SignHashX(preimage []byte) (*FeeBumpTransaction, error)
- func (t *FeeBumpTransaction) SignWithKeyString(network string, keys ...string) (*FeeBumpTransaction, error)
- func (t *FeeBumpTransaction) Signatures() []xdr.DecoratedSignature
- func (t *FeeBumpTransaction) ToGenericTransaction() *GenericTransaction
- func (t *FeeBumpTransaction) ToXDR() xdr.TransactionEnvelope
- func (t *FeeBumpTransaction) UnmarshalText(b []byte) error
- type FeeBumpTransactionParams
- type GenericTransaction
- func (t GenericTransaction) FeeBump() (*FeeBumpTransaction, bool)
- func (t GenericTransaction) Hash(networkStr string) ([32]byte, error)
- func (t GenericTransaction) HashHex(network string) (string, error)
- func (t *GenericTransaction) MarshalBinary() ([]byte, error)
- func (t *GenericTransaction) MarshalText() ([]byte, error)
- func (t *GenericTransaction) ToXDR() (xdr.TransactionEnvelope, error)
- func (t GenericTransaction) Transaction() (*Transaction, bool)
- func (t *GenericTransaction) UnmarshalText(b []byte) error
- type Inflation
- type LedgerBounds
- type Memo
- type MemoHash
- type MemoID
- type MemoReturn
- type MemoText
- type NativeAsset
- func (na NativeAsset) GetCode() string
- func (na NativeAsset) GetIssuer() string
- func (na NativeAsset) GetType() (AssetType, error)
- func (na NativeAsset) IsNative() bool
- func (na NativeAsset) LessThan(other Asset) bool
- func (na NativeAsset) MustToAsset() Asset
- func (na NativeAsset) MustToChangeTrustAsset() ChangeTrustAsset
- func (na NativeAsset) MustToTrustLineAsset() TrustLineAsset
- func (na NativeAsset) ToAsset() (Asset, error)
- func (na NativeAsset) ToChangeTrustAsset() (ChangeTrustAsset, error)
- func (na NativeAsset) ToTrustLineAsset() (TrustLineAsset, error)
- func (na NativeAsset) ToXDR() (xdr.Asset, error)
- type Operation
- type Payment
- type Preconditions
- type SignerSummary
- type SimpleAccount
- type SorobanOperation
- type TimeBounds
- type Timebounds
- type Transaction
- func (t *Transaction) AddSignatureBase64(network, publicKey, signature string) (*Transaction, error)
- func (t *Transaction) AddSignatureDecorated(signature ...xdr.DecoratedSignature) (*Transaction, error)
- func (t *Transaction) Base64() (string, error)
- func (t *Transaction) BaseFee() int64
- func (t *Transaction) ClearSignatures() (*Transaction, error)
- func (t *Transaction) Hash(networkStr string) ([32]byte, error)
- func (t *Transaction) HashHex(network string) (string, error)
- func (t *Transaction) MarshalBinary() ([]byte, error)
- func (t *Transaction) MarshalText() ([]byte, error)
- func (t *Transaction) MaxFee() int64
- func (t *Transaction) Memo() Memo
- func (t *Transaction) Operations() []Operation
- func (t *Transaction) SequenceNumber() int64
- func (t *Transaction) Sign(network string, kps ...*keypair.Full) (*Transaction, error)
- func (t *Transaction) SignHashX(preimage []byte) (*Transaction, error)
- func (t *Transaction) SignWithKeyString(network string, keys ...string) (*Transaction, error)
- func (t *Transaction) Signatures() []xdr.DecoratedSignature
- func (t *Transaction) SourceAccount() SimpleAccount
- func (t *Transaction) Timebounds() TimeBounds
- func (t *Transaction) ToGenericTransaction() *GenericTransaction
- func (t *Transaction) ToXDR() xdr.TransactionEnvelope
- func (t *Transaction) UnmarshalText(b []byte) error
- type TransactionParams
- type TrustLineAsset
- type TrustLineAssetWrapper
- type ValidationError
Constants ¶
const MemoTextMaxLength = 28
MemoTextMaxLength is the maximum number of bytes allowed for a text memo.
const MinBaseFee = 100
MinBaseFee is the minimum transaction fee for the Stellar network of 100 stroops (0.00001 XLM).
const TimeoutInfinite = int64(0)
TimeoutInfinite allows an indefinite upper bound to be set for Transaction.MaxTime. This is usually not what you want.
Variables ¶
var MaxTrustlineLimit = amount.StringFromInt64(math.MaxInt64)
MaxTrustlineLimit represents the maximum value that can be set as a trustline limit.
Functions ¶
func SetOpSourceAccount ¶
SetOpSourceAccount sets the source account ID on an Operation, allowing M-strkeys (as defined in SEP23).
Types ¶
type Account ¶
type Account interface {
GetAccountID() string
IncrementSequenceNumber() (int64, error)
GetSequenceNumber() (int64, error)
}
Account represents the aspects of a Stellar account necessary to construct transactions. See https://developers.stellar.org/docs/glossary/accounts/
type AccountMerge ¶
AccountMerge represents the Stellar merge account operation. See https://developers.stellar.org/docs/start/list-of-operations/
func (*AccountMerge) BuildXDR ¶
func (am *AccountMerge) BuildXDR() (xdr.Operation, error)
BuildXDR for AccountMerge returns a fully configured XDR Operation.
func (*AccountMerge) FromXDR ¶
func (am *AccountMerge) FromXDR(xdrOp xdr.Operation) error
FromXDR for AccountMerge initialises the txnbuild struct from the corresponding xdr Operation.
func (*AccountMerge) GetSourceAccount ¶
func (am *AccountMerge) GetSourceAccount() string
GetSourceAccount returns the source account of the operation, or the empty string if not set.
func (*AccountMerge) Validate ¶
func (am *AccountMerge) Validate() error
Validate for AccountMerge validates the required struct fields. It returns an error if any of the fields are invalid. Otherwise, it returns nil.
type AllowTrust
deprecated
type AllowTrust struct {
Trustor string
Type Asset
Authorize bool
AuthorizeToMaintainLiabilities bool
ClawbackEnabled bool
SourceAccount string
}
Deprecated: use SetTrustLineFlags instead. AllowTrust represents the Stellar allow trust operation. See https://developers.stellar.org/docs/start/list-of-operations/
func (*AllowTrust) BuildXDR ¶
func (at *AllowTrust) BuildXDR() (xdr.Operation, error)
BuildXDR for AllowTrust returns a fully configured XDR Operation.
func (*AllowTrust) FromXDR ¶
func (at *AllowTrust) FromXDR(xdrOp xdr.Operation) error
FromXDR for AllowTrust initialises the txnbuild struct from the corresponding xdr Operation.
func (*AllowTrust) GetSourceAccount ¶
func (at *AllowTrust) GetSourceAccount() string
GetSourceAccount returns the source account of the operation, or the empty string if not set.
func (*AllowTrust) Validate ¶
func (at *AllowTrust) Validate() error
Validate for AllowTrust validates the required struct fields. It returns an error if any of the fields are invalid. Otherwise, it returns nil.
type Asset ¶
Asset represents a Stellar asset.
func MustAssetFromXDR ¶
MustAssetFromXDR constructs an Asset from its xdr representation. If the given asset xdr is invalid, MustAssetFromXDR will panic.
func ParseAssetString ¶
ParseAssetString parses an asset string in canonical form (SEP-11) into an Asset structure. https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0011.md#asset
type AssetAmount ¶
AssetAmount is a "tuple", pairing an asset with an amount. Used for LiquidityPoolDeposit and LiquidityPoolWithdraw operations.
type AssetType ¶
AssetType represents the type of a Stellar asset.
const ( AssetTypeNative AssetType = AssetType(xdr.AssetTypeAssetTypeNative) AssetTypeCreditAlphanum4 AssetType = AssetType(xdr.AssetTypeAssetTypeCreditAlphanum4) AssetTypeCreditAlphanum12 AssetType = AssetType(xdr.AssetTypeAssetTypeCreditAlphanum12) )
AssetTypeNative, AssetTypeCreditAlphanum4, AssetTypeCreditAlphanum12 enumerate the different types of asset on the Stellar network.
type Assets ¶
type Assets []Asset
Assets represents a list of Stellar assets. Importantly, it is sortable.
type BasicAsset ¶
type BasicAsset interface {
GetType() (AssetType, error)
IsNative() bool
GetCode() string
GetIssuer() string
// Conversions to the 3 asset types
ToAsset() (Asset, error)
MustToAsset() Asset
ToChangeTrustAsset() (ChangeTrustAsset, error)
MustToChangeTrustAsset() ChangeTrustAsset
ToTrustLineAsset() (TrustLineAsset, error)
MustToTrustLineAsset() TrustLineAsset
}
Breaks out some stuff common to all assets
type BumpSequence ¶
BumpSequence represents the Stellar bump sequence operation. See https://developers.stellar.org/docs/start/list-of-operations/
func (*BumpSequence) GetSourceAccount ¶
func (bs *BumpSequence) GetSourceAccount() string
GetSourceAccount returns the source account of the operation, or the empty string if not set.
func (*BumpSequence) Validate ¶
func (bs *BumpSequence) Validate() error
Validate for BumpSequence validates the required struct fields. It returns an error if any of the fields are invalid. Otherwise, it returns nil.
type ChangeTrust ¶
type ChangeTrust struct {
Line ChangeTrustAsset
Limit string
SourceAccount string
}
ChangeTrust represents the Stellar change trust operation. See https://developers.stellar.org/docs/start/list-of-operations/ If Limit is omitted, it defaults to txnbuild.MaxTrustlineLimit.
func RemoveTrustlineOp ¶
func RemoveTrustlineOp(issuedAsset ChangeTrustAsset) ChangeTrust
RemoveTrustlineOp returns a ChangeTrust operation to remove the trustline of the described asset, by setting the limit to "0".
func (*ChangeTrust) BuildXDR ¶
func (ct *ChangeTrust) BuildXDR() (xdr.Operation, error)
BuildXDR for ChangeTrust returns a fully configured XDR Operation.
func (*ChangeTrust) FromXDR ¶
func (ct *ChangeTrust) FromXDR(xdrOp xdr.Operation) error
FromXDR for ChangeTrust initialises the txnbuild struct from the corresponding xdr Operation.
func (*ChangeTrust) GetSourceAccount ¶
func (ct *ChangeTrust) GetSourceAccount() string
GetSourceAccount returns the source account of the operation, or the empty string if not set.
func (*ChangeTrust) Validate ¶
func (ct *ChangeTrust) Validate() error
Validate for ChangeTrust validates the required struct fields. It returns an error if any of the fields are invalid. Otherwise, it returns nil.
type ChangeTrustAsset ¶
type ChangeTrustAsset interface {
BasicAsset
ToXDR() (xdr.ChangeTrustAsset, error)
ToChangeTrustAsset() (ChangeTrustAsset, error)
ToTrustLineAsset() (TrustLineAsset, error)
}
ChangeTrustAsset represents a Stellar change trust asset.
type ChangeTrustAssetWrapper ¶
type ChangeTrustAssetWrapper struct {
Asset
}
ChangeTrustAssetWrapper wraps a native/credit Asset so it generates xdr to be used in a change trust operation.
func (ChangeTrustAssetWrapper) ToXDR ¶
func (ctaw ChangeTrustAssetWrapper) ToXDR() (xdr.ChangeTrustAsset, error)
ToXDR for ChangeTrustAssetWrapper generates the xdr.TrustLineAsset.
type CreditAsset ¶
CreditAsset represents non-XLM assets on the Stellar network.
func (CreditAsset) GetCode ¶
func (ca CreditAsset) GetCode() string
GetCode for CreditAsset returns the asset code.
func (CreditAsset) GetIssuer ¶
func (ca CreditAsset) GetIssuer() string
GetIssuer for CreditAsset returns the address of the issuing account.
func (CreditAsset) GetType ¶
func (ca CreditAsset) GetType() (AssetType, error)
GetType for CreditAsset returns the enum type of the asset, based on its code length.
func (CreditAsset) IsNative ¶
func (ca CreditAsset) IsNative() bool
IsNative for CreditAsset returns false (this is not an XLM asset).
func (CreditAsset) LessThan ¶
func (ca CreditAsset) LessThan(other Asset) bool
LessThan returns true if this asset sorts before some other asset.
func (CreditAsset) MustToAsset ¶
func (ca CreditAsset) MustToAsset() Asset
MustToAsset for CreditAsset returns itself unchanged.
func (CreditAsset) MustToChangeTrustAsset ¶
func (ca CreditAsset) MustToChangeTrustAsset() ChangeTrustAsset
MustToChangeTrustAsset for CreditAsset produces a corresponding XDR asset.
func (CreditAsset) MustToTrustLineAsset ¶
func (ca CreditAsset) MustToTrustLineAsset() TrustLineAsset
MustToTrustLineAsset for CreditAsset produces a corresponding XDR asset.
func (CreditAsset) ToAsset ¶
func (ca CreditAsset) ToAsset() (Asset, error)
ToAsset for CreditAsset returns itself unchanged.
func (CreditAsset) ToChangeTrustAsset ¶
func (ca CreditAsset) ToChangeTrustAsset() (ChangeTrustAsset, error)
ToChangeTrustAsset for CreditAsset produces a corresponding XDR asset.
func (CreditAsset) ToTrustLineAsset ¶
func (ca CreditAsset) ToTrustLineAsset() (TrustLineAsset, error)
ToTrustLineAsset for CreditAsset produces a corresponding XDR asset.
type FeeBumpTransaction ¶
type FeeBumpTransaction struct {
// contains filtered or unexported fields
}
FeeBumpTransaction represents a CAP 15 fee bump transaction. Fee bump transactions allow an arbitrary account to pay the fee for a transaction.
func NewFeeBumpTransaction ¶
func NewFeeBumpTransaction(params FeeBumpTransactionParams) (*FeeBumpTransaction, error)
NewFeeBumpTransaction returns a new FeeBumpTransaction instance
func (*FeeBumpTransaction) AddSignatureBase64 ¶
func (t *FeeBumpTransaction) AddSignatureBase64(network, publicKey, signature string) (*FeeBumpTransaction, error)
AddSignatureBase64 returns a new FeeBumpTransaction instance which extends the current instance with an additional signature derived from the given base64-encoded signature.
func (*FeeBumpTransaction) AddSignatureDecorated ¶
func (t *FeeBumpTransaction) AddSignatureDecorated(signature ...xdr.DecoratedSignature) (*FeeBumpTransaction, error)
AddSignatureDecorated returns a new FeeBumpTransaction instance which extends the current instance with an additional decorated signature(s).
func (*FeeBumpTransaction) Base64 ¶
func (t *FeeBumpTransaction) Base64() (string, error)
Base64 returns the base 64 XDR representation of the transaction envelope.
func (*FeeBumpTransaction) BaseFee ¶
func (t *FeeBumpTransaction) BaseFee() int64
BaseFee returns the per operation fee for this transaction.
func (*FeeBumpTransaction) ClearSignatures ¶
func (t *FeeBumpTransaction) ClearSignatures() (*FeeBumpTransaction, error)
ClearSignatures returns a new Transaction instance which extends the current instance with signatures removed.
func (*FeeBumpTransaction) FeeAccount ¶
func (t *FeeBumpTransaction) FeeAccount() string
FeeAccount returns the address of the account which will be paying for the inner transaction.
func (*FeeBumpTransaction) Hash ¶
func (t *FeeBumpTransaction) Hash(networkStr string) ([32]byte, error)
Hash returns the network specific hash of this transaction encoded as a byte array.
func (*FeeBumpTransaction) HashHex ¶
func (t *FeeBumpTransaction) HashHex(network string) (string, error)
HashHex returns the network specific hash of this transaction encoded as a hexadecimal string.
func (*FeeBumpTransaction) InnerTransaction ¶
func (t *FeeBumpTransaction) InnerTransaction() *Transaction
InnerTransaction returns the Transaction which is wrapped by this FeeBumpTransaction instance.
func (*FeeBumpTransaction) MarshalBinary ¶
func (t *FeeBumpTransaction) MarshalBinary() ([]byte, error)
MarshalBinary returns the binary XDR representation of the transaction envelope.
func (*FeeBumpTransaction) MarshalText ¶
func (t *FeeBumpTransaction) MarshalText() ([]byte, error)
MarshalText returns the base64 XDR representation of the transaction envelope.
func (*FeeBumpTransaction) MaxFee ¶
func (t *FeeBumpTransaction) MaxFee() int64
MaxFee returns the total fees which can be spent to submit this transaction.
func (*FeeBumpTransaction) Sign ¶
func (t *FeeBumpTransaction) Sign(network string, kps ...*keypair.Full) (*FeeBumpTransaction, error)
Sign returns a new FeeBumpTransaction instance which extends the current instance with additional signatures derived from the given list of keypair instances.
func (*FeeBumpTransaction) SignHashX ¶
func (t *FeeBumpTransaction) SignHashX(preimage []byte) (*FeeBumpTransaction, error)
SignHashX returns a new FeeBumpTransaction instance which extends the current instance with HashX signature type. See description here: https://developers.stellar.org/docs/glossary/multisig/#hashx
func (*FeeBumpTransaction) SignWithKeyString ¶
func (t *FeeBumpTransaction) SignWithKeyString(network string, keys ...string) (*FeeBumpTransaction, error)
SignWithKeyString returns a new FeeBumpTransaction instance which extends the current instance with additional signatures derived from the given list of private key strings.
func (*FeeBumpTransaction) Signatures ¶
func (t *FeeBumpTransaction) Signatures() []xdr.DecoratedSignature
Signatures returns the list of signatures attached to this transaction. The contents of the returned slice should not be modified.
func (*FeeBumpTransaction) ToGenericTransaction ¶
func (t *FeeBumpTransaction) ToGenericTransaction() *GenericTransaction
ToGenericTransaction creates a GenericTransaction containing the FeeBumpTransaction.
func (*FeeBumpTransaction) ToXDR ¶
func (t *FeeBumpTransaction) ToXDR() xdr.TransactionEnvelope
ToXDR returns the a xdr.TransactionEnvelope which is equivalent to this transaction. The envelope should not be modified because any changes applied may affect the internals of the FeeBumpTransaction instance.
func (*FeeBumpTransaction) UnmarshalText ¶
func (t *FeeBumpTransaction) UnmarshalText(b []byte) error
UnmarshalText consumes into the value the base64 XDR representation of the transaction envelope.
type FeeBumpTransactionParams ¶
type FeeBumpTransactionParams struct {
Inner *Transaction
FeeAccount string
BaseFee int64
}
FeeBumpTransactionParams is a container for parameters which are used to construct new FeeBumpTransaction instances
type GenericTransaction ¶
type GenericTransaction struct {
// contains filtered or unexported fields
}
GenericTransaction represents a parsed transaction envelope returned by TransactionFromXDR. A GenericTransaction can be either a Transaction or a FeeBumpTransaction.
func NewGenericTransactionWithFeeBumpTransaction ¶
func NewGenericTransactionWithFeeBumpTransaction(feeBumpTx *FeeBumpTransaction) *GenericTransaction
NewGenericTransactionWithFeeBumpTransaction creates a GenericTransaction containing a FeeBumpTransaction.
func NewGenericTransactionWithTransaction ¶
func NewGenericTransactionWithTransaction(tx *Transaction) *GenericTransaction
NewGenericTransactionWithTransaction creates a GenericTransaction containing a Transaction.
func TransactionFromXDR ¶
func TransactionFromXDR(txeB64 string) (*GenericTransaction, error)
TransactionFromXDR parses the supplied transaction envelope in base64 XDR and returns a GenericTransaction instance.
func (GenericTransaction) FeeBump ¶
func (t GenericTransaction) FeeBump() (*FeeBumpTransaction, bool)
FeeBump unpacks the GenericTransaction instance into a FeeBumpTransaction. The function also returns a boolean which is true if the GenericTransaction can be unpacked into a FeeBumpTransaction.
func (GenericTransaction) Hash ¶
func (t GenericTransaction) Hash(networkStr string) ([32]byte, error)
Hash returns the network specific hash of this transaction encoded as a byte array.
func (GenericTransaction) HashHex ¶
func (t GenericTransaction) HashHex(network string) (string, error)
HashHex returns the network specific hash of this transaction encoded as a hexadecimal string.
func (*GenericTransaction) MarshalBinary ¶
func (t *GenericTransaction) MarshalBinary() ([]byte, error)
MarshalBinary returns the binary XDR representation of the transaction envelope.
func (*GenericTransaction) MarshalText ¶
func (t *GenericTransaction) MarshalText() ([]byte, error)
MarshalText returns the base64 XDR representation of the transaction envelope.
func (*GenericTransaction) ToXDR ¶
func (t *GenericTransaction) ToXDR() (xdr.TransactionEnvelope, error)
ToXDR returns the a xdr.TransactionEnvelope which is equivalent to this transaction. The envelope should not be modified because any changes applied may affect the internals of the GenericTransaction.
func (GenericTransaction) Transaction ¶
func (t GenericTransaction) Transaction() (*Transaction, bool)
Transaction unpacks the GenericTransaction instance into a Transaction. The function also returns a boolean which is true if the GenericTransaction can be unpacked into a Transaction.
func (*GenericTransaction) UnmarshalText ¶
func (t *GenericTransaction) UnmarshalText(b []byte) error
UnmarshalText consumes into the value the base64 XDR representation of the transaction envelope.
type Inflation ¶
type Inflation struct {
SourceAccount string
}
Inflation represents the Stellar inflation operation. See https://developers.stellar.org/docs/start/list-of-operations/
func (*Inflation) FromXDR ¶
FromXDR for Inflation initialises the txnbuild struct from the corresponding xdr Operation.
func (*Inflation) GetSourceAccount ¶
GetSourceAccount returns the source account of the operation, or the empty string if not set.
type LedgerBounds ¶
LedgerBounds represent a transaction precondition that controls the ledger range for which a transaction is valid. Setting MaxLedger = 0 indicates there is no maximum ledger.
func (*LedgerBounds) Validate ¶
func (lb *LedgerBounds) Validate() error
type MemoHash ¶
type MemoHash [32]byte
MemoHash is a hash representing a reference to another transaction.
type MemoReturn ¶
type MemoReturn [32]byte
MemoReturn is a hash representing the hash of the transaction the sender is refunding.
type MemoText ¶
type MemoText string
MemoText is used to send human messages of up to 28 bytes of ASCII/UTF-8.
type NativeAsset ¶
type NativeAsset struct{}
NativeAsset represents the native XLM asset.
func (NativeAsset) GetCode ¶
func (na NativeAsset) GetCode() string
GetCode for NativeAsset returns an empty string (XLM doesn't have a code).
func (NativeAsset) GetIssuer ¶
func (na NativeAsset) GetIssuer() string
GetIssuer for NativeAsset returns an empty string (XLM doesn't have an issuer).
func (NativeAsset) GetType ¶
func (na NativeAsset) GetType() (AssetType, error)
GetType for NativeAsset returns the enum type of the asset.
func (NativeAsset) IsNative ¶
func (na NativeAsset) IsNative() bool
IsNative for NativeAsset returns true (this is an XLM asset).
func (NativeAsset) LessThan ¶
func (na NativeAsset) LessThan(other Asset) bool
LessThan returns true if this asset sorts before some other asset.
func (NativeAsset) MustToAsset ¶
func (na NativeAsset) MustToAsset() Asset
MustToAsset for NativeAsset returns itself unchanged.
func (NativeAsset) MustToChangeTrustAsset ¶
func (na NativeAsset) MustToChangeTrustAsset() ChangeTrustAsset
MustToChangeTrustAsset for NativeAsset produces a corresponding ChangeTrustAsset.
func (NativeAsset) MustToTrustLineAsset ¶
func (na NativeAsset) MustToTrustLineAsset() TrustLineAsset
MustToTrustLineAsset for NativeAsset produces a corresponding TrustLineAsset.
func (NativeAsset) ToAsset ¶
func (na NativeAsset) ToAsset() (Asset, error)
ToAsset for NativeAsset returns itself unchanged.
func (NativeAsset) ToChangeTrustAsset ¶
func (na NativeAsset) ToChangeTrustAsset() (ChangeTrustAsset, error)
ToChangeTrustAsset for NativeAsset produces a corresponding ChangeTrustAsset.
func (NativeAsset) ToTrustLineAsset ¶
func (na NativeAsset) ToTrustLineAsset() (TrustLineAsset, error)
ToTrustLineAsset for NativeAsset produces a corresponding TrustLineAsset.
type Operation ¶
type Operation interface {
BuildXDR() (xdr.Operation, error)
FromXDR(xdrOp xdr.Operation) error
Validate() error
GetSourceAccount() string
}
Operation represents the operation types of the Stellar network.
type Payment ¶
Payment represents the Stellar payment operation. See https://developers.stellar.org/docs/start/list-of-operations/
func (*Payment) FromXDR ¶
FromXDR for Payment initialises the txnbuild struct from the corresponding xdr Operation.
func (*Payment) GetSourceAccount ¶
GetSourceAccount returns the source account of the operation, or the empty string if not set.
type Preconditions ¶
type Preconditions struct {
// Transaction is only valid during a certain time range (units are seconds).
TimeBounds TimeBounds
// Transaction is valid for ledger numbers n such that minLedger <= n <
// maxLedger (if maxLedger == 0, then only minLedger is checked)
LedgerBounds *LedgerBounds
// If nil, the transaction is only valid when sourceAccount's sequence
// number "N" is seqNum - 1. Otherwise, valid when N satisfies minSeqNum <=
// N < tx.seqNum.
MinSequenceNumber *int64
// Transaction is valid if the current ledger time is at least
// minSequenceNumberAge greater than the source account's seqTime (units are
// seconds).
MinSequenceNumberAge uint64
// Transaction is valid if the current ledger number is at least
// minSequenceNumberLedgerGap greater than the source account's seqLedger.
MinSequenceNumberLedgerGap uint32
// Transaction is valid if there is a signature corresponding to every
// Signer in this array, even if the signature is not otherwise required by
// the source account or operations.
ExtraSigners []string
}
Preconditions is a container for all transaction preconditions.
func (*Preconditions) BuildXDR ¶
func (cond *Preconditions) BuildXDR() (xdr.Preconditions, error)
BuildXDR will create a precondition structure that varies depending on whether or not there are additional preconditions besides timebounds (which are required).
func (*Preconditions) FromXDR ¶
func (cond *Preconditions) FromXDR(precondXdr xdr.Preconditions) error
FromXDR fills in the precondition structure from an xdr.Precondition.
func (*Preconditions) Validate ¶
func (cond *Preconditions) Validate() error
Validate ensures that all enabled preconditions are valid.
type SignerSummary ¶
SignerSummary is a map of signers to their weights.
type SimpleAccount ¶
SimpleAccount is a minimal implementation of an Account.
func NewSimpleAccount ¶
func NewSimpleAccount(accountID string, sequence int64) SimpleAccount
NewSimpleAccount is a factory method that creates a SimpleAccount from "accountID" and "sequence".
func (*SimpleAccount) GetAccountID ¶
func (sa *SimpleAccount) GetAccountID() string
GetAccountID returns the Account ID.
func (*SimpleAccount) GetSequenceNumber ¶
func (sa *SimpleAccount) GetSequenceNumber() (int64, error)
GetSequenceNumber returns the sequence number of the account.
func (*SimpleAccount) IncrementSequenceNumber ¶
func (sa *SimpleAccount) IncrementSequenceNumber() (int64, error)
IncrementSequenceNumber increments the internal record of the account's sequence number by 1.
type SorobanOperation ¶
type SorobanOperation interface {
BuildTransactionExt() (xdr.TransactionExt, error)
}
SorobanOperation represents a smart contract operation on the Stellar network.
type TimeBounds ¶
TimeBounds represents the time window during which a Stellar transaction is considered valid.
MinTime and MaxTime represent Stellar timebounds - a window of time over which the Transaction will be considered valid. In general, almost all Transactions benefit from setting an upper timebound, because once submitted, the status of a pending Transaction may remain unresolved for a long time if the network is congested. With an upper timebound, the submitter has a guaranteed time at which the Transaction is known to have either succeeded or failed, and can then take appropriate action (e.g. to resubmit or mark as resolved).
Create a TimeBounds struct using one of NewTimebounds(), NewTimeout(), or NewInfiniteTimeout().
func NewInfiniteTimeout ¶
func NewInfiniteTimeout() TimeBounds
NewInfiniteTimeout is a factory method that sets the MaxTime to a value representing an indefinite upper time bound. This is rarely needed, but is helpful for certain smart contracts, and for deterministic testing. A Transaction cannot be built unless a TimeBounds object is provided through a factory method.
func NewTimebounds ¶
func NewTimebounds(minTime, maxTime int64) TimeBounds
NewTimebounds is a factory method that constructs a TimeBounds object from a min and max time. A Transaction cannot be built unless a TimeBounds object is provided through a factory method.
func NewTimeout ¶
func NewTimeout(timeout int64) TimeBounds
NewTimeout is a factory method that sets the MaxTime to be the duration in seconds in the future specified by 'timeout'. A Transaction cannot be built unless a TimeBounds object is provided through a factory method. This method uses the provided system time - make sure it is accurate.
func (*TimeBounds) Validate ¶
func (tb *TimeBounds) Validate() error
Validate for TimeBounds sanity-checks the configured Timebound limits, and confirms the object was built using a factory method. This is done to ensure that default Timebound structs (which have no limits) are not valid - you must explicitly specify the Timebound you require.
type Timebounds ¶
type Timebounds = TimeBounds
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
Transaction represents a Stellar transaction. See https://developers.stellar.org/docs/glossary/transactions/ A Transaction may be wrapped by a FeeBumpTransaction in which case the account authorizing the FeeBumpTransaction will pay for the transaction fees instead of the Transaction's source account.
func NewTransaction ¶
func NewTransaction(params TransactionParams) (*Transaction, error)
NewTransaction returns a new Transaction instance
func (*Transaction) AddSignatureBase64 ¶
func (t *Transaction) AddSignatureBase64(network, publicKey, signature string) (*Transaction, error)
AddSignatureBase64 returns a new Transaction instance which extends the current instance with an additional signature derived from the given base64-encoded signature.
func (*Transaction) AddSignatureDecorated ¶
func (t *Transaction) AddSignatureDecorated(signature ...xdr.DecoratedSignature) (*Transaction, error)
AddSignatureDecorated returns a new Transaction instance which extends the current instance with an additional decorated signature(s).
func (*Transaction) Base64 ¶
func (t *Transaction) Base64() (string, error)
Base64 returns the base 64 XDR representation of the transaction envelope.
func (*Transaction) BaseFee ¶
func (t *Transaction) BaseFee() int64
BaseFee returns the per operation fee for this transaction.
func (*Transaction) ClearSignatures ¶
func (t *Transaction) ClearSignatures() (*Transaction, error)
ClearSignatures returns a new Transaction instance which extends the current instance with signatures removed.
func (*Transaction) Hash ¶
func (t *Transaction) Hash(networkStr string) ([32]byte, error)
Hash returns the network specific hash of this transaction encoded as a byte array.
func (*Transaction) HashHex ¶
func (t *Transaction) HashHex(network string) (string, error)
HashHex returns the network specific hash of this transaction encoded as a hexadecimal string.
func (*Transaction) MarshalBinary ¶
func (t *Transaction) MarshalBinary() ([]byte, error)
MarshalBinary returns the binary XDR representation of the transaction envelope.
func (*Transaction) MarshalText ¶
func (t *Transaction) MarshalText() ([]byte, error)
MarshalText returns the base64 XDR representation of the transaction envelope.
func (*Transaction) MaxFee ¶
func (t *Transaction) MaxFee() int64
MaxFee returns the total fees which can be spent to submit this transaction.
func (*Transaction) Memo ¶
func (t *Transaction) Memo() Memo
Memo returns the memo configured for this transaction.
func (*Transaction) Operations ¶
func (t *Transaction) Operations() []Operation
Operations returns the list of operations included in this transaction. The contents of the returned slice should not be modified.
func (*Transaction) SequenceNumber ¶
func (t *Transaction) SequenceNumber() int64
SequenceNumber returns the sequence number of the transaction.
func (*Transaction) Sign ¶
func (t *Transaction) Sign(network string, kps ...*keypair.Full) (*Transaction, error)
Sign returns a new Transaction instance which extends the current instance with additional signatures derived from the given list of keypair instances.
func (*Transaction) SignHashX ¶
func (t *Transaction) SignHashX(preimage []byte) (*Transaction, error)
SignHashX returns a new Transaction instance which extends the current instance with HashX signature type. See description here: https://developers.stellar.org/docs/glossary/multisig/#hashx
func (*Transaction) SignWithKeyString ¶
func (t *Transaction) SignWithKeyString(network string, keys ...string) (*Transaction, error)
SignWithKeyString returns a new Transaction instance which extends the current instance with additional signatures derived from the given list of private key strings.
func (*Transaction) Signatures ¶
func (t *Transaction) Signatures() []xdr.DecoratedSignature
Signatures returns the list of signatures attached to this transaction. The contents of the returned slice should not be modified.
func (*Transaction) SourceAccount ¶
func (t *Transaction) SourceAccount() SimpleAccount
SourceAccount returns the account which is originating this account.
func (*Transaction) Timebounds ¶
func (t *Transaction) Timebounds() TimeBounds
Timebounds returns the Timebounds configured for this transaction.
func (*Transaction) ToGenericTransaction ¶
func (t *Transaction) ToGenericTransaction() *GenericTransaction
ToGenericTransaction creates a GenericTransaction containing the Transaction.
func (*Transaction) ToXDR ¶
func (t *Transaction) ToXDR() xdr.TransactionEnvelope
ToXDR returns the a xdr.TransactionEnvelope which is equivalent to this transaction. The envelope should not be modified because any changes applied may affect the internals of the Transaction instance.
func (*Transaction) UnmarshalText ¶
func (t *Transaction) UnmarshalText(b []byte) error
UnmarshalText consumes into the value the base64 XDR representation of the transaction envelope.
type TransactionParams ¶
type TransactionParams struct {
SourceAccount Account
IncrementSequenceNum bool
Operations []Operation
BaseFee int64
Memo Memo
Preconditions Preconditions
}
TransactionParams is a container for parameters which are used to construct new Transaction instances
type TrustLineAsset ¶
type TrustLineAsset interface {
BasicAsset
ToXDR() (xdr.TrustLineAsset, error)
}
TrustLineAsset represents a Stellar trust line asset.
type TrustLineAssetWrapper ¶
type TrustLineAssetWrapper struct {
Asset
}
TrustLineAssetWrapper wraps a native/credit Asset so it generates xdr to be used in a trust line operation.
func (TrustLineAssetWrapper) ToXDR ¶
func (tlaw TrustLineAssetWrapper) ToXDR() (xdr.TrustLineAsset, error)
ToXDR for TrustLineAssetWrapper generates the xdr.TrustLineAsset.
type ValidationError ¶
type ValidationError struct {
Field string // Field is the struct field on which the validation error occurred.
Message string // Message is the validation error message.
}
ValidationError is a custom error struct that holds validation errors of txnbuild's operation structs.
func NewValidationError ¶
func NewValidationError(field, message string) *ValidationError
NewValidationError creates a ValidationError struct with the provided field and message values.
func (*ValidationError) Error ¶
func (opError *ValidationError) Error() string
Error for ValidationError struct implements the error interface.