@@ -61,12 +61,23 @@ func (b *BabbageBlock) Era() Era {
6161 return eras [ERA_ID_BABBAGE ]
6262}
6363
64- func (b * BabbageBlock ) Transactions () []TransactionBody {
65- ret := []TransactionBody {}
66- for _ , v := range b .TransactionBodies {
67- // Create temp var since we take the address and the loop var gets reused
68- tmpVal := v
69- ret = append (ret , & tmpVal )
64+ func (b * BabbageBlock ) Transactions () []Transaction {
65+ ret := []Transaction {}
66+ for idx := range b .TransactionBodies {
67+ tmpTransaction := BabbageTransaction {
68+ Body : b .TransactionBodies [idx ],
69+ WitnessSet : b .TransactionWitnessSets [idx ],
70+ TxMetadata : b .TransactionMetadataSet [uint (idx )],
71+ }
72+ isValid := true
73+ for _ , invalidTxIdx := range b .InvalidTransactions {
74+ if invalidTxIdx == uint (idx ) {
75+ isValid = false
76+ break
77+ }
78+ }
79+ tmpTransaction .IsValid = isValid
80+ ret = append (ret , & tmpTransaction )
7081 }
7182 return ret
7283}
@@ -198,10 +209,27 @@ type BabbageTransactionWitnessSet struct {
198209
199210type BabbageTransaction struct {
200211 cbor.StructAsArray
212+ cbor.DecodeStoreCbor
201213 Body BabbageTransactionBody
202214 WitnessSet BabbageTransactionWitnessSet
203215 IsValid bool
204- Metadata cbor.Value
216+ TxMetadata cbor.Value
217+ }
218+
219+ func (t BabbageTransaction ) Hash () string {
220+ return t .Body .Hash ()
221+ }
222+
223+ func (t BabbageTransaction ) Inputs () []TransactionInput {
224+ return t .Body .Inputs ()
225+ }
226+
227+ func (t BabbageTransaction ) Outputs () []TransactionOutput {
228+ return t .Body .Outputs ()
229+ }
230+
231+ func (t BabbageTransaction ) Metadata () cbor.Value {
232+ return t .TxMetadata
205233}
206234
207235func NewBabbageBlockFromCbor (data []byte ) (* BabbageBlock , error ) {
0 commit comments