beignet 0.21.12 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -12
- package/dist/cli/beignet-node.js +853 -295
- package/dist/cli/beignet-node.js.map +1 -1
- package/dist/cli/cli.js +71 -16
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/config.js +35 -4
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/daemon-options.js +1 -0
- package/dist/cli/daemon-options.js.map +1 -1
- package/dist/cli/daemon.js +174 -30
- package/dist/cli/daemon.js.map +1 -1
- package/dist/cli/errors.js +9 -1
- package/dist/cli/errors.js.map +1 -1
- package/dist/cli/fs-utils.js +73 -0
- package/dist/cli/fs-utils.js.map +1 -0
- package/dist/cli/index.js +2 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/instance-lock.js +1 -1
- package/dist/cli/instance-lock.js.map +1 -1
- package/dist/cli/node-storage-view.js +40 -0
- package/dist/cli/node-storage-view.js.map +1 -0
- package/dist/cli/openapi.js +48 -5
- package/dist/cli/openapi.js.map +1 -1
- package/dist/cli/payment-queue.js +215 -31
- package/dist/cli/payment-queue.js.map +1 -1
- package/dist/cli/process-faults.js +37 -0
- package/dist/cli/process-faults.js.map +1 -0
- package/dist/cli/restore.js +4 -0
- package/dist/cli/restore.js.map +1 -1
- package/dist/electrum/index.js +25 -6
- package/dist/electrum/index.js.map +1 -1
- package/dist/lightning/channel/channel-state.js.map +1 -1
- package/dist/lightning/channel/channel.js +367 -9
- package/dist/lightning/channel/channel.js.map +1 -1
- package/dist/lightning/channel/commitment-builder.js +2 -1
- package/dist/lightning/channel/commitment-builder.js.map +1 -1
- package/dist/lightning/channel/types.js.map +1 -1
- package/dist/lightning/gossip/pathfinding.js +5 -1
- package/dist/lightning/gossip/pathfinding.js.map +1 -1
- package/dist/lightning/node/lightning-node.js +263 -29
- package/dist/lightning/node/lightning-node.js.map +1 -1
- package/dist/lightning/node/types.js.map +1 -1
- package/dist/lightning/storage/serialization.js +16 -0
- package/dist/lightning/storage/serialization.js.map +1 -1
- package/dist/lightning/storage/sqlite-storage.js +46 -0
- package/dist/lightning/storage/sqlite-storage.js.map +1 -1
- package/dist/lightning/transport/peer-manager.js +13 -7
- package/dist/lightning/transport/peer-manager.js.map +1 -1
- package/dist/lightning/watchtower/tower-connection.js +2 -4
- package/dist/lightning/watchtower/tower-connection.js.map +1 -1
- package/dist/lightning/watchtower/watchtower-client.js +3 -1
- package/dist/lightning/watchtower/watchtower-client.js.map +1 -1
- package/dist/transaction/index.js +25 -8
- package/dist/transaction/index.js.map +1 -1
- package/dist/types/cli/beignet-node.d.ts +40 -8
- package/dist/types/cli/daemon.d.ts +8 -0
- package/dist/types/cli/errors.d.ts +5 -1
- package/dist/types/cli/fs-utils.d.ts +11 -0
- package/dist/types/cli/index.d.ts +1 -1
- package/dist/types/cli/node-storage-view.d.ts +2 -0
- package/dist/types/cli/payment-queue.d.ts +27 -0
- package/dist/types/cli/process-faults.d.ts +9 -0
- package/dist/types/cli/types.d.ts +6 -0
- package/dist/types/electrum/index.d.ts +1 -0
- package/dist/types/lightning/channel/channel-state.d.ts +1 -0
- package/dist/types/lightning/channel/channel.d.ts +14 -0
- package/dist/types/lightning/channel/commitment-builder.d.ts +4 -0
- package/dist/types/lightning/channel/types.d.ts +2 -0
- package/dist/types/lightning/node/lightning-node.d.ts +17 -2
- package/dist/types/lightning/node/types.d.ts +4 -0
- package/dist/types/lightning/storage/serialization.d.ts +4 -0
- package/dist/types/lightning/storage/sqlite-storage.d.ts +1 -0
- package/dist/types/lightning/transport/peer-manager.d.ts +14 -0
- package/dist/types/lightning/watchtower/tower-connection.d.ts +2 -0
- package/dist/types/lightning/watchtower/watchtower-client.d.ts +3 -0
- package/dist/types/transaction/index.d.ts +3 -0
- package/dist/types/wallet/index.d.ts +5 -0
- package/dist/wallet/index.js +252 -150
- package/dist/wallet/index.js.map +1 -1
- package/docs/AI_AGENT_GUIDE.md +25 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -284,7 +284,7 @@ coordinator.exportDescriptors();
|
|
|
284
284
|
<details>
|
|
285
285
|
<summary><b>Encrypted storage and leveled logging</b></summary>
|
|
286
286
|
|
|
287
|
-
The wallet persists through the host-injected `TStorage` interface (`storage: { getData, setData }`), and values are handed over as-is, so by default they are stored in plaintext. Persisted data is addresses, indexes, UTXOs, transactions, balance and fee estimates: no private keys and no mnemonic are ever written, so exposure is a privacy concern (full wallet history), not fund loss.
|
|
287
|
+
The wallet persists through the host-injected `TStorage` interface (`storage: { getData, setData }`), and values are handed over as-is, so by default they are stored in plaintext. Persisted data is addresses, indexes, UTXOs, transactions, balance and fee estimates: no private keys and no mnemonic are ever written, so exposure is a privacy concern (full wallet history), not fund loss. The staged send (`transaction`) is written without signing keys, so a key pair handed to `sweepPrivateKey` or `addExternalInputs` never reaches storage, and `send`, `sendMany`, `sendMax`, `buildPsbt` and `sweepPrivateKey` reset the staged send when they return, so a restart never replays an earlier call's recipients.
|
|
288
288
|
|
|
289
289
|
Wrap any `TStorage` with `createEncryptedStorage` to encrypt at rest with AES-256-GCM under an HKDF-derived key from the seed. Pre-existing plaintext values pass through unchanged and migrate lazily as they are rewritten.
|
|
290
290
|
|
|
@@ -442,14 +442,17 @@ CLI: `beignet watchtower list|add <pubkey@host:port>|remove <uri>`, daemon flag
|
|
|
442
442
|
The same node runs as an HTTP/SSE daemon for language-agnostic integrations, driven by a JSON CLI.
|
|
443
443
|
|
|
444
444
|
```bash
|
|
445
|
-
# 1. Generate a mnemonic
|
|
445
|
+
# 1. Generate a mnemonic, an API token and ~/.beignet/config.json
|
|
446
446
|
npx beignet init --network regtest
|
|
447
|
+
# {"ok":true,"result":{"message":"Initialized","mnemonic":"...","network":"regtest",
|
|
448
|
+
# "apiToken":"3f9c...64 hex...","note":"apiToken was generated and saved to config.json; ..."}}
|
|
447
449
|
|
|
448
|
-
# 2. Start the daemon (add --daemon to background it)
|
|
450
|
+
# 2. Start the daemon (add --daemon to background it). It reads the token from
|
|
451
|
+
# config.json; --api-token or BEIGNET_API_TOKEN override it.
|
|
449
452
|
BEIGNET_ELECTRUM_HOST=127.0.0.1 BEIGNET_ELECTRUM_PORT=60001 BEIGNET_ELECTRUM_TLS=false \
|
|
450
|
-
npx beignet start --network regtest
|
|
453
|
+
npx beignet start --network regtest
|
|
451
454
|
|
|
452
|
-
# 3. Drive it with the CLI (thin HTTP client, JSON out)
|
|
455
|
+
# 3. Drive it with the CLI (thin HTTP client, JSON out; it sends the token itself)
|
|
453
456
|
npx beignet info --pretty
|
|
454
457
|
npx beignet address
|
|
455
458
|
npx beignet channel connect-and-open <pubkey> <host> <port> 200000
|
|
@@ -459,22 +462,26 @@ npx beignet invoice pay <bolt11>
|
|
|
459
462
|
|
|
460
463
|
Electrum and most other settings come from `~/.beignet/config.json` or the environment (`BEIGNET_MNEMONIC`, `BEIGNET_ELECTRUM_HOST`, `BEIGNET_ELECTRUM_PORT`, `BEIGNET_NETWORK`, ...). Run `npx beignet help` for the full command and flag list.
|
|
461
464
|
|
|
462
|
-
|
|
465
|
+
`config.json` holds the mnemonic, so everything under `~/.beignet` is created owner-only (`0700` directories, `0600` files: config, pid file, database and sidecars, backups, SCB exports), the CLI runs `init`, `start`, `backup` and `restore` under umask `077`, and a config file an earlier release left readable is tightened the next time it is read, with a notice on stderr. Details in [src/cli/README.md](src/cli/README.md#file-permissions).
|
|
466
|
+
|
|
467
|
+
Or over HTTP directly, with the token `init` printed (or `apiToken` from `~/.beignet/config.json`):
|
|
463
468
|
|
|
464
469
|
```bash
|
|
465
|
-
|
|
470
|
+
TOKEN=3f9c... # the apiToken from beignet init
|
|
471
|
+
curl -X POST http://localhost:2112/invoice/create -H "Authorization: Bearer $TOKEN" \
|
|
466
472
|
-H 'Content-Type: application/json' -d '{"amountSats": 1000, "description": "coffee"}'
|
|
467
473
|
|
|
468
|
-
curl -X POST http://localhost:2112/invoice/pay -H
|
|
474
|
+
curl -X POST http://localhost:2112/invoice/pay -H "Authorization: Bearer $TOKEN" \
|
|
469
475
|
-H 'Content-Type: application/json' -d '{"bolt11": "lnbcrt10n1..."}'
|
|
470
476
|
|
|
471
|
-
curl -N http://localhost:2112/events -H
|
|
472
|
-
curl http://localhost:2112/ready
|
|
477
|
+
curl -N http://localhost:2112/events -H "Authorization: Bearer $TOKEN" # SSE stream
|
|
478
|
+
curl http://localhost:2112/ready # load-balancer probe
|
|
473
479
|
```
|
|
474
480
|
|
|
475
481
|
- Responses are `{ "ok": true, "result": {...} }` or `{ "ok": false, "error": { "code": "...", "message": "..." } }`.
|
|
476
482
|
- Full spec at `GET /openapi.json`.
|
|
477
|
-
- `
|
|
483
|
+
- Authentication is on for every install `beignet init` creates (releases after 0.22.0): `init` mints a random `apiToken` and saves it in `config.json` (run `init` again on an older config to add one). Auth is off only for a config with neither `apiToken` nor `apiKeys` (named keys with `readonly`/`invoice`/`admin` scopes); `beignet start` warns on stderr in that case. `GET /health`, `/ready` and `/openapi.json` are auth-exempt; `/metrics` only with `metricsPublic`; everything else requires the bearer token. The daemon binds `127.0.0.1` by default.
|
|
484
|
+
- While auth is off, three browser guards keep a web page from driving the loopback daemon (issue #1005): a request body must be `Content-Type: application/json` (else `415 UNSUPPORTED_MEDIA_TYPE`), an `Origin` other than the configured `cors` origin or a `Sec-Fetch-Site: cross-site` request is refused (`403 CROSS_SITE_REQUEST_REFUSED`), and the `Host` header must be the loopback name the daemon is bound on (else `421 HOST_NOT_ALLOWED`, which also defeats DNS rebinding). They apply to every route but `OPTIONS`; plain clients (curl, the CLI, the SDKs) send none of those headers and are unaffected, and with a token configured the guards do not run at all.
|
|
478
485
|
- Embed it instead of shelling out: `import { startDaemon } from 'beignet/cli'`.
|
|
479
486
|
|
|
480
487
|
### FFOR offline receive
|
|
@@ -740,9 +747,13 @@ Beignet is under active development. Known gaps and caveats:
|
|
|
740
747
|
|
|
741
748
|
Recommended safeguards in production:
|
|
742
749
|
|
|
743
|
-
- Cap exposure with `maxPaymentSats` and `dailySpendLimitSats`.
|
|
750
|
+
- Cap exposure with `maxPaymentSats` and `dailySpendLimitSats`. Both count a
|
|
751
|
+
payment's amount plus its routing-fee cap, so the fee cannot slip past them:
|
|
752
|
+
the cap is `maxFeeSats`/`maxFeeMsat` when you pass one, and 1% of the
|
|
753
|
+
amount (never below 50 sats) when you do not.
|
|
744
754
|
- Call `validatePayment()` before every send.
|
|
745
755
|
- Set `backupPath` for automated database backups, and keep an SCB (`beignet backup scb`).
|
|
756
|
+
- Keep `~/.beignet` and the data directory owner-only. The CLI creates them `0700`/`0600` and tightens an older config on load; check them again after copying files between hosts.
|
|
746
757
|
- Pass multiple `electrumServers` for connection redundancy.
|
|
747
758
|
- Configure watchtowers so breaches are punished while you are offline.
|
|
748
759
|
- Monitor `node:error` events and the `/health` endpoint.
|