aboutsummaryrefslogtreecommitdiff
path: root/src/util.cpp
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2012-01-04 21:40:52 -0500
committerGavin Andresen <gavinandresen@gmail.com>2012-01-13 10:22:23 -0500
commit922e8e2929a2e78270868385aa46f96002fbcff3 (patch)
treed7c7d2b3fe89bc18b8d0f1137980b9db16db3ae8 /src/util.cpp
parentd11a58a2d39b90dfe27d3a696b3977b87d7c8113 (diff)
downloadbitcoin-922e8e2929a2e78270868385aa46f96002fbcff3.tar.xz
Replace OP_EVAL (BIP 12) with Pay-to-script-hash (BIP 16).
Diffstat (limited to 'src/util.cpp')
-rw-r--r--src/util.cpp46
1 files changed, 28 insertions, 18 deletions
diff --git a/src/util.cpp b/src/util.cpp
index ac7bacb7f5..67e1bf801a 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -400,26 +400,36 @@ bool ParseMoney(const char* pszIn, int64& nRet)
}
-vector<unsigned char> ParseHex(const char* psz)
+static char phexdigit[256] =
+{ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+ 0,1,2,3,4,5,6,7,8,9,-1,-1,-1,-1,-1,-1,
+ -1,0xa,0xb,0xc,0xd,0xe,0xf,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+ -1,0xa,0xb,0xc,0xd,0xe,0xf,-1,-1,-1,-1,-1,-1,-1,-1,-1
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,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1,-1,-1,-1,-1,-1,-1,-1,
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
- -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, };
+ BOOST_FOREACH(unsigned char c, str)
+ {
+ if (phexdigit[c] < 0)
+ return false;
+ }
+ return (str.size() > 0) && (str.size()%2 == 0);
+}
+vector<unsigned char> ParseHex(const char* psz)
+{
// convert hex dump to vector
vector<unsigned char> vch;
loop