Bitcoin Basics - Discussion

There was a question asked a couple times but it didn’t answer the question in my head…
If a miner creates a block with my transaction in it and another miner creates a block also with my transaction in it at the same time and one block gets orphaned, my transaction goes back into the mempool, but it was also accepted in a different block.

How does my transaction that was returned to the mempool keep from being put into another block again? Where is the “mempool” and do all miners see the same one?

Every node has it’s own mempool that gets synced together basically. If 1 node sends a transaction, it will propagate to all other nodes. everybody should have the same data eventually. Once a transaction is inside a block, the ownership is changed of these utxo’s. So if 2 miners mine a block at the same time, only transactions that weren’t included in the ‘winning’ block will go back to the mempool. The blockchain is the true current state of all transactions where it’s proven wich addresses have wich utxo’s. It’s just impossible to double spend within the blockchain. So if a miner would mine a transaction that is already confirmed, the block can never be valid on the blockchain he is mining. I hope I addressed the issue.

I think I understand now. The transaction that goes back in the mempool would no longer be valid because it is attempting to spend UTXOs that were already spent by the accepted transaction. Correct?

1 Like

Hello Community!

I am confused on calculating transaction fees.

Input - Output = fee Doesn’t make sense to me. If my mom sends me 1 BTC ( LOL! even if she knew what it was, she would not be able to figure out how to send it), and I want to spend .9BTC… the fee cannot be .1BTC… because at current prices that would be apprx $600 and the fees are usually very small. Help! Also why do all inputs need to be spent? Is the difference just sent back to the same wallet where it came from?

To minimize the fee’s, you need to send also a bit to an address that you own yourself (as change)

So if your mother has a utxo of 1btc (on a bitcoin address) and she wants to send you 0.9btc to your address she need to also send 0.0999 (or something) to an address of herself as well. So the miner only has a little fee. But most wallets do all this automatically and you just specify the fee you wanna spend.
So in this example the transaction would look like:

INPUT:
1btc (address x from mom)

OUTPUT:
0.9(Address y for you)
0.0999 (to another address of mom)

Fee = the difference of input - output (0.0001 in this case)

2 Likes

Thank you Fabrice!
Would then that mean that there are multiple addressed within one wallet?

OUTPUT:
0.9(Address y for you)
0.0999 (to another address of mom)

Where does this “another” address reside? I have made Bitcoin transactions before and never specified a second address.
Blame it on Ivan for confusing me.

Yes, I agree with you up to here.

Maybe I’ve misunderstood what you mean here, but (with Bitcoin) miners do not need to be simultaneously mining the “same list of transactions”. It’s kind of like a free market, in that for their next block each miner will select whichever transactions they think will give them the highest return on investment. It stands to reason that, because of the inherent latency in the network, different mempools will have different mixes of transactions (to which degree will depend on their relative distance from one another wthin the network). Whenever a mining node solves a block, then this is propogated throughout the network for all full nodes (which includes other mining nodes) to verify, add to their individual copies of the blockchain, remove the block’s validated transactions from their mempools, and then propogate the block further. As a result of this, different versions of the blockchain can coexist throughout the network at any one time, but the longest chain eventually “wins”. Where this results in nodes discarding blocks (stale blocks), the affected transactions are recycled by returning them to the mempool. This is why it is important to wait for several block confirmations to ensure that a particular transaction has been included permanently in the main chain (the version agreed upon by the whole network through consensus).

Yes, you’re right that many different variations on the theme exist. I’m pretty clear now about how the PoW consensus mechanism operates with Bitcoin (and Ethereum, for the time being), but I’m no expert on the other variations — at some point I need to do more research and improve my understanding of PoS. I think I’ll also revisit Cardano’s protocol in terms of block creation and consensus, at some time. I have a feeling that their use of epochs has something in common with what you have descibed… although I’m not sure…

Thank you for refocusing on the real thing. Therefore, how many blocks can be mined locally, I dare say, before it gets shorter than another. Enabling some transactions not to be mined due to small fees for example, would the double spent issue would resolved if transactions get lost in mempools for ages, cause nobody wants to mine them - do the transaction get rejected before that or something like that, from the beginning? Is that even relevant?

Thank. I have loads of old invalid stuff from years ago, when I just started to get interested in understanding the mining job a bit. However abstract of Bitcoin would always remain simpler than actually guessing or learning from scratch all processes that implies a full working technology yet for ever developing.

Happy Easter Monday.

