RFC: Improve amount handling
- 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.