Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: jubalix on March 30, 2014, 03:18:50 AM



Title: hashing a transaction
Post by: jubalix on March 30, 2014, 03:18:50 AM
could some one explain, when I send a transaction signed by my priv key my your address to a new address, the block solved as I understand it does exactly that.

So the block does not have to check every prior transaction for that transaction merely that you signing key validly works with the hash of everything else before which is everything before + you public address that the "coin" is on, and output I suppose sits on the public key, and this signed transaction, signed by your priv key is then combined with the new public address, and so on.

I feel I am missing something here, as all the prior transactions for that amount are needed in the blockchain but then what for? surely a block does not have time to check all prior transactions it has in them, and when  I look at the diagram in satoshi's paper and each transaction appears to be composed of all the hashes before it discounted int into he last signed hash plus address.

Any explanation much appreciated


Title: Re: hashing a transaction
Post by: t3a on March 30, 2014, 05:06:22 AM
Your TX includes a hash each inputs associated TX. When you make a TX, you have inputs and outputs. The outputs being spent are inputs in your TX and they were part of the UTXO set until you spent them. Outputs are added to the UTXO. To find out if a TX is valid, your client checks the UTXO list and sees if your input it pointing to a TX belonging to it.


Title: Re: hashing a transaction
Post by: DannyHamilton on March 30, 2014, 07:36:35 PM

I assume that English is not your native language?  I'm struggling to understand what you are saying, and what you are asking.  I'll do the best I can to interpret and answer:

could some one explain, when I send a transaction signed by my priv key my your address to a new address, the block solved as I understand it does exactly that.

Does exactly what?

When you send a transaction, your wallet chooses unspent outputs that were sent to an address for which it has the private key.  Your wallet uses enough of these unspent outputs to provide the necessary value to the transaction.  Then your wallet creates new outputs assigning that value to the addresses that you are sending to.  Finally your wallet uses the private keys to create the necessary digistal signatures for each of the inputs.

Once the transaction is created and signed, your wallet broadcasts the transaction to all the peers that it is connected to.  Each peer validates that the inputs, outputs, and signature are all valid.  Then the peers relay the transaction to all the peers they are connected to.

This validate and relay process continues until almost every node on the network is aware of the transaction.  Eventually, a solo miner (or mining pool) includes the transaction in a block that they solve.

So the block does not have to check every prior transaction for that transaction

Blocks dont' cekch anything.  Peers (also known as nodes) check the transaction before relaying it.  Solo miners (or mining pools) check it before adding it to the block they are attemtping to solve.

merely that you signing key validly works with the hash of everything else before which is everything before + you public address that the "coin" is on, and output I suppose sits on the public key, and this signed transaction, signed by your priv key is then combined with the new public address, and so on.

While building their own copy of the blockchain, each node verifies every transaction of every block.  By doing this, the software is able to build up a list of unspent outputs.  The software doesn't need to trace every transaction all the way back to when each of the bitcoins were mined every time it tries to validate a newly received transaction. Since the software already verified all those tranactions as it received them, it can simply trust its own copy of unspent outputs to decide if a new transaction is valid.

I feel I am missing something here, as all the prior transactions for that amount are needed in the blockchain but then what for?

So that any new node that starts up can acquire the full history and build its own list of currently unspent outputs.

surely a block does not have time to check all prior transactions it has in them,

As I said, blocks don't check anything.  Nodes (peers) check all prior transactions as it builds it's own copy of the blockchain.  Then it trusts its own list of unspent outputs that it built from that history.

and when  I look at the diagram in satoshi's paper and each transaction appears to be composed of all the hashes before it discounted int into he last signed hash plus address.

Each transaction is a list of unspent outputs being used as inputs to fund the transaction, a signature for each input, and a list of new unspent outputs.