Skip to content

Commit 7e44524

Browse files
authored
feat: add withdrawals field to transaction events (#310)
* feat: add withdrawals field to transaction events Added support for staking withdrawals in transaction events. Withdrawal data was already available from gouroboros and is now propagated through adder's events. * fix: update check for withdrawals len Somehow committed an earlier version 🤦 Fixed
1 parent 9bab858 commit 7e44524

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

input/chainsync/tx.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ type TransactionEvent struct {
3939
Fee uint64 `json:"fee"`
4040
TTL uint64 `json:"ttl,omitempty"`
4141
ResolvedInputs []ledger.TransactionOutput `json:"resolvedInputs,omitempty"`
42+
Withdrawals map[string]uint64 `json:"withdrawals,omitempty"`
4243
}
4344

4445
func NewTransactionContext(
@@ -88,5 +89,11 @@ func NewTransactionEvent(
8889
if len(resolvedInputs) > 0 {
8990
evt.ResolvedInputs = resolvedInputs
9091
}
92+
if withdrawals := tx.Withdrawals(); len(withdrawals) > 0{
93+
evt.Withdrawals = make(map[string]uint64)
94+
for addr, amount := range withdrawals {
95+
evt.Withdrawals[addr.String()] = amount
96+
}
97+
}
9198
return evt
9299
}

0 commit comments

Comments
 (0)