Hi, I'm a beginner to Bitcoin. I made a lot of search, but there are some things about how transactions work that still make me desist from getting into the business.
The answers I found to my doubts are ambiguous and I hope someone can help me to clear them.
I created a wallet (I tried Bitcoin Core and Electrum). If I've well understood, when I want to receive a payment, I have to create a new public address for every transaction. So, if I use a new address, nobody should be able to associate all the payments received to a single wallet. If I want to send Bitcoins, I need the public address of the receiver.
Any transaction is written in the Blockchain, and there are some sites that, for a given public address, can show several transactions associated to it, both for sent and received Bitcoins.
This is how it is explained for example here:
https://support.coincorner.com/hc/en-us/articles/360010531460-Understanding-a-Bitcoin-transactionBut how is this possible, if for every payment I receive I use a new public address? It shouldn't be possible to associate all the public addresses to a single wallet.
If you are just receiving bitcoins on new address every time and haven't spent any of the output then it is impossible to link your public addresses with each other. You will only see single receiving transaction if you search the specific bitcoin address on 'Block Explorer'. However, if you have sent money from the wallet then it is possible to link addresses. This is how:
Suppose you received 0.005 BTC on your bitcoin address A and 0.002 BTC on your bitcoin address B. Now you sent a transaction of 0.006 BTC to another address X. To create this transaction, your wallet will use both unspent outputs (UTXOs) as the input like this
Inputs Outputs
Address A 0.005 BTC >>> Address X 0.006 BTC
Address B 0.002 BTC >>> Change Address 0.001 BTC
There are some services which will create link between addresses through this method and will show you all linked addresses to the specific wallet.
Transactions are not done from/to addresses. Transactions are done via scripts and hashes. You create an output and lock it with a locking script. For example, if I say I am sending 0.02 BTC to Address 16Rv1veEeGncvoBEWYCjtp2ViSee1aRtrj what I am actually doing is this:
I am locking 0.02 BTC with this hash - 16Rv1veEeGncvoBEWYCjtp2ViSee1aRtrj and putting a condition that who ever can produce a valid signature using public key such that hash of the public key is equal to 16Rv1veEeGncvoBEWYCjtp2ViSee1aRtrj can spend these 0.02 BTC.
P2SH addresses i.e. addresses starting with '3' work little differently from what I just said. If you send 0.02 BTC to say, 3G8uPe3XKGhyQ2HGZfrmT7yJSxeQ6kJHK4, you are actually locking 0.02 BTC to the script whose hash is 3G8uPe3XKGhyQ2HGZfrmT7yJSxeQ6kJHK4. Now to spend these 0.02 BTC, you have to provide valid redeem script such that hashing that script will produce hash equal to 3G8uPe3XKGhyQ2HGZfrmT7yJSxeQ6kJHK4 and another script to unlock redeem script.
More doubts? Keep them coming.