cocod 0.0.2 → 0.0.4

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.
@@ -22,7 +22,7 @@ jobs:
22
22
  git config user.name "github-actions[bot]"
23
23
  git config user.email "github-actions[bot]@users.noreply.github.com"
24
24
  - name: Bump version
25
- run: bun pm version patch
25
+ run: bun pm version patch --no-git-tag-version
26
26
  - name: Pack tarball
27
27
  run: bun pm pack
28
28
  - name: Publish to npm
package/README.md CHANGED
@@ -18,7 +18,17 @@ A Cashu wallet CLI and daemon built with Bun and TypeScript.
18
18
 
19
19
  ## Installation
20
20
 
21
+ ### From npm (recommended)
22
+
21
23
  ```bash
24
+ bun install --global cocod
25
+ ```
26
+
27
+ ### From source
28
+
29
+ ```bash
30
+ git clone <repository-url>
31
+ cd cocod
22
32
  bun install
23
33
  ```
24
34
 
@@ -28,19 +38,19 @@ bun install
28
38
 
29
39
  ```bash
30
40
  # Check daemon status
31
- bun src/index.ts status
41
+ cocod status
32
42
 
33
43
  # Initialize wallet (generates mnemonic automatically)
34
- bun src/index.ts init
44
+ cocod init
35
45
 
36
46
  # Or initialize with your own mnemonic
37
- bun src/index.ts init "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"
47
+ cocod init "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"
38
48
 
39
49
  # Unlock encrypted wallet (if passphrase was set)
40
- bun src/index.ts unlock "your-passphrase"
50
+ cocod unlock "your-passphrase"
41
51
 
42
52
  # Check balance
43
- bun src/index.ts balance
53
+ cocod balance
44
54
  ```
45
55
 
46
56
  ### Available Commands
@@ -53,16 +63,21 @@ bun src/index.ts balance
53
63
  | `init [mnemonic]` | Initialize wallet (generates mnemonic if not provided) |
54
64
  | `unlock <passphrase>` | Unlock encrypted wallet |
55
65
  | `balance` | Get wallet balance across all mints |
56
- | `receive <token>` | Receive a Cashu token |
57
66
  | `history` | View wallet history (supports `--offset`, `--limit`, `--watch`) |
58
67
 
68
+ #### Receive Operations
69
+
70
+ | Command | Description |
71
+ | ------------------------- | ------------------------------------------ |
72
+ | `receive cashu <token>` | Receive a Cashu token |
73
+ | `receive bolt11 <amount>` | Create Lightning invoice to receive tokens |
74
+
59
75
  #### Mint Management
60
76
 
61
- | Command | Description |
62
- | ---------------------- | --------------------------------------- |
63
- | `mint add <url>` | Add a new mint URL |
64
- | `mint list` | List configured mints |
65
- | `mint bolt11 <amount>` | Create Lightning invoice to mint tokens |
77
+ | Command | Description |
78
+ | ---------------- | --------------------- |
79
+ | `mint add <url>` | Add a new mint URL |
80
+ | `mint list` | List configured mints |
66
81
 
67
82
  #### NPC (npub.cash)
68
83
 
@@ -82,19 +97,19 @@ bun src/index.ts balance
82
97
 
83
98
  ```bash
84
99
  # Add a mint
85
- bun src/index.ts mint add https://mint.example.com
100
+ cocod mint add https://mint.example.com
86
101
 
87
102
  # Create a Lightning invoice for 1000 sats
88
- bun src/index.ts mint bolt11 1000
103
+ cocod receive bolt11 1000
89
104
 
90
105
  # Receive a Cashu token
91
- bun src/index.ts receive "cashuAeyJ0b2tlbiI6W3sicHJvb2ZzIjpbeyJ..."
106
+ cocod receive cashu "cashuAeyJ0b2tlbiI6W3sicHJvb2ZzIjpbeyJ..."
92
107
 
93
108
  # View last 10 history entries
94
- bun src/index.ts history --limit 10
109
+ cocod history --limit 10
95
110
 
96
111
  # Watch history in real-time
97
- bun src/index.ts history --watch
112
+ cocod history --watch
98
113
  ```
