Bitcoin Forum
December 05, 2016, 12:55:39 PM *
News: Latest stable version of Bitcoin Core: 0.13.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Question about how transactions are validated  (Read 788 times)
bji
Member
**
Offline Offline

Activity: 112


View Profile
June 21, 2011, 06:45:09 AM
 #1

I just want to confirm my understanding of how transactions are structured and what miners need to do to verify transactions.  I'd like to do so using an example.

Say that Bitcoin address A is first referenced in block N when it is given 50 coins by the coinbase.

Next it is in block N + 1 where it is the output for a transaction that gives it 40 coins from Bitcoin address B.

Next it is in block N + 2 where it is the output for a transaction that gives it 5 coins from Bitcoin address C.

Next it is in block N + 3 where it is the output for a transaction that gives it 1 coin from Bitcoin address D.

Now a miner sees it in block N + 4 giving 100 coins to bitcoin address E.

Is it true that the miner has to trace back through the history of all blocks (in this case the only relevent blocks turn out to be N through N + 3, but the miner doesn't know that until it traces back all the way to the origin block) in order to verify what the balance is in bitcoin address A and whether or not the total is at least 100 coins (in this case, it isn't, it's only 96 coins, and the transaction would be rejected)?

Of course one would expect that if this were the case, that each miner would keep track, with every block, of the total number of bitcoins now in the bitcoin addresses for which transactions were present in the block, and if it stored this extra information, it could know the balance of each bitcoin address just by looking at the balance in the most recent block in which a transaction involving the address appeared.

Or maybe I'm misunderstanding something?
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1480942539
Hero Member
*
Offline Offline

Posts: 1480942539

View Profile Personal Message (Offline)

Ignore
1480942539
Reply with quote  #2

1480942539
Report to moderator
1480942539
Hero Member
*
Offline Offline

Posts: 1480942539

View Profile Personal Message (Offline)

Ignore
1480942539
Reply with quote  #2

1480942539
Report to moderator
1480942539
Hero Member
*
Offline Offline

Posts: 1480942539

View Profile Personal Message (Offline)

Ignore
1480942539
Reply with quote  #2

1480942539
Report to moderator
kjj
Legendary
*
Offline Offline

Activity: 1302



View Profile
June 21, 2011, 06:50:33 AM
 #2

Transactions are not address to address.  They are transaction to address.

p2pcoin: a USB/CD/PXE p2pool miner - 1N8ZXx2cuMzqBYSK72X4DAy1UdDbZQNPLf - todo
I routinely ignore posters with paid advertising in their sigs.  You should too.
bji
Member
**
Offline Offline

Activity: 112


View Profile
June 21, 2011, 08:01:43 AM
 #3

Transactions are not address to address.  They are transaction to address.

Thanks for the correction.

So replace 'address' with 'transaction' in my original question.  Did I get the right answer?
Gr.Green
Newbie
*
Offline Offline

Activity: 17


View Profile
June 21, 2011, 08:26:02 AM
 #4

He'd need to list all input transactions from blocks N... N+3 as a source of funds. This will allow the network to verify the transaction without having to do a search.

What I don't understand is how do they know which transaction is in which block. Do they build a mega map of all transaction-to-block relationships and look that up? This would grow like mad.

Seems as the number of transactions grows the cost of looking up the validity would become more than the cost to compute the hash. Maybe there would be separate parts of the network responsible for each task and they would split the transaction fees.
Pieter Wuille
Legendary
*
qt
Offline Offline

Activity: 1036


View Profile WWW
June 21, 2011, 08:57:42 AM
 #5

No they just keep a map of all unspent transactions.

aka sipa, core dev team

Tips and donations: 1KwDYMJMS4xq3ZEWYfdBRwYG2fHwhZsipa
bji
Member
**
Offline Offline

Activity: 112


View Profile
June 21, 2011, 09:09:45 AM
 #6

He'd need to list all input transactions from blocks N... N+3 as a source of funds. This will allow the network to verify the transaction without having to do a search.

Thanks, I think I'm starting to understand a little better.  I was getting confused and thinking that transactions transfer an amount from one bitcoin address to another.

What transactions really seem to do is simply to name outputs from other transactions as inputs to this transaction, provide 'script' which when combined with the output script of those transactions evaluates to true, thus proving the right to 'claim' the entire set of funds declared in the output, and then set up a new set of outputs with script that would then be combined with the next transaction to set up another such sequence.

So there is no 'adding bitcoins to a bitcoin address', there is only 'rewriting a set of old outputs with a new set of outputs' with the inputs used as a mechanism to identify, and provide proof of the claim to, the old outputs.

And so to verify a transaction, a miner just needs to verify that the inputs properly claim outputs of a transactions which themselves were validated, never needing to go further back than the transactions directly referenced by a new transaction.

Quote
What I don't understand is how do they know which transaction is in which block. Do they build a mega map of all transaction-to-block relationships and look that up? This would grow like mad.

Seems like they must, doesn't it?  But I guess they can also forget about individual transaction outputs once they have been claimed and then can forget the whole transaction once all of its outputs have been claimed, since no valid transaction can ever reference those outputs again.

Quote
Seems as the number of transactions grows the cost of looking up the validity would become more than the cost to compute the hash. Maybe there would be separate parts of the network responsible for each task and they would split the transaction fees.

Yeah having to keep track of every unclaimed transaction output for all perpetuity sounds very hard when there are significant numbers of unclaimed transactions.

And having to swallow the feed of transactions (both unverified, and verified within blocks) when there are hundreds of transactions per second sounds even harder.
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!