Skip to content

horizonclient v3.0.0 & txnbuild v3.0.0

Compare
Choose a tag to compare
@tamirms tamirms released this 28 Apr 19:47
20797e3

txnbuild

Breaking changes

  • The Account interface has been extended to include GetSequenceNumber() (int64, error). Also, IncrementSequenceNumber() now returns an (int64, error) pair instead of a (xdr.SequenceNumber, error) pair.
  • Refactor workflow for creating and signing transactions. Previously, you could create a transaction envelope by populating a Transaction instance and calling the Build() function on the Transaction instance.

Transaction is now an opaque type which has accessor functions like SourceAccount() SimpleAccount, Memo() Memo, etc. The motivation behind this change is to make Transaction more immutable. Here is an example of how to use the new transaction type:

	kp := keypair.MustParse("SBPQUZ6G4FZNWFHKUWC5BEYWF6R52E3SEP7R3GWYSM2XTKGF5LNTWW4R")
	client := horizonclient.DefaultTestNetClient
	ar := horizonclient.AccountRequest{AccountID: kp.Address()}
	sourceAccount, err := client.AccountDetail(ar)
	check(err)

	op := txnbuild.Payment{
		Destination: "GCCOBXW2XQNUSL467IEILE6MMCNRR66SSVL4YQADUNYYNUVREF3FIV2Z",
		Amount:      "10",
		Asset:       NativeAsset{},
	}

	tx, err := txnbuild.NewTransaction(
		txnbuild.TransactionParams{
			SourceAccount:        &sourceAccount,
			// If IncrementSequenceNum is true, NewTransaction() will call `sourceAccount.IncrementSequenceNumber()`
			// to obtain the sequence number for the transaction.
			// If IncrementSequenceNum is false, NewTransaction() will call `sourceAccount.GetSequenceNumber()`
			// to obtain the sequence number for the transaction.
			IncrementSequenceNum: true,
			Operations:           []Operation{&op},
			BaseFee:              MinBaseFee,
			Timebounds:           NewInfiniteTimeout(),
		},
	)
	check(err)

	tx, err = tx.Sign(network.TestNetworkPassphrase, kp.(*keypair.Full))
  • TransactionFromXDR now has the following signature TransactionFromXDR(txeB64 string) (*GenericTransaction, error). A GenericTransaction is a container which can be unpacked into either a Transaction or a FeeBumpTransaction.
  • BuildChallengeTx now returns a Transaction instance instead of the base 64 string encoding of the SEP 10 challenge transaction.
  • VerifyChallengeTx has been removed. Use VerifyChallengeTxThreshold or VerifyChallengeTxSigners instead.

Add

  • Add NewFeeBumpTransaction(params FeeBumpTransactionParams) (*FeeBumpTransaction, error) function for creating fee bump transactions. Note that fee bump transactions will only be accepted by Stellar Core once Protocol 13 is enabled.

Updates

  • AllowTrust supports CAP0018 Fine-Grained Control of Authorization by exposing a AuthorizeToMaintainLiabilities boolean field.
  • ReadChallengeTx will reject any challenge transactions which are fee bump transactions.
  • ReadChallengeTx will reject any challenge transactions which contain a MuxedAccount with a memo ID.

Remove

  • Dropped support for Go 1.12.

horizonclient

Breaking changes

  • The type for the following fields in the Transaction struct have changed from int32 to int64:
    • FeeCharged
    • MaxFee
  • The TransactionSuccess Horizon response has been removed. Instead, all submit transaction functions return with a full Horizon Transaction response on success.
  • The GetSequenceNumber() and IncrementSequenceNumber() functions on the Account struct now return int64 values instead of xdr.SequenceNumber values.

Add

  • Add IsNotFoundError
  • Add client.SubmitFeeBumpTransaction and client.SubmitFeeBumpTransactionWithOptions for submitting fee bump transactions. Note that fee bump transactions will only be accepted by Stellar Core once Protocol 13 is enabled.

Updates

  • To support CAP0018 Fine-Grained Control of Authorization:
    • There is a new effect TrustlineAuthorizedToMaintainLiabilities which occurs when a trustline has been authorized to maintain liabilities.
    • The AuthorizeToMaintainLiabilities boolean field was added to the AllowTrust operation struct.
  • These fields were added to the Transaction struct to support fee bump transactions:
    • FeeAccount (the account which paid the transaction fee)
    • FeeBumpTransaction (only present in Protocol 13 fee bump transactions)
    • InnerTransaction (only present in Protocol 13 fee bump transactions).
  • Transaction has a new MemoBytes field which is populated when MemoType is equal to text. MemoBytes stores the base 64 encoding of the memo bytes set in the transaction envelope.
  • Fixed a bug where HorizonTimeOut has misleading units of time by:
    • Removed HorizonTimeOut (seconds)
    • Added HorizonTimeout (nanoseconds)