File tree Expand file tree Collapse file tree 8 files changed +95
-0
lines changed Expand file tree Collapse file tree 8 files changed +95
-0
lines changed Original file line number Diff line number Diff line change @@ -178,6 +178,14 @@ func (t AllegraTransaction) IsValid() bool {
178
178
return true
179
179
}
180
180
181
+ func (t AllegraTransaction ) Consumed () []TransactionInput {
182
+ return t .Inputs ()
183
+ }
184
+
185
+ func (t AllegraTransaction ) Produced () []TransactionOutput {
186
+ return t .Outputs ()
187
+ }
188
+
181
189
func (t * AllegraTransaction ) ProtocolParametersUpdate () map [Blake2b224 ]any {
182
190
updateMap := make (map [Blake2b224 ]any )
183
191
for k , v := range t .Body .Update .ProtocolParamUpdates {
Original file line number Diff line number Diff line change @@ -284,6 +284,23 @@ func (t AlonzoTransaction) IsValid() bool {
284
284
return t .IsTxValid
285
285
}
286
286
287
+ func (t AlonzoTransaction ) Consumed () []TransactionInput {
288
+ if t .IsValid () {
289
+ return t .Inputs ()
290
+ } else {
291
+ return t .Collateral ()
292
+ }
293
+ }
294
+
295
+ func (t AlonzoTransaction ) Produced () []TransactionOutput {
296
+ if t .IsValid () {
297
+ return t .Outputs ()
298
+ } else {
299
+ // No collateral return in Alonzo
300
+ return []TransactionOutput {}
301
+ }
302
+ }
303
+
287
304
func (t * AlonzoTransaction ) ProtocolParametersUpdate () map [Blake2b224 ]any {
288
305
updateMap := make (map [Blake2b224 ]any )
289
306
for k , v := range t .Body .Update .ProtocolParamUpdates {
Original file line number Diff line number Diff line change @@ -209,6 +209,12 @@ func (b *BabbageTransactionBody) ReferenceInputs() []TransactionInput {
209
209
}
210
210
211
211
func (b * BabbageTransactionBody ) CollateralReturn () TransactionOutput {
212
+ // Return an actual nil if we have no value. If we return our nil pointer,
213
+ // we get a non-nil interface containing a nil value, which is harder to
214
+ // compare against
215
+ if b .TxCollateralReturn == nil {
216
+ return nil
217
+ }
212
218
return b .TxCollateralReturn
213
219
}
214
220
@@ -450,6 +456,25 @@ func (t BabbageTransaction) IsValid() bool {
450
456
return t .IsTxValid
451
457
}
452
458
459
+ func (t BabbageTransaction ) Consumed () []TransactionInput {
460
+ if t .IsValid () {
461
+ return t .Inputs ()
462
+ } else {
463
+ return t .Collateral ()
464
+ }
465
+ }
466
+
467
+ func (t BabbageTransaction ) Produced () []TransactionOutput {
468
+ if t .IsValid () {
469
+ return t .Outputs ()
470
+ } else {
471
+ if t .CollateralReturn () == nil {
472
+ return []TransactionOutput {}
473
+ }
474
+ return []TransactionOutput {t .CollateralReturn ()}
475
+ }
476
+ }
477
+
453
478
func (t * BabbageTransaction ) ProtocolParametersUpdate () map [Blake2b224 ]any {
454
479
updateMap := make (map [Blake2b224 ]any )
455
480
for k , v := range t .Body .Update .ProtocolParamUpdates {
Original file line number Diff line number Diff line change @@ -193,6 +193,14 @@ func (t *ByronTransaction) IsValid() bool {
193
193
return true
194
194
}
195
195
196
+ func (t * ByronTransaction ) Consumed () []TransactionInput {
197
+ return t .Inputs ()
198
+ }
199
+
200
+ func (t * ByronTransaction ) Produced () []TransactionOutput {
201
+ return t .Outputs ()
202
+ }
203
+
196
204
func (t * ByronTransaction ) Utxorpc () * utxorpc.Tx {
197
205
return & utxorpc.Tx {}
198
206
}
Original file line number Diff line number Diff line change @@ -180,6 +180,25 @@ func (t ConwayTransaction) IsValid() bool {
180
180
return t .IsTxValid
181
181
}
182
182
183
+ func (t ConwayTransaction ) Consumed () []TransactionInput {
184
+ if t .IsValid () {
185
+ return t .Inputs ()
186
+ } else {
187
+ return t .Collateral ()
188
+ }
189
+ }
190
+
191
+ func (t ConwayTransaction ) Produced () []TransactionOutput {
192
+ if t .IsValid () {
193
+ return t .Outputs ()
194
+ } else {
195
+ if t .CollateralReturn () == nil {
196
+ return []TransactionOutput {}
197
+ }
198
+ return []TransactionOutput {t .CollateralReturn ()}
199
+ }
200
+ }
201
+
183
202
func (t * ConwayTransaction ) ProtocolParametersUpdate () map [Blake2b224 ]any {
184
203
updateMap := make (map [Blake2b224 ]any )
185
204
for k , v := range t .Body .Update .ProtocolParamUpdates {
Original file line number Diff line number Diff line change @@ -191,6 +191,14 @@ func (t MaryTransaction) IsValid() bool {
191
191
return true
192
192
}
193
193
194
+ func (t MaryTransaction ) Consumed () []TransactionInput {
195
+ return t .Inputs ()
196
+ }
197
+
198
+ func (t MaryTransaction ) Produced () []TransactionOutput {
199
+ return t .Outputs ()
200
+ }
201
+
194
202
func (t * MaryTransaction ) ProtocolParametersUpdate () map [Blake2b224 ]any {
195
203
updateMap := make (map [Blake2b224 ]any )
196
204
for k , v := range t .Body .Update .ProtocolParamUpdates {
Original file line number Diff line number Diff line change @@ -385,6 +385,14 @@ func (t ShelleyTransaction) IsValid() bool {
385
385
return true
386
386
}
387
387
388
+ func (t ShelleyTransaction ) Consumed () []TransactionInput {
389
+ return t .Inputs ()
390
+ }
391
+
392
+ func (t ShelleyTransaction ) Produced () []TransactionOutput {
393
+ return t .Outputs ()
394
+ }
395
+
388
396
func (t ShelleyTransaction ) Utxorpc () * utxorpc.Tx {
389
397
return t .Body .Utxorpc ()
390
398
}
Original file line number Diff line number Diff line change @@ -28,6 +28,8 @@ type Transaction interface {
28
28
TransactionBody
29
29
Metadata () * cbor.Value
30
30
IsValid () bool
31
+ Consumed () []TransactionInput
32
+ Produced () []TransactionOutput
31
33
ProtocolParametersUpdate () map [Blake2b224 ]any
32
34
}
33
35
You can’t perform that action at this time.
0 commit comments