mirror of
https://github.com/aljazceru/nutshell.git
synced 2025-12-21 02:54:20 +01:00
MintPayloads -> MintRequest
This commit is contained in:
@@ -106,15 +106,15 @@ class BlindedSignature(BaseModel):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class MintPayloads(BaseModel):
|
class MintRequest(BaseModel):
|
||||||
blinded_messages: List[BlindedMessage] = []
|
blinded_messages: List[BlindedMessage] = []
|
||||||
|
|
||||||
|
|
||||||
class SplitRequest(BaseModel):
|
class SplitRequest(BaseModel):
|
||||||
proofs: List[Proof]
|
proofs: List[Proof]
|
||||||
amount: int
|
amount: int
|
||||||
output_data: MintPayloads = None # backwards compatibility with clients < v0.2.1
|
output_data: MintRequest = None # backwards compatibility with clients < v0.2.1
|
||||||
outputs: MintPayloads = None
|
outputs: MintRequest = None
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.backwards_compatibility_v021()
|
self.backwards_compatibility_v021()
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from typing import Union
|
|||||||
from fastapi import APIRouter
|
from fastapi import APIRouter
|
||||||
from secp256k1 import PublicKey
|
from secp256k1 import PublicKey
|
||||||
|
|
||||||
from cashu.core.base import CheckRequest, MeltRequest, MintPayloads, SplitRequest
|
from cashu.core.base import CheckRequest, MeltRequest, MintRequest, SplitRequest
|
||||||
from cashu.mint import ledger
|
from cashu.mint import ledger
|
||||||
|
|
||||||
router: APIRouter = APIRouter()
|
router: APIRouter = APIRouter()
|
||||||
@@ -24,7 +24,7 @@ async def request_mint(amount: int = 0):
|
|||||||
|
|
||||||
|
|
||||||
@router.post("/mint")
|
@router.post("/mint")
|
||||||
async def mint(payloads: MintPayloads, payment_hash: Union[str, None] = None):
|
async def mint(payloads: MintRequest, payment_hash: Union[str, None] = None):
|
||||||
"""
|
"""
|
||||||
Requests the minting of tokens belonging to a paid payment request.
|
Requests the minting of tokens belonging to a paid payment request.
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ from cashu.core.base import (
|
|||||||
BlindedSignature,
|
BlindedSignature,
|
||||||
CheckRequest,
|
CheckRequest,
|
||||||
MeltRequest,
|
MeltRequest,
|
||||||
MintPayloads,
|
MintRequest,
|
||||||
P2SHScript,
|
P2SHScript,
|
||||||
Proof,
|
Proof,
|
||||||
SplitRequest,
|
SplitRequest,
|
||||||
@@ -96,7 +96,7 @@ class LedgerAPI:
|
|||||||
assert len(amounts) == len(
|
assert len(amounts) == len(
|
||||||
secrets
|
secrets
|
||||||
), f"len(amounts)={len(amounts)} not equal to len(secrets)={len(secrets)}"
|
), f"len(amounts)={len(amounts)} not equal to len(secrets)={len(secrets)}"
|
||||||
payloads: MintPayloads = MintPayloads()
|
payloads: MintRequest = MintRequest()
|
||||||
rs = []
|
rs = []
|
||||||
for secret, amount in zip(secrets, amounts):
|
for secret, amount in zip(secrets, amounts):
|
||||||
B_, r = b_dhke.step1_alice(secret)
|
B_, r = b_dhke.step1_alice(secret)
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ Here we see how `Alice` generates `N` blinded messages `T_i`. The following step
|
|||||||
- `Alice` remembers `r` for the construction of the proof in Step 5.
|
- `Alice` remembers `r` for the construction of the proof in Step 5.
|
||||||
|
|
||||||
### Step 4: Request tokens
|
### Step 4: Request tokens
|
||||||
- `Alice` constructs JSON `MintPayloads = {"blinded_messages" : ["amount" : <amount>, "B_" : <blinded_message>] }` [NOTE: rename "blinded_messages", rename "B_", rename "MintPayloads"]
|
- `Alice` constructs JSON `MintRequest = {"blinded_messages" : ["amount" : <amount>, "B_" : <blinded_message>] }` [NOTE: rename "blinded_messages", rename "B_", rename "MintRequest"]
|
||||||
- `Alice` requests tokens via `POST /mint?payment_hash=<payment_hash>` with body `MintPayloads` [NOTE: rename MintPayloads]
|
- `Alice` requests tokens via `POST /mint?payment_hash=<payment_hash>` with body `MintRequest` [NOTE: rename MintRequest]
|
||||||
- `Alice` receives from `Bob` a list of blinded signatures `List[BlindedSignature]`, one for each token, e.g. `[{"amount" : <amount>, "C_" : <blinded_signature>}, ...]` [NOTE: rename C_]
|
- `Alice` receives from `Bob` a list of blinded signatures `List[BlindedSignature]`, one for each token, e.g. `[{"amount" : <amount>, "C_" : <blinded_signature>}, ...]` [NOTE: rename C_]
|
||||||
- If an error occured, `Alice` receives JSON `{"error" : <error_reason>}}`[TODO: Specify case of error]
|
- If an error occured, `Alice` receives JSON `{"error" : <error_reason>}}`[TODO: Specify case of error]
|
||||||
|
|
||||||
@@ -120,5 +120,5 @@ Here we describe how `Alice` can request from `Bob` to make a Lightning payment
|
|||||||
|
|
||||||
# Todo:
|
# Todo:
|
||||||
- Call subsections 1. and 1.2 etc so they can be referenced
|
- Call subsections 1. and 1.2 etc so they can be referenced
|
||||||
- Define objets like `MintPayloads` and `SplitRequests` once when they appear and reuse them.
|
- Define objets like `MintRequest` and `SplitRequests` once when they appear and reuse them.
|
||||||
- Clarify whether a `TOKEN` is a single Proof or a list of Proofs
|
- Clarify whether a `TOKEN` is a single Proof or a list of Proofs
|
||||||
Reference in New Issue
Block a user