From 4f60dc1b8ae06ed2ae2c2a13d990850092d2ac96 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sun, 18 May 2014 22:54:42 +1000 Subject: [PATCH] Provide a way to extract a serialised integer --- src/libckpool.c | 12 ++++++++++++ src/libckpool.h | 1 + 2 files changed, 13 insertions(+) diff --git a/src/libckpool.c b/src/libckpool.c index a77c8658..2d034d71 100644 --- a/src/libckpool.c +++ b/src/libckpool.c @@ -1255,6 +1255,18 @@ int ser_number(uchar *s, int32_t val) return len; } +int get_sernumber(uchar *s) +{ + int32_t val = 0; + int len; + + len = s[0]; + if (unlikely(len < 1 || len > 4)) + return 0; + memcpy(&val, &s[1], len); + return le32toh(val); +} + /* For testing a le encoded 256 byte hash against a target */ bool fulltest(const uchar *hash, const uchar *target) { diff --git a/src/libckpool.h b/src/libckpool.h index 8fc637b0..6f07652c 100644 --- a/src/libckpool.h +++ b/src/libckpool.h @@ -344,6 +344,7 @@ void b58tobin(char *b58bin, const char *b58); void address_to_pubkeytxn(char *pkh, const char *addr); int ser_number(uchar *s, int32_t val); +int get_sernumber(uchar *s); bool fulltest(const uchar *hash, const uchar *target); void copy_tv(tv_t *dest, const tv_t *src);