horizonclient v3.0.0 & txnbuild v3.0.0
txnbuild
Breaking changes
- The
Account
interface has been extended to includeGetSequenceNumber() (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 theBuild()
function on theTransaction
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 signatureTransactionFromXDR(txeB64 string) (*GenericTransaction, error)
. AGenericTransaction
is a container which can be unpacked into either aTransaction
or aFeeBumpTransaction
.BuildChallengeTx
now returns aTransaction
instance instead of the base 64 string encoding of the SEP 10 challenge transaction.VerifyChallengeTx
has been removed. UseVerifyChallengeTxThreshold
orVerifyChallengeTxSigners
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 aAuthorizeToMaintainLiabilities
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 fromint32
toint64
:FeeCharged
MaxFee
- The
TransactionSuccess
Horizon response has been removed. Instead, all submit transaction functions return with a full HorizonTransaction
response on success. - The
GetSequenceNumber()
andIncrementSequenceNumber()
functions on theAccount
struct now returnint64
values instead ofxdr.SequenceNumber
values.
Add
- Add
IsNotFoundError
- Add
client.SubmitFeeBumpTransaction
andclient.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 theAllowTrust
operation struct.
- There is a new effect
- 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 newMemoBytes
field which is populated whenMemoType
is equal totext
.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)