Post
Topic
Board Marketplace
Re: [ANNOUNCE] Bitcoin message service v1.0 (within block-chain)
by
cjp
on 27/03/2012, 21:28:08 UTC
If you send a patch, I will consider adding it.
Still, the back-end has to be updated as well, and it requires additional work ...

BTCmsg,
at your service.

Here you have a diff on "protocol.py".
Although my error rate when coding is usually quite low, I have to warn you that this is completely untested.
Code:
10a11
> SHA256SUM_IDENTIFIER='03'
48a50,68
>     if data_type=='sha256':
>         x=h
>         # Verify h is 64 hexadecimal chars long
>         if len(x) != 64:
>             print 'sha256 must be exactly 64 chars long'
>             return ([],'')
>         for j in range(64):
>             if x[j]<'0' or x[j]>'f':
>                 print 'sha256 chars are only 0-9,a-f'
>                 return ([],'')
>         # Split to groups with char length
>         # 2,4,4,...,4,2
>         s=[]
>         s.append(SHA256SUM_IDENTIFIER+h[:2]) # Mark sha256 msg with SHA256SUM_IDENTIFIER
>         for i in range(15):
>             s.append(h[2+i*4:6+i*4])
>         s.append(h[62:65]+'00')
>         for t in s:
>             output.append('0.'+'%08d' % (int(t,16)))
76a97,107
>     elif data_type == ASCII_IDENTIFIER: # ascii
>         x=''
>         for t in l:
>             x+=t
>         m=x[2:]
>         return binascii.unhexlify(m)
>     elif data_type == SHA256SUM_IDENTIFIER: # sha256
>         x=''
>         for t in l:
>             x+=t
>         return x[2:-2]
78,85c109
<         if data_type == ASCII_IDENTIFIER: # ascii
<             x=''
<             for t in l:
<                 x+=t
<             m=x[2:]
<             return binascii.unhexlify(m)
<         else:
<             print 'Unrecognized data type %s' % (data_type,)
---
>         print 'Unrecognized data type %s' % (data_type,)

I didn't mean you necessarily have to implement this SHA256 option, I just meant that it would be nice to standardize it for future software versions. I consider using this in my own software, so if I follow the extended version of the standard, at least you and others know how to interpret my messages. Also, we'll avoid the "incompatibility" scenario where someone else uses "03" for some other purpose.