Open doublespending opened 6 years ago
I find the same problem and I wana if you have solved it?Thanks a lot if you help.
Now I'm working on same problem. I would appreciate it if anyone could share it when they solve it... https://github.com/hou27/blockchain_go/issues/5
I have checked the code for many many time. However, I could not figure out what is going on. Thanks a lot for helping me solve this problem.
Things have been modified:
I add following code in line206 of server.go to check received block merkle root before Node 3001 accepts it.
fmt.Printf("Merkle root %x\n", block.HashTransactions())
I add following code in line20 of cli_printchain.go to check block merkle root of Node 3000
fmt.Printf("Merkle Root: %x\n", block.HashTransactions())
The result is listed as follow:
NODE_ID=3000
============ Block 0000a7984f7d50d2ed14d3258929a51968dfc8c72f7e4bf5aa9dfe8259c63 763 ============ Height: 2 Prev. block: 00002a49026d0c09c705656e712454330081cf4b1a34b6a94272b96eaebc9b9d Merkle Root: 2e9ca5178708cd52921a1e04da0119f2c880a3acbde48587c0111233133e83e5 PoW: true
--- Transaction ee722146dfec6f180caddfffb59c9f91c59283a77b8eb62712bba2b9685b3508 : Input 0: TXID: Out: -1 Signature: PubKey: 38663663653861313435663431353333393861666534343364666532616133 653635386438343533 Output 0: Value: 10 Script: 63c894ec2fefbaaaec894330c84d6ac4d9368f32 --- Transaction 15573a2f01c78697da7feabec2addb6d88566df5739107b03569d9a6108264a2 : Input 0: TXID: 014d3733ddcac7d8a6ddc8773dd20c5c3a5fa24f00f805b1f7f9463c4c34c7 86 Out: 0 Signature: 7604be74a211bb555d4cb4398c5a03f92f16336ebfd5daded074be2740406d 9379d05f178da575dc3920e0bca6846b0d604fe7091270b3827545cdc6ab713c27 PubKey: 2dd3203343090c26c4f3eec07ed25a81b576e80cce5be3606e0369dfee3a7c 96c03569b60e49033924477b9064ba31e78184f6e116128961dfef5fcfd837ed21 Output 0: Value: 10 Script: 44106b8010bebd3cd52e6456485b9a1832ffc487
============ Block 00002a49026d0c09c705656e712454330081cf4b1a34b6a94272b96eaebc9 b9d ============ Height: 1 Prev. block: 00002ecf72d5c715045fe2a1df4d4bde31bde6068b3692b6e3b952462d400578 Merkle Root: 86b83927a27e60fb9bc356b698706bbccd7f325b13632d52a7180a2895cd6084 PoW: true
...
NODE_ID=3001
Starting node 3001 Received version command Received inv command Recevied inventory with 3 block Received block command Recevied a new block! Added block 0000a7984f7d50d2ed14d3258929a51968dfc8c72f7e4bf5aa9dfe8259c63763 Merkle root 1c2feda8be36b4e886b5271866c57be11d447095ec4d09a13932c3933f73d235 Received block command Recevied a new block! Added block 00002a49026d0c09c705656e712454330081cf4b1a34b6a94272b96eaebc9b9d Merkle root 0c83315ca4d85362613b4d46b1509498e6864dcead04fd17409053877c948f1c Received block command Recevied a new block! Added block 00002ecf72d5c715045fe2a1df4d4bde31bde6068b3692b6e3b952462d400578 Merkle root d8247ea3d8f866d55a868ffa8fb0b96d871f1b4cda5f52bfac479af1fbfa79c5
Have a check of merkle root:
Block: 0000a7984f7d50d2ed14d3258929a51968dfc8c72f7e4bf5aa9dfe8259c63763 NODE_3000: 2e9ca5178708cd52921a1e04da0119f2c880a3acbde48587c0111233133e83e5 NODE_3001: 1c2feda8be36b4e886b5271866c57be11d447095ec4d09a13932c3933f73d235
Block: 00002a49026d0c09c705656e712454330081cf4b1a34b6a94272b96eaebc9b9d NODE_3000: 86b83927a27e60fb9bc356b698706bbccd7f325b13632d52a7180a2895cd6084 NODE_3001: 0c83315ca4d85362613b4d46b1509498e6864dcead04fd17409053877c948f1c
...