99
114
 
100
115
  ## Architecture
@@ -133,7 +148,7 @@ Communication happens over a Unix domain socket:
133
148
  ### Commands
134
149
 
135
150
  ```bash
136
- # Run CLI
151
+ # Run CLI from source
137
152
  bun src/index.ts --help
138
153
 
139
154
  # Run with npm-style script
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cocod",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "module": "src/index.ts",
5
5
  "type": "module",
6
6
  "private": false,
package/src/cli.ts CHANGED
@@ -45,17 +45,29 @@ program
45
45
  await handleDaemonCommand("/balance");
46
46
  });
47
47
 
48
- // Receive - POST command with argument
49
- program
50
- .command("receive <token>")
48
+ // Receive - nested subcommands
49
+ const receiveCmd = program.command("receive").description("Receive operations");
50
+
51
+ receiveCmd
52
+ .command("cashu <token>")
51
53
  .description("Receive Cashu token")
52
54
  .action(async (token: string) => {
53
- await handleDaemonCommand("/receive", {
55
+ await handleDaemonCommand("/receive/cashu", {
54
56
  method: "POST",
55
57
  body: { token },
56
58
  });
57
59
  });
58
60
 
61
+ receiveCmd
62
+ .command("bolt11 <amount>")
63
+ .description("Create Lightning invoice to receive tokens")
64
+ .action(async (amount: string) => {
65
+ await handleDaemonCommand("/receive/bolt11", {
66
+ method: "POST",
67
+ body: { amount: parseInt(amount) },
68
+ });
69
+ });
70
+
59
71
  // Ping
60
72
  program
61
73
  .command("ping")
@@ -102,16 +114,6 @@ mintsCmd
102
114
  });
103
115
  });
104
116
 
105
- mintsCmd
106
- .command("bolt11 <amount>")
107
- .description("Create Lightning invoice to mint tokens")
108
- .action(async (amount: string) => {
109
- await handleDaemonCommand("/mints/bolt11", {
110
- method: "POST",
111
- body: { amount: parseInt(amount) },
112
- });
113
- });
114
-
115
117
  // NPC - nested subcommands
116
118
  const npcCmd = program.command("npc").description("NPC operations");
117
119
 
package/src/routes.ts CHANGED
@@ -147,7 +147,7 @@ export function createRouteHandlers(
147
147
  return Response.json({ output: augmentedBalance });
148
148
  }),
149
149
  },
150
- "/receive": {
150
+ "/receive/cashu": {
151
151
  POST: stateManager.requireUnlocked(async (req, state: UnlockedState) => {
152
152
  try {
153
153
  const body = (await req.json()) as { token: string };
@@ -164,6 +164,13 @@ export function createRouteHandlers(
164
164
  }
165
165
  }),
166
166
  },
167
+ "/receive/bolt11": {
168
+ POST: stateManager.requireUnlocked(async (req, state: UnlockedState) => {
169
+ const body = (await req.json()) as { amount: number };
170
+ const quote = await state.manager.quotes.createMintQuote(state.mintUrl, body.amount);
171
+ return Response.json({ output: quote.request });
172
+ }),
173
+ },
167
174
  "/mints/add": {
168
175
  POST: stateManager.requireUnlocked(async (req, state: UnlockedState) => {
169
176
  const body = (await req.json()) as { url: string };
@@ -188,13 +195,6 @@ export function createRouteHandlers(
188
195
  }),
189
196
  },
190
197
 
191
- "/mints/bolt11": {
192
- POST: stateManager.requireUnlocked(async (req, state: UnlockedState) => {
193
- const body = (await req.json()) as { amount: number };
194
- const quote = await state.manager.quotes.createMintQuote(state.mintUrl, body.amount);
195
- return Response.json({ output: quote.request });
196
- }),
197
- },
198
198
  "/history": {
199
199
  GET: stateManager.requireUnlocked(async (req, state: UnlockedState) => {
200
200
  const url = new URL(req.url);