### Central Ledger Server Output Example Source: https://github.com/mojaloop/central-ledger/blob/main/Onboarding.md This is an example of the expected output when the central ledger server starts successfully, showing the available API endpoints and initial log messages. ```bash > @mojaloop/ml-api-adapter@4.4.1 start /fullpath/to/ml-api-adapter > run-p start:api > @mojaloop/ml-api-adapter@4.4.1 start:api /fullpath/to/ml-api-adapter > node src/api/index.js http://hostname.local:4000 GET / Metadata GET /documentation GET /health Status of adapter GET /metrics Prometheus metrics endpoint GET /swagger.json GET /swaggerui/{path*} GET /swaggerui/extend.js POST /transfers Transfer API. GET /transfers/{id} Get a transfer by Id PUT /transfers/{id} Fulfil a transfer 2019-02-01T13:30:30.454Z - info: participantEndpointCache::initializeCache::start 2019-02-01T13:30:30.456Z - info: participantEndpointCache::initializeCache::Cache initialized successfully 2019-02-01T13:30:30.457Z - info: Notification::startConsumer 2019-02-01T13:30:30.458Z - info: Notification::startConsumer - starting Consumer for topicNames: [topic-notification-event] ``` -------------------------------- ### Example Configuration Environment Variables Source: https://github.com/mojaloop/central-ledger/blob/main/_autodocs/configuration.md Provides a comprehensive example of setting various Central Ledger configuration parameters via shell environment variables. ```bash # Database export CLEDG_DATABASE_DIALECT=postgres export CLEDG_DATABASE_HOST=postgres.local export CLEDG_DATABASE_PORT=5432 export CLEDG_DATABASE_USER=ledger export CLEDG_DATABASE_PASSWORD=secure123 # Server export CLEDG_PORT=3000 export CLEDG_ADMIN_PORT=3001 export CLEDG_HOSTNAME=http://ledger.example.com # Hub export CLEDG_HUB_PARTICIPANT_NAME=CENTRAL_HUB export CLEDG_LEDGER_ACCOUNT_NAME=FEES # Amounts export CLEDG_AMOUNT__PRECISION=10 export CLEDG_AMOUNT__SCALE=2 # Kafka export CLEDG_KAFKA__BROKERS='["kafka1:9092","kafka2:9092"]' # Metrics export CLEDG_INSTRUMENTATION_METRICS_DISABLED=false ``` -------------------------------- ### Install Node Modules Source: https://github.com/mojaloop/central-ledger/blob/main/Onboarding.md Navigate into the cloned directory and install the necessary Node.js modules. If you encounter issues, refer to the Common Errors/FAQs section. ```bash cd central-ledger npm install ``` -------------------------------- ### Start Development Docker Services Source: https://github.com/mojaloop/central-ledger/blob/main/README.md Starts the Docker-dependent services for the development environment using specific compose files. This should be done before starting local services. ```bash docker compose -f ./docker-compose.yml -f docker-compose.dev.yml up -d ``` -------------------------------- ### Create Participant Example Request Source: https://github.com/mojaloop/central-ledger/blob/main/_autodocs/api-reference/participants.md Example JSON payload for the POST /participants endpoint. ```json { "name": "DFSP1", "currency": "USD", "isProxy": false } ``` -------------------------------- ### Install Kubectl on macOS Source: https://github.com/mojaloop/central-ledger/blob/main/KUBERNETES.md Use Homebrew to install Kubectl on macOS. ```bash brew install kubectl ``` -------------------------------- ### Install Helm on macOS Source: https://github.com/mojaloop/central-ledger/blob/main/KUBERNETES.md Use Homebrew to install Helm on macOS. ```bash brew install kubernetes-helm ``` -------------------------------- ### Start Minikube Cluster Source: https://github.com/mojaloop/central-ledger/blob/main/KUBERNETES.md Initiates a Minikube Kubernetes cluster. ```bash minikube start ``` -------------------------------- ### Install Docker on macOS Source: https://github.com/mojaloop/central-ledger/blob/main/KUBERNETES.md Use Homebrew to install Docker on macOS. ```bash brew install docker ``` -------------------------------- ### Get All Accounts Response Source: https://github.com/mojaloop/central-ledger/blob/main/API.md Example of a successful response when retrieving all accounts. Returns an array of account objects. ```http HTTP/1.1 200 OK [ { "id": "http://central-ledger/accounts/dfsp1", "name": "dfsp1", "created": "2016-09-28T17:03:37.168Z", "balance": 1000000, "is_disabled": false, "ledger": "http://central-ledger" }, { "id": "http://central-ledger/accounts/dfsp2", "name": "dfsp2", "created": "2016-09-28T17:03:37.168Z", "balance": 1000000, "is_disabled": false, "ledger": "http://central-ledger" } ] ``` -------------------------------- ### Start Central-Ledger and Dependencies with Docker Compose Source: https://github.com/mojaloop/central-ledger/blob/main/Onboarding.md Use this command to start all services defined in the docker-compose.yml file. It pulls dependencies, builds the central-ledger image, and runs all containers, ensuring dependencies are ready. ```bash docker-compose up -d ``` -------------------------------- ### Install Minikube on macOS Source: https://github.com/mojaloop/central-ledger/blob/main/KUBERNETES.md Use Homebrew Cask to install Minikube on macOS. ```bash brew cask install minikube ``` -------------------------------- ### Get Account Response (Authenticated) Source: https://github.com/mojaloop/central-ledger/blob/main/API.md Example of a successful HTTP response when retrieving account details. ```http HTTP/1.1 200 OK Content-Type: application/json { "id": "http://central-ledger/accounts/dfsp1", "name": "dfsp1", "created": "2016-09-28T17:03:37.168Z", "balance": 1000000, "is_disabled": false, "ledger": "http://central-ledger" } ``` -------------------------------- ### Run ml-core-test-harness Services Source: https://github.com/mojaloop/central-ledger/blob/main/documentation/fx-implementation/README.md Start the necessary services for the ml-core-test-harness using docker-compose with specific profiles. ```bash docker-compose --profile all-services --profile ttk-provisioning --profile ttk-tests --profile debug up -d ``` -------------------------------- ### Start Local Central Ledger Service Source: https://github.com/mojaloop/central-ledger/blob/main/README.md Starts the local Central Ledger service. This command should be run after the development Docker services are up and running. ```bash npm start ``` -------------------------------- ### Start Central Ledger Service Source: https://github.com/mojaloop/central-ledger/blob/main/README.md Start the Central Ledger service in the background for integration testing. Logs are redirected to a file, and the process ID is saved for later termination. ```bash npm start > cl-service.log & echo $! > /tmp/int-test-service.pid ``` -------------------------------- ### Get Account Response - DFSP API Source: https://github.com/mojaloop/central-ledger/blob/main/API.md This is an example of a successful 200 OK response when retrieving account information via the DFSP API. It returns the account object. ```http HTTP/1.1 200 OK Content-Type: application/json { "id": "http://central-ledger/accounts/dfsp1", "name": "dfsp1", "ledger": "http://central-ledger" } ``` -------------------------------- ### Start Dependency Resolution Source: https://github.com/mojaloop/central-ledger/blob/main/README.md Run this command to initiate the process of fixing dependency vulnerabilities. It utilizes npm scripts for automation. ```bash npm run audit:fix ``` -------------------------------- ### Start Central Ledger Service Source: https://github.com/mojaloop/central-ledger/blob/main/_autodocs/README.md Commands to initiate the API server, message handlers, or development environment. ```bash npm start ``` ```bash npm start:handlers ``` ```bash npm run dev ``` -------------------------------- ### Run Dependencies for Integration Tests Source: https://github.com/mojaloop/central-ledger/blob/main/README.md Starts the necessary Docker dependencies for running integration tests. Ensure these services are running before proceeding. ```bash docker compose up -d mysql kafka init-kafka redis-node-0 redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5 npm run wait-4-docker ``` -------------------------------- ### Run Integration Tests Source: https://github.com/mojaloop/central-ledger/blob/main/README.md Execute the integration tests after the Central Ledger service has been started. ```bash npm run test:int ``` -------------------------------- ### Response for Getting Available Permissions Source: https://github.com/mojaloop/central-ledger/blob/main/API.md A successful response (200 OK) listing available permissions. Each permission is represented by a key and a description. ```http HTTP/1.1 200 OK [ { "key": "ACCOUNTS_CREATE", "description": "Create an account" }, { "key": "ACCOUNTS_LIST", "description": "List all accounts" } ] ``` -------------------------------- ### Get All Charges Source: https://github.com/mojaloop/central-ledger/blob/main/API.md Retrieves a list of all created charges in the system. ```APIDOC ## GET /charges ### Description Lists all created charges. ### Method GET ### Endpoint http://central-ledger-admin/charges ### Headers - **Authorization** (string) - Required - Bearer Token for JWT authentication. ### Response #### Success Response (200 OK) - **Array** (object) - An array of all created Charge objects. ### Response Example ```json [ { "name": "fee_1", "id": 1, "charge_type": "fee", "rate_type": "flat", "rate": "1.00", "minimum": "0.00", "maximum": "15.00", "code": "001", "is_active": true, "created": "2017-04-10T19:49:54.850Z", "payer": "sender", "payee": "receiver" } ] ``` ### Errors (4xx) - **NotFoundError**: The requested resource could not be found. ``` -------------------------------- ### Example response for participant endpoints Source: https://github.com/mojaloop/central-ledger/blob/main/_autodocs/api-reference/participants.md Shows the JSON structure returned when retrieving participant endpoints. ```json [ { "type": "FSPIOP_CALLBACK_URL_TRANSFERS_POST", "value": "http://dfsp1.example.com/transfers" } ] ``` -------------------------------- ### Settlement Model Request Body Example Source: https://github.com/mojaloop/central-ledger/blob/main/_autodocs/api-reference/settlement-models.md A sample JSON payload for creating a NET_MULTILATERAL_DEFERRED settlement model. ```json { "name": "NET_MULTILATERAL_DEFERRED", "settlementGranularity": "NET", "settlementInterchange": "MULTILATERAL", "settlementDelay": "DEFERRED", "currency": "USD", "requireLiquidityCheck": true, "ledgerAccountType": "POSITION", "autoPositionReset": true, "settlementAccountType": "SETTLEMENT" } ``` -------------------------------- ### Batch Position Calculation Source: https://github.com/mojaloop/central-ledger/blob/main/_autodocs/api-reference/position-service.md Example of calculating position deltas for a batch of transfers using the PositionService. ```javascript const batch = [ { transferId: 'tx1', payerFsp: 'DFSP1', payeeFsp: 'DFSP2', amount: '100', currency: 'USD' }, { transferId: 'tx2', payerFsp: 'DFSP1', payeeFsp: 'DFSP3', amount: '50', currency: 'USD' }, { transferId: 'tx3', payerFsp: 'DFSP2', payeeFsp: 'DFSP1', amount: '30', currency: 'USD' } ] const positions = await PositionService.calculatePreparePositionsBatch(batch) // Results in position deltas: // DFSP1: -150 (paying 100+50, receiving 30) // DFSP2: +100-30 = +70 (receiving 100, paying 30) // DFSP3: +50 (receiving 50) ``` -------------------------------- ### Configure Database and Run Server Source: https://github.com/mojaloop/central-ledger/blob/main/Onboarding.md Set the database connection URI and optionally disable MongoDB. Then, start the central ledger server using npm. Ensure the `wait-for-objstore.sh` script is commented out in `docker/wait-for/wait-for-central-ledger.sh` if MongoDB is disabled. ```bash # Disable the MongoDB (optional) export CLEDG_MONGODB__DISABLED=true # set the CLEDG_DATABASE_URI* environment variable (required): export CLEDG_DATABASE_URI=mysql://central_ledger:password@localhost:3306/central_ledger # start the server npm run start ``` -------------------------------- ### Get All Accounts Request Source: https://github.com/mojaloop/central-ledger/blob/main/API.md Example HTTP request to retrieve all accounts. Requires JWT authorization. ```http GET http://central-ledger-admin/accounts HTTP/1.1 ``` -------------------------------- ### Create Charge Response Source: https://github.com/mojaloop/central-ledger/blob/main/API.md Example of a successful response after creating a charge. Returns the newly created charge object. ```http HTTP/1.1 201 CREATED Content-Type: application/json { "name": "charge", "id": 5, "charge_type": "fee", "rate_type": "flat", "rate": "1.00", "minimum": "0.00", "maximum": "100.00", "code": "001", "is_active": true, "created": "2017-03-10T17:56:35.966Z", "payer": "sender", "payee": "receiver" } ``` -------------------------------- ### Start Backend Dependencies with Docker Compose Source: https://github.com/mojaloop/central-ledger/blob/main/Onboarding.md Initiate all backend dependencies (MySQL, Kafka, etc.) using Docker Compose. The `objstore` can be omitted if MongoDB is disabled. The `mockserver` is optional. ```bash # start all back-end dependencies in Docker docker-compose up -d mysql kafka temp_curl objstore simulator mockserver ml-api-adapter ``` -------------------------------- ### Install Specific Sodium Version Source: https://github.com/mojaloop/central-ledger/blob/main/Onboarding.md Resolves compilation issues during `npm install` by installing a specific, compatible version of the `sodium` package. ```bash npm install sodium@2.0.3 ``` -------------------------------- ### GET /enums Source: https://github.com/mojaloop/central-ledger/blob/main/_autodocs/api-reference/root-endpoints.md Retrieves the full list of system enumerations. This endpoint is cached for performance and preloaded on service startup. ```APIDOC ## GET /enums ### Description Retrieves the complete set of system enumerations, including limit types and settlement granularities, used for client-side operations. ### Method GET ### Endpoint /enums ### Response #### Success Response (200) - **limitType** (object) - Map of available limit types - **participantLimitType** (object) - Map of available participant limit types - **settlementGranularity** (object) - Map of available settlement granularities ``` -------------------------------- ### Fix npm install failure on macOS with OpenSSL Source: https://github.com/mojaloop/central-ledger/blob/main/Onboarding.md When `npm install` fails on macOS with linker errors related to `x86_64` architecture, install OpenSSL using Homebrew and set the `CFLAGS` and `LDFLAGS` environment variables before running `npm install`. ```bash export CFLAGS=-I/usr/local/opt/openssl/include export LDFLAGS=-L/usr/local/opt/openssl/lib npm install ``` -------------------------------- ### Wait for Docker Containers Script Source: https://github.com/mojaloop/central-ledger/blob/main/README.md Run this script after starting Docker containers to ensure all services are up and running before proceeding with tests. ```bash npm run wait-4-docker ``` -------------------------------- ### Initialize Helm Source: https://github.com/mojaloop/central-ledger/blob/main/KUBERNETES.md Initializes Helm. This command only needs to be run once. ```bash helm init ``` -------------------------------- ### Start Integration Test Docker Containers Source: https://github.com/mojaloop/central-ledger/blob/main/README.md Launch the necessary Docker containers for running integration tests locally. This includes databases, Kafka, and Redis. ```bash docker compose up -d mysql kafka init-kafka redis-node-0 redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5 ``` -------------------------------- ### GET /enums Source: https://github.com/mojaloop/central-ledger/blob/main/_autodocs/api-reference/root-endpoints.md Retrieve all system enumerations used for UI dropdowns, input validation, and ID mapping. ```APIDOC ## GET /enums ### Description Retrieve all system enumerations. ### Method GET ### Endpoint /enums ### Response #### Success Response (200) - **ledgerAccountType** (object) - Account classifications - **settlementGranularity** (object) - Settlement scope - **settlementInterchange** (object) - Settlement parties - **settlementDelay** (object) - Settlement timing - **limitType** (object) - Participant limits - **participantLimitType** (object) - Participant-specific limits - **transferState** (object) - Transfer lifecycle states - **transferEventAction** (object) - Transfer event types - **transferEventType** (object) - Event classifications #### Response Example { "ledgerAccountType": { "POSITION": { "ledgerAccountTypeId": 1, "name": "POSITION" } }, "transferState": { "PREPARE": { "transferStateId": 1, "name": "PREPARE" } } } ``` -------------------------------- ### Environment Variable Mapping Source: https://github.com/mojaloop/central-ledger/blob/main/_autodocs/configuration.md Demonstrates how double underscores in environment variables map to nested configuration keys. ```text CLEDG_DATABASE_HOST → config.DATABASE.HOST CLEDG_KAFKA__BROKERS → config.KAFKA.BROKERS CLEDG_KAFKA__CONFIG__TOPICS → config.KAFKA.CONFIG.TOPICS ``` -------------------------------- ### Get Authentication Token Source: https://github.com/mojaloop/central-ledger/blob/main/API.md The get authentication endpoint generates an authentication token. ```APIDOC ## GET /auth_token ### Description Generates an authentication token for accessing the API. ### Method GET ### Endpoint http://central-ledger/auth_token ### Headers - **Content-Type** (String) - Required - Must be set to `application/json` - **Authorization** (Basic) - Optional - Defaults to `admin:admin` ### Response #### Success Response (200 OK) - **token** (String) - The generated authentication token ### Response Example ```json { "token": "1234token4321" } ``` ``` -------------------------------- ### Get Admin Authentication Token Response (200 OK) Source: https://github.com/mojaloop/central-ledger/blob/main/API.md Successful response containing the generated authentication token. ```http HTTP/1.1 200 OK { "token": "1234token4321" } ``` -------------------------------- ### Ledger account types response format Source: https://github.com/mojaloop/central-ledger/blob/main/_autodocs/api-reference/ledger-account-types.md Example of the JSON array returned when fetching all ledger account types. ```json [ { "ledgerAccountTypeId": 1, "name": "POSITION", "description": "Participant position account for tracking balances", "isActive": true }, { "ledgerAccountTypeId": 2, "name": "SETTLEMENT", "description": "Settlement account for transfer settlement", "isActive": true }, { "ledgerAccountTypeId": 3, "name": "INTERCHANGE_FEE_SETTLEMENT", "description": "Interchange fee settlement account", "isActive": true } ] ``` -------------------------------- ### Get All Users Source: https://github.com/mojaloop/central-ledger/blob/main/API.md Retrieves a list of all users in the system. This endpoint returns basic user information including userId, name, and email. ```http HTTP/1.1 200 OK [ { "userId": "e181fc02", "key": "key", "lastName": "lastName", "firstName": "firstName", "email": "email@central-ledger.com", "isActive": true, "createdDate": "2017-04-10T21:15:06.378Z" }, { "userId": "e181fc03", "key": "key", "lastName": "lastName2", "firstName": "firstName2", "email": "email2@central-ledger.com", "isActive": false, "createdDate": "2017-04-10T21:15:06.378Z" } ] ``` -------------------------------- ### Clone ml-core-test-harness Repository Source: https://github.com/mojaloop/central-ledger/blob/main/documentation/fx-implementation/README.md Clone the ml-core-test-harness repository to set up for testing FX functionality. ```bash git clone https://github.com/mojaloop/ml-core-test-harness.git ``` -------------------------------- ### Get All Roles Request Source: https://github.com/mojaloop/central-ledger/blob/main/API.md HTTP GET request to retrieve a list of all roles. Requires an Authorization header with a Bearer Token. ```http GET http://central-ledger-admin/roles HTTP/1.1 ``` -------------------------------- ### Configure Central Ledger Environment Variables Source: https://github.com/mojaloop/central-ledger/blob/main/_autodocs/00_START_HERE.md Sets essential database, server, and hub configuration parameters via environment variables. ```bash # Database export CLEDG_DATABASE_DIALECT=postgres export CLEDG_DATABASE_HOST=localhost export CLEDG_DATABASE_USER=ledger export CLEDG_DATABASE_PASSWORD=secret # Server export CLEDG_PORT=3000 export CLEDG_HOSTNAME=http://localhost:3000 # Hub export CLEDG_HUB_PARTICIPANT_NAME=HUB # Amounts export CLEDG_AMOUNT__PRECISION=10 export CLEDG_AMOUNT__SCALE=2 ``` -------------------------------- ### Client-Side Enum Integration Source: https://github.com/mojaloop/central-ledger/blob/main/_autodocs/api-reference/root-endpoints.md Demonstrates fetching enums at startup and implementing helper functions for UI dropdowns, validation, and ID-to-name mapping. ```javascript // Fetch enums on client startup const response = await fetch('http://localhost:3000/enums') const enums = await response.json() // Use for dropdowns const settlementGranularityOptions = Object.entries(enums.settlementGranularity) .map(([key, value]) => ({ label: key, value: key, id: value.settlementGranularityId })) // Validate user input function isValidSettlementGranularity(value) { return value in enums.settlementGranularity } // Map ID to name function getSettlementGranularityName(id) { return Object.values(enums.settlementGranularity) .find(sg => sg.settlementGranularityId === id)?.name } ``` -------------------------------- ### Get All Charges Request Source: https://github.com/mojaloop/central-ledger/blob/main/API.md A simple HTTP GET request to retrieve a list of all created charges. Requires an Authorization header with a JWT Bearer Token. ```http GET http://central-ledger-admin/charges HTTP/1.1 ``` -------------------------------- ### Enable Minikube Ingress Addon Source: https://github.com/mojaloop/central-ledger/blob/main/KUBERNETES.md Enables the ingress controller addon for Minikube. ```bash minikube addon enable ingress ``` -------------------------------- ### Get Account Admin Source: https://github.com/mojaloop/central-ledger/blob/main/API.md The get account endpoint will return information about the account. To successfully retrieve an account, make sure the [account has been previously created.](#create-account) ```APIDOC ## GET /accounts/{name} ### Description Retrieves information about a specific account. ### Method GET ### Endpoint http://central-ledger-admin/accounts/{name} ### URL Parameters - **name** (String) - Required - The unique name for the account ### Headers - **Authorization** (Bearer Token) - Required - JWT based access token ### Response #### Success Response (200 OK) - **Object** (Account) - The [Account object](#account-object) as saved ### Request Example ```http GET http://central-ledger/accounts/dfsp1 HTTP/1.1 ``` ### Response Example ```json { "id": "http://central-ledger/accounts/dfsp1", "name": "dfsp1", "created": "2016-09-28T17:03:37.168Z", "balance": 1000000, "is_disabled": false, "ledger": "http://central-ledger" } ``` ``` -------------------------------- ### Run Central Ledger Services for Integration Tests Source: https://github.com/mojaloop/central-ledger/blob/main/README.md Starts the Central Ledger services and configures Kafka topic mappings for integration testing. This should be run after dependencies are up. ```bash nvm use npm run migrate export CLEDG_KAFKA__EVENT_TYPE_ACTION_TOPIC_MAP__POSITION__PREPARE=topic-transfer-position-batch export CLEDG_KAFKA__EVENT_TYPE_ACTION_TOPIC_MAP__POSITION__COMMIT=topic-transfer-position-batch export CLEDG_KAFKA__EVENT_TYPE_ACTION_TOPIC_MAP__POSITION__RESERVE=topic-transfer-position-batch export CLEDG_KAFKA__EVENT_TYPE_ACTION_TOPIC_MAP__POSITION__TIMEOUT_RESERVED=topic-transfer-position-batch export CLEDG_KAFKA__EVENT_TYPE_ACTION_TOPIC_MAP__POSITION__FX_TIMEOUT_RESERVED=topic-transfer-position-batch export CLEDG_KAFKA__EVENT_TYPE_ACTION_TOPIC_MAP__POSITION__ABORT=topic-transfer-position-batch export CLEDG_KAFKA__EVENT_TYPE_ACTION_TOPIC_MAP__POSITION__FX_ABORT=topic-transfer-position-batch npm start ``` -------------------------------- ### Get Available Permissions Request Source: https://github.com/mojaloop/central-ledger/blob/main/API.md An HTTP GET request to retrieve a list of all available permissions within the system. An Authorization header with a JWT Bearer Token is required. ```http GET http://central-ledger-admin/permissions HTTP/1.1 ``` -------------------------------- ### Get Charge Quote Request Source: https://github.com/mojaloop/central-ledger/blob/main/API.md This endpoint is used to get a list of charge quotes for a given amount. The sender is responsible for paying these charges. Ensure the Content-Type header is set to application/json. ```http POST http://central-ledger/charges/quotes HTTP/1.1 Content-Type: application/json { "amount": "10.00" } ``` -------------------------------- ### Create Account Source: https://github.com/mojaloop/central-ledger/blob/main/TransferGuide.md Use this endpoint to create a new account. Provide the account name and password. Refer to API documentation for response and error details. ```bash POST http://central-ledger/accounts Content-Type: application/json { "name": "dfsp1", "password": "dfsp1_password" } ``` ```bash POST http://central-ledger/accounts HTTP/1.1 Content-Type: application/json { "name": "dfsp2", "password": "dfsp2_password" } ``` -------------------------------- ### Get Ledger Metadata Response Source: https://github.com/mojaloop/central-ledger/blob/main/API.md A successful response (200 OK) for the get metadata endpoint. It provides details about the ledger's configuration, including currency, precision, scale, and available service endpoints. ```json { "currency_code": null, "currency_symbol": null, "ledger": "http://central-ledger", "urls": { "auth_token": "http://central-ledger/auth_token", "health": "http://central-ledger/health", "positions": "http://central-ledger/positions", "account": "http://central-ledger/accounts/:name", "accounts": "http://central-ledger/accounts", "send_message": "http://central-ledger/messages", "transfer": "http://central-ledger/transfers/:id", "transfer_fulfilment": "http://central-ledger/transfers/:id/fulfilment", "transfer_rejection": "http://central-ledger/transfers/:id/rejection", "notifications": "ws://central-ledger/websocket" }, "precision": 10, "scale": 2 } ``` -------------------------------- ### Manage Database Migrations and Seeding Source: https://github.com/mojaloop/central-ledger/blob/main/_autodocs/README.md Commands to apply pending database migrations and load initial seed data. ```bash npm run migrate ``` ```bash npm run seed:run ``` -------------------------------- ### Get All Net Positions Response Source: https://github.com/mojaloop/central-ledger/blob/main/API.md A successful response (200 OK) for the get net positions endpoint. It returns an array of position objects, each detailing an account's payment, receipts, and net balance. ```json { "positions": [ { "account": "http://central-ledger/accounts/dfsp1", "payments": "0", "receipts": "0", "net": "0" }, { "account": "http://central-ledger/accounts/dfsp2", "payments": "100", "receipts": "0", "net": "-100" }, { "account": "http://central-ledger/accounts/dfsp3", "payments": "0", "receipts": "100", "net": "100" } ] } ``` -------------------------------- ### GET /participants/limits Source: https://github.com/mojaloop/central-ledger/blob/main/_autodocs/api-reference/participants.md Retrieve limits for all participants. ```APIDOC ## GET /participants/limits ### Description Retrieve limits for all participants. ### Method GET ### Endpoint /participants/limits ### Parameters #### Query Parameters - **currency** (string) - Required - ISO 4217 currency code - **type** (string) - Optional - Optional limit type filter ### Response #### Success Response (200) - **name** (string) - Participant name - **currency** (string) - ISO 4217 currency code - **limit** (object) - Limit details including type, value, and alarmPercentage #### Response Example [ { "name": "DFSP1", "currency": "USD", "limit": { "type": "NET_DEBIT_CAP", "value": 1000000, "alarmPercentage": 90 } } ] ``` -------------------------------- ### GET /participants Source: https://github.com/mojaloop/central-ledger/blob/main/_autodocs/api-reference/participants.md Retrieve all participants registered in the system. ```APIDOC ## GET /participants ### Description Retrieve all participants registered in the system. ### Method GET ### Endpoint /participants ### Parameters #### Query Parameters - **isProxy** (boolean) - Optional - Filter to return only proxy participants ### Response #### Success Response (200) - **Array** (Participant objects) - List of registered participants #### Response Example [ { "name": "DFSP1", "id": "http://central-ledger/participants/DFSP1", "created": "2024-01-15T10:30:00.000Z", "isActive": true, "links": { "self": "http://central-ledger/participants/DFSP1" }, "accounts": [ { "id": 1, "ledgerAccountType": "POSITION", "currency": "USD", "isActive": true, "createdDate": "2024-01-15T10:30:00.000Z", "createdBy": "admin" } ], "isProxy": false } ] ``` -------------------------------- ### Start Docker Containers for Integration Tests (Docker) Source: https://github.com/mojaloop/central-ledger/blob/main/README.md Launch Docker containers, including a 'central-ledger' container for proxy shell access, when running integration tests inside Docker. ```bash docker-compose -f docker-compose.yml -f docker-compose.integration.yml up -d kafka mysql central-ledger init-kafka redis-node-0 redis-node-1 redis-node-2 redis-node-3 redis-node-4 redis-node-5 ``` -------------------------------- ### GET /transactions/{id} Source: https://github.com/mojaloop/central-ledger/blob/main/_autodocs/api-reference/transactions.md Retrieve a transaction by its identifier. ```APIDOC ## GET /transactions/{id} ### Description Retrieve a transaction by its identifier. ### Method GET ### Endpoint /transactions/{id} ### Parameters #### Path Parameters - **id** (string) - Required - Transfer ID (UUID or ULID format) ### Response #### Success Response (200) - **transactionId** (string) - Transaction ID - **transferId** (string) - Transfer ID - **ilpPacket** (string) - ILP packet data - **data** (object) - Transaction data payload #### Response Example { "transactionId": "550e8400-e29b-41d4-a716-446655440000", "transferId": "550e8400-e29b-41d4-a716-446655440001", "ilpPacket": "eyJhbGciOiJSUzI1NiIsImtpZCI6IjEifQ...", "data": { "transactionType": "TRANSFER", "payer": { "personalInfo": { "name": "John Doe" }, "partyIdInfo": { "partyIdType": "MSISDN", "partyIdentifier": "+254123456789" } }, "payee": { "personalInfo": { "name": "Jane Smith" }, "partyIdInfo": { "partyIdType": "MSISDN", "partyIdentifier": "+254987654321" } }, "amount": { "amount": "100.00", "currency": "USD" } } } ``` -------------------------------- ### Deploy Central-Ledger to Kubernetes Source: https://github.com/mojaloop/central-ledger/blob/main/KUBERNETES.md Creates Kubernetes resources for Central-Ledger from the specified directory. ```bash kubectl create -f ./deploy/k8s ``` -------------------------------- ### Get All Users Source: https://github.com/mojaloop/central-ledger/blob/main/API.md Retrieves a list of all admin users. ```APIDOC ## GET /users ### Description Returns all admin users for the central ledger. ### Method GET ### Endpoint http://central-ledger-admin/users ### Headers - **Authorization** (Bearer Token) - Required - JWT based access token ### Response #### Success Response (200 OK) - **Object** (Array) - A list of [User objects](#user-object) for the central ledger #### Request Example ```http GET http://central-ledger-admin/users HTTP/1.1 ``` ``` -------------------------------- ### Health Check Source: https://github.com/mojaloop/central-ledger/blob/main/API.md Get the current status of the service. ```APIDOC ## GET /health ### Description Retrieves the current operational status of the Central Ledger service. ### Method GET ### Endpoint http://central-ledger/health ### Response #### Success Response (200 OK) - **status** (String) - The status of the ledger, *OK* if the service is working ### Response Example ```json { "status": "OK" } ``` ``` -------------------------------- ### Initialize Position Metrics Source: https://github.com/mojaloop/central-ledger/blob/main/_autodocs/api-reference/position-service.md Configure histogram metrics for tracking domain position operations. ```javascript const histogram = Metrics.getHistogram( 'domain_position', 'changeParticipantPosition - Metrics for transfer domain', ['success', 'funcName'] ) // Dimensions: // - success: true/false // - funcName: 'changeParticipantPosition' or 'calculatePreparePositionsBatch' ``` -------------------------------- ### Create Settlement Model in JavaScript Source: https://github.com/mojaloop/central-ledger/blob/main/_autodocs/api-reference/settlement-service.md Initializes a new settlement model configuration. Requires a valid model object and optional Knex transaction. ```javascript const SettlementService = require('src/domain/settlement') const created = await SettlementService.createSettlementModel({ name: 'NET_MULTILATERAL_DEFERRED', settlementGranularity: 'NET', settlementInterchange: 'MULTILATERAL', settlementDelay: 'DEFERRED', currency: 'USD', requireLiquidityCheck: true, ledgerAccountType: 'POSITION', settlementAccountType: 'SETTLEMENT', autoPositionReset: true }) ``` -------------------------------- ### Create a Participant Source: https://github.com/mojaloop/central-ledger/blob/main/_autodocs/README.md Registers a new participant in the system. Requires a unique name and currency definition. ```bash curl -X POST http://localhost:3000/participants \ -H "Content-Type: application/json" \ -d '{ "name": "DFSP1", "currency": "USD", "isProxy": false }' ``` -------------------------------- ### GET /participants/{name}/endpoints Source: https://github.com/mojaloop/central-ledger/blob/main/_autodocs/api-reference/participants.md Retrieves endpoints for a participant. ```APIDOC ## GET /participants/{name}/endpoints ### Description Retrieve endpoints for a participant. ### Method GET ### Endpoint /participants/{name}/endpoints ### Parameters #### Path Parameters - **name** (string) - Required - Participant name #### Query Parameters - **type** (string) - Optional - Filter by specific endpoint type ### Response #### Success Response (200) - Array of endpoint objects or single endpoint #### Response Example [ { "type": "FSPIOP_CALLBACK_URL_TRANSFERS_POST", "value": "http://dfsp1.example.com/transfers" } ] ``` -------------------------------- ### GET /participants/{name} Source: https://github.com/mojaloop/central-ledger/blob/main/_autodocs/api-reference/participants.md Retrieve a specific participant by name. ```APIDOC ## GET /participants/{name} ### Description Retrieve a specific participant by name. ### Method GET ### Endpoint /participants/{name} ### Parameters #### Path Parameters - **name** (string) - Required - Participant name (2-30 characters) ### Response #### Success Response (200) - **Object** (Participant) - The requested participant object #### Error Response (404) - Participant not found ``` -------------------------------- ### Get User by ID Source: https://github.com/mojaloop/central-ledger/blob/main/API.md Retrieves an admin user by their ID. ```APIDOC ## GET /users/{userId} ### Description Returns an admin user with the given ID. ### Method GET ### Endpoint http://central-ledger-admin/users/{userId} ### Headers - **Authorization** (Bearer Token) - Required - JWT based access token ### Response #### Success Response (200 OK) - **Object** (User) - [User object](#user-object) for the given id #### Response Example ```http HTTP/1.1 200 OK { "userId": "e181fc02", "key": "key", "lastName": "lastName", "firstName": "firstName", "email": "email@central-ledger.com", "isActive": true, "createdDate": "2017-04-10T21:15:06.378Z" } ``` #### Errors (4xx) - **NotFoundError** - The requested resource could not be found ```http { "id": "NotFoundError", "message": "The requested resource could not be found." } ``` ``` -------------------------------- ### Open Kubernetes Dashboard Source: https://github.com/mojaloop/central-ledger/blob/main/KUBERNETES.md Opens the Kubernetes dashboard in a web browser. ```bash minikube dashboard ``` -------------------------------- ### Run Functional Tests Source: https://github.com/mojaloop/central-ledger/blob/main/README.md Executes the functional tests using the ml-core-test-harness. This command will clone the test harness if it doesn't exist and run the tests. ```bash npm run test:functional ``` -------------------------------- ### GET /health endpoint request Source: https://github.com/mojaloop/central-ledger/blob/main/_autodocs/api-reference/root-endpoints.md Request to check the service availability. ```javascript GET /health ``` -------------------------------- ### Checkout FX Implementation Branch Source: https://github.com/mojaloop/central-ledger/blob/main/documentation/fx-implementation/README.md Checkout the specific branch containing the FX implementation features in the ml-core-test-harness. ```bash git checkout feat/fx-impl ``` -------------------------------- ### Get all accounts Source: https://github.com/mojaloop/central-ledger/blob/main/API.md Retrieves a list of all created accounts in the central ledger. ```APIDOC ## GET /accounts ### Description The get all accounts endpoint lists all created accounts. ### Method GET ### Endpoint http://central-ledger-admin/accounts ### Headers - **Authorization** (Bearer Token) - JWT based access token ### Response #### Success Response (200 OK) - **Object** (Array) - An array of all created [Account objects](#account-object) ### Response Example ```json [ { "id": "http://central-ledger/accounts/dfsp1", "name": "dfsp1", "created": "2016-09-28T17:03:37.168Z", "balance": 1000000, "is_disabled": false, "ledger": "http://central-ledger" }, { "id": "http://central-ledger/accounts/dfsp2", "name": "dfsp2", "created": "2016-09-28T17:03:37.168Z", "balance": 1000000, "is_disabled": false, "ledger": "http://central-ledger" } ] ``` ### Errors (4xx) - **NotFoundError** - The requested resource could not be found ```json { "id": "NotFoundError", "message": "The requested resource could not be found." } ``` ``` -------------------------------- ### GET /participants/{name}/accounts Source: https://github.com/mojaloop/central-ledger/blob/main/_autodocs/api-reference/participants.md Retrieve all accounts associated with a specific participant. ```APIDOC ## GET /participants/{name}/accounts ### Description Retrieve all accounts for a participant. ### Method GET ### Endpoint /participants/{name}/accounts ### Parameters #### Path Parameters - **name** (string) - Required - Participant name ### Response #### Success Response (200) - **Response Body** (Array) - Array of account objects with current balances ``` -------------------------------- ### Run All Tests Command Source: https://github.com/mojaloop/central-ledger/blob/main/README.md Execute all unit, functional, and integration tests for the project. This command includes code coverage reporting. ```bash npm run test:all ``` -------------------------------- ### GET /enums endpoint request Source: https://github.com/mojaloop/central-ledger/blob/main/_autodocs/api-reference/root-endpoints.md Request to retrieve all system-wide enumeration definitions. ```javascript GET /enums ``` -------------------------------- ### Create Participant API Request Source: https://github.com/mojaloop/central-ledger/blob/main/_autodocs/00_START_HERE.md Registers a new participant by sending a POST request with name and currency details. ```bash curl -X POST http://localhost:3000/participants \ -H "Content-Type: application/json" \ -d '{ "name": "DFSP1", "currency": "USD" }' ``` -------------------------------- ### GET /ledgerAccountTypes Source: https://github.com/mojaloop/central-ledger/blob/main/_autodocs/api-reference/ledger-account-types.md Retrieves a list of all ledger account types defined in the system. ```APIDOC ## GET /ledgerAccountTypes ### Description Retrieve all ledger account types. ### Method GET ### Endpoint /ledgerAccountTypes ### Response #### Success Response (200) - **Array** (Array of Ledger Account Type objects) - List of all ledger account types. #### Response Example [ { "ledgerAccountTypeId": 1, "name": "POSITION", "description": "Participant position account for tracking balances", "isActive": true } ] ``` -------------------------------- ### Add Participant Limit and Initial Position Source: https://github.com/mojaloop/central-ledger/blob/main/_autodocs/api-reference/participant-service.md Configures financial limits and an optional starting position for a participant. Throws an error if the participant is missing or the limit is already defined. ```javascript await ParticipantService.addLimitAndInitialPosition('DFSP1', { currency: 'USD', limit: { type: 'NET_DEBIT_CAP', value: 1000000 }, initialPosition: 50000 }) ``` -------------------------------- ### GET /settlementModels Source: https://github.com/mojaloop/central-ledger/blob/main/_autodocs/api-reference/settlement-models.md Retrieves a list of all settlement models currently configured in the system. ```APIDOC ## GET /settlementModels ### Description Retrieve all settlement models configured in the system. ### Method GET ### Endpoint /settlementModels ### Response #### Success Response (200) - **Response Body** (Array) - Array of Settlement Model objects #### Response Example [ { "settlementModelId": 1, "name": "GROSS_BILATERAL_IMMEDIATE", "isActive": true, "settlementGranularity": "GROSS", "settlementInterchange": "BILATERAL", "settlementDelay": "IMMEDIATE", "currency": "USD", "requireLiquidityCheck": true, "ledgerAccountTypeId": 1, "settlementAccountTypeId": 2, "autoPositionReset": true } ] ``` -------------------------------- ### Get System Enums API Request Source: https://github.com/mojaloop/central-ledger/blob/main/_autodocs/00_START_HERE.md Fetches the system-wide enumeration values. ```bash curl http://localhost:3000/enums ``` -------------------------------- ### Configure Kafka Position Event Topics Source: https://github.com/mojaloop/central-ledger/blob/main/README.md Customize Kafka topic names for POSITION.PREPARE and POSITION.COMMIT events. Ensure only supported event types are configured. ```json "KAFKA": { "EVENT_TYPE_ACTION_TOPIC_MAP" : { "POSITION":{ "PREPARE": "topic-transfer-position-batch", "COMMIT": "topic-transfer-position-batch" } } } ``` -------------------------------- ### Get Available Permissions Source: https://github.com/mojaloop/central-ledger/blob/main/API.md Retrieves a list of all available permissions that can be assigned to roles. ```APIDOC ## GET /permissions ### Description Lists all available permissions. ### Method GET ### Endpoint http://central-ledger-admin/permissions ### Headers - **Authorization** (string) - Required - Bearer Token for JWT authentication. ### Response #### Success Response (200 OK) - **Array** (object) - An array of Permission objects. ### Response Example ```json [ { "key": "ACCOUNTS_CREATE", "description": "Create an account" }, { "key": "ACCOUNTS_LIST", "description": "List all accounts" } ] ``` ### Errors (4xx) - **NotFoundError**: The requested resource could not be found. ``` -------------------------------- ### POST /participants/{name}/initialPositionAndLimits Source: https://github.com/mojaloop/central-ledger/blob/main/_autodocs/api-reference/participants.md Sets initial position and limits for a participant currency. ```APIDOC ## POST /participants/{name}/initialPositionAndLimits ### Description Set initial position and limits for a participant currency. ### Method POST ### Endpoint /participants/{name}/initialPositionAndLimits ### Parameters #### Path Parameters - **name** (string) - Required - Participant name #### Request Body - **currency** (string) - Required - ISO 4217 currency code - **limit** (object) - Required - Limit configuration - **limit.type** (string) - Required - Limit type - **limit.value** (number) - Required - Limit value (non-negative) - **initialPosition** (number) - Optional - Starting position value ### Response #### Success Response (201) - Status Code: 201 Created ``` -------------------------------- ### Get Minikube IP Address Source: https://github.com/mojaloop/central-ledger/blob/main/KUBERNETES.md Retrieves the IP address of the Minikube cluster. ```bash minikube ip ``` -------------------------------- ### Participant response schema Source: https://github.com/mojaloop/central-ledger/blob/main/_autodocs/api-reference/participants.md Example of the JSON structure returned when querying participants. ```json [ { "name": "DFSP1", "id": "http://central-ledger/participants/DFSP1", "created": "2024-01-15T10:30:00.000Z", "isActive": true, "links": { "self": "http://central-ledger/participants/DFSP1" }, "accounts": [ { "id": 1, "ledgerAccountType": "POSITION", "currency": "USD", "isActive": true, "createdDate": "2024-01-15T10:30:00.000Z", "createdBy": "admin" } ], "isProxy": false } ] ``` -------------------------------- ### Create Account Response - DFSP API Source: https://github.com/mojaloop/central-ledger/blob/main/API.md This is an example of a successful 201 Created response when creating an account via the DFSP API. It returns the newly created account object. ```http HTTP/1.1 201 CREATED Content-Type: application/json { "id": "http://central-ledger/accounts/dfsp1", "name": "dfsp1", "created": "2017-01-03T19:50:39.744Z", "balance": "0", "is_disabled": false, "ledger": "http://central-ledger" } ``` -------------------------------- ### Deploy PostgreSQL using Helm Source: https://github.com/mojaloop/central-ledger/blob/main/KUBERNETES.md Deploys PostgreSQL to the Kubernetes cluster using Helm, with custom values from a specified file. ```bash helm install --name central-ledger -f ./deploy/helm/central-ledger-helm-postgresql-values.yaml stable/postgresql ``` -------------------------------- ### GET /participants/{name}/positions Source: https://github.com/mojaloop/central-ledger/blob/main/_autodocs/api-reference/participants.md Retrieve the positions for a specific participant filtered by currency. ```APIDOC ## GET /participants/{name}/positions ### Description Retrieve participant positions. ### Method GET ### Endpoint /participants/{name}/positions ### Parameters #### Path Parameters - **name** (string) - Required - Participant name #### Query Parameters - **currency** (string) - Required - ISO 4217 currency code ### Response #### Success Response (200) - **Response Body** (Array) - Array of position objects ``` -------------------------------- ### GET /participants/{name}/limits Source: https://github.com/mojaloop/central-ledger/blob/main/_autodocs/api-reference/participants.md Retrieve limits for a specific participant identified by name. ```APIDOC ## GET /participants/{name}/limits ### Description Retrieve limits for a specific participant. ### Method GET ### Endpoint /participants/{name}/limits ### Parameters #### Path Parameters - **name** (string) - Required - Participant name #### Query Parameters - **currency** (string) - Required - ISO 4217 currency code - **type** (string) - Optional - Optional limit type filter ### Response #### Success Response (200) - **currency** (string) - ISO 4217 currency code - **limit** (object) - Limit details including type, value, and alarmPercentage #### Response Example [ { "currency": "USD", "limit": { "type": "NET_DEBIT_CAP", "value": 1000000, "alarmPercentage": 90 } } ] ```