Skip to content

Commit 9fb129a

Browse files
authored
feat: TX validity interval start attribute (#633)
This adds a method for retrieving the validity interval start from a TX Fixes #335
1 parent 3f73561 commit 9fb129a

File tree

8 files changed

+40
-1
lines changed

8 files changed

+40
-1
lines changed

ledger/allegra.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,17 @@ type AllegraTransactionBody struct {
119119
ProtocolParamUpdates map[Blake2b224]AllegraProtocolParameterUpdate
120120
Epoch uint64
121121
} `cbor:"6,keyasint,omitempty"`
122-
ValidityIntervalStart uint64 `cbor:"8,keyasint,omitempty"`
122+
TxValidityIntervalStart uint64 `cbor:"8,keyasint,omitempty"`
123123
}
124124

125125
func (b *AllegraTransactionBody) UnmarshalCBOR(cborData []byte) error {
126126
return b.UnmarshalCbor(cborData, b)
127127
}
128128

129+
func (b *AllegraTransactionBody) ValidityIntervalStart() uint64 {
130+
return b.TxValidityIntervalStart
131+
}
132+
129133
type AllegraTransaction struct {
130134
cbor.StructAsArray
131135
cbor.DecodeStoreCbor
@@ -154,6 +158,10 @@ func (t AllegraTransaction) TTL() uint64 {
154158
return t.Body.TTL()
155159
}
156160

161+
func (t AllegraTransaction) ValidityIntervalStart() uint64 {
162+
return t.Body.ValidityIntervalStart()
163+
}
164+
157165
func (t AllegraTransaction) ReferenceInputs() []TransactionInput {
158166
return t.Body.ReferenceInputs()
159167
}

ledger/alonzo.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,10 @@ func (t AlonzoTransaction) TTL() uint64 {
272272
return t.Body.TTL()
273273
}
274274

275+
func (t AlonzoTransaction) ValidityIntervalStart() uint64 {
276+
return t.Body.ValidityIntervalStart()
277+
}
278+
275279
func (t AlonzoTransaction) ReferenceInputs() []TransactionInput {
276280
return t.Body.ReferenceInputs()
277281
}

ledger/babbage.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,10 @@ func (t BabbageTransaction) TTL() uint64 {
440440
return t.Body.TTL()
441441
}
442442

443+
func (t BabbageTransaction) ValidityIntervalStart() uint64 {
444+
return t.Body.ValidityIntervalStart()
445+
}
446+
443447
func (t BabbageTransaction) ReferenceInputs() []TransactionInput {
444448
return t.Body.ReferenceInputs()
445449
}

ledger/byron.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,11 @@ func (t *ByronTransaction) TTL() uint64 {
170170
return 0
171171
}
172172

173+
func (t *ByronTransaction) ValidityIntervalStart() uint64 {
174+
// No validity interval start in Byron
175+
return 0
176+
}
177+
173178
func (t *ByronTransaction) ReferenceInputs() []TransactionInput {
174179
// No reference inputs in Byron
175180
return nil

ledger/conway.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,10 @@ func (t ConwayTransaction) TTL() uint64 {
345345
return t.Body.TTL()
346346
}
347347

348+
func (t ConwayTransaction) ValidityIntervalStart() uint64 {
349+
return t.Body.ValidityIntervalStart()
350+
}
351+
348352
func (t ConwayTransaction) ReferenceInputs() []TransactionInput {
349353
return t.Body.ReferenceInputs()
350354
}

ledger/mary.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ func (t MaryTransaction) TTL() uint64 {
175175
return t.Body.TTL()
176176
}
177177

178+
func (t MaryTransaction) ValidityIntervalStart() uint64 {
179+
return t.Body.ValidityIntervalStart()
180+
}
181+
178182
func (t MaryTransaction) ReferenceInputs() []TransactionInput {
179183
return t.Body.ReferenceInputs()
180184
}

ledger/shelley.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,11 @@ func (b *ShelleyTransactionBody) TTL() uint64 {
213213
return b.Ttl
214214
}
215215

216+
func (b *ShelleyTransactionBody) ValidityIntervalStart() uint64 {
217+
// No validity interval start in Shelley
218+
return 0
219+
}
220+
216221
func (b *ShelleyTransactionBody) ReferenceInputs() []TransactionInput {
217222
return []TransactionInput{}
218223
}
@@ -403,6 +408,10 @@ func (t ShelleyTransaction) TTL() uint64 {
403408
return t.Body.TTL()
404409
}
405410

411+
func (t ShelleyTransaction) ValidityIntervalStart() uint64 {
412+
return t.Body.ValidityIntervalStart()
413+
}
414+
406415
func (t ShelleyTransaction) ReferenceInputs() []TransactionInput {
407416
return t.Body.ReferenceInputs()
408417
}

ledger/tx.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ type TransactionBody interface {
4040
Inputs() []TransactionInput
4141
Outputs() []TransactionOutput
4242
TTL() uint64
43+
ValidityIntervalStart() uint64
4344
ReferenceInputs() []TransactionInput
4445
Collateral() []TransactionInput
4546
CollateralReturn() TransactionOutput

0 commit comments

Comments
 (0)