I was under the impression that addresses are just an encoded, hashed public keys with a prefix and that only the public key is used on the blockchain (not the address) for transactions. But if the public key is hashed, how does the wallet get the public key from the address to create a transaction?
I did some research which confirmed my doubts that this is not possible. So I was wondering, how does the wallet create a transaction if it doesn't have the public key?
EDIT: I mean how does someone trying to send 10 BTC get the public key of the receiver for pay to public key from the receivers to address. I fully understand the cryptographic element of private & public keypairs and how bitcoin is spent just not how the public key of the receiver is derived from the address. What I have seen is that (most commonly) transactions are pay to public key hash (P2PKH) rather than what I originally thought which was all txns are pay to public key (P2PK).