diff --git a/cashu/core/base.py b/cashu/core/base.py index 479afc2..a2cc436 100644 --- a/cashu/core/base.py +++ b/cashu/core/base.py @@ -126,11 +126,11 @@ class SplitRequest(BaseModel): self.output_data = None -class CheckPayload(BaseModel): +class CheckRequest(BaseModel): proofs: List[Proof] -class MeltPayload(BaseModel): +class MeltRequest(BaseModel): proofs: List[Proof] amount: int invoice: str diff --git a/cashu/mint/router.py b/cashu/mint/router.py index 5b253ca..e5c1958 100644 --- a/cashu/mint/router.py +++ b/cashu/mint/router.py @@ -3,7 +3,7 @@ from typing import Union from fastapi import APIRouter from secp256k1 import PublicKey -from cashu.core.base import CheckPayload, MeltPayload, MintPayloads, SplitRequest +from cashu.core.base import CheckRequest, MeltRequest, MintPayloads, SplitRequest from cashu.mint import ledger router: APIRouter = APIRouter() @@ -55,7 +55,7 @@ async def mint(payloads: MintPayloads, payment_hash: Union[str, None] = None): @router.post("/melt") -async def melt(payload: MeltPayload): +async def melt(payload: MeltRequest): """ Requests tokens to be destroyed and sent out via Lightning. """ @@ -64,7 +64,7 @@ async def melt(payload: MeltPayload): @router.post("/check") -async def check_spendable(payload: CheckPayload): +async def check_spendable(payload: CheckRequest): return await ledger.check_spendable(payload.proofs) diff --git a/cashu/wallet/wallet.py b/cashu/wallet/wallet.py index ae06a20..d95574c 100644 --- a/cashu/wallet/wallet.py +++ b/cashu/wallet/wallet.py @@ -11,8 +11,8 @@ import cashu.core.b_dhke as b_dhke from cashu.core.base import ( BlindedMessage, BlindedSignature, - CheckPayload, - MeltPayload, + CheckRequest, + MeltRequest, MintPayloads, P2SHScript, Proof, @@ -202,7 +202,7 @@ class LedgerAPI: return fst_proofs, snd_proofs async def check_spendable(self, proofs: List[Proof]): - payload = CheckPayload(proofs=proofs) + payload = CheckRequest(proofs=proofs) return_dict = requests.post( self.url + "/check", json=payload.dict(), @@ -211,7 +211,7 @@ class LedgerAPI: return return_dict async def pay_lightning(self, proofs: List[Proof], amount: int, invoice: str): - payload = MeltPayload(proofs=proofs, amount=amount, invoice=invoice) + payload = MeltRequest(proofs=proofs, amount=amount, invoice=invoice) return_dict = requests.post( self.url + "/melt", json=payload.dict(), diff --git a/docs/specs/cashu_client_spec.md b/docs/specs/cashu_client_spec.md index dbb4113..071df92 100644 --- a/docs/specs/cashu_client_spec.md +++ b/docs/specs/cashu_client_spec.md @@ -97,7 +97,7 @@ Note that the following steps can also be performed by `Alice` herself if she wa ## 5 - Burn sent tokens Here we describe how `Alice` checks with the mint whether the tokens she sent `Carol` have been redeemed so she can safely delete them from her database. This step is optional but highly recommended so `Alice` can properly account for the tokens and adjust her balance accordingly. - `Alice` loads all `` with `pending=True` from her database and might group them by the `send_id`. -- `Alice` constructs a JSON of the form `{"proofs" : [{"amount" : , "secret" : s, "C" : Z}, ...]}` from these (grouped) tokens. [TODO: this object is called CheckPayload] +- `Alice` constructs a JSON of the form `{"proofs" : [{"amount" : , "secret" : s, "C" : Z}, ...]}` from these (grouped) tokens. [TODO: this object is called CheckRequest] - `Alice` sends them to the mint `Bob` via the endpoint `POST /check` with the JSON as the body of the request. - `Alice` receives a JSON of the form `{"1" : , "2" : ...}` where `"1"` is the index of the proof she sent to the mint before and `` is a boolean that is `True` if the token has not been claimed yet by `Carol` and `False` if it has already been claimed. - If `` is `False`, `Alice` removes the proof [NOTE: consistent name?] from her list of spendable proofs. @@ -108,7 +108,7 @@ Here we describe how `Alice` can request from `Bob` to make a Lightning payment - `Alice` wants to pay the bolt11 invoice ``. - `Alice` calculates the fees for the Lightning payments upfront with the function `max(, * *)` with `` currently being `4` Satoshis and `` being `0.01` (or 1% of ``). `Alice` then adds this fee to `` and rounds it up to the next higher integer which results in ``. - `Alice` now performs the same set of instructions as in Step 3.1 and 3.2 and splits her spendable tokens into a set `` that she keeps and and a set `` that she can send for making the Lightning payment. -- `Alice` constructs the JSON `MeltPayload` of the form `{"proofs" : , "amount" : , "invoice" : }` [NOTE: Maybe use notation List[Proof] everywhere. Used MeltPayload here, maybe define each payload at the beginning of each section.] +- `Alice` constructs the JSON `MeltRequest` of the form `{"proofs" : , "amount" : , "invoice" : }` [NOTE: Maybe use notation List[Proof] everywhere. Used MeltRequest here, maybe define each payload at the beginning of each section.] - `Alice` requests a payment from `Bob` via the endpoint `POST /melt` with the JSON as the body of the request. - `Alice` receives a JSON of the form `{"paid" : }` with `` being `True` if the payment was successful and `False` otherwise. - If ` == True`, `Alice` removes `` from her database of spendable tokens [NOTE: called it tokens again]