Title: help in my code
Post by: FabioCarpi on January 06, 2015, 02:03:25 PM
I'm redoing the entire bitcoin in php only to understand it better. buy im facing a bug that i believe is in the 3rd part code... the 3rd part code is not generating the correct sign, comparing the asm section... My code: https://github.com/FabioCarpi/MyCoin ECDSA library: https://github.com/mdanter/phpecc how to sign: http://bitcoin.stackexchange.com/questions/32628/redeeming-a-raw-transaction-step-by-step-example-required the bitcoin-qt transaction { "txid" : "ad989cd6f44a2ab5f045133e49265c94439f8215269ddc9f45cb62e3fb22bf3c", "version" : 1, "locktime" : 0, "vin" : [ { "txid" : "2340b563df807a3ce1346804ced39f513f9af91aa53a93776d580f528c80307d", "vout" : 120, "scriptSig" : { "asm" : "3045022100f5a81f1794b125f989173d9196fa2708bd7c2a7b4dfd3cbe75c3e3007fe4a3a002204646af9d4c6a95b0a4975ee12b3eb301e018f5846720e6405967bc33125ec29001 0355bb21eeff72c061adf57064b239d67d5ff77f8c2a1f7b8a2bd4b854dbdab634", "hex" : "483045022100f5a81f1794b125f989173d9196fa2708bd7c2a7b4dfd3cbe75c3e3007fe4a3a002204646af9d4c6a95b0a4975ee12b3eb301e018f5846720e6405967bc33125ec29001210355bb21eeff72c061adf57064b239d67d5ff77f8c2a1f7b8a2bd4b854dbdab634" }, "sequence" : 4294967295 } ], "vout" : [ { "value" : 0.00015845, "n" : 0, "scriptPubKey" : { "asm" : "OP_DUP OP_HASH160 1e6bfcb5baf275ad219e3f58d82203b118614832 OP_EQUALVERIFY OP_CHECKSIG", "hex" : "76a9141e6bfcb5baf275ad219e3f58d82203b11861483288ac", "reqSigs" : 1, "type" : "pubkeyhash", "addresses" : [ "13mrdqLsMJoZQ9ippio8B39Qiq9f9AZpuq" ] } } ] }
my program transaction { "txid": "b74960aec12e1a7211238dba60847913bc929c908c8f309da0048bd95633fc72", "version": 1, "locktime": 0, "vin": [ { "txid": "2340b563df807a3ce1346804ced39f513f9af91aa53a93776d580f528c80307d", "vout": 120, "scriptSig": { "asm": "3045022100d5858128654c60cb2c0e1594433b2ef703a75983b9bfd42909ba790b7f29bc580220415b811d0517beba05c9a79cfbe0df01de497d686b8d8ea6521d20f939b2c7ca01 032cf7099e6397032e9d47853cf01dae85a7af039bd0e6fd55682e91d502b5507e", "hex": "483045022100d5858128654c60cb2c0e1594433b2ef703a75983b9bfd42909ba790b7f29bc580220415b811d0517beba05c9a79cfbe0df01de497d686b8d8ea6521d20f939b2c7ca01" }, "sequence": 4294967295 } ], "vout": [ { "value": "0,00015845", "n": 0, "scriptPubKey": { "asm": "OP_DUP OP_HASH160 1e6bfcb5baf275ad219e3f58d82203b118614832 OP_EQUALVERIFY OP_CHECKSIG", "hex": "76a9141e6bfcb5baf275ad219e3f58d82203b11861483288ac", "reqSigs": 1, "type": "pubkeyhash", "addresses": [ "13mrdqLsMJoZQ9ippio8B39Qiq9f9AZpuq" ] } } ] }
Title: Re: help in my code
Post by: Remember remember the 5th of November on January 06, 2015, 02:39:53 PM
You would have to point to the code. I can't look at all of your code.
Also, this is just my advice, but please use english naming of your files + comments. It's difficult to navigate.
Title: Re: help in my code
Post by: FabioCarpi on January 06, 2015, 03:36:58 PM
Sorry about that. The program is in Portuguese. I'm asking for help here because I'm can't find help in my language...
Title: Re: help in my code
Post by: dabura667 on January 06, 2015, 05:13:12 PM
Your code is using the wrong pubkey.
Your pubkey (from bitcoin-qt) 0355bb21eeff72c061adf57064b239d67d5ff77f8c2a1f7b8a2bd4b854dbdab634
Your pubkey (from your code) 032cf7099e6397032e9d47853cf01dae85a7af039bd0e6fd55682e91d502b5507e
Title: Re: help in my code
Post by: FabioCarpi on January 06, 2015, 05:40:20 PM
thank you. had not seen it... i fixed that... buy i alread got the wrong asm... there something that i can't understand... im using this code (https://github.com/Bit-Wasp/bitcoin-lib-php/blob/master/src/RawTransaction.php) to sign... but why i have to use a random number (line 1122) to sign? there i will got differents asm... my program { "txid": "964acec4d856bedbddd3dc691799d1048e34dca6b66d07089cc2bf38570aa6d7", "version": 1, "locktime": 0, "vin": [ { "txid": "2340b563df807a3ce1346804ced39f513f9af91aa53a93776d580f528c80307d", "vout": 120, "scriptSig": { "asm": "304402204615cfb3c49d99f166e929902b5e5480f42701d4f3b9fa6626fd53aed926c5400220725d66f22943f4032b1d57950fd0babe19ed5a4d8f9fe07daa91951bef38195b01 0355bb21eeff72c061adf57064b239d67d5ff77f8c2a1f7b8a2bd4b854dbdab634", "hex": "47304402204615cfb3c49d99f166e929902b5e5480f42701d4f3b9fa6626fd53aed926c5400220725d66f22943f4032b1d57950fd0babe19ed5a4d8f9fe07daa91951bef38195b01" }, "sequence": 4294967295 } ], "vout": [ { "value": 0.00015845, "n": 0, "scriptPubKey": { "asm": "OP_DUP OP_HASH160 1e6bfcb5baf275ad219e3f58d82203b118614832 OP_EQUALVERIFY OP_CHECKSIG", "hex": "76a9141e6bfcb5baf275ad219e3f58d82203b11861483288ac", "reqSigs": 1, "type": "pubkeyhash", "addresses": [ "13mrdqLsMJoZQ9ippio8B39Qiq9f9AZpuq" ] } } ] }
bitcoin-qt { "txid" : "ad989cd6f44a2ab5f045133e49265c94439f8215269ddc9f45cb62e3fb22bf3c", "version" : 1, "locktime" : 0, "vin" : [ { "txid" : "2340b563df807a3ce1346804ced39f513f9af91aa53a93776d580f528c80307d", "vout" : 120, "scriptSig" : { "asm" : "3045022100f5a81f1794b125f989173d9196fa2708bd7c2a7b4dfd3cbe75c3e3007fe4a3a002204646af9d4c6a95b0a4975ee12b3eb301e018f5846720e6405967bc33125ec29001 0355bb21eeff72c061adf57064b239d67d5ff77f8c2a1f7b8a2bd4b854dbdab634", "hex" : "483045022100f5a81f1794b125f989173d9196fa2708bd7c2a7b4dfd3cbe75c3e3007fe4a3a002204646af9d4c6a95b0a4975ee12b3eb301e018f5846720e6405967bc33125ec29001210355bb21eeff72c061adf57064b239d67d5ff77f8c2a1f7b8a2bd4b854dbdab634" }, "sequence" : 4294967295 } ], "vout" : [ { "value" : 0.00015845, "n" : 0, "scriptPubKey" : { "asm" : "OP_DUP OP_HASH160 1e6bfcb5baf275ad219e3f58d82203b118614832 OP_EQUALVERIFY OP_CHECKSIG", "hex" : "76a9141e6bfcb5baf275ad219e3f58d82203b11861483288ac", "reqSigs" : 1, "type" : "pubkeyhash", "addresses" : [ "13mrdqLsMJoZQ9ippio8B39Qiq9f9AZpuq" ] } } ] }
Title: Re: help in my code
Post by: Remember remember the 5th of November on January 06, 2015, 10:20:55 PM
If RFC6979 is used, there will be no need for a random value.
|