diff --git a/cashu/core/base.py b/cashu/core/base.py index 2c21a83..d03ab98 100644 --- a/cashu/core/base.py +++ b/cashu/core/base.py @@ -41,11 +41,6 @@ class Proof(BaseModel): self.__setattr__(key, val) -class Proofs(BaseModel): - # NOTE: not used in Pydantic validation - __root__: List[Proof] - - # ------- LIGHTNING INVOICE ------- @@ -276,6 +271,11 @@ class MintKeysets: # ------- TOKEN ------- +class TokenV1(BaseModel): + # NOTE: not used in Pydantic validation + __root__: List[Proof] + + class TokenMintV2(BaseModel): url: str ks: List[str] diff --git a/cashu/wallet/cli.py b/cashu/wallet/cli.py index dc20331..18dbbf5 100644 --- a/cashu/wallet/cli.py +++ b/cashu/wallet/cli.py @@ -388,7 +388,7 @@ async def receive(ctx, token: str, lock: str): # deserialize token dtoken = json.loads(base64.urlsafe_b64decode(token)) - # backwards compatibility < 0.8: V2 tokens with "tokens" field instead of "proofs" field + # backwards compatibility wallet to wallet < 0.8: V2 tokens renamed "tokens" field to "proofs" if "tokens" in dtoken: dtoken["proofs"] = dtoken.pop("tokens") diff --git a/cashu/wallet/wallet.py b/cashu/wallet/wallet.py index 1223a8e..02188c2 100644 --- a/cashu/wallet/wallet.py +++ b/cashu/wallet/wallet.py @@ -514,7 +514,7 @@ class Wallet(LedgerAPI): # add mint information to the token, if requested if include_mints: - # hold information about the mint + # dummy object to hold information about the mint mints: Dict[str, TokenMintV2] = dict() # iterate through all proofs and add their keyset to `mints` for proof in proofs: @@ -535,7 +535,9 @@ class Wallet(LedgerAPI): # if a mint has multiple keysets, append to the existing list if keyset.id not in mints[placeholder_mint_id].ks: mints[placeholder_mint_id].ks.append(keyset.id) + if len(mints) > 0: + # add dummy object to token token.mints = mints return token