Bitcoin Forum
September 23, 2018, 03:46:06 AM *
News: ♦♦ New info! Bitcoin Core users absolutely must upgrade to previously-announced 0.16.3 [Torrent]. All Bitcoin users should temporarily trust confirmations slightly less. More info.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Question on How Transaction Verification Works  (Read 44 times)
BlockchainNoob
Newbie
*
Offline Offline

Activity: 1
Merit: 0


View Profile
December 27, 2017, 12:11:03 AM
 #1

So I have been trying to understand the process on how transactions get verified but have a few questions that I was hoping you guys could answer. My current understanding of a transaction is like this:

I send 1 bitcoin from my public key (signed with my private key) to another public key. This is then sent to the mempool of the nearest node and then if it meets the requirements of a valid transaction this is broadcast to all other nodes on the network. If I add a high fee to my transaction it will be picked up by a miner and added to a block quickly, if I select a low fee or no fee it risks staying in the mempool. If it is not picked up by a miner after a certain amount of time it will be returned to my wallet.

Question 1: How does the miner verify my transaction in the mem pool? Does the miner's software automatically reference all the existing transactions on the blockchain to ensure that my account has 1 bitcoin to send?

Questions 2: Are only valid transactions added to a block to be verified?

Question 3: It is my understanding that a block needs an even number of transactions in a block in order to hash down to a merkle root. If transactions are in fact verified in a block and not in the mempool, is an additional transaction added to the block when one is discarded so that there are an even number of transactions to hash down to a merkle root?

Question 4: Do miners create their own custom software or are all miners running the exact same software?

If anyone could help me understand the exact path a transaction goes through from start to finish I would really appreciate it. I looked around for answers, but most didn't go into enough detail.

EDIT: Please move this to the newbie forum. Sorry for posting in the wrong section  Undecided
1537674366
Hero Member
*
Offline Offline

Posts: 1537674366

View Profile Personal Message (Offline)

Ignore
1537674366
Reply with quote  #2

1537674366
Report to moderator
1537674366
Hero Member
*
Offline Offline

Posts: 1537674366

View Profile Personal Message (Offline)

Ignore
1537674366
Reply with quote  #2

1537674366
Report to moderator
1537674366
Hero Member
*
Offline Offline

Posts: 1537674366

View Profile Personal Message (Offline)

Ignore
1537674366
Reply with quote  #2

1537674366
Report to moderator
Make a difference with your Ether.
Donate Ether for the greater good.
SPRING.WETRUST.IO
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1537674366
Hero Member
*
Offline Offline

Posts: 1537674366

View Profile Personal Message (Offline)

Ignore
1537674366
Reply with quote  #2

1537674366
Report to moderator
1537674366
Hero Member
*
Offline Offline

Posts: 1537674366

View Profile Personal Message (Offline)

Ignore
1537674366
Reply with quote  #2

1537674366
Report to moderator
DannyHamilton
Legendary
*
Offline Offline

Activity: 2198
Merit: 1373



View Profile
December 27, 2017, 02:23:59 AM
 #2

So I have been trying to understand the process on how transactions get verified but have a few questions that I was hoping you guys could answer. My current understanding of a transaction is like this:

I send 1 bitcoin from my public key (signed with my private key) to another public key. This is then sent to the mempool of the nearest node and then if it meets the requirements of a valid transaction this is broadcast to all other nodes on the network. If I add a high fee to my transaction it will be picked up by a miner and added to a block quickly, if I select a low fee or no fee it risks staying in the mempool. If it is not picked up by a miner after a certain amount of time it will be returned to my wallet.

While that is a reasonable high-level understanding of transactions, it gets some of the details incorrect.

Try this:

You create and sign a transaction that is funded with bitcoins that you received in earlier transactions. The public key that was indicated in those earlier transactions indicate which private key must be used to generate the signature. Your transaction indicates a public key that must be used when verifying a signature that spends those bitcoins.

This transaction is shared with ALL the nodes that your wallet is connected to.

Each node verifies for itself that the transaction is valid. If it is, then the transaction is added to the node's own mempool and is shared with all the nodes that are connected to that node. Each of those nodes verifies for itself that the transaction is valid. If it is, then the transaction is added to the node's own mempool and is shared with all the nodes that are connected to that node. And so on until nearly all nodes on the network (including mining nodes) have heard about the transaction.

If you add a high enough fee to your transaction it will be added to one of the next few blocks that are solved worldwide.

If you select a low fee or no fee it risks staying in the mempool (or perhaps even never being added to the mempool of some nodes at all). If it is not included in a block after a whilemany nodes may drop it from their mempool and forget that the transaction ever existed.

Depending on the wallet software that you are using, your wallet might choose to also forget about the transaction after a while (in whice case it will once again show those bitcoins as being available for you to try spending again) or it may re-broadcast the transaction (to remind all the nodes and miners about it), or it may choose to just continue to remember the transaction without re-broadcasting it until you take some action to drop the transaction from your wallet or re-broadcast it.

Any other node that has ever seen the transaction can re-broadcast the transaction if they want to so long as it is valid.

Question 1: How does the miner verify my transaction in the mem pool?

The solo-miner (or mining pool operator) runs node software.  That node software will verify the transaction BEFORE adding it to it's own mempool.

Does the miner's software automatically reference all the existing transactions on the blockchain to ensure that my account has 1 bitcoin to send?

Node software generally keeps a list of unspent transaction outputs (often referred to as the UTXO).  Your transaction is funded by listing (as inputs) unspent transaction outputs. Any transaction outputs that are listed as inputs are then considered to be "spent" and are removed from the UTXO.  So, if your transaction lists any inputs that are not in the UTXO, then your transaction is invalid.  If any signatures in your transaction do not validate properly, then your transaction is invalid.  If any of the structure of your transaction does not line up with the required structure, then your transaction is invalid.

Questions 2: Are only valid transactions added to a block to be verified?

Correct.  Nodes will not add invalid transactions to their mempool.  Nodes will not relay invalid transactions to other nodes. Miners will not accept invalid transactions into the blocks they are building. Nodes will not accept into their blockchain any blocks with invalid transactions. Nodes will not relay blocks with invalid transactions to other nodes.

Question 3: It is my understanding that a block needs an even number of transactions in a block in order to hash down to a merkle root.

This would appear to be untrue.  The merkle algorithm has processes for dealing with odd numbers of transactions.

If transactions are in fact verified in a block and not in the mempool,

Transactions are verified before being added to a mempool.  They are again verified before adding a block to a blockchain.

is an additional transaction added to the block when one is discarded

The protocol rules allow the miner to add as many or as few transaction to their block as they like so long as they include AT LEAST the block reward transaction, AND the block does not exceed the maximum allowed block size (or block weight).  The only other requirement is that the transactions in the block are valid.  The miner can use any criteria they like to choose which transactions to include in the block they are working on and which to leave out.  Since most miners and mining pools are profit motivated, they will generally choose the transactions that pay the highest fee per byte (or per block weight).

Question 4: Do miners create their own custom software or are all miners running the exact same software?

I'm sure there are some solo-miners and some mining pools that have created their own custom software.  I'm sure there are also some solo-miners and some mining pools that are using publicly available open source software.


hopeAo
Jr. Member
*
Offline Offline

Activity: 42
Merit: 1


View Profile
December 27, 2017, 02:56:35 AM
 #3

So I have been trying to understand the process on how transactions get verified but have a few questions that I was hoping you guys could answer. My current understanding of a transaction is like this:

I send 1 bitcoin from my public key (signed with my private key) to another public key. This is then sent to the mempool of the nearest node and then if it meets the requirements of a valid transaction this is broadcast to all other nodes on the network. If I add a high fee to my transaction it will be picked up by a miner and added to a block quickly, if I select a low fee or no fee it risks staying in the mempool. If it is not picked up by a miner after a certain amount of time it will be returned to my wallet.

Question 1: How does the miner verify my transaction in the mem pool? Does the miner's software automatically reference all the existing transactions on the blockchain to ensure that my account has 1 bitcoin to send?

Questions 2: Are only valid transactions added to a block to be verified?

Question 3: It is my understanding that a block needs an even number of transactions in a block in order to hash down to a merkle root. If transactions are in fact verified in a block and not in the mempool, is an additional transaction added to the block when one is discarded so that there are an even number of transactions to hash down to a merkle root?

Question 4: Do miners create their own custom software or are all miners running the exact same software?

If anyone could help me understand the exact path a transaction goes through from start to finish I would really appreciate it. I looked around for answers, but most didn't go into enough detail.

EDIT: Please move this to the newbie forum. Sorry for posting in the wrong section  Undecided


The node will look at a transaction as it arrives and then run many of checks to verify it. Each node builds its own transaction pool, which are mostly the same. The conditions can change and evolve over time and a present list can be checked through the AcceptToMemoryPool, CheckTransaction and CheckInputs functions in the bitcoin client.
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!