Bitcoin Forum
October 24, 2017, 06:36:25 AM *
News: Latest stable version of Bitcoin Core: 0.15.0.1  [Torrent]. (New!)
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Script serialization in human-readable string  (Read 1718 times)
oleganza
Full Member
***
Offline Offline

Activity: 200


Software design and user experience.


View Profile WWW
August 17, 2013, 10:11:56 PM
 #1

I'm looking at script.h in BitcoinQT, in a definition of ValueString() and see this:

Code:
inline std::string ValueString(const std::vector<unsigned char>& vch)
{
    if (vch.size() <= 4)
        return strprintf("%d", CBigNum(vch).getint());
    else
        return HexStr(vch);
}

Which creates some ambiguity: it can output 1002003004 for both decimal number 1002003004 (which fits in 4-byte int) and for hex representation of 5-byte data 10 02 00 30 04.

Is it okay? Do we have some other non-ambiguous encoding of data? I don't see any string parser in BitcoinQT, so maybe it's a non-issue, but bitcoin-ruby has a parser. In case of bitcoin-ruby, it only parses 2, 3, ... 16 as OP_<n>, while 17 would be parsed as 0x17==23. And data 0x16 (==22) would be encoded as "16" and then interpreted as 0x10 (== 16).

In CoreBitcoin (objc implementation) I'd like to avoid ambiguity and be able to correctly parse human-readable scripts.

Bitcoin analytics: blog.oleganza.com / 1TipsuQ7CSqfQsjA9KU5jarSB1AnrVLLo
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!