Skip to content

Commit 667e480

Browse files
committed
fix(ledger) tx reversion handles empty middle accounts
1 parent a929bff commit 667e480

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

internal/controller/ledger/controller_default.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,13 @@ func (ctrl *DefaultController) revertTransaction(ctx context.Context, store Stor
406406
balances[posting.Source][posting.Asset],
407407
big.NewInt(0).Neg(posting.Amount),
408408
)
409+
if _, ok := balances[posting.Destination]; ok {
410+
// if destination is also a source in some posting, since balances should only contain posting sources
411+
balances[posting.Destination][posting.Asset] = balances[posting.Destination][posting.Asset].Add(
412+
balances[posting.Destination][posting.Asset],
413+
posting.Amount,
414+
)
415+
}
409416
}
410417

411418
for account, forAccount := range balances {

0 commit comments

Comments
 (0)