2 Likes

Your Wallet contains private keys with lots of addresses. Every time you click on receive bitcoin after getting paid, you will have a different address. Your wallet will sum all funds on all addresses you own together.
You probably only have experience by using the same address all the time on a hosted wallet like coinbase or binance?
You must know that this is basically just a database. Install a wallet where you control your own keys. Then you will notice that after every transaction, you will get another address that is also tied to your keys.
https://coinsutra.com/hd-wallets-deterministic-wallet/

I think that’s an interesting point. I’m not entirely sure how this would work and be resolved in practice, but if your transaction just didn’t seem to get mined and included in a valid block (and so you decided to resend the transaction with higher fees), then the nodes receiving the new transaction should identify it as a double-spend, and either (i) remove the initial transaction with the lower fees from their mempools, if it is still there; or (ii) reject the new transaction if they have already received and validated a mined block which contains the first transaction (which in turn would have already triggered the removal of that transaction from their mempools).
I also seem to recall hearing about the possibility for a sender to recall a transaction which has already been broadcast. This could therefore be done if an initial transaction seemed to be “stuck” and unconfirmed by the network, before sending a revised transaction with higher fees — although I may be mistaken.

Could someone with more experience confirm this? @filip, @Fabrice

It is clear now. Please charge Ivan for helping his students.

I’m recalling that topic - why do I think there’s a gap there. In building something on top of Bitcoin shouldn’t be discarded - or - it will be resolved by better questioning.

Lol! That makes me think, What if there was a way for a Philanthropic Foundation to get hands on all stupidly lost Bitcoins and actually implement a decentralised Bitcoin recycling network for whom’s profit if Bitcoin is so true in nature.

Also, Where is hacking-Bitcoin part of the relient understanding of it, apart from what’s already known about Bitcoin hacks and bugs ? I wouldn’t like like to question my understanding to seldom in that matter but people like something had came magically out of some sort of hat :tophat:? Just like Hex ?
If the Blockchain is some sort of mathematical proof of value, therefore it must also be a binary, hexadecimal, a programmed proof of value - or is it just a structured data proof of existence that can balance humanity PTSD of what war really is. Humanity getting to discover ourselves truly ?

Hi! What does it mean when a wallet “broadcasts” a transaction to the network? Ivan’s explanation of a 51% attack made it sound more like a gossip protocol where nodes send new transactions to other nodes, rather than a broadcast. Is that how it works, miners having IP addresses of other miners and forwarding new transactions to them?
How long does it take for a transaction to propagate through the network? Milliseconds, seconds, minutes,…?
Is the same mechanism used to inform the nodes that a new block has been mined?
tnx!

Now some wallets have RBF (replace by fee). So you can basically replace the tx with more fee
https://en.bitcoin.it/wiki/Replace_by_fee

Another solution is to make another tx with the change of the stuck tx with some more fee.
(Child pays for parent)

Check this out:

https://bitcoinmagazine.com/articles/what-to-do-if-your-bitcoin-transaction-gets-stuck-1481042383

3 Likes

Yes it’s like gossip. Each node is in connection with a bunch of other nodes (peers) you can also manually add known trusted nodes (of friends you trust) , and those nodes are in connection with other peers. The speed depends if the size of the transaction or blocks. I don’t know the average speed, but it’s probably just the speed like sending files through the internet.

https://medium.com/coinmonks/block-propagation-scaling-and-adoption-maturing-blockchains-99218260b7b8

2 Likes

Your bip39 seed phrase (12 or 24 words) generates a master key where many addresses can derived wich you control in your HD Wallet. You’ll have lots of addresses wich are all yours. you should never reuse old addresses for privacy and safety. Your private keys stored in your Wallet will know wich addresses belong to you. Your wallet will sum up all utxo’s of all your addresses together to show your total balance.

I got some answers from @Fabrice…not sure if you saw his reply… https://forum.toshitimes.com/t/bitcoin-basics-discussion/8417/120
Interesting reading!

2 Likes

I wanted to tag him, but didn’t know the username. I should have edited the post and looked it up.
Anyway if you have good questions, tagging me makes it more visible in my notificationlist among all other homework. It’s very busy lately. So by tagging me, I will notice it sooner.
Have a nice day @jon_m !
You’re doing a great job! I like people who want to dive much deeper in these topics. I also still need to learn a lot. The rabbit hole is very deep :sunglasses:
Good questions by students makes me learn it also much better.

1 Like