### XRPLF CLI Configuration Management Source: https://github.com/xrplf/xrpl-cli/blob/main/readme.md Commands for setting, getting, and listing configuration options for the XRPLF CLI. ```bash xrplf config set ``` ```bash xrplf config get ``` ```bash xrplf config list ``` -------------------------------- ### Install Dependencies with PNPM Source: https://github.com/xrplf/xrpl-cli/blob/main/readme.md Installs project dependencies using the PNPM package manager. Assumes PNPM is already installed on the system. ```bash pnpm install ``` -------------------------------- ### XRPLF CLI: JavaScript Custom Command Example Source: https://github.com/xrplf/xrpl-cli/blob/main/readme.md Example of how to create a custom command for the XRPLF CLI using a JavaScript file. Exports an `exec` function and an optional `description`. ```javascript import chalk from "chalk"; import getStdin from "get-stdin"; const log = console.log; export const exec = async (context) => { const input = await getStdin(); // context contains the flags and input if (!context.flags.quiet) { log(`via: ${context.personality}\n`); log( chalk.white( JSON.stringify( { ...context, stdin: input, env: { ...process.env } }, null, 2 ) ) ); } }; export const description = "hello world example in javascript"; ``` -------------------------------- ### Programmatic Configuration Management in JavaScript Source: https://context7.com/xrplf/xrpl-cli/llms.txt Demonstrates how to manage XRPL CLI configuration settings programmatically within JavaScript applications. This includes setting, getting, checking for, deleting, and accessing all configuration values. Configuration is persisted across sessions. ```javascript import config from './lib/config.js'; // Set configuration config.set('api_endpoint', 'https://api.example.com'); config.set('retry_count', 3); // Get configuration const endpoint = config.get('api_endpoint'); console.log(endpoint); // https://api.example.com // Check if key exists if (config.has('retry_count')) { console.log('Retry count is configured'); } // Delete configuration config.delete('old_key'); // Access all config as object const allConfig = config.store; console.log(allConfig); // Config is automatically persisted to: // macOS: ~/Library/Preferences/xrpl-cli/config.toml // Linux: ~/.config/xrpl-cli/config.toml // Windows: %APPDATA%\xrpl-cli\Config\config.toml ``` -------------------------------- ### Creating Custom CLI Actions in JavaScript Source: https://context7.com/xrplf/xrpl-cli/llms.txt Extends the XRPL CLI by creating new commands as JavaScript modules. This example demonstrates how to define a 'verify' action that reads a UNL file, decodes its blob, and verifies the signature using the `validator.js` library. It utilizes `chalk` for colored output and `fs.promises` for file operations. ```javascript // src/actions/verify.js import chalk from 'chalk'; import { verify } from '../lib/validator.js'; import fs from 'fs/promises'; export const description = 'Verify a signed UNL file'; export const exec = async (context) => { const [cmd, subcommand, filepath] = context.input; if (!filepath) { console.error('Usage: xrplf verify '); process.exit(1); } try { // Read UNL file const unlData = JSON.parse(await fs.readFile(filepath, 'utf8')); // Decode blob and verify signature const blob = Buffer.from(unlData.blob, 'base64'); const isValid = verify( blob, unlData.signature, unlData.public_key ); if (isValid) { console.log(chalk.green('✅ UNL signature is valid')); // Parse blob to show details const vlBlob = JSON.parse(blob.toString('utf8')); console.log(`Sequence: ${vlBlob.sequence}`); console.log(`Validators: ${vlBlob.validators.length}`); console.log(`Expiration: ${new Date((vlBlob.expiration + 946684800) * 1000).toISOString()}`); } else { console.log(chalk.red('❌ UNL signature is invalid')); process.exit(1); } } catch (error) { console.error(chalk.red(`Error: ${error.message}`)); process.exit(1); } }; // Usage: // xrplf verify unl.json // // Output: // ✅ UNL signature is valid // Sequence: 2025100901 // Validators: 35 // Expiration: 2026-04-09T00:00:00.000Z ``` -------------------------------- ### Get Global Configuration Value - XRPL CLI Source: https://context7.com/xrplf/xrpl-cli/llms.txt Retrieves specific configuration values from the global config store. If a key does not exist, it returns a message indicating that no value is set. ```bash # Get a specific configuration value xrplf config get gcp_project_id # Get non-existent key xrplf config get missing_key ``` -------------------------------- ### XRPLF CLI Secrets Management Source: https://github.com/xrplf/xrpl-cli/blob/main/readme.md Commands for interacting with secret managers (local and GCP) to set and get secrets. Supports an optional service key prefix. ```bash xrplf secrets set --service="$optionalKeyPrefix" ``` ```bash xrplf secrets get --service="$optionalKeyPrefix" ``` ```bash xrplf secrets provider ``` -------------------------------- ### XRPLF CLI Basic Usage Source: https://github.com/xrplf/xrpl-cli/blob/main/readme.md Displays the help menu for the XRPLF CLI, listing available commands and their usage. ```bash xrplf help ``` -------------------------------- ### Clone XRPLF Repository Source: https://github.com/xrplf/xrpl-cli/blob/main/readme.md Clones the XRPLF infrastructure repository from GitHub. This is the first step to set up the CLI. ```bash git clone git@github.com:XRPLF/xrpl-infra.git ``` -------------------------------- ### List All Global Configuration Values - XRPL CLI Source: https://context7.com/xrplf/xrpl-cli/llms.txt Displays all currently stored global configuration key-value pairs in the user's home directory. ```bash # List all configuration values xrplf config list ``` -------------------------------- ### List All XRPLF Commands Source: https://github.com/xrplf/xrpl-cli/blob/main/readme.md Lists all available commands that can be executed by the XRPLF CLI. ```bash xrpl ``` -------------------------------- ### Initialize XRPL CLI with Environment Variables Source: https://context7.com/xrplf/xrpl-cli/llms.txt This command initializes the XRPL CLI, instructing it to use environment variables for validator keys instead of a secret store. Ensure the UNL_VALIDATOR_KEYS environment variable is properly set. ```bash export UNL_VALIDATOR_KEYS='{"vk":{...},"sk":{...}}' xrplf unl init --use_env ``` -------------------------------- ### Upload UNL to Google Cloud Storage Source: https://context7.com/xrplf/xrpl-cli/llms.txt Distributes generated UNL files by uploading them to a specified Google Cloud Storage bucket. The command handles bucket creation (if needed), setting public read permissions, uploading with gzip compression, and optimizing cache headers. ```bash # Upload UNL to default bucket xrplf unl upload xrplf-unl unl.json # Upload with flags xrplf unl upload --bucket=my-unl-bucket --file=unl.json # Skip confirmation for overwrites (automation) xrplf unl upload --bucket=xrplf-unl --file=unl.json --quiet ``` -------------------------------- ### Link XRPLF CLI Globally Source: https://github.com/xrplf/xrpl-cli/blob/main/readme.md Makes the XRPLF CLI command globally accessible on your system using PNPM's link functionality. This allows you to run `xrplf` from any directory. ```bash pnpm link --global ``` -------------------------------- ### Initialize Validator Keys - XRPL CLI Source: https://context7.com/xrplf/xrpl-cli/llms.txt Generates or loads cryptographic keypairs (validator master key and ephemeral signing key) for signing UNLs. It checks the secret store for existing keys and prompts the user to save newly generated keys. ```bash # Initialize new validator keys (interactive) xrplf unl init ``` -------------------------------- ### Environment Configuration and Flag Defaults in JavaScript Source: https://context7.com/xrplf/xrpl-cli/llms.txt Configures CLI behavior using environment variables and default flag values. It demonstrates setting environment variables for different operating systems and accessing them within custom actions using helper functions like `setFlagDefaults` and `setContextFunctions`. This enables features like debug logging and interactive URL redirection. ```javascript // Set environment variables // macOS/Linux: export XRPL_CLI_SECRET_BACKEND=gcp export GCP_PROJECT_ID=xrplf-infra-shared export UNL_VALIDATOR_KEYS='{"vk":{...},"sk":{...}}' // Windows: // set XRPL_CLI_SECRET_BACKEND=gcp // set GCP_PROJECT_ID=xrplf-infra-shared // Environment loading happens automatically: // 1. System-level: ~/.config/xrplf/.env (or OS equivalent) // 2. Project-level: ./.env (current directory, overrides system) // Access in custom actions import { setFlagDefaults, setContextFunctions } from './lib/env.js'; export const exec = async (context) => { // Set up context helpers setContextFunctions(context); setFlagDefaults(context); // Use debug logging context.debugLog('Processing request...'); // Open URL interactively await context.redirect('https://explorer.xrpl.org', { incognito: false }); // Access flags if (context.flags.quiet) { // Skip output } if (context.flags.debug) { console.log('Debug mode enabled'); } }; // Common flags available: // --debug Enable debug output // --quiet Suppress interactive prompts // --service Service prefix for secrets ``` -------------------------------- ### List Secrets - XRPL CLI Source: https://context7.com/xrplf/xrpl-cli/llms.txt Displays available secrets from the configured backend. Note that the GCP provider only shows secret names, not their values, and the local Keytar provider does not support listing secrets. ```bash # List secrets (GCP only shows names) xrplf secret list # With service prefix xrplf secret list --service=unl ``` -------------------------------- ### Set Global Configuration Value - XRPL CLI Source: https://context7.com/xrplf/xrpl-cli/llms.txt Stores persistent configuration values in TOML format within the user's home directory. These values are accessible across all CLI sessions. Accepts single or multiple key-value pairs. ```bash xrplf config set gcp_project_id xrplf-infra-shared xrplf config set secret_backend gcp xrplf config set personality xrplf xrplf config set custom_endpoint https://s1.ripple.com ``` -------------------------------- ### Set Secret Storage Provider - XRPL CLI Source: https://context7.com/xrplf/xrpl-cli/llms.txt Configures the secret storage backend, allowing selection between the local OS keychain (macOS Keychain, Windows Credential Vault, Linux Secret Service) or Google Cloud Secret Manager. The GCP option may require prior authentication. ```bash # Use local keychain xrplf secret provider local # Use Google Cloud Secret Manager xrplf secret provider gcp ``` -------------------------------- ### Generate Signed UNL with XRPLF CLI Source: https://github.com/xrplf/xrpl-cli/blob/main/readme.md Generates a signed Unique Node List (UNL) file using keys stored in the secret manager. Requires a validators file and can specify an output directory. ```bash xrplf unl generate --validators="../unl/data/unl-raw.yaml" --output="/tmp/unl.json" ``` -------------------------------- ### Programmatic UNL Generation with XRPL Core Library Source: https://context7.com/xrplf/xrpl-cli/llms.txt Generates and signs Unique Node Lists (UNLs) using the XRPL core library. It requires validator configurations, cryptographic keys, and an XRPL client connection. The output is a signed UNL object, which is then saved to a JSON file. ```javascript import { Client as XrplClient } from 'xrpl'; import { createVL, generateKeyPair } from './lib/unl.js'; import yaml from 'yaml'; import fs from 'fs/promises'; // Generate validator keypairs const masterKey = generateKeyPair(); const ephemeralKey = generateKeyPair(); console.log('Master Key:', { publicKey: masterKey.nodePublicKeyHex, secretKey: masterKey.secret_key }); // Load validators from YAML const validatorsYaml = await fs.readFile('validators.yaml', 'utf8'); const config = yaml.parse(validatorsYaml); const validators = config.nodes.map(node => node.id); // Connect to XRPL const client = new XrplClient('wss://s2.ripple.com'); await client.connect(); // Generate sequence number (YYYYMMDDBB format) const now = new Date(); const year = now.getFullYear(); const month = String(now.getMonth() + 1).padStart(2, '0'); const day = String(now.getDate()).padStart(2, '0'); const minutesSinceMidnight = now.getHours() * 60 + now.getMinutes(); const bucket = String(Math.floor(minutesSinceMidnight / 15)).padStart(2, '0'); const sequence = Number(`${year}${month}${day}${bucket}`); // Set expiration to 180 days from now (Unix timestamp) const expiration = Math.floor((Date.now() + 180 * 24 * 60 * 60 * 1000) / 1000); // Create signed UNL const vl = await createVL( { privateKey: masterKey.secret_key, publicKey: masterKey.nodePublicKeyHex }, { privateKey: ephemeralKey.secret_key, publicKey: ephemeralKey.nodePublicKeyHex }, sequence, expiration, validators, client ); await client.disconnect(); // Save to file await fs.writeFile('unl.json', JSON.stringify(vl, null, 2)); console.log('UNL created:', { sequence, expiration: new Date(expiration * 1000).toISOString(), validators: validators.length, publicKey: vl.public_key }); // Output structure: // { // blob: "eyJzZXF1ZW5jZSI6MjAyNTEwMDkwMSw...", // manifest: "JAAAAAFxIXATMU...", // signature: "3045022100...", // public_key: "ED1234...", // version: 1 // } ``` -------------------------------- ### Set Google Cloud Project Environment Variable Source: https://github.com/xrplf/xrpl-cli/blob/main/readme.md Sets the `GOOGLE_CLOUD_PROJECT` environment variable, which is often required for XRPLF CLI commands interacting with Google Cloud services. ```bash export GOOGLE_CLOUD_PROJECT=xrplf-infra-shared ``` -------------------------------- ### Generate Signed UNL from YAML Source: https://context7.com/xrplf/xrpl-cli/llms.txt Generates a cryptographically signed Unique Node List (UNL) from a local or remote YAML file containing validator information. Options include specifying output file, compression, custom sequence numbers, expiration dates, and skipping confirmation prompts. ```bash # Create UNL from local YAML file xrplf unl generate validators.yaml --output=unl.json --compress # Create UNL from remote YAML file xrplf unl generate https://example.com/validators.yaml --output=unl.json # Specify custom sequence number (default: auto-generated from timestamp) xrplf unl generate validators.yaml --sequence=2025100901 --output=unl.json # Specify custom expiration (default: 180 days from now) xrplf unl generate validators.yaml --expiration="2026-04-09" --output=unl.json # Skip confirmation prompt (for automation) xrplf unl generate validators.yaml --output=unl.json --quiet ``` -------------------------------- ### Programmatic Secret Management in JavaScript Source: https://context7.com/xrplf/xrpl-cli/llms.txt Provides programmatic access to secret management within the XRPL CLI, supporting automatic detection of secret storage providers (local or GCP). It covers storing, retrieving, deleting, and listing secrets, along with error handling for operations. ```javascript import { getSecretProvider } from './lib/secrets.js'; // Get configured secret provider (local or GCP) const secrets = await getSecretProvider(); // Check which provider is active console.log(secrets.type()); // 'local' or 'gcp' // Store a secret await secrets.set('myservice', 'api_key', 'sk-1234567890'); // Retrieve a secret const apiKey = await secrets.get('myservice', 'api_key'); console.log(apiKey); // sk-1234567890 // Delete a secret await secrets.delete('myservice', 'api_key'); // List secrets (GCP only, returns array of secret names) const secretNames = await secrets.list('myservice'); console.log(secretNames); // Error handling try { const value = await secrets.get('service', 'missing_key'); if (value === null) { console.log('Secret not found'); } } catch (error) { console.error('Secret retrieval failed:', error.message); } ``` -------------------------------- ### Retrieve Secret Value - XRPL CLI Source: https://context7.com/xrplf/xrpl-cli/llms.txt Fetches stored secrets from the configured backend. Secrets can be retrieved directly or by specifying a service prefix. Handles non-existent secrets by indicating they are not set. ```bash # Get secret value xrplf secret get api_token # Get secret with service prefix xrplf secret get --service=unl validator_keys # Get non-existent secret xrplf secret get missing_secret ``` -------------------------------- ### Store Secret Value - XRPL CLI Source: https://context7.com/xrplf/xrpl-cli/llms.txt Stores sensitive values in the currently configured secret backend. Secrets can be set interactively, via standard input (stdin) for automation, or with a custom service prefix to scope them. ```bash # Store secret interactively xrplf secret set api_token # Store secret via stdin echo "my-secret-value" | xrplf secret set api_token # Store secret with custom service prefix echo '{"vk":{"privateKey":"ED..."}}' | xrplf secret set --service=unl validator_keys ``` -------------------------------- ### Delete Global Configuration Value - XRPL CLI Source: https://context7.com/xrplf/xrpl-cli/llms.txt Removes a configuration value from the global config store. If the specified key does not exist, it informs the user that no value is set for that key. ```bash # Delete a configuration value xrplf config delete old_key # Try to delete non-existent key xrplf config delete missing_key ``` -------------------------------- ### Delete Secret - XRPL CLI Source: https://context7.com/xrplf/xrpl-cli/llms.txt Removes a secret from the configured backend. This operation can be performed on secrets stored directly or those scoped with a service prefix. It confirms successful deletion or indicates if the secret was not found. ```bash # Delete a secret xrplf secret delete old_api_token # Delete with service prefix xrplf secret delete --service=unl validator_keys ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.