[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M76WSH9VAM24WJPZN19AEGC0":3,"skill-same:01M76WSH9VAM24WJPZN19AEGC0":55},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":32,"commitSha":33,"skillDirectory":34,"forksCount":35,"repositoryHtmlUrl":36,"repositoryHomepageUrl":6,"ownerHtmlUrl":37,"ownerBlogUrl":38,"ownerDescription":39,"updatedAt":40,"install":41,"resources":54},"01M76WSH9VAM24WJPZN19AEGC0","bitkit-cli",null,"Bitcoin Lightning payment CLI for agents. Lowest LSP fees. Self-custody wallet with LNURL, typed exit codes, JSON envelope output, encrypted messaging, and daemon mode.","javimosch\u002Fopen-claw-skills","javimosch","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F12900508?v=4","01M6D3F2AS6PV75ET9PZ1QGP8J","Javier Leandro Arancibia","01M75B8NCTAJG9WH5YNZH7C3D8",0,"MIT","https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fovitrif\u002Fbitkit-cli\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: bitkit-cli\ndescription: Bitcoin Lightning payment CLI for agents. Lowest LSP fees. Self-custody wallet with LNURL, typed exit codes, JSON envelope output, encrypted messaging, and daemon mode.\nversion: 0.2.0\nmetadata:\n  clawdbot:\n    requires:\n      bins: [bitkit]\n    homepage: https:\u002F\u002Fgithub.com\u002Fsynonymdev\u002Fbitkit-cli\n    emoji: \"\\u26A1\"\n---\n\n# bitkit-cli -- AI Agent Skill\n\nBitcoin Lightning payment CLI for agents. Lowest LSP fees. Self-custody wallet with LNURL\u002FLightning Address support, typed exit codes, JSON envelope output, encrypted Pubky messaging, and daemon mode.\n\n**Install:** `curl -sSL https:\u002F\u002Fraw.githubusercontent.com\u002Fsynonymdev\u002Fbitkit-cli\u002Fmain\u002Finstall.sh | sh`\n**Binary names:** `bitkit` or `bk` (identical alias)\n**Always use:** `--json` flag on every invocation for parseable output.\n\n## JSON Envelope\n\nAll `--json` output uses a consistent envelope:\n\n**Success** (stdout):\n```json\n{ \"ok\": true, \"data\": { ... } }\n```\n\n**Error** (stderr):\n```json\n{ \"ok\": false, \"error\": \"message\", \"code\": 1 }\n```\n\nParse with: `jq -r '.data.field'` for success data, check `.ok` first.\n\n## Quick Start\n\n```bash\n# 1. Create wallet (no encryption for agent use)\nbk init --no-password --json\n\n# 2. Start daemon for instant command execution\nbk start --json\n\n# 3. Get on-chain address and fund it\nADDRESS=$(bk address --json | jq -r '.data.address')\n\n# 4. Order inbound Lightning liquidity via LSP\nORDER=$(bk lsp create-order 500000 --json)\nORDER_ID=$(echo \"$ORDER\" | jq -r '.data.order_id')\n\n# 5. Pay the order (on-chain to payment_address), then open channel\nbk lsp open-channel \"$ORDER_ID\" --listen 9735 --json\n\n# 6. Create an invoice and receive payment\nbk invoice 5000 --description \"agent service\" --wait --listen 9735 --json\n\n# 7. Pay someone else's invoice\nbk pay lnbc50u1p... --json\n\n# 8. Check balance and history\nbk balance --json\nbk history --json\n\n# 9. Stop daemon when done\nbk stop --json\n```\n\n## Daemon Mode\n\nBy default each command cold-starts the LDK node (slow). Start a persistent daemon for instant execution:\n\n```bash\nbk start --json           # start daemon (default port 3457)\nbk status --json          # check if running\nbk balance --json         # instant -- proxied through daemon\nbk stop --json            # stop daemon\n```\n\nWhen the daemon is running, all commands automatically proxy through its HTTP API. When stopped, commands fall back to per-command cold-start. No code changes needed.\n\n### `start`\n\nStart the background daemon. Idempotent -- returns current PID if already running.\n\n```bash\nbk start --json\nbk start --port 8080 --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"status\": \"started\",\n    \"pid\": 12345,\n    \"port\": 3457\n  }\n}\n```\n\n| Arg | Default | Description |\n|-----|---------|-------------|\n| `--port \u003Cport>` | `3457` | HTTP API port |\n\n`status` is `\"started\"` or `\"already_running\"`.\n\n### `stop`\n\nStop the running daemon.\n\n```bash\nbk stop --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"status\": \"stopped\",\n    \"pid\": 12345\n  }\n}\n```\n\nErrors if no daemon is running (exit code 1).\n\n### `status`\n\nCheck daemon status.\n\n```bash\nbk status --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"running\": true,\n    \"pid\": 12345,\n    \"port\": 3457,\n    \"started_at\": \"2026-02-19T10:00:00+00:00\",\n    \"version\": \"0.1.0\"\n  }\n}\n```\n\nWhen stopped: `running` is `false`, all other fields are `null`.\n\n## Global Flags\n\n| Flag | Env Variable | Default | Description |\n|------|-------------|---------|-------------|\n| `--json` | -- | off | Machine-readable JSON to stdout |\n| `--dir \u003Cpath>` | `BITKIT_DIR` | `~\u002F.bitkit\u002F` | Wallet data directory |\n| `--network \u003Cnet>` | `BITKIT_NETWORK` | `mainnet` | `mainnet` or `regtest` |\n| `--listen \u003Cport>` | `BITKIT_LISTEN` | off | P2P listen port on `0.0.0.0:\u003Cport>` |\n| `--password \u003Cpw>` | `BITKIT_PASSWORD` | -- | Wallet password (for encrypted seeds) |\n\n## Command Reference\n\n### Wallet\n\n#### `init`\n\nCreate a new wallet. Idempotent -- re-running prints existing wallet info.\n\n```bash\nbk init --no-password --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"node_id\": \"02abc123...\",\n    \"seed_phrase\": \"abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about\",\n    \"wallet_dir\": \"\u002Froot\u002F.bitkit\",\n    \"network\": \"mainnet\",\n    \"pubky_id\": \"8pinxrz9tuxfz3qo5gkhdebuhtq6mrimh3matdncsrsno7kg45mo\"\n  }\n}\n```\n\n| Arg | Required | Description |\n|-----|----------|-------------|\n| `--no-password` | one of | Store seed as plaintext (for agents) |\n| `--password \u003Cpw>` | one of | Encrypt seed with AES-256-GCM + Argon2id |\n\n#### `info`\n\nShow node status, channel counts, sync state.\n\n```bash\nbk info --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"node_id\": \"02abc123...\",\n    \"network\": \"mainnet\",\n    \"channels_active\": 1,\n    \"channels_pending\": 0,\n    \"block_height\": 880000,\n    \"synced\": true,\n    \"wallet_dir\": \"\u002Froot\u002F.bitkit\"\n  }\n}\n```\n\n#### `balance`\n\nShow Lightning and on-chain balances in satoshis.\n\n```bash\nbk balance --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"lightning_sats\": 450000,\n    \"onchain_sats\": 50000,\n    \"total_sats\": 500000,\n    \"total_onchain_sats\": 55000,\n    \"anchor_reserve_sats\": 5000,\n    \"pending_sweep_sats\": 0,\n    \"pending_sweeps\": []\n  }\n}\n```\n\n- `onchain_sats` -- spendable on-chain balance\n- `total_onchain_sats` -- all on-chain funds including reserved\n- `anchor_reserve_sats` -- sats reserved for anchor channel fees\n- `pending_sweep_sats` -- funds sweeping from closed channels (not yet spendable)\n- `pending_sweeps` -- array of sweep entries with `amount_sats`, `status`, `spending_txid`, `confirmation_height`\n\n| Arg | Description |\n|-----|-------------|\n| `--btc` | Display in BTC instead of sats (human output only) |\n\n#### `config`\n\nShow resolved configuration with source tracking. Does not start the node.\n\n```bash\nbk config --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"network\": { \"value\": \"mainnet\", \"source\": \"default\" },\n    \"wallet_dir\": { \"value\": \"\u002Froot\u002F.bitkit\", \"source\": \"default\" },\n    \"chain_source\": { \"value\": \"esplora\", \"source\": \"file\" },\n    \"esplora_url\": { \"value\": \"https:\u002F\u002Fblockstream.info\u002Fapi\", \"source\": \"file\" },\n    \"electrum_url\": { \"value\": \"\", \"source\": \"file\" },\n    \"rgs_url\": { \"value\": \"https:\u002F\u002Frapidsync.lightningdevkit.org\u002Fsnapshot\", \"source\": \"file\" },\n    \"blocktank_url\": { \"value\": \"https:\u002F\u002Fapi1.blocktank.to\u002Fapi\", \"source\": \"file\" },\n    \"listen_port\": { \"value\": \"off\", \"source\": \"default\" }\n  }\n}\n```\n\nEach entry has `value` (resolved value) and `source` (`cli`, `env`, `file`, or `default`).\n\n#### `address`\n\nGet a new on-chain receive address. Generates a fresh address each call. Optionally validate an existing address.\n\n```bash\nbk address --json\nbk address --type taproot --json\nbk address --validate bc1q... --json\n```\n\nGenerate address:\n```json\n{\n  \"ok\": true,\n  \"data\": { \"address\": \"bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4\", \"address_type\": \"native-segwit\" }\n}\n```\n\nValidate address (`--validate`):\n```json\n{\n  \"ok\": true,\n  \"data\": { \"address\": \"bc1q...\", \"valid\": true, \"network\": \"mainnet\", \"reason\": null }\n}\n```\n\nOn invalid address: `valid` is `false` and `reason` explains why.\n\n| Arg | Default | Description |\n|-----|---------|-------------|\n| `--type \u003Ctype>` | `native-segwit` | Address type: `legacy`, `nested-segwit`, `native-segwit`, `taproot` |\n| `--validate \u003Caddr>` | -- | Validate `\u003Caddr>` for the current network; no node start needed |\n| `--qr` | off | Display address as QR code in terminal (human output only) |\n\n#### `send`\n\nSend bitcoin on-chain to an address.\n\n```bash\nbk send bc1q... 50000 --json\nbk send bc1q... 50000 --fee-rate 5 --json\nbk send bc1q... --drain --json\nbk send bc1q... 50000 --utxo \u003Ctxid>:\u003Cvout> --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"txid\": \"abc123...\",\n    \"address\": \"bc1q...\",\n    \"amount_sats\": 50000,\n    \"drain\": false,\n    \"fee_rate_sat_per_vb\": 5,\n    \"utxos_used\": [\"abc123...:0\"]\n  }\n}\n```\n\nWhen `--drain` is used, `amount_sats` is `null`. When no `--fee-rate` is set, `fee_rate_sat_per_vb` is `null`.\n\n| Arg | Default | Description |\n|-----|---------|-------------|\n| `\u003Caddress>` | required | Destination Bitcoin address |\n| `\u003Camount_sats>` | -- | Amount in satoshis (omit with `--drain`) |\n| `--drain` | off | Send all spendable funds (mutually exclusive with `--utxo`) |\n| `--fee-rate \u003Csat\u002Fvb>` | auto | Fee rate in sat\u002Fvb |\n| `--utxo \u003Ctxid:vout>` | -- | Spend a specific UTXO (repeatable; incompatible with `--drain`) |\n\n#### `list-utxos`\n\nList all spendable UTXOs in the on-chain wallet.\n\n```bash\nbk list-utxos --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"utxos\": [\n      {\n        \"txid\": \"abc123...\",\n        \"vout\": 0,\n        \"value_sats\": 1000000,\n        \"outpoint\": \"abc123...:0\"\n      }\n    ],\n    \"total_sats\": 1000000,\n    \"count\": 1\n  }\n}\n```\n\nUse `outpoint` values (e.g. `abc123...:0`) as `--utxo` arguments for `send` and `estimate-fee`.\n\n#### `estimate-fee`\n\nPreview the fee for an on-chain send without broadcasting.\n\n```bash\nbk estimate-fee bc1q... 50000 --json\nbk estimate-fee bc1q... 50000 --fee-rate 5 --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"fee_sats\": 250,\n    \"address\": \"bc1q...\",\n    \"amount_sats\": 50000,\n    \"fee_rate_sat_per_vb\": 5\n  }\n}\n```\n\n`fee_rate_sat_per_vb` is `null` when not specified (node chooses automatically).\n\n| Arg | Default | Description |\n|-----|---------|-------------|\n| `\u003Caddress>` | required | Destination Bitcoin address |\n| `\u003Camount_sats>` | required | Amount to send in satoshis |\n| `--fee-rate \u003Csat\u002Fvb>` | auto | Override fee rate in sat\u002Fvb |\n| `--utxo \u003Ctxid:vout>` | -- | Restrict coin selection to specific UTXOs |\n\n#### `bump-fee`\n\nReplace an unconfirmed transaction with a higher-fee version (RBF). The original transaction must be in the mempool and RBF-enabled.\n\n```bash\nbk bump-fee \u003Ctxid> \u003Cfee_rate> --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"original_txid\": \"abc123...\",\n    \"new_txid\": \"def456...\",\n    \"fee_rate_sat_per_vb\": 20\n  }\n}\n```\n\n| Arg | Description |\n|-----|-------------|\n| `\u003Ctxid>` | TXID of the unconfirmed transaction to replace |\n| `\u003Cfee_rate>` | New fee rate in sat\u002Fvb (must be higher than the original) |\n\nOn failure (invalid txid, not in mempool, RBF not signalled): exits with code 1.\n\n#### `cpfp`\n\nAccelerate a stuck transaction by spending one of its outputs at a higher fee rate (Child-Pays-For-Parent).\n\n```bash\nbk cpfp \u003Ctxid> --json\nbk cpfp \u003Ctxid> --fee-rate 30 --json\nbk cpfp \u003Ctxid> --urgent --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"parent_txid\": \"abc123...\",\n    \"child_txid\": \"def456...\",\n    \"fee_rate_sat_per_vb\": 30,\n    \"urgent\": false\n  }\n}\n```\n\n`fee_rate_sat_per_vb` is `null` when neither `--fee-rate` nor `--urgent` is set.\n\n| Arg | Default | Description |\n|-----|---------|-------------|\n| `\u003Ctxid>` | required | TXID of the parent transaction to accelerate |\n| `--fee-rate \u003Csat\u002Fvb>` | auto | Explicit fee rate for the child transaction |\n| `--urgent` | off | Automatically compute a high fee rate to confirm next block |\n\nOn failure (invalid txid, no spendable output found): exits with code 1.\n\n#### `history`\n\nList recent transactions, newest first.\n\n```bash\nbk history --limit 5 --type send --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": [\n    {\n      \"type\": \"send\",\n      \"amount_sat\": 5000,\n      \"fee_sat\": 3,\n      \"status\": \"complete\",\n      \"timestamp\": \"2026-02-15 12:00:00\",\n      \"description\": \"coffee\"\n    }\n  ]\n}\n```\n\n| Arg | Default | Description |\n|-----|---------|-------------|\n| `--limit \u003Cn>` | `20` | Number of entries |\n| `--type \u003Csend\\|recv>` | all | Filter by direction |\n\n**Status values:** `complete`, `pending`, `failed`\n**Type values:** `send`, `recv`\n\n### Lightning Payments\n\n#### `invoice`\n\nGenerate a BOLT 11 invoice to receive payment.\n\n```bash\nbk invoice 5000 --description \"agent service\" --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"bolt11\": \"lnbc50u1p...\",\n    \"payment_hash\": \"a1b2c3d4e5f6...\",\n    \"amount_sat\": 5000,\n    \"description\": \"agent service\",\n    \"expires_at\": \"2026-02-15T14:30:00+00:00\"\n  }\n}\n```\n\n| Arg | Default | Description |\n|-----|---------|-------------|\n| `\u003Camount_sats>` | required | Amount in satoshis |\n| `--description \u003Ctext>` | `\"\"` | Invoice memo |\n| `--expiry \u003Csecs>` | `3600` | Invoice expiry in seconds |\n| `--wait` | off | Block until payment received |\n| `--timeout \u003Csecs>` | `300` | Timeout when using `--wait` |\n| `--qr` | off | Display invoice as QR code in terminal (human output only) |\n\n**Two-phase output with `--wait`:** First prints the invoice envelope above, then blocks. When payment arrives, prints a second envelope to stdout:\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"status\": \"received\",\n    \"amount_sat\": 5000,\n    \"payment_hash\": \"a1b2c3d4e5f6...\"\n  }\n}\n```\n\nIf timeout expires, exits with code 2 (network error). Always use `--listen \u003Cport>` with `--wait` so the payer can connect.\n\n#### `pay`\n\nPay a BOLT 11 invoice, LNURL, or Lightning Address. Polls until success, failure, or timeout.\n\n```bash\nbk pay lnbc50u1p... --json\nbk pay lnurl1dp68gurn... --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"status\": \"success\",\n    \"amount_sat\": 5000,\n    \"fee_sat\": 3,\n    \"payment_hash\": \"a1b2c3d4e5f6...\",\n    \"preimage\": \"1a2b3c4d5e6f...\"\n  }\n}\n```\n\n| Arg | Default | Description |\n|-----|---------|-------------|\n| `\u003Cbolt11>` | required | BOLT 11 invoice, LNURL, or Lightning Address |\n| `--max-fee \u003Csats>` | unlimited | Maximum routing fee in satoshis |\n| `--timeout \u003Csecs>` | `60` | Payment timeout |\n\n**LNURL\u002FLightning Address support:** `pay` accepts LNURL (`lnurl1...`) and resolves to a BOLT11 invoice. For LNURL-pay with variable amounts (where `min_sendable != max_sendable`), the CLI currently requires a fixed-amount LNURL. Lightning Address (`user@domain.tld`) requires a `--amount` flag which is not yet implemented — use a BOLT11 invoice instead.\n\nOn failure: exits with code 1 (\"Payment failed\"). On timeout: exits with code 2.\n\n#### `withdraw`\n\nWithdraw from an LNURL-withdraw endpoint. Creates an invoice and submits it to the LNURL service.\n\n```bash\nbk withdraw lnurl1dp68gurn... --json\nbk withdraw lnurl1dp68gurn... --amount 10000 --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"status\": \"submitted\",\n    \"amount_sat\": 10000,\n    \"bolt11\": \"lnbc100u1p...\"\n  }\n}\n```\n\n| Arg | Default | Description |\n|-----|---------|-------------|\n| `\u003Clnurl>` | required | LNURL-withdraw bech32 string |\n| `--amount \u003Csats>` | max withdrawable | Amount in satoshis |\n\n### Channels\n\n#### `open-channel`\n\nOpen a Lightning channel to a peer. Requires on-chain funds.\n\n```bash\nbk open-channel 02ab...@127.0.0.1:9735 100000 --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"channel_id\": \"12345678901234567890\",\n    \"peer\": \"02ab...\",\n    \"amount_sats\": 100000\n  }\n}\n```\n\n| Arg | Description |\n|-----|-------------|\n| `\u003Cpeer>` | Peer in `pubkey@host:port` format |\n| `\u003Camount_sats>` | Channel capacity in satoshis |\n| `--push \u003Csats>` | Give the peer initial balance |\n\n#### `close-channel`\n\nClose a Lightning channel. Get `channel_id` and `peer` from `list-channels`.\n\n```bash\nbk close-channel 12345678901234567890 02ab... --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"channel_id\": \"12345678901234567890\",\n    \"status\": \"closing\"\n  }\n}\n```\n\n| Arg | Description |\n|-----|-------------|\n| `\u003Cchannel_id>` | Channel ID (decimal, from `list-channels`) |\n| `\u003Cpeer>` | Counterparty node public key |\n| `--force` | Force close (use when peer is unresponsive) |\n\n**Status values:** `closing` (cooperative), `force_closing`\n\n#### `list-channels`\n\nList all Lightning channels with capacity, balances, and status.\n\n```bash\nbk list-channels --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": [\n    {\n      \"channel_id\": \"12345678901234567890\",\n      \"peer\": \"02ab...\",\n      \"capacity_sats\": 500000,\n      \"local_balance_msat\": 250000000,\n      \"remote_balance_msat\": 250000000,\n      \"is_usable\": true,\n      \"is_channel_ready\": true,\n      \"is_outbound\": false\n    }\n  ]\n}\n```\n\nNote: balances are in millisatoshis. Divide by 1000 for satoshis.\n\n### LSP (Blocktank Liquidity)\n\nUse the Blocktank LSP to get inbound Lightning liquidity without manually finding peers.\n\n#### `lsp info`\n\nGet LSP service info: available nodes, channel limits, fee rates.\n\n```bash\nbk lsp info --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"nodes\": [\n      {\n        \"alias\": \"blocktank-lsp\",\n        \"pubkey\": \"02abc...\",\n        \"connection_strings\": [\"02abc...@1.2.3.4:9735\"]\n      }\n    ],\n    \"min_channel_size_sats\": 20000,\n    \"max_channel_size_sats\": 5000000,\n    \"min_expiry_weeks\": 2,\n    \"max_expiry_weeks\": 52,\n    \"network\": \"Mainnet\",\n    \"fee_rates_fast\": 10,\n    \"fee_rates_mid\": 5,\n    \"fee_rates_slow\": 1\n  }\n}\n```\n\n#### `lsp estimate-fee`\n\nEstimate the cost of a channel order before creating it.\n\n```bash\nbk lsp estimate-fee 500000 --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"fee_sats\": 500,\n    \"network_fee_sats\": 300,\n    \"service_fee_sats\": 200\n  }\n}\n```\n\n| Arg | Default | Description |\n|-----|---------|-------------|\n| `\u003Clsp_balance_sats>` | required | Inbound liquidity amount |\n| `--expiry \u003Cweeks>` | `6` | Channel expiry in weeks |\n| `--client-balance-sats \u003Csats>` | `0` | Outbound liquidity (your side) |\n\n#### `lsp create-order`\n\nCreate a channel order. Returns payment details.\n\n```bash\nbk lsp create-order 500000 --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"order_id\": \"ord-abc123...\",\n    \"state\": \"Created\",\n    \"fee_sats\": 500,\n    \"lsp_balance_sats\": 500000,\n    \"client_balance_sats\": 0,\n    \"payment_address\": \"bc1q...\",\n    \"payment_bolt11\": \"lnbc...\",\n    \"order_expires_at\": \"2026-03-01T00:00:00Z\"\n  }\n}\n```\n\n| Arg | Default | Description |\n|-----|---------|-------------|\n| `\u003Clsp_balance_sats>` | required | Inbound liquidity amount |\n| `--expiry \u003Cweeks>` | `6` | Channel expiry in weeks |\n| `--client-balance-sats \u003Csats>` | `0` | Your outbound balance |\n| `--zero-conf` | off | Enable zero-conf channel |\n\nAfter creating, pay to `payment_address` (on-chain) or `payment_bolt11` (Lightning). Then poll `get-order` until state becomes `Paid`.\n\n#### `lsp get-order`\n\nCheck the status of an order.\n\n```bash\nbk lsp get-order ord-abc123 --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"order_id\": \"ord-abc123...\",\n    \"state\": \"Open\",\n    \"state2\": \"Paid\",\n    \"fee_sats\": 500,\n    \"lsp_balance_sats\": 500000,\n    \"client_balance_sats\": 0,\n    \"channel_expiry_weeks\": 6,\n    \"channel_state\": \"Opening\",\n    \"funding_tx\": \"abc123def...\",\n    \"payment_state\": \"Paid\",\n    \"order_expires_at\": \"2026-03-01T00:00:00Z\",\n    \"created_at\": \"2026-02-17T00:00:00Z\"\n  }\n}\n```\n\n`channel_state` and `funding_tx` are `null` until the channel is being opened.\n\n**State enum values for `lsp get-order`:**\n\n| Field | Values | Description |\n|-------|--------|-------------|\n| `state` | `Created`, `Open`, `Expired`, `Closed` | Legacy order state |\n| `state2` | `Created`, `Paid`, `Executed`, `Expired` | Current order state (prefer this) |\n| `channel_state` | `Opening`, `Open`, `Closed` | Channel lifecycle state |\n| `payment_state` | `Created`, `Paid`, `Refunded`, `RefundAvailable`, `Canceled` | Payment lifecycle state |\n\nPoll `state2` for order progress: `Created` → `Paid` (after on-chain payment) → `Executed` (channel opened).\n\n#### `lsp open-channel`\n\nTell Blocktank to open a channel to your node. The order must be in `Paid` state. Requires `--listen` so Blocktank can connect.\n\n```bash\nbk lsp open-channel ord-abc123 --listen 9735 --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"order_id\": \"ord-abc123...\",\n    \"state\": \"Open\",\n    \"channel_state\": \"Opening\",\n    \"funding_tx\": \"abc123def...\"\n  }\n}\n```\n\n### Messaging (Pubky Encrypted)\n\nEnd-to-end encrypted messaging via the Pubky network. Identity is created during `init`.\n\n#### `message whoami`\n\nPrint your Pubky messaging ID. Does not require network access.\n\n```bash\nbk message whoami --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"pubky_id\": \"8pinxrz9tuxfz3qo5gkhdebuhtq6mrimh3matdncsrsno7kg45mo\"\n  }\n}\n```\n\n#### `message send`\n\nSend an encrypted message to a peer.\n\n```bash\nbk message send 8pin...xyz '{\"type\":\"invoice\",\"bolt11\":\"lnbc...\",\"amount_sats\":5000,\"description\":\"service\"}' --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"message_id\": \"abc-123-def\",\n    \"recipient\": \"8pin...xyz\"\n  }\n}\n```\n\n| Arg | Description |\n|-----|-------------|\n| `\u003Cpubky>` | Recipient's Pubky ID |\n| `\u003Ctext>` | Message content (plain text or JSON string) |\n\n#### `message read`\n\nRead the full conversation with a peer, sorted by timestamp.\n\n```bash\nbk message read 8pin...xyz --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"messages\": [\n      {\n        \"sender\": \"8pin...abc\",\n        \"content\": \"{\\\"type\\\":\\\"invoice\\\",\\\"bolt11\\\":\\\"lnbc...\\\",\\\"amount_sats\\\":5000,\\\"description\\\":\\\"service\\\"}\",\n        \"timestamp\": 1708000000,\n        \"verified\": true\n      }\n    ]\n  }\n}\n```\n\n| Field | Description |\n|-------|-------------|\n| `sender` | Pubky ID of the message author |\n| `content` | Message text (may contain JSON -- parse it) |\n| `timestamp` | Unix timestamp in seconds |\n| `verified` | `true` if cryptographic signature verified |\n\n#### `message listen`\n\nPoll for new messages from a peer. Streams one envelope per line to stdout as messages arrive.\n\n```bash\nbk message listen 8pin...xyz --interval 3 --timeout 120 --json\n```\n\nEach new message is printed as a single-line envelope:\n\n```json\n{\"ok\":true,\"data\":{\"sender\":\"8pin...abc\",\"content\":\"hello\",\"timestamp\":1708000001,\"verified\":true}}\n```\n\n| Arg | Default | Description |\n|-----|---------|-------------|\n| `\u003Cpubky>` | required | Peer's Pubky ID |\n| `--interval \u003Csecs>` | `3` | Poll interval |\n| `--timeout \u003Csecs>` | `0` (forever) | Stop after this many seconds |\n\nStatus messages go to stderr. Only message JSON goes to stdout.\n\n## Agent Integration\n\n### Daemon HTTP API\n\nWhen the daemon is running (`bk start`), all commands proxy through an HTTP API on `localhost:3457` (configurable via `--port`). The API uses HTTP Basic Auth with auto-generated credentials.\n\n**Authentication:** HTTP Basic Auth (`bitkit:\u003Cpassword>`). Password is auto-generated on first `bk start` and stored in `\u003Cwallet_dir>\u002Fapi-password`.\n\n**Endpoints:**\n\n| Method | Path | Description |\n|--------|------|-------------|\n| GET | `\u002Fhealth` | Health check (no auth) |\n| GET | `\u002Fbalance` | Wallet balance |\n| GET | `\u002Finfo` | Node info |\n| GET | `\u002Fhistory?limit=20&type=send` | Payment history |\n| GET | `\u002Fchannels` | List channels |\n| GET | `\u002Futxos` | List UTXOs |\n| POST | `\u002Faddress` | Generate receive address |\n| POST | `\u002Fsend` | Send on-chain |\n| POST | `\u002Finvoice` | Create Lightning invoice |\n| POST | `\u002Fpay` | Pay Lightning invoice |\n| POST | `\u002Festimate-fee` | Estimate on-chain fee |\n| POST | `\u002Fbump-fee` | RBF fee bump |\n| POST | `\u002Fcpfp` | CPFP acceleration |\n| POST | `\u002Fchannels\u002Fopen` | Open channel |\n| POST | `\u002Fchannels\u002Fclose` | Close channel |\n| GET | `\u002Fevents` | WebSocket event stream |\n\nAll responses use the same JSON envelope as CLI `--json` output: `{\"ok\": true, \"data\": {...}}`.\n\n**POST Request Body Schemas:**\n\n`POST \u002Faddress`:\n```json\n{ \"address_type\": \"native-segwit\" }\n```\n`address_type` is optional. Values: `legacy`, `nested-segwit`, `native-segwit`, `taproot`.\n\n`POST \u002Fsend`:\n```json\n{ \"address\": \"bc1q...\", \"amount_sats\": 50000, \"drain\": false, \"fee_rate\": 5, \"utxos\": [\"txid:0\"] }\n```\n`amount_sats` is required unless `drain` is `true`. `fee_rate`, `drain`, `utxos` are optional.\n\n`POST \u002Festimate-fee`:\n```json\n{ \"address\": \"bc1q...\", \"amount_sats\": 50000, \"fee_rate\": 5, \"utxos\": [\"txid:0\"] }\n```\n`fee_rate` and `utxos` are optional.\n\n`POST \u002Fbump-fee`:\n```json\n{ \"txid\": \"abc123...\", \"fee_rate\": 20 }\n```\nBoth fields required.\n\n`POST \u002Fcpfp`:\n```json\n{ \"txid\": \"abc123...\", \"fee_rate\": 30, \"urgent\": false }\n```\n`txid` is required. `fee_rate` and `urgent` are optional (mutually exclusive).\n\n`POST \u002Finvoice`:\n```json\n{ \"amount_sats\": 5000, \"description\": \"agent service\", \"expiry\": 3600 }\n```\n`amount_sats` is required. `description` and `expiry` are optional.\n\n`POST \u002Fpay`:\n```json\n{ \"bolt11\": \"lnbc50u1p...\", \"max_fee\": 100, \"timeout\": 60 }\n```\n`bolt11` is required. `max_fee` and `timeout` are optional.\n\n`POST \u002Fchannels\u002Fopen`:\n```json\n{ \"peer\": \"02ab...@127.0.0.1:9735\", \"amount_sats\": 100000, \"push_sats\": 0 }\n```\n`peer` and `amount_sats` are required. `push_sats` is optional.\n\n`POST \u002Fchannels\u002Fclose`:\n```json\n{ \"channel_id\": \"12345678901234567890\", \"peer\": \"02ab...\", \"force\": false }\n```\n`channel_id` and `peer` are required. `force` is optional (default `false`).\n\n### Webhooks\n\nConfigure in `~\u002F.bitkit\u002F\u003Cnetwork>\u002Fconfig.toml`:\n\n```toml\nwebhook_url = \"https:\u002F\u002Fyour-agent.example.com\u002Fwebhook\"\nwebhook_secret = \"your-hmac-secret\"\n```\n\n**Events and Payloads:**\n\nEach webhook POST body contains `event`, `data`, and `timestamp` (Unix ms):\n\n**`payment_received`** — Lightning payment received:\n```json\n{\n  \"event\": \"payment_received\",\n  \"data\": { \"payment_hash\": \"abc...\", \"amount_sat\": 1000 },\n  \"timestamp\": 1708444800000\n}\n```\n\n**`payment_sent`** — Outbound Lightning payment succeeded:\n```json\n{\n  \"event\": \"payment_sent\",\n  \"data\": { \"payment_hash\": \"abc...\", \"amount_sat\": 5000, \"fee_sat\": 3 },\n  \"timestamp\": 1708444800000\n}\n```\n\n**`payment_failed`** — Outbound Lightning payment failed:\n```json\n{\n  \"event\": \"payment_failed\",\n  \"data\": { \"payment_hash\": \"abc...\", \"reason\": \"RouteNotFound\" },\n  \"timestamp\": 1708444800000\n}\n```\n`payment_hash` and `reason` are nullable (may be `null`).\n\n**`channel_ready`** — Channel fully open and usable:\n```json\n{\n  \"event\": \"channel_ready\",\n  \"data\": { \"channel_id\": \"4242...\", \"counterparty_node_id\": \"02ab...\" },\n  \"timestamp\": 1708444800000\n}\n```\n`counterparty_node_id` is nullable.\n\n**`channel_closed`** — Channel closed:\n```json\n{\n  \"event\": \"channel_closed\",\n  \"data\": { \"channel_id\": \"4242...\", \"counterparty_node_id\": \"02ab...\", \"reason\": \"CooperativeClosure\" },\n  \"timestamp\": 1708444800000\n}\n```\n`counterparty_node_id` and `reason` are nullable.\n\n**Signature:** `X-Bitkit-Signature: hmac-sha256=\u003Chex>` header (HMAC-SHA256 of body using `webhook_secret`).\n\n**Retry:** 3 attempts with exponential backoff (1s, 4s, 16s).\n\n### WebSocket Events\n\nConnect to `ws:\u002F\u002Flocalhost:3457\u002Fevents` with Basic Auth. Receives the same events as webhooks in real-time as JSON text frames.\n\n```bash\n# Example with websocat\nwebsocat ws:\u002F\u002Flocalhost:3457\u002Fevents -H \"Authorization: Basic $(echo -n 'bitkit:PASSWORD' | base64)\"\n```\n\n**Frame format:** Each event is a JSON text frame with the same structure as webhook payloads:\n\n```json\n{\"event\":\"payment_received\",\"data\":{\"payment_hash\":\"abc...\",\"amount_sat\":1000},\"timestamp\":1708444800000}\n```\n\n**Behavior:**\n- Server sends a WebSocket Ping every 10 seconds as a keepalive\n- If the client falls behind, the server sends a warning frame: `{\"warning\":\"missed 3 events\"}`\n- Connection closes when: client sends a Close frame, any WebSocket error occurs, or the daemon shuts down\n- No client-to-server messages are expected (receive-only stream)\n\n### Configuration Reference\n\nConfig file: `~\u002F.bitkit\u002F\u003Cnetwork>\u002Fconfig.toml` (created by `bk init`). All fields are under `[node]`:\n\n```toml\n[node]\nnetwork = \"mainnet\"                    # \"mainnet\" or \"regtest\"\nchain_source = \"esplora\"               # \"esplora\" or \"electrum\"\nesplora_url = \"https:\u002F\u002Fblockstream.info\u002Fapi\"\nelectrum_url = \"\"                      # used when chain_source = \"electrum\"\nrgs_url = \"https:\u002F\u002Frapidsync.lightningdevkit.org\u002Fsnapshot\"\nblocktank_url = \"https:\u002F\u002Fapi1.blocktank.to\u002Fapi\"\nwebhook_url = \"\"                       # POST target for events\nwebhook_secret = \"\"                    # HMAC-SHA256 signing key\nauto_liquidity = false                 # enable background inbound capacity monitor\nauto_liquidity_threshold_sats = 100000 # order channel when inbound \u003C this\nauto_liquidity_channel_size_sats = 500000  # channel size to order\n```\n\n| Field | Type | Default | Description |\n|-------|------|---------|-------------|\n| `network` | string | `\"mainnet\"` | Bitcoin network |\n| `chain_source` | string | `\"esplora\"` | Chain sync backend: `esplora` or `electrum` |\n| `esplora_url` | string | `\"https:\u002F\u002Fblockstream.info\u002Fapi\"` | Esplora API URL |\n| `electrum_url` | string | `\"\"` | Electrum server URL (regtest: `tcp:\u002F\u002F127.0.0.1:60001`) |\n| `rgs_url` | string | (LDK default) | Rapid Gossip Sync URL for Lightning routing graph |\n| `blocktank_url` | string | `\"https:\u002F\u002Fapi1.blocktank.to\u002Fapi\"` | Blocktank LSP API URL |\n| `webhook_url` | string | `\"\"` | Webhook POST target (empty = disabled) |\n| `webhook_secret` | string | `\"\"` | HMAC-SHA256 key for `X-Bitkit-Signature` header |\n| `auto_liquidity` | bool | `false` | Enable background inbound capacity monitor |\n| `auto_liquidity_threshold_sats` | u64 | `100000` | Order channel when inbound capacity drops below this |\n| `auto_liquidity_channel_size_sats` | u64 | `500000` | Size of auto-ordered channels |\n\n### Auto-Liquidity\n\nWhen `auto_liquidity = true` in `config.toml`, the daemon monitors inbound channel capacity every 5 minutes. If total inbound capacity drops below `auto_liquidity_threshold_sats`, it automatically creates a Blocktank channel order for `auto_liquidity_channel_size_sats`.\n\n**Important:** The auto-created order still requires on-chain payment to `payment_address` from the order. The daemon does not pay automatically — an agent or human must fund the order.\n\n**Workflow:**\n1. Enable in config: `auto_liquidity = true`\n2. Start daemon: `bk start --json`\n3. Monitor for `channel_ready` events via webhook or WebSocket\n4. When a Blocktank order is created, check `bk lsp get-order \u003Cid>` for the `payment_address`\n5. Pay the order on-chain, then the channel opens automatically\n\n### API Password\n\nThe daemon HTTP API uses HTTP Basic Auth. The password is auto-generated on first `bk start`.\n\n**Location:** `\u003Cwallet_dir>\u002Fapi-password` (e.g., `~\u002F.bitkit\u002Fapi-password`)\n**Format:** 32 random bytes encoded as 64 hex characters\n**Permissions:** File mode `0600` (owner read\u002Fwrite only)\n\n```bash\n# Read the password\ncat ~\u002F.bitkit\u002Fapi-password\n\n# Use with curl\ncurl -u \"bitkit:$(cat ~\u002F.bitkit\u002Fapi-password)\" http:\u002F\u002Flocalhost:3457\u002Fbalance\n\n# Use with WebSocket\nwebsocat ws:\u002F\u002Flocalhost:3457\u002Fevents -H \"Authorization: Basic $(echo -n \"bitkit:$(cat ~\u002F.bitkit\u002Fapi-password)\" | base64)\"\n```\n\nThe password persists across daemon restarts. Delete the file to force regeneration on next `bk start`.\n\n## Error Handling\n\n### Exit Codes\n\n| Code | Name | Common Causes | Recovery |\n|------|------|---------------|----------|\n| 0 | Success | -- | -- |\n| 1 | User error | Bad input, missing wallet, invalid invoice, expired invoice | Fix input and retry |\n| 2 | Network error | Connection failed, sync timeout, payment timeout | Retry after delay |\n| 3 | Insufficient funds | Not enough on-chain or Lightning balance | Fund wallet or open channel |\n\n### Error Envelope\n\nWhen `--json` is used and an error occurs, a structured error envelope is written to stderr:\n\n```json\n{\n  \"ok\": false,\n  \"error\": \"Invalid invoice: ...\",\n  \"code\": 1\n}\n```\n\n### Bash Pattern\n\n```bash\nOUTPUT=$(bk pay \"$BOLT11\" --json 2>\u002Fdev\u002Fnull)\nEXIT_CODE=$?\n\ncase $EXIT_CODE in\n  0) echo \"Success: $(echo \"$OUTPUT\" | jq -r '.data.payment_hash')\" ;;\n  1) echo \"Bad input -- check the invoice\" >&2; exit 1 ;;\n  2) echo \"Network issue -- retrying...\" >&2; sleep 5; bk pay \"$BOLT11\" --json ;;\n  3) echo \"Insufficient funds\" >&2; exit 3 ;;\nesac\n```\n\n**Important:** Errors print to stderr (as JSON envelope when `--json` is used). Success output prints to stdout. Always capture them separately.\n\n## Multi-Wallet Pattern\n\nRun multiple independent agent wallets by using separate data directories.\n\n```bash\nexport BITKIT_DIR=\"\u002Ftmp\u002Fagent-${SESSION_ID}\"\nbk init --no-password --json\nbk address --json\n# ... each agent operates independently\n```\n\nOr use the `--dir` flag:\n\n```bash\nbk --dir \u002Ftmp\u002Fagent-alice init --no-password --json\nbk --dir \u002Ftmp\u002Fagent-bob init --no-password --json\n```\n\nEach directory gets its own seed, node identity, Pubky ID, and channel state. Agents sharing a machine can run concurrently with different `--dir` values.\n\n## Input Validation Reference\n\n| Format | Pattern | Example |\n|--------|---------|---------|\n| Node pubkey | 66-char hex (compressed secp256k1) | `02abc123...` |\n| Peer address | `pubkey@host:port` | `02abc...@127.0.0.1:9735` |\n| Transaction ID | 64-char hex | `4a5e1e4baab89f3a...` |\n| Outpoint | `txid:vout` (decimal vout) | `4a5e1e4b...:0` |\n| Channel ID | Decimal u128 | `12345678901234567890` |\n| Bitcoin address | Network-validated bech32\u002Fbase58 | `bc1q...`, `bcrt1q...` |\n| BOLT11 invoice | `lnbc...` or `lnbcrt...` prefix | `lnbc50u1p...` |\n| LNURL | Bech32 with `lnurl` HRP | `lnurl1dp68gurn...` |\n| Lightning Address | `user@domain.tld` | `agent@pay.bitkit.to` |\n| Pubky ID | 52-char z-base-32 | `8pinxrz9tux...45mo` |\n| Fee rate | Positive integer (sat\u002Fvb) | `5` |\n| Amount | Non-negative integer (satoshis) | `50000` |\n\nAll validation errors exit with code 1 and include a descriptive error message.\n\n## Messaging Workflow\n\n### Agent Message Protocol\n\nAgents communicate structured data by sending JSON strings as message content. The convention uses a `type` field to distinguish message kinds:\n\n**Invoice request:**\n\n```json\n{\n  \"type\": \"invoice\",\n  \"bolt11\": \"lnbc50u1p...\",\n  \"amount_sats\": 5000,\n  \"description\": \"data analysis service\"\n}\n```\n\n**Payment confirmation:**\n\n```json\n{\n  \"type\": \"payment_confirmation\",\n  \"payment_hash\": \"a1b2c3d4e5f6...\",\n  \"amount_sats\": 5000\n}\n```\n\n### Workflow: Discover, Message, Pay\n\n```bash\n# 1. Get your own Pubky ID to share with other agents\nMY_ID=$(bk message whoami --json | jq -r '.data.pubky_id')\n\n# 2. Send a message to another agent\nbk message send \"$PEER_PUBKY\" \"Hello, I need data analysis\" --json\n\n# 3. Listen for their reply (they'll send an invoice)\nbk message listen \"$PEER_PUBKY\" --timeout 120 --json | while IFS= read -r MSG; do\n  TYPE=$(echo \"$MSG\" | jq -r '.data.content' | jq -r '.type \u002F\u002F empty' 2>\u002Fdev\u002Fnull)\n  if [ \"$TYPE\" = \"invoice\" ]; then\n    BOLT11=$(echo \"$MSG\" | jq -r '.data.content' | jq -r '.bolt11')\n    echo \"Received invoice: $BOLT11\"\n    break\n  fi\ndone\n\n# 4. Pay the invoice\nbk pay \"$BOLT11\" --json\n```\n\n## End-to-End: Pay Another Agent\n\nComplete flow where Agent A requests a service, Agent B invoices for it, Agent A pays, and Agent B confirms.\n\n### Agent B (service provider)\n\n```bash\n#!\u002Fusr\u002Fbin\u002Fenv bash\nset -euo pipefail\nexport BITKIT_DIR=\u002Ftmp\u002Fagent-b\n\n# Initialize and share identity\nbk init --no-password --json >\u002Fdev\u002Fnull\nMY_ID=$(bk message whoami --json | jq -r '.data.pubky_id')\necho \"Agent B Pubky ID: $MY_ID\"\n\n# Listen for requests from Agent A\nbk message listen \"$AGENT_A_PUBKY\" --timeout 300 --json | while IFS= read -r MSG; do\n  CONTENT=$(echo \"$MSG\" | jq -r '.data.content')\n\n  # Create invoice for the requested service\n  INVOICE_JSON=$(bk invoice 5000 --description \"data analysis\" --json)\n  BOLT11=$(echo \"$INVOICE_JSON\" | jq -r '.data.bolt11')\n\n  # Send invoice to Agent A\n  PAYLOAD=$(jq -n --arg b \"$BOLT11\" '{type:\"invoice\",bolt11:$b,amount_sats:5000,description:\"data analysis\"}')\n  bk message send \"$AGENT_A_PUBKY\" \"$PAYLOAD\" --json\n\n  # Wait for payment\n  RECEIVED=$(bk invoice 5000 --description \"data analysis\" --wait --listen 9735 --json | tail -1)\n  HASH=$(echo \"$RECEIVED\" | jq -r '.data.payment_hash')\n\n  # Confirm payment\n  CONFIRM=$(jq -n --arg h \"$HASH\" '{type:\"payment_confirmation\",payment_hash:$h,amount_sats:5000}')\n  bk message send \"$AGENT_A_PUBKY\" \"$CONFIRM\" --json\n  break\ndone\n```\n\n### Agent A (client)\n\n```bash\n#!\u002Fusr\u002Fbin\u002Fenv bash\nset -euo pipefail\nexport BITKIT_DIR=\u002Ftmp\u002Fagent-a\n\n# Initialize\nbk init --no-password --json >\u002Fdev\u002Fnull\nMY_ID=$(bk message whoami --json | jq -r '.data.pubky_id')\n\n# Request service from Agent B\nbk message send \"$AGENT_B_PUBKY\" \"Please analyze dataset X\" --json\n\n# Wait for invoice\nBOLT11=\"\"\nbk message listen \"$AGENT_B_PUBKY\" --timeout 120 --json | while IFS= read -r MSG; do\n  TYPE=$(echo \"$MSG\" | jq -r '.data.content' | jq -r '.type \u002F\u002F empty' 2>\u002Fdev\u002Fnull)\n  if [ \"$TYPE\" = \"invoice\" ]; then\n    BOLT11=$(echo \"$MSG\" | jq -r '.data.content' | jq -r '.bolt11')\n    break\n  fi\ndone\n\n# Pay the invoice\nPAY_RESULT=$(bk pay \"$BOLT11\" --json)\necho \"Payment status: $(echo \"$PAY_RESULT\" | jq -r '.data.status')\"\necho \"Fee paid: $(echo \"$PAY_RESULT\" | jq -r '.data.fee_sat') sats\"\n\n# Wait for confirmation\nbk message listen \"$AGENT_B_PUBKY\" --timeout 60 --json | while IFS= read -r MSG; do\n  TYPE=$(echo \"$MSG\" | jq -r '.data.content' | jq -r '.type \u002F\u002F empty' 2>\u002Fdev\u002Fnull)\n  if [ \"$TYPE\" = \"payment_confirmation\" ]; then\n    echo \"Payment confirmed by Agent B\"\n    break\n  fi\ndone\n```\n\n## Security & Privacy\n\n**Trust model:** Fully self-custodial. The BIP39 seed never leaves the local machine. No telemetry, analytics, or tracking of any kind.\n\n**External endpoints contacted:**\n\n| Endpoint | Purpose | Data Sent | Configurable |\n|----------|---------|-----------|--------------|\n| Esplora server | Chain sync (mainnet) | Transaction queries | Yes (`esplora_url`) |\n| Electrum server | Chain sync (regtest) | Transaction queries | Yes (`electrum_url`) |\n| RGS server | Lightning gossip sync | None (download only) | Yes (`rgs_url`) |\n| Blocktank API | LSP channel orders | Node ID, order params | Yes (`blocktank_url`) |\n| LNURL service | Pay\u002Fwithdraw resolution | Amount, callback URL | User-initiated only |\n| Pubky DHT | Encrypted messaging | E2E encrypted payloads | Built-in |\n| Webhook URL | Event notifications | Payment\u002Fchannel events | Yes (`webhook_url`) |\n\n**Seed storage:** Custom binary format with magic bytes (`BKIT`), version byte, and encrypted (AES-256-GCM + Argon2id KDF) or plaintext flag. File: `~\u002F.bitkit\u002F\u003Cnetwork>\u002Fseed.enc`.\n\n**API password:** Auto-generated 32-byte random hex, stored with `0600` permissions. Only used for local daemon HTTP API access.\n\n## LSP Workflow: Fresh Wallet to Lightning-Ready\n\nFrom a brand new wallet to being able to send and receive Lightning payments:\n\n```bash\n# 1. Create wallet\nbk init --no-password --json\n\n# 2. Get on-chain address\nADDRESS=$(bk address --json | jq -r '.data.address')\necho \"Fund this address: $ADDRESS\"\n\n# 3. (Fund the address externally, wait for confirmation)\n\n# 4. Estimate channel fees\nbk lsp estimate-fee 500000 --json\n\n# 5. Create channel order\nORDER_ID=$(bk lsp create-order 500000 --json | jq -r '.data.order_id')\n\n# 6. Pay the order on-chain (the payment_address from create-order)\n# ... or wait for on-chain funding to cover it\n\n# 7. Poll until order is paid\nwhile true; do\n  STATE=$(bk lsp get-order \"$ORDER_ID\" --json | jq -r '.data.state2')\n  [ \"$STATE\" = \"Paid\" ] && break\n  sleep 10\ndone\n\n# 8. Open the channel\nbk lsp open-channel \"$ORDER_ID\" --listen 9735 --json\n\n# 9. Verify channel is active\nbk list-channels --json | jq '.data[0].is_usable'\n\n# Now ready to send and receive Lightning payments\n```\n\n## Tags\n\nbitcoin, lightning, payment, invoice, self-custody, wallet, CLI, agent, LNURL, lightning-address, BOLT11, LSP, lowest-fees, daemon, webhooks, websocket, encrypted-messaging, on-chain, channels, liquidity\n","# bitkit-cli -- AI Agent Skill\n\nBitcoin Lightning payment CLI for agents. Lowest LSP fees. Self-custody wallet with LNURL\u002FLightning Address support, typed exit codes, JSON envelope output, encrypted Pubky messaging, and daemon mode.\n\n**Install:** `curl -sSL https:\u002F\u002Fraw.githubusercontent.com\u002Fsynonymdev\u002Fbitkit-cli\u002Fmain\u002Finstall.sh | sh`\n**Binary names:** `bitkit` or `bk` (identical alias)\n**Always use:** `--json` flag on every invocation for parseable output.\n\n## JSON Envelope\n\nAll `--json` output uses a consistent envelope:\n\n**Success** (stdout):\n```json\n{ \"ok\": true, \"data\": { ... } }\n```\n\n**Error** (stderr):\n```json\n{ \"ok\": false, \"error\": \"message\", \"code\": 1 }\n```\n\nParse with: `jq -r '.data.field'` for success data, check `.ok` first.\n\n## Quick Start\n\n```bash\n# 1. Create wallet (no encryption for agent use)\nbk init --no-password --json\n\n# 2. Start daemon for instant command execution\nbk start --json\n\n# 3. Get on-chain address and fund it\nADDRESS=$(bk address --json | jq -r '.data.address')\n\n# 4. Order inbound Lightning liquidity via LSP\nORDER=$(bk lsp create-order 500000 --json)\nORDER_ID=$(echo \"$ORDER\" | jq -r '.data.order_id')\n\n# 5. Pay the order (on-chain to payment_address), then open channel\nbk lsp open-channel \"$ORDER_ID\" --listen 9735 --json\n\n# 6. Create an invoice and receive payment\nbk invoice 5000 --description \"agent service\" --wait --listen 9735 --json\n\n# 7. Pay someone else's invoice\nbk pay lnbc50u1p... --json\n\n# 8. Check balance and history\nbk balance --json\nbk history --json\n\n# 9. Stop daemon when done\nbk stop --json\n```\n\n## Daemon Mode\n\nBy default each command cold-starts the LDK node (slow). Start a persistent daemon for instant execution:\n\n```bash\nbk start --json           # start daemon (default port 3457)\nbk status --json          # check if running\nbk balance --json         # instant -- proxied through daemon\nbk stop --json            # stop daemon\n```\n\nWhen the daemon is running, all commands automatically proxy through its HTTP API. When stopped, commands fall back to per-command cold-start. No code changes needed.\n\n### `start`\n\nStart the background daemon. Idempotent -- returns current PID if already running.\n\n```bash\nbk start --json\nbk start --port 8080 --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"status\": \"started\",\n    \"pid\": 12345,\n    \"port\": 3457\n  }\n}\n```\n\n| Arg | Default | Description |\n|-----|---------|-------------|\n| `--port \u003Cport>` | `3457` | HTTP API port |\n\n`status` is `\"started\"` or `\"already_running\"`.\n\n### `stop`\n\nStop the running daemon.\n\n```bash\nbk stop --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"status\": \"stopped\",\n    \"pid\": 12345\n  }\n}\n```\n\nErrors if no daemon is running (exit code 1).\n\n### `status`\n\nCheck daemon status.\n\n```bash\nbk status --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"running\": true,\n    \"pid\": 12345,\n    \"port\": 3457,\n    \"started_at\": \"2026-02-19T10:00:00+00:00\",\n    \"version\": \"0.1.0\"\n  }\n}\n```\n\nWhen stopped: `running` is `false`, all other fields are `null`.\n\n## Global Flags\n\n| Flag | Env Variable | Default | Description |\n|------|-------------|---------|-------------|\n| `--json` | -- | off | Machine-readable JSON to stdout |\n| `--dir \u003Cpath>` | `BITKIT_DIR` | `~\u002F.bitkit\u002F` | Wallet data directory |\n| `--network \u003Cnet>` | `BITKIT_NETWORK` | `mainnet` | `mainnet` or `regtest` |\n| `--listen \u003Cport>` | `BITKIT_LISTEN` | off | P2P listen port on `0.0.0.0:\u003Cport>` |\n| `--password \u003Cpw>` | `BITKIT_PASSWORD` | -- | Wallet password (for encrypted seeds) |\n\n## Command Reference\n\n### Wallet\n\n#### `init`\n\nCreate a new wallet. Idempotent -- re-running prints existing wallet info.\n\n```bash\nbk init --no-password --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"node_id\": \"02abc123...\",\n    \"seed_phrase\": \"abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about\",\n    \"wallet_dir\": \"\u002Froot\u002F.bitkit\",\n    \"network\": \"mainnet\",\n    \"pubky_id\": \"8pinxrz9tuxfz3qo5gkhdebuhtq6mrimh3matdncsrsno7kg45mo\"\n  }\n}\n```\n\n| Arg | Required | Description |\n|-----|----------|-------------|\n| `--no-password` | one of | Store seed as plaintext (for agents) |\n| `--password \u003Cpw>` | one of | Encrypt seed with AES-256-GCM + Argon2id |\n\n#### `info`\n\nShow node status, channel counts, sync state.\n\n```bash\nbk info --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"node_id\": \"02abc123...\",\n    \"network\": \"mainnet\",\n    \"channels_active\": 1,\n    \"channels_pending\": 0,\n    \"block_height\": 880000,\n    \"synced\": true,\n    \"wallet_dir\": \"\u002Froot\u002F.bitkit\"\n  }\n}\n```\n\n#### `balance`\n\nShow Lightning and on-chain balances in satoshis.\n\n```bash\nbk balance --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"lightning_sats\": 450000,\n    \"onchain_sats\": 50000,\n    \"total_sats\": 500000,\n    \"total_onchain_sats\": 55000,\n    \"anchor_reserve_sats\": 5000,\n    \"pending_sweep_sats\": 0,\n    \"pending_sweeps\": []\n  }\n}\n```\n\n- `onchain_sats` -- spendable on-chain balance\n- `total_onchain_sats` -- all on-chain funds including reserved\n- `anchor_reserve_sats` -- sats reserved for anchor channel fees\n- `pending_sweep_sats` -- funds sweeping from closed channels (not yet spendable)\n- `pending_sweeps` -- array of sweep entries with `amount_sats`, `status`, `spending_txid`, `confirmation_height`\n\n| Arg | Description |\n|-----|-------------|\n| `--btc` | Display in BTC instead of sats (human output only) |\n\n#### `config`\n\nShow resolved configuration with source tracking. Does not start the node.\n\n```bash\nbk config --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"network\": { \"value\": \"mainnet\", \"source\": \"default\" },\n    \"wallet_dir\": { \"value\": \"\u002Froot\u002F.bitkit\", \"source\": \"default\" },\n    \"chain_source\": { \"value\": \"esplora\", \"source\": \"file\" },\n    \"esplora_url\": { \"value\": \"https:\u002F\u002Fblockstream.info\u002Fapi\", \"source\": \"file\" },\n    \"electrum_url\": { \"value\": \"\", \"source\": \"file\" },\n    \"rgs_url\": { \"value\": \"https:\u002F\u002Frapidsync.lightningdevkit.org\u002Fsnapshot\", \"source\": \"file\" },\n    \"blocktank_url\": { \"value\": \"https:\u002F\u002Fapi1.blocktank.to\u002Fapi\", \"source\": \"file\" },\n    \"listen_port\": { \"value\": \"off\", \"source\": \"default\" }\n  }\n}\n```\n\nEach entry has `value` (resolved value) and `source` (`cli`, `env`, `file`, or `default`).\n\n#### `address`\n\nGet a new on-chain receive address. Generates a fresh address each call. Optionally validate an existing address.\n\n```bash\nbk address --json\nbk address --type taproot --json\nbk address --validate bc1q... --json\n```\n\nGenerate address:\n```json\n{\n  \"ok\": true,\n  \"data\": { \"address\": \"bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4\", \"address_type\": \"native-segwit\" }\n}\n```\n\nValidate address (`--validate`):\n```json\n{\n  \"ok\": true,\n  \"data\": { \"address\": \"bc1q...\", \"valid\": true, \"network\": \"mainnet\", \"reason\": null }\n}\n```\n\nOn invalid address: `valid` is `false` and `reason` explains why.\n\n| Arg | Default | Description |\n|-----|---------|-------------|\n| `--type \u003Ctype>` | `native-segwit` | Address type: `legacy`, `nested-segwit`, `native-segwit`, `taproot` |\n| `--validate \u003Caddr>` | -- | Validate `\u003Caddr>` for the current network; no node start needed |\n| `--qr` | off | Display address as QR code in terminal (human output only) |\n\n#### `send`\n\nSend bitcoin on-chain to an address.\n\n```bash\nbk send bc1q... 50000 --json\nbk send bc1q... 50000 --fee-rate 5 --json\nbk send bc1q... --drain --json\nbk send bc1q... 50000 --utxo \u003Ctxid>:\u003Cvout> --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"txid\": \"abc123...\",\n    \"address\": \"bc1q...\",\n    \"amount_sats\": 50000,\n    \"drain\": false,\n    \"fee_rate_sat_per_vb\": 5,\n    \"utxos_used\": [\"abc123...:0\"]\n  }\n}\n```\n\nWhen `--drain` is used, `amount_sats` is `null`. When no `--fee-rate` is set, `fee_rate_sat_per_vb` is `null`.\n\n| Arg | Default | Description |\n|-----|---------|-------------|\n| `\u003Caddress>` | required | Destination Bitcoin address |\n| `\u003Camount_sats>` | -- | Amount in satoshis (omit with `--drain`) |\n| `--drain` | off | Send all spendable funds (mutually exclusive with `--utxo`) |\n| `--fee-rate \u003Csat\u002Fvb>` | auto | Fee rate in sat\u002Fvb |\n| `--utxo \u003Ctxid:vout>` | -- | Spend a specific UTXO (repeatable; incompatible with `--drain`) |\n\n#### `list-utxos`\n\nList all spendable UTXOs in the on-chain wallet.\n\n```bash\nbk list-utxos --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"utxos\": [\n      {\n        \"txid\": \"abc123...\",\n        \"vout\": 0,\n        \"value_sats\": 1000000,\n        \"outpoint\": \"abc123...:0\"\n      }\n    ],\n    \"total_sats\": 1000000,\n    \"count\": 1\n  }\n}\n```\n\nUse `outpoint` values (e.g. `abc123...:0`) as `--utxo` arguments for `send` and `estimate-fee`.\n\n#### `estimate-fee`\n\nPreview the fee for an on-chain send without broadcasting.\n\n```bash\nbk estimate-fee bc1q... 50000 --json\nbk estimate-fee bc1q... 50000 --fee-rate 5 --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"fee_sats\": 250,\n    \"address\": \"bc1q...\",\n    \"amount_sats\": 50000,\n    \"fee_rate_sat_per_vb\": 5\n  }\n}\n```\n\n`fee_rate_sat_per_vb` is `null` when not specified (node chooses automatically).\n\n| Arg | Default | Description |\n|-----|---------|-------------|\n| `\u003Caddress>` | required | Destination Bitcoin address |\n| `\u003Camount_sats>` | required | Amount to send in satoshis |\n| `--fee-rate \u003Csat\u002Fvb>` | auto | Override fee rate in sat\u002Fvb |\n| `--utxo \u003Ctxid:vout>` | -- | Restrict coin selection to specific UTXOs |\n\n#### `bump-fee`\n\nReplace an unconfirmed transaction with a higher-fee version (RBF). The original transaction must be in the mempool and RBF-enabled.\n\n```bash\nbk bump-fee \u003Ctxid> \u003Cfee_rate> --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"original_txid\": \"abc123...\",\n    \"new_txid\": \"def456...\",\n    \"fee_rate_sat_per_vb\": 20\n  }\n}\n```\n\n| Arg | Description |\n|-----|-------------|\n| `\u003Ctxid>` | TXID of the unconfirmed transaction to replace |\n| `\u003Cfee_rate>` | New fee rate in sat\u002Fvb (must be higher than the original) |\n\nOn failure (invalid txid, not in mempool, RBF not signalled): exits with code 1.\n\n#### `cpfp`\n\nAccelerate a stuck transaction by spending one of its outputs at a higher fee rate (Child-Pays-For-Parent).\n\n```bash\nbk cpfp \u003Ctxid> --json\nbk cpfp \u003Ctxid> --fee-rate 30 --json\nbk cpfp \u003Ctxid> --urgent --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"parent_txid\": \"abc123...\",\n    \"child_txid\": \"def456...\",\n    \"fee_rate_sat_per_vb\": 30,\n    \"urgent\": false\n  }\n}\n```\n\n`fee_rate_sat_per_vb` is `null` when neither `--fee-rate` nor `--urgent` is set.\n\n| Arg | Default | Description |\n|-----|---------|-------------|\n| `\u003Ctxid>` | required | TXID of the parent transaction to accelerate |\n| `--fee-rate \u003Csat\u002Fvb>` | auto | Explicit fee rate for the child transaction |\n| `--urgent` | off | Automatically compute a high fee rate to confirm next block |\n\nOn failure (invalid txid, no spendable output found): exits with code 1.\n\n#### `history`\n\nList recent transactions, newest first.\n\n```bash\nbk history --limit 5 --type send --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": [\n    {\n      \"type\": \"send\",\n      \"amount_sat\": 5000,\n      \"fee_sat\": 3,\n      \"status\": \"complete\",\n      \"timestamp\": \"2026-02-15 12:00:00\",\n      \"description\": \"coffee\"\n    }\n  ]\n}\n```\n\n| Arg | Default | Description |\n|-----|---------|-------------|\n| `--limit \u003Cn>` | `20` | Number of entries |\n| `--type \u003Csend\\|recv>` | all | Filter by direction |\n\n**Status values:** `complete`, `pending`, `failed`\n**Type values:** `send`, `recv`\n\n### Lightning Payments\n\n#### `invoice`\n\nGenerate a BOLT 11 invoice to receive payment.\n\n```bash\nbk invoice 5000 --description \"agent service\" --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"bolt11\": \"lnbc50u1p...\",\n    \"payment_hash\": \"a1b2c3d4e5f6...\",\n    \"amount_sat\": 5000,\n    \"description\": \"agent service\",\n    \"expires_at\": \"2026-02-15T14:30:00+00:00\"\n  }\n}\n```\n\n| Arg | Default | Description |\n|-----|---------|-------------|\n| `\u003Camount_sats>` | required | Amount in satoshis |\n| `--description \u003Ctext>` | `\"\"` | Invoice memo |\n| `--expiry \u003Csecs>` | `3600` | Invoice expiry in seconds |\n| `--wait` | off | Block until payment received |\n| `--timeout \u003Csecs>` | `300` | Timeout when using `--wait` |\n| `--qr` | off | Display invoice as QR code in terminal (human output only) |\n\n**Two-phase output with `--wait`:** First prints the invoice envelope above, then blocks. When payment arrives, prints a second envelope to stdout:\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"status\": \"received\",\n    \"amount_sat\": 5000,\n    \"payment_hash\": \"a1b2c3d4e5f6...\"\n  }\n}\n```\n\nIf timeout expires, exits with code 2 (network error). Always use `--listen \u003Cport>` with `--wait` so the payer can connect.\n\n#### `pay`\n\nPay a BOLT 11 invoice, LNURL, or Lightning Address. Polls until success, failure, or timeout.\n\n```bash\nbk pay lnbc50u1p... --json\nbk pay lnurl1dp68gurn... --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"status\": \"success\",\n    \"amount_sat\": 5000,\n    \"fee_sat\": 3,\n    \"payment_hash\": \"a1b2c3d4e5f6...\",\n    \"preimage\": \"1a2b3c4d5e6f...\"\n  }\n}\n```\n\n| Arg | Default | Description |\n|-----|---------|-------------|\n| `\u003Cbolt11>` | required | BOLT 11 invoice, LNURL, or Lightning Address |\n| `--max-fee \u003Csats>` | unlimited | Maximum routing fee in satoshis |\n| `--timeout \u003Csecs>` | `60` | Payment timeout |\n\n**LNURL\u002FLightning Address support:** `pay` accepts LNURL (`lnurl1...`) and resolves to a BOLT11 invoice. For LNURL-pay with variable amounts (where `min_sendable != max_sendable`), the CLI currently requires a fixed-amount LNURL. Lightning Address (`user@domain.tld`) requires a `--amount` flag which is not yet implemented — use a BOLT11 invoice instead.\n\nOn failure: exits with code 1 (\"Payment failed\"). On timeout: exits with code 2.\n\n#### `withdraw`\n\nWithdraw from an LNURL-withdraw endpoint. Creates an invoice and submits it to the LNURL service.\n\n```bash\nbk withdraw lnurl1dp68gurn... --json\nbk withdraw lnurl1dp68gurn... --amount 10000 --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"status\": \"submitted\",\n    \"amount_sat\": 10000,\n    \"bolt11\": \"lnbc100u1p...\"\n  }\n}\n```\n\n| Arg | Default | Description |\n|-----|---------|-------------|\n| `\u003Clnurl>` | required | LNURL-withdraw bech32 string |\n| `--amount \u003Csats>` | max withdrawable | Amount in satoshis |\n\n### Channels\n\n#### `open-channel`\n\nOpen a Lightning channel to a peer. Requires on-chain funds.\n\n```bash\nbk open-channel 02ab...@127.0.0.1:9735 100000 --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"channel_id\": \"12345678901234567890\",\n    \"peer\": \"02ab...\",\n    \"amount_sats\": 100000\n  }\n}\n```\n\n| Arg | Description |\n|-----|-------------|\n| `\u003Cpeer>` | Peer in `pubkey@host:port` format |\n| `\u003Camount_sats>` | Channel capacity in satoshis |\n| `--push \u003Csats>` | Give the peer initial balance |\n\n#### `close-channel`\n\nClose a Lightning channel. Get `channel_id` and `peer` from `list-channels`.\n\n```bash\nbk close-channel 12345678901234567890 02ab... --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"channel_id\": \"12345678901234567890\",\n    \"status\": \"closing\"\n  }\n}\n```\n\n| Arg | Description |\n|-----|-------------|\n| `\u003Cchannel_id>` | Channel ID (decimal, from `list-channels`) |\n| `\u003Cpeer>` | Counterparty node public key |\n| `--force` | Force close (use when peer is unresponsive) |\n\n**Status values:** `closing` (cooperative), `force_closing`\n\n#### `list-channels`\n\nList all Lightning channels with capacity, balances, and status.\n\n```bash\nbk list-channels --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": [\n    {\n      \"channel_id\": \"12345678901234567890\",\n      \"peer\": \"02ab...\",\n      \"capacity_sats\": 500000,\n      \"local_balance_msat\": 250000000,\n      \"remote_balance_msat\": 250000000,\n      \"is_usable\": true,\n      \"is_channel_ready\": true,\n      \"is_outbound\": false\n    }\n  ]\n}\n```\n\nNote: balances are in millisatoshis. Divide by 1000 for satoshis.\n\n### LSP (Blocktank Liquidity)\n\nUse the Blocktank LSP to get inbound Lightning liquidity without manually finding peers.\n\n#### `lsp info`\n\nGet LSP service info: available nodes, channel limits, fee rates.\n\n```bash\nbk lsp info --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"nodes\": [\n      {\n        \"alias\": \"blocktank-lsp\",\n        \"pubkey\": \"02abc...\",\n        \"connection_strings\": [\"02abc...@1.2.3.4:9735\"]\n      }\n    ],\n    \"min_channel_size_sats\": 20000,\n    \"max_channel_size_sats\": 5000000,\n    \"min_expiry_weeks\": 2,\n    \"max_expiry_weeks\": 52,\n    \"network\": \"Mainnet\",\n    \"fee_rates_fast\": 10,\n    \"fee_rates_mid\": 5,\n    \"fee_rates_slow\": 1\n  }\n}\n```\n\n#### `lsp estimate-fee`\n\nEstimate the cost of a channel order before creating it.\n\n```bash\nbk lsp estimate-fee 500000 --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"fee_sats\": 500,\n    \"network_fee_sats\": 300,\n    \"service_fee_sats\": 200\n  }\n}\n```\n\n| Arg | Default | Description |\n|-----|---------|-------------|\n| `\u003Clsp_balance_sats>` | required | Inbound liquidity amount |\n| `--expiry \u003Cweeks>` | `6` | Channel expiry in weeks |\n| `--client-balance-sats \u003Csats>` | `0` | Outbound liquidity (your side) |\n\n#### `lsp create-order`\n\nCreate a channel order. Returns payment details.\n\n```bash\nbk lsp create-order 500000 --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"order_id\": \"ord-abc123...\",\n    \"state\": \"Created\",\n    \"fee_sats\": 500,\n    \"lsp_balance_sats\": 500000,\n    \"client_balance_sats\": 0,\n    \"payment_address\": \"bc1q...\",\n    \"payment_bolt11\": \"lnbc...\",\n    \"order_expires_at\": \"2026-03-01T00:00:00Z\"\n  }\n}\n```\n\n| Arg | Default | Description |\n|-----|---------|-------------|\n| `\u003Clsp_balance_sats>` | required | Inbound liquidity amount |\n| `--expiry \u003Cweeks>` | `6` | Channel expiry in weeks |\n| `--client-balance-sats \u003Csats>` | `0` | Your outbound balance |\n| `--zero-conf` | off | Enable zero-conf channel |\n\nAfter creating, pay to `payment_address` (on-chain) or `payment_bolt11` (Lightning). Then poll `get-order` until state becomes `Paid`.\n\n#### `lsp get-order`\n\nCheck the status of an order.\n\n```bash\nbk lsp get-order ord-abc123 --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"order_id\": \"ord-abc123...\",\n    \"state\": \"Open\",\n    \"state2\": \"Paid\",\n    \"fee_sats\": 500,\n    \"lsp_balance_sats\": 500000,\n    \"client_balance_sats\": 0,\n    \"channel_expiry_weeks\": 6,\n    \"channel_state\": \"Opening\",\n    \"funding_tx\": \"abc123def...\",\n    \"payment_state\": \"Paid\",\n    \"order_expires_at\": \"2026-03-01T00:00:00Z\",\n    \"created_at\": \"2026-02-17T00:00:00Z\"\n  }\n}\n```\n\n`channel_state` and `funding_tx` are `null` until the channel is being opened.\n\n**State enum values for `lsp get-order`:**\n\n| Field | Values | Description |\n|-------|--------|-------------|\n| `state` | `Created`, `Open`, `Expired`, `Closed` | Legacy order state |\n| `state2` | `Created`, `Paid`, `Executed`, `Expired` | Current order state (prefer this) |\n| `channel_state` | `Opening`, `Open`, `Closed` | Channel lifecycle state |\n| `payment_state` | `Created`, `Paid`, `Refunded`, `RefundAvailable`, `Canceled` | Payment lifecycle state |\n\nPoll `state2` for order progress: `Created` → `Paid` (after on-chain payment) → `Executed` (channel opened).\n\n#### `lsp open-channel`\n\nTell Blocktank to open a channel to your node. The order must be in `Paid` state. Requires `--listen` so Blocktank can connect.\n\n```bash\nbk lsp open-channel ord-abc123 --listen 9735 --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"order_id\": \"ord-abc123...\",\n    \"state\": \"Open\",\n    \"channel_state\": \"Opening\",\n    \"funding_tx\": \"abc123def...\"\n  }\n}\n```\n\n### Messaging (Pubky Encrypted)\n\nEnd-to-end encrypted messaging via the Pubky network. Identity is created during `init`.\n\n#### `message whoami`\n\nPrint your Pubky messaging ID. Does not require network access.\n\n```bash\nbk message whoami --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"pubky_id\": \"8pinxrz9tuxfz3qo5gkhdebuhtq6mrimh3matdncsrsno7kg45mo\"\n  }\n}\n```\n\n#### `message send`\n\nSend an encrypted message to a peer.\n\n```bash\nbk message send 8pin...xyz '{\"type\":\"invoice\",\"bolt11\":\"lnbc...\",\"amount_sats\":5000,\"description\":\"service\"}' --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"message_id\": \"abc-123-def\",\n    \"recipient\": \"8pin...xyz\"\n  }\n}\n```\n\n| Arg | Description |\n|-----|-------------|\n| `\u003Cpubky>` | Recipient's Pubky ID |\n| `\u003Ctext>` | Message content (plain text or JSON string) |\n\n#### `message read`\n\nRead the full conversation with a peer, sorted by timestamp.\n\n```bash\nbk message read 8pin...xyz --json\n```\n\n```json\n{\n  \"ok\": true,\n  \"data\": {\n    \"messages\": [\n      {\n        \"sender\": \"8pin...abc\",\n        \"content\": \"{\\\"type\\\":\\\"invoice\\\",\\\"bolt11\\\":\\\"lnbc...\\\",\\\"amount_sats\\\":5000,\\\"description\\\":\\\"service\\\"}\",\n        \"timestamp\": 1708000000,\n        \"verified\": true\n      }\n    ]\n  }\n}\n```\n\n| Field | Description |\n|-------|-------------|\n| `sender` | Pubky ID of the message author |\n| `content` | Message text (may contain JSON -- parse it) |\n| `timestamp` | Unix timestamp in seconds |\n| `verified` | `true` if cryptographic signature verified |\n\n#### `message listen`\n\nPoll for new messages from a peer. Streams one envelope per line to stdout as messages arrive.\n\n```bash\nbk message listen 8pin...xyz --interval 3 --timeout 120 --json\n```\n\nEach new message is printed as a single-line envelope:\n\n```json\n{\"ok\":true,\"data\":{\"sender\":\"8pin...abc\",\"content\":\"hello\",\"timestamp\":1708000001,\"verified\":true}}\n```\n\n| Arg | Default | Description |\n|-----|---------|-------------|\n| `\u003Cpubky>` | required | Peer's Pubky ID |\n| `--interval \u003Csecs>` | `3` | Poll interval |\n| `--timeout \u003Csecs>` | `0` (forever) | Stop after this many seconds |\n\nStatus messages go to stderr. Only message JSON goes to stdout.\n\n## Agent Integration\n\n### Daemon HTTP API\n\nWhen the daemon is running (`bk start`), all commands proxy through an HTTP API on `localhost:3457` (configurable via `--port`). The API uses HTTP Basic Auth with auto-generated credentials.\n\n**Authentication:** HTTP Basic Auth (`bitkit:\u003Cpassword>`). Password is auto-generated on first `bk start` and stored in `\u003Cwallet_dir>\u002Fapi-password`.\n\n**Endpoints:**\n\n| Method | Path | Description |\n|--------|------|-------------|\n| GET | `\u002Fhealth` | Health check (no auth) |\n| GET | `\u002Fbalance` | Wallet balance |\n| GET | `\u002Finfo` | Node info |\n| GET | `\u002Fhistory?limit=20&type=send` | Payment history |\n| GET | `\u002Fchannels` | List channels |\n| GET | `\u002Futxos` | List UTXOs |\n| POST | `\u002Faddress` | Generate receive address |\n| POST | `\u002Fsend` | Send on-chain |\n| POST | `\u002Finvoice` | Create Lightning invoice |\n| POST | `\u002Fpay` | Pay Lightning invoice |\n| POST | `\u002Festimate-fee` | Estimate on-chain fee |\n| POST | `\u002Fbump-fee` | RBF fee bump |\n| POST | `\u002Fcpfp` | CPFP acceleration |\n| POST | `\u002Fchannels\u002Fopen` | Open channel |\n| POST | `\u002Fchannels\u002Fclose` | Close channel |\n| GET | `\u002Fevents` | WebSocket event stream |\n\nAll responses use the same JSON envelope as CLI `--json` output: `{\"ok\": true, \"data\": {...}}`.\n\n**POST Request Body Schemas:**\n\n`POST \u002Faddress`:\n```json\n{ \"address_type\": \"native-segwit\" }\n```\n`address_type` is optional. Values: `legacy`, `nested-segwit`, `native-segwit`, `taproot`.\n\n`POST \u002Fsend`:\n```json\n{ \"address\": \"bc1q...\", \"amount_sats\": 50000, \"drain\": false, \"fee_rate\": 5, \"utxos\": [\"txid:0\"] }\n```\n`amount_sats` is required unless `drain` is `true`. `fee_rate`, `drain`, `utxos` are optional.\n\n`POST \u002Festimate-fee`:\n```json\n{ \"address\": \"bc1q...\", \"amount_sats\": 50000, \"fee_rate\": 5, \"utxos\": [\"txid:0\"] }\n```\n`fee_rate` and `utxos` are optional.\n\n`POST \u002Fbump-fee`:\n```json\n{ \"txid\": \"abc123...\", \"fee_rate\": 20 }\n```\nBoth fields required.\n\n`POST \u002Fcpfp`:\n```json\n{ \"txid\": \"abc123...\", \"fee_rate\": 30, \"urgent\": false }\n```\n`txid` is required. `fee_rate` and `urgent` are optional (mutually exclusive).\n\n`POST \u002Finvoice`:\n```json\n{ \"amount_sats\": 5000, \"description\": \"agent service\", \"expiry\": 3600 }\n```\n`amount_sats` is required. `description` and `expiry` are optional.\n\n`POST \u002Fpay`:\n```json\n{ \"bolt11\": \"lnbc50u1p...\", \"max_fee\": 100, \"timeout\": 60 }\n```\n`bolt11` is required. `max_fee` and `timeout` are optional.\n\n`POST \u002Fchannels\u002Fopen`:\n```json\n{ \"peer\": \"02ab...@127.0.0.1:9735\", \"amount_sats\": 100000, \"push_sats\": 0 }\n```\n`peer` and `amount_sats` are required. `push_sats` is optional.\n\n`POST \u002Fchannels\u002Fclose`:\n```json\n{ \"channel_id\": \"12345678901234567890\", \"peer\": \"02ab...\", \"force\": false }\n```\n`channel_id` and `peer` are required. `force` is optional (default `false`).\n\n### Webhooks\n\nConfigure in `~\u002F.bitkit\u002F\u003Cnetwork>\u002Fconfig.toml`:\n\n```toml\nwebhook_url = \"https:\u002F\u002Fyour-agent.example.com\u002Fwebhook\"\nwebhook_secret = \"your-hmac-secret\"\n```\n\n**Events and Payloads:**\n\nEach webhook POST body contains `event`, `data`, and `timestamp` (Unix ms):\n\n**`payment_received`** — Lightning payment received:\n```json\n{\n  \"event\": \"payment_received\",\n  \"data\": { \"payment_hash\": \"abc...\", \"amount_sat\": 1000 },\n  \"timestamp\": 1708444800000\n}\n```\n\n**`payment_sent`** — Outbound Lightning payment succeeded:\n```json\n{\n  \"event\": \"payment_sent\",\n  \"data\": { \"payment_hash\": \"abc...\", \"amount_sat\": 5000, \"fee_sat\": 3 },\n  \"timestamp\": 1708444800000\n}\n```\n\n**`payment_failed`** — Outbound Lightning payment failed:\n```json\n{\n  \"event\": \"payment_failed\",\n  \"data\": { \"payment_hash\": \"abc...\", \"reason\": \"RouteNotFound\" },\n  \"timestamp\": 1708444800000\n}\n```\n`payment_hash` and `reason` are nullable (may be `null`).\n\n**`channel_ready`** — Channel fully open and usable:\n```json\n{\n  \"event\": \"channel_ready\",\n  \"data\": { \"channel_id\": \"4242...\", \"counterparty_node_id\": \"02ab...\" },\n  \"timestamp\": 1708444800000\n}\n```\n`counterparty_node_id` is nullable.\n\n**`channel_closed`** — Channel closed:\n```json\n{\n  \"event\": \"channel_closed\",\n  \"data\": { \"channel_id\": \"4242...\", \"counterparty_node_id\": \"02ab...\", \"reason\": \"CooperativeClosure\" },\n  \"timestamp\": 1708444800000\n}\n```\n`counterparty_node_id` and `reason` are nullable.\n\n**Signature:** `X-Bitkit-Signature: hmac-sha256=\u003Chex>` header (HMAC-SHA256 of body using `webhook_secret`).\n\n**Retry:** 3 attempts with exponential backoff (1s, 4s, 16s).\n\n### WebSocket Events\n\nConnect to `ws:\u002F\u002Flocalhost:3457\u002Fevents` with Basic Auth. Receives the same events as webhooks in real-time as JSON text frames.\n\n```bash\n# Example with websocat\nwebsocat ws:\u002F\u002Flocalhost:3457\u002Fevents -H \"Authorization: Basic $(echo -n 'bitkit:PASSWORD' | base64)\"\n```\n\n**Frame format:** Each event is a JSON text frame with the same structure as webhook payloads:\n\n```json\n{\"event\":\"payment_received\",\"data\":{\"payment_hash\":\"abc...\",\"amount_sat\":1000},\"timestamp\":1708444800000}\n```\n\n**Behavior:**\n- Server sends a WebSocket Ping every 10 seconds as a keepalive\n- If the client falls behind, the server sends a warning frame: `{\"warning\":\"missed 3 events\"}`\n- Connection closes when: client sends a Close frame, any WebSocket error occurs, or the daemon shuts down\n- No client-to-server messages are expected (receive-only stream)\n\n### Configuration Reference\n\nConfig file: `~\u002F.bitkit\u002F\u003Cnetwork>\u002Fconfig.toml` (created by `bk init`). All fields are under `[node]`:\n\n```toml\n[node]\nnetwork = \"mainnet\"                    # \"mainnet\" or \"regtest\"\nchain_source = \"esplora\"               # \"esplora\" or \"electrum\"\nesplora_url = \"https:\u002F\u002Fblockstream.info\u002Fapi\"\nelectrum_url = \"\"                      # used when chain_source = \"electrum\"\nrgs_url = \"https:\u002F\u002Frapidsync.lightningdevkit.org\u002Fsnapshot\"\nblocktank_url = \"https:\u002F\u002Fapi1.blocktank.to\u002Fapi\"\nwebhook_url = \"\"                       # POST target for events\nwebhook_secret = \"\"                    # HMAC-SHA256 signing key\nauto_liquidity = false                 # enable background inbound capacity monitor\nauto_liquidity_threshold_sats = 100000 # order channel when inbound \u003C this\nauto_liquidity_channel_size_sats = 500000  # channel size to order\n```\n\n| Field | Type | Default | Description |\n|-------|------|---------|-------------|\n| `network` | string | `\"mainnet\"` | Bitcoin network |\n| `chain_source` | string | `\"esplora\"` | Chain sync backend: `esplora` or `electrum` |\n| `esplora_url` | string | `\"https:\u002F\u002Fblockstream.info\u002Fapi\"` | Esplora API URL |\n| `electrum_url` | string | `\"\"` | Electrum server URL (regtest: `tcp:\u002F\u002F127.0.0.1:60001`) |\n| `rgs_url` | string | (LDK default) | Rapid Gossip Sync URL for Lightning routing graph |\n| `blocktank_url` | string | `\"https:\u002F\u002Fapi1.blocktank.to\u002Fapi\"` | Blocktank LSP API URL |\n| `webhook_url` | string | `\"\"` | Webhook POST target (empty = disabled) |\n| `webhook_secret` | string | `\"\"` | HMAC-SHA256 key for `X-Bitkit-Signature` header |\n| `auto_liquidity` | bool | `false` | Enable background inbound capacity monitor |\n| `auto_liquidity_threshold_sats` | u64 | `100000` | Order channel when inbound capacity drops below this |\n| `auto_liquidity_channel_size_sats` | u64 | `500000` | Size of auto-ordered channels |\n\n### Auto-Liquidity\n\nWhen `auto_liquidity = true` in `config.toml`, the daemon monitors inbound channel capacity every 5 minutes. If total inbound capacity drops below `auto_liquidity_threshold_sats`, it automatically creates a Blocktank channel order for `auto_liquidity_channel_size_sats`.\n\n**Important:** The auto-created order still requires on-chain payment to `payment_address` from the order. The daemon does not pay automatically — an agent or human must fund the order.\n\n**Workflow:**\n1. Enable in config: `auto_liquidity = true`\n2. Start daemon: `bk start --json`\n3. Monitor for `channel_ready` events via webhook or WebSocket\n4. When a Blocktank order is created, check `bk lsp get-order \u003Cid>` for the `payment_address`\n5. Pay the order on-chain, then the channel opens automatically\n\n### API Password\n\nThe daemon HTTP API uses HTTP Basic Auth. The password is auto-generated on first `bk start`.\n\n**Location:** `\u003Cwallet_dir>\u002Fapi-password` (e.g., `~\u002F.bitkit\u002Fapi-password`)\n**Format:** 32 random bytes encoded as 64 hex characters\n**Permissions:** File mode `0600` (owner read\u002Fwrite only)\n\n```bash\n# Read the password\ncat ~\u002F.bitkit\u002Fapi-password\n\n# Use with curl\ncurl -u \"bitkit:$(cat ~\u002F.bitkit\u002Fapi-password)\" http:\u002F\u002Flocalhost:3457\u002Fbalance\n\n# Use with WebSocket\nwebsocat ws:\u002F\u002Flocalhost:3457\u002Fevents -H \"Authorization: Basic $(echo -n \"bitkit:$(cat ~\u002F.bitkit\u002Fapi-password)\" | base64)\"\n```\n\nThe password persists across daemon restarts. Delete the file to force regeneration on next `bk start`.\n\n## Error Handling\n\n### Exit Codes\n\n| Code | Name | Common Causes | Recovery |\n|------|------|---------------|----------|\n| 0 | Success | -- | -- |\n| 1 | User error | Bad input, missing wallet, invalid invoice, expired invoice | Fix input and retry |\n| 2 | Network error | Connection failed, sync timeout, payment timeout | Retry after delay |\n| 3 | Insufficient funds | Not enough on-chain or Lightning balance | Fund wallet or open channel |\n\n### Error Envelope\n\nWhen `--json` is used and an error occurs, a structured error envelope is written to stderr:\n\n```json\n{\n  \"ok\": false,\n  \"error\": \"Invalid invoice: ...\",\n  \"code\": 1\n}\n```\n\n### Bash Pattern\n\n```bash\nOUTPUT=$(bk pay \"$BOLT11\" --json 2>\u002Fdev\u002Fnull)\nEXIT_CODE=$?\n\ncase $EXIT_CODE in\n  0) echo \"Success: $(echo \"$OUTPUT\" | jq -r '.data.payment_hash')\" ;;\n  1) echo \"Bad input -- check the invoice\" >&2; exit 1 ;;\n  2) echo \"Network issue -- retrying...\" >&2; sleep 5; bk pay \"$BOLT11\" --json ;;\n  3) echo \"Insufficient funds\" >&2; exit 3 ;;\nesac\n```\n\n**Important:** Errors print to stderr (as JSON envelope when `--json` is used). Success output prints to stdout. Always capture them separately.\n\n## Multi-Wallet Pattern\n\nRun multiple independent agent wallets by using separate data directories.\n\n```bash\nexport BITKIT_DIR=\"\u002Ftmp\u002Fagent-${SESSION_ID}\"\nbk init --no-password --json\nbk address --json\n# ... each agent operates independently\n```\n\nOr use the `--dir` flag:\n\n```bash\nbk --dir \u002Ftmp\u002Fagent-alice init --no-password --json\nbk --dir \u002Ftmp\u002Fagent-bob init --no-password --json\n```\n\nEach directory gets its own seed, node identity, Pubky ID, and channel state. Agents sharing a machine can run concurrently with different `--dir` values.\n\n## Input Validation Reference\n\n| Format | Pattern | Example |\n|--------|---------|---------|\n| Node pubkey | 66-char hex (compressed secp256k1) | `02abc123...` |\n| Peer address | `pubkey@host:port` | `02abc...@127.0.0.1:9735` |\n| Transaction ID | 64-char hex | `4a5e1e4baab89f3a...` |\n| Outpoint | `txid:vout` (decimal vout) | `4a5e1e4b...:0` |\n| Channel ID | Decimal u128 | `12345678901234567890` |\n| Bitcoin address | Network-validated bech32\u002Fbase58 | `bc1q...`, `bcrt1q...` |\n| BOLT11 invoice | `lnbc...` or `lnbcrt...` prefix | `lnbc50u1p...` |\n| LNURL | Bech32 with `lnurl` HRP | `lnurl1dp68gurn...` |\n| Lightning Address | `user@domain.tld` | `agent@pay.bitkit.to` |\n| Pubky ID | 52-char z-base-32 | `8pinxrz9tux...45mo` |\n| Fee rate | Positive integer (sat\u002Fvb) | `5` |\n| Amount | Non-negative integer (satoshis) | `50000` |\n\nAll validation errors exit with code 1 and include a descriptive error message.\n\n## Messaging Workflow\n\n### Agent Message Protocol\n\nAgents communicate structured data by sending JSON strings as message content. The convention uses a `type` field to distinguish message kinds:\n\n**Invoice request:**\n\n```json\n{\n  \"type\": \"invoice\",\n  \"bolt11\": \"lnbc50u1p...\",\n  \"amount_sats\": 5000,\n  \"description\": \"data analysis service\"\n}\n```\n\n**Payment confirmation:**\n\n```json\n{\n  \"type\": \"payment_confirmation\",\n  \"payment_hash\": \"a1b2c3d4e5f6...\",\n  \"amount_sats\": 5000\n}\n```\n\n### Workflow: Discover, Message, Pay\n\n```bash\n# 1. Get your own Pubky ID to share with other agents\nMY_ID=$(bk message whoami --json | jq -r '.data.pubky_id')\n\n# 2. Send a message to another agent\nbk message send \"$PEER_PUBKY\" \"Hello, I need data analysis\" --json\n\n# 3. Listen for their reply (they'll send an invoice)\nbk message listen \"$PEER_PUBKY\" --timeout 120 --json | while IFS= read -r MSG; do\n  TYPE=$(echo \"$MSG\" | jq -r '.data.content' | jq -r '.type \u002F\u002F empty' 2>\u002Fdev\u002Fnull)\n  if [ \"$TYPE\" = \"invoice\" ]; then\n    BOLT11=$(echo \"$MSG\" | jq -r '.data.content' | jq -r '.bolt11')\n    echo \"Received invoice: $BOLT11\"\n    break\n  fi\ndone\n\n# 4. Pay the invoice\nbk pay \"$BOLT11\" --json\n```\n\n## End-to-End: Pay Another Agent\n\nComplete flow where Agent A requests a service, Agent B invoices for it, Agent A pays, and Agent B confirms.\n\n### Agent B (service provider)\n\n```bash\n#!\u002Fusr\u002Fbin\u002Fenv bash\nset -euo pipefail\nexport BITKIT_DIR=\u002Ftmp\u002Fagent-b\n\n# Initialize and share identity\nbk init --no-password --json >\u002Fdev\u002Fnull\nMY_ID=$(bk message whoami --json | jq -r '.data.pubky_id')\necho \"Agent B Pubky ID: $MY_ID\"\n\n# Listen for requests from Agent A\nbk message listen \"$AGENT_A_PUBKY\" --timeout 300 --json | while IFS= read -r MSG; do\n  CONTENT=$(echo \"$MSG\" | jq -r '.data.content')\n\n  # Create invoice for the requested service\n  INVOICE_JSON=$(bk invoice 5000 --description \"data analysis\" --json)\n  BOLT11=$(echo \"$INVOICE_JSON\" | jq -r '.data.bolt11')\n\n  # Send invoice to Agent A\n  PAYLOAD=$(jq -n --arg b \"$BOLT11\" '{type:\"invoice\",bolt11:$b,amount_sats:5000,description:\"data analysis\"}')\n  bk message send \"$AGENT_A_PUBKY\" \"$PAYLOAD\" --json\n\n  # Wait for payment\n  RECEIVED=$(bk invoice 5000 --description \"data analysis\" --wait --listen 9735 --json | tail -1)\n  HASH=$(echo \"$RECEIVED\" | jq -r '.data.payment_hash')\n\n  # Confirm payment\n  CONFIRM=$(jq -n --arg h \"$HASH\" '{type:\"payment_confirmation\",payment_hash:$h,amount_sats:5000}')\n  bk message send \"$AGENT_A_PUBKY\" \"$CONFIRM\" --json\n  break\ndone\n```\n\n### Agent A (client)\n\n```bash\n#!\u002Fusr\u002Fbin\u002Fenv bash\nset -euo pipefail\nexport BITKIT_DIR=\u002Ftmp\u002Fagent-a\n\n# Initialize\nbk init --no-password --json >\u002Fdev\u002Fnull\nMY_ID=$(bk message whoami --json | jq -r '.data.pubky_id')\n\n# Request service from Agent B\nbk message send \"$AGENT_B_PUBKY\" \"Please analyze dataset X\" --json\n\n# Wait for invoice\nBOLT11=\"\"\nbk message listen \"$AGENT_B_PUBKY\" --timeout 120 --json | while IFS= read -r MSG; do\n  TYPE=$(echo \"$MSG\" | jq -r '.data.content' | jq -r '.type \u002F\u002F empty' 2>\u002Fdev\u002Fnull)\n  if [ \"$TYPE\" = \"invoice\" ]; then\n    BOLT11=$(echo \"$MSG\" | jq -r '.data.content' | jq -r '.bolt11')\n    break\n  fi\ndone\n\n# Pay the invoice\nPAY_RESULT=$(bk pay \"$BOLT11\" --json)\necho \"Payment status: $(echo \"$PAY_RESULT\" | jq -r '.data.status')\"\necho \"Fee paid: $(echo \"$PAY_RESULT\" | jq -r '.data.fee_sat') sats\"\n\n# Wait for confirmation\nbk message listen \"$AGENT_B_PUBKY\" --timeout 60 --json | while IFS= read -r MSG; do\n  TYPE=$(echo \"$MSG\" | jq -r '.data.content' | jq -r '.type \u002F\u002F empty' 2>\u002Fdev\u002Fnull)\n  if [ \"$TYPE\" = \"payment_confirmation\" ]; then\n    echo \"Payment confirmed by Agent B\"\n    break\n  fi\ndone\n```\n\n## Security & Privacy\n\n**Trust model:** Fully self-custodial. The BIP39 seed never leaves the local machine. No telemetry, analytics, or tracking of any kind.\n\n**External endpoints contacted:**\n\n| Endpoint | Purpose | Data Sent | Configurable |\n|----------|---------|-----------|--------------|\n| Esplora server | Chain sync (mainnet) | Transaction queries | Yes (`esplora_url`) |\n| Electrum server | Chain sync (regtest) | Transaction queries | Yes (`electrum_url`) |\n| RGS server | Lightning gossip sync | None (download only) | Yes (`rgs_url`) |\n| Blocktank API | LSP channel orders | Node ID, order params | Yes (`blocktank_url`) |\n| LNURL service | Pay\u002Fwithdraw resolution | Amount, callback URL | User-initiated only |\n| Pubky DHT | Encrypted messaging | E2E encrypted payloads | Built-in |\n| Webhook URL | Event notifications | Payment\u002Fchannel events | Yes (`webhook_url`) |\n\n**Seed storage:** Custom binary format with magic bytes (`BKIT`), version byte, and encrypted (AES-256-GCM + Argon2id KDF) or plaintext flag. File: `~\u002F.bitkit\u002F\u003Cnetwork>\u002Fseed.enc`.\n\n**API password:** Auto-generated 32-byte random hex, stored with `0600` permissions. Only used for local daemon HTTP API access.\n\n## LSP Workflow: Fresh Wallet to Lightning-Ready\n\nFrom a brand new wallet to being able to send and receive Lightning payments:\n\n```bash\n# 1. Create wallet\nbk init --no-password --json\n\n# 2. Get on-chain address\nADDRESS=$(bk address --json | jq -r '.data.address')\necho \"Fund this address: $ADDRESS\"\n\n# 3. (Fund the address externally, wait for confirmation)\n\n# 4. Estimate channel fees\nbk lsp estimate-fee 500000 --json\n\n# 5. Create channel order\nORDER_ID=$(bk lsp create-order 500000 --json | jq -r '.data.order_id')\n\n# 6. Pay the order on-chain (the payment_address from create-order)\n# ... or wait for on-chain funding to cover it\n\n# 7. Poll until order is paid\nwhile true; do\n  STATE=$(bk lsp get-order \"$ORDER_ID\" --json | jq -r '.data.state2')\n  [ \"$STATE\" = \"Paid\" ] && break\n  sleep 10\ndone\n\n# 8. Open the channel\nbk lsp open-channel \"$ORDER_ID\" --listen 9735 --json\n\n# 9. Verify channel is active\nbk list-channels --json | jq '.data[0].is_usable'\n\n# Now ready to send and receive Lightning payments\n```\n\n## Tags\n\nbitcoin, lightning, payment, invoice, self-custody, wallet, CLI, agent, LNURL, lightning-address, BOLT11, LSP, lowest-fees, daemon, webhooks, websocket, encrypted-messaging, on-chain, channels, liquidity\n",{"name":5,"version":24,"metadata":25,"description":7},"0.2.0",{"clawdbot":26},{"emoji":27,"homepage":28,"requires":29},"⚡","https:\u002F\u002Fgithub.com\u002Fsynonymdev\u002Fbitkit-cli",{"bins":30},[31],"bitkit","main","f9d3fe7cf9ac8f1ea63a0d96e98e1f510a3814db","skills\u002Fovitrif\u002Fbitkit-cli",1,"https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills","https:\u002F\u002Fgithub.com\u002Fjavimosch","intrane.fr","Building robust, open-source infrastructure for the commons. AI-leveraged, self-hosted, built to last.","2026-06-07 03:34:58",{"source":8,"skillName":5,"commands":42,"prompt":52,"zipAvailable":53},[43,46,49],{"tool":44,"command":45},"npx","npx skills add javimosch\u002Fopen-claw-skills --skill bitkit-cli",{"tool":47,"command":48},"bunx","bunx skills add javimosch\u002Fopen-claw-skills --skill bitkit-cli",{"tool":50,"command":51},"pnpm","pnpm dlx skills add javimosch\u002Fopen-claw-skills --skill bitkit-cli","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fovitrif\u002Fbitkit-cli\u002FSKILL.md",true,[],[56,64,71,78,85,92],{"skillNo":57,"name":58,"nameZh":6,"description":59,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":63},"01M778GGXG2VQ0YF31W2MKGMQZ","crowd-prompting","A marketplace where AI agents improve prompts, system instructions, tool descriptions, and other text-based content with domain expertise from real-world operations — and earn tokens for valuable contributions.","https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzzadrian\u002Fcrowd-prompting\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":65,"name":66,"nameZh":6,"description":67,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":63},"01M778G7BH8SBJ9FJ6C3G7CB1K","ceaser","Interact with the Ceaser privacy protocol on Base L2 using the ceaser-mcp MCP tools. This skill uses the ceaser-mcp npm package for ALL operations -- shield, unshield, note management, and protocol queries. All ceaser tool calls use CLI subcommands (npx -y ceaser-mcp \u003Csubcommand>). Ceaser is a privacy-preserving ETH wrapper using Noir\u002FUltraHonk zero-knowledge proofs on Base L2 (chain ID 8453).","https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzyra-v21\u002Fceaser\u002FSKILL.md",[],[],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":63},"01M778FYCJQZWFKKX5FYMK3S47","ceaser-send","Fully automated private ETH transfer via Ceaser Protocol on Base L2 using the ceaser-mcp MCP tools. This skill uses the ceaser-mcp npm package for ALL operations -- all ceaser tool calls use CLI subcommands (npx -y ceaser-mcp \u003Csubcommand>). WARNING -- creates observable on-chain links between user wallet and hot wallet (see Privacy Warning). Generates an ephemeral hot wallet with BIP-39 mnemonic recovery, user funds it, agent signs and broadcasts the Shield TX automatically. Exactly one manual step required (funding the hot wallet with ETH). Uses Noir\u002FUltraHonk zero-knowledge proofs.","https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzyra-v21\u002Fceaser-send\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":63},"01M778FQQNSEYA3HJKZBPQ4M9Z","dilemm-ai","Compete in DilemmAI, the prisoner's dilemma AI arena at dilemm.ai. Use when an OpenClaw agent wants to create an account, design and submit strategy prompts for their bot, enter matchmaking, analyze historical matches and leaderboards, and iterate on bot strategy. Requires headless browser automation (no API available yet).","https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzyori\u002Fdilemm-ai\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":63},"01M778FGVZX7QA2TF9BFMM37FY","moldium","Post and manage content on the Moldium blog platform. Triggered by \"post to Moldium\", \"write a blog post\", \"publish an article\", etc.","https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzyom45\u002Fmoldium\u002FSKILL.md",[],[],{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":63},"01M778F88D8PQ9MQ0KNW2TJ8ZH","arxiv-paper-reviews","Interact with arXiv Crawler API to fetch papers, read reviews, submit comments, search papers, and import papers. Use when working with arXiv papers, fetching paper lists by date\u002Fcategory\u002Finterest, viewing paper details with comments, submitting paper reviews, searching papers by title, or importing papers from arXiv URLs via API at http:\u002F\u002Fweakaccept.top:8000\u002F.","https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzxrys\u002Farxiv-paper-reviews\u002FSKILL.md",[],[]]