Skip to content

Commit

Permalink
feat: reference inputs in utxorpc for babbage/conway
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Gianelloni <[email protected]>
  • Loading branch information
wolf31o2 committed Mar 30, 2024
1 parent 09d79f4 commit 0392437
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
37 changes: 37 additions & 0 deletions ledger/babbage.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,43 @@ func (b *BabbageTransactionBody) ReferenceInputs() []TransactionInput {
return ret
}

func (b *BabbageTransactionBody) Utxorpc() *utxorpc.Tx {
var txi, txri []*utxorpc.TxInput
var txo []*utxorpc.TxOutput
for _, i := range b.Inputs() {
input := i.Utxorpc()
txi = append(txi, input)
}
for _, o := range b.Outputs() {
output := o.Utxorpc()
txo = append(txo, output)
}
for _, ri := range b.ReferenceInputs() {
input := ri.Utxorpc()
txri = append(txri, input)
}
tmpHash, err := hex.DecodeString(b.Hash())
if err != nil {
return &utxorpc.Tx{}
}
tx := &utxorpc.Tx{
Inputs: txi,
Outputs: txo,
// Certificates: b.Certificates(),
// Withdrawals: b.Withdrawals(),
// Mint: b.Mint(),
ReferenceInputs: txri,
// Witnesses: b.Witnesses(),
// Collateral: b.Collateral(),
Fee: b.Fee(),
// Successful: b.Successful(),
// Auxiliary: b.AuxData(),
// Validity: b.Validity(),
Hash: tmpHash,
}
return tx
}

const (
DatumOptionTypeHash = 0
DatumOptionTypeData = 1
Expand Down
6 changes: 3 additions & 3 deletions ledger/shelley.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,14 @@ func (b *ShelleyTransactionBody) Utxorpc() *utxorpc.Tx {
tx := &utxorpc.Tx{
Inputs: txi,
Outputs: txo,
Fee: b.Fee(),
Hash: tmpHash,
// Certificates: b.Certificates(),
// Validity: b.Validity(),
// Withdrawals: b.Withdrawals(),
// Witnesses: b.Witnesses(),
Fee: b.Fee(),
// Validity: b.Validity(),
// Successful: b.Successful(),
// Auxiliary: b.AuxData(),
Hash: tmpHash,
}
return tx
}
Expand Down

0 comments on commit 0392437

Please sign in to comment.