Skip to content

Commit

Permalink
feat: TX validity interval start attribute (#633)
Browse files Browse the repository at this point in the history
This adds a method for retrieving the validity interval start from a TX

Fixes #335
  • Loading branch information
agaffney authored May 16, 2024
1 parent 3f73561 commit 9fb129a
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ledger/allegra.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,17 @@ type AllegraTransactionBody struct {
ProtocolParamUpdates map[Blake2b224]AllegraProtocolParameterUpdate
Epoch uint64
} `cbor:"6,keyasint,omitempty"`
ValidityIntervalStart uint64 `cbor:"8,keyasint,omitempty"`
TxValidityIntervalStart uint64 `cbor:"8,keyasint,omitempty"`
}

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

func (b *AllegraTransactionBody) ValidityIntervalStart() uint64 {
return b.TxValidityIntervalStart
}

type AllegraTransaction struct {
cbor.StructAsArray
cbor.DecodeStoreCbor
Expand Down Expand Up @@ -154,6 +158,10 @@ func (t AllegraTransaction) TTL() uint64 {
return t.Body.TTL()
}

func (t AllegraTransaction) ValidityIntervalStart() uint64 {
return t.Body.ValidityIntervalStart()
}

func (t AllegraTransaction) ReferenceInputs() []TransactionInput {
return t.Body.ReferenceInputs()
}
Expand Down
4 changes: 4 additions & 0 deletions ledger/alonzo.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,10 @@ func (t AlonzoTransaction) TTL() uint64 {
return t.Body.TTL()
}

func (t AlonzoTransaction) ValidityIntervalStart() uint64 {
return t.Body.ValidityIntervalStart()
}

func (t AlonzoTransaction) ReferenceInputs() []TransactionInput {
return t.Body.ReferenceInputs()
}
Expand Down
4 changes: 4 additions & 0 deletions ledger/babbage.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,10 @@ func (t BabbageTransaction) TTL() uint64 {
return t.Body.TTL()
}

func (t BabbageTransaction) ValidityIntervalStart() uint64 {
return t.Body.ValidityIntervalStart()
}

func (t BabbageTransaction) ReferenceInputs() []TransactionInput {
return t.Body.ReferenceInputs()
}
Expand Down
5 changes: 5 additions & 0 deletions ledger/byron.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ func (t *ByronTransaction) TTL() uint64 {
return 0
}

func (t *ByronTransaction) ValidityIntervalStart() uint64 {
// No validity interval start in Byron
return 0
}

func (t *ByronTransaction) ReferenceInputs() []TransactionInput {
// No reference inputs in Byron
return nil
Expand Down
4 changes: 4 additions & 0 deletions ledger/conway.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,10 @@ func (t ConwayTransaction) TTL() uint64 {
return t.Body.TTL()
}

func (t ConwayTransaction) ValidityIntervalStart() uint64 {
return t.Body.ValidityIntervalStart()
}

func (t ConwayTransaction) ReferenceInputs() []TransactionInput {
return t.Body.ReferenceInputs()
}
Expand Down
4 changes: 4 additions & 0 deletions ledger/mary.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ func (t MaryTransaction) TTL() uint64 {
return t.Body.TTL()
}

func (t MaryTransaction) ValidityIntervalStart() uint64 {
return t.Body.ValidityIntervalStart()
}

func (t MaryTransaction) ReferenceInputs() []TransactionInput {
return t.Body.ReferenceInputs()
}
Expand Down
9 changes: 9 additions & 0 deletions ledger/shelley.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,11 @@ func (b *ShelleyTransactionBody) TTL() uint64 {
return b.Ttl
}

func (b *ShelleyTransactionBody) ValidityIntervalStart() uint64 {
// No validity interval start in Shelley
return 0
}

func (b *ShelleyTransactionBody) ReferenceInputs() []TransactionInput {
return []TransactionInput{}
}
Expand Down Expand Up @@ -403,6 +408,10 @@ func (t ShelleyTransaction) TTL() uint64 {
return t.Body.TTL()
}

func (t ShelleyTransaction) ValidityIntervalStart() uint64 {
return t.Body.ValidityIntervalStart()
}

func (t ShelleyTransaction) ReferenceInputs() []TransactionInput {
return t.Body.ReferenceInputs()
}
Expand Down
1 change: 1 addition & 0 deletions ledger/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type TransactionBody interface {
Inputs() []TransactionInput
Outputs() []TransactionOutput
TTL() uint64
ValidityIntervalStart() uint64
ReferenceInputs() []TransactionInput
Collateral() []TransactionInput
CollateralReturn() TransactionOutput
Expand Down

0 comments on commit 9fb129a

Please sign in to comment.