FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Buy endpoint should accept chain-specific balances · Issue #201 · JavaScriptSolidServer/JavaScriptSolidServer · GitHub

Repository navigation

Buy endpoint should accept chain-specific balances #201

Closed

Description

Bug

When --pay-chains is enabled, all TXO deposits go to chain-specific balances (e.g. tbtc4). But POST /pay/.buy only draws from the generic sat balance, making it impossible to buy tokens with chain deposits.

Steps to reproduce

  1. Start JSS with --pay --pay-token GSAT --pay-rate 1 --pay-chains tbtc3,tbtc4
  2. Deposit a tbtc4 TXO → balance shows tbtc4: 2083219, sat: 0
  3. POST /pay/.buy { amount: 100 } → Insufficient sat balance

Expected

Should be able to buy tokens using chain-specific balances, e.g.:

POST /pay/.buy { "amount": 100, "currency": "tbtc4" }

Suggested fix

In the .buy handler, accept an optional currency field. If provided and it's an enabled chain, debit from that chain's balance instead of generic sat.

const currency = body.currency || null;
const balance = getBalance(ledger, didUri, currency);
// ... debit(ledger, didUri, satCost, currency)

Activity

  1. added a commit that references this issue on Mar 12, 2026
    aa15fd7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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


      Back | FazBrowse Home | New Git URL