Is it possible to get the public key
of a user, if we have a transaction
from that User in my wallet ?
-
The public/private key is unique to the wallet. Each wallet can have multiple public/private keys (accounts). Which wallet are you using?– user2277550Commented Jun 12, 2016 at 21:28
1 Answer
There is no such thing as a public key for a user, but there is such a thing as a public key for an address. The transaction that has been paid to you probably contains more than one address owned by the sender. First, the bitcoin in the transaction likely came from multiple unspent transaction outputs (UTXOs), all of which were owned by the sender and probably have different addresses. Next, the transaction likely had a change output, which would be yet another address owned by the sender.
Any of the UTXO's used as inputs to the transaction would have had the public keys of the addresses revealed in the scriptSig that was used for the input to sign the bitcoin over to you. You can find these scripts by using a block explorer. They will each contain a public key and a signature.
If the change output has already been spent by the user, you can find that transaction and look up the public key in the scriptSig there as well.
Keep in mind that none of this information is specific to your wallet, as it is all public information on the blockchain. The only information you have that I don't have is the specific transaction you are referring to. Given that transaction ID, anyone and everyone can look up this information.