mirror of
https://github.com/Routstr/routstrd.git
synced 2026-08-09 03:44:38 +00:00
fix: surface cocod "Not enough proofs" as InsufficientBalanceError
When cocod cannot assemble enough proofs to send (e.g. due to denomination fragmentation or stale proof state), it returns "Send failed: Not enough proofs to send". This was propagating as a generic Error, causing the HTTP handler to return 500 instead of the structured 402 insufficient_balance response. Map that cocod error to InsufficientBalanceError in walletAdapter.sendToken so the existing handler path returns the correct 402. Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4
parent
5771a47054
commit
3abc028395
@@ -1,4 +1,5 @@
|
||||
import { getDecodedToken } from "@cashu/cashu-ts";
|
||||
import { InsufficientBalanceError } from "@routstr/sdk";
|
||||
import { logger } from "../../utils/logger";
|
||||
import { createCocodClient, type CocodClient } from "./cocod-client";
|
||||
|
||||
@@ -79,6 +80,10 @@ export async function createWalletAdapter(
|
||||
continue;
|
||||
}
|
||||
|
||||
if (errorMessage.includes("Not enough proofs")) {
|
||||
throw new InsufficientBalanceError(amount, 0);
|
||||
}
|
||||
|
||||
logger.error("Error in walletAdapter sendToken:", error);
|
||||
throw error;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user