queueReleaseTransaction queues a transaction to release funds from the aggregate balance back to a shadow balance. Parameters: - ctx context.Context: The context for the operation. - txn *model.Transaction: The original transaction. - alloc Allocation: The allocation details. - mapping *model.Linea
(ctx context.Context, txn *model.Transaction, alloc Allocation, mapping *model.LineageMapping, sourceBalance, sourceAggBalance *model.Balance, index int)
| 595 | // Returns: |
| 596 | // - error: An error if the transaction could not be queued. |
| 597 | func (l *LedgerForge) queueReleaseTransaction(ctx context.Context, txn *model.Transaction, alloc Allocation, mapping *model.LineageMapping, sourceBalance, sourceAggBalance *model.Balance, index int) error { |
| 598 | releaseTxn := &model.Transaction{ |
| 599 | Source: sourceAggBalance.BalanceID, |
| 600 | Destination: alloc.BalanceID, |
| 601 | PreciseAmount: new(big.Int).Set(alloc.Amount), |
| 602 | Currency: sourceBalance.Currency, |
| 603 | Precision: txn.Precision, |
| 604 | Reference: fmt.Sprintf("%s_release_%s_%d", txn.Reference, mapping.Provider, index), |
| 605 | Description: fmt.Sprintf("Release %s funds", mapping.Provider), |
| 606 | MetaData: map[string]interface{}{ |
| 607 | "_shadow_for": txn.TransactionID, |
| 608 | "_provider": mapping.Provider, |
| 609 | "_lineage_type": "release", |
| 610 | "_main_balance": sourceBalance.BalanceID, |
| 611 | "_allocation": sourceBalance.AllocationStrategy, |
| 612 | }, |
| 613 | SkipQueue: true, |
| 614 | Inflight: txn.Inflight, |
| 615 | } |
| 616 | |
| 617 | _, err := l.QueueTransaction(ctx, releaseTxn) |
| 618 | return err |
| 619 | } |
| 620 | |
| 621 | // processDestinationLineage processes lineage tracking for the destination balance when it also tracks fund lineage. |
| 622 | // Uses pre-created destination balances to avoid nested lock acquisition (locks are already held by caller). |
no test coverage detected