Bitcoin Forum
May 22, 2018, 07:04:31 AM *
News: Latest stable version of Bitcoin Core: 0.16.0  [Torrent]. (New!)
   Home   Help Search Donate Login Register  
Pages: [1]
Author Topic: Script serialization in human-readable string  (Read 1733 times)
Full Member
Offline Offline

Activity: 200
Merit: 100

Software design and user experience.

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

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

inline std::string ValueString(const std::vector<unsigned char>& vch)
    if (vch.size() <= 4)
        return strprintf("%d", CBigNum(vch).getint());
        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: / 1TipsuQ7CSqfQsjA9KU5jarSB1AnrVLLo
Pages: [1]
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!