getOrCreateDestinationLineageBalances retrieves or creates shadow and aggregate balances for the destination. Parameters: - ctx context.Context: The context for the operation. - provider string: The fund provider identifier. - destinationBalance *model.Balance: The destination balance. Returns: -
(ctx context.Context, provider string, destinationBalance *model.Balance)
| 681 | // - *model.Balance: The destination aggregate balance. |
| 682 | // - error: An error if the balances could not be retrieved or created. |
| 683 | func (l *LedgerForge) getOrCreateDestinationLineageBalances(ctx context.Context, provider string, destinationBalance *model.Balance) (*model.Balance, *model.Balance, error) { |
| 684 | destIdentity, err := l.datasource.GetIdentityByID(destinationBalance.IdentityID) |
| 685 | if err != nil { |
| 686 | return nil, nil, fmt.Errorf("failed to get destination identity: %w", err) |
| 687 | } |
| 688 | |
| 689 | destIdentifier := l.getIdentityIdentifier(destIdentity) |
| 690 | destShadowIndicator := fmt.Sprintf("@%s_%s_lineage", provider, destIdentifier) |
| 691 | destAggIndicator := fmt.Sprintf("@%s_lineage", destIdentifier) |
| 692 | |
| 693 | destShadowBalance, err := l.getOrCreateBalanceByIndicator(ctx, destShadowIndicator, destinationBalance.Currency) |
| 694 | if err != nil { |
| 695 | return nil, nil, fmt.Errorf("failed to create destination shadow balance: %w", err) |
| 696 | } |
| 697 | |
| 698 | destAggBalance, err := l.getOrCreateBalanceByIndicator(ctx, destAggIndicator, destinationBalance.Currency) |
| 699 | if err != nil { |
| 700 | return nil, nil, fmt.Errorf("failed to create destination aggregate balance: %w", err) |
| 701 | } |
| 702 | |
| 703 | return destShadowBalance, destAggBalance, nil |
| 704 | } |
| 705 | |
| 706 | // queueReceiveTransaction queues a transaction to receive funds into the destination's shadow balance. |
| 707 | // |
no test coverage detected