nebulasio / WebExtensionWallet

170 stars 58 forks source link

How do you get the currently unlocked Wallet's public key? #14

Open woniesong92 opened 6 years ago

woniesong92 commented 6 years ago

Also, is there a way to detect whether the user has unlocked a wallet?

yupnano commented 6 years ago

Do you mean that you want to get an notification when an wallet is unlocked, or just to get the wallet address that has been unlocked?

woniesong92 commented 6 years ago

Both would be nice. In Metamask, you can check the accounts array and see if it's empty to know if the user has unlocked their wallet. Using this, people can show the warning sign "Please unlock your wallet in Metamask before using our dapp."

zoowii commented 6 years ago

What I want is user's pubkey who call some contract api, or pubkey of any address. I wrote a dapp, which stored encrypted data in that smart contract. I want to use user's pubkey to encrypt the data, and let user decrypt it by privatekey. Could you add caller's pubkey to smartcontract's Blockchain.transaction object?

zoowii commented 6 years ago

I think if you add this feature, dapp developers can do more things by smart-contract

yupnano commented 6 years ago

Thanks for your advice! I will discuss about this with my colleagues later.

hostgame commented 6 years ago

@zoowii wallet address is your public key #6 You can get it by such js code

window.postMessage({ "target": "contentscript", "data":{}, "method": "getAccount", }, "*");

window.addEventListener('message', function(e) { try{ var user_account = e.data.data.account; console.log(user_account); }catch (e) { } });

zoowii commented 6 years ago

@hostgame nebulas's address is not same with public key, event decode them to integers