I know there are quite similar questions, but none have addressed my issue. Let's say I use Electrum wallet, that generates addresses & keypairs from seed. So for every next transaction I use different private key, public key & address. So (as I understand) when I want to buy something I send my address encrypted with private key to recipient, he decrypts it with public key & then checks the blockchain to determine if I can afford the transaction. But since I use different address for every transaction, how is that possible? I don't see way to connect current transaction to all that came before.
1 Answer
So (as I understand) when I want to buy something I send my address encrypted with private key to recipient, he decrypts it with public key & then checks the blockchain to determine if I can afford the transaction
Not quite the way it works. You just send the address, which is essentially the public key, to the person who is trying to do the paying. Given the address (more technically, references to times that address has been paid to on the blockchain before), anyone (not just the payee/payer) can verify that the transaction has the funds to spend.
And rather than sending the private key to show that you are the owner of the coins, you send a Digital Signature, which you need the private key to generate.
Your wallet reports your balance by looking at the list of times that you have been paid to before, which you have also not spent. This will be across many addresses. The network doesn't know which payments on the blockchain are yours, you have to reference a few of them when you want to spend funds, and prove you own the key to them with a digital signature.
-
Check out the original paper, it explains how the whole referencing-previous-payments-to-pay works. Mar 9, 2016 at 18:33
-
1Indeed. To clarify further: there is no encryption involved anywhere, and it's the receiver that uses a new key for every requested transaction (not the sender, except for his own change). Mar 9, 2016 at 18:35
-
1@PieterWuille btw, thanks for spending time answering Qs on B.SE, I've learned a lot from you, as I'm sure many others have, it's nice to have a core dev so involved. Mar 9, 2016 at 18:38
-
@StephenM347 Reading your answer I was confused at first. I was asking about situation, when I am the buyer, but your answer assumes, that I'm the seller. But now it makes sense: as buyer I don't need to send address to anyone - instead I need to receive address to which I need to pay - right? And so the address needs change after receiving bitcoins, not after sending them (as PieterWuille said). Still, blockchain needs to be checked by receiver to verify my funds. Why do I have to reference few of my payments, instead of all of them? (Trying to read paper too but, its though...)– Sushi271Mar 9, 2016 at 19:44
-
@StephenM347 w8 I think I just got an epiphany. Is it that every receiving address has its own balance? As in: by analyzing blockchain information about payment made to that address and then all payments made from that address I can determine how much money this address contains? And when I buy something, if it's not enough, wallet software sends more addresses, so that in total they contain enough money to cover the expense?– Sushi271Mar 9, 2016 at 20:07