Versions in this module Expand all Collapse all v1 v1.0.0 Oct 10, 2026 Changes in this version + const AllocationFIFO + const AllocationLIFO + const AllocationProp + const GeneralLedgerID + const IndexModeRefresh + const InflightActionCommit + const InflightActionVoid + const LineageFundAllocation + const LineageProviderKey + const StatusApplied + const StatusCommit + const StatusCompleted + const StatusFailed + const StatusInProgress + const StatusInflight + const StatusQueued + const StatusRejected + const StatusScheduled + const StatusStarted + const StatusVoid + var ErrEntityNotFound = errors.New("entity not found") + var ErrInflightActionQueued = errors.New("a commit or void is already queued for this transaction") + var ErrQueueBackpressure = errors.New("queue backpressure: redis memory or pending task limit reached") + var SQLFiles embed.FS + func ClassifyInflightError(err error) string + func DocumentToIndexMap(document interface{}) (map[string]interface{}, error) + func IsDuplicateReferenceError(err error) bool + func IsInflightTransaction(transaction *model.Transaction) bool + func NewBalanceTracker() *model.BalanceTracker + type Allocation struct + Amount *big.Int + BalanceID string + type BalanceLineage struct + AggregateBalanceID string + BalanceID string + Providers []ProviderBreakdown + TotalWithLineage *big.Int + type BatchJobResult struct + Error error + Txn *model.Transaction + type BulkInflightAction int + const BulkInflightCommit + const BulkInflightVoid + type BulkInflightItem struct + Amount *big.Int + TransactionID string + type BulkInflightOutcome struct + Code string + Err error + TransactionID string + Txn *model.Transaction + type BulkTransactionError struct + Message string + func (e *BulkTransactionError) Error() string + func (e *BulkTransactionError) Unwrap() error + type ChainProcessor struct + func NewChainProcessor(ledgerforge *LedgerForge) *ChainProcessor + func (p *ChainProcessor) IsRunning() bool + func (p *ChainProcessor) Start(ctx context.Context) + func (p *ChainProcessor) Stop() + type ChainVerifyResult = model.ChainVerifyResult + type IndexTask struct + Collection string + DocumentID string + Mode string + Payload map[string]interface{} + ScopeID string + type IndexUpserter func(ctx context.Context, collection string, document interface{}) error + type InflightActionPayload struct + Action string + ActionID string + PreciseAmount string + TransactionID string + type LedgerForge struct + Hooks hooks.HookManager + func NewLedgerForge(db database.IDataSource) (*LedgerForge, error) + func (b *LedgerForge) Close() error + func (b *LedgerForge) Config() *config.Configuration + func (b *LedgerForge) CreateMatchingRule(ctx context.Context, rule model.MatchingRule) (*model.MatchingRule, error) + func (b *LedgerForge) DeleteMatchingRule(ctx context.Context, id string) error + func (b *LedgerForge) GetDataSource() database.IDataSource + func (b *LedgerForge) GetMatchingRule(ctx context.Context, id string) (*model.MatchingRule, error) + func (b *LedgerForge) GetReconciliation(ctx context.Context, id string) (*model.Reconciliation, error) + func (b *LedgerForge) GetReindexProgress() (search.ReindexProgress, error) + func (b *LedgerForge) GetSearchClient() *search.TypesenseClient + func (b *LedgerForge) ListMatchingRules(ctx context.Context) ([]*model.MatchingRule, error) + func (b *LedgerForge) ProcessWebhook(ctx context.Context, task *asynq.Task) error + func (b *LedgerForge) RecoverQueuedTransactions(ctx context.Context, threshold time.Duration) (int, error) + func (b *LedgerForge) SendWebhook(newWebhook NewWebhook) error + func (b *LedgerForge) StartInstantReconciliation(ctx context.Context, transactions []model.ExternalTransaction, ...) (string, error) + func (b *LedgerForge) StartReconciliation(ctx context.Context, uploadID, strategy, groupCriteria string, ...) (string, error) + func (b *LedgerForge) StartReindex(batchSize int) (search.ReindexProgress, error) + func (b *LedgerForge) TryReindexIfNeeded(ctx context.Context) + func (b *LedgerForge) UpdateMatchingRule(ctx context.Context, rule model.MatchingRule) (*model.MatchingRule, error) + func (b *LedgerForge) UploadExternalData(ctx context.Context, source string, reader io.Reader, filename string) (string, int, error) + func (l *LedgerForge) BulkInflightUpdate(ctx context.Context, action BulkInflightAction, items []BulkInflightItem, ...) ([]BulkInflightOutcome, error) + func (l *LedgerForge) CommitInflightTransaction(ctx context.Context, transactionID string, amount *big.Int) (*model.Transaction, error) + func (l *LedgerForge) CommitInflightTransactionWithQueue(ctx context.Context, transactionID string, amount *big.Int) (*model.Transaction, error) + func (l *LedgerForge) CommitInflightTransactionWithRef(ctx context.Context, transactionID string, amount *big.Int, reference string) (*model.Transaction, error) + func (l *LedgerForge) CommitWorker(ctx context.Context, jobs <-chan *model.Transaction, ...) + func (l *LedgerForge) CreateAPIKey(ctx context.Context, name, ownerID string, scopes []string, ...) (*model.APIKey, error) + func (l *LedgerForge) CreateAccount(account model.Account) (model.Account, error) + func (l *LedgerForge) CreateBalance(ctx context.Context, balance model.Balance) (model.Balance, error) + func (l *LedgerForge) CreateBulkTransactions(ctx context.Context, req *model.BulkTransactionRequest) (*model.BulkTransactionResult, error) + func (l *LedgerForge) CreateIdentity(identity model.Identity) (model.Identity, error) + func (l *LedgerForge) CreateLedger(ledger model.Ledger) (model.Ledger, error) + func (l *LedgerForge) CreateMonitor(ctx context.Context, monitor model.BalanceMonitor) (model.BalanceMonitor, error) + func (l *LedgerForge) DecidePolicyApproval(ctx context.Context, id string, approve bool) (*model.PolicyAdmission, error) + func (l *LedgerForge) DeleteIdentity(id string) error + func (l *LedgerForge) DeleteKeyPolicy(ctx context.Context, key string) error + func (l *LedgerForge) DeleteMonitor(ctx context.Context, id string) error + func (l *LedgerForge) DetokenizeIdentity(identityID string) (map[string]string, error) + func (l *LedgerForge) DetokenizeIdentityField(identityID, fieldName string) (string, error) + func (l *LedgerForge) GetAPIKeyByKey(ctx context.Context, key string) (*model.APIKey, error) + func (l *LedgerForge) GetAccount(id string, include []string) (*model.Account, error) + func (l *LedgerForge) GetAccountByNumber(id string) (*model.Account, error) + func (l *LedgerForge) GetAllAccounts() ([]model.Account, error) + func (l *LedgerForge) GetAllAccountsWithFilter(ctx context.Context, filters *filter.QueryFilterSet, limit, offset int) ([]model.Account, error) + func (l *LedgerForge) GetAllAccountsWithFilterAndOptions(ctx context.Context, filters *filter.QueryFilterSet, opts *filter.QueryOptions, ...) ([]model.Account, *int64, error) + func (l *LedgerForge) GetAllBalances(ctx context.Context, limit, offset int) ([]model.Balance, error) + func (l *LedgerForge) GetAllBalancesWithFilter(ctx context.Context, filters *filter.QueryFilterSet, limit, offset int) ([]model.Balance, error) + func (l *LedgerForge) GetAllBalancesWithFilterAndOptions(ctx context.Context, filters *filter.QueryFilterSet, opts *filter.QueryOptions, ...) ([]model.Balance, *int64, error) + func (l *LedgerForge) GetAllIdentities() ([]model.Identity, error) + func (l *LedgerForge) GetAllIdentitiesWithFilter(ctx context.Context, filters *filter.QueryFilterSet, limit, offset int) ([]model.Identity, error) + func (l *LedgerForge) GetAllIdentitiesWithFilterAndOptions(ctx context.Context, filters *filter.QueryFilterSet, opts *filter.QueryOptions, ...) ([]model.Identity, *int64, error) + func (l *LedgerForge) GetAllLedgers(limit, offset int) ([]model.Ledger, error) + func (l *LedgerForge) GetAllLedgersWithFilter(ctx context.Context, filters *filter.QueryFilterSet, limit, offset int) ([]model.Ledger, error) + func (l *LedgerForge) GetAllLedgersWithFilterAndOptions(ctx context.Context, filters *filter.QueryFilterSet, opts *filter.QueryOptions, ...) ([]model.Ledger, *int64, error) + func (l *LedgerForge) GetAllMonitors(ctx context.Context) ([]model.BalanceMonitor, error) + func (l *LedgerForge) GetAllTransactions(limit, offset int) ([]model.Transaction, error) + func (l *LedgerForge) GetAllTransactionsWithFilter(ctx context.Context, filters *filter.QueryFilterSet, limit, offset int) ([]model.Transaction, error) + func (l *LedgerForge) GetAllTransactionsWithFilterAndOptions(ctx context.Context, filters *filter.QueryFilterSet, opts *filter.QueryOptions, ...) ([]model.Transaction, *int64, error) + func (l *LedgerForge) GetBalanceAtTime(ctx context.Context, balanceID string, targetTime time.Time, fromSource bool) (*model.Balance, error) + func (l *LedgerForge) GetBalanceByID(ctx context.Context, id string, include []string, withQueued bool) (*model.Balance, error) + func (l *LedgerForge) GetBalanceByIndicator(ctx context.Context, indicator, currency string) (*model.Balance, error) + func (l *LedgerForge) GetBalanceLineage(ctx context.Context, balanceID string) (*BalanceLineage, error) + func (l *LedgerForge) GetBalanceMonitors(ctx context.Context, balanceID string) ([]model.BalanceMonitor, error) + func (l *LedgerForge) GetDetokenizedIdentity(identityID string) (*model.Identity, error) + func (l *LedgerForge) GetIdentity(id string) (*model.Identity, error) + func (l *LedgerForge) GetInflightTransactionsByParentID(ctx context.Context, parentTransactionID string, batchSize int, offset int64) ([]*model.Transaction, error) + func (l *LedgerForge) GetKeyPolicy(ctx context.Context, key string) (*model.KeyPolicy, error) + func (l *LedgerForge) GetLedgerByID(id string) (*model.Ledger, error) + func (l *LedgerForge) GetMonitorByID(ctx context.Context, id string) (*model.BalanceMonitor, error) + func (l *LedgerForge) GetRefundableTransactionsByParentID(ctx context.Context, parentTransactionID string, batchSize int, offset int64) ([]*model.Transaction, error) + func (l *LedgerForge) GetTransaction(ctx context.Context, TransactionID string) (*model.Transaction, error) + func (l *LedgerForge) GetTransactionByRef(ctx context.Context, reference string) (model.Transaction, error) + func (l *LedgerForge) GetTransactionLineage(ctx context.Context, transactionID string) (*TransactionLineage, error) + func (l *LedgerForge) ListAPIKeys(ctx context.Context, ownerID string) ([]*model.APIKey, error) + func (l *LedgerForge) ListPolicyApprovals(ctx context.Context) ([]model.PolicyAdmission, error) + func (l *LedgerForge) MultiSearch(searchParams *api.MultiSearchSearchesParameter) (*api.MultiSearchResult, error) + func (l *LedgerForge) PolicyCapacity(ctx context.Context, key string) ([]model.PolicyCapacity, error) + func (l *LedgerForge) PrepareLineageOutbox(ctx context.Context, txn *model.Transaction, ...) *model.LineageOutbox + func (l *LedgerForge) PreviewBulkTransactions(ctx context.Context, request *model.BulkTransactionRequest) (*model.BulkTransactionPreview, error) + func (l *LedgerForge) PreviewInflightAction(ctx context.Context, txID, action string, amount *big.Int) (*model.TransactionPreview, error) + func (l *LedgerForge) PreviewRefund(ctx context.Context, transactionID string) (*model.TransactionPreview, error) + func (l *LedgerForge) PreviewTransaction(ctx context.Context, transaction *model.Transaction) (*model.TransactionPreview, error) + func (l *LedgerForge) ProcessIndexTask(ctx context.Context, task IndexTask, upsert IndexUpserter) error + func (l *LedgerForge) ProcessLineageFromOutbox(ctx context.Context, entry model.LineageOutbox) error + func (l *LedgerForge) ProcessQueuedTransaction(ctx context.Context, transaction *model.Transaction, hotLane bool) (*model.Transaction, error) + func (l *LedgerForge) ProcessRefundsInBatches(ctx context.Context, parentTransactionID string, opts RefundOptions) ([]*model.Transaction, error) + func (l *LedgerForge) ProcessTransactionInBatches(ctx context.Context, parentTransactionID string, amount *big.Int, ...) ([]*model.Transaction, error) + func (l *LedgerForge) PutKeyPolicy(ctx context.Context, p model.KeyPolicy) (*model.KeyPolicy, error) + func (l *LedgerForge) QueueInflightAction(ctx context.Context, transactionID string, amount *big.Int, action string) (*model.Transaction, error) + func (l *LedgerForge) QueueTransaction(ctx context.Context, transaction *model.Transaction) (*model.Transaction, error) + func (l *LedgerForge) RecordTransaction(ctx context.Context, transaction *model.Transaction) (*model.Transaction, error) + func (l *LedgerForge) RefundTransaction(ctx context.Context, transactionID string, skipQueue bool) (*model.Transaction, error) + func (l *LedgerForge) RefundTransactionWithOptions(ctx context.Context, transactionID string, opts RefundOptions) (*model.Transaction, error) + func (l *LedgerForge) RefundWorker(ctx context.Context, jobs <-chan *model.Transaction, ...) + func (l *LedgerForge) RefundWorkerWithOptions(skipQueue bool) transactionWorker + func (l *LedgerForge) RefundWorkerWithRefundOptions(opts RefundOptions) transactionWorker + func (l *LedgerForge) RejectTransaction(ctx context.Context, transaction *model.Transaction, reason string) (*model.Transaction, error) + func (l *LedgerForge) RevokeAPIKey(ctx context.Context, id, ownerID string) error + func (l *LedgerForge) RunInflightActionByParent(ctx context.Context, parentTransactionID, action string, amount *big.Int, ...) (retryable bool, err error) + func (l *LedgerForge) Search(collection string, query *api.SearchCollectionParams) (interface{}, error) + func (l *LedgerForge) TakeBalanceSnapshots(ctx context.Context, batchSize int) + func (l *LedgerForge) TokenizeAllPII(identityID string) error + func (l *LedgerForge) TokenizeIdentity(identityID string, fields []string) error + func (l *LedgerForge) TokenizeIdentityField(identityID, fieldName string) error + func (l *LedgerForge) TryRecordQueuedTransactionBatch(ctx context.Context, transaction *model.Transaction) (handled bool, err error) + func (l *LedgerForge) TryRecordQueuedTransactionBatchForHotLane(ctx context.Context, transaction *model.Transaction) (handled bool, err error) + func (l *LedgerForge) UpdateBalanceIdentity(balanceID, identityID string) error + func (l *LedgerForge) UpdateIdentity(identity *model.Identity) error + func (l *LedgerForge) UpdateLastUsed(ctx context.Context, id string) error + func (l *LedgerForge) UpdateLedger(id, name string) (*model.Ledger, error) + func (l *LedgerForge) UpdateMetadata(ctx context.Context, entityID string, newMetadata map[string]interface{}) (map[string]interface{}, error) + func (l *LedgerForge) UpdateMonitor(ctx context.Context, monitor *model.BalanceMonitor) error + func (l *LedgerForge) VerifyChain(ctx context.Context, progress func(seq int64)) (ChainVerifyResult, error) + func (l *LedgerForge) VoidInflightTransaction(ctx context.Context, transactionID string) (*model.Transaction, error) + func (l *LedgerForge) VoidInflightTransactionWithRef(ctx context.Context, transactionID string, reference string) (*model.Transaction, error) + func (l *LedgerForge) VoidWorker(ctx context.Context, jobs <-chan *model.Transaction, ...) + type LineageOutboxPayload struct + Amount float64 + Currency string + Inflight bool + PreciseAmount string + Precision float64 + Reference string + SkipQueue bool + type LineageOutboxProcessor struct + func NewLineageOutboxProcessor(ledgerforge *LedgerForge) *LineageOutboxProcessor + func (p *LineageOutboxProcessor) IsRunning() bool + func (p *LineageOutboxProcessor) Start(ctx context.Context) + func (p *LineageOutboxProcessor) Stop() + func (p *LineageOutboxProcessor) WithBatchSize(size int) *LineageOutboxProcessor + func (p *LineageOutboxProcessor) WithLockDuration(duration time.Duration) *LineageOutboxProcessor + func (p *LineageOutboxProcessor) WithPollInterval(interval time.Duration) *LineageOutboxProcessor + type LineageSource struct + Balance *big.Int + BalanceID string + CreatedAt time.Time + type NewWebhook struct + Event string + Payload interface{} + type ProviderBreakdown struct + Amount *big.Int + Available *big.Int + BalanceID string + Provider string + Spent *big.Int + type Queue struct + Client *asynq.Client + Inspector *asynq.Inspector + func NewQueue(conf *config.Configuration, client *asynq.Client, ...) *Queue + func (q *Queue) Enqueue(ctx context.Context, transaction *model.Transaction) error + func (q *Queue) EnqueueInflightAction(ctx context.Context, p InflightActionPayload) error + func (q *Queue) GetTransactionFromQueue(transactionID string) (*model.Transaction, error) + func (q *Queue) QueueInflightCommit(ctx context.Context, transaction *model.Transaction) error + func (q *Queue) QueueInflightExpiry(ctx context.Context, transaction *model.Transaction) error + type QueuedTransactionRecoveryProcessor struct + func NewQueuedTransactionRecoveryProcessor(ledgerforge *LedgerForge) *QueuedTransactionRecoveryProcessor + func (p *QueuedTransactionRecoveryProcessor) IsRunning() bool + func (p *QueuedTransactionRecoveryProcessor) Start(ctx context.Context) + func (p *QueuedTransactionRecoveryProcessor) Stop() + type RefundOptions struct + Description string + MetaData map[string]interface{} + SkipQueue bool + type TransactionLineage struct + FundAllocation []map[string]interface{} + ShadowTransactions []model.Transaction + TransactionID string + type TransactionTypePayload struct + Data model.Transaction