LEARNING

A project knowledge command that records lessons learned, debugging findings, and recurring code patterns from a Bitcoin wallet command-line tool.

In plain words
What is it for?
It helps investigate command behavior, document gotchas, and check known causes of issues such as missing balances or incorrect key derivation.
Why use it?
It keeps important discoveries in one place, so developers can avoid repeating mistakes when working with ownership, storage, configuration, and wallet behavior.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/calhooon/bsv-wallet-cli/learning
Clone the repo
git clone --depth 1 https://github.com/Calhooon/bsv-wallet-cli
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 838 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00838
Opus 5 $0.00000 $0.00419
Sonnet 5 $0.00000 $0.00168
Haiku 4.5 $0.00000 $0.00084

Measured yesterday against content hash 934fcc199351, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

LEARNING scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

src/commands/LEARNING.md · 20 lines

How it starts

The opening of the file, as written. The whole thing — 20 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Learning — commands

Lessons Learned

  • [2026-02-24] daemon opens SQLite twice — once for Monitor (needs Arc<Storage>) and once for Wallet (takes owned StorageSqlx). This is because Wallet::new consumes ownership. If you try to share a single connection, the borrow checker stops you. Same pattern applies to Services.
  • [2026-02-24] serve takes WalletContext by value (not &WalletContext like other commands) because it moves ctx.wallet into the shared server state via make_wallet_state. This means serve consumes the context — you can't use it after calling serve::run.
  • [2026-02-24] init writes .env to CWD, not ~/.config/ or any global path. Easy to lose the root key if you init from a temp directory. The key is also printed to stdout, so capture it.

Debugging Insights

  • [2026-02-24] If balance returns 0 but outputs shows UTXOs, check the basket name. balance hardcodes "default" basket. Outputs in other baskets (e.g., from custom internalizeAction calls) won't appear.
  • [2026-02-24] fund failures often trace back to derivation mismatches. The anyone_key() counterparty + BRC-29 constants (SfKxPIJNgdI=, NaGLC6fMH50=) must match exactly what address used to generate the funding address. If the address derivation changes, fund silently produces an output the wallet can't spend.
  • [2026-02-24] daemon's UTXO check runs every 5 minutes and logs via tracing::warn. If you don't see warnings, check RUST_LOG is set to at least warn. The threshold defaults to 3 (MIN_UTXOS env var).
  • [2026-02-24] split with a low balance will bail with "Balance too low" even if you have UTXOs, because it reserves 200 sats for fees. With 1 UTXO at 200 sats, the available balance is 0.

Pattern Notes

  • [2026-02-24] Three files duplicate BRC-29 constants (DEFAULT_DERIVATION_PREFIX, DEFAULT_DERIVATION_SUFFIX, BRC29_PROTOCOL): address.rs, split.rs, fund.rs. These must stay in sync. A shared constants module would prevent drift, but hasn't been extracted yet.
  • [2026-02-24] Every command follows the same JSON output pattern: if ctx.json_output { serde_json::json!(...) } else { println!(...) }. The --json flag on the CLI propagates through WalletContext. New commands should follow this convention.
  • [2026-02-24] Commands split into two initialization patterns: most take &WalletContext, but init, daemon, and services take &Cli directly. init has no wallet yet; daemon needs separate Arc ownership; services only needs chain info, not a full wallet.
  • [2026-02-24] send tags outputs as "relinquish" — this is how the wallet knows not to count sent coins in its own balance. Forgetting this tag causes sent funds to appear as spendable.
  • [2026-02-24] outputs and actions only fetch page 1 (limit 100). balance is the only command that paginates exhaustively. If a wallet has >100 UTXOs, outputs will show a partial view.

Read the full file on GitHub · 20 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 20 lines · 0 tokens per session scan A 934fcc199351

Subscribe to this mod's changes

LEARNING is a command published in the GitHub repository Calhooon/bsv-wallet-cli (10 stars, last pushed 3d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 838 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.