Skip to content

Commit

Permalink
update nut-09 endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
callebtc committed Mar 4, 2024
1 parent 7257386 commit 3771a8e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
8 changes: 7 additions & 1 deletion cashu/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 -------
Expand Down
2 changes: 1 addition & 1 deletion cashu/mint/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
9 changes: 8 additions & 1 deletion cashu/wallet/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 3771a8e

Please sign in to comment.