Hi ,
Assuming this blockchain output result (starting from genesis block 0) "i m building bitcoin from scratch" :
Alice={
"private_key": "4e5238c752e7274f7ddfc830ea08a51abd3eac65041d2bcbdc4aa605ef3558df",
"public_key": "04692a6b64ee578d71560d60035fcf603411a6355371438f6af2a18a3acb4c9cfa9495657aad4bf 296935d4a5b09c13d3c0a9452b26c7c6d6b4f260f7c14cc7dfd",
"public_key_hash": "f654d9b8a60961d5fde58049e1956d0e1b8b0fcf9c1ff9b3d72cb66b47b7d1f8"
}
Bob={
"private_key": "7eea7f277e7a934b52fa69699ea17f79eb2d2383d9bc685013dcaba5187e357d",
"public_key": "045c927042030e1a2d44590d81b6faf60fd39e4c9fee1b7d81cff3df314e2c1599aa7724c224ebd 24ad42252b22a13ad92b2d71ca5bbef8796e726ea86adab833e",
"public_key_hash": "7f156e1b6b2be69577c2ddbcd5bd91b119d2a8da8bf5cade344f34995c7a536b"
}
Charlie={
"private_key": "9331e7ad92abc7141de6b08721defd7ddcfb56fe62c0d990afde712392b869b0",
"public_key": "04bee6e9b1445d99fbfa789c4f7015d911d3ac262ca4575ce9711fb482f5c4dc310e08d4833a620 7cd074ec87f899f495ba6d0a64e51a9ff36e70c41d302e70cde",
"public_key_hash": "329612d65984fa0293210640d24867cfc2388eca6c0b91970e053ac4d4eae536"
}
-------------------------------------------------------
Block# 0 mined in: 171 ms
----UTXO DB --------
{
"a58364ef3f15886f3601809b1b1821714b0cd6d75d3a5e123ff5a1c20b195b34---0": {
"value": 50,
"pubKeyHash": "f654d9b8a60961d5fde58049e1956d0e1b8b0fcf9c1ff9b3d72cb66b47b7d1f8"
}
}
--------------------
Block# 1 mined in: 72 ms
----UTXO DB --------
{
"a58364ef3f15886f3601809b1b1821714b0cd6d75d3a5e123ff5a1c20b195b34---0": null,
"ed1b5fc60eadd9fc02d35f58631446b19ceff41965d7e83fa885060e20d29cbf---0": {
"value": 96,
"pubKeyHash": "f654d9b8a60961d5fde58049e1956d0e1b8b0fcf9c1ff9b3d72cb66b47b7d1f8"
},
"7fa2fe6c1cfedcba9c94889ff79f18459d90c6100c81c33f335c91026f1b856e---0": {
"value": 30,
"pubKeyHash": "7f156e1b6b2be69577c2ddbcd5bd91b119d2a8da8bf5cade344f34995c7a536b"
},
"7fa2fe6c1cfedcba9c94889ff79f18459d90c6100c81c33f335c91026f1b856e---1": {
"value": 20,
"pubKeyHash": "f654d9b8a60961d5fde58049e1956d0e1b8b0fcf9c1ff9b3d72cb66b47b7d1f8"
},
"f859c4c1cbf10bb3643e5fcbaedfea0a24b72927122fd7b5fcce1cd015a519db---0": {
"value": 4,
"pubKeyHash": "329612d65984fa0293210640d24867cfc2388eca6c0b91970e053ac4d4eae536"
}
}
--------------------
{
"chain": [
{
"index": 0,
"timestamp": "01/01/2017",
"data": [
{
"inps": [
{
"prevtxn_hash": "COINBASE_0",
"index": 0,
"scriptSig": {
"sig": "dummy1",
"pubKey": "dummy2"
}
}
],
"outs": [
{
"value": 50,
"pubKeyHash": "f654d9b8a60961d5fde58049e1956d0e1b8b0fcf9c1ff9b3d72cb66b47b7d1f8"
}
],
"hash": "a58364ef3f15886f3601809b1b1821714b0cd6d75d3a5e123ff5a1c20b195b34"
}
],
"previousHash": "0000000000000000000000000000000000000000000000000000000000000000",
"nonce": 1060430016,
"hash": "00055703d7aef669d2e4aa125a7cbcc03352842091cf716bd983777d7d44a9a7"
},
{
"index": 1,
"timestamp": "01/01/2017",
"data": [
{
"inps": [
{
"prevtxn_hash": "COINBASE_1",
"index": 0,
"scriptSig": {
"sig": "dummy1",
"pubKey": "dummy2"
}
}
],
"outs": [
{
"value": 96,
"pubKeyHash": "f654d9b8a60961d5fde58049e1956d0e1b8b0fcf9c1ff9b3d72cb66b47b7d1f8"
}
],
"hash": "ed1b5fc60eadd9fc02d35f58631446b19ceff41965d7e83fa885060e20d29cbf"
},
{
"inps": [
{
"prevtxn_hash": "a58364ef3f15886f3601809b1b1821714b0cd6d75d3a5e123ff5a1c20b195b34",
"index": 0,
"scriptSig": {
"sig": "3044022021bd08b21e59331af21a7ef809106f0955b9cb3ae8e17547075d18f24f168eca02200c5 9fead771c0c996d9fa9785d867b5e6f60c255ef5096042fc5ce3df9e34108",
"pubKey": "04692a6b64ee578d71560d60035fcf603411a6355371438f6af2a18a3acb4c9cfa9495657aad4bf 296935d4a5b09c13d3c0a9452b26c7c6d6b4f260f7c14cc7dfd"
}
}
],
"outs": [
{
"value": 30,
"pubKeyHash": "7f156e1b6b2be69577c2ddbcd5bd91b119d2a8da8bf5cade344f34995c7a536b"
},
{
"value": 20,
"pubKeyHash": "f654d9b8a60961d5fde58049e1956d0e1b8b0fcf9c1ff9b3d72cb66b47b7d1f8"
}
],
"hash": "7fa2fe6c1cfedcba9c94889ff79f18459d90c6100c81c33f335c91026f1b856e"
},
{
"inps": [
{
"prevtxn_hash": "a58364ef3f15886f3601809b1b1821714b0cd6d75d3a5e123ff5a1c20b195b34",
"index": 0,
"scriptSig": {
"sig": "304402207ded8626fa1a183db8fae4fc745ee5fefb5095932ee1f9e1606d402cb5b4a9d30220059 f0a538a9bfe36a34be21ef5b80b7fe9115b4b41d0ac257ec519461bdfb19e",
"pubKey": "04692a6b64ee578d71560d60035fcf603411a6355371438f6af2a18a3acb4c9cfa9495657aad4bf 296935d4a5b09c13d3c0a9452b26c7c6d6b4f260f7c14cc7dfd"
}
}
],
"outs": [
{
"value": 4,
"pubKeyHash": "329612d65984fa0293210640d24867cfc2388eca6c0b91970e053ac4d4eae536"
}
],
"hash": "f859c4c1cbf10bb3643e5fcbaedfea0a24b72927122fd7b5fcce1cd015a519db"
}
],
"previousHash": "00055703d7aef669d2e4aa125a7cbcc03352842091cf716bd983777d7d44a9a7",
"nonce": 3033275015,
"hash": "0003352f6e897bb4544d489df8d2f9b8cb09170ca267e456180db291829cd8df"
}
],
"utxo_db": {
"db": {
"a58364ef3f15886f3601809b1b1821714b0cd6d75d3a5e123ff5a1c20b195b34---0": null,
"ed1b5fc60eadd9fc02d35f58631446b19ceff41965d7e83fa885060e20d29cbf---0": {
"value": 96,
"pubKeyHash": "f654d9b8a60961d5fde58049e1956d0e1b8b0fcf9c1ff9b3d72cb66b47b7d1f8"
},
"7fa2fe6c1cfedcba9c94889ff79f18459d90c6100c81c33f335c91026f1b856e---0": {
"value": 30,
"pubKeyHash": "7f156e1b6b2be69577c2ddbcd5bd91b119d2a8da8bf5cade344f34995c7a536b"
},
"7fa2fe6c1cfedcba9c94889ff79f18459d90c6100c81c33f335c91026f1b856e---1": {
"value": 20,
"pubKeyHash": "f654d9b8a60961d5fde58049e1956d0e1b8b0fcf9c1ff9b3d72cb66b47b7d1f8"
},
"f859c4c1cbf10bb3643e5fcbaedfea0a24b72927122fd7b5fcce1cd015a519db---0": {
"value": 4,
"pubKeyHash": "329612d65984fa0293210640d24867cfc2388eca6c0b91970e053ac4d4eae536"
}
}
}
}
------------------------------------
Balances:
alice:116
bob:30
charlie:4
====================================================================================
In the Block#0 pays alice 50 from coinbase (witch is the single txn in the block)
resulting a txn hash a58364ef3f15886f3601809b1b1821714b0cd6d75d3a5e123ff5a1c20b195b34 , redeemed to alice pubkeyhash f654d9b8a60961d5fde58049e1956d0e1b8b0fcf9c1ff9b3d72cb66b47b7d1f8
--> Mined correctly (by alice)
In the Block#1 :
txn1 : alice sends 30 to bob and 20 back to her self using UTXO#0 (a58364ef3f15886f3601809b1b1821714b0cd6d75d3a5e123ff5a1c20b195b34 index:0) found in block#0
txn2: : alice sends 4 to charlie from
SAME UTXO#0 (a58364ef3f15886f3601809b1b1821714b0cd6d75d3a5e123ff5a1c20b195b34 index:0) found in block#0
AND alice mine the block, resulting that the txn fees in txn2 = 50(in a58364ef3f...) - 4( to charlie) = 46 --> alice coinbase redemtion = 50+46=96
Can you guys tell me how double spending UTXO in the same block (currently being mined) is handeled in bitcoin core ?
Thanx