Skip to content

Commit

Permalink
feat: TX auxiliary data hash attribute
Browse files Browse the repository at this point in the history
This adds a method for retrieving the auxiliary data hash from a TX

Fixes #334
  • Loading branch information
agaffney committed May 16, 2024
1 parent 9fb129a commit 06f4a23
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ledger/allegra.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ func (t AllegraTransaction) Withdrawals() map[*Address]uint64 {
return t.Body.Withdrawals()
}

func (t AllegraTransaction) AuxDataHash() *Blake2b256 {
return t.Body.AuxDataHash()
}

func (t AllegraTransaction) RequiredSigners() []Blake2b224 {
return t.Body.RequiredSigners()
}
Expand Down
4 changes: 4 additions & 0 deletions ledger/alonzo.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,10 @@ func (t AlonzoTransaction) Withdrawals() map[*Address]uint64 {
return t.Body.Withdrawals()
}

func (t AlonzoTransaction) AuxDataHash() *Blake2b256 {
return t.Body.AuxDataHash()
}

func (t AlonzoTransaction) RequiredSigners() []Blake2b224 {
return t.Body.RequiredSigners()
}
Expand Down
4 changes: 4 additions & 0 deletions ledger/babbage.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,10 @@ func (t BabbageTransaction) Withdrawals() map[*Address]uint64 {
return t.Body.Withdrawals()
}

func (t BabbageTransaction) AuxDataHash() *Blake2b256 {
return t.Body.AuxDataHash()
}

func (t BabbageTransaction) ScriptDataHash() *Blake2b256 {
return t.Body.ScriptDataHash()
}
Expand Down
5 changes: 5 additions & 0 deletions ledger/byron.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ func (t *ByronTransaction) Withdrawals() map[*Address]uint64 {
return nil
}

func (t *ByronTransaction) AuxDataHash() *Blake2b256 {
// No aux data hash in Byron
return nil
}

func (t *ByronTransaction) RequiredSigners() []Blake2b224 {
// No required signers 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 @@ -373,6 +373,10 @@ func (t ConwayTransaction) Withdrawals() map[*Address]uint64 {
return t.Body.Withdrawals()
}

func (t ConwayTransaction) AuxDataHash() *Blake2b256 {
return t.Body.AuxDataHash()
}

func (t ConwayTransaction) RequiredSigners() []Blake2b224 {
return t.Body.RequiredSigners()
}
Expand Down
4 changes: 4 additions & 0 deletions ledger/mary.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ func (t MaryTransaction) Withdrawals() map[*Address]uint64 {
return t.Body.Withdrawals()
}

func (t MaryTransaction) AuxDataHash() *Blake2b256 {
return t.Body.AuxDataHash()
}

func (t MaryTransaction) RequiredSigners() []Blake2b224 {
return t.Body.RequiredSigners()
}
Expand Down
10 changes: 9 additions & 1 deletion ledger/shelley.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ type ShelleyTransactionBody struct {
ProtocolParamUpdates map[Blake2b224]ShelleyProtocolParameterUpdate
Epoch uint64
} `cbor:"6,keyasint,omitempty"`
MetadataHash Blake2b256 `cbor:"7,keyasint,omitempty"`
TxAuxDataHash *Blake2b256 `cbor:"7,keyasint,omitempty"`
}

func (b *ShelleyTransactionBody) UnmarshalCBOR(cborData []byte) error {
Expand Down Expand Up @@ -249,6 +249,10 @@ func (b *ShelleyTransactionBody) Withdrawals() map[*Address]uint64 {
return b.TxWithdrawals
}

func (b *ShelleyTransactionBody) AuxDataHash() *Blake2b256 {
return b.TxAuxDataHash
}

func (b *ShelleyTransactionBody) RequiredSigners() []Blake2b224 {
// No required signers in Shelley
return nil
Expand Down Expand Up @@ -436,6 +440,10 @@ func (t ShelleyTransaction) Withdrawals() map[*Address]uint64 {
return t.Body.Withdrawals()
}

func (t ShelleyTransaction) AuxDataHash() *Blake2b256 {
return t.Body.AuxDataHash()
}

func (t ShelleyTransaction) RequiredSigners() []Blake2b224 {
return t.Body.RequiredSigners()
}
Expand Down
1 change: 1 addition & 0 deletions ledger/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type TransactionBody interface {
TotalCollateral() uint64
Certificates() []Certificate
Withdrawals() map[*Address]uint64
AuxDataHash() *Blake2b256
RequiredSigners() []Blake2b224
AssetMint() *MultiAsset[MultiAssetTypeMint]
ScriptDataHash() *Blake2b256
Expand Down

0 comments on commit 06f4a23

Please sign in to comment.