Skip to content

Commit

Permalink
fix: Transaction.ToBytes()
Browse files Browse the repository at this point in the history
  • Loading branch information
janaakhterov committed Nov 11, 2020
1 parent e83000b commit b285319
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,15 +327,20 @@ func (transaction *Transaction) String() string {
protobuf.MarshalTextString(transaction.body())
}

// MarshalBinary implements the encoding.BinaryMarshaler interface.
func (transaction *Transaction) MarshalBinary() ([]byte, error) {
return protobuf.Marshal(transaction.transactions[0])
}

func (transaction *Transaction) ToBytes() ([]byte, error) {
return transaction.MarshalBinary()
buf := protobuf.NewBuffer(make([]byte, 0))

for _, tx := range transaction.transactions {
err := buf.Marshal(tx)
if err != nil {
return buf.Bytes(), err
}
}

return buf.Bytes(), nil
}


// The protobuf stores the transaction body as raw bytes so we need to first
// decode what we have to inspect the Kind, TransactionID, and the NodeAccountID so we know how to
// properly execute it
Expand Down

0 comments on commit b285319

Please sign in to comment.