Skip to content

Commit 2015cff

Browse files
authored
Merge pull request #402 from blinklabs-io/feat/txfee
feat: transaction fee
2 parents ba505e5 + d3cee38 commit 2015cff

File tree

7 files changed

+31
-1
lines changed

7 files changed

+31
-1
lines changed

ledger/allegra.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ func (t AllegraTransaction) Outputs() []TransactionOutput {
117117
return t.Body.Outputs()
118118
}
119119

120+
func (t AllegraTransaction) Fee() uint64 {
121+
return t.Body.Fee()
122+
}
123+
120124
func (t AllegraTransaction) Metadata() *cbor.Value {
121125
return t.TxMetadata
122126
}

ledger/alonzo.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@ func (t AlonzoTransaction) Outputs() []TransactionOutput {
212212
return t.Body.Outputs()
213213
}
214214

215+
func (t AlonzoTransaction) Fee() uint64 {
216+
return t.Body.Fee()
217+
}
218+
215219
func (t AlonzoTransaction) Metadata() *cbor.Value {
216220
return t.TxMetadata
217221
}

ledger/babbage.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,10 @@ func (t BabbageTransaction) Outputs() []TransactionOutput {
334334
return t.Body.Outputs()
335335
}
336336

337+
func (t BabbageTransaction) Fee() uint64 {
338+
return t.Body.Fee()
339+
}
340+
337341
func (t BabbageTransaction) Metadata() *cbor.Value {
338342
return t.TxMetadata
339343
}

ledger/byron.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ func (t *ByronTransaction) Outputs() []TransactionOutput {
134134
return nil
135135
}
136136

137+
func (t *ByronTransaction) Fee() uint64 {
138+
// TODO
139+
return 0
140+
}
141+
137142
func (t *ByronTransaction) Metadata() *cbor.Value {
138143
return t.Attributes
139144
}

ledger/mary.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ func (t MaryTransaction) Outputs() []TransactionOutput {
128128
return t.Body.Outputs()
129129
}
130130

131+
func (t MaryTransaction) Fee() uint64 {
132+
return t.Body.Fee()
133+
}
134+
131135
func (t MaryTransaction) Metadata() *cbor.Value {
132136
return t.TxMetadata
133137
}

ledger/shelley.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ type ShelleyTransactionBody struct {
141141
hash string
142142
TxInputs []ShelleyTransactionInput `cbor:"0,keyasint,omitempty"`
143143
TxOutputs []ShelleyTransactionOutput `cbor:"1,keyasint,omitempty"`
144-
Fee uint64 `cbor:"2,keyasint,omitempty"`
144+
TxFee uint64 `cbor:"2,keyasint,omitempty"`
145145
Ttl uint64 `cbor:"3,keyasint,omitempty"`
146146
// TODO: figure out how to parse properly
147147
Certificates cbor.RawMessage `cbor:"4,keyasint,omitempty"`
@@ -185,6 +185,10 @@ func (b *ShelleyTransactionBody) Outputs() []TransactionOutput {
185185
return ret
186186
}
187187

188+
func (b *ShelleyTransactionBody) Fee() uint64 {
189+
return b.TxFee
190+
}
191+
188192
type ShelleyTransactionInput struct {
189193
cbor.StructAsArray
190194
TxId Blake2b256
@@ -265,6 +269,10 @@ func (t ShelleyTransaction) Outputs() []TransactionOutput {
265269
return t.Body.Outputs()
266270
}
267271

272+
func (t ShelleyTransaction) Fee() uint64 {
273+
return t.Body.Fee()
274+
}
275+
268276
func (t ShelleyTransaction) Metadata() *cbor.Value {
269277
return t.TxMetadata
270278
}

ledger/tx.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ type TransactionBody interface {
3232
Cbor() []byte
3333
Inputs() []TransactionInput
3434
Outputs() []TransactionOutput
35+
Fee() uint64
3536
}
3637

3738
type TransactionInput interface {

0 commit comments

Comments
 (0)