Skip to content

Commit

Permalink
feat: transaction fee
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Gianelloni <wolf31o2@blinklabs.io>
  • Loading branch information
wolf31o2 committed Oct 16, 2023
1 parent 54800ce commit d3cee38
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ledger/allegra.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ func (t AllegraTransaction) Outputs() []TransactionOutput {
return t.Body.Outputs()
}

func (t AllegraTransaction) Fee() uint64 {
return t.Body.Fee()
}

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 @@ -204,6 +204,10 @@ func (t AlonzoTransaction) Outputs() []TransactionOutput {
return t.Body.Outputs()
}

func (t AlonzoTransaction) Fee() uint64 {
return t.Body.Fee()
}

func (t AlonzoTransaction) Metadata() *cbor.Value {
return t.TxMetadata
}
Expand Down
4 changes: 4 additions & 0 deletions ledger/babbage.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,10 @@ func (t BabbageTransaction) Outputs() []TransactionOutput {
return t.Body.Outputs()
}

func (t BabbageTransaction) Fee() uint64 {
return t.Body.Fee()
}

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 @@ -124,6 +124,11 @@ func (t *ByronTransaction) Outputs() []TransactionOutput {
return nil
}

func (t *ByronTransaction) Fee() uint64 {
// TODO
return 0
}

func (t *ByronTransaction) Metadata() *cbor.Value {
return t.Attributes
}
Expand Down
4 changes: 4 additions & 0 deletions ledger/mary.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ func (t MaryTransaction) Outputs() []TransactionOutput {
return t.Body.Outputs()
}

func (t MaryTransaction) Fee() uint64 {
return t.Body.Fee()
}

func (t MaryTransaction) Metadata() *cbor.Value {
return t.TxMetadata
}
Expand Down
10 changes: 9 additions & 1 deletion ledger/shelley.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ type ShelleyTransactionBody struct {
hash string
TxInputs []ShelleyTransactionInput `cbor:"0,keyasint,omitempty"`
TxOutputs []ShelleyTransactionOutput `cbor:"1,keyasint,omitempty"`
Fee uint64 `cbor:"2,keyasint,omitempty"`
TxFee uint64 `cbor:"2,keyasint,omitempty"`
Ttl uint64 `cbor:"3,keyasint,omitempty"`
// TODO: figure out how to parse properly
Certificates cbor.RawMessage `cbor:"4,keyasint,omitempty"`
Expand Down Expand Up @@ -169,6 +169,10 @@ func (b *ShelleyTransactionBody) Outputs() []TransactionOutput {
return ret
}

func (b *ShelleyTransactionBody) Fee() uint64 {
return b.TxFee
}

type ShelleyTransactionInput struct {
cbor.StructAsArray
TxId Blake2b256
Expand Down Expand Up @@ -249,6 +253,10 @@ func (t ShelleyTransaction) Outputs() []TransactionOutput {
return t.Body.Outputs()
}

func (t ShelleyTransaction) Fee() uint64 {
return t.Body.Fee()
}

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 @@ -32,6 +32,7 @@ type TransactionBody interface {
Cbor() []byte
Inputs() []TransactionInput
Outputs() []TransactionOutput
Fee() uint64
}

type TransactionInput interface {
Expand Down

0 comments on commit d3cee38

Please sign in to comment.