mirror of
https://github.com/aljazceru/nutshell.git
synced 2025-12-24 03:54:21 +01:00
legacy test
This commit is contained in:
@@ -40,9 +40,7 @@ class Proof(BaseModel):
|
||||
|
||||
|
||||
class Proofs(BaseModel):
|
||||
"""TODO: Use this model"""
|
||||
|
||||
proofs: List[Proof]
|
||||
__root__: List[Proof]
|
||||
|
||||
|
||||
class Invoice(BaseModel):
|
||||
@@ -79,6 +77,11 @@ class BlindedMessages(BaseModel):
|
||||
blinded_messages: List[BlindedMessage] = []
|
||||
|
||||
|
||||
class PostMintResponseLegacy(BaseModel):
|
||||
# NOTE: Backwards compability for < 0.7.1 where we used a simple list and not a key-value dictionary
|
||||
__root__: List[BlindedSignature] = []
|
||||
|
||||
|
||||
class PostMintResponse(BaseModel):
|
||||
promises: List[BlindedSignature] = []
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ from cashu.core.base import (
|
||||
MeltRequest,
|
||||
P2SHScript,
|
||||
PostMintResponse,
|
||||
PostMintResponseLegacy,
|
||||
Proof,
|
||||
SplitRequest,
|
||||
TokenV2,
|
||||
@@ -260,8 +261,12 @@ class LedgerAPI:
|
||||
resp.raise_for_status()
|
||||
reponse_dict = resp.json()
|
||||
self.raise_on_error(reponse_dict)
|
||||
promises = PostMintResponse.parse_obj(reponse_dict)
|
||||
return self._construct_proofs(promises.promises, secrets, rs)
|
||||
try:
|
||||
promises = PostMintResponseLegacy.parse_obj(reponse_dict)
|
||||
return self._construct_proofs(promises, secrets, rs)
|
||||
except:
|
||||
promises = PostMintResponse.parse_obj(reponse_dict)
|
||||
return self._construct_proofs(promises.promises, secrets, rs)
|
||||
|
||||
async def split(self, proofs, amount, scnd_secret: Optional[str] = None):
|
||||
"""Consume proofs and create new promises based on amount split.
|
||||
|
||||
Reference in New Issue
Block a user