@@ -84,6 +84,32 @@ func NewTransactionBodyFromCbor(txType uint, data []byte) (TransactionBody, erro
8484 return nil , fmt .Errorf ("unknown transaction type: %d" , txType )
8585}
8686
87+ func DetermineTransactionType (data []byte ) (uint , error ) {
88+ // TODO: uncomment this once the following issue is resolved:
89+ // https://github.com/blinklabs-io/gouroboros/issues/206
90+ /*
91+ if _, err := NewByronTransactionFromCbor(data); err == nil {
92+ return TxTypeByron, nil
93+ }
94+ */
95+ if _ , err := NewShelleyTransactionFromCbor (data ); err == nil {
96+ return TxTypeShelley , nil
97+ }
98+ if _ , err := NewAllegraTransactionFromCbor (data ); err == nil {
99+ return TxTypeAllegra , nil
100+ }
101+ if _ , err := NewMaryTransactionFromCbor (data ); err == nil {
102+ return TxTypeMary , nil
103+ }
104+ if _ , err := NewAlonzoTransactionFromCbor (data ); err == nil {
105+ return TxTypeAlonzo , nil
106+ }
107+ if _ , err := NewBabbageTransactionFromCbor (data ); err == nil {
108+ return TxTypeBabbage , nil
109+ }
110+ return 0 , fmt .Errorf ("unknown transaction type" )
111+ }
112+
87113func generateTransactionHash (data []byte , prefix []byte ) string {
88114 // We can ignore the error return here because our fixed size/key arguments will
89115 // never trigger an error
0 commit comments