Skip to content

Commit b1fb0bb

Browse files
committed
fix(ledger): copy datum hash to alonzo format
Signed-off-by: Chris Gianelloni <wolf31o2@blinklabs.io>
1 parent 4439ff8 commit b1fb0bb

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

ledger/babbage/babbage.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,12 @@ func (o *BabbageTransactionOutput) UnmarshalCBOR(cborData []byte) error {
456456
// Copy from temp legacy object to Babbage format
457457
o.OutputAddress = tmpOutput.OutputAddress
458458
o.OutputAmount = tmpOutput.OutputAmount
459+
// Copy datum hash if present in legacy Alonzo output
460+
if tmpOutput.OutputDatumHash != nil {
461+
o.DatumOption = &BabbageTransactionOutputDatumOption{
462+
hash: tmpOutput.OutputDatumHash,
463+
}
464+
}
459465
o.legacyOutput = true
460466
} else {
461467
type tBabbageTransactionOutput BabbageTransactionOutput
@@ -476,6 +482,10 @@ func (o *BabbageTransactionOutput) MarshalCBOR() ([]byte, error) {
476482
OutputAddress: o.OutputAddress,
477483
OutputAmount: o.OutputAmount,
478484
}
485+
// Copy datum hash if present
486+
if o.DatumOption != nil && o.DatumOption.hash != nil {
487+
tmpOutput.OutputDatumHash = o.DatumOption.hash
488+
}
479489
return cbor.Encode(&tmpOutput)
480490
}
481491
return cbor.EncodeGeneric(o)

0 commit comments

Comments
 (0)