if the bitcoin address didnt exist, would the transaction go through. I didn't have a good answer because I never tried it. Does the transaction go through or are the coins lost forever?
As long as the address is a valid bitcoin address then the network will accept it.
But if nobody has the private key to that address then you can consider those bitcoins to be out of circulation forever.
Isn't this scary? Imagine for some reason.. when copypasting an address or whatever, you don't select the last leter, then send a shitton of money into an address that doesn't exsist.. coins lost forever. Shouldnt the software guarantee that the transaction can be doable (guarantee that the address exists) before going on with the transaction?
If you paste everything except the last letter then the checksum will fail and the address is not valid so you will not be able to send any BTC to the invalid address.
If you copy it "by hand" and make a mistake, for example put in 'h' instead of 'H' then the checksum will fail, the address is invalid, you are protected.
It is possible to create an address with a valid checksum without ever knowing the private key. The normal process for creating a Bitcoin address is:
(private key) -> (public key) -> (hash of public key) -> (append id and checksum to hash of public key) -> (base 58 encode)
but it is possible to skip the first three steps and make a
valid Bitcoin address (the checksum is correct)
but nobody knows or will ever know the private key.
1BitcoinEaterAddressDontSendf59kuEis such an address. Any BTC sent to this address are lost forever because it was created directly and the private key will never be known.
Notice the random looking stuff after 1BitcoinEaterAddressDontSend, that is the checksum.