As per the answer to this question, we cannot retrieve the public key of a user.
1)How does my wallet get the value (public key/public key hash) to which I need to make the payment?
2)What is the harm in exposing an address's public key?
Bitcoin Stack Exchange is a question and answer site for Bitcoin crypto-currency enthusiasts. It only takes a minute to sign up.
Sign up to join this communityAs per the answer to this question, we cannot retrieve the public key of a user.
1)How does my wallet get the value (public key/public key hash) to which I need to make the payment?
2)What is the harm in exposing an address's public key?
I read through both questions, so please correct me if im answering the wrong question.
The user who you want to pay must send you their public key (or QR to scan) in order to send money to them. This is, of course, unless their public key (wallet) is listed on a public website. Please see https://en.bitcoin.it/wiki/Help:Introduction#Sending_payments
In general*, there is no harm in exposing a public key. This question on crypto stackexchange goes into more detail Is exposing a public key bad?
That person has to tell you what their public key (or its hash) is. A Bitcoin address is the most convenient way to encode the hash of a public key, so typically the person will tell you an address and ask you to make a payment to that address. You can enter that address into your wallet and make the payment.
Related: How can a sender know receiver's public key when creating "Pay To Public Key" tx?
If you are using bitcoind
, you can get new receivable address using bitcore-cli getnewaddress
command