txnbuild

package
v0.0.0-...-821bc58 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

README

txnbuild

txnbuild is a Stellar SDK, implemented in Go. It provides a reference implementation of the complete set of operations that compose transactions for the Stellar distributed ledger.

This project is maintained by the Stellar Development Foundation.

  import (
	"log"
	
	"github.com/stellar/go/clients/horizonclient"
	"github.com/stellar/go/keypair"
	"github.com/stellar/go/network"
	"github.com/stellar/go/txnbuild"
	)

	// Make a keypair for a known account from a secret seed
	kp, _ := keypair.Parse("SBPQUZ6G4FZNWFHKUWC5BEYWF6R52E3SEP7R3GWYSM2XTKGF5LNTWW4R")

	// Get the current state of the account from the network
	client := horizonclient.DefaultTestNetClient
	ar := horizonclient.AccountRequest{AccountID: kp.Address()}
	sourceAccount, err := client.AccountDetail(ar)
  	if err != nil {
    		log.Println(err)
  	}

	// Build an operation to create and fund a new account
	op := txnbuild.CreateAccount{
		Destination: "GCCOBXW2XQNUSL467IEILE6MMCNRR66SSVL4YQADUNYYNUVREF3FIV2Z",
		Amount:      "10",
	}

	// Construct the transaction that holds the operations to execute on the network
	tx := txnbuild.Transaction{
		SourceAccount: &sourceAccount,
		Operations:    []txnbuild.Operation{&op},
		Timebounds:    txnbuild.NewTimebounds(0, 300),
		Network:       network.TestNetworkPassphrase,
	}

	// Serialise, sign and encode the transaction
	txe, err := tx.BuildSignEncode(kp.(*keypair.Full))
  	if err != nil {
    		log.Println(err)
  	}

	// Send the transaction to the network
	resp, err := client.SubmitTransactionXDR(txeBase64)
  	if err != nil {
    		log.Println(err)
  	}

Getting Started

This library is aimed at developers building Go applications on top of the Stellar network. 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. Together, these two libraries provide a complete Stellar SDK.

An easy-to-follow demonstration that exercises this SDK on the TestNet with actual accounts is also included! See the Demo section below.

Prerequisites
  • Go 1.10 or greater
Installing
  • Download the Stellar Go monorepo: git clone git@github.com:stellar/go.git
  • Enter the source directory: cd $GOPATH/src/github.com/stellar/go
  • Download external dependencies: dep ensure -v

Running the tests

Run the unit tests from the package directory: go test

Demo

To see the SDK in action, build and run the demo:

  • Enter the demo directory: cd $GOPATH/src/github.com/stellar/go/txnbuild/cmd/demo
  • Build the demo: go build
  • Run the demo: ./demo init

Contributing

Please read Code of Conduct to understand this project's communication rules.

To submit improvements and fixes to this library, please see CONTRIBUTING.

License

This project is licensed under the Apache License - see the LICENSE file for details.

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://www.stellar.org/developers/go/reference/index.html.

Index

Examples

Constants

AuthImmutable is a flag that if set prevents any authorization flags from being set, and prevents the account from ever being merged (deleted).

AuthRequired is a flag that requires the issuing account to give other accounts permission before they can hold the issuing account's credit.

AuthRevocable is a flag that allows the issuing account to revoke its credit held by other accounts.

View Source
const MemoTextMaxLength = 28

MemoTextMaxLength is the maximum number of bytes allowed for a text memo.

View Source
const TimeoutInfinite = int64(0)

TimeoutInfinite allows an indefinite upper bound to be set for Transaction.MaxTime. This is usually not what you want.

Variables

View Source
var MaxTrustlineLimit = amount.StringFromInt64(math.MaxInt64)

MaxTrustlineLimit represents the maximum value that can be set as a trustline limit.

Functions

func NewHomeDomain

func NewHomeDomain(hd string) *string

NewHomeDomain is syntactic sugar that makes instantiating SetOptions more convenient.

func NewInflationDestination

func NewInflationDestination(ai string) *string

NewInflationDestination is syntactic sugar that makes instantiating SetOptions more convenient.

func SetOpSourceAccount

