diff --git a/src/lib/capacitorAmberSigner.ts b/src/lib/capacitorAmberSigner.ts index 67e69e6..072dacb 100644 --- a/src/lib/capacitorAmberSigner.ts +++ b/src/lib/capacitorAmberSigner.ts @@ -44,6 +44,13 @@ export async function getAmberPublicKeyViaPlugin(): Promise { const { npub } = await plugin.getPublicKey(AMBER_PACKAGE); + // Despite the field being called "npub", the Java bridge calls npubToHex() + // before returning — so this is actually a hex pubkey already. + if (/^[0-9a-f]{64}$/i.test(npub)) { + return npub.toLowerCase(); + } + + // Fallback: if it somehow comes back as a real npub, decode it const decoded = nip19.decode(npub); if (decoded.type !== 'npub') throw new Error('Unexpected key format from Amber'); return decoded.data as string;