MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / queueReceiveTransaction

Method queueReceiveTransaction

lineage.go:722–745  ·  view source on GitHub ↗

queueReceiveTransaction queues a transaction to receive funds into the destination's shadow balance. Parameters: - ctx context.Context: The context for the operation. - txn *model.Transaction: The original transaction. - alloc Allocation: The allocation details. - mapping *model.LineageMapping: The

(ctx context.Context, txn *model.Transaction, alloc Allocation, mapping *model.LineageMapping, sourceBalance, destinationBalance, destShadowBalance, destAggBalance *model.Balance, index int)

Source from the content-addressed store, hash-verified

720// Returns:
721// - error: An error if the transaction could not be queued.
722func (l *LedgerForge) queueReceiveTransaction(ctx context.Context, txn *model.Transaction, alloc Allocation, mapping *model.LineageMapping, sourceBalance, destinationBalance, destShadowBalance, destAggBalance *model.Balance, index int) error {
723 receiveTxn := &model.Transaction{
724 Source: destShadowBalance.BalanceID,
725 Destination: destAggBalance.BalanceID,
726 PreciseAmount: new(big.Int).Set(alloc.Amount),
727 Currency: destinationBalance.Currency,
728 Precision: txn.Precision,
729 Reference: fmt.Sprintf("%s_receive_%s_%d", txn.Reference, mapping.Provider, index),
730 Description: fmt.Sprintf("Receive %s funds", mapping.Provider),
731 MetaData: map[string]interface{}{
732 "_shadow_for": txn.TransactionID,
733 "_provider": mapping.Provider,
734 "_lineage_type": "receive",
735 "_main_balance": destinationBalance.BalanceID,
736 "_from_balance": sourceBalance.BalanceID,
737 },
738 AllowOverdraft: true,
739 SkipQueue: true,
740 Inflight: txn.Inflight,
741 }
742
743 _, err := l.QueueTransaction(ctx, receiveTxn)
744 return err
745}
746
747// updateFundAllocationMetadata updates the transaction metadata with fund allocation details.
748//

Callers 1

Calls 2

QueueTransactionMethod · 0.95
SetMethod · 0.65

Tested by

no test coverage detected