diff --git a/ledger/allegra.go b/ledger/allegra.go index 244dcc56..ed445bfd 100644 --- a/ledger/allegra.go +++ b/ledger/allegra.go @@ -174,6 +174,10 @@ func (t AllegraTransaction) Certificates() []Certificate { return t.Body.Certificates() } +func (t AllegraTransaction) Withdrawals() map[*Address]uint64 { + return t.Body.Withdrawals() +} + func (t AllegraTransaction) Metadata() *cbor.Value { return t.TxMetadata } diff --git a/ledger/alonzo.go b/ledger/alonzo.go index fd0089e6..57edbac9 100644 --- a/ledger/alonzo.go +++ b/ledger/alonzo.go @@ -284,6 +284,10 @@ func (t AlonzoTransaction) Certificates() []Certificate { return t.Body.Certificates() } +func (t AlonzoTransaction) Withdrawals() map[*Address]uint64 { + return t.Body.Withdrawals() +} + func (t AlonzoTransaction) Metadata() *cbor.Value { return t.TxMetadata } diff --git a/ledger/babbage.go b/ledger/babbage.go index 9c242b77..9c6a64e2 100644 --- a/ledger/babbage.go +++ b/ledger/babbage.go @@ -460,6 +460,10 @@ func (t BabbageTransaction) Certificates() []Certificate { return t.Body.Certificates() } +func (t BabbageTransaction) Withdrawals() map[*Address]uint64 { + return t.Body.Withdrawals() +} + func (t BabbageTransaction) Metadata() *cbor.Value { return t.TxMetadata } diff --git a/ledger/byron.go b/ledger/byron.go index 1f4463c7..5b7bb07f 100644 --- a/ledger/byron.go +++ b/ledger/byron.go @@ -195,6 +195,11 @@ func (t *ByronTransaction) Certificates() []Certificate { return nil } +func (t *ByronTransaction) Withdrawals() map[*Address]uint64 { + // No withdrawals in Byron + return nil +} + func (t *ByronTransaction) Metadata() *cbor.Value { return t.Attributes } diff --git a/ledger/conway.go b/ledger/conway.go index b7f6e5cb..3e88a5af 100644 --- a/ledger/conway.go +++ b/ledger/conway.go @@ -180,6 +180,10 @@ func (t ConwayTransaction) Certificates() []Certificate { return t.Body.Certificates() } +func (t ConwayTransaction) Withdrawals() map[*Address]uint64 { + return t.Body.Withdrawals() +} + func (t ConwayTransaction) Metadata() *cbor.Value { return t.TxMetadata } diff --git a/ledger/mary.go b/ledger/mary.go index d4591fd6..6f0d6617 100644 --- a/ledger/mary.go +++ b/ledger/mary.go @@ -191,6 +191,10 @@ func (t MaryTransaction) Certificates() []Certificate { return t.Body.Certificates() } +func (t MaryTransaction) Withdrawals() map[*Address]uint64 { + return t.Body.Withdrawals() +} + func (t MaryTransaction) Metadata() *cbor.Value { return t.TxMetadata } diff --git a/ledger/shelley.go b/ledger/shelley.go index f812b6dd..fcd82494 100644 --- a/ledger/shelley.go +++ b/ledger/shelley.go @@ -168,11 +168,8 @@ type ShelleyTransactionBody struct { TxFee uint64 `cbor:"2,keyasint,omitempty"` Ttl uint64 `cbor:"3,keyasint,omitempty"` TxCertificates []CertificateWrapper `cbor:"4,keyasint,omitempty"` - // TODO: figure out how to parse this correctly - // We keep the raw CBOR because it can contain a map with []byte keys, which - // Go does not allow - Withdrawals cbor.Value `cbor:"5,keyasint,omitempty"` - Update struct { + TxWithdrawals map[*Address]uint64 `cbor:"5,keyasint,omitempty"` + Update struct { cbor.StructAsArray ProtocolParamUpdates map[Blake2b224]ShelleyProtocolParameterUpdate Epoch uint64 @@ -243,6 +240,10 @@ func (b *ShelleyTransactionBody) Certificates() []Certificate { return ret } +func (b *ShelleyTransactionBody) Withdrawals() map[*Address]uint64 { + return b.TxWithdrawals +} + func (b *ShelleyTransactionBody) Utxorpc() *utxorpc.Tx { var txi []*utxorpc.TxInput var txo []*utxorpc.TxOutput @@ -397,6 +398,10 @@ func (t ShelleyTransaction) Certificates() []Certificate { return t.Body.Certificates() } +func (t ShelleyTransaction) Withdrawals() map[*Address]uint64 { + return t.Body.Withdrawals() +} + func (t ShelleyTransaction) Metadata() *cbor.Value { return t.TxMetadata } diff --git a/ledger/tx.go b/ledger/tx.go index 5c5e05b2..b8caf324 100644 --- a/ledger/tx.go +++ b/ledger/tx.go @@ -45,6 +45,7 @@ type TransactionBody interface { CollateralReturn() TransactionOutput TotalCollateral() uint64 Certificates() []Certificate + Withdrawals() map[*Address]uint64 Utxorpc() *utxorpc.Tx }