Skip to content

Commit

Permalink
Fix wallet backwards paid flag melt (#659)
Browse files Browse the repository at this point in the history
* backwards compat for melt quote without state

* backwards compat for quote without state
  • Loading branch information
callebtc authored Nov 2, 2024
1 parent e9d4689 commit 0b2a020
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cashu/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,13 @@ def from_row(cls, row: Row):
def from_resp_wallet(
cls, melt_quote_resp, mint: str, amount: int, unit: str, request: str
):
# BEGIN: BACKWARDS COMPATIBILITY < 0.16.0: "paid" field to "state"
if melt_quote_resp.state is None:
if melt_quote_resp.paid is True:
melt_quote_resp.state = MeltQuoteState.paid
elif melt_quote_resp.paid is False:
melt_quote_resp.state = MeltQuoteState.unpaid
# END: BACKWARDS COMPATIBILITY < 0.16.0
return cls(
quote=melt_quote_resp.quote,
method="bolt11",
Expand Down Expand Up @@ -433,6 +440,13 @@ def from_row(cls, row: Row):

@classmethod
def from_resp_wallet(cls, mint_quote_resp, mint: str, amount: int, unit: str):
# BEGIN: BACKWARDS COMPATIBILITY < 0.16.0: "paid" field to "state"
if mint_quote_resp.state is None:
if mint_quote_resp.paid is True:
mint_quote_resp.state = MintQuoteState.paid
elif mint_quote_resp.paid is False:
mint_quote_resp.state = MintQuoteState.unpaid
# END: BACKWARDS COMPATIBILITY < 0.16.0
return cls(
quote=mint_quote_resp.quote,
method="bolt11",
Expand Down

0 comments on commit 0b2a020

Please sign in to comment.