Skip to content

Update API responses to specify BtcAmount unit #1858

@t-bast

Description

@t-bast

When we return a bitcoin amount, our JSON responses currently specify the unit (btc, sat, msat) in the parameter name, but it's a bit ugly and is missing in some places.

Maybe it would be better to include the unit explicitly in the response. I see two different options:

  • Instead of returning a numeric value, return a string including the unit (e.g. "2500 msat", "0.45 btc", "1.5 mbtc"). The drawback is that the string must be parsed to extract the amount (but it's trivial to do).
  • Instead of returning a numeric value, return an object with a unit field (e.g. {"amount": 2500, "unit": "msat"}, {"amount": 0.45, "unit": "btc"}, {"amount": 1.5, "unit": "mbtct"})

This would also be desirable for inputs, we could use strings with a unit suffix (e.g. `fundingFeerate="2500 sat/byte").

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions