Hacker News new | ask | show | jobs
by sprt 3304 days ago
Wrt transactions, I don't understand why you need to send yourself the unspent BTCs. Why does it make things significantly easier?
3 comments

It's essentially for efficiency but not merely; it would be impractical to do with partial spends. Transactions are immutable and spend all of their inputs because it's easier to track and verify no double spend has occurred. If you allowed for partial spends, you'd have to trace the ancestry and descendants of all the transactions to verify whether there was enough bitcoin to spend it. This way if you have a transaction and it hasn't been spent since it originated, you know exactly how much can be spent.

I think it's natural to think of addresses as having a certain amount of bitcoin in them like an account at a bank. But bitcoin doesn't actually have accounts with balances. It just has transactions that have yet to be spent. You can calculate the amount of bitcoin that is spendable by an address so it looks like an account, which is what every wallet does but underneath it's just a collection of transactions that point to some address that you have the private key of.

The high-level meaning of a transaction is to send all the contents of an address. So if you only want to send partial payment, then you need two transactions - one to the foreign destination address and one back to yourself for the remaining funds. The analogy is closer to law and property title, rather than the mathematical/accounting actions of addition or subtraction.

In fact addresses don't really exist, other than as named state in the chain of title. It is the prior, unspent transaction output (utxo) that is unlocked during a transfer, and not some abstract bitcoin address.

Other blockchains, can and do handle these things differently.

Because the miner almost always expects a fee, so why not just infer how high it is and you don't need to spend block bytes on it?
Ok, but the unspent output takes space as well. I think you could just replace it with the fee. Not sure if I'm missing something or if it was just an arbitrary design decision.
It has to do with the way transactions and the blockchain ledger works, reread the transaction part of the article and it might make more sense. Basically, transaction outputs can either be spent or unspent, you can't half spend an output (or perhaps more accurately, you can't spend a previous output twice).
Yes I understand that's how it works, but I don't get why it's important. Surely you could double spend an output as long as you don't exceed its value; and that looks easily verifiable.
Ah, my bad. Sorry if I was being condescending in my previous reply then.

I suspect it was a design decision, yeah. If outputs could be spent multiple times then you'd need to traverse the chain of outputs backwards to see how much an output has left in it. Bitcoin's implementation is less complex and more elegant, imo.