Skip to content

Foreign-mint swap path returns 500 instead of handling melt fee shortfall #408

@sh1ftred

Description

@sh1ftred

Bug Description

When attempting to topup using a foreign-mint token (e.g., Mountainlake), the app attempts to melt the token into the primary mint. If the melt quote requires more sats than the token amount due to fees, the operation fails with a 500 Internal Server Error instead of returning a proper user-facing error.

Root Cause

The fee-handling bug in the foreign-mint swap path: the app tries to melt a token but the melt quote requires more sats than provided (including fees), causing an unhandled exception that surfaces as 500.

Reproduction

Case 1: 404 sat token

  • Request ID: ef2c0cc1-0484-4165-a3d7-4298348a9b60
  • Log location: logs/app_2026-03-14.log:53634
  • Token: 404 sat from https://mint.mountainlake.io
  • Error: Provided: 404, needed: 412 (Code: 11000)
  • Result: 500 Internal Server Error

Case 2: 4200 sat token

  • Request ID: c8bb32e1-0486-4b5b-b5cd-621b57735274
  • Log location: logs/app_2026-03-14.log:55015
  • Token: 4200 sat from https://mint.mountainlake.io
  • Error: Provided: 4200, needed: 4284 (Code: 11000)
  • Result: 500 Internal Server Error

Expected Behavior

The app should detect the insufficient melt inputs and return a user-friendly error message explaining that the token value is insufficient to cover melt fees, rather than returning a 500 Internal Server Error.

Additional Notes

  • Both tokens are now SPENT at the mint (checked just now)
  • The 404 sat request failed because the melt needed 412 sats
  • The 4200 sat request failed because the melt needed 4284 sats
  • This confirms the bug is reproducible and not token-specific

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions