Skip to content

Commit

Permalink
fix(ledger) tx reversion handles empty middle accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
CrosleyZack committed Feb 25, 2025
1 parent a929bff commit 667e480
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/controller/ledger/controller_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,13 @@ func (ctrl *DefaultController) revertTransaction(ctx context.Context, store Stor
balances[posting.Source][posting.Asset],
big.NewInt(0).Neg(posting.Amount),
)
if _, ok := balances[posting.Destination]; ok {
// if destination is also a source in some posting, since balances should only contain posting sources
balances[posting.Destination][posting.Asset] = balances[posting.Destination][posting.Asset].Add(
balances[posting.Destination][posting.Asset],
posting.Amount,
)
}

Check warning on line 415 in internal/controller/ledger/controller_default.go

View check run for this annotation

Codecov / codecov/patch

internal/controller/ledger/controller_default.go#L410-L415

Added lines #L410 - L415 were not covered by tests
}

for account, forAccount := range balances {
Expand Down

0 comments on commit 667e480

Please sign in to comment.