Skip to content

Commit

Permalink
feat: reference inputs in transaction interface
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Gianelloni <wolf31o2@blinklabs.io>
  • Loading branch information
wolf31o2 committed Mar 17, 2024
1 parent 4f41b55 commit 673ed7e
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 4 deletions.
4 changes: 4 additions & 0 deletions ledger/allegra.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ func (t AllegraTransaction) TTL() uint64 {
return t.Body.TTL()
}

func (t AllegraTransaction) ReferenceInputs() []TransactionInput {
return t.Body.ReferenceInputs()
}

func (t AllegraTransaction) Metadata() *cbor.Value {
return t.TxMetadata
}
Expand Down
4 changes: 4 additions & 0 deletions ledger/alonzo.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ func (t AlonzoTransaction) TTL() uint64 {
return t.Body.TTL()
}

func (t AlonzoTransaction) ReferenceInputs() []TransactionInput {
return t.Body.ReferenceInputs()
}

func (t AlonzoTransaction) Metadata() *cbor.Value {
return t.TxMetadata
}
Expand Down
21 changes: 17 additions & 4 deletions ledger/babbage.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,10 @@ func (h *BabbageBlockHeader) Era() Era {

type BabbageTransactionBody struct {
AlonzoTransactionBody
TxOutputs []BabbageTransactionOutput `cbor:"1,keyasint,omitempty"`
CollateralReturn BabbageTransactionOutput `cbor:"16,keyasint,omitempty"`
TotalCollateral uint64 `cbor:"17,keyasint,omitempty"`
ReferenceInputs []ShelleyTransactionInput `cbor:"18,keyasint,omitempty"`
TxOutputs []BabbageTransactionOutput `cbor:"1,keyasint,omitempty"`
CollateralReturn BabbageTransactionOutput `cbor:"16,keyasint,omitempty"`
TotalCollateral uint64 `cbor:"17,keyasint,omitempty"`
TxReferenceInputs []ShelleyTransactionInput `cbor:"18,keyasint,omitempty"`
}

func (b *BabbageTransactionBody) UnmarshalCBOR(cborData []byte) error {
Expand All @@ -194,6 +194,15 @@ func (b *BabbageTransactionBody) Outputs() []TransactionOutput {
return ret
}

func (b *BabbageTransactionBody) ReferenceInputs() []TransactionInput {
ret := []TransactionInput{}
for _, input := range b.TxReferenceInputs {
input := input
ret = append(ret, &input)
}
return ret
}

const (
DatumOptionTypeHash = 0
DatumOptionTypeData = 1
Expand Down Expand Up @@ -375,6 +384,10 @@ func (t BabbageTransaction) TTL() uint64 {
return t.Body.TTL()
}

func (t BabbageTransaction) ReferenceInputs() []TransactionInput {
return t.Body.ReferenceInputs()
}

func (t BabbageTransaction) Metadata() *cbor.Value {
return t.TxMetadata
}
Expand Down
5 changes: 5 additions & 0 deletions ledger/byron.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ func (t *ByronTransaction) TTL() uint64 {
return 0
}

func (t *ByronTransaction) ReferenceInputs() []TransactionInput {
// TODO
return nil
}

func (t *ByronTransaction) Metadata() *cbor.Value {
return t.Attributes
}
Expand Down
4 changes: 4 additions & 0 deletions ledger/conway.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ func (t ConwayTransaction) TTL() uint64 {
return t.Body.TTL()
}

func (t ConwayTransaction) ReferenceInputs() []TransactionInput {
return t.Body.ReferenceInputs()
}

func (t ConwayTransaction) Metadata() *cbor.Value {
return t.TxMetadata
}
Expand Down
4 changes: 4 additions & 0 deletions ledger/mary.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ func (t MaryTransaction) TTL() uint64 {
return t.Body.TTL()
}

func (t MaryTransaction) ReferenceInputs() []TransactionInput {
return t.Body.ReferenceInputs()
}

func (t MaryTransaction) Metadata() *cbor.Value {
return t.TxMetadata
}
Expand Down
8 changes: 8 additions & 0 deletions ledger/shelley.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ func (b *ShelleyTransactionBody) TTL() uint64 {
return b.Ttl
}

func (b *ShelleyTransactionBody) ReferenceInputs() []TransactionInput {
return []TransactionInput{}
}

func (b *ShelleyTransactionBody) Utxorpc() *utxorpc.Tx {
var txi []*utxorpc.TxInput
var txo []*utxorpc.TxOutput
Expand Down Expand Up @@ -351,6 +355,10 @@ func (t ShelleyTransaction) TTL() uint64 {
return t.Body.TTL()
}

func (t ShelleyTransaction) ReferenceInputs() []TransactionInput {
return t.Body.ReferenceInputs()
}

func (t ShelleyTransaction) Metadata() *cbor.Value {
return t.TxMetadata
}
Expand Down
1 change: 1 addition & 0 deletions ledger/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type TransactionBody interface {
Inputs() []TransactionInput
Outputs() []TransactionOutput
TTL() uint64
ReferenceInputs() []TransactionInput
Utxorpc() *utxorpc.Tx
}

Expand Down

0 comments on commit 673ed7e

Please sign in to comment.