How to derive public key of wallet address?

+2 votes

How can I get the public key for a wallet address? The purpose is I want to encrypt something using the recipient's public key which he can presumably decrypt since he has his private key.

I can see that getaddresses api call with verbose=true shows the pubkey for each address, but this is only for addresses stored in the current node's wallet. What if the address is from another node?

asked Jun 14, 2018 by anonymous

1 Answer

0 votes

A blockchain address is calculated as a hash of the public key, and there's no way to reverse this mapping. So your best bet would be to use a stream in which address holders can publish their public key, and then use liststreampublisheritems to retrieve it. (Actually as soon as someone has signed a transaction, their public key is revealed to the blockchain as part of that signature, although this may be a little less convenient to extract.)

answered Jun 16, 2018 by MultiChain