Fix getPublicKey: Java returns hex not npub despite field name
NostrSigner.npubToHex() is called before putting result in "npub" field, so the value is already a 64-char hex pubkey. Skip nip19.decode() and use it directly. This was causing the "data must be at least 8 chars" error. Co-authored-by: shakespeare.diy <assistant@shakespeare.diy>
This commit is contained in:
parent
9eda3d5c86
commit
da1d208579
1 changed files with 7 additions and 0 deletions
|
|
@ -44,6 +44,13 @@ export async function getAmberPublicKeyViaPlugin(): Promise<string> {
|
|||
|
||||
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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue