mirror of
https://github.com/Routstr/routstrd.git
synced 2026-07-30 15:46:14 +00:00
docker now has current repo and also added xcashu refunds to the cli
This commit is contained in:
@@ -1,3 +1,11 @@
|
|||||||
FROM oven/bun:1-slim
|
FROM oven/bun:1-slim
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY package.json bun.lock ./
|
||||||
|
RUN bun install --frozen-lockfile
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
RUN bun run build && bun install -g . && bun add -g @earendil-works/pi-coding-agent
|
||||||
|
|
||||||
|
EXPOSE 8008
|
||||||
CMD ["/bin/bash"]
|
CMD ["/bin/bash"]
|
||||||
|
|||||||
+8
-7
@@ -1,14 +1,15 @@
|
|||||||
services:
|
services:
|
||||||
bun:
|
routstrd:
|
||||||
build: .
|
build: .
|
||||||
container_name: routstrd-bun
|
container_name: routstrd
|
||||||
working_dir: /app
|
|
||||||
volumes:
|
|
||||||
- .:/app
|
|
||||||
- bun_home:/root/.bun
|
|
||||||
stdin_open: true
|
stdin_open: true
|
||||||
tty: true
|
tty: true
|
||||||
|
volumes:
|
||||||
|
- routstrd_data:/data
|
||||||
|
ports:
|
||||||
|
- "8008:8008"
|
||||||
|
restart: unless-stopped
|
||||||
command: /bin/bash
|
command: /bin/bash
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
bun_home:
|
routstrd_data:
|
||||||
|
|||||||
+32
-1
@@ -231,7 +231,8 @@ program
|
|||||||
"Mint URL to refund to (defaults to first mint in wallet)",
|
"Mint URL to refund to (defaults to first mint in wallet)",
|
||||||
)
|
)
|
||||||
.option("-y, --yes", "Skip confirmation prompt", false)
|
.option("-y, --yes", "Skip confirmation prompt", false)
|
||||||
.action(async (options: { mintUrl?: string; yes: boolean }) => {
|
.option("--xcashu", "Refund xcashu tokens only (uses refundXcashuTokens)", false)
|
||||||
|
.action(async (options: { mintUrl?: string; yes: boolean; xcashu: boolean }) => {
|
||||||
await ensureDaemonRunning();
|
await ensureDaemonRunning();
|
||||||
|
|
||||||
let mintUrl = options.mintUrl;
|
let mintUrl = options.mintUrl;
|
||||||
@@ -257,6 +258,36 @@ program
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (options.xcashu) {
|
||||||
|
// xcashu path: only refund xcashu tokens
|
||||||
|
const result = await callDaemon("/refund/xcashu", {
|
||||||
|
method: "POST",
|
||||||
|
body: { mintUrl },
|
||||||
|
});
|
||||||
|
|
||||||
|
if (result.error) {
|
||||||
|
console.log(result.error);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const output = result.output as
|
||||||
|
| {
|
||||||
|
message: string;
|
||||||
|
results: Array<{ baseUrl: string; token: string; success: boolean; error?: string }>;
|
||||||
|
}
|
||||||
|
| undefined;
|
||||||
|
|
||||||
|
if (output) {
|
||||||
|
console.log(output.message);
|
||||||
|
console.log("\nResults:");
|
||||||
|
for (const r of output.results) {
|
||||||
|
const status = r.success ? "success" : `failed: ${r.error || "unknown"}`;
|
||||||
|
console.log(` - ${r.baseUrl}: ${status}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const result = await callDaemon("/refund", {
|
const result = await callDaemon("/refund", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: { mintUrl },
|
body: { mintUrl },
|
||||||
|
|||||||
@@ -537,6 +537,34 @@ export function createDaemonRequestHandler(deps: {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (req.method === "POST" && url.pathname === "/refund/xcashu") {
|
||||||
|
try {
|
||||||
|
const body = await readJsonBody(req);
|
||||||
|
const mintUrl = getRequiredStringField(body, "mintUrl");
|
||||||
|
|
||||||
|
const spender = deps.refundClient.getCashuSpender();
|
||||||
|
const results = await spender.refundXcashuTokens(mintUrl);
|
||||||
|
|
||||||
|
sendJson(res, 200, {
|
||||||
|
output: {
|
||||||
|
message: `Refunded xcashu tokens to ${mintUrl}`,
|
||||||
|
results: results.map(
|
||||||
|
(r: { baseUrl: string; token: string; success: boolean; error?: string }) => ({
|
||||||
|
baseUrl: r.baseUrl,
|
||||||
|
token: r.token,
|
||||||
|
success: r.success,
|
||||||
|
error: r.error,
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(`xcashu refund error: ${toErrorMessage(error)}`);
|
||||||
|
respondWithError(res, error);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (req.method === "GET" && url.pathname === "/balance") {
|
if (req.method === "GET" && url.pathname === "/balance") {
|
||||||
try {
|
try {
|
||||||
const balances = await deps.walletAdapter.getBalances();
|
const balances = await deps.walletAdapter.getBalances();
|
||||||
|
|||||||
Reference in New Issue
Block a user