@@ -162,6 +162,21 @@ async def _get_keys_deprecated(self, url: str) -> WalletKeyset:
162162 Exception: If no keys are received from the mint
163163 """
164164 logger .warning (f"Using deprecated API call: { url } /keys" )
165+
166+ # First, get the list of keysets to find the active keyset ID
167+ # This is needed since the /keys endpoint doesn't return the ID
168+ keysets_resp = await self ._get_keysets_deprecated (url )
169+ # Find the first active keyset with unit "sat" (deprecated /keys only returns sat keysets)
170+ active_keyset_id = None
171+ for ks in keysets_resp :
172+ if ks .active and ks .unit == "sat" :
173+ active_keyset_id = ks .id
174+ break
175+
176+ # If no active keyset found, just use the first one
177+ if not active_keyset_id and keysets_resp :
178+ active_keyset_id = keysets_resp [0 ].id
179+
165180 resp = await self .httpx .get (
166181 f"{ url } /keys" ,
167182 )
@@ -172,7 +187,13 @@ async def _get_keys_deprecated(self, url: str) -> WalletKeyset:
172187 int (amt ): PublicKey (bytes .fromhex (val ), raw = True )
173188 for amt , val in keys .items ()
174189 }
175- keyset = WalletKeyset (unit = "sat" , public_keys = keyset_keys , mint_url = url )
190+ # Pass the keyset ID from /keysets response to WalletKeyset
191+ keyset = WalletKeyset (
192+ unit = "sat" ,
193+ public_keys = keyset_keys ,
194+ mint_url = url ,
195+ id = active_keyset_id
196+ )
176197 return keyset
177198
178199 @async_set_httpx_client
0 commit comments