Skip to content

Module X402::Wallet

Helpers for loading and persisting the server wallet key.

The gem uses BSV::Wallet::WalletClient as the concrete BRC-100 wallet. This module provides a loader that resolves the signing WIF from either the SERVER_WIF environment variable or an on-disk wallet.key file, and constructs a WalletClient with a FileStore pointed at the same directory.

See lib/tasks/x402.rake for the interactive +rake x402:wallet:setup+ task which creates or restores the on-disk wallet.key.

Constants

DEFAULT_DIR

Not documented.

KEY_FILENAME

Not documented.

Public Class Methods

key_path(dir: = nil)

Returns the canonical path to the on-disk wallet key file for the given directory. - @param dir [String, nil] optional override - @return [String] absolute path

load(dir: = nil)

Resolve the signing WIF and construct a BSV::Wallet::WalletClient.

Resolution order (locked per HLR #104): 1. +SERVER_WIF+ environment variable (wins if set) 2. +

/wallet.key+ file (default: +~/.bsv-wallet/wallet.key+, or +BSV_WALLET_DIR+ if set) 3. Raises +ConfigurationError+ with a hint to run the setup task - @param dir [String, nil] override the wallet directory (rarely needed — prefer +BSV_WALLET_DIR+ env var for process-wide config) - @raise [ConfigurationError] if no WIF can be resolved - @return [BSV::Wallet::WalletClient]