@1sat/cli 0.0.3 → 0.0.5

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.
Files changed (2) hide show
  1. package/README.md +311 -0
  2. package/package.json +9 -5
package/README.md ADDED
@@ -0,0 +1,311 @@
1
+ # @1sat/cli
2
+
3
+ Command-line interface for 1Sat Ordinals on BSV.
4
+
5
+ ```
6
+ bun add -g @1sat/cli
7
+ ```
8
+
9
+ Or run without installing:
10
+
11
+ ```
12
+ bunx @1sat/cli
13
+ ```
14
+
15
+ ---
16
+
17
+ ## Quick Start
18
+
19
+ ```bash
20
+ # 1. Set up your wallet (interactive)
21
+ 1sat init
22
+
23
+ # 2. Check your balance
24
+ 1sat wallet balance
25
+
26
+ # 3. List your ordinals
27
+ 1sat ordinals list
28
+ ```
29
+
30
+ ---
31
+
32
+ ## Install
33
+
34
+ **Global install (recommended):**
35
+
36
+ ```bash
37
+ bun add -g @1sat/cli
38
+ ```
39
+
40
+ **Run without installing:**
41
+
42
+ ```bash
43
+ bunx @1sat/cli <command>
44
+ ```
45
+
46
+ **Binary:** The installed binary is named `1sat`.
47
+
48
+ ---
49
+
50
+ ## Authentication
51
+
52
+ The CLI resolves your private key in this order:
53
+
54
+ 1. `PRIVATE_KEY_WIF` environment variable — works without a password or any disk state.
55
+ 2. `~/.1sat/keys.bep` — encrypted keyfile created by `1sat init`. Requires a password at runtime via `ONESAT_PASSWORD` env var or an interactive prompt.
56
+ 3. Neither found — exits with an error and tells you to run `1sat init`.
57
+
58
+ **Environment variable (CI / scripting):**
59
+
60
+ ```bash
61
+ export PRIVATE_KEY_WIF="<your WIF key>"
62
+ 1sat wallet balance
63
+ ```
64
+
65
+ **Encrypted keyfile (interactive use):**
66
+
67
+ ```bash
68
+ # Set once — creates ~/.1sat/keys.bep
69
+ 1sat init
70
+
71
+ # Unlock at runtime via env var
72
+ export ONESAT_PASSWORD="your-password"
73
+ 1sat wallet balance
74
+
75
+ # Or enter it interactively when prompted
76
+ 1sat wallet balance
77
+ ```
78
+
79
+ WIF keys start with `5`, `K`, or `L` on mainnet and `c` on testnet.
80
+
81
+ ---
82
+
83
+ ## Configuration
84
+
85
+ All state lives in `~/.1sat/` (mode `0700`):
86
+
87
+ | File | Purpose |
88
+ |------|---------|
89
+ | `config.json` | Network, data directory, storage settings |
90
+ | `keys.bep` | AES-encrypted private key (mode `0600`) |
91
+ | `data/` | Local wallet databases |
92
+
93
+ **View current config:**
94
+
95
+ ```bash
96
+ 1sat config show
97
+ ```
98
+
99
+ **Set a value:**
100
+
101
+ ```bash
102
+ 1sat config set chain test
103
+ 1sat config set remoteStorageUrl https://storage.example.com
104
+ ```
105
+
106
+ Settable keys: `chain`, `dataDir`, `remoteStorageUrl`, `storageIdentityKey`.
107
+
108
+ **Print config directory:**
109
+
110
+ ```bash
111
+ 1sat config path
112
+ ```
113
+
114
+ ---
115
+
116
+ ## Commands
117
+
118
+ ### Setup
119
+
120
+ ```bash
121
+ 1sat init # Interactive wallet setup wizard
122
+ ```
123
+
124
+ `init` generates or imports a WIF key, encrypts it with a password you choose, selects mainnet or testnet, and writes `~/.1sat/config.json`.
125
+
126
+ ---
127
+
128
+ ### Wallet
129
+
130
+ ```bash
131
+ 1sat wallet balance # Show balance in satoshis and UTXO count
132
+ 1sat wallet address # Show deposit address
133
+ 1sat wallet info # Show address, identity key, balance, network
134
+ 1sat wallet send --to <addr> --sats <amount>
135
+ 1sat wallet send-all --to <addr> # Empty the wallet to one address
136
+ ```
137
+
138
+ ---
139
+
140
+ ### Ordinals
141
+
142
+ ```bash
143
+ 1sat ordinals list # List owned inscriptions
144
+ 1sat ordinals mint --file <path> # Inscribe a file (MIME type auto-detected)
145
+ 1sat ordinals mint --file <path> --type <mime> # Inscribe with explicit content type
146
+ 1sat ordinals transfer --outpoint <txid.vout> --to <addr>
147
+ 1sat ordinals sell --outpoint <txid.vout> --price <sats>
148
+ 1sat ordinals cancel --outpoint <txid.vout>
149
+ 1sat ordinals buy --outpoint <txid.vout>
150
+ ```
151
+
152
+ Supported file types for auto-detection: `.txt`, `.html`, `.css`, `.js`, `.json`, `.svg`, `.png`, `.jpg`, `.gif`, `.webp`, `.mp3`, `.mp4`, `.pdf`, and more.
153
+
154
+ ---
155
+
156
+ ### Tokens (BSV21)
157
+
158
+ ```bash
159
+ 1sat tokens balances # Show balances by token ID
160
+ 1sat tokens list # List all token UTXOs
161
+ 1sat tokens list --token-id <id> # Filter by token ID
162
+ 1sat tokens send --token-id <id> --to <addr> --amount <n>
163
+ 1sat tokens buy --outpoint <txid.vout> --token-id <id> --amount <n>
164
+ ```
165
+
166
+ `tokens deploy` is not yet available; token deployment will be added once a deploy action lands in `@1sat/actions`.
167
+
168
+ ---
169
+
170
+ ### Locks
171
+
172
+ ```bash
173
+ 1sat locks info # Show locked amounts and maturity status
174
+ 1sat locks lock --sats <amount> --blocks <n> # Lock BSV until block height
175
+ 1sat locks unlock # Unlock all matured locks
176
+ ```
177
+
178
+ ---
179
+
180
+ ### Identity (BAP)
181
+
182
+ ```bash
183
+ 1sat identity create # Publish a BAP identity on-chain
184
+ 1sat identity info # Show your identity key
185
+ 1sat identity sign --message <text> # Sign a message (BSM)
186
+ ```
187
+
188
+ ---
189
+
190
+ ### Social
191
+
192
+ ```bash
193
+ 1sat social post --content <text> # Create an on-chain BSocial post
194
+ 1sat social post --content <text> --app <name> # Post with a custom app tag
195
+ ```
196
+
197
+ ---
198
+
199
+ ### OpNS
200
+
201
+ OpNS (Ordinals Name System) binds your BAP identity to an on-chain name inscription.
202
+
203
+ ```bash
204
+ 1sat opns lookup # List OpNS names in your wallet
205
+ 1sat opns register --outpoint <txid.vout> # Bind your identity to a name
206
+ 1sat opns deregister --outpoint <txid.vout> # Remove the identity binding
207
+ ```
208
+
209
+ ---
210
+
211
+ ### Sweep
212
+
213
+ Import assets from an external private key (e.g., a legacy P2PKH wallet) into your BRC-100 wallet.
214
+
215
+ ```bash
216
+ 1sat sweep scan --wif <key> # Preview what a key holds (BSV, ordinals, tokens)
217
+ 1sat sweep import --wif <key> # Import everything into your wallet
218
+ ```
219
+
220
+ `scan` is non-destructive. `import` broadcasts transactions — confirm when prompted or pass `--yes`.
221
+
222
+ ---
223
+
224
+ ### Transaction Utilities
225
+
226
+ ```bash
227
+ 1sat tx decode <hex> # Decode a raw transaction hex string
228
+ ```
229
+
230
+ ---
231
+
232
+ ### Generic Action Executor
233
+
234
+ Every action registered in `@1sat/actions` is available by name:
235
+
236
+ ```bash
237
+ 1sat action # List all registered actions grouped by category
238
+ 1sat action <name> # Run an action with no input
239
+ 1sat action <name> '<json>' # Run an action with JSON input
240
+ ```
241
+
242
+ Example:
243
+
244
+ ```bash
245
+ 1sat action sendBsv '{"requests":[{"address":"1A1zP1eP5QGefi2DMPTfTL5SLmv7Divf","satoshis":1000}]}'
246
+ ```
247
+
248
+ This executor gives scripting access to all 30+ actions without waiting for dedicated CLI subcommands to be added.
249
+
250
+ ---
251
+
252
+ ## Global Options
253
+
254
+ These options work with every command:
255
+
256
+ | Flag | Description |
257
+ |------|-------------|
258
+ | `--json` | Print output as JSON (machine-readable) |
259
+ | `--quiet`, `-q` | Suppress all output |
260
+ | `--yes`, `-y` | Skip confirmation prompts |
261
+ | `--chain <main\|test>` | Network selection (default: `main`) |
262
+ | `--help`, `-h` | Show help |
263
+ | `--version`, `-v` | Show version |
264
+
265
+ **JSON output example:**
266
+
267
+ ```bash
268
+ 1sat wallet balance --json
269
+ # {"satoshis":123456,"utxos":3}
270
+
271
+ 1sat ordinals list --json
272
+ # [...array of outputs...]
273
+ ```
274
+
275
+ **Scripting with --yes:**
276
+
277
+ ```bash
278
+ 1sat wallet send --to 1A1z... --sats 1000 --yes
279
+ ```
280
+
281
+ ---
282
+
283
+ ## Development
284
+
285
+ Run from source inside the monorepo:
286
+
287
+ ```bash
288
+ cd /path/to/1sat-sdk
289
+
290
+ # Install dependencies
291
+ bun install
292
+
293
+ # Run the CLI directly (no compile step)
294
+ bun run packages/cli/src/cli.ts <command>
295
+
296
+ # Or use the dev script from the cli package
297
+ cd packages/cli
298
+ bun dev <command>
299
+
300
+ # Build a self-contained binary
301
+ bun run build
302
+ # Output: packages/cli/bin/1sat
303
+ ```
304
+
305
+ The CLI is pure Bun with no framework. Arg parsing is manual (`src/args.ts`). Bun executes TypeScript directly, so you can run from source without a compile step.
306
+
307
+ ---
308
+
309
+ ## License
310
+
311
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1sat/cli",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "CLI for 1Sat Ordinals SDK",
5
5
  "type": "module",
6
6
  "main": "./src/cli.ts",
@@ -16,14 +16,18 @@
16
16
  "keywords": ["1sat", "bsv", "ordinals", "cli"],
17
17
  "license": "MIT",
18
18
  "dependencies": {
19
- "@1sat/actions": "0.0.52",
20
- "@1sat/client": "0.0.15",
19
+ "@1sat/actions": "0.0.53",
20
+ "@1sat/client": "0.0.16",
21
21
  "@1sat/types": "0.0.13",
22
- "@1sat/wallet-node": "0.0.11",
22
+ "@1sat/wallet-node": "0.0.12",
23
23
  "@bsv/sdk": "^2.0.4",
24
+ "@bsv/wallet-toolbox": "^2.0.20",
24
25
  "chalk": "^5.0.0",
25
26
  "@clack/prompts": "^0.8.0",
26
- "bitcoin-backup": "^0.0.8"
27
+ "bitcoin-backup": "^0.0.8",
28
+ "dotenv": "^17.0.0",
29
+ "knex": "^3.1.0",
30
+ "sigma-protocol": "^0.1.9"
27
31
  },
28
32
  "devDependencies": {
29
33
  "@types/bun": "^1.3.9",