fusion44 / fusion44/blitz_api

RFC: Improve amount handling

Open
#200 3 comments 1 reaction 0 assignees View on GitHub
enhancement investigate REST v0.6.0-beta
Dominant language
Python
Stars
25
Forks
19
PR merge metrics
No merged PRs in 30d

Description

Currently the handling of sats amounts is not clear. Sometimes the value has to be given as msat and sometimes as whole sats.

My proposal would be that each endpoint taking an amount as parameter requires an Amount object instead of an integer:
```python
class Amount(BaseModel):
btc: float = Query(None, description="The amount in BTC.")
sat: int = Query(None, description="The amount in sat.")
msat: int = Query(None, description="The amount in msat.")
```
When giving this parameter, only one of the fields must be set. When the user provides an amount in sat or btc, the endpoint converts it to to the appropriate and passes it to the implementation. The parameter would be passed as `{"msat": 345678000}`

Alternative approach would be to pass it as a string:
```
msat without the appendix would be default
as msat: 345678000
as btc: 0.00345678btc
as sat: 345678sat
as msat: 345678000msat
```
Of course this means that clients must be changed to support this, but currently we only have the WebUI as a user, so it should be fine.

A similar model will be used when the API returns an amount value.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.