From 32b1b4433d031bb647f4a9ed97f89ebc4b41c61e Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 25 Oct 2016 19:20:55 -0300 Subject: [PATCH] test --- src/cJSON.h | 1 - src/komodo_utils.h | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/cJSON.h b/src/cJSON.h index c14a72130..6d85f6fa7 100755 --- a/src/cJSON.h +++ b/src/cJSON.h @@ -34,7 +34,6 @@ //#include "../crypto777/OS_portable.h" #define SATOSHIDEN ((uint64_t)100000000L) -//#define dstr(x) ((double)(x) / SATOSHIDEN) #define MAX_JSON_FIELD 4096 // on the big side #ifdef __cplusplus diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 30507e42f..5842c4d53 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -13,6 +13,8 @@ * * ******************************************************************************/ +#define dstr(x) ((double)(x) / SATOSHIDEN) + union _bits256 { uint8_t bytes[32]; uint16_t ushorts[16]; uint32_t uints[8]; uint64_t ulongs[4]; uint64_t txid; }; typedef union _bits256 bits256; @@ -832,6 +834,41 @@ int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex) return(n + adjust); } +char hexbyte(int32_t c) +{ + c &= 0xf; + if ( c < 10 ) + return('0'+c); + else if ( c < 16 ) + return('a'+c-10); + else return(0); +} + +int32_t init_hexbytes_noT(char *hexbytes,unsigned char *message,long len) +{ + int32_t i; + if ( len <= 0 ) + { + hexbytes[0] = 0; + return(1); + } + for (i=0; i>4) & 0xf); + hexbytes[i*2 + 1] = hexbyte(message[i] & 0xf); + //printf("i.%d (%02x) [%c%c]\n",i,message[i],hexbytes[i*2],hexbytes[i*2+1]); + } + hexbytes[len*2] = 0; + //printf("len.%ld\n",len*2+1); + return((int32_t)len*2+1); +} + +char *bits256_str(char hexstr[65],bits256 x) +{ + init_hexbytes_noT(hexstr,x.bytes,sizeof(x)); + return(hexstr); +} + int32_t iguana_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp) { int32_t i; uint64_t x;