diff --git a/cashu/core/base.py b/cashu/core/base.py index d9f1dc0a..5bfa142a 100644 --- a/cashu/core/base.py +++ b/cashu/core/base.py @@ -530,7 +530,13 @@ class CheckFeesResponse_deprecated(BaseModel): class PostRestoreResponse(BaseModel): outputs: List[BlindedMessage] = [] - promises: List[BlindedSignature] = [] + signatures: List[BlindedSignature] = [] + promises: Optional[List[BlindedSignature]] = [] # deprecated since 0.15.1 + + # duplicate value of "signatures" in "promises" for backwards compatibility with old clients < 0.15.1 upon initialization + def __init__(self, **data): + super().__init__(**data) + self.promises = self.signatures # ------- KEYSETS ------- diff --git a/cashu/mint/router.py b/cashu/mint/router.py index d0cac90a..de3a07c7 100644 --- a/cashu/mint/router.py +++ b/cashu/mint/router.py @@ -355,4 +355,4 @@ async def check_state( async def restore(payload: PostMintRequest) -> PostRestoreResponse: assert payload.outputs, Exception("no outputs provided.") outputs, promises = await ledger.restore(payload.outputs) - return PostRestoreResponse(outputs=outputs, promises=promises) + return PostRestoreResponse(outputs=outputs, signatures=promises) diff --git a/cashu/wallet/wallet.py b/cashu/wallet/wallet.py index 9dd07b82..54735068 100644 --- a/cashu/wallet/wallet.py +++ b/cashu/wallet/wallet.py @@ -697,7 +697,14 @@ async def restore_promises( self.raise_on_error_request(resp) response_dict = resp.json() returnObj = PostRestoreResponse.parse_obj(response_dict) - return returnObj.outputs, returnObj.promises + + # BEGIN backwards compatibility < 0.15.1 + # if the mint returns promises, duplicate into signatures + if returnObj.promises: + returnObj.signatures = returnObj.promises + # END backwards compatibility < 0.15.1 + + return returnObj.outputs, returnObj.signatures class Wallet(LedgerAPI, WalletP2PK, WalletHTLC, WalletSecrets):