func SetOpSourceAccount(op *xdr.Operation, sourceAccount Account)

SetOpSourceAccount sets the source account ID on an Operation.

Types

type Account

type Account interface {
	GetAccountID() string
	IncrementSequenceNumber() (xdr.SequenceNumber, 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

type AccountMerge struct {
	Destination   string
	SourceAccount Account
}

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 := Transaction{
	SourceAccount: &sourceAccount,
	Operations:    []Operation{&op},
	Timebounds:    NewInfiniteTimeout(), // Use a real timeout in production!
	Network:       network.TestNetworkPassphrase,
}

txe, err := tx.BuildSignEncode(kp.(*keypair.Full))
check(err)
fmt.Println(txe)
Output:

AAAAAODcbeFyXKxmUWK1L6znNbKKIkPkHRJNbLktcKPqLnLFAAAAZAAMoj8AAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAIAAAAAITg3tq8G0kvnvoIhZPMYJsY+9KVV8xAA6NxhtKxIXZUAAAAAAAAAAHqLnLFAAAAQC87HdYfOZpOx/isr7JEOy9ef3GH51ToKSkC6b4UJdDktlCqHFCD0cSttJ/F5MUx2ScSkwpeAlEVR8B62X6N/g4=

func (*AccountMerge) BuildXDR

func (am *AccountMerge) BuildXDR() (xdr.Operation, error)

BuildXDR for AccountMerge returns a fully configured XDR Operation.

type AllowTrust

type AllowTrust struct {
	Trustor       string
	Type          Asset
	Authorize     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 := Transaction{
	SourceAccount: &sourceAccount,
	Operations:    []Operation{&op},
	Timebounds:    NewInfiniteTimeout(), // Use a real timeout in production!
	Network:       network.TestNetworkPassphrase,
}

txe, err := tx.BuildSignEncode(kp.(*keypair.Full))
check(err)
fmt.Println(txe)
Output:

AAAAAODcbeFyXKxmUWK1L6znNbKKIkPkHRJNbLktcKPqLnLFAAAAZAAMoj8AAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAHAAAAAITg3tq8G0kvnvoIhZPMYJsY+9KVV8xAA6NxhtKxIXZUAAAAAUFCQ0QAAAABAAAAAAAAAAHqLnLFAAAAQBjcydaIxwvXxLFEhNK4jm1lJeYSjRDfxRmDSOIkZTZTqRKewI1NMmIYAIZCUis98Axi32ShqutfXXDscsGixA0=

func (*AllowTrust) BuildXDR

func (at *AllowTrust) BuildXDR() (xdr.Operation, error)

BuildXDR for AllowTrust returns a fully configured XDR Operation.

type Asset

type Asset interface {
	GetType() (AssetType, error)
	IsNative() bool
	GetCode() string
	GetIssuer() string
	ToXDR() (xdr.Asset, error)
}

Asset represents a Stellar asset.

type AssetType

type AssetType xdr.AssetType

AssetType represents the type of a Stellar asset.

AssetTypeNative, AssetTypeCreditAlphanum4, AssetTypeCreditAlphanum12 enumerate the different types of asset on the Stellar network.

type BumpSequence

type BumpSequence struct {
	BumpTo        int64
	SourceAccount Account
}

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 := Transaction{
	SourceAccount: &sourceAccount,
	Operations:    []Operation{&op},
	Timebounds:    NewInfiniteTimeout(), // Use a real timeout in production!
	Network:       network.TestNetworkPassphrase,
}

txe, err := tx.BuildSignEncode(kp.(*keypair.Full))
check(err)
fmt.Println(txe)
Output:

AAAAAODcbeFyXKxmUWK1L6znNbKKIkPkHRJNbLktcKPqLnLFAAAAZAAMoj8AAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAALACIgugAAAGwAAAAAAAAAAeoucsUAAABAQi/I4d0+fzZyQpchIYXqxHhhTmjHvfmK8qsL/BLjrXmPUADja9tdIupKEkDn/v8NfnpRS/4u3u+Vy70zuOxHDg==

func (*BumpSequence) BuildXDR

func (bs *BumpSequence) BuildXDR() (xdr.Operation, error)

BuildXDR for BumpSequence returns a fully configured XDR Operation.

type ChangeTrust

type ChangeTrust struct {
	Line          Asset
	Limit         string
	SourceAccount Account
}

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 := Transaction{
	SourceAccount: &sourceAccount,
	Operations:    []Operation{&op},
	Timebounds:    NewInfiniteTimeout(), // Use a real timeout in production!
	Network:       network.TestNetworkPassphrase,
}

txe, err := tx.BuildSignEncode(kp.(*keypair.Full))
check(err)
fmt.Println(txe)
Output:

AAAAAODcbeFyXKxmUWK1L6znNbKKIkPkHRJNbLktcKPqLnLFAAAAZAAMoj8AAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAGAAAAAUFCQ0QAAAAAhODe2rwbSS+e+giFk8xgmxj70pVXzEADo3GG0rEhdlQAAAAABfXhAAAAAAAAAAAB6i5yxQAAAECqpS4iUUyuUSVicZIseVoj8DjWgYDet21zUQeHNr1teTflnCUS+awFQ5lNqxl+AHPB34JzN6RYoEISoEIfNpIH
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 := Transaction{
	SourceAccount: &sourceAccount,
	Operations:    []Operation{&op},
	Timebounds:    NewInfiniteTimeout(), // Use a real timeout in production!
	Network:       network.TestNetworkPassphrase,
}

txe, err := tx.BuildSignEncode(kp.(*keypair.Full))
check(err)
fmt.Println(txe)
Output:

AAAAAODcbeFyXKxmUWK1L6znNbKKIkPkHRJNbLktcKPqLnLFAAAAZAAMoj8AAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAGAAAAAUFCQ0QAAAAAhODe2rwbSS+e+giFk8xgmxj70pVXzEADo3GG0rEhdlQAAAAAAAAAAAAAAAAAAAAB6i5yxQAAAEAouZRZwuPF5j68byMRcw2mtToS6nFsxGJcZjO4oGm2dWVsVS1MGqFhr+JvIJlMRUKKdPxtZAoO9kjSbpUspUcC

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.

type CreateAccount

type CreateAccount struct {
	Destination   string
	Amount        string
	SourceAccount Account
}

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 := Transaction{
	SourceAccount: &sourceAccount,
	Operations:    []Operation{&op},
	Timebounds:    NewInfiniteTimeout(), // Use a real timeout in production!
	Network:       network.TestNetworkPassphrase,
}

txe, err := tx.BuildSignEncode(kp.(*keypair.Full))
check(err)
fmt.Println(txe)
Output:

AAAAAODcbeFyXKxmUWK1L6znNbKKIkPkHRJNbLktcKPqLnLFAAAAZAAMoj8AAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAITg3tq8G0kvnvoIhZPMYJsY+9KVV8xAA6NxhtKxIXZUAAAAAAX14QAAAAAAAAAAAeoucsUAAABAqyuXG3pGL9a4MZwrX5OTWF1gd094rsowh2zXSZzDPDoGlAVljE/yjo7p6MkUY7TpMAa3Y+iXC5ael6JVD0pyDQ==

func (*CreateAccount) BuildXDR

func (ca *CreateAccount) BuildXDR() (xdr.Operation, error)

BuildXDR for CreateAccount returns a fully configured XDR Operation.

type CreatePassiveSellOffer

type CreatePassiveSellOffer struct {
	Selling       Asset
	Buying        Asset
	Amount        string
	Price         string
	SourceAccount Account
}

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 := Transaction{
	SourceAccount: &sourceAccount,
	Operations:    []Operation{&op},
	Timebounds:    NewInfiniteTimeout(), // Use a real timeout in production!
	Network:       network.TestNetworkPassphrase,
}

txe, err := tx.BuildSignEncode(kp.(*keypair.Full))
check(err)
fmt.Println(txe)
Output:

AAAAAODcbeFyXKxmUWK1L6znNbKKIkPkHRJNbLktcKPqLnLFAAAAZAAMoj8AAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAEAAAAAAAAAAFBQkNEAAAAACXK8doPx27P6IReQlRRuweSSUiUfjqgyswxiu3Sh2R+AAAAAAX14QAAAAABAAAAAQAAAAAAAAAB6i5yxQAAAEAThdst0NXPUzAL0GzzieSoryHIeF5VtjOc1KIA/SGI/xq69woAydjPccm/MzwfSr8rkw++AFp6Edn+1C1o9IYG

func (*CreatePassiveSellOffer) BuildXDR

func (cpo *CreatePassiveSellOffer) BuildXDR() (xdr.Operation, error)

BuildXDR for CreatePassiveSellOffer returns a fully configured XDR Operation.

type CreditAsset

type CreditAsset struct {
	Code   string
	Issuer string
}

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) ToXDR

func (ca CreditAsset) ToXDR() (xdr.Asset, error)

ToXDR for CreditAsset produces a corresponding XDR asset.

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 := Transaction{
	SourceAccount: &sourceAccount,
	Operations:    []Operation{&op},
	Timebounds:    NewInfiniteTimeout(), // Use a real timeout in production!
	Network:       network.TestNetworkPassphrase,
}

txe, err := tx.BuildSignEncode(kp.(*keypair.Full))
check(err)
fmt.Println(txe)
Output:

AAAAAODcbeFyXKxmUWK1L6znNbKKIkPkHRJNbLktcKPqLnLFAAAAZAAMoj8AAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAJAAAAAAAAAAHqLnLFAAAAQP3NHWXvzKIHB3+jjhHITdc/tBPntWYj3SoTjpON+dxjKqU5ohFamSHeqi5ONXkhE9Uajr5sVZXjQfUcTTzsWAA=

func (*Inflation) BuildXDR

func (inf *Inflation) BuildXDR() (xdr.Operation, error)

BuildXDR for Inflation returns a fully configured XDR Operation.

type ManageBuyOffer

type ManageBuyOffer struct {
	Selling       Asset
	Buying        Asset
	Amount        string
	Price         string
	OfferID       int64
	SourceAccount Account
}

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 := Transaction{
	SourceAccount: &sourceAccount,
	Operations:    []Operation{&buyOffer},
	Timebounds:    NewInfiniteTimeout(),
	Network:       network.TestNetworkPassphrase,
}

txe, err := tx.BuildSignEncode(kp.(*keypair.Full))
check(err)
fmt.Println(txe)
Output:

AAAAAH4RyzTWNfXhqwLUoCw91aWkZtgIzY8SAVkIPc0uFVmYAAAAZAAMoj8AAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAMAAAAAAAAAAFBQkNEAAAAAODcbeFyXKxmUWK1L6znNbKKIkPkHRJNbLktcKPqLnLFAAAAADuaygAAAAABAAAAZAAAAAAAAAAAAAAAAAAAAAEuFVmYAAAAQPh8h1TrzDpcgzB/VE8V0X2pFGV8/JyuYrx0I5bRfBJuLJr0l8yL1isP1wZjvMdX7fNiktwSLuUuj749nWA6wAo=

func (*ManageBuyOffer) BuildXDR

func (mo *ManageBuyOffer) BuildXDR() (xdr.Operation, error)

BuildXDR for ManageBuyOffer returns a fully configured XDR Operation.

type ManageData

type ManageData struct {
	Name          string
	Value         []byte
	SourceAccount Account
}

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 := Transaction{
	SourceAccount: &sourceAccount,
	Operations:    []Operation{&op},
	Timebounds:    NewInfiniteTimeout(), // Use a real timeout in production!
	Network:       network.TestNetworkPassphrase,
}

txe, err := tx.BuildSignEncode(kp.(*keypair.Full))
check(err)
fmt.Println(txe)
Output:

AAAAAODcbeFyXKxmUWK1L6znNbKKIkPkHRJNbLktcKPqLnLFAAAAZAAMoj8AAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAKAAAAEEZydWl0IHByZWZlcmVuY2UAAAABAAAABUFwcGxlAAAAAAAAAAAAAAHqLnLFAAAAQO1ELJBEoqBDyIsS7uSJwe1LOimV/E+09MyF1G/+yrxSggFVPEjD5LXcm/6POze3IsMuIYJU1et5Q2Vt9f73zQo=
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 := Transaction{
	SourceAccount: &sourceAccount,
	Operations:    []Operation{&op},
	Timebounds:    NewInfiniteTimeout(), // Use a real timeout in production!
	Network:       network.TestNetworkPassphrase,
}

txe, err := tx.BuildSignEncode(kp.(*keypair.Full))
check(err)
fmt.Println(txe)
Output:

AAAAAODcbeFyXKxmUWK1L6znNbKKIkPkHRJNbLktcKPqLnLFAAAAZAAMoj8AAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAKAAAAEEZydWl0IHByZWZlcmVuY2UAAAAAAAAAAAAAAAHqLnLFAAAAQMWkjW+mHMbwOfLhpUMDu3I6U/nv132RY7RT++arqlZOs2hx3r7FOJTvndbnSSwSxwDp/VY3BSxB/4MLCZl+ogA=

func (*ManageData) BuildXDR

func (md *ManageData) BuildXDR() (xdr.Operation, error)

BuildXDR for ManageData returns a fully configured XDR Operation.

type ManageSellOffer

type ManageSellOffer struct {
	Selling       Asset
	Buying        Asset
	Amount        string
	Price         string
	OfferID       int64
	SourceAccount Account
}

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 := Transaction{
	SourceAccount: &sourceAccount,
	Operations:    []Operation{&op},
	Timebounds:    NewInfiniteTimeout(), // Use a real timeout in production!
	Network:       network.TestNetworkPassphrase,
}

txe, err := tx.BuildSignEncode(kp.(*keypair.Full))
check(err)
fmt.Println(txe)
Output:

AAAAAODcbeFyXKxmUWK1L6znNbKKIkPkHRJNbLktcKPqLnLFAAAAZAAMoj8AAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAADAAAAAAAAAAFBQkNEAAAAACXK8doPx27P6IReQlRRuweSSUiUfjqgyswxiu3Sh2R+AAAAADuaygAAAAABAAAAZAAAAAAAAAAAAAAAAAAAAAHqLnLFAAAAQG1+s35VQTuILAGTT6uaDT9RrgMi0xYTLqdoZbGgMGLiSwIglJk/OS/v1DrmshoXIhwL/O7Ilychy/vcA/4dAQo=
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 := Transaction{
	SourceAccount: &sourceAccount,
	Operations:    []Operation{&op},
	Timebounds:    NewInfiniteTimeout(), // Use a real timeout in production!
	Network:       network.TestNetworkPassphrase,
}

txe, err := tx.BuildSignEncode(kp.(*keypair.Full))
check(err)
fmt.Println(txe)
Output:

AAAAAODcbeFyXKxmUWK1L6znNbKKIkPkHRJNbLktcKPqLnLFAAAAZAAMoj8AAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAADAAAAAAAAAAFGQUtFAAAAAEEHgGTElYZi82AkGiJdSja2OBaU2aEcwwp3AY3tFJ2xAAAAAAAAAAAAAAABAAAAAQAAAAAALJSWAAAAAAAAAAHqLnLFAAAAQGcT6ggtq6q3qbx+PsMgE1b9cGYonfhIu8d3E/Ti9vbpojyr2L/an3+kkydY946gjDR/qOt5HfTqo8kWGMy2XgY=
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 := Transaction{
	SourceAccount: &sourceAccount,
	Operations:    []Operation{&op},
	Timebounds:    NewInfiniteTimeout(), // Use a real timeout in production!
	Network:       network.TestNetworkPassphrase,
}

txe, err := tx.BuildSignEncode(kp.(*keypair.Full))
check(err)
fmt.Println(txe)
Output:

AAAAAODcbeFyXKxmUWK1L6znNbKKIkPkHRJNbLktcKPqLnLFAAAAZAAMoj8AAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAADAAAAAAAAAAFBQkNEAAAAACXK8doPx27P6IReQlRRuweSSUiUfjqgyswxiu3Sh2R+AAAAAB3NZQAAAAABAAAAMgAAAAAAJhxcAAAAAAAAAAHqLnLFAAAAQKY77jK6QC4tG1HghFY9W2jJnYsl5qKk+55z78zUkYOhMU9QsOXeSC6A/BXeavSO8w0CsF1HxLc1TDfWC1PlNw4=

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.

type Memo

type Memo interface {
	ToXDR() (xdr.Memo, error)
}

Memo represents the superset of all memo types.

type MemoHash

type MemoHash [32]byte

MemoHash is a hash representing a reference to another transaction.

func (MemoHash) ToXDR

func (mh MemoHash) ToXDR() (xdr.Memo, error)

ToXDR for MemoHash returns an XDR object representation of a Memo of the same type.

type MemoID

type MemoID uint64

MemoID is an identifier representing the transaction originator.

func (MemoID) ToXDR

func (mid MemoID) ToXDR() (xdr.Memo, error)

ToXDR for MemoID returns an XDR object representation of a Memo of the same type.

type MemoReturn

type MemoReturn [32]byte

MemoReturn is a hash representing the hash of the transaction the sender is refunding.

func (MemoReturn) ToXDR

func (mr MemoReturn) ToXDR() (xdr.Memo, error)

ToXDR for MemoReturn returns an XDR object representation of a Memo of the same type.

type MemoText

type MemoText string

MemoText is used to send human messages of up to 28 bytes of ASCII/UTF-8.

func (MemoText) ToXDR

func (mt MemoText) ToXDR() (xdr.Memo, error)

ToXDR for MemoText returns an XDR object representation of a Memo of the same type.

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) ToXDR

func (na NativeAsset) ToXDR() (xdr.Asset, error)

ToXDR for NativeAsset produces a corresponding XDR asset.

type Operation

type Operation interface {
	BuildXDR() (xdr.Operation, error)
}

Operation represents the operation types of the Stellar network.

type PathPayment

type PathPayment struct {
	SendAsset     Asset
	SendMax       string
	Destination   string
	DestAsset     Asset
	DestAmount    string
	Path          []Asset
	SourceAccount Account
}

PathPayment represents the Stellar path payment 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 := PathPayment{
	SendAsset:   NativeAsset{},
	SendMax:     "10",
	Destination: kp.Address(),
	DestAsset:   NativeAsset{},
	DestAmount:  "1",
	Path:        []Asset{abcdAsset},
}

tx := Transaction{
	SourceAccount: &sourceAccount,
	Operations:    []Operation{&op},
	Timebounds:    NewInfiniteTimeout(), // Use a real timeout in production!
	Network:       network.TestNetworkPassphrase,
}

txe, err := tx.BuildSignEncode(kp.(*keypair.Full))
check(err)
fmt.Println(txe)
Output:

AAAAAH4RyzTWNfXhqwLUoCw91aWkZtgIzY8SAVkIPc0uFVmYAAAAZAAMoj8AAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAACAAAAAAAAAAAF9eEAAAAAAH4RyzTWNfXhqwLUoCw91aWkZtgIzY8SAVkIPc0uFVmYAAAAAAAAAAAAmJaAAAAAAQAAAAFBQkNEAAAAAODcbeFyXKxmUWK1L6znNbKKIkPkHRJNbLktcKPqLnLFAAAAAAAAAAEuFVmYAAAAQOGE+w2bvIp8JQIPIFXWk5kO77cNUOlPZwlItA5V68/qmZTbJWq8wqdZtjELkZtNcQQX4x8EToShbn5nitG3RA4=

func (*PathPayment) BuildXDR

func (pp *PathPayment) BuildXDR() (xdr.Operation, error)

BuildXDR for Payment returns a fully configured XDR Operation.

type Payment

type Payment struct {
	Destination   string
	Amount        string
	Asset         Asset
	SourceAccount Account
}

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 := Transaction{
	SourceAccount: &sourceAccount,
	Operations:    []Operation{&op},
	Timebounds:    NewInfiniteTimeout(), // Use a real timeout in production!
	Network:       network.TestNetworkPassphrase,
}

txe, err := tx.BuildSignEncode(kp.(*keypair.Full))
check(err)
fmt.Println(txe)
Output:

AAAAAODcbeFyXKxmUWK1L6znNbKKIkPkHRJNbLktcKPqLnLFAAAAZAAMoj8AAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAITg3tq8G0kvnvoIhZPMYJsY+9KVV8xAA6NxhtKxIXZUAAAAAAAAAAAF9eEAAAAAAAAAAAHqLnLFAAAAQHb8LTro4QVpzcGzOToW28p340o54KX5/xxodABM+izweQlbVKb9bISRUOu+sNfi50weXeAeGVL+oTQS5YR4lgI=

func (*Payment) BuildXDR

func (p *Payment) BuildXDR() (xdr.Operation, error)

BuildXDR for Payment returns a fully configured XDR Operation.

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 := Transaction{
	SourceAccount: &sourceAccount,
	Operations:    []Operation{&op},
	Timebounds:    NewInfiniteTimeout(), // Use a real timeout in production!
	Network:       network.TestNetworkPassphrase,
}

txe, err := tx.BuildSignEncode(kp.(*keypair.Full))
check(err)
fmt.Println(txe)
Output:

AAAAAODcbeFyXKxmUWK1L6znNbKKIkPkHRJNbLktcKPqLnLFAAAAZAAMoj8AAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAQAAAACE4N7avBtJL576CIWTzGCbGPvSlVfMQAOjcYbSsSF2VAAAAAEAAAACAAAAAQAAAAUAAAABAAAACgAAAAEAAAABAAAAAQAAAAIAAAABAAAAAgAAAAEAAAAcTG92ZWx5THVtZW5zTG9va0x1bWlub3VzLmNvbQAAAAEAAAAAhODe2rwbSS+e+giFk8xgmxj70pVXzEADo3GG0rEhdlQAAAAEAAAAAAAAAAHqLnLFAAAAQHGdxG4uiB41Dywb1OiNQwHpCYoNZiaEXTRbPjdRf3SkBCdI1wkBDG6vREDsWfouMks5urKNx0hzg/YMLTa7TwY=

func (*SetOptions) BuildXDR

func (so *SetOptions) BuildXDR() (xdr.Operation, error)

BuildXDR for SetOptions returns a fully configured XDR Operation.

type Signer

type Signer struct {
	Address string
	Weight  Threshold
}

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 SimpleAccount

type SimpleAccount struct {
	AccountID string
	Sequence  int64
}

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() (xdr.SequenceNumber, error)

GetSequenceNumber returns the sequence number of the account.

func (*SimpleAccount) IncrementSequenceNumber

func (sa *SimpleAccount) IncrementSequenceNumber() (xdr.SequenceNumber, 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

func NewThreshold(t Threshold) *Threshold

NewThreshold is syntactic sugar that makes instantiating SetOptions more convenient.

type Timebounds

type Timebounds struct {
	MinTime int64
	MaxTime int64
	// contains filtered or unexported fields
}

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 {
	SourceAccount Account
	Operations    []Operation
	BaseFee       uint32
	Memo          Memo
	Timebounds    Timebounds
	Network       string
	// contains filtered or unexported fields
}

Transaction represents a Stellar transaction. See https://www.stellar.org/developers/guides/concepts/transactions.html

func (*Transaction) Base64

func (tx *Transaction) Base64() (string, error)

Base64 returns the base 64 XDR representation of the Transaction.

func (*Transaction) Build

func (tx *Transaction) Build() error

Build for Transaction completely configures the Transaction. After calling Build, the Transaction is ready to be serialised or signed.

func (*Transaction) BuildSignEncode

func (tx *Transaction) BuildSignEncode(keypairs ...*keypair.Full) (string, error)

BuildSignEncode performs all the steps to produce a final transaction suitable for submitting to the network.

func (*Transaction) Hash

func (tx *Transaction) Hash() ([32]byte, error)

Hash provides a signable object representing the Transaction on the specified network.

func (*Transaction) MarshalBinary

func (tx *Transaction) MarshalBinary() ([]byte, error)

MarshalBinary returns the binary XDR representation of the Transaction.

func (*Transaction) SetDefaultFee

func (tx *Transaction) SetDefaultFee()

SetDefaultFee sets a sensible minimum default for the Transaction fee, if one has not already been set. It is a linear function of the number of Operations in the Transaction.

func (*Transaction) Sign

func (tx *Transaction) Sign(kps ...*keypair.Full) error

Sign for Transaction signs a previously built transaction. A signed transaction may be submitted to the network.

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.

Jump to

Keyboard shortcuts

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