Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

txnbuild: Initialise transaction envelope in build #1376

Merged
merged 1 commit into from
Jun 20, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions txnbuild/transaction.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
/*
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.
*/
package txnbuild
Expand Down Expand Up @@ -125,6 +123,12 @@ func (tx *Transaction) Build() error {
// Set a default fee, if it hasn't been set yet
tx.SetDefaultFee()

// Initialise transaction envelope
if tx.xdrEnvelope == nil {
tx.xdrEnvelope = &xdr.TransactionEnvelope{}
tx.xdrEnvelope.Tx = tx.xdrTransaction
}

return nil
}

Expand All @@ -133,11 +137,6 @@ func (tx *Transaction) Build() error {
func (tx *Transaction) Sign(kps ...*keypair.Full) error {
// TODO: Only sign if Transaction has been previously built
// TODO: Validate network set before sign
// Initialise transaction envelope
if tx.xdrEnvelope == nil {
tx.xdrEnvelope = &xdr.TransactionEnvelope{}
tx.xdrEnvelope.Tx = tx.xdrTransaction
}

// Hash the transaction
hash, err := tx.Hash()
Expand Down