vulpemventures / marina

Liquid Wallet browser extension
MIT License
35 stars 16 forks source link

getNextAddress() does not show publicKey #489

Closed jamesdorfman closed 8 months ago

jamesdorfman commented 1 year ago

I am trying to get a raw pubkey from marina (not an address, but the underlying pubkey itself).

The API reference says that getNextAddress() should return a publicKey:

Screenshot 2023-08-10 at 4 03 36 PM

However, when I run the following code in google chrome v115

await window.marina.enable();
let nextAddr = await window.marina.getNextAddress()
console.log(nextAddr);

this is the result which gets logged to the console:

{
    confidentialAddress: 'XXX',
    derivationPath: 'XXX',
    accountName: 'mainAccountTest',
    networks: Array(1),
    blindingPrivateKey: 'XXX'
}

Is there still a way for me to get a publicKey? Is this a bug?

Thanks!

louisinger commented 1 year ago

Hey @jamesdorfman,

indeed, there is an error in the API reference. I'll fix it, thanks! docs.vulpem.com/marina/api should be up to date.

About adrress' public key

getNextAddress returns an Address since v0.5.x. The interface does not contain the script public key but you can derive it using bip32.

related to https://github.com/vulpemventures/docs.vulpem.com/issues/19

stevenroose commented 1 year ago

Do you mean to say that the API call no longer returns an object but just and Address and that's why all other fields were dropped? I think the fields in that screenshot are actually really useful, no? And AFAIU they come for free because internally you already need to have them to construct the address, so returning them has no downsides to me it seems.. Tbf the hardware wallet APIs I've worked with all return the public key alongside the address when deriving or asking for a new address.

louisinger commented 1 year ago

Do you mean to say that the API call no longer returns an object but just and Address and that's why all other fields were dropped?

No, Address is still an interface with all the fields except the public key (+ some additional fields in case of taproot addresses).

I think the fields in that screenshot are actually really useful, no? And AFAIU they come for free because internally you already need to have them to construct the address, so returning them has no downsides to me it seems.. Tbf the hardware wallet APIs I've worked with all return the public key alongside the address when deriving or asking for a new address.

Yes you're right. Initially we removed the public key because v0.5.x introduces account system and returns masterXPubKey for each one. So the idea was to remove the "duplicates" and let apps to generate raw public key while they need it. However, you're not the first ones saying this so let's discuss how & if we re-add the public key field there: https://github.com/vulpemventures/marina-provider/issues/32