Merge pull request #524 from lnbits/docs_api_add_unit_to_invoice
Fix fiat amount entry in invoice creation
This commit is contained in:
commit
88df4266b7
3 changed files with 16 additions and 13 deletions
|
|
@ -61,7 +61,7 @@
|
||||||
<code
|
<code
|
||||||
>curl -X POST {{ request.base_url }}api/v1/payments -d '{"out": false,
|
>curl -X POST {{ request.base_url }}api/v1/payments -d '{"out": false,
|
||||||
"amount": <int>, "memo": <string>, "webhook":
|
"amount": <int>, "memo": <string>, "webhook":
|
||||||
<url:string>}' -H "X-Api-Key: <i>{{ wallet.inkey }}</i>" -H
|
<url:string>, "unit": <string>}' -H "X-Api-Key: <i>{{ wallet.inkey }}</i>" -H
|
||||||
"Content-type: application/json"</code
|
"Content-type: application/json"</code
|
||||||
>
|
>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
|
|
|
||||||
|
|
@ -417,9 +417,11 @@
|
||||||
filled
|
filled
|
||||||
dense
|
dense
|
||||||
v-model.number="receive.data.amount"
|
v-model.number="receive.data.amount"
|
||||||
type="number"
|
:label="'Amount (' + receive.unit + ') *'"
|
||||||
label="Amount ({{LNBITS_DENOMINATION}}) *"
|
:mask="receive.unit != 'sat' ? '#.##' : '#'"
|
||||||
:step="receive.unit != 'sat' ? '0.001' : '1'"
|
fill-mask="0"
|
||||||
|
reverse-fill-mask
|
||||||
|
:step="receive.unit != 'sat' ? '0.01' : '1'"
|
||||||
:min="receive.minMax[0]"
|
:min="receive.minMax[0]"
|
||||||
:max="receive.minMax[1]"
|
:max="receive.minMax[1]"
|
||||||
:readonly="receive.lnurl && receive.lnurl.fixed"
|
:readonly="receive.lnurl && receive.lnurl.fixed"
|
||||||
|
|
@ -437,7 +439,7 @@
|
||||||
<q-btn
|
<q-btn
|
||||||
unelevated
|
unelevated
|
||||||
color="primary"
|
color="primary"
|
||||||
:disable="receive.data.memo == null || receive.data.amount == null || receive.data.amount <= 0"
|
:disable="receive.data.amount == null || receive.data.amount <= 0"
|
||||||
type="submit"
|
type="submit"
|
||||||
>
|
>
|
||||||
<span v-if="receive.lnurl">
|
<span v-if="receive.lnurl">
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ from lnbits.utils.exchange_rates import (
|
||||||
fiat_amount_as_satoshis,
|
fiat_amount_as_satoshis,
|
||||||
satoshis_amount_as_fiat,
|
satoshis_amount_as_fiat,
|
||||||
)
|
)
|
||||||
|
from lnbits.settings import LNBITS_SITE_TITLE
|
||||||
|
|
||||||
from .. import core_app, db
|
from .. import core_app, db
|
||||||
from ..crud import (
|
from ..crud import (
|
||||||
|
|
@ -123,7 +124,7 @@ async def api_payments(wallet: WalletTypeInfo = Depends(get_key_type)):
|
||||||
|
|
||||||
class CreateInvoiceData(BaseModel):
|
class CreateInvoiceData(BaseModel):
|
||||||
out: Optional[bool] = True
|
out: Optional[bool] = True
|
||||||
amount: int = Query(None, ge=1)
|
amount: float = Query(None, ge=0)
|
||||||
memo: str = None
|
memo: str = None
|
||||||
unit: Optional[str] = "sat"
|
unit: Optional[str] = "sat"
|
||||||
description_hash: Optional[str] = None
|
description_hash: Optional[str] = None
|
||||||
|
|
@ -140,9 +141,9 @@ async def api_payments_create_invoice(data: CreateInvoiceData, wallet: Wallet):
|
||||||
memo = ""
|
memo = ""
|
||||||
else:
|
else:
|
||||||
description_hash = b""
|
description_hash = b""
|
||||||
memo = data.memo
|
memo = data.memo or LNBITS_SITE_TITLE
|
||||||
if data.unit == "sat":
|
if data.unit == "sat":
|
||||||
amount = data.amount
|
amount = int(data.amount)
|
||||||
else:
|
else:
|
||||||
price_in_sats = await fiat_amount_as_satoshis(data.amount, data.unit)
|
price_in_sats = await fiat_amount_as_satoshis(data.amount, data.unit)
|
||||||
amount = price_in_sats
|
amount = price_in_sats
|
||||||
|
|
@ -292,11 +293,11 @@ async def api_payments_pay_lnurl(
|
||||||
detail=f"{domain} returned an invalid invoice. Expected {data.amount} msat, got {invoice.amount_msat}.",
|
detail=f"{domain} returned an invalid invoice. Expected {data.amount} msat, got {invoice.amount_msat}.",
|
||||||
)
|
)
|
||||||
|
|
||||||
# if invoice.description_hash != data.description_hash:
|
# if invoice.description_hash != data.description_hash:
|
||||||
# raise HTTPException(
|
# raise HTTPException(
|
||||||
# status_code=HTTPStatus.BAD_REQUEST,
|
# status_code=HTTPStatus.BAD_REQUEST,
|
||||||
# detail=f"{domain} returned an invalid invoice. Expected description_hash == {data.description_hash}, got {invoice.description_hash}.",
|
# detail=f"{domain} returned an invalid invoice. Expected description_hash == {data.description_hash}, got {invoice.description_hash}.",
|
||||||
# )
|
# )
|
||||||
|
|
||||||
extra = {}
|
extra = {}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue