diff options
Diffstat (limited to 'data/transactions/transaction.go')
-rw-r--r-- | data/transactions/transaction.go | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/data/transactions/transaction.go b/data/transactions/transaction.go index 9a7d97899..d617160e8 100644 --- a/data/transactions/transaction.go +++ b/data/transactions/transaction.go @@ -17,6 +17,7 @@ package transactions import ( + "encoding/binary" "errors" "fmt" @@ -180,6 +181,19 @@ func (tx Transaction) ID() Txid { return Txid(crypto.Hash(enc)) } +// InnerID returns something akin to Txid, but folds in the parent Txid and the +// index of the inner call. +func (tx Transaction) InnerID(parent Txid, index int) Txid { + input := append(protocol.GetEncodingBuf(), []byte(protocol.Transaction)...) + input = append(input, parent[:]...) + buf := make([]byte, 8) + binary.BigEndian.PutUint64(buf, uint64(index)) + input = append(input, buf...) + enc := tx.MarshalMsg(input) + defer protocol.PutEncodingBuf(enc) + return Txid(crypto.Hash(enc)) +} + // Sign signs a transaction using a given Account's secrets. func (tx Transaction) Sign(secrets *crypto.SignatureSecrets) SignedTxn { sig := secrets.Sign(tx) @@ -405,11 +419,11 @@ func (tx Transaction) WellFormed(spec SpecialAddresses, proto config.ConsensusPa // Limit the sum of all types of references that bring in account records if len(tx.Accounts)+len(tx.ForeignApps)+len(tx.ForeignAssets) > proto.MaxAppTotalTxnReferences { - return fmt.Errorf("tx has too many references, max is %d", proto.MaxAppTotalTxnReferences) + return fmt.Errorf("tx references exceed MaxAppTotalTxnReferences = %d", proto.MaxAppTotalTxnReferences) } if tx.ExtraProgramPages > uint32(proto.MaxExtraAppProgramPages) { - return fmt.Errorf("tx.ExtraProgramPages too large, max number of extra pages is %d", proto.MaxExtraAppProgramPages) + return fmt.Errorf("tx.ExtraProgramPages exceeds MaxExtraAppProgramPages = %d", proto.MaxExtraAppProgramPages) } lap := len(tx.ApprovalProgram) |