Skip to content

Commit 5a6633b

Browse files
authored
feat: TX auxiliary data hash attribute (#634)
This adds a method for retrieving the auxiliary data hash from a TX Fixes #334
1 parent 9fb129a commit 5a6633b

File tree

8 files changed

+35
-1
lines changed

8 files changed

+35
-1
lines changed

ledger/allegra.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ func (t AllegraTransaction) Withdrawals() map[*Address]uint64 {
186186
return t.Body.Withdrawals()
187187
}
188188

189+
func (t AllegraTransaction) AuxDataHash() *Blake2b256 {
190+
return t.Body.AuxDataHash()
191+
}
192+
189193
func (t AllegraTransaction) RequiredSigners() []Blake2b224 {
190194
return t.Body.RequiredSigners()
191195
}

ledger/alonzo.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,10 @@ func (t AlonzoTransaction) Withdrawals() map[*Address]uint64 {
300300
return t.Body.Withdrawals()
301301
}
302302

303+
func (t AlonzoTransaction) AuxDataHash() *Blake2b256 {
304+
return t.Body.AuxDataHash()
305+
}
306+
303307
func (t AlonzoTransaction) RequiredSigners() []Blake2b224 {
304308
return t.Body.RequiredSigners()
305309
}

ledger/babbage.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,10 @@ func (t BabbageTransaction) Withdrawals() map[*Address]uint64 {
468468
return t.Body.Withdrawals()
469469
}
470470

471+
func (t BabbageTransaction) AuxDataHash() *Blake2b256 {
472+
return t.Body.AuxDataHash()
473+
}
474+
471475
func (t BabbageTransaction) ScriptDataHash() *Blake2b256 {
472476
return t.Body.ScriptDataHash()
473477
}

ledger/byron.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@ func (t *ByronTransaction) Withdrawals() map[*Address]uint64 {
205205
return nil
206206
}
207207

208+
func (t *ByronTransaction) AuxDataHash() *Blake2b256 {
209+
// No aux data hash in Byron
210+
return nil
211+
}
212+
208213
func (t *ByronTransaction) RequiredSigners() []Blake2b224 {
209214
// No required signers in Byron
210215
return nil

ledger/conway.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,10 @@ func (t ConwayTransaction) Withdrawals() map[*Address]uint64 {
373373
return t.Body.Withdrawals()
374374
}
375375

376+
func (t ConwayTransaction) AuxDataHash() *Blake2b256 {
377+
return t.Body.AuxDataHash()
378+
}
379+
376380
func (t ConwayTransaction) RequiredSigners() []Blake2b224 {
377381
return t.Body.RequiredSigners()
378382
}

ledger/mary.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ func (t MaryTransaction) Withdrawals() map[*Address]uint64 {
203203
return t.Body.Withdrawals()
204204
}
205205

206+
func (t MaryTransaction) AuxDataHash() *Blake2b256 {
207+
return t.Body.AuxDataHash()
208+
}
209+
206210
func (t MaryTransaction) RequiredSigners() []Blake2b224 {
207211
return t.Body.RequiredSigners()
208212
}

ledger/shelley.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ type ShelleyTransactionBody struct {
174174
ProtocolParamUpdates map[Blake2b224]ShelleyProtocolParameterUpdate
175175
Epoch uint64
176176
} `cbor:"6,keyasint,omitempty"`
177-
MetadataHash Blake2b256 `cbor:"7,keyasint,omitempty"`
177+
TxAuxDataHash *Blake2b256 `cbor:"7,keyasint,omitempty"`
178178
}
179179

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

252+
func (b *ShelleyTransactionBody) AuxDataHash() *Blake2b256 {
253+
return b.TxAuxDataHash
254+
}
255+
252256
func (b *ShelleyTransactionBody) RequiredSigners() []Blake2b224 {
253257
// No required signers in Shelley
254258
return nil
@@ -436,6 +440,10 @@ func (t ShelleyTransaction) Withdrawals() map[*Address]uint64 {
436440
return t.Body.Withdrawals()
437441
}
438442

443+
func (t ShelleyTransaction) AuxDataHash() *Blake2b256 {
444+
return t.Body.AuxDataHash()
445+
}
446+
439447
func (t ShelleyTransaction) RequiredSigners() []Blake2b224 {
440448
return t.Body.RequiredSigners()
441449
}

ledger/tx.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type TransactionBody interface {
4747
TotalCollateral() uint64
4848
Certificates() []Certificate
4949
Withdrawals() map[*Address]uint64
50+
AuxDataHash() *Blake2b256
5051
RequiredSigners() []Blake2b224
5152
AssetMint() *MultiAsset[MultiAssetTypeMint]
5253
ScriptDataHash() *Blake2b256

0 commit comments

Comments
 (0)