Bitcoin Forum
May 03, 2024, 05:50:18 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: help in my code  (Read 737 times)
FabioCarpi (OP)
Sr. Member
****
Offline Offline

Activity: 375
Merit: 254



View Profile
January 06, 2015, 02:03:25 PM
 #1

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
Code:
{
"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
Code:
{
    "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"
                ]
            }
        }
    ]
}
In order to get the maximum amount of activity points possible, you just need to post once per day on average. Skipping days is OK as long as you maintain the average.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714758618
Hero Member
*
Offline Offline

Posts: 1714758618

View Profile Personal Message (Offline)

Ignore
1714758618
Reply with quote  #2

1714758618
Report to moderator
Remember remember the 5th of November
Legendary
*
Offline Offline

Activity: 1862
Merit: 1011

Reverse engineer from time to time


View Profile
January 06, 2015, 02:39:53 PM
 #2

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.

BTC:1AiCRMxgf1ptVQwx6hDuKMu4f7F27QmJC2
FabioCarpi (OP)
Sr. Member
****
Offline Offline

Activity: 375
Merit: 254



View Profile
January 06, 2015, 03:36:58 PM
 #3

Sorry about that. The program is in Portuguese. I'm asking for help here because I'm can't find help in my language...
dabura667
Sr. Member
****
Offline Offline

Activity: 475
Merit: 252


View Profile
January 06, 2015, 05:13:12 PM
 #4

Your code is using the wrong pubkey.

Your pubkey (from bitcoin-qt)
0355bb21eeff72c061adf57064b239d67d5ff77f8c2a1f7b8a2bd4b854dbdab634

Your pubkey (from your code)
032cf7099e6397032e9d47853cf01dae85a7af039bd0e6fd55682e91d502b5507e

My Tip Address:
1DXcHTJS2DJ3xDoxw22wCt11FeAsgfzdBU
FabioCarpi (OP)
Sr. Member
****
Offline Offline

Activity: 375
Merit: 254



View Profile
January 06, 2015, 05:40:20 PM
 #5

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
Code:
{
    "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
Code:
{
"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"
]
}
}
]
}
Remember remember the 5th of November
Legendary
*
Offline Offline

Activity: 1862
Merit: 1011

Reverse engineer from time to time


View Profile
January 06, 2015, 10:20:55 PM
 #6

If RFC6979 is used, there will be no need for a random value.

BTC:1AiCRMxgf1ptVQwx6hDuKMu4f7F27QmJC2
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!