1

At the moment I'm trying to get a look inside Bitcoin and the Blockchain, but I'm having some general unanswered questions.

  1. How does a wallet know how much Bitcoins belongs to a specific address?

I guess there are many possible ways to do that like parsing the complete blockchain and look for some transaction the address made and just sum up the transaction amounts. But that seems to be like the worst possible method. Is there another way to access the blockchain, for example like SQL for relational databases?

  1. In which block will the transaction for creating a block hash listed?

When you find a correct hash of a block you'll receive Bitcoins. But the transaction will be listed in the following block, correct? If the transaction would be listed in the block for which the miner found the hash, the hash would be instantly incorrect after adding this transaction to the block?!

  1. Who hashes the merkle root?

I already know that the merkle tree is "final" hash from all pairwise hashed transactions. But who hashes all the transactions? Is that also part of the miners themselves? If so, the miners have to hash all transactions and afterwards find the correct nonce?

  1. How do miners know that there is a new block?

I know that news blocks are generated every 10 minutes. Is this regulated by time? Let's say the last blocks hash was found at 9:30 and it's now 9:40, would the miner just look in the blockchain and get all transactions from 9:30 to 9:40 and that's the block that needs to be hashed?

  1. Is the difficulty only regulated by the leading zeroes in a hash?

When finding the correct hash it seems like getting the correct amount of leading zeroes is elementary. But is this the only way to regulate the difficulty?

  1. What if no nounce is found for a block?

Is it possible that the network can't find a nonce to generate the needed hash?

Thank you very much

closed as too broad by Pieter Wuille, alcio, Adam Millerchip, Max Vernon, remedcu Dec 14 '17 at 21:32

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Most of your questions are easily answered by looking them up in "Mastering Bitcoin" by Andreas Antonopoulos. Freely available at bitcoinbook.info. – BlackBeltBob Dec 13 '17 at 8:57
1

How does a wallet know how much Bitcoins belongs to a specific address?

A wallet is a private key which generates public keys. You can look those up in the blockchain to see if any of them have an open balance.

In which block will the transaction for creating a block hash listed?

The first transaction in a block is generated by miners themselves, crediting themselves with the coinbase reward. then, the miner adds further transactions and starts looking for a hash that has the right difficulty target. If the miner finds one, the miner publishes the block. Miners thus credits themselves within their own block.

Who hashes the merkle root?

The act of mining is finding a suitable hash for the merkle root and the block header.

How do miners know that there is a new block?

The difficulty is updated every 2016 blocks. Because each block is timestamped, the difficulty adjustment knows how much time has passed, and can raise the difficulty in such a way that the next 2016 blocks will all take approximately 10min to find. Note that this assumes a steady hash rate.

Is the difficulty only regulated by the leading zeroes in a hash?

Yup.

What if no nounce is found for a block?

If so, you swap two transactions in the merkle tree that are unrelated. You can look for a new nonce for the corresponding tree.

  • Thanks for your answer. But what's the best way to look up the public address in the blockchain? Parsing the complete blockchain would take too long. – SO1992 Dec 13 '17 at 9:29
  • if you want to do it manually, have a look at blockchain.info. The bitcoin core wallet does this while receiving tx from other nodes. So there is no manual intervention required... – pebwindkraft Dec 13 '17 at 10:11
  • Let's say I would have 100 Bitcoins and I'm going to download a mobile wallet from the AppStore. How exactly does the wallet get it's current balance? Or can a address ever only be accessed by the same wallet? So moving to a new wallet app wouldn't make any sense? – SO1992 Dec 13 '17 at 11:17
  • The hot wallet will probably not download the whole chain itself, but will just ask a server what the balance is for a bitcoin address. – BlackBeltBob Dec 13 '17 at 15:01
  • So the server has to parse the complete blockchain? I'm sorry, but I don't understand how to access the blockchain the fastest way... – SO1992 Dec 13 '17 at 15:15

Not the answer you're looking for? Browse other questions tagged or ask your own question.