mirror of
https://github.com/Routstr/routstrd.git
synced 2026-07-30 15:46:14 +00:00
Merge branch 'main' of github.com-red:Routstr/routstrd
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
node_modules/
|
||||
dist/
|
||||
.git/
|
||||
.worktrees/
|
||||
.pi/
|
||||
logs/
|
||||
tmp/
|
||||
temp/
|
||||
*.log
|
||||
.env
|
||||
.env.*
|
||||
.DS_Store
|
||||
@@ -0,0 +1,3 @@
|
||||
FROM oven/bun:1-slim
|
||||
WORKDIR /app
|
||||
CMD ["/bin/bash"]
|
||||
@@ -1,11 +1,10 @@
|
||||
{
|
||||
"lockfileVersion": 1,
|
||||
"lockfileVersion": 0,
|
||||
"workspaces": {
|
||||
"": {
|
||||
"name": "routstrd",
|
||||
"dependencies": {
|
||||
"@cashu/cashu-ts": "^3.1.1",
|
||||
"@routstr/sdk": "^0.3.6",
|
||||
"@cashu/cashu-ts": "^4.3.0",
|
||||
"@routstr/sdk": "^0.3.8",
|
||||
"applesauce-core": "^5.1.0",
|
||||
"applesauce-relay": "^5.1.0",
|
||||
"commander": "^14.0.2",
|
||||
@@ -24,7 +23,7 @@
|
||||
},
|
||||
},
|
||||
"packages": {
|
||||
"@cashu/cashu-ts": ["@cashu/cashu-ts@3.7.0", "", { "dependencies": { "@noble/curves": "^2.2.0", "@noble/hashes": "^2.2.0", "@scure/base": "^2.2.0", "@scure/bip32": "^2.2.0" } }, "sha512-Jy4Hek+Wouh94xS4InmTJRLpBPXA6fddVOAHR5lfNyTsCk9r3desY0vnwUGvOZBZWsSKZXedqdD/YpjWb3zngQ=="],
|
||||
"@cashu/cashu-ts": ["@cashu/cashu-ts@4.3.0", "", { "dependencies": { "@noble/curves": "^2.2.0", "@noble/hashes": "^2.2.0", "@scure/base": "^2.2.0", "@scure/bip32": "^2.2.0" } }, "sha512-YUkqKDN/8edtZi0f6O4wymRkVvr24A/ysxZYhaInr/1PFrBlrBbxi1dmdkf9MK14mwBMkWtAQutJm/vCfMePGQ=="],
|
||||
|
||||
"@noble/ciphers": ["@noble/ciphers@2.1.1", "", {}, "sha512-bysYuiVfhxNJuldNXlFEitTVdNnYUc+XNJZd7Qm2a5j1vZHgY+fazadNFWFaMK/2vye0JVlxV3gHmC0WDfAOQw=="],
|
||||
|
||||
@@ -32,7 +31,7 @@
|
||||
|
||||
"@noble/hashes": ["@noble/hashes@2.2.0", "", {}, "sha512-IYqDGiTXab6FniAgnSdZwgWbomxpy9FtYvLKs7wCUs2a8RkITG+DFGO1DM9cr+E3/RgADRpFjrKVaJ1z6sjtEg=="],
|
||||
|
||||
"@routstr/sdk": ["@routstr/sdk@0.3.6", "", { "dependencies": { "@cashu/cashu-ts": "^3.1.1", "applesauce-core": "^5.1.0", "applesauce-relay": "^5.1.0", "rxjs": "^7.8.1", "zustand": "^5.0.5" }, "optionalDependencies": { "better-sqlite3": "^11.7.2" }, "peerDependencies": { "typescript": ">=5.0.0" } }, "sha512-QYHhudkQQUX59NA51GBZHJOcVPZVbTDG3F1tX1E+WzXVNEbARXzI1a1DH3D19dsHfWntZjzikNz3ZQGeWQWb/A=="],
|
||||
"@routstr/sdk": ["@routstr/sdk@0.3.8", "", { "dependencies": { "@cashu/cashu-ts": "^3.1.1", "applesauce-core": "^5.1.0", "applesauce-relay": "^5.1.0", "rxjs": "^7.8.1", "zustand": "^5.0.5" }, "optionalDependencies": { "better-sqlite3": "^11.7.2" }, "peerDependencies": { "typescript": ">=5.0.0" } }, "sha512-5wQh+SPfBQBgWZq4VJSpOlpp3EWKDPBQ3lFAwQpvTdJ9Ds/IpkAvPbIAtS2ZLqTY7oN95GtlZps5TMOtyCDwGA=="],
|
||||
|
||||
"@scure/base": ["@scure/base@2.2.0", "", {}, "sha512-b8XEupJibegiXV+tDUseI8oLQc8ei3d/4Jkb2RpbHh3MfE054ov3uIz2dhFkB3FI8iwYkEh0gGCApkrYggkPNg=="],
|
||||
|
||||
@@ -42,7 +41,7 @@
|
||||
|
||||
"@types/bun": ["@types/bun@1.3.14", "", { "dependencies": { "bun-types": "1.3.14" } }, "sha512-h1hFqFVcvAvD9j9K7ZW7vd82aSA+rTdznZa+5bwvCwqSB1jmmfLcbIWhOLx1/+boy/xmjgCs/OMUL8hRJSmnPw=="],
|
||||
|
||||
"@types/node": ["@types/node@25.7.0", "", { "dependencies": { "undici-types": "~7.21.0" } }, "sha512-z+pdZyxE+RTQE9AcboAZCb4otwcrvgHD+GlBpPgn0emDVt0ohrTMhAwlr2Wd9nZ+nihhYFxO2pThz3C5qSu2Eg=="],
|
||||
"@types/node": ["@types/node@25.8.0", "", { "dependencies": { "undici-types": ">=7.24.0 <7.24.7" } }, "sha512-TCFSk8IZh+iLX1xtksoBVtdmgL+1IX0fC9BeU4QqFSuNdN/K+HUlhqOzEmSYYpZUVsLYcPqc9KX+60iDuninSQ=="],
|
||||
|
||||
"@types/qrcode": ["@types/qrcode@1.5.6", "", { "dependencies": { "@types/node": "*" } }, "sha512-te7NQcV2BOvdj2b1hCAHzAoMNuj65kNBMz0KBaxM6c3VGBOhU0dURQKOtH8CFNI/dsKkwlv32p26qYQTWoB5bw=="],
|
||||
|
||||
@@ -194,7 +193,7 @@
|
||||
|
||||
"typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
|
||||
|
||||
"undici-types": ["undici-types@7.21.0", "", {}, "sha512-w9IMgQrz4O0YN1LtB7K5P63vhlIOvC7opSmouCJ+ZywlPAlO9gIkJ+otk6LvGpAs2wg4econaCz3TvQ9xPoyuQ=="],
|
||||
"undici-types": ["undici-types@7.24.6", "", {}, "sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg=="],
|
||||
|
||||
"util-deprecate": ["util-deprecate@1.0.2", "", {}, "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw=="],
|
||||
|
||||
@@ -212,6 +211,8 @@
|
||||
|
||||
"zustand": ["zustand@5.0.13", "", { "peerDependencies": { "@types/react": ">=18.0.0", "immer": ">=9.0.6", "react": ">=18.0.0", "use-sync-external-store": ">=1.2.0" }, "optionalPeers": ["@types/react", "immer", "react", "use-sync-external-store"] }, "sha512-efI2tVaVQPqtOh114loML/Z80Y4NP3yc+Ff0fYiZJPauNeWZeIp/bRFD7I9bfmCOYBh/PHxlglQ9+wvlwnPikQ=="],
|
||||
|
||||
"@routstr/sdk/@cashu/cashu-ts": ["@cashu/cashu-ts@3.7.0", "", { "dependencies": { "@noble/curves": "^2.2.0", "@noble/hashes": "^2.2.0", "@scure/base": "^2.2.0", "@scure/bip32": "^2.2.0" } }, "sha512-Jy4Hek+Wouh94xS4InmTJRLpBPXA6fddVOAHR5lfNyTsCk9r3desY0vnwUGvOZBZWsSKZXedqdD/YpjWb3zngQ=="],
|
||||
|
||||
"@scure/bip39/@noble/hashes": ["@noble/hashes@2.0.1", "", {}, "sha512-XlOlEbQcE9fmuXxrVTXCTlG2nlRXa9Rj3rr5Ue/+tX+nmkgbX720YHh0VR3hBF9xDvwnb8D2shVGOwNx+ulArw=="],
|
||||
|
||||
"@scure/bip39/@scure/base": ["@scure/base@2.0.0", "", {}, "sha512-3E1kpuZginKkek01ovG8krQ0Z44E3DHPjc5S2rjJw9lZn3KSQOs8S7wqikF/AH7iRanHypj85uGyxk0XAyC37w=="],
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
services:
|
||||
bun:
|
||||
build: .
|
||||
container_name: routstrd-bun
|
||||
working_dir: /app
|
||||
volumes:
|
||||
- .:/app
|
||||
- bun_home:/root/.bun
|
||||
stdin_open: true
|
||||
tty: true
|
||||
command: /bin/bash
|
||||
|
||||
volumes:
|
||||
bun_home:
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "routstrd",
|
||||
"version": "0.2.21",
|
||||
"version": "0.2.22",
|
||||
"module": "src/index.ts",
|
||||
"type": "module",
|
||||
"private": false,
|
||||
@@ -24,7 +24,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@cashu/cashu-ts": "^4.3.0",
|
||||
"@routstr/sdk": "^0.3.6",
|
||||
"@routstr/sdk": "^0.3.8",
|
||||
"applesauce-core": "^5.1.0",
|
||||
"applesauce-relay": "^5.1.0",
|
||||
"commander": "^14.0.2",
|
||||
|
||||
@@ -272,7 +272,7 @@ function makeSdkLogger(prefix?: string): SdkLogger {
|
||||
const fmt = (...args: unknown[]) => (tag ? [tag, ...args] : args);
|
||||
return {
|
||||
log: (...args: unknown[]) => logger.log(...fmt(...args)),
|
||||
warn: (...args: unknown[]) => logger.log(...fmt(...args)),
|
||||
warn: (...args: unknown[]) => logger.warn(...fmt(...args)),
|
||||
error: (...args: unknown[]) => logger.error(...fmt(...args)),
|
||||
debug: (...args: unknown[]) => logger.debug(...fmt(...args)),
|
||||
child: (p: string) => makeSdkLogger(prefix ? `${prefix}:${p}` : p),
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ function makeSdkLogger(prefix?: string): SdkLogger {
|
||||
const fmt = (...args: unknown[]) => (tag ? [tag, ...args] : args);
|
||||
return {
|
||||
log: (...args: unknown[]) => logger.log(...fmt(...args)),
|
||||
warn: (...args: unknown[]) => logger.log(...fmt(...args)),
|
||||
warn: (...args: unknown[]) => logger.warn(...fmt(...args)),
|
||||
error: (...args: unknown[]) => logger.error(...fmt(...args)),
|
||||
debug: (...args: unknown[]) => logger.debug(...fmt(...args)),
|
||||
child: (p: string) => makeSdkLogger(prefix ? `${prefix}:${p}` : p),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getDecodedToken } from "@cashu/cashu-ts";
|
||||
import { getDecodedToken, Amount } from "@cashu/cashu-ts";
|
||||
import { InsufficientBalanceError } from "@routstr/sdk";
|
||||
import { logger } from "../../utils/logger";
|
||||
import { createCocodClient, type CocodClient } from "./cocod-client";
|
||||
@@ -7,9 +7,9 @@ export function decodeCashuTokenAmount(token: string): {
|
||||
amount: number;
|
||||
unit: "sat" | "msat";
|
||||
} {
|
||||
const decoded = getDecodedToken(token);
|
||||
const decoded = getDecodedToken(token, []);
|
||||
const amount =
|
||||
decoded?.proofs?.reduce((sum, proof) => sum + proof.amount, 0) ?? 0;
|
||||
decoded?.proofs?.reduce((sum, proof) => sum + proof.amount.toNumber(), 0) ?? 0;
|
||||
const unit = decoded?.unit === "msat" ? "msat" : "sat";
|
||||
return { amount, unit };
|
||||
}
|
||||
|
||||
+5
-5
@@ -28,7 +28,7 @@ async function startDaemonUnlocked(
|
||||
const startupTimeoutMs = 10 * 60 * 1000;
|
||||
|
||||
if (await isDaemonHealthy(port)) {
|
||||
logger.log(`Routstr daemon already running on http://localhost:${port}/v1`);
|
||||
console.log(`Routstr daemon already running on http://localhost:${port}/v1`);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -43,8 +43,8 @@ async function startDaemonUnlocked(
|
||||
const shellCmd = `bun run "${daemonScript}" ${args.map((a) => `'${a}'`).join(" ")}`;
|
||||
|
||||
const proc = Bun.spawn(["sh", "-c", shellCmd], {
|
||||
stdout: "inherit",
|
||||
stderr: "inherit",
|
||||
stdout: "ignore",
|
||||
stderr: "ignore",
|
||||
stdin: "ignore",
|
||||
detached: true,
|
||||
});
|
||||
@@ -67,7 +67,7 @@ async function startDaemonUnlocked(
|
||||
}
|
||||
|
||||
if (await isDaemonHealthy(port)) {
|
||||
logger.log(`Routstr daemon started (PID: ${proc.pid}).`);
|
||||
console.log(`Routstr daemon started (PID: ${proc.pid}).`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -84,7 +84,7 @@ export async function startDaemon(
|
||||
const startupTimeoutMs = 10 * 60 * 1000;
|
||||
|
||||
if (await isDaemonHealthy(port)) {
|
||||
logger.log(`Routstr daemon already running on http://localhost:${port}/v1`);
|
||||
console.log(`Routstr daemon already running on http://localhost:${port}/v1`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -48,18 +48,18 @@ async function writeLog(level: string, ...args: unknown[]) {
|
||||
|
||||
export const logger = {
|
||||
log: (...args: unknown[]) => {
|
||||
console.log(...args);
|
||||
writeLog("INFO", ...args);
|
||||
},
|
||||
debug: (...args: unknown[]) => {
|
||||
writeLog("DEBUG", ...args);
|
||||
},
|
||||
warn: (...args: unknown[]) => {
|
||||
writeLog("WARN", ...args);
|
||||
},
|
||||
error: (...args: unknown[]) => {
|
||||
console.error(...args);
|
||||
writeLog("ERROR", ...args);
|
||||
},
|
||||
info: (...args: unknown[]) => {
|
||||
console.log(...args);
|
||||
writeLog("INFO", ...args);
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user