Skip to content

Commit d3cee38

Browse files
committed
feat: transaction fee
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent 54800ce commit d3cee38

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
@@ -109,6 +109,10 @@ func (t AllegraTransaction) Outputs() []TransactionOutput {
109109
return t.Body.Outputs()
110110
}
111111

112+
func (t AllegraTransaction) Fee() uint64 {
113+
return t.Body.Fee()
114+
}
115+
112116
func (t AllegraTransaction) Metadata() *cbor.Value {
113117
return t.TxMetadata
114118
}

ledger/alonzo.go

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

207+
func (t AlonzoTransaction) Fee() uint64 {
208+
return t.Body.Fee()
209+
}
210+
207211
func (t AlonzoTransaction) Metadata() *cbor.Value {
208212
return t.TxMetadata
209213
}

ledger/babbage.go

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

321+
func (t BabbageTransaction) Fee() uint64 {
322+
return t.Body.Fee()
323+
}
324+
321325
func (t BabbageTransaction) Metadata() *cbor.Value {
322326
return t.TxMetadata
323327
}

ledger/byron.go

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

127+
func (t *ByronTransaction) Fee() uint64 {
128+
// TODO
129+
return 0
130+
}
131+
127132
func (t *ByronTransaction) Metadata() *cbor.Value {
128133
return t.Attributes
129134
}

ledger/mary.go

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

123+
func (t MaryTransaction) Fee() uint64 {
124+
return t.Body.Fee()
125+
}
126+
123127
func (t MaryTransaction) Metadata() *cbor.Value {
124128
return t.TxMetadata
125129
}

ledger/shelley.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ type ShelleyTransactionBody struct {
125125
hash string
126126
TxInputs []ShelleyTransactionInput `cbor:"0,keyasint,omitempty"`
127127
TxOutputs []ShelleyTransactionOutput `cbor:"1,keyasint,omitempty"`
128-
Fee uint64 `cbor:"2,keyasint,omitempty"`
128+
TxFee uint64 `cbor:"2,keyasint,omitempty"`
129129
Ttl uint64 `cbor:"3,keyasint,omitempty"`
130130
// TODO: figure out how to parse properly
131131
Certificates cbor.RawMessage `cbor:"4,keyasint,omitempty"`
@@ -169,6 +169,10 @@ func (b *ShelleyTransactionBody) Outputs() []TransactionOutput {
169169
return ret
170170
}
171171

172+
func (b *ShelleyTransactionBody) Fee() uint64 {
173+
return b.TxFee
174+
}
175+
172176
type ShelleyTransactionInput struct {
173177
cbor.StructAsArray
174178
TxId Blake2b256
@@ -249,6 +253,10 @@ func (t ShelleyTransaction) Outputs() []TransactionOutput {
249253
return t.Body.Outputs()
250254
}
251255

256+
func (t ShelleyTransaction) Fee() uint64 {
257+
return t.Body.Fee()
258+
}
259+
252260
func (t ShelleyTransaction) Metadata() *cbor.Value {
253261
return t.TxMetadata
254262
}

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)