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/AnneNamuli/go-stellar/tree/master/clients/horizonclient). Together, these two libraries provide a complete Stellar SDK. For more information and further examples, see https://www.stellar.org/developers/go/reference/index.html.
Index ¶
- Constants
- Variables
- func AndPredicate(left xdr.ClaimPredicate, right xdr.ClaimPredicate) xdr.ClaimPredicate
- func BeforeAbsoluteTimePredicate(epochSeconds int64) xdr.ClaimPredicate
- func BeforeRelativeTimePredicate(secondsBefore int64) xdr.ClaimPredicate
- func NewHomeDomain(hd string) *string
- func NewInflationDestination(ai string) *string
- func NotPredicate(pred xdr.ClaimPredicate) xdr.ClaimPredicate
- func OrPredicate(left xdr.ClaimPredicate, right xdr.ClaimPredicate) xdr.ClaimPredicate
- func SetOpSourceAccount(op *xdr.Operation, sourceAccount Account)
- func VerifyChallengeTxSigners(challengeTx, serverAccountID, network string, homeDomains []string, ...) ([]string, error)
- func VerifyChallengeTxThreshold(challengeTx, serverAccountID, network string, homeDomains []string, ...) (signersFound []string, err error)
- type Account
- type AccountFlag
- type AccountMerge
- type AllowTrust
- type Asset
- type AssetType
- type BeginSponsoringFutureReserves
- type BumpSequence
- type ChangeTrust
- type ClaimClaimableBalance
- type Claimant
- type CreateAccount
- type CreateClaimableBalance
- type CreatePassiveSellOffer
- type CreditAsset
- type DataID
- type EndSponsoringFutureReserves
- type FeeBumpTransaction
- func (t *FeeBumpTransaction) AddSignatureBase64(network, publicKey, signature string) (*FeeBumpTransaction, error)
- func (t *FeeBumpTransaction) Base64() (string, error)
- func (t *FeeBumpTransaction) BaseFee() int64
- 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) 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) ToXDR() xdr.TransactionEnvelope
- func (t *FeeBumpTransaction) TxEnvelope() (xdr.TransactionEnvelope, error)
- type FeeBumpTransactionParams
- type GenericTransaction
- type Inflation
- type ManageBuyOffer
- type ManageData
- type ManageSellOffer
- func CreateOfferOp(selling, buying Asset, amount, price string, sourceAccount ...Account) (ManageSellOffer, error)
- func DeleteOfferOp(offerID int64, sourceAccount ...Account) (ManageSellOffer, error)
- func UpdateOfferOp(selling, buying Asset, amount, price string, offerID int64, ...) (ManageSellOffer, error)
- type Memo
- type MemoHash
- type MemoID
- type MemoReturn
- type MemoText
- type NativeAsset
- type OfferID
- type Operation
- type PathPayment
- type PathPaymentStrictReceive
- type PathPaymentStrictSend
- type Payment
- type RevokeSponsorship
- type RevokeSponsorshipType
- type SetOptions
- type Signer
- type SignerID
- type SignerSummary
- type SimpleAccount
- type Threshold
- type Timebounds
- type Transaction
- func BuildChallengeTx(serverSignerSecret, clientAccountID, homeDomain, network string, ...) (*Transaction, error)
- func NewTransaction(params TransactionParams) (*Transaction, error)
- func ReadChallengeTx(challengeTx, serverAccountID, network string, homeDomains []string) (tx *Transaction, clientAccountID string, matchedHomeDomain string, err error)
- func (t *Transaction) AddSignatureBase64(network, publicKey, signature string) (*Transaction, error)
- func (t *Transaction) Base64() (string, error)
- func (t *Transaction) BaseFee() int64
- func (t *Transaction) ClaimableBalanceID(operationIndex int) (string, 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) MaxFee() int64
- func (t *Transaction) Memo() Memo
- func (t *Transaction) Operations() []Operation
- 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) ToXDR() xdr.TransactionEnvelope
- func (t *Transaction) TxEnvelope() (xdr.TransactionEnvelope, error)
- type TransactionParams
- type TrustLineID
- type ValidationError
Examples ¶
- AccountMerge
- AllowTrust
- BeginSponsoringFutureReserves
- BeginSponsoringFutureReserves (Transfer)
- BuildChallengeTx
- BumpSequence
- ChangeTrust
- ChangeTrust (RemoveTrustline)
- ClaimClaimableBalance
- CreateAccount
- CreateClaimableBalance
- CreatePassiveSellOffer
- FeeBumpTransaction
- Inflation
- ManageBuyOffer
- ManageData
- ManageData (RemoveDataEntry)
- ManageSellOffer
- ManageSellOffer (DeleteOffer)
- ManageSellOffer (UpdateOffer)
- PathPayment
- PathPaymentStrictReceive
- PathPaymentStrictSend
- Payment
- Payment (SetBaseFee)
- RevokeSponsorship
- SetOptions
- VerifyChallengeTxThreshold
Constants ¶
const AuthImmutable = AccountFlag(xdr.AccountFlagsAuthImmutableFlag)
AuthImmutable is a flag that if set prevents any authorization flags from being set, and prevents the account from ever being merged (deleted).
const AuthRequired = AccountFlag(xdr.AccountFlagsAuthRequiredFlag)
AuthRequired is a flag that requires the issuing account to give other accounts permission before they can hold the issuing account's credit.
const AuthRevocable = AccountFlag(xdr.AccountFlagsAuthRevocableFlag)
AuthRevocable is a flag that allows the issuing account to revoke its credit held by other accounts.
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.
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.
var ( UnconditionalPredicate = xdr.ClaimPredicate{ Type: xdr.ClaimPredicateTypeClaimPredicateUnconditional, } )
Functions ¶
func AndPredicate ¶
func AndPredicate(left xdr.ClaimPredicate, right xdr.ClaimPredicate) xdr.ClaimPredicate
AndPredicate returns a xdr.ClaimPredicate
func BeforeAbsoluteTimePredicate ¶
func BeforeAbsoluteTimePredicate(epochSeconds int64) xdr.ClaimPredicate
BeforeAbsoluteTimePredicate returns a Before Absolute Time xdr.ClaimPredicate
This predicate will be fulfilled if the closing time of the ledger that includes the CreateClaimableBalance operation is less than this (absolute) Unix timestamp.
func BeforeRelativeTimePredicate ¶
func BeforeRelativeTimePredicate(secondsBefore int64) xdr.ClaimPredicate
BeforeRelativeTimePredicate returns a Before Relative Time xdr.ClaimPredicate
This predicate will be fulfilled if the closing time of the ledger that includes the CreateClaimableBalance operation plus this relative time delta (in seconds) is less than the current time.
func NewHomeDomain ¶
NewHomeDomain is syntactic sugar that makes instantiating SetOptions more convenient.
func NewInflationDestination ¶
NewInflationDestination is syntactic sugar that makes instantiating SetOptions more convenient.
func NotPredicate ¶
func NotPredicate(pred xdr.ClaimPredicate) xdr.ClaimPredicate
NotPredicate returns a new predicate inverting the passed in predicate
func OrPredicate ¶
func OrPredicate(left xdr.ClaimPredicate, right xdr.ClaimPredicate) xdr.ClaimPredicate
OrPredicate returns a xdr.ClaimPredicate
func SetOpSourceAccount ¶
SetOpSourceAccount sets the source account ID on an Operation.
func VerifyChallengeTxSigners ¶
func VerifyChallengeTxSigners(challengeTx, serverAccountID, network string, homeDomains []string, signers ...string) ([]string, error)
VerifyChallengeTxSigners verifies that for a SEP 10 challenge transaction all signatures on the transaction are accounted for. A transaction is verified if it is signed by the server account, and all other signatures match a signer that has been provided as an argument. Additional signers can be provided that do not have a signature, but all signatures must be matched to a signer for verification to succeed. If verification succeeds a list of signers that were found is returned, excluding the server account ID.
Signers that are not prefixed as an address/account ID strkey (G...) will be ignored.
The homeDomain field is reserved for future use and not used.
Errors will be raised if:
- The transaction is invalid according to ReadChallengeTx.
- No client signatures are found on the transaction.
- One or more signatures in the transaction are not identifiable as the server account or one of the signers provided in the arguments.
func VerifyChallengeTxThreshold ¶
func VerifyChallengeTxThreshold(challengeTx, serverAccountID, network string, homeDomains []string, threshold Threshold, signerSummary SignerSummary) (signersFound []string, err error)
VerifyChallengeTxThreshold verifies that for a SEP 10 challenge transaction all signatures on the transaction are accounted for and that the signatures meet a threshold on an account. A transaction is verified if it is signed by the server account, and all other signatures match a signer that has been provided as an argument, and those signatures meet a threshold on the account.
Signers that are not prefixed as an address/account ID strkey (G...) will be ignored.
The homeDomain field is reserved for future use and not used.
Errors will be raised if:
- The transaction is invalid according to ReadChallengeTx.
- No client signatures are found on the transaction.
- One or more signatures in the transaction are not identifiable as the server account or one of the signers provided in the arguments.
- The signatures are all valid but do not meet the threshold.
Example ¶
package main import ( "fmt" "sort" "time" "github.com/AnneNamuli/go-stellar/clients/horizonclient" "github.com/AnneNamuli/go-stellar/keypair" "github.com/AnneNamuli/go-stellar/network" "github.com/AnneNamuli/go-stellar/protocols/horizon" "github.com/AnneNamuli/go-stellar/txnbuild" ) var serverAccount, _ = keypair.ParseFull("SCDXPYDGKV5HOAGVZN3FQSS5FKUPP5BAVBWH4FXKTAWAC24AE4757JSI") var clientAccount, _ = keypair.ParseFull("SANVNCABRBVISCV7KH4SZVBKPJWWTT4424OVWUHUHPH2MVSF6RC7HPGN") var clientSigner1, _ = keypair.ParseFull("SBPQUZ6G4FZNWFHKUWC5BEYWF6R52E3SEP7R3GWYSM2XTKGF5LNTWW4R") var clientSigner2, _ = keypair.ParseFull("SBMSVD4KKELKGZXHBUQTIROWUAPQASDX7KEJITARP4VMZ6KLUHOGPTYW") var horizonClient = func() horizonclient.ClientInterface { client := &horizonclient.MockClient{} client. On("AccountDetail", horizonclient.AccountRequest{AccountID: clientAccount.Address()}). Return( horizon.Account{ Thresholds: horizon.AccountThresholds{LowThreshold: 1, MedThreshold: 10, HighThreshold: 100}, Signers: []horizon.Signer{ {Key: clientSigner1.Address(), Weight: 40}, {Key: clientSigner2.Address(), Weight: 60}, }, }, nil, ) return client }() func main() { // Server builds challenge transaction var challengeTx string { tx, err := txnbuild.BuildChallengeTx(serverAccount.Seed(), clientAccount.Address(), "test", network.TestNetworkPassphrase, time.Minute) if err != nil { fmt.Println("Error:", err) return } challengeTx, err = tx.Base64() if err != nil { fmt.Println("Error:", err) return } } // Client reads and signs challenge transaction var signedChallengeTx string { tx, txClientAccountID, _, err := txnbuild.ReadChallengeTx(challengeTx, serverAccount.Address(), network.TestNetworkPassphrase, []string{"test"}) if err != nil { fmt.Println("Error:", err) return } if txClientAccountID != clientAccount.Address() { fmt.Println("Error: challenge tx is not for expected client account") return } tx, err = tx.Sign(network.TestNetworkPassphrase, clientSigner1, clientSigner2) if err != nil { fmt.Println("Error:", err) return } signedChallengeTx, err = tx.Base64() if err != nil { fmt.Println("Error:", err) return } } // Server verifies signed challenge transaction { _, txClientAccountID, _, err := txnbuild.ReadChallengeTx(challengeTx, serverAccount.Address(), network.TestNetworkPassphrase, []string{"test"}) if err != nil { fmt.Println("Error:", err) return } // Server gets account clientAccountExists := false horizonClientAccount, err := horizonClient.AccountDetail(horizonclient.AccountRequest{AccountID: txClientAccountID}) if horizonclient.IsNotFoundError(err) { clientAccountExists = false fmt.Println("Account does not exist, use master key to verify") } else if err == nil { clientAccountExists = true } else { fmt.Println("Error:", err) return } if clientAccountExists { // Server gets list of signers from account signerSummary := horizonClientAccount.SignerSummary() // Server chooses the threshold to require: low, med or high threshold := txnbuild.Threshold(horizonClientAccount.Thresholds.MedThreshold) // Server verifies threshold is met signers, err := txnbuild.VerifyChallengeTxThreshold(signedChallengeTx, serverAccount.Address(), network.TestNetworkPassphrase, []string{"test"}, threshold, signerSummary) if err != nil { fmt.Println("Error:", err) return } fmt.Println("Client Signers Verified:") sort.Strings(signers) for _, signer := range signers { fmt.Println(signer, "weight:", signerSummary[signer]) } } else { // Server verifies that master key has signed challenge transaction signersFound, err := txnbuild.VerifyChallengeTxSigners(signedChallengeTx, serverAccount.Address(), network.TestNetworkPassphrase, []string{"test"}, txClientAccountID) if err != nil { fmt.Println("Error:", err) return } fmt.Println("Client Master Key Verified:") for _, signerFound := range signersFound { fmt.Println(signerFound) } } } }
Output: Client Signers Verified: GAS4V4O2B7DW5T7IQRPEEVCRXMDZESKISR7DVIGKZQYYV3OSQ5SH5LVP weight: 60 GDQNY3PBOJOKYZSRMK2S7LHHGWZIUISD4QORETLMXEWXBI7KFZZMKTL3 weight: 40
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://www.stellar.org/developers/guides/concepts/accounts.html
type AccountFlag ¶
type AccountFlag uint32
AccountFlag represents the bitmask flags used to set and clear account authorization options.
type AccountMerge ¶
AccountMerge represents the Stellar merge account operation. See https://www.stellar.org/developers/guides/concepts/list-of-operations.html
Example ¶
kp, _ := keypair.Parse("SBPQUZ6G4FZNWFHKUWC5BEYWF6R52E3SEP7R3GWYSM2XTKGF5LNTWW4R") client := horizonclient.DefaultTestNetClient ar := horizonclient.AccountRequest{AccountID: kp.Address()} sourceAccount, err := client.AccountDetail(ar) check(err) op := AccountMerge{ Destination: "GCCOBXW2XQNUSL467IEILE6MMCNRR66SSVL4YQADUNYYNUVREF3FIV2Z", } tx, err := NewTransaction( TransactionParams{ SourceAccount: &sourceAccount, IncrementSequenceNum: true, Operations: []Operation{&op}, BaseFee: MinBaseFee, Timebounds: NewInfiniteTimeout(), // Use a real timeout in production! }, ) check(err) tx, err = tx.Sign(network.TestNetworkPassphrase, kp.(*keypair.Full)) check(err) txe, err := tx.Base64() check(err) fmt.Println(txe)
Output: AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAABAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAACAAAAACE4N7avBtJL576CIWTzGCbGPvSlVfMQAOjcYbSsSF2VAAAAAAAAAAB6i5yxQAAAEAvOx3WHzmaTsf4rK+yRDsvXn9xh+dU6CkpAum+FCXQ5LZQqhxQg9HErbSfxeTFMdknEpMKXgJRFUfAetl+jf4O
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() Account
GetSourceAccount returns the source account of the operation, or nil 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 ¶
type AllowTrust struct { Trustor string Type Asset Authorize bool AuthorizeToMaintainLiabilities bool SourceAccount Account }
AllowTrust represents the Stellar allow trust operation. See https://www.stellar.org/developers/guides/concepts/list-of-operations.html
Example ¶
kp, _ := keypair.Parse("SBPQUZ6G4FZNWFHKUWC5BEYWF6R52E3SEP7R3GWYSM2XTKGF5LNTWW4R") client := horizonclient.DefaultTestNetClient ar := horizonclient.AccountRequest{AccountID: kp.Address()} sourceAccount, err := client.AccountDetail(ar) check(err) op := AllowTrust{ Trustor: "GCCOBXW2XQNUSL467IEILE6MMCNRR66SSVL4YQADUNYYNUVREF3FIV2Z", Type: CreditAsset{"ABCD", "GCCOBXW2XQNUSL467IEILE6MMCNRR66SSVL4YQADUNYYNUVREF3FIV2Z"}, Authorize: true, } tx, err := NewTransaction( TransactionParams{ SourceAccount: &sourceAccount, IncrementSequenceNum: true, Operations: []Operation{&op}, BaseFee: MinBaseFee, Timebounds: NewInfiniteTimeout(), // Use a real timeout in production! }, ) check(err) tx, err = tx.Sign(network.TestNetworkPassphrase, kp.(*keypair.Full)) check(err) txe, err := tx.Base64() check(err) fmt.Println(txe)
Output: AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAABAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABwAAAACE4N7avBtJL576CIWTzGCbGPvSlVfMQAOjcYbSsSF2VAAAAAFBQkNEAAAAAQAAAAAAAAAB6i5yxQAAAEAY3MnWiMcL18SxRITSuI5tZSXmEo0Q38UZg0jiJGU2U6kSnsCNTTJiGACGQlIrPfAMYt9koarrX11w7HLBosQN
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() Account
GetSourceAccount returns the source account of the operation, or nil 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 ¶
type Asset interface { GetType() (AssetType, error) IsNative() bool GetCode() string GetIssuer() string ToXDR() (xdr.Asset, error) }
Asset represents a Stellar asset.
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 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 BeginSponsoringFutureReserves ¶
BeginSponsoringFutureReserves represents the Stellar begin sponsoring future reserves operation. See https://www.stellar.org/developers/guides/concepts/list-of-operations.html
Example ¶
test := InitSponsorshipTestConfig() // If the sponsoree submits the transaction, the `SourceAccount` fields can // be omitted for the "sponsor sandwich" operations. sponsorTrustline := []Operation{ &BeginSponsoringFutureReserves{SponsoredID: test.A.Address()}, &ChangeTrust{ SourceAccount: &test.Aaccount, Line: &test.Assets[0], Limit: MaxTrustlineLimit, }, &EndSponsoringFutureReserves{}, } // The sponsorer obviously must sign the tx, but so does the sponsoree, to // consent to the sponsored operation. txb64, err := newSignedTransaction( TransactionParams{ SourceAccount: &test.Aaccount, Operations: sponsorTrustline, Timebounds: NewInfiniteTimeout(), BaseFee: MinBaseFee, IncrementSequenceNum: true, }, network.TestNetworkPassphrase, test.S1, test.A, ) check(err) fmt.Println(txb64)
Output: AAAAAgAAAAC0FS8Odh4yFSpaseK1sYMMVdTpVCJmylGJpMeYu9LOKAAAASwAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAEAAAAAC0FS8Odh4yFSpaseK1sYMMVdTpVCJmylGJpMeYu9LOKAAAAAEAAAAAtBUvDnYeMhUqWrHitbGDDFXU6VQiZspRiaTHmLvSzigAAAAGAAAAAUFCQ0QAAAAAfhHLNNY19eGrAtSgLD3VpaRm2AjNjxIBWQg9zS4VWZh//////////wAAAAAAAAARAAAAAAAAAAIuFVmYAAAAQARLe8wjGKq6WwdOPGkw2jo4eltp6dAHXEum4kYKzIjYx9fs4kdNJAaJE0s3Fy6JAIo1ttrGWp8zq6VX6P5CcAW70s4oAAAAQNpzu6NxKgcYd70mJl6EHyRPdjNTfxGm1w4XIIyIfZElRpmuZ6aWpXA0wwS6BimT3UQizK55T1kt1B2Pi3KyPAw=
Example (Transfer) ¶
test := InitSponsorshipTestConfig() transferOps := []Operation{ &BeginSponsoringFutureReserves{ SourceAccount: &test.S2account, SponsoredID: test.S1.Address(), }, &RevokeSponsorship{ SponsorshipType: RevokeSponsorshipTypeTrustLine, Account: &test.Aaccount.AccountID, TrustLine: &TrustLineID{ Account: test.A.Address(), Asset: test.Assets[1], }, }, &EndSponsoringFutureReserves{}, } // For transfers, both the old and new sponsor need to sign. txb64, err := newSignedTransaction( TransactionParams{ SourceAccount: &test.S1account, Operations: transferOps, Timebounds: NewInfiniteTimeout(), BaseFee: MinBaseFee, IncrementSequenceNum: true, }, network.TestNetworkPassphrase, test.S1, test.S2, ) check(err) fmt.Println(txb64)
Output: AAAAAgAAAAB+Ecs01jX14asC1KAsPdWlpGbYCM2PEgFZCD3NLhVZmAAAASwAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAABAAAAAODcbeFyXKxmUWK1L6znNbKKIkPkHRJNbLktcKPqLnLFAAAAEAAAAAB+Ecs01jX14asC1KAsPdWlpGbYCM2PEgFZCD3NLhVZmAAAAAAAAAASAAAAAAAAAAEAAAAAtBUvDnYeMhUqWrHitbGDDFXU6VQiZspRiaTHmLvSzigAAAABRUZHSAAAAAB+Ecs01jX14asC1KAsPdWlpGbYCM2PEgFZCD3NLhVZmAAAAAAAAAARAAAAAAAAAAIuFVmYAAAAQDx6tSWzDT5MCVpolKLvhBwM/PpV9d/Om8PlJ4GZekp+DY6H2XAZ+Rldlfa0DqK8KNuMF921Vha6fpmK7FY4/QrqLnLFAAAAQCxxzLrpHFwd+CS6xmAoytq+ORtrkxUy2k6B7wIuASrlJDnYAHZptf7bBKXPn5ImcpJIcB3E5Xl98s/lEA0+YAA=
func (*BeginSponsoringFutureReserves) BuildXDR ¶
func (bs *BeginSponsoringFutureReserves) BuildXDR() (xdr.Operation, error)
BuildXDR for BeginSponsoringFutureReserves returns a fully configured XDR Operation.
func (*BeginSponsoringFutureReserves) FromXDR ¶
func (bs *BeginSponsoringFutureReserves) FromXDR(xdrOp xdr.Operation) error
FromXDR for BeginSponsoringFutureReserves initializes the txnbuild struct from the corresponding xdr Operation.
func (*BeginSponsoringFutureReserves) GetSourceAccount ¶
func (bs *BeginSponsoringFutureReserves) GetSourceAccount() Account
GetSourceAccount returns the source account of the operation, or nil if not set.
func (*BeginSponsoringFutureReserves) Validate ¶
func (bs *BeginSponsoringFutureReserves) Validate() error
Validate for BeginSponsoringFutureReserves validates the required struct fields. It returns an error if any of the fields are invalid. Otherwise, it returns nil.
type BumpSequence ¶
BumpSequence represents the Stellar bump sequence operation. See https://www.stellar.org/developers/guides/concepts/list-of-operations.html
Example ¶
kp, _ := keypair.Parse("SBPQUZ6G4FZNWFHKUWC5BEYWF6R52E3SEP7R3GWYSM2XTKGF5LNTWW4R") client := horizonclient.DefaultTestNetClient ar := horizonclient.AccountRequest{AccountID: kp.Address()} sourceAccount, err := client.AccountDetail(ar) check(err) op := BumpSequence{ BumpTo: 9606132444168300, } tx, err := NewTransaction( TransactionParams{ SourceAccount: &sourceAccount, IncrementSequenceNum: true, Operations: []Operation{&op}, BaseFee: MinBaseFee, Timebounds: NewInfiniteTimeout(), // Use a real timeout in production! }, ) check(err) tx, err = tx.Sign(network.TestNetworkPassphrase, kp.(*keypair.Full)) check(err) txe, err := tx.Base64() check(err) fmt.Println(txe)
Output: AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAABAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAACwAiILoAAABsAAAAAAAAAAHqLnLFAAAAQEIvyOHdPn82ckKXISGF6sR4YU5ox735ivKrC/wS4615j1AA42vbXSLqShJA5/7/DX56UUv+Lt7vlcu9M7jsRw4=
func (*BumpSequence) BuildXDR ¶
func (bs *BumpSequence) BuildXDR() (xdr.Operation, error)
BuildXDR for BumpSequence returns a fully configured XDR Operation.
func (*BumpSequence) FromXDR ¶
func (bs *BumpSequence) FromXDR(xdrOp xdr.Operation) error
FromXDR for BumpSequence initialises the txnbuild struct from the corresponding xdr Operation.
func (*BumpSequence) GetSourceAccount ¶
func (bs *BumpSequence) GetSourceAccount() Account
GetSourceAccount returns the source account of the operation, or nil 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 ¶
ChangeTrust represents the Stellar change trust operation. See https://www.stellar.org/developers/guides/concepts/list-of-operations.html. If Limit is omitted, it defaults to txnbuild.MaxTrustlineLimit.
Example ¶
kp, _ := keypair.Parse("SBPQUZ6G4FZNWFHKUWC5BEYWF6R52E3SEP7R3GWYSM2XTKGF5LNTWW4R") client := horizonclient.DefaultTestNetClient ar := horizonclient.AccountRequest{AccountID: kp.Address()} sourceAccount, err := client.AccountDetail(ar) check(err) op := ChangeTrust{ Line: CreditAsset{"ABCD", "GCCOBXW2XQNUSL467IEILE6MMCNRR66SSVL4YQADUNYYNUVREF3FIV2Z"}, Limit: "10", } tx, err := NewTransaction( TransactionParams{ SourceAccount: &sourceAccount, IncrementSequenceNum: true, Operations: []Operation{&op}, BaseFee: MinBaseFee, Timebounds: NewInfiniteTimeout(), // Use a real timeout in production! }, ) check(err) tx, err = tx.Sign(network.TestNetworkPassphrase, kp.(*keypair.Full)) check(err) txe, err := tx.Base64() check(err) fmt.Println(txe)
Output: AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAABAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABgAAAAFBQkNEAAAAAITg3tq8G0kvnvoIhZPMYJsY+9KVV8xAA6NxhtKxIXZUAAAAAAX14QAAAAAAAAAAAeoucsUAAABAqqUuIlFMrlElYnGSLHlaI/A41oGA3rdtc1EHhza9bXk35ZwlEvmsBUOZTasZfgBzwd+CczekWKBCEqBCHzaSBw==
Example (RemoveTrustline) ¶
kp, _ := keypair.Parse("SBPQUZ6G4FZNWFHKUWC5BEYWF6R52E3SEP7R3GWYSM2XTKGF5LNTWW4R") client := horizonclient.DefaultTestNetClient ar := horizonclient.AccountRequest{AccountID: kp.Address()} sourceAccount, err := client.AccountDetail(ar) check(err) op := RemoveTrustlineOp(CreditAsset{"ABCD", "GCCOBXW2XQNUSL467IEILE6MMCNRR66SSVL4YQADUNYYNUVREF3FIV2Z"}) tx, err := NewTransaction( TransactionParams{ SourceAccount: &sourceAccount, IncrementSequenceNum: true, Operations: []Operation{&op}, BaseFee: MinBaseFee, Timebounds: NewInfiniteTimeout(), // Use a real timeout in production! }, ) check(err) tx, err = tx.Sign(network.TestNetworkPassphrase, kp.(*keypair.Full)) check(err) txe, err := tx.Base64() check(err) fmt.Println(txe)
Output: AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAABAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABgAAAAFBQkNEAAAAAITg3tq8G0kvnvoIhZPMYJsY+9KVV8xAA6NxhtKxIXZUAAAAAAAAAAAAAAAAAAAAAeoucsUAAABAKLmUWcLjxeY+vG8jEXMNprU6EupxbMRiXGYzuKBptnVlbFUtTBqhYa/ibyCZTEVCinT8bWQKDvZI0m6VLKVHAg==
func RemoveTrustlineOp ¶
func RemoveTrustlineOp(issuedAsset Asset) 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() Account
GetSourceAccount returns the source account of the operation, or nil 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 ClaimClaimableBalance ¶
ClaimClaimableBalance represents the Stellar claim claimable balance operation. See https://www.stellar.org/developers/guides/concepts/list-of-operations.html
Example ¶
A := "SCZANGBA5YHTNYVVV4C3U252E2B6P6F5T3U6MM63WBSBZATAQI3EBTQ4" aKeys := keypair.MustParseFull(A) aAccount := SimpleAccount{AccountID: aKeys.Address()} balanceId := "000000000bf0a78c7ca2a980768b66980ba97934f3b3b45a05ce7a5195a44b64b7dedadb" claimBalance := ClaimClaimableBalance{BalanceID: balanceId} txb64, err := newSignedTransaction( TransactionParams{ SourceAccount: &aAccount, // or Account B, depending on the condition! IncrementSequenceNum: true, BaseFee: MinBaseFee, Timebounds: NewInfiniteTimeout(), Operations: []Operation{&claimBalance}, }, network.TestNetworkPassphrase, aKeys, ) check(err) fmt.Println(txb64)
Output: AAAAAgAAAAC0FS8Odh4yFSpaseK1sYMMVdTpVCJmylGJpMeYu9LOKAAAAGQAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAADwAAAAAL8KeMfKKpgHaLZpgLqXk087O0WgXOelGVpEtkt97a2wAAAAAAAAABu9LOKAAAAEAesnN9L5oVpoZloBoUYfafhhuGSXAsJL2q15zyyWysc7fOADPdiQXQTEuySp12/ciGYWbZhw/fvyzLJlTgqmsI
func (*ClaimClaimableBalance) BuildXDR ¶
func (cb *ClaimClaimableBalance) BuildXDR() (xdr.Operation, error)
BuildXDR for ClaimClaimableBalance returns a fully configured XDR Operation.
func (*ClaimClaimableBalance) FromXDR ¶
func (cb *ClaimClaimableBalance) FromXDR(xdrOp xdr.Operation) error
FromXDR for ClaimClaimableBalance initializes the txnbuild struct from the corresponding xdr Operation.
func (*ClaimClaimableBalance) GetSourceAccount ¶
func (cb *ClaimClaimableBalance) GetSourceAccount() Account
GetSourceAccount returns the source account of the operation, or nil if not set.
func (*ClaimClaimableBalance) Validate ¶
func (cb *ClaimClaimableBalance) Validate() error
Validate for ClaimClaimableBalance validates the required struct fields. It returns an error if any of the fields are invalid. Otherwise, it returns nil.
type Claimant ¶
type Claimant struct { Destination string Predicate xdr.ClaimPredicate }
Claimant represents a claimable balance claimant
func NewClaimant ¶
func NewClaimant(destination string, predicate *xdr.ClaimPredicate) Claimant
NewClaimant returns a new Claimant, if predicate is nil then a Claimant with unconditional predicate is returned.
type CreateAccount ¶
CreateAccount represents the Stellar create account operation. See https://www.stellar.org/developers/guides/concepts/list-of-operations.html
Example ¶
kp, _ := keypair.Parse("SBPQUZ6G4FZNWFHKUWC5BEYWF6R52E3SEP7R3GWYSM2XTKGF5LNTWW4R") client := horizonclient.DefaultTestNetClient ar := horizonclient.AccountRequest{AccountID: kp.Address()} sourceAccount, err := client.AccountDetail(ar) check(err) op := CreateAccount{ Destination: "GCCOBXW2XQNUSL467IEILE6MMCNRR66SSVL4YQADUNYYNUVREF3FIV2Z", Amount: "10", } tx, err := NewTransaction( TransactionParams{ SourceAccount: &sourceAccount, IncrementSequenceNum: true, Operations: []Operation{&op}, BaseFee: MinBaseFee, Timebounds: NewInfiniteTimeout(), // Use a real timeout in production! }, ) check(err) tx, err = tx.Sign(network.TestNetworkPassphrase, kp.(*keypair.Full)) check(err) txe, err := tx.Base64() check(err) fmt.Println(txe)
Output: AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAABAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAACE4N7avBtJL576CIWTzGCbGPvSlVfMQAOjcYbSsSF2VAAAAAAF9eEAAAAAAAAAAAHqLnLFAAAAQKsrlxt6Ri/WuDGcK1+Tk1hdYHdPeK7KMIds10mcwzw6BpQFZYxP8o6O6ejJFGO06TAGt2PolwuWnpeiVQ9Kcg0=
func (*CreateAccount) BuildXDR ¶
func (ca *CreateAccount) BuildXDR() (xdr.Operation, error)
BuildXDR for CreateAccount returns a fully configured XDR Operation.
func (*CreateAccount) FromXDR ¶
func (ca *CreateAccount) FromXDR(xdrOp xdr.Operation) error
FromXDR for CreateAccount initialises the txnbuild struct from the corresponding xdr Operation.
func (*CreateAccount) GetSourceAccount ¶
func (ca *CreateAccount) GetSourceAccount() Account
GetSourceAccount returns the source account of the operation, or nil if not set.
func (*CreateAccount) Validate ¶
func (ca *CreateAccount) Validate() error
Validate for CreateAccount validates the required struct fields. It returns an error if any of the fields are invalid. Otherwise, it returns nil.
type CreateClaimableBalance ¶
type CreateClaimableBalance struct { Amount string Asset Asset Destinations []Claimant SourceAccount Account }
CreateClaimableBalance represents the Stellar create claimable balance operation. See https://www.stellar.org/developers/guides/concepts/list-of-operations.html
Example ¶
A := "SCZANGBA5YHTNYVVV4C3U252E2B6P6F5T3U6MM63WBSBZATAQI3EBTQ4" B := "GA2C5RFPE6GCKMY3US5PAB6UZLKIGSPIUKSLRB6Q723BM2OARMDUYEJ5" aKeys := keypair.MustParseFull(A) aAccount := SimpleAccount{AccountID: aKeys.Address()} soon := time.Now().Add(time.Second * 60) bCanClaim := BeforeRelativeTimePredicate(60) aCanReclaim := NotPredicate(BeforeAbsoluteTimePredicate(soon.Unix())) claimants := []Claimant{ NewClaimant(B, &bCanClaim), NewClaimant(aKeys.Address(), &aCanReclaim), } claimableBalanceEntry := CreateClaimableBalance{ Destinations: claimants, Asset: NativeAsset{}, Amount: "420", } // Build and sign the transaction tx, err := NewTransaction( TransactionParams{ SourceAccount: &aAccount, IncrementSequenceNum: true, BaseFee: MinBaseFee, Timebounds: NewInfiniteTimeout(), Operations: []Operation{&claimableBalanceEntry}, }, ) check(err) tx, err = tx.Sign(network.TestNetworkPassphrase, aKeys) check(err) balanceId, err := tx.ClaimableBalanceID(0) check(err) fmt.Println(balanceId)
Output: 000000000bf0a78c7ca2a980768b66980ba97934f3b3b45a05ce7a5195a44b64b7dedadb
func (*CreateClaimableBalance) BuildXDR ¶
func (cb *CreateClaimableBalance) BuildXDR() (xdr.Operation, error)
BuildXDR for CreateClaimableBalance returns a fully configured XDR Operation.
func (*CreateClaimableBalance) FromXDR ¶
func (cb *CreateClaimableBalance) FromXDR(xdrOp xdr.Operation) error
FromXDR for CreateClaimableBalance initializes the txnbuild struct from the corresponding xdr Operation.
func (*CreateClaimableBalance) GetSourceAccount ¶
func (cb *CreateClaimableBalance) GetSourceAccount() Account
GetSourceAccount returns the source account of the operation, or nil if not set.
func (*CreateClaimableBalance) Validate ¶
func (cb *CreateClaimableBalance) Validate() error
Validate for CreateClaimableBalance validates the required struct fields. It returns an error if any of the fields are invalid. Otherwise, it returns nil.
type CreatePassiveSellOffer ¶
type CreatePassiveSellOffer struct { Selling Asset Buying Asset Amount string Price string SourceAccount Account // contains filtered or unexported fields }
CreatePassiveSellOffer represents the Stellar create passive offer operation. See https://www.stellar.org/developers/guides/concepts/list-of-operations.html
Example ¶
kp, _ := keypair.Parse("SBPQUZ6G4FZNWFHKUWC5BEYWF6R52E3SEP7R3GWYSM2XTKGF5LNTWW4R") client := horizonclient.DefaultTestNetClient ar := horizonclient.AccountRequest{AccountID: kp.Address()} sourceAccount, err := client.AccountDetail(ar) check(err) op := CreatePassiveSellOffer{ Selling: NativeAsset{}, Buying: CreditAsset{"ABCD", "GAS4V4O2B7DW5T7IQRPEEVCRXMDZESKISR7DVIGKZQYYV3OSQ5SH5LVP"}, Amount: "10", Price: "1.0", } tx, err := NewTransaction( TransactionParams{ SourceAccount: &sourceAccount, IncrementSequenceNum: true, Operations: []Operation{&op}, BaseFee: MinBaseFee, Timebounds: NewInfiniteTimeout(), // Use a real timeout in production! }, ) check(err) tx, err = tx.Sign(network.TestNetworkPassphrase, kp.(*keypair.Full)) check(err) txe, err := tx.Base64() check(err) fmt.Println(txe)
Output: AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAABAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABAAAAAAAAAABQUJDRAAAAAAlyvHaD8duz+iEXkJUUbsHkklIlH46oMrMMYrt0odkfgAAAAAF9eEAAAAAAQAAAAEAAAAAAAAAAeoucsUAAABAE4XbLdDVz1MwC9Bs84nkqK8hyHheVbYznNSiAP0hiP8auvcKAMnYz3HJvzM8H0q/K5MPvgBaehHZ/tQtaPSGBg==
func (*CreatePassiveSellOffer) BuildXDR ¶
func (cpo *CreatePassiveSellOffer) BuildXDR() (xdr.Operation, error)
BuildXDR for CreatePassiveSellOffer returns a fully configured XDR Operation.
func (*CreatePassiveSellOffer) FromXDR ¶
func (cpo *CreatePassiveSellOffer) FromXDR(xdrOp xdr.Operation) error
FromXDR for CreatePassiveSellOffer initialises the txnbuild struct from the corresponding xdr Operation.
func (*CreatePassiveSellOffer) GetSourceAccount ¶
func (cpo *CreatePassiveSellOffer) GetSourceAccount() Account
GetSourceAccount returns the source account of the operation, or nil if not set.
func (*CreatePassiveSellOffer) Validate ¶
func (cpo *CreatePassiveSellOffer) Validate() error
Validate for CreatePassiveSellOffer validates the required struct fields. It returns an error if any of the fields are invalid. Otherwise, it returns nil.
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).
type EndSponsoringFutureReserves ¶
type EndSponsoringFutureReserves struct {
SourceAccount Account
}
EndSponsoringFutureReserves represents the Stellar begin sponsoring future reserves operation. See https://www.stellar.org/developers/guides/concepts/list-of-operations.html
func (*EndSponsoringFutureReserves) BuildXDR ¶
func (es *EndSponsoringFutureReserves) BuildXDR() (xdr.Operation, error)
BuildXDR for EndSponsoringFutureReserves returns a fully configured XDR Operation.
func (*EndSponsoringFutureReserves) FromXDR ¶
func (es *EndSponsoringFutureReserves) FromXDR(xdrOp xdr.Operation) error
FromXDR for EndSponsoringFutureReserves initializes the txnbuild struct from the corresponding xdr Operation.
func (*EndSponsoringFutureReserves) GetSourceAccount ¶
func (es *EndSponsoringFutureReserves) GetSourceAccount() Account
GetSourceAccount returns the source account of the operation, or nil if not set.
func (*EndSponsoringFutureReserves) Validate ¶
func (es *EndSponsoringFutureReserves) Validate() error
Validate for EndSponsoringFutureReserves validates the required struct fields. It returns an error if any of the fields are invalid. Otherwise, it returns nil.
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.
Example ¶
kp, _ := keypair.Parse("SBPQUZ6G4FZNWFHKUWC5BEYWF6R52E3SEP7R3GWYSM2XTKGF5LNTWW4R") client := horizonclient.DefaultTestNetClient ar := horizonclient.AccountRequest{AccountID: kp.Address()} sourceAccount, err := client.AccountDetail(ar) check(err) op := BumpSequence{ BumpTo: 9606132444168300, } tx, err := NewTransaction( TransactionParams{ SourceAccount: &sourceAccount, IncrementSequenceNum: true, Operations: []Operation{&op}, BaseFee: MinBaseFee, Timebounds: NewInfiniteTimeout(), // Use a real timeout in production! }, ) check(err) tx, err = tx.Sign(network.TestNetworkPassphrase, kp.(*keypair.Full)) check(err) feeBumpKP, _ := keypair.Parse("SBZVMB74Z76QZ3ZOY7UTDFYKMEGKW5XFJEB6PFKBF4UYSSWHG4EDH7PY") feeBumpTx, err := NewFeeBumpTransaction( FeeBumpTransactionParams{ Inner: tx, FeeAccount: feeBumpKP.Address(), BaseFee: MinBaseFee, }, ) check(err) feeBumpTx, err = feeBumpTx.Sign(network.TestNetworkPassphrase, feeBumpKP.(*keypair.Full)) check(err) txe, err := feeBumpTx.Base64() check(err) fmt.Println(txe)
Output: AAAABQAAAAB+Ecs01jX14asC1KAsPdWlpGbYCM2PEgFZCD3NLhVZmAAAAAAAAADIAAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAABAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAACwAiILoAAABsAAAAAAAAAAHqLnLFAAAAQEIvyOHdPn82ckKXISGF6sR4YU5ox735ivKrC/wS4615j1AA42vbXSLqShJA5/7/DX56UUv+Lt7vlcu9M7jsRw4AAAAAAAAAAS4VWZgAAABAeD0gL6WpzSdGTzWd4c9yUu3r+W21hOTLT4ItHGBTHYPT20Wk3dytuqfP89EzlkZXvtG8/N0HH4w+oJCLOL/5Aw==
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) 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) 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) 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://www.stellar.org/developers/guides/concepts/multi-sig.html#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) ToXDR ¶
func (t *FeeBumpTransaction) ToXDR() xdr.TransactionEnvelope
ToXDR is like TxEnvelope except that the transaction envelope returned by ToXDR should not be modified because any changes applied to the transaction envelope may affect the internals of the FeeBumpTransaction instance.
func (*FeeBumpTransaction) TxEnvelope ¶
func (t *FeeBumpTransaction) TxEnvelope() (xdr.TransactionEnvelope, error)
TxEnvelope returns the a xdr.TransactionEnvelope instance which is equivalent to this transaction.
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 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) 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.
type Inflation ¶
type Inflation struct {
SourceAccount Account
}
Inflation represents the Stellar inflation operation. See https://www.stellar.org/developers/guides/concepts/list-of-operations.html
Example ¶
kp, _ := keypair.Parse("SBPQUZ6G4FZNWFHKUWC5BEYWF6R52E3SEP7R3GWYSM2XTKGF5LNTWW4R") client := horizonclient.DefaultTestNetClient ar := horizonclient.AccountRequest{AccountID: kp.Address()} sourceAccount, err := client.AccountDetail(ar) check(err) op := Inflation{} tx, err := NewTransaction( TransactionParams{ SourceAccount: &sourceAccount, IncrementSequenceNum: true, Operations: []Operation{&op}, BaseFee: MinBaseFee, Timebounds: NewInfiniteTimeout(), // Use a real timeout in production! }, ) check(err) tx, err = tx.Sign(network.TestNetworkPassphrase, kp.(*keypair.Full)) check(err) txe, err := tx.Base64() check(err) fmt.Println(txe)
Output: AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAABAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAACQAAAAAAAAAB6i5yxQAAAED9zR1l78yiBwd/o44RyE3XP7QT57VmI90qE46TjfncYyqlOaIRWpkh3qouTjV5IRPVGo6+bFWV40H1HE087FgA
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 nil if not set.
type ManageBuyOffer ¶
type ManageBuyOffer struct { Selling Asset Buying Asset Amount string Price string OfferID int64 SourceAccount Account // contains filtered or unexported fields }
ManageBuyOffer represents the Stellar manage buy offer operation. See https://www.stellar.org/developers/guides/concepts/list-of-operations.html
Example ¶
kp, _ := keypair.Parse("SBZVMB74Z76QZ3ZOY7UTDFYKMEGKW5XFJEB6PFKBF4UYSSWHG4EDH7PY") client := horizonclient.DefaultTestNetClient ar := horizonclient.AccountRequest{AccountID: kp.Address()} sourceAccount, err := client.AccountDetail(ar) check(err) buyOffer := ManageBuyOffer{ Selling: NativeAsset{}, Buying: CreditAsset{"ABCD", "GDQNY3PBOJOKYZSRMK2S7LHHGWZIUISD4QORETLMXEWXBI7KFZZMKTL3"}, Amount: "100", Price: "0.01", OfferID: 0, } tx, err := NewTransaction( TransactionParams{ SourceAccount: &sourceAccount, IncrementSequenceNum: true, Operations: []Operation{&buyOffer}, BaseFee: MinBaseFee, Timebounds: NewInfiniteTimeout(), // Use a real timeout in production! }, ) check(err) tx, err = tx.Sign(network.TestNetworkPassphrase, kp.(*keypair.Full)) check(err) txe, err := tx.Base64() check(err) fmt.Println(txe)
Output: AAAAAgAAAAB+Ecs01jX14asC1KAsPdWlpGbYCM2PEgFZCD3NLhVZmAAAAGQADKI/AAAABAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAADAAAAAAAAAABQUJDRAAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAAA7msoAAAAAAQAAAGQAAAAAAAAAAAAAAAAAAAABLhVZmAAAAED4fIdU68w6XIMwf1RPFdF9qRRlfPycrmK8dCOW0XwSbiya9JfMi9YrD9cGY7zHV+3zYpLcEi7lLo++PZ1gOsAK
func (*ManageBuyOffer) BuildXDR ¶
func (mo *ManageBuyOffer) BuildXDR() (xdr.Operation, error)
BuildXDR for ManageBuyOffer returns a fully configured XDR Operation.
func (*ManageBuyOffer) FromXDR ¶
func (mo *ManageBuyOffer) FromXDR(xdrOp xdr.Operation) error
FromXDR for ManageBuyOffer initialises the txnbuild struct from the corresponding xdr Operation.
func (*ManageBuyOffer) GetSourceAccount ¶
func (mo *ManageBuyOffer) GetSourceAccount() Account
GetSourceAccount returns the source account of the operation, or nil if not set.
func (*ManageBuyOffer) Validate ¶
func (mo *ManageBuyOffer) Validate() error
Validate for ManageBuyOffer validates the required struct fields. It returns an error if any of the fields are invalid. Otherwise, it returns nil.
type ManageData ¶
ManageData represents the Stellar manage data operation. See https://www.stellar.org/developers/guides/concepts/list-of-operations.html
Example ¶
kp, _ := keypair.Parse("SBPQUZ6G4FZNWFHKUWC5BEYWF6R52E3SEP7R3GWYSM2XTKGF5LNTWW4R") client := horizonclient.DefaultTestNetClient ar := horizonclient.AccountRequest{AccountID: kp.Address()} sourceAccount, err := client.AccountDetail(ar) check(err) op := ManageData{ Name: "Fruit preference", Value: []byte("Apple"), } tx, err := NewTransaction( TransactionParams{ SourceAccount: &sourceAccount, IncrementSequenceNum: true, Operations: []Operation{&op}, BaseFee: MinBaseFee, Timebounds: NewInfiniteTimeout(), // Use a real timeout in production! }, ) check(err) tx, err = tx.Sign(network.TestNetworkPassphrase, kp.(*keypair.Full)) check(err) txe, err := tx.Base64() check(err) fmt.Println(txe)
Output: AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAABAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAACgAAABBGcnVpdCBwcmVmZXJlbmNlAAAAAQAAAAVBcHBsZQAAAAAAAAAAAAAB6i5yxQAAAEDtRCyQRKKgQ8iLEu7kicHtSzoplfxPtPTMhdRv/sq8UoIBVTxIw+S13Jv+jzs3tyLDLiGCVNXreUNlbfX+980K
Example (RemoveDataEntry) ¶
kp, _ := keypair.Parse("SBPQUZ6G4FZNWFHKUWC5BEYWF6R52E3SEP7R3GWYSM2XTKGF5LNTWW4R") client := horizonclient.DefaultTestNetClient ar := horizonclient.AccountRequest{AccountID: kp.Address()} sourceAccount, err := client.AccountDetail(ar) check(err) op := ManageData{ Name: "Fruit preference", } tx, err := NewTransaction( TransactionParams{ SourceAccount: &sourceAccount, IncrementSequenceNum: true, Operations: []Operation{&op}, BaseFee: MinBaseFee, Timebounds: NewInfiniteTimeout(), // Use a real timeout in production! }, ) check(err) tx, err = tx.Sign(network.TestNetworkPassphrase, kp.(*keypair.Full)) check(err) txe, err := tx.Base64() check(err) fmt.Println(txe)
Output: AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAABAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAACgAAABBGcnVpdCBwcmVmZXJlbmNlAAAAAAAAAAAAAAAB6i5yxQAAAEDFpI1vphzG8Dny4aVDA7tyOlP579d9kWO0U/vmq6pWTrNocd6+xTiU753W50ksEscA6f1WNwUsQf+DCwmZfqIA
func (*ManageData) BuildXDR ¶
func (md *ManageData) BuildXDR() (xdr.Operation, error)
BuildXDR for ManageData returns a fully configured XDR Operation.
func (*ManageData) FromXDR ¶
func (md *ManageData) FromXDR(xdrOp xdr.Operation) error
FromXDR for ManageData initialises the txnbuild struct from the corresponding xdr Operation.
func (*ManageData) GetSourceAccount ¶
func (md *ManageData) GetSourceAccount() Account
GetSourceAccount returns the source account of the operation, or nil if not set.
func (*ManageData) Validate ¶
func (md *ManageData) Validate() error
Validate for ManageData validates the required struct fields. It returns an error if any of the fields are invalid. Otherwise, it returns nil.
type ManageSellOffer ¶
type ManageSellOffer struct { Selling Asset Buying Asset Amount string Price string OfferID int64 SourceAccount Account // contains filtered or unexported fields }
ManageSellOffer represents the Stellar manage offer operation. See https://www.stellar.org/developers/guides/concepts/list-of-operations.html
Example ¶
kp, _ := keypair.Parse("SBPQUZ6G4FZNWFHKUWC5BEYWF6R52E3SEP7R3GWYSM2XTKGF5LNTWW4R") client := horizonclient.DefaultTestNetClient ar := horizonclient.AccountRequest{AccountID: kp.Address()} sourceAccount, err := client.AccountDetail(ar) check(err) selling := NativeAsset{} buying := CreditAsset{"ABCD", "GAS4V4O2B7DW5T7IQRPEEVCRXMDZESKISR7DVIGKZQYYV3OSQ5SH5LVP"} sellAmount := "100" price := "0.01" op, err := CreateOfferOp(selling, buying, sellAmount, price) check(err) tx, err := NewTransaction( TransactionParams{ SourceAccount: &sourceAccount, IncrementSequenceNum: true, Operations: []Operation{&op}, BaseFee: MinBaseFee, Timebounds: NewInfiniteTimeout(), // Use a real timeout in production! }, ) check(err) tx, err = tx.Sign(network.TestNetworkPassphrase, kp.(*keypair.Full)) check(err) txe, err := tx.Base64() check(err) fmt.Println(txe)
Output: AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAABAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAAAAAABQUJDRAAAAAAlyvHaD8duz+iEXkJUUbsHkklIlH46oMrMMYrt0odkfgAAAAA7msoAAAAAAQAAAGQAAAAAAAAAAAAAAAAAAAAB6i5yxQAAAEBtfrN+VUE7iCwBk0+rmg0/Ua4DItMWEy6naGWxoDBi4ksCIJSZPzkv79Q65rIaFyIcC/zuyJcnIcv73AP+HQEK
Example (DeleteOffer) ¶
kp, _ := keypair.Parse("SBPQUZ6G4FZNWFHKUWC5BEYWF6R52E3SEP7R3GWYSM2XTKGF5LNTWW4R") client := horizonclient.DefaultTestNetClient ar := horizonclient.AccountRequest{AccountID: kp.Address()} sourceAccount, err := client.AccountDetail(ar) check(err) offerID := int64(2921622) op, err := DeleteOfferOp(offerID) check(err) tx, err := NewTransaction( TransactionParams{ SourceAccount: &sourceAccount, IncrementSequenceNum: true, Operations: []Operation{&op}, BaseFee: MinBaseFee, Timebounds: NewInfiniteTimeout(), // Use a real timeout in production! }, ) check(err) tx, err = tx.Sign(network.TestNetworkPassphrase, kp.(*keypair.Full)) check(err) txe, err := tx.Base64() check(err) fmt.Println(txe)
Output: AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAABAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAAAAAABRkFLRQAAAABBB4BkxJWGYvNgJBoiXUo2tjgWlNmhHMMKdwGN7RSdsQAAAAAAAAAAAAAAAQAAAAEAAAAAACyUlgAAAAAAAAAB6i5yxQAAAEBnE+oILauqt6m8fj7DIBNW/XBmKJ34SLvHdxP04vb26aI8q9i/2p9/pJMnWPeOoIw0f6jreR306qPJFhjMtl4G
Example (UpdateOffer) ¶
kp, _ := keypair.Parse("SBPQUZ6G4FZNWFHKUWC5BEYWF6R52E3SEP7R3GWYSM2XTKGF5LNTWW4R") client := horizonclient.DefaultTestNetClient ar := horizonclient.AccountRequest{AccountID: kp.Address()} sourceAccount, err := client.AccountDetail(ar) check(err) selling := NativeAsset{} buying := CreditAsset{"ABCD", "GAS4V4O2B7DW5T7IQRPEEVCRXMDZESKISR7DVIGKZQYYV3OSQ5SH5LVP"} sellAmount := "50" price := "0.02" offerID := int64(2497628) op, err := UpdateOfferOp(selling, buying, sellAmount, price, offerID) check(err) tx, err := NewTransaction( TransactionParams{ SourceAccount: &sourceAccount, IncrementSequenceNum: true, Operations: []Operation{&op}, BaseFee: MinBaseFee, Timebounds: NewInfiniteTimeout(), // Use a real timeout in production! }, ) check(err) tx, err = tx.Sign(network.TestNetworkPassphrase, kp.(*keypair.Full)) check(err) txe, err := tx.Base64() check(err) fmt.Println(txe)
Output: AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAABAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAAAAAABQUJDRAAAAAAlyvHaD8duz+iEXkJUUbsHkklIlH46oMrMMYrt0odkfgAAAAAdzWUAAAAAAQAAADIAAAAAACYcXAAAAAAAAAAB6i5yxQAAAECmO+4yukAuLRtR4IRWPVtoyZ2LJeaipPuec+/M1JGDoTFPULDl3kgugPwV3mr0jvMNArBdR8S3NUw31gtT5TcO
func CreateOfferOp ¶
func CreateOfferOp(selling, buying Asset, amount, price string, sourceAccount ...Account) (ManageSellOffer, error)
CreateOfferOp returns a ManageSellOffer operation to create a new offer, by setting the OfferID to "0". The sourceAccount is optional, and if not provided, will be that of the surrounding transaction.
func DeleteOfferOp ¶
func DeleteOfferOp(offerID int64, sourceAccount ...Account) (ManageSellOffer, error)
DeleteOfferOp returns a ManageSellOffer operation to delete an offer, by setting the Amount to "0". The sourceAccount is optional, and if not provided, will be that of the surrounding transaction.
func UpdateOfferOp ¶
func UpdateOfferOp(selling, buying Asset, amount, price string, offerID int64, sourceAccount ...Account) (ManageSellOffer, error)
UpdateOfferOp returns a ManageSellOffer operation to update an offer. The sourceAccount is optional, and if not provided, will be that of the surrounding transaction.
func (*ManageSellOffer) BuildXDR ¶
func (mo *ManageSellOffer) BuildXDR() (xdr.Operation, error)
BuildXDR for ManageSellOffer returns a fully configured XDR Operation.
func (*ManageSellOffer) FromXDR ¶
func (mo *ManageSellOffer) FromXDR(xdrOp xdr.Operation) error
FromXDR for ManageSellOffer initialises the txnbuild struct from the corresponding xdr Operation.
func (*ManageSellOffer) GetSourceAccount ¶
func (mo *ManageSellOffer) GetSourceAccount() Account
GetSourceAccount returns the source account of the operation, or nil if not set.
func (*ManageSellOffer) Validate ¶
func (mo *ManageSellOffer) Validate() error
Validate for ManageSellOffer validates the required struct fields. It returns an error if any of the fields are invalid. Otherwise, it returns nil.
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).
type Operation ¶
type Operation interface { BuildXDR() (xdr.Operation, error) FromXDR(xdrOp xdr.Operation) error Validate() error GetSourceAccount() Account }
Operation represents the operation types of the Stellar network.
type PathPayment ¶
type PathPayment = PathPaymentStrictReceive
PathPayment represents the Stellar path_payment operation. This operation was removed in Stellar Protocol 12 and replaced by PathPaymentStrictReceive. Deprecated: This operation was renamed to PathPaymentStrictReceive, which functions identically.
Example ¶
kp, _ := keypair.Parse("SBZVMB74Z76QZ3ZOY7UTDFYKMEGKW5XFJEB6PFKBF4UYSSWHG4EDH7PY") client := horizonclient.DefaultTestNetClient ar := horizonclient.AccountRequest{AccountID: kp.Address()} sourceAccount, err := client.AccountDetail(ar) check(err) abcdAsset := CreditAsset{"ABCD", "GDQNY3PBOJOKYZSRMK2S7LHHGWZIUISD4QORETLMXEWXBI7KFZZMKTL3"} op := PathPayment{ SendAsset: NativeAsset{}, SendMax: "10", Destination: kp.Address(), DestAsset: NativeAsset{}, DestAmount: "1", Path: []Asset{abcdAsset}, } tx, err := NewTransaction( TransactionParams{ SourceAccount: &sourceAccount, IncrementSequenceNum: true, Operations: []Operation{&op}, BaseFee: MinBaseFee, Timebounds: NewInfiniteTimeout(), // Use a real timeout in production! }, ) check(err) tx, err = tx.Sign(network.TestNetworkPassphrase, kp.(*keypair.Full)) check(err) txe, err := tx.Base64() check(err) fmt.Println(txe)
Output: AAAAAgAAAAB+Ecs01jX14asC1KAsPdWlpGbYCM2PEgFZCD3NLhVZmAAAAGQADKI/AAAABAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAgAAAAAAAAAABfXhAAAAAAB+Ecs01jX14asC1KAsPdWlpGbYCM2PEgFZCD3NLhVZmAAAAAAAAAAAAJiWgAAAAAEAAAABQUJDRAAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAAAAAAABLhVZmAAAAEDhhPsNm7yKfCUCDyBV1pOZDu+3DVDpT2cJSLQOVevP6pmU2yVqvMKnWbYxC5GbTXEEF+MfBE6EoW5+Z4rRt0QO
type PathPaymentStrictReceive ¶
type PathPaymentStrictReceive struct { SendAsset Asset SendMax string Destination string DestAsset Asset DestAmount string Path []Asset SourceAccount Account }
PathPaymentStrictReceive represents the Stellar path_payment_strict_receive operation. See https://www.stellar.org/developers/guides/concepts/list-of-operations.html
Example ¶
kp, _ := keypair.Parse("SBZVMB74Z76QZ3ZOY7UTDFYKMEGKW5XFJEB6PFKBF4UYSSWHG4EDH7PY") client := horizonclient.DefaultTestNetClient ar := horizonclient.AccountRequest{AccountID: kp.Address()} sourceAccount, err := client.AccountDetail(ar) check(err) abcdAsset := CreditAsset{"ABCD", "GDQNY3PBOJOKYZSRMK2S7LHHGWZIUISD4QORETLMXEWXBI7KFZZMKTL3"} op := PathPaymentStrictReceive{ SendAsset: NativeAsset{}, SendMax: "10", Destination: kp.Address(), DestAsset: NativeAsset{}, DestAmount: "1", Path: []Asset{abcdAsset}, } tx, err := NewTransaction( TransactionParams{ SourceAccount: &sourceAccount, IncrementSequenceNum: true, Operations: []Operation{&op}, BaseFee: MinBaseFee, Timebounds: NewInfiniteTimeout(), // Use a real timeout in production! }, ) check(err) tx, err = tx.Sign(network.TestNetworkPassphrase, kp.(*keypair.Full)) check(err) txe, err := tx.Base64() check(err) fmt.Println(txe)
Output: AAAAAgAAAAB+Ecs01jX14asC1KAsPdWlpGbYCM2PEgFZCD3NLhVZmAAAAGQADKI/AAAABAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAgAAAAAAAAAABfXhAAAAAAB+Ecs01jX14asC1KAsPdWlpGbYCM2PEgFZCD3NLhVZmAAAAAAAAAAAAJiWgAAAAAEAAAABQUJDRAAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAAAAAAABLhVZmAAAAEDhhPsNm7yKfCUCDyBV1pOZDu+3DVDpT2cJSLQOVevP6pmU2yVqvMKnWbYxC5GbTXEEF+MfBE6EoW5+Z4rRt0QO
func (*PathPaymentStrictReceive) BuildXDR ¶
func (pp *PathPaymentStrictReceive) BuildXDR() (xdr.Operation, error)
BuildXDR for PathPaymentStrictReceive returns a fully configured XDR Operation.
func (*PathPaymentStrictReceive) FromXDR ¶
func (pp *PathPaymentStrictReceive) FromXDR(xdrOp xdr.Operation) error
FromXDR for PathPaymentStrictReceive initialises the txnbuild struct from the corresponding xdr Operation.
func (*PathPaymentStrictReceive) GetSourceAccount ¶
func (pp *PathPaymentStrictReceive) GetSourceAccount() Account
GetSourceAccount returns the source account of the operation, or nil if not set.
func (*PathPaymentStrictReceive) Validate ¶
func (pp *PathPaymentStrictReceive) Validate() error
Validate for PathPaymentStrictReceive validates the required struct fields. It returns an error if any of the fields are invalid. Otherwise, it returns nil.
type PathPaymentStrictSend ¶
type PathPaymentStrictSend struct { SendAsset Asset SendAmount string Destination string DestAsset Asset DestMin string Path []Asset SourceAccount Account }
PathPaymentStrictSend represents the Stellar path_payment_strict_send operation. See https://www.stellar.org/developers/guides/concepts/list-of-operations.html
Example ¶
kp, _ := keypair.Parse("SBZVMB74Z76QZ3ZOY7UTDFYKMEGKW5XFJEB6PFKBF4UYSSWHG4EDH7PY") client := horizonclient.DefaultTestNetClient ar := horizonclient.AccountRequest{AccountID: kp.Address()} sourceAccount, err := client.AccountDetail(ar) check(err) abcdAsset := CreditAsset{"ABCD", "GDQNY3PBOJOKYZSRMK2S7LHHGWZIUISD4QORETLMXEWXBI7KFZZMKTL3"} op := PathPaymentStrictSend{ SendAsset: NativeAsset{}, SendAmount: "1", Destination: kp.Address(), DestAsset: NativeAsset{}, DestMin: "10", Path: []Asset{abcdAsset}, } tx, err := NewTransaction( TransactionParams{ SourceAccount: &sourceAccount, IncrementSequenceNum: true, Operations: []Operation{&op}, BaseFee: MinBaseFee, Timebounds: NewInfiniteTimeout(), // Use a real timeout in production! }, ) check(err) tx, err = tx.Sign(network.TestNetworkPassphrase, kp.(*keypair.Full)) check(err) txe, err := tx.Base64() check(err) fmt.Println(txe)
Output: AAAAAgAAAAB+Ecs01jX14asC1KAsPdWlpGbYCM2PEgFZCD3NLhVZmAAAAGQADKI/AAAABAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAADQAAAAAAAAAAAJiWgAAAAAB+Ecs01jX14asC1KAsPdWlpGbYCM2PEgFZCD3NLhVZmAAAAAAAAAAABfXhAAAAAAEAAAABQUJDRAAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAAAAAAABLhVZmAAAAEDV6CmR4ATvtm2qBzHE9UqqS95ZnIIHgpuU7hTZO38DHhf+oeZQ02DGvst4vYMMAIPGkMAsLlfAN/AFinz74DAD
func (*PathPaymentStrictSend) BuildXDR ¶
func (pp *PathPaymentStrictSend) BuildXDR() (xdr.Operation, error)
BuildXDR for Payment returns a fully configured XDR Operation.
func (*PathPaymentStrictSend) FromXDR ¶
func (pp *PathPaymentStrictSend) FromXDR(xdrOp xdr.Operation) error
FromXDR for PathPaymentStrictSend initialises the txnbuild struct from the corresponding xdr Operation.
func (*PathPaymentStrictSend) GetSourceAccount ¶
func (pp *PathPaymentStrictSend) GetSourceAccount() Account
GetSourceAccount returns the source account of the operation, or nil if not set.
func (*PathPaymentStrictSend) Validate ¶
func (pp *PathPaymentStrictSend) Validate() error
Validate for PathPaymentStrictSend validates the required struct fields. It returns an error if any of the fields are invalid. Otherwise, it returns nil.
type Payment ¶
Payment represents the Stellar payment operation. See https://www.stellar.org/developers/guides/concepts/list-of-operations.html
Example ¶
kp, _ := keypair.Parse("SBPQUZ6G4FZNWFHKUWC5BEYWF6R52E3SEP7R3GWYSM2XTKGF5LNTWW4R") client := horizonclient.DefaultTestNetClient ar := horizonclient.AccountRequest{AccountID: kp.Address()} sourceAccount, err := client.AccountDetail(ar) check(err) op := Payment{ Destination: "GCCOBXW2XQNUSL467IEILE6MMCNRR66SSVL4YQADUNYYNUVREF3FIV2Z", Amount: "10", Asset: NativeAsset{}, } tx, err := NewTransaction( TransactionParams{ SourceAccount: &sourceAccount, IncrementSequenceNum: true, Operations: []Operation{&op}, BaseFee: MinBaseFee, Timebounds: NewInfiniteTimeout(), // Use a real timeout in production! }, ) check(err) tx, err = tx.Sign(network.TestNetworkPassphrase, kp.(*keypair.Full)) check(err) txe, err := tx.Base64() check(err) fmt.Println(txe)
Output: AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAABAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAACE4N7avBtJL576CIWTzGCbGPvSlVfMQAOjcYbSsSF2VAAAAAAAAAAABfXhAAAAAAAAAAAB6i5yxQAAAEB2/C066OEFac3Bszk6FtvKd+NKOeCl+f8caHQATPos8HkJW1Sm/WyEkVDrvrDX4udMHl3gHhlS/qE0EuWEeJYC
Example (SetBaseFee) ¶
kp, _ := keypair.Parse("SBPQUZ6G4FZNWFHKUWC5BEYWF6R52E3SEP7R3GWYSM2XTKGF5LNTWW4R") client := horizonclient.DefaultTestNetClient ar := horizonclient.AccountRequest{AccountID: kp.Address()} sourceAccount, err := client.AccountDetail(ar) check(err) op1 := Payment{ Destination: "GCCOBXW2XQNUSL467IEILE6MMCNRR66SSVL4YQADUNYYNUVREF3FIV2Z", Amount: "10", Asset: NativeAsset{}, } op2 := Payment{ Destination: "GCCOBXW2XQNUSL467IEILE6MMCNRR66SSVL4YQADUNYYNUVREF3FIV2Z", Amount: "100", Asset: NativeAsset{}, } // get fees from network feeStats, err := client.FeeStats() check(err) tx, err := NewTransaction( TransactionParams{ SourceAccount: &sourceAccount, IncrementSequenceNum: true, Operations: []Operation{&op1, &op2}, BaseFee: feeStats.MaxFee.P50, Timebounds: NewInfiniteTimeout(), // Use a real timeout in production! }, ) check(err) tx, err = tx.Sign(network.TestNetworkPassphrase, kp.(*keypair.Full)) check(err) txe, err := tx.Base64() check(err) fmt.Println(txe)
Output: AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAABLAADKI/AAAABAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAQAAAACE4N7avBtJL576CIWTzGCbGPvSlVfMQAOjcYbSsSF2VAAAAAAAAAAABfXhAAAAAAAAAAABAAAAAITg3tq8G0kvnvoIhZPMYJsY+9KVV8xAA6NxhtKxIXZUAAAAAAAAAAA7msoAAAAAAAAAAAHqLnLFAAAAQMmOXP+k93ENYtu7evNTu2h63UkNrQnF6ci49Oh1XufQ3rhzS4Dd1+6AXqgWa4FbcvlTVRjxCurkflI4Rov2xgQ=
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 nil if not set.
type RevokeSponsorship ¶
type RevokeSponsorship struct { SourceAccount Account SponsorshipType RevokeSponsorshipType // Account ID (strkey) Account *string TrustLine *TrustLineID Offer *OfferID Data *DataID // Claimable Balance ID ClaimableBalance *string Signer *SignerID }
RevokeSponsorship is a union type representing a RevokeSponsorship Operation. SponsorshipType stablishes which sponsorship is being revoked. The other fields should be ignored.
Example ¶
test := InitSponsorshipTestConfig() revokeOps := []Operation{ &RevokeSponsorship{ SponsorshipType: RevokeSponsorshipTypeTrustLine, Account: &test.Aaccount.AccountID, TrustLine: &TrustLineID{ Account: test.A.Address(), Asset: test.Assets[1], }, }, &RevokeSponsorship{ SponsorshipType: RevokeSponsorshipTypeTrustLine, Account: &test.Aaccount.AccountID, TrustLine: &TrustLineID{ Account: test.A.Address(), Asset: test.Assets[2], }, }, } // With revocation, only the new sponsor needs to sign. txb64, err := newSignedTransaction( TransactionParams{ SourceAccount: &test.S2account, Operations: revokeOps, Timebounds: NewInfiniteTimeout(), BaseFee: MinBaseFee, IncrementSequenceNum: true, }, network.TestNetworkPassphrase, test.S2, ) check(err) fmt.Println(txb64)
Output: AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAMgAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAEgAAAAAAAAABAAAAALQVLw52HjIVKlqx4rWxgwxV1OlUImbKUYmkx5i70s4oAAAAAUVGR0gAAAAAfhHLNNY19eGrAtSgLD3VpaRm2AjNjxIBWQg9zS4VWZgAAAAAAAAAEgAAAAAAAAABAAAAALQVLw52HjIVKlqx4rWxgwxV1OlUImbKUYmkx5i70s4oAAAAAUlKS0wAAAAA4Nxt4XJcrGZRYrUvrOc1sooiQ+QdEk1suS1wo+oucsUAAAAAAAAAAeoucsUAAABA9YO+xRc5Vb8ueP1U8go7ka+u/gZJd2z075c2pdFxYb+4AvQUQGvg+N4wvtNll43lPwXq5XAz74BfP99wugplDQ==
func (*RevokeSponsorship) GetSourceAccount ¶
func (r *RevokeSponsorship) GetSourceAccount() Account
func (*RevokeSponsorship) Validate ¶
func (r *RevokeSponsorship) Validate() error
type RevokeSponsorshipType ¶
type RevokeSponsorshipType int
const ( RevokeSponsorshipTypeAccount RevokeSponsorshipType = iota + 1 RevokeSponsorshipTypeTrustLine RevokeSponsorshipTypeOffer RevokeSponsorshipTypeData RevokeSponsorshipTypeClaimableBalance RevokeSponsorshipTypeSigner )
type SetOptions ¶
type SetOptions struct { InflationDestination *string SetFlags []AccountFlag ClearFlags []AccountFlag MasterWeight *Threshold LowThreshold *Threshold MediumThreshold *Threshold HighThreshold *Threshold HomeDomain *string Signer *Signer SourceAccount Account // contains filtered or unexported fields }
SetOptions represents the Stellar set options operation. See https://www.stellar.org/developers/guides/concepts/list-of-operations.html
Example ¶
kp, _ := keypair.Parse("SBPQUZ6G4FZNWFHKUWC5BEYWF6R52E3SEP7R3GWYSM2XTKGF5LNTWW4R") client := horizonclient.DefaultTestNetClient ar := horizonclient.AccountRequest{AccountID: kp.Address()} sourceAccount, err := client.AccountDetail(ar) check(err) op := SetOptions{ InflationDestination: NewInflationDestination("GCCOBXW2XQNUSL467IEILE6MMCNRR66SSVL4YQADUNYYNUVREF3FIV2Z"), ClearFlags: []AccountFlag{AuthRevocable}, SetFlags: []AccountFlag{AuthRequired, AuthImmutable}, MasterWeight: NewThreshold(10), LowThreshold: NewThreshold(1), MediumThreshold: NewThreshold(2), HighThreshold: NewThreshold(2), HomeDomain: NewHomeDomain("LovelyLumensLookLuminous.com"), Signer: &Signer{Address: "GCCOBXW2XQNUSL467IEILE6MMCNRR66SSVL4YQADUNYYNUVREF3FIV2Z", Weight: Threshold(4)}, } tx, err := NewTransaction( TransactionParams{ SourceAccount: &sourceAccount, IncrementSequenceNum: true, Operations: []Operation{&op}, BaseFee: MinBaseFee, Timebounds: NewInfiniteTimeout(), // Use a real timeout in production! }, ) check(err) tx, err = tx.Sign(network.TestNetworkPassphrase, kp.(*keypair.Full)) check(err) txe, err := tx.Base64() check(err) fmt.Println(txe)
Output: AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAABAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABQAAAAEAAAAAhODe2rwbSS+e+giFk8xgmxj70pVXzEADo3GG0rEhdlQAAAABAAAAAgAAAAEAAAAFAAAAAQAAAAoAAAABAAAAAQAAAAEAAAACAAAAAQAAAAIAAAABAAAAHExvdmVseUx1bWVuc0xvb2tMdW1pbm91cy5jb20AAAABAAAAAITg3tq8G0kvnvoIhZPMYJsY+9KVV8xAA6NxhtKxIXZUAAAABAAAAAAAAAAB6i5yxQAAAEBxncRuLogeNQ8sG9TojUMB6QmKDWYmhF00Wz43UX90pAQnSNcJAQxur0RA7Fn6LjJLObqyjcdIc4P2DC02u08G
func (*SetOptions) BuildXDR ¶
func (so *SetOptions) BuildXDR() (xdr.Operation, error)
BuildXDR for SetOptions returns a fully configured XDR Operation.
func (*SetOptions) FromXDR ¶
func (so *SetOptions) FromXDR(xdrOp xdr.Operation) error
FromXDR for SetOptions initialises the txnbuild struct from the corresponding xdr Operation.
func (*SetOptions) GetSourceAccount ¶
func (so *SetOptions) GetSourceAccount() Account
GetSourceAccount returns the source account of the operation, or nil if not set.
func (*SetOptions) Validate ¶
func (so *SetOptions) Validate() error
Validate for SetOptions validates the required struct fields. It returns an error if any of the fields are invalid. Otherwise, it returns nil.
type Signer ¶
Signer represents the Signer in a SetOptions operation. If the signer already exists, it is updated. If the weight is 0, the signer is deleted.
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 Threshold ¶
type Threshold uint8
Threshold is the datatype for MasterWeight, Signer.Weight, and Thresholds. Each is a number between 0-255 inclusive.
func NewThreshold ¶
NewThreshold is syntactic sugar that makes instantiating SetOptions more convenient.
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 specifiy the Timebound you require.
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
Transaction represents a Stellar transaction. See https://www.stellar.org/developers/guides/concepts/transactions.html 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 BuildChallengeTx ¶
func BuildChallengeTx(serverSignerSecret, clientAccountID, homeDomain, network string, timebound time.Duration) (*Transaction, error)
BuildChallengeTx is a factory method that creates a valid SEP 10 challenge, for use in web authentication. "timebound" is the time duration the transaction should be valid for, and must be greater than 1s (300s is recommended). More details on SEP 10: https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0010.md
Example ¶
// Generate random nonce serverSignerSeed := "SBZVMB74Z76QZ3ZOY7UTDFYKMEGKW5XFJEB6PFKBF4UYSSWHG4EDH7PY" clientAccountID := "GDQNY3PBOJOKYZSRMK2S7LHHGWZIUISD4QORETLMXEWXBI7KFZZMKTL3" anchorName := "SDF" timebound := time.Duration(5 * time.Minute) tx, err := BuildChallengeTx(serverSignerSeed, clientAccountID, anchorName, network.TestNetworkPassphrase, timebound) check(err) txeBase64, err := tx.Base64() check(err) ok, err := checkChallengeTx(txeBase64, anchorName) check(err) fmt.Println(ok)
Output: true
func NewTransaction ¶
func NewTransaction(params TransactionParams) (*Transaction, error)
NewTransaction returns a new Transaction instance
func ReadChallengeTx ¶
func ReadChallengeTx(challengeTx, serverAccountID, network string, homeDomains []string) (tx *Transaction, clientAccountID string, matchedHomeDomain string, err error)
ReadChallengeTx reads a SEP 10 challenge transaction and returns the decoded transaction and client account ID contained within.
Before calling this function, retrieve the SIGNING_KEY included in the TOML file hosted on the service's homeDomain and ensure it matches the serverAccountID you intend to pass.
This function verifies the serverAccountID signed the challenge. If the serverAccountID also matches the SIGNING_KEY included in the TOML file hosted the service's homeDomain passed, malicious web services will not be able to use the challenge transaction POSTed back to the authentication endpoint.
The challenge's first Manage Data operation is expected to contain the homeDomain parameter passed to the function.
It does not verify that the transaction has been signed by the client or that any signatures other than the servers on the transaction are valid. Use one of the following functions to completely verify the transaction: - VerifyChallengeTxThreshold - VerifyChallengeTxSigners
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) 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) ClaimableBalanceID ¶
func (t *Transaction) ClaimableBalanceID(operationIndex int) (string, error)
ClaimableBalanceID returns the claimable balance ID for the operation at the given index within the transaction. given index (which should be a `CreateClaimableBalance` operation).
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) 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) 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://www.stellar.org/developers/guides/concepts/multi-sig.html#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) ToXDR ¶
func (t *Transaction) ToXDR() xdr.TransactionEnvelope
ToXDR is like TxEnvelope except that the transaction envelope returned by ToXDR should not be modified because any changes applied to the transaction envelope may affect the internals of the Transaction instance.
func (*Transaction) TxEnvelope ¶
func (t *Transaction) TxEnvelope() (xdr.TransactionEnvelope, error)
TxEnvelope returns the a xdr.TransactionEnvelope instance which is equivalent to this transaction.
type TransactionParams ¶
type TransactionParams struct { SourceAccount Account IncrementSequenceNum bool Operations []Operation BaseFee int64 Memo Memo Timebounds Timebounds }
TransactionParams is a container for parameters which are used to construct new Transaction instances
type TrustLineID ¶
type ValidationError ¶
type ValidationError struct { Field string // Field is the struct field on which the validation error occured. 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.
Source Files ¶
- account_merge.go
- allow_trust.go
- asset.go
- begin_sponsoring_future_reserves.go
- bump_sequence.go
- change_trust.go
- claim_claimable_balance.go
- create_account.go
- create_claimable_balance.go
- create_passive_offer.go
- end_sponsoring_future_reserves.go
- helpers.go
- inflation.go
- manage_buy_offer.go
- manage_data.go
- manage_offer.go
- memo.go
- operation.go
- path_payment.go
- path_payment_strict_send.go
- payment.go
- price.go
- revoke_sponsorship.go
- set_options.go
- signer_summary.go
- simple_account.go
- timebounds.go
- transaction.go
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
demo
Demo is an interactive demonstration of the Go SDK using the Stellar TestNet.
|
Demo is an interactive demonstration of the Go SDK using the Stellar TestNet. |
demo/operations
Package demo is an interactive demonstration of the Go SDK using the Stellar TestNet.
|
Package demo is an interactive demonstration of the Go SDK using the Stellar TestNet. |
Package examplehorizonclient provides a dummy client for use with the GoDoc examples.
|
Package examplehorizonclient provides a dummy client for use with the GoDoc examples. |