This commit is contained in:
callebtc
2023-01-14 15:29:09 +01:00
parent c34636e2f3
commit af0984ccde
3 changed files with 9 additions and 7 deletions

View File

@@ -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]

View File

@@ -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")

View File

@@ -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