feat(wallet): replace cocod with coco-core#40
Conversation
30348ef to
2f58137
Compare
sh1ftred
left a comment
There was a problem hiding this comment.
Thanks for the PR. Please look into the comments :)
| .option("-y, --yes", "Skip confirmation prompt", false) | ||
| .option("--xcashu", "Refund xcashu tokens only (uses refundXcashuTokens)", false) | ||
| .action(async (options: { mintUrl?: string; yes: boolean; xcashu: boolean }) => { | ||
| await ensureDaemonRunning(); |
There was a problem hiding this comment.
these changes are just cosmetic. not needed. your formatting is different from mine haha.
| }, | ||
|
|
||
| async getStatus(): Promise<CocodState> { | ||
| return "UNLOCKED"; |
There was a problem hiding this comment.
Is this correct? It literally just says "UNLOCKED" for status?
| }, | ||
|
|
||
| async unlock(_passphrase: string): Promise<string> { | ||
| return "already unlocked"; |
There was a problem hiding this comment.
Also this function? Aren't there any coco-core statuses we can return?
|
hey @sh1ftred -the formatting issue was prettier auto-formatting on save, reverted the unnccessary changes -earlier i forgot to document that getstatus() and unlock(), coco-core has no lock/unlock concept at all. checked the full type definitions, there is no LOCKED/UNINITIALIZED state in coco-core. the wallet is always ready once initializeCoco() completes, so returning UNLOCKED is intentional |
|
In
Could we at minimum do a lightweight health check here (e.g. a DB ping or balance query) and return async getStatus(): Promise<CocodState> {
try {
await coco.wallet.balances.total();
return "UNLOCKED";
} catch {
return "ERROR";
}
} |
|
My agent wrote that haha. I think you didn't understand why getStatus exists in the first place. |
…istMints, improve receiveBolt11 type safety
255024d to
450e6c2
Compare
Previously routstrd relied on cocod - a separate Cashu wallet daemon for all wallet operations.
Before
routstrd spawns cocod process, talks to it over
~/.cocod/cocod.sockcocod manages the wallet and reads/writes to
~/.cocod/coco.dbroutstrd -> cocod (separate process, Unix socket) -> ~/.cocod/coco.db
After
routstrd uses coco-core library directly in the same process
reads mnemonic from
~/.cocod/config.json, same db at~/.cocod/coco.dbno separate process, no socket communication
routstrd -> coco-core (same process) -> ~/.cocod/coco.db
Same wallet data, no separate process needed.
Changes
src/daemon/wallet/coco-client.tswhich implements the existingCocodClientinterface using@cashu/coco-coreand@cashu/coco-sqlite-bundaemon/index.tsto usecreateCocoClient()instead ofcreateCocodClient()onboardno longer installs@routstr/cocodor runscocod init,generates the mnemonic directly using
@scure/bip39and saves itto
~/.cocod/config.jsonin the same formatstartcommand no longer checks if cocod is installedNew dependencies
@cashu/coco-core@cashu/coco-sqlite-bun@scure/bip39Tested
onboard flow, balance reads, and ai requests all working