Skip to content

Commit 512417f

Browse files
authored
feat: reference inputs in transaction interface (#547)
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent 4f41b55 commit 512417f

File tree

8 files changed

+47
-4
lines changed

8 files changed

+47
-4
lines changed

ledger/allegra.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ func (t AllegraTransaction) TTL() uint64 {
149149
return t.Body.TTL()
150150
}
151151

152+
func (t AllegraTransaction) ReferenceInputs() []TransactionInput {
153+
return t.Body.ReferenceInputs()
154+
}
155+
152156
func (t AllegraTransaction) Metadata() *cbor.Value {
153157
return t.TxMetadata
154158
}

ledger/alonzo.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,10 @@ func (t AlonzoTransaction) TTL() uint64 {
251251
return t.Body.TTL()
252252
}
253253

254+
func (t AlonzoTransaction) ReferenceInputs() []TransactionInput {
255+
return t.Body.ReferenceInputs()
256+
}
257+
254258
func (t AlonzoTransaction) Metadata() *cbor.Value {
255259
return t.TxMetadata
256260
}

ledger/babbage.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,10 @@ func (h *BabbageBlockHeader) Era() Era {
175175

176176
type BabbageTransactionBody struct {
177177
AlonzoTransactionBody
178-
TxOutputs []BabbageTransactionOutput `cbor:"1,keyasint,omitempty"`
179-
CollateralReturn BabbageTransactionOutput `cbor:"16,keyasint,omitempty"`
180-
TotalCollateral uint64 `cbor:"17,keyasint,omitempty"`
181-
ReferenceInputs []ShelleyTransactionInput `cbor:"18,keyasint,omitempty"`
178+
TxOutputs []BabbageTransactionOutput `cbor:"1,keyasint,omitempty"`
179+
CollateralReturn BabbageTransactionOutput `cbor:"16,keyasint,omitempty"`
180+
TotalCollateral uint64 `cbor:"17,keyasint,omitempty"`
181+
TxReferenceInputs []ShelleyTransactionInput `cbor:"18,keyasint,omitempty"`
182182
}
183183

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

197+
func (b *BabbageTransactionBody) ReferenceInputs() []TransactionInput {
198+
ret := []TransactionInput{}
199+
for _, input := range b.TxReferenceInputs {
200+
input := input
201+
ret = append(ret, &input)
202+
}
203+
return ret
204+
}
205+
197206
const (
198207
DatumOptionTypeHash = 0
199208
DatumOptionTypeData = 1
@@ -375,6 +384,10 @@ func (t BabbageTransaction) TTL() uint64 {
375384
return t.Body.TTL()
376385
}
377386

387+
func (t BabbageTransaction) ReferenceInputs() []TransactionInput {
388+
return t.Body.ReferenceInputs()
389+
}
390+
378391
func (t BabbageTransaction) Metadata() *cbor.Value {
379392
return t.TxMetadata
380393
}

ledger/byron.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ func (t *ByronTransaction) TTL() uint64 {
153153
return 0
154154
}
155155

156+
func (t *ByronTransaction) ReferenceInputs() []TransactionInput {
157+
// TODO
158+
return nil
159+
}
160+
156161
func (t *ByronTransaction) Metadata() *cbor.Value {
157162
return t.Attributes
158163
}

ledger/conway.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ func (t ConwayTransaction) TTL() uint64 {
160160
return t.Body.TTL()
161161
}
162162

163+
func (t ConwayTransaction) ReferenceInputs() []TransactionInput {
164+
return t.Body.ReferenceInputs()
165+
}
166+
163167
func (t ConwayTransaction) Metadata() *cbor.Value {
164168
return t.TxMetadata
165169
}

ledger/mary.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ func (t MaryTransaction) TTL() uint64 {
160160
return t.Body.TTL()
161161
}
162162

163+
func (t MaryTransaction) ReferenceInputs() []TransactionInput {
164+
return t.Body.ReferenceInputs()
165+
}
166+
163167
func (t MaryTransaction) Metadata() *cbor.Value {
164168
return t.TxMetadata
165169
}

ledger/shelley.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,10 @@ func (b *ShelleyTransactionBody) TTL() uint64 {
217217
return b.Ttl
218218
}
219219

220+
func (b *ShelleyTransactionBody) ReferenceInputs() []TransactionInput {
221+
return []TransactionInput{}
222+
}
223+
220224
func (b *ShelleyTransactionBody) Utxorpc() *utxorpc.Tx {
221225
var txi []*utxorpc.TxInput
222226
var txo []*utxorpc.TxOutput
@@ -351,6 +355,10 @@ func (t ShelleyTransaction) TTL() uint64 {
351355
return t.Body.TTL()
352356
}
353357

358+
func (t ShelleyTransaction) ReferenceInputs() []TransactionInput {
359+
return t.Body.ReferenceInputs()
360+
}
361+
354362
func (t ShelleyTransaction) Metadata() *cbor.Value {
355363
return t.TxMetadata
356364
}

ledger/tx.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type TransactionBody interface {
3737
Inputs() []TransactionInput
3838
Outputs() []TransactionOutput
3939
TTL() uint64
40+
ReferenceInputs() []TransactionInput
4041
Utxorpc() *utxorpc.Tx
4142
}
4243

0 commit comments

Comments
 (0)