Bitcoin Forum
May 07, 2024, 11:52:11 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: SOLVED [Why are my generated transactions non-canonical?]  (Read 1185 times)
comp006 (OP)
Newbie
*
Offline Offline

Activity: 17
Merit: 0


View Profile
June 16, 2015, 04:37:57 PM
Last edit: June 16, 2015, 05:39:11 PM by comp006
 #1

Hi,

I'm writing a c++ library to sign Bitcoin transactions (you can find it here: https://github.com/sgeisler/EasyBitcoin).

I tryed to send a transaction from 1HikVCL5PsR75toN23yEifLqmg8uXAepoz to some other address. At the moment only the code to sign the input is implemented, so I first created a raw transaction with coinbin and then replaced the unsigned input with the signed input generated by my script.

Code:
0100000001883971b9025799b61040fdd0bc516a4c631f8753f689962fc72980de4f2aabc8000000006a47304402207a57c1db269e2ab4706279309a4d1d91112478d92132c2580d4b6f21670dce0502200590c8be6be1616c41db4663800c3b3d9d36ffa0e4d1c7b08082b0b00f679f9a01210440af8583e795691debf6331605a444a1bd2ae3e3978b38ff1d2c7f69443b6c01ffffffff01905f0100000000001976a914ed25801aa39644aaa7fcef2944ba200e05e615be88ac00000000

Coinbin shows it as signed when I try to verify it: verify at coinb.in

But when I try to broadcast it it shows:
Quote
64: non-canonical

I don't know what I'm doing wrong. I mainly followed this tutorial.

Do you know if a bitcoin transaction debugger exists?

It would be great if you could help me Smiley


EDIT: I think I've found my error, I'm only hashing the input and not the whole tx (silly me), will try to hash the whole tx. But why did coinb.in accept the signature if it wasn't correct?
1715082731
Hero Member
*
Offline Offline

Posts: 1715082731

View Profile Personal Message (Offline)

Ignore
1715082731
Reply with quote  #2

1715082731
Report to moderator
1715082731
Hero Member
*
Offline Offline

Posts: 1715082731

View Profile Personal Message (Offline)

Ignore
1715082731
Reply with quote  #2

1715082731
Report to moderator
1715082731
Hero Member
*
Offline Offline

Posts: 1715082731

View Profile Personal Message (Offline)

Ignore
1715082731
Reply with quote  #2

1715082731
Report to moderator
It is a common myth that Bitcoin is ruled by a majority of miners. This is not true. Bitcoin miners "vote" on the ordering of transactions, but that's all they do. They can't vote to change the network rules.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715082731
Hero Member
*
Offline Offline

Posts: 1715082731

View Profile Personal Message (Offline)

Ignore
1715082731
Reply with quote  #2

1715082731
Report to moderator
1715082731
Hero Member
*
Offline Offline

Posts: 1715082731

View Profile Personal Message (Offline)

Ignore
1715082731
Reply with quote  #2

1715082731
Report to moderator
1715082731
Hero Member
*
Offline Offline

Posts: 1715082731

View Profile Personal Message (Offline)

Ignore
1715082731
Reply with quote  #2

1715082731
Report to moderator
tspacepilot
Legendary
*
Offline Offline

Activity: 1456
Merit: 1078


I may write code in exchange for bitcoins.


View Profile
June 17, 2015, 08:12:01 AM
 #2

Hi,

I'm writing a c++ library to sign Bitcoin transactions (you can find it here: https://github.com/sgeisler/EasyBitcoin).

I tryed to send a transaction from 1HikVCL5PsR75toN23yEifLqmg8uXAepoz to some other address. At the moment only the code to sign the input is implemented, so I first created a raw transaction with coinbin and then replaced the unsigned input with the signed input generated by my script.

Code:
0100000001883971b9025799b61040fdd0bc516a4c631f8753f689962fc72980de4f2aabc8000000006a47304402207a57c1db269e2ab4706279309a4d1d91112478d92132c2580d4b6f21670dce0502200590c8be6be1616c41db4663800c3b3d9d36ffa0e4d1c7b08082b0b00f679f9a01210440af8583e795691debf6331605a444a1bd2ae3e3978b38ff1d2c7f69443b6c01ffffffff01905f0100000000001976a914ed25801aa39644aaa7fcef2944ba200e05e615be88ac00000000

Coinbin shows it as signed when I try to verify it: verify at coinb.in

But when I try to broadcast it it shows:
Quote
64: non-canonical

I don't know what I'm doing wrong. I mainly followed this tutorial.

Do you know if a bitcoin transaction debugger exists?

It would be great if you could help me Smiley


EDIT: I think I've found my error, I'm only hashing the input and not the whole tx (silly me), will try to hash the whole tx. But why did coinb.in accept the signature if it wasn't correct?

My best guess is that coinb.in isn't actually verifying the signature.  I can see that  it "decoded" the transaction and it has a check next to "signed".  But, alas, I'm not familiar with this interface, perhaps it turns green or something if the signature is valid?  Did you go back to try the coinb.in again after you figured out the error?  I'm curious what you found.
johoe
Full Member
***
Offline Offline

Activity: 217
Merit: 241


View Profile
June 17, 2015, 11:17:06 AM
 #3

The pubkey in the scriptSig looks also strange:

0440af8583e795691debf6331605a444a1bd2ae3e3978b38ff1d2c7f69443b6c01

33 bytes (compressed) but starts with 04 indicating uncompressed.

Donations to 1CF62UFWXiKqFUmgQMUby9DpEW5LXjypU3
comp006 (OP)
Newbie
*
Offline Offline

Activity: 17
Merit: 0


View Profile
June 17, 2015, 01:17:48 PM
 #4

It works now: https://blockchain.info/de/tx/64d45ef207f6b283540db006bf6ddd43a1c312ca826e08336053fe7f6bab0b8a (my first transaction signed with my own library Smiley )

The txs produced now look like this:

Code:
0100000001883971b9025799b61040fdd0bc516a4c631f8753f689962fc72980de4f2aabc8000000006b483045022100f24f95da3b0df769a79af676c6d0cbd781fa7c0d04be1712c3b148b53472fad702200dc0b3635bba2a0af15104d86ef86ccc74811287184956aa4b612e041e5a5ace01210340af8583e795691debf6331605a444a1bd2ae3e3978b38ff1d2c7f69443b6c01ffffffff01905f0100000000001976a914b7675e0b90a09cb97674702be07b119c989b835088ac00000000

Code:
01000000  		version
01  number of inputs
883971b9025799b61040fdd0bc516a4c631f8753f689962fc72980de4f2aabc8 reverse hash
00000000 prev. output number
6b size of scriptSig


48  push data 72
3045022100f24f95da3b0df769a79af676c6d0cbd781fa7c0d04be1712c3b148b53472fad702200dc0b3635bba2a0af15104d86ef86ccc74811287184956aa4b612e041e5a5ace01 sig + hash all
21  push data 33
0340af8583e795691debf6331605a444a1bd2ae3e3978b38ff1d2c7f69443b6c01 pubKey


ffffffff  sequence
01 number of outputs
905f010000000000  value
19 scriptPubKey size
76a914b7675e0b90a09cb97674702be07b119c989b835088ac scriptPubKey
00000000 locktime

So it seems to work now. I don't know what went wrong with the pubKey (I'm using openssl for all the crypto. Thx to all Smiley
OutCast3k
Hero Member
*****
Offline Offline

Activity: 714
Merit: 601


View Profile WWW
June 17, 2015, 07:02:54 PM
 #5

**snip**

My best guess is that coinb.in isn't actually verifying the signature.  I can see that  it "decoded" the transaction and it has a check next to "signed".  But, alas, I'm not familiar with this interface, perhaps it turns green or something if the signature is valid?  Did you go back to try the coinb.in again after you figured out the error?  I'm curious what you found.

That is correct, coinb.in's verify page will just check to see if a signature exists not if its valid or not. Hope this helps.

coinb.in - Open Source, Multi Signature, HD Wallet and more! | Donate: 33tht1bKDgZVxb39MnZsWa8oxHXHvUYE4G
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!