Versions in this module Expand all Collapse all v1 v1.0.0 Oct 10, 2026 Changes in this version + var ErrAPIKeyNotFound = errors.New("api key not found") + var ErrInvalidAPIKey = errors.New("invalid api key") + var ErrLegacyAPIKeyVerificationBusy = errors.New("legacy API key verification is busy") + func ConnectDB(dsConfig config.DataSourceConfig) (*sql.DB, error) + type Datasource struct + Cache cache.Cache + Conn *sql.DB + func GetDBConnection(configuration *config.Configuration) (*Datasource, error) + func (d *Datasource) AdmitPolicy(ctx context.Context, key, identity string, legs []model.PolicyLeg) (*model.PolicyAdmission, error) + func (d *Datasource) CheckPolicyCommit(ctx context.Context, id string) error + func (d *Datasource) Close() error + func (d *Datasource) DecidePolicyApproval(ctx context.Context, id string, p policy.Principal, approve bool) (*model.PolicyAdmission, error) + func (d *Datasource) DeleteKeyPolicy(ctx context.Context, id string) error + func (d *Datasource) GetKeyPolicy(ctx context.Context, id string) (*model.KeyPolicy, error) + func (d *Datasource) ListPolicyApprovals(ctx context.Context, key string) ([]model.PolicyAdmission, error) + func (d *Datasource) ListTransactionsByMetadataScope(ctx context.Context, scopeID string, limit int, offset int64) ([]*model.Transaction, error) + func (d *Datasource) PolicyCapacity(ctx context.Context, key string) ([]model.PolicyCapacity, error) + func (d *Datasource) PolicyHoldIDs(ctx context.Context, id string) ([]string, error) + func (d *Datasource) PutKeyPolicy(ctx context.Context, p model.KeyPolicy) (*model.KeyPolicy, error) + func (d *Datasource) ReleasePolicyLeg(ctx context.Context, id string) error + func (d *Datasource) UpdateBalanceMetadata(ctx context.Context, id string, metadata map[string]interface{}) error + func (d *Datasource) UpdateIdentityMetadata(id string, metadata map[string]interface{}) error + func (d *Datasource) UpdateLedgerMetadata(id string, metadata map[string]interface{}) error + func (d *Datasource) UpdateTransactionMetadata(ctx context.Context, id string, metadata map[string]interface{}) error + func (d *Datasource) VerifyPolicyLeg(ctx context.Context, t *model.Transaction) (*model.PolicyAdmission, error) + func (d Datasource) ChainPendingTransactions(ctx context.Context, cutoff time.Time, batchSize int) (int, error) + func (d Datasource) ClaimPendingOutboxEntries(ctx context.Context, batchSize int, lockDuration time.Duration) ([]model.LineageOutbox, error) + func (d Datasource) CountQueuedTransactionsForPairLane(ctx context.Context, source, destination, currency, lane string) (int, error) + func (d Datasource) CountUnchainedTransactions(ctx context.Context, cutoff time.Time) (int64, error) + func (d Datasource) CreateAccount(account model.Account) (model.Account, error) + func (d Datasource) CreateBalance(balance model.Balance) (model.Balance, error) + func (d Datasource) CreateIdentity(identity model.Identity) (model.Identity, error) + func (d Datasource) CreateLedger(ledger model.Ledger) (model.Ledger, error) + func (d Datasource) CreateMonitor(monitor model.BalanceMonitor) (model.BalanceMonitor, error) + func (d Datasource) DeleteAccount(id string) error + func (d Datasource) DeleteIdentity(id string) error + func (d Datasource) DeleteLineageMapping(ctx context.Context, id int64) error + func (d Datasource) DeleteMatchingRule(ctx context.Context, id string) error + func (d Datasource) DeleteMonitor(id string) error + func (d Datasource) ExportChainCheckpoints(ctx context.Context) ([]model.ChainCheckpoint, error) + func (d Datasource) FetchAndGroupExternalTransactions(ctx context.Context, uploadID string, groupCriteria string, batchSize int, ...) (map[string][]*model.Transaction, error) + func (d Datasource) GetAccountByID(id string, include []string) (*model.Account, error) + func (d Datasource) GetAccountByNumber(number string) (*model.Account, error) + func (d Datasource) GetAllAccounts() ([]model.Account, error) + func (d Datasource) GetAllAccountsWithFilter(ctx context.Context, filters *filter.QueryFilterSet, limit, offset int) ([]model.Account, error) + func (d Datasource) GetAllAccountsWithFilterAndOptions(ctx context.Context, filters *filter.QueryFilterSet, opts *filter.QueryOptions, ...) ([]model.Account, *int64, error) + func (d Datasource) GetAllBalances(limit, offset int) ([]model.Balance, error) + func (d Datasource) GetAllBalancesWithFilter(ctx context.Context, filters *filter.QueryFilterSet, limit, offset int) ([]model.Balance, error) + func (d Datasource) GetAllBalancesWithFilterAndOptions(ctx context.Context, filters *filter.QueryFilterSet, opts *filter.QueryOptions, ...) ([]model.Balance, *int64, error) + func (d Datasource) GetAllIdentities() ([]model.Identity, error) + func (d Datasource) GetAllIdentitiesPaginated(limit, offset int) ([]model.Identity, error) + func (d Datasource) GetAllIdentitiesWithFilter(ctx context.Context, filters *filter.QueryFilterSet, limit, offset int) ([]model.Identity, error) + func (d Datasource) GetAllIdentitiesWithFilterAndOptions(ctx context.Context, filters *filter.QueryFilterSet, opts *filter.QueryOptions, ...) ([]model.Identity, *int64, error) + func (d Datasource) GetAllLedgers(limit, offset int) ([]model.Ledger, error) + func (d Datasource) GetAllLedgersWithFilter(ctx context.Context, filters *filter.QueryFilterSet, limit, offset int) ([]model.Ledger, error) + func (d Datasource) GetAllLedgersWithFilterAndOptions(ctx context.Context, filters *filter.QueryFilterSet, opts *filter.QueryOptions, ...) ([]model.Ledger, *int64, error) + func (d Datasource) GetAllMonitors() ([]model.BalanceMonitor, error) + func (d Datasource) GetAllTransactions(ctx context.Context, limit, offset int) ([]model.Transaction, error) + func (d Datasource) GetAllTransactionsWithFilter(ctx context.Context, filters *filter.QueryFilterSet, limit, offset int) ([]model.Transaction, error) + func (d Datasource) GetAllTransactionsWithFilterAndOptions(ctx context.Context, filters *filter.QueryFilterSet, opts *filter.QueryOptions, ...) ([]model.Transaction, *int64, error) + func (d Datasource) GetBalanceAtTime(ctx context.Context, balanceID string, targetTime time.Time, fromSource bool) (*model.Balance, error) + func (d Datasource) GetBalanceByID(id string, include []string, withQueued bool) (*model.Balance, error) + func (d Datasource) GetBalanceByIDLite(id string) (*model.Balance, error) + func (d Datasource) GetBalanceByIndicator(indicator, currency string) (*model.Balance, error) + func (d Datasource) GetBalanceMonitors(balanceID string) ([]model.BalanceMonitor, error) + func (d Datasource) GetBalancesByIDsLite(ctx context.Context, ids []string) (map[string]*model.Balance, error) + func (d Datasource) GetChainState(ctx context.Context) (*model.ChainState, error) + func (d Datasource) GetChainedTransactionsAfter(ctx context.Context, afterSeq int64, limit int) ([]model.ChainedTransaction, error) + func (d Datasource) GetExistingTransactionReferences(ctx context.Context, references []string) (map[string]struct{}, error) + func (d Datasource) GetExternalTransactionsByReconciliationID(ctx context.Context, reconciliationID string) ([]*model.ExternalTransaction, error) + func (d Datasource) GetExternalTransactionsPaginated(ctx context.Context, uploadID string, batchSize int, offset int64) ([]*model.ExternalTransaction, error) + func (d Datasource) GetIdentityByID(id string) (*model.Identity, error) + func (d Datasource) GetInflightTransactionsByParentID(ctx context.Context, parentTransactionID string, batchSize int, offset int64) ([]*model.Transaction, error) + func (d Datasource) GetLedgerByID(id string) (*model.Ledger, error) + func (d Datasource) GetLineageMappingByProvider(ctx context.Context, balanceID, provider string) (*model.LineageMapping, error) + func (d Datasource) GetLineageMappings(ctx context.Context, balanceID string) ([]model.LineageMapping, error) + func (d Datasource) GetMatchesByReconciliationID(ctx context.Context, reconciliationID string) ([]*model.Match, error) + func (d Datasource) GetMatchingRule(ctx context.Context, id string) (*model.MatchingRule, error) + func (d Datasource) GetMatchingRules(ctx context.Context) ([]*model.MatchingRule, error) + func (d Datasource) GetMonitorByID(id string) (*model.BalanceMonitor, error) + func (d Datasource) GetOutboxByTransactionID(ctx context.Context, transactionID string) (*model.LineageOutbox, error) + func (d Datasource) GetQueuedAmounts(ctx context.Context, balanceID string) (debit, credit *big.Int, err error) + func (d Datasource) GetQueuedTransactionsForCoalescing(ctx context.Context, ...) ([]*model.Transaction, error) + func (d Datasource) GetQueuedTransactionsForDestinationCoalescing(ctx context.Context, destination, currency, excludeTransactionID string, ...) ([]*model.Transaction, error) + func (d Datasource) GetQueuedTransactionsForSourceCoalescing(ctx context.Context, source, currency, excludeTransactionID string, ...) ([]*model.Transaction, error) + func (d Datasource) GetReconciliation(ctx context.Context, id string) (*model.Reconciliation, error) + func (d Datasource) GetReconciliationsByUploadID(ctx context.Context, uploadID string) ([]*model.Reconciliation, error) + func (d Datasource) GetRefundableTransactionsByParentID(ctx context.Context, parentTransactionID string, batchSize int, offset int64) ([]*model.Transaction, error) + func (d Datasource) GetSourceDestination(sourceId, destinationId string) ([]*model.Balance, error) + func (d Datasource) GetStuckQueuedTransactions(ctx context.Context, threshold time.Duration, batchSize int) ([]*model.Transaction, error) + func (d Datasource) GetTotalCommittedTransactions(ctx context.Context, parentID string) (*big.Int, error) + func (d Datasource) GetTransaction(ctx context.Context, id string) (*model.Transaction, error) + func (d Datasource) GetTransactionByRef(ctx context.Context, reference string) (model.Transaction, error) + func (d Datasource) GetTransactionsByCriteria(ctx context.Context, minAmount, maxAmount *float64, currency *string, ...) ([]*model.Transaction, error) + func (d Datasource) GetTransactionsByParent(ctx context.Context, parentID string, limit int, offset int64) ([]*model.Transaction, error) + func (d Datasource) GetTransactionsByShadowFor(ctx context.Context, parentTransactionID string) ([]model.Transaction, error) + func (d Datasource) GetTransactionsPaginated(ctx context.Context, _ string, batchSize int, offset int64) ([]*model.Transaction, error) + func (d Datasource) GroupTransactions(ctx context.Context, groupCriteria string, batchSize int, offset int64) (map[string][]*model.Transaction, error) + func (d Datasource) HasPendingCreditOutbox(ctx context.Context, balanceID string) (bool, error) + func (d Datasource) InsertLineageOutbox(ctx context.Context, outbox *model.LineageOutbox) error + func (d Datasource) InsertLineageOutboxInTx(ctx context.Context, tx *sql.Tx, outbox *model.LineageOutbox) error + func (d Datasource) IsParentTransactionVoid(ctx context.Context, parentID string) (bool, error) + func (d Datasource) IsTransactionRefunded(ctx context.Context, transaction *model.Transaction) (bool, error) + func (d Datasource) LoadReconciliationProgress(ctx context.Context, reconciliationID string) (model.ReconciliationProgress, error) + func (d Datasource) MarkOutboxCompleted(ctx context.Context, id int64) error + func (d Datasource) MarkOutboxFailed(ctx context.Context, id int64, errMsg string) error + func (d Datasource) ReadIntegritySnapshot(ctx context.Context) (integrity.Snapshot, error) + func (d Datasource) RecordExternalTransaction(ctx context.Context, tx *model.ExternalTransaction, uploadID string) error + func (d Datasource) RecordMatch(ctx context.Context, match *model.Match) error + func (d Datasource) RecordMatches(ctx context.Context, reconciliationID string, matches []model.Match) error + func (d Datasource) RecordMatchingRule(ctx context.Context, rule *model.MatchingRule) error + func (d Datasource) RecordReconciliation(ctx context.Context, rec *model.Reconciliation) error + func (d Datasource) RecordTransaction(ctx context.Context, txn *model.Transaction) (*model.Transaction, error) + func (d Datasource) RecordTransactionWithBalances(ctx context.Context, txn *model.Transaction, ...) (*model.Transaction, error) + func (d Datasource) RecordTransactionWithBalancesAndOutbox(ctx context.Context, txn *model.Transaction, ...) (*model.Transaction, error) + func (d Datasource) RecordTransactionsWithBalanceSetAndOutboxes(ctx context.Context, txns []*model.Transaction, balances []*model.Balance, ...) ([]*model.Transaction, error) + func (d Datasource) RecordTransactionsWithBalancesAndOutboxes(ctx context.Context, txns []*model.Transaction, ...) ([]*model.Transaction, error) + func (d Datasource) RecordUnmatched(ctx context.Context, reconciliationID string, results []string) error + func (d Datasource) SaveReconciliationProgress(ctx context.Context, reconciliationID string, ...) error + func (d Datasource) TakeBalanceSnapshots(ctx context.Context, batchSize int) (int, error) + func (d Datasource) TransactionExistsByIDOrParentID(ctx context.Context, id string) (bool, error) + func (d Datasource) TransactionExistsByRef(ctx context.Context, reference string) (bool, error) + func (d Datasource) UpdateAccount(account *model.Account) error + func (d Datasource) UpdateBalance(balance *model.Balance) error + func (d Datasource) UpdateBalanceIdentity(balanceID string, identityID string) error + func (d Datasource) UpdateBalances(ctx context.Context, sourceBalance, destinationBalance *model.Balance) error + func (d Datasource) UpdateIdentity(identity *model.Identity) error + func (d Datasource) UpdateLedger(id, name string) (*model.Ledger, error) + func (d Datasource) UpdateMatchingRule(ctx context.Context, rule *model.MatchingRule) error + func (d Datasource) UpdateMonitor(monitor *model.BalanceMonitor) error + func (d Datasource) UpdateReconciliationStatus(ctx context.Context, id string, status string, ...) error + func (d Datasource) UpsertLineageMapping(ctx context.Context, mapping model.LineageMapping) error + func (d Datasource) VerifyChainSnapshot(ctx context.Context, progress func(int64)) (model.ChainVerifyResult, error) + func (d Datasource) VerifyChainSnapshotWithAnchors(ctx context.Context, progress func(int64), anchors []model.ChainCheckpoint) (model.ChainVerifyResult, error) + func (s *Datasource) CreateAPIKey(ctx context.Context, name, ownerID string, scopes []string, ...) (*model.APIKey, error) + func (s *Datasource) GetAPIKey(ctx context.Context, key string) (*model.APIKey, error) + func (s *Datasource) ListAPIKeys(ctx context.Context, ownerID string) ([]*model.APIKey, error) + func (s *Datasource) RevokeAPIKey(ctx context.Context, id, ownerID string) error + func (s *Datasource) UpdateLastUsed(ctx context.Context, id string) error + type IDataSource interface + func NewDataSource(configuration *config.Configuration) (IDataSource, error)