Merge pull request #498 from jl777/dPoW

fixes assetchain detection of notarizations and universal build
This commit is contained in:
jl777
2017-10-26 23:48:25 +03:00
committed by GitHub
45 changed files with 3901 additions and 1461 deletions

View File

@@ -39,10 +39,25 @@ sudo apt-get install build-essential pkg-config libcurl3-gnutls-dev libc6-dev li
Komodo
------
We have a release process that goes through several stages before it reaches master. This allows the most conservative users just use the master branch, which is only updated after the other branches have signed off on a release.
99% of the activity is in the dev branch, this is where I am testing each change one by one and there are literally thousands of updates. Only use this branch if you really want to be on the bleeding edge. I try to keep things stable, but there are times where necessarily there are bugs in the dev branch, since I am actively developing and debugging here. A good rule is to wait for at least 4 hours from the last update before using the dev branch (unless you know what you are doing)
After things look good in the dev branch, it is propagated to the beta branch, this is the version the notary nodes use. They are knowledegable command line server guys and so they have a keen eye for anything that wasnt caught during the dev cycle.
After the notary nodes verify things are working and the latest release is deemed stable, it is propagated to the dPoW branch. From here an automated Jenkins process builds it for all OS, and since the notary nodes are all unix, it is possible for some issues to be caught at this stage. The dPoW branch is what goes into the GUI installers.
After the GUI are updated and released and it is verified that no significant support issues were created, the master branch is finally updated.
Master branch: exchanges and users that build from the repo without changing branches
dPoW branch: autobuild into GUI installers, unix, osx, windows
beta branch: notary nodes, command line unix
dev branch: bleeding edge, possibly wont even compile, multiple updates per hour
```
git clone https://github.com/jl777/komodo
cd komodo
#you might want to: git checkout <branch>; git pull
./zcutil/fetch-params.sh
# -j8 uses 8 threads - replace 8 with number of threads you want to use
./zcutil/build.sh -j8

View File

@@ -19,6 +19,7 @@ $(package)_config_opts_i686_linux=address-model=32 architecture=x86
$(package)_toolset_$(host_os)=gcc
$(package)_archiver_$(host_os)=$($(package)_ar)
$(package)_toolset_darwin=gcc
$(package)_archiver_darwin=$($(package)_ar)
$(package)_config_libraries=chrono,filesystem,program_options,system,thread,test
$(package)_cxxflags=-fvisibility=hidden
$(package)_cxxflags_linux=-fPIC
@@ -34,10 +35,18 @@ define $(package)_config_cmds
./bootstrap.sh --without-icu --with-libraries=$(boost_config_libraries)
endef
ifeq ($(host_os),linux)
define $(package)_build_cmds
./b2 -d2 -j2 -d1 --prefix=$($(package)_staging_prefix_dir) $($(package)_config_opts) cxxflags=-std=c++11 stage
endef
define $(package)_stage_cmds
./b2 -d0 -j4 --prefix=$($(package)_staging_prefix_dir) $($(package)_config_opts) cxxflags=-std=c++11 install
endef
else
define $(package)_build_cmds
./b2 -d2 -j2 -d1 --prefix=$($(package)_staging_prefix_dir) $($(package)_config_opts) stage
endef
define $(package)_stage_cmds
./b2 -d0 -j4 --prefix=$($(package)_staging_prefix_dir) $($(package)_config_opts) install
endef
endif

View File

@@ -13,11 +13,12 @@ ifeq ($(build_os),darwin)
define $(package)_set_vars
$(package)_build_env=MACOSX_DEPLOYMENT_TARGET="10.9"
endef
else
endif
define $(package)_config_cmds
$($(package)_conf_tool) $($(package)_config_opts)
endef
endif
ifeq ($(build_os),darwin)
define $(package)_build_cmds

View File

@@ -29,9 +29,15 @@ define $(package)_config_cmds
$($(package)_autoconf) --host=$(host) --build=$(build)
endef
ifeq ($(build_os),darwin)
define $(package)_build_cmds
$(MAKE)
endef
else
define $(package)_build_cmds
$(MAKE) CPPFLAGS='-fPIC'
endef
endif
define $(package)_stage_cmds
$(MAKE) DESTDIR=$($(package)_staging_dir) install ; echo '=== staging find for $(package):' ; find $($(package)_staging_dir)

View File

@@ -9,23 +9,24 @@ $(package)_git_commit=3854b20c25e8bc567aab2b558dec84d45f4a3e73
$(package)_dependencies=libgmp libsodium
ifeq ($(build_os),darwin)
define $(package)_set_vars
$(package)_build_env=CC="$($(package)_cc)" CXX="$($(package)_cxx)"
$(package)_build_env+=CXXFLAGS="$($(package)_cxxflags) -DBINARY_OUTPUT -DSTATICLIB -DNO_PT_COMPRESSION=1 "
endef
define $(package)_build_cmds
CC=gcc-5 CXX=g++-5 CXXFLAGS="-arch x86_64 -DBINARY_OUTPUT -DNO_PT_COMPRESSION=1" $(MAKE) lib DEPINST=$(host_prefix) CURVE=ALT_BN128 MULTICORE=0 NO_PROCPS=1 NO_GTEST=1 NO_DOCS=1 STATIC=1 NO_SUPERCOP=1 FEATUREFLAGS=-DMONTGOMERY_OUTPUT
$(MAKE) lib DEPINST=$(host_prefix) CURVE=ALT_BN128 MULTICORE=1 NO_PROCPS=1 NO_GTEST=1 NO_DOCS=1 STATIC=1 NO_SUPERCOP=1 FEATUREFLAGS=-DMONTGOMERY_OUTPUT OPTFLAGS="-O2 -march=x86-64"
endef
else ifeq ($(host_os),mingw32)
define $(package)_build_cmds
CXX="x86_64-w64-mingw32-g++-posix" CXXFLAGS="-DBINARY_OUTPUT -DPTW32_STATIC_LIB -DSTATICLIB -DNO_PT_COMPRESSION=1 -fopenmp" $(MAKE) lib DEPINST=$(host_prefix) CURVE=ALT_BN128 MULTICORE=1 NO_PROCPS=1 NO_GTEST=1 NO_DOCS=1 STATIC=1 NO_SUPERCOP=1 FEATUREFLAGS=-DMONTGOMERY_OUTPUT OPTFLAGS="-O2 -march=x86-64"
CXX="x86_64-w64-mingw32-g++-posix" CXXFLAGS="-DBINARY_OUTPUT -DPTW32_STATIC_LIB -DSTATICLIB -DNO_PT_COMPRESSION=1 -fopenmp" $(MAKE) lib DEPINST=$(host_prefix) CURVE=ALT_BN128 MULTICORE=1 NO_PROCPS=1 NO_GTEST=1 NO_DOCS=1 STATIC=1 NO_SUPERCOP=1 FEATUREFLAGS=-DMONTGOMERY_OUTPUT OPTFLAGS="-O2 -march=x86-64"
endef
else
define $(package)_build_cmds
CXXFLAGS="-fPIC -DBINARY_OUTPUT -DNO_PT_COMPRESSION=1" $(MAKE) lib DEPINST=$(host_prefix) CURVE=ALT_BN128 MULTICORE=1 NO_PROCPS=1 NO_GTEST=1 NO_DOCS=1 STATIC=1 NO_SUPERCOP=1 FEATUREFLAGS=-DMONTGOMERY_OUTPUT OPTFLAGS="-O2 -march=x86-64"
CXXFLAGS="-fPIC -DBINARY_OUTPUT -DNO_PT_COMPRESSION=1" $(MAKE) lib DEPINST=$(host_prefix) CURVE=ALT_BN128 MULTICORE=1 NO_PROCPS=1 NO_GTEST=1 NO_DOCS=1 STATIC=1 NO_SUPERCOP=1 FEATUREFLAGS=-DMONTGOMERY_OUTPUT OPTFLAGS="-O2 -march=x86-64"
endef
endif
define $(package)_stage_cmds
$(MAKE) install STATIC=1 DEPINST=$(host_prefix) PREFIX=$($(package)_staging_dir)$(host_prefix) CURVE=ALT_BN128 NO_SUPERCOP=1
endef

View File

@@ -1,6 +1,6 @@
#!/bin/bash
set -x
delay=10
delay=60
source pubkey.txt
echo $pubkey

View File

@@ -72,7 +72,7 @@ public:
#include "komodo_globals.h"
#include "komodo_utils.h"
#include "cJSON.c"
#include "komodo_cJSON.c"
#include "komodo_notary.h"
void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout)

View File

@@ -173,7 +173,7 @@ bool AppInit(int argc, char* argv[])
exit(1);
}
#ifndef WIN32
#ifndef _WIN32
fDaemon = GetBoolArg("-daemon", false);
if (fDaemon)
{

3577
src/cJSON.c Executable file → Normal file

File diff suppressed because it is too large Load Diff

451
src/cJSON.h Executable file → Normal file
View File

@@ -1,27 +1,24 @@
/*
Copyright (c) 2009 Dave Gamble
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
#ifndef cJSON__h
#define cJSON__h
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
@@ -31,199 +28,241 @@
#include <float.h>
#include <memory.h>
//#include "../crypto777/OS_portable.h"
#define MAX_JSON_FIELD 4096 // on the big side
#ifndef cJSON__h
#define cJSON__h
#ifdef __cplusplus
extern "C"
{
#endif
/* cJSON Types: */
#define cJSON_False 0
#define cJSON_True 1
#define cJSON_NULL 2
#define cJSON_Number 3
#define cJSON_String 4
#define cJSON_Array 5
#define cJSON_Object 6
#define is_cJSON_Null(json) ((json) != 0 && ((json)->type & 0xff) == cJSON_NULL)
#define is_cJSON_Array(json) ((json) != 0 && ((json)->type & 0xff) == cJSON_Array)
#define is_cJSON_String(json) ((json) != 0 && ((json)->type & 0xff) == cJSON_String)
#define is_cJSON_Number(json) ((json) != 0 && ((json)->type & 0xff) == cJSON_Number)
#define is_cJSON_Object(json) ((json) != 0 && ((json)->type & 0xff) == cJSON_Object)
#define is_cJSON_True(json) ((json) != 0 && ((json)->type & 0xff) == cJSON_True)
#define is_cJSON_False(json) ((json) != 0 && ((json)->type & 0xff) == cJSON_False)
/* project version */
#define CJSON_VERSION_MAJOR 1
#define CJSON_VERSION_MINOR 5
#define CJSON_VERSION_PATCH 9
#include <stddef.h>
/* cJSON Types: */
#define cJSON_Invalid (0)
#define cJSON_False (1 << 0)
#define cJSON_True (1 << 1)
#define cJSON_NULL (1 << 2)
#define cJSON_Number (1 << 3)
#define cJSON_String (1 << 4)
#define cJSON_Array (1 << 5)
#define cJSON_Object (1 << 6)
#define cJSON_Raw (1 << 7) /* raw json */
#define cJSON_IsReference 256
/* The cJSON structure: */
typedef struct cJSON {
struct cJSON *next,*prev; /* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
struct cJSON *child; /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
int32_t type; /* The type of the item, as above. */
char *valuestring; /* The item's string, if type==cJSON_String */
int64_t valueint; /* The item's number, if type==cJSON_Number */
double valuedouble; /* The item's number, if type==cJSON_Number */
char *string; /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
} cJSON;
typedef struct cJSON_Hooks {
void *(*malloc_fn)(size_t sz);
void (*free_fn)(void *ptr);
} cJSON_Hooks;
/* Supply malloc, realloc and free functions to cJSON */
extern void cJSON_InitHooks(cJSON_Hooks* hooks);
/* Supply a block of JSON, and this returns a cJSON object you can interrogate. Call cJSON_Delete when finished. */
extern cJSON *cJSON_Parse(const char *value);
/* Render a cJSON entity to text for transfer/storage. Free the char* when finished. */
extern char *cJSON_Print(cJSON *item);
/* Render a cJSON entity to text for transfer/storage without any formatting. Free the char* when finished. */
extern char *cJSON_PrintUnformatted(cJSON *item);
/* Delete a cJSON entity and all subentities. */
extern void cJSON_Delete(cJSON *c);
/* Returns the number of items in an array (or object). */
extern int cJSON_GetArraySize(cJSON *array);
/* Retrieve item number "item" from array "array". Returns NULL if unsuccessful. */
extern cJSON *cJSON_GetArrayItem(cJSON *array,int32_t item);
/* Get item "string" from object. Case insensitive. */
extern cJSON *cJSON_GetObjectItem(cJSON *object,const char *string);
/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
extern const char *cJSON_GetErrorPtr(void);
/* These calls create a cJSON item of the appropriate type. */
extern cJSON *cJSON_CreateNull(void);
extern cJSON *cJSON_CreateTrue(void);
extern cJSON *cJSON_CreateFalse(void);
extern cJSON *cJSON_CreateBool(int32_t b);
extern cJSON *cJSON_CreateNumber(double num);
extern cJSON *cJSON_CreateString(const char *string);
extern cJSON *cJSON_CreateArray(void);
extern cJSON *cJSON_CreateObject(void);
/* These utilities create an Array of count items. */
extern cJSON *cJSON_CreateIntArray(int64_t *numbers,int32_t count);
extern cJSON *cJSON_CreateFloatArray(float *numbers,int32_t count);
extern cJSON *cJSON_CreateDoubleArray(double *numbers,int32_t count);
extern cJSON *cJSON_CreateStringArray(char **strings,int32_t count);
/* Append item to the specified array/object. */
extern void cJSON_AddItemToArray(cJSON *array, cJSON *item);
extern void cJSON_AddItemToObject(cJSON *object,const char *string,cJSON *item);
/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */
extern void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
extern void cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item);
/* Remove/Detatch items from Arrays/Objects. */
extern cJSON *cJSON_DetachItemFromArray(cJSON *array,int32_t which);
extern void cJSON_DeleteItemFromArray(cJSON *array,int32_t which);
extern cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string);
extern void cJSON_DeleteItemFromObject(cJSON *object,const char *string);
/* Update array items. */
extern void cJSON_ReplaceItemInArray(cJSON *array,int32_t which,cJSON *newitem);
extern void cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
/* Duplicate a cJSON item */
extern cJSON *cJSON_Duplicate(cJSON *item,int32_t recurse);
/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will
need to be released. With recurse!=0, it will duplicate any children connected to the item.
The item->next and ->prev pointers are always zero on return from Duplicate. */
/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */
extern cJSON *cJSON_ParseWithOpts(const char *value,const char **return_parse_end,int32_t require_null_terminated);
extern void cJSON_Minify(char *json);
/* Macros for creating things quickly. */
#define cJSON_AddNullToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateNull())
#define cJSON_AddTrueToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateTrue())
#define cJSON_AddFalseToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateFalse())
#define cJSON_AddBoolToObject(object,name,b) cJSON_AddItemToObject(object, name, cJSON_CreateBool(b))
#define cJSON_AddNumberToObject(object,name,n) cJSON_AddItemToObject(object, name, cJSON_CreateNumber(n))
#define cJSON_AddStringToObject(object,name,s) cJSON_AddItemToObject(object, name, cJSON_CreateString(s))
struct destbuf { char buf[MAX_JSON_FIELD]; };
/* When assigning an integer value, it needs to be propagated to valuedouble too. */
#define cJSON_SetIntValue(object,val) ((object)?(object)->valueint=(object)->valuedouble=(val):(val))
#define jfieldstr get_cJSON_fieldname
char *cJSON_str(cJSON *json);
char *jstr(cJSON *json,char *field);
char *jprint(cJSON *json,int32_t freeflag);
int32_t jint(cJSON *json,char *field);
uint32_t juint(cJSON *json,char *field);
char *jstri(cJSON *json,int32_t i);
int32_t jinti(cJSON *json,int32_t i);
uint32_t juinti(cJSON *json,int32_t i);
uint64_t j64bitsi(cJSON *json,int32_t i);
double jdoublei(cJSON *json,int32_t i);
double jdouble(cJSON *json,char *field);
cJSON *jobj(cJSON *json,char *field);
cJSON *jarray(int32_t *nump,cJSON *json,char *field);
cJSON *jitem(cJSON *array,int32_t i);
uint64_t j64bits(cJSON *json,char *field);
void jadd(cJSON *json,char *field,cJSON *item);
void jaddstr(cJSON *json,char *field,char *str);
void jaddnum(cJSON *json,char *field,double num);
void jadd64bits(cJSON *json,char *field,uint64_t nxt64bits);
void jaddi(cJSON *json,cJSON *item);
void jaddistr(cJSON *json,char *str);
void jaddinum(cJSON *json,double num);
void jaddi64bits(cJSON *json,uint64_t nxt64bits);
void jdelete(cJSON *object,char *string);
cJSON *jduplicate(cJSON *json);
int32_t jnum(cJSON *obj,char *field);
bits256 jbits256(cJSON *json,char *field);
bits256 jbits256i(cJSON *json,int32_t i);
void jaddbits256(cJSON *json,char *field,bits256 hash);
void jaddibits256(cJSON *json,bits256 hash);
void copy_cJSON(struct destbuf *dest,cJSON *obj);
void copy_cJSON2(char *dest,int32_t maxlen,cJSON *obj);
cJSON *gen_list_json(char **list);
int32_t extract_cJSON_str(char *dest,int32_t max,cJSON *json,char *field);
#define cJSON_StringIsConst 512
void free_json(cJSON *json);
int64_t _conv_cJSON_float(cJSON *json);
int64_t conv_cJSON_float(cJSON *json,char *field);
int64_t get_cJSON_int(cJSON *json,char *field);
void add_satoshis_json(cJSON *json,char *field,uint64_t satoshis);
uint64_t get_satoshi_obj(cJSON *json,char *field);
int32_t get_API_int(cJSON *obj,int32_t val);
uint32_t get_API_uint(cJSON *obj,uint32_t val);
uint64_t get_API_nxt64bits(cJSON *obj);
double get_API_float(cJSON *obj);
char *get_cJSON_fieldname(cJSON *obj);
void ensure_jsonitem(cJSON *json,char *field,char *value);
int32_t in_jsonarray(cJSON *array,char *value);
char *bitcoind_RPC(char **retstrp,char *debugstr,char *url,char *userpass,char *command,char *params);
uint64_t calc_nxt64bits(const char *str);
int32_t expand_nxt64bits(char *str,uint64_t nxt64bits);
char *nxt64str(uint64_t nxt64bits);
char *nxt64str2(uint64_t nxt64bits);
cJSON *addrs_jsonarray(uint64_t *addrs,int32_t num);
int32_t myatoi(char *str,int32_t range);
/* The cJSON structure: */
typedef struct cJSON
{
/* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
struct cJSON *next;
struct cJSON *prev;
/* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
struct cJSON *child;
char *stringifyM(char *str);
#define replace_backslashquotes unstringify
char *unstringify(char *str);
#define jtrue cJSON_CreateTrue
#define jfalse cJSON_CreateFalse
/* The type of the item, as above. */
int type;
#define jfieldname get_cJSON_fieldname
/* The item's string, if type==cJSON_String and type == cJSON_Raw */
char *valuestring;
/* writing to valueint is DEPRECATED, use cJSON_SetNumberValue instead */
int valueint;
/* The item's number, if type==cJSON_Number */
double valuedouble;
/* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
char *string;
} cJSON;
typedef struct cJSON_Hooks
{
void *(*malloc_fn)(size_t sz);
void (*free_fn)(void *ptr);
} cJSON_Hooks;
typedef int cJSON_bool;
#if !defined(__WINDOWS__) && (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32))
#define __WINDOWS__
#endif
#ifdef __WINDOWS__
/* When compiling for windows, we specify a specific calling convention to avoid issues where we are being called from a project with a different default calling convention. For windows you have 2 define options:
CJSON_HIDE_SYMBOLS - Define this in the case where you don't want to ever dllexport symbols
CJSON_EXPORT_SYMBOLS - Define this on library build when you want to dllexport symbols (default)
CJSON_IMPORT_SYMBOLS - Define this if you want to dllimport symbol
For *nix builds that support visibility attribute, you can define similar behavior by
setting default visibility to hidden by adding
-fvisibility=hidden (for gcc)
or
-xldscope=hidden (for sun cc)
to CFLAGS
then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJSON_EXPORT_SYMBOLS does
*/
/* export symbols by default, this is necessary for copy pasting the C and header file */
#if !defined(CJSON_HIDE_SYMBOLS) && !defined(CJSON_IMPORT_SYMBOLS) && !defined(CJSON_EXPORT_SYMBOLS)
#define CJSON_EXPORT_SYMBOLS
#endif
#if defined(CJSON_HIDE_SYMBOLS)
#define CJSON_PUBLIC(type) type __stdcall
#elif defined(CJSON_EXPORT_SYMBOLS)
#define CJSON_PUBLIC(type) __declspec(dllexport) type __stdcall
#elif defined(CJSON_IMPORT_SYMBOLS)
#define CJSON_PUBLIC(type) __declspec(dllimport) type __stdcall
#endif
#else /* !WIN32 */
#if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(CJSON_API_VISIBILITY)
#define CJSON_PUBLIC(type) __attribute__((visibility("default"))) type
#else
#define CJSON_PUBLIC(type) type
#endif
#endif
/* Limits how deeply nested arrays/objects can be before cJSON rejects to parse them.
* This is to prevent stack overflows. */
#ifndef CJSON_NESTING_LIMIT
#define CJSON_NESTING_LIMIT 1000
#endif
/* returns the version of cJSON as a string */
CJSON_PUBLIC(const char*) cJSON_Version(void);
/* Supply malloc, realloc and free functions to cJSON */
CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks);
/* Memory Management: the caller is always responsible to free the results from all variants of cJSON_Parse (with cJSON_Delete) and cJSON_Print (with stdlib free, cJSON_Hooks.free_fn, or cJSON_free as appropriate). The exception is cJSON_PrintPreallocated, where the caller has full responsibility of the buffer. */
/* Supply a block of JSON, and this returns a cJSON object you can interrogate. */
CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value);
/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */
/* If you supply a ptr in return_parse_end and parsing fails, then return_parse_end will contain a pointer to the error so will match cJSON_GetErrorPtr(). */
CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated);
/* Render a cJSON entity to text for transfer/storage. */
CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item);
/* Render a cJSON entity to text for transfer/storage without any formatting. */
CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item);
/* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess at the final size. guessing well reduces reallocation. fmt=0 gives unformatted, =1 gives formatted */
CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt);
/* Render a cJSON entity to text using a buffer already allocated in memory with given length. Returns 1 on success and 0 on failure. */
/* NOTE: cJSON is not always 100% accurate in estimating how much memory it will use, so to be safe allocate 5 bytes more than you actually need */
CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format);
/* Delete a cJSON entity and all subentities. */
CJSON_PUBLIC(void) cJSON_Delete(cJSON *c);
/* Returns the number of items in an array (or object). */
CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array);
/* Retrieve item number "item" from array "array". Returns NULL if unsuccessful. */
CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index);
/* Get item "string" from object. Case insensitive. */
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, const char * const string);
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string);
CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string);
/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void);
/* These functions check the type of an item */
CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON * const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON * const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON * const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON * const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON * const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON * const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON * const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item);
/* These calls create a cJSON item of the appropriate type. */
CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void);
CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void);
CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void);
CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean);
CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num);
CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string);
/* raw json */
CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw);
CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void);
CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void);
/* These utilities create an Array of count items. */
CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count);
CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count);
CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count);
CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char **strings, int count);
/* Append item to the specified array/object. */
CJSON_PUBLIC(void) cJSON_AddItemToArray(cJSON *array, cJSON *item);
CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item);
/* Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object.
* WARNING: When this function was used, make sure to always check that (item->type & cJSON_StringIsConst) is zero before
* writing to `item->string` */
CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item);
/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */
CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
CJSON_PUBLIC(void) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item);
/* Remove/Detatch items from Arrays/Objects. */
CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item);
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which);
CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which);
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object, const char *string);
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObjectCaseSensitive(cJSON *object, const char *string);
CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string);
CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string);
/* Update array items. */
CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem); /* Shifts pre-existing items to the right. */
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement);
CJSON_PUBLIC(void) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem);
CJSON_PUBLIC(void) cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
CJSON_PUBLIC(void) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object,const char *string,cJSON *newitem);
/* Duplicate a cJSON item */
CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse);
/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will
need to be released. With recurse!=0, it will duplicate any children connected to the item.
The item->next and ->prev pointers are always zero on return from Duplicate. */
/* Recursively compare two cJSON items for equality. If either a or b is NULL or invalid, they will be considered unequal.
* case_sensitive determines if object keys are treated case sensitive (1) or case insensitive (0) */
CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive);
CJSON_PUBLIC(void) cJSON_Minify(char *json);
/* Macros for creating things quickly. */
#define cJSON_AddNullToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateNull())
#define cJSON_AddTrueToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateTrue())
#define cJSON_AddFalseToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateFalse())
#define cJSON_AddBoolToObject(object,name,b) cJSON_AddItemToObject(object, name, cJSON_CreateBool(b))
#define cJSON_AddNumberToObject(object,name,n) cJSON_AddItemToObject(object, name, cJSON_CreateNumber(n))
#define cJSON_AddStringToObject(object,name,s) cJSON_AddItemToObject(object, name, cJSON_CreateString(s))
#define cJSON_AddRawToObject(object,name,s) cJSON_AddItemToObject(object, name, cJSON_CreateRaw(s))
/* When assigning an integer value, it needs to be propagated to valuedouble too. */
#define cJSON_SetIntValue(object, number) ((object) ? (object)->valueint = (object)->valuedouble = (number) : (number))
/* helper for the cJSON_SetNumberValue macro */
CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number);
#define cJSON_SetNumberValue(object, number) ((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) : (number))
/* Macro for iterating over an array or object */
#define cJSON_ArrayForEach(element, array) for(element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
/* malloc/free objects using the malloc/free functions that have been set with cJSON_InitHooks */
CJSON_PUBLIC(void *) cJSON_malloc(size_t size);
CJSON_PUBLIC(void) cJSON_free(void *object);
#ifdef __cplusplus
}

View File

@@ -10,7 +10,7 @@
#include "config/bitcoin-config.h"
#endif
#ifdef WIN32
#ifdef _WIN32
#ifdef _WIN32_WINNT
#undef _WIN32_WINNT
#endif
@@ -46,7 +46,7 @@
#include <unistd.h>
#endif
#ifdef WIN32
#ifdef _WIN32
#define MSG_DONTWAIT 0
#else
typedef u_int SOCKET;
@@ -64,7 +64,7 @@ typedef u_int SOCKET;
#define SOCKET_ERROR -1
#endif
#ifdef WIN32
#ifdef _WIN32
#ifndef S_IRUSR
#define S_IRUSR 0400
#define S_IWUSR 0200
@@ -78,7 +78,7 @@ typedef u_int SOCKET;
#define MSG_NOSIGNAL 0
#endif
#ifndef WIN32
#ifndef _WIN32
// PRIO_MAX is not defined on Solaris
#ifndef PRIO_MAX
#define PRIO_MAX 20
@@ -94,7 +94,7 @@ size_t strnlen( const char *start, size_t max_len);
#endif // HAVE_DECL_STRNLEN
bool static inline IsSelectableSocket(SOCKET s) {
#ifdef WIN32
#ifdef _WIN32
return true;
#else
return (s < FD_SETSIZE);

View File

@@ -28,6 +28,7 @@
#include <boost/optional.hpp>
/*
#ifdef __APPLE__
#include <machine/endian.h>
#include <libkern/OSByteOrder.h>
@@ -51,7 +52,7 @@
#define __LITTLE_ENDIAN LITTLE_ENDIAN
#define __BYTE_ORDER BYTE_ORDER
#endif
*/
EhSolverCancelledException solver_cancelled;
template<unsigned int N, unsigned int K>

View File

@@ -25,37 +25,37 @@ curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dp
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"MNZ\",\"pubkey\":\"$pubkey\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"USD\",\"pubkey\":\"$pubkey\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"EUR\",\"pubkey\":\"$pubkey\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"JPY\",\"pubkey\":\"$pubkey\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"GBP\",\"pubkey\":\"$pubkey\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"AUD\",\"pubkey\":\"$pubkey\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CAD\",\"pubkey\":\"$pubkey\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CHF\",\"pubkey\":\"$pubkey\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"NZD\",\"pubkey\":\"$pubkey\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CNY\",\"pubkey\":\"$pubkey\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"RUB\",\"pubkey\":\"$pubkey\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"MXN\",\"pubkey\":\"$pubkey\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"BRL\",\"pubkey\":\"$pubkey\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"INR\",\"pubkey\":\"$pubkey\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"HKD\",\"pubkey\":\"$pubkey\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"TRY\",\"pubkey\":\"$pubkey\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"ZAR\",\"pubkey\":\"$pubkey\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"PLN\",\"pubkey\":\"$pubkey\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"NOK\",\"pubkey\":\"$pubkey\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"SEK\",\"pubkey\":\"$pubkey\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"DKK\",\"pubkey\":\"$pubkey\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CZK\",\"pubkey\":\"$pubkey\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"HUF\",\"pubkey\":\"$pubkey\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"ILS\",\"pubkey\":\"$pubkey\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"KRW\",\"pubkey\":\"$pubkey\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"MYR\",\"pubkey\":\"$pubkey\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"PHP\",\"pubkey\":\"$pubkey\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"RON\",\"pubkey\":\"$pubkey\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"SGD\",\"pubkey\":\"$pubkey\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"THB\",\"pubkey\":\"$pubkey\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"BGN\",\"pubkey\":\"$pubkey\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"IDR\",\"pubkey\":\"$pubkey\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"HRK\",\"pubkey\":\"$pubkey\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"USD\",\"pubkey\":\"$pubkey\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"EUR\",\"pubkey\":\"$pubkey\"}"
#
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"JPY\",\"pubkey\":\"$pubkey\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"GBP\",\"pubkey\":\"$pubkey\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"AUD\",\"pubkey\":\"$pubkey\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CAD\",\"pubkey\":\"$pubkey\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CHF\",\"pubkey\":\"$pubkey\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"NZD\",\"pubkey\":\"$pubkey\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CNY\",\"pubkey\":\"$pubkey\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"RUB\",\"pubkey\":\"$pubkey\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"MXN\",\"pubkey\":\"$pubkey\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"BRL\",\"pubkey\":\"$pubkey\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"INR\",\"pubkey\":\"$pubkey\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"HKD\",\"pubkey\":\"$pubkey\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"TRY\",\"pubkey\":\"$pubkey\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"ZAR\",\"pubkey\":\"$pubkey\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"PLN\",\"pubkey\":\"$pubkey\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"NOK\",\"pubkey\":\"$pubkey\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"SEK\",\"pubkey\":\"$pubkey\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"DKK\",\"pubkey\":\"$pubkey\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CZK\",\"pubkey\":\"$pubkey\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"HUF\",\"pubkey\":\"$pubkey\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"ILS\",\"pubkey\":\"$pubkey\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"KRW\",\"pubkey\":\"$pubkey\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"MYR\",\"pubkey\":\"$pubkey\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"PHP\",\"pubkey\":\"$pubkey\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"RON\",\"pubkey\":\"$pubkey\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"SGD\",\"pubkey\":\"$pubkey\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"THB\",\"pubkey\":\"$pubkey\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"BGN\",\"pubkey\":\"$pubkey\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"IDR\",\"pubkey\":\"$pubkey\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"HRK\",\"pubkey\":\"$pubkey\"}"

View File

@@ -38,8 +38,13 @@ TEST(Transaction, JSDescriptionRandomized) {
libzcash::JSOutput(addr, 50),
libzcash::JSOutput(addr, 50)
};
#ifdef __LP64__ // required for building on MacOS
boost::array<uint64_t, ZC_NUM_JS_INPUTS> inputMap;
boost::array<uint64_t, ZC_NUM_JS_OUTPUTS> outputMap;
#else
boost::array<size_t, ZC_NUM_JS_INPUTS> inputMap;
boost::array<size_t, ZC_NUM_JS_OUTPUTS> outputMap;
#endif
{
auto jsdesc = JSDescription::Randomized(
@@ -48,12 +53,22 @@ TEST(Transaction, JSDescriptionRandomized) {
inputMap, outputMap,
0, 0, false);
#ifdef __LP64__ // required for building on MacOS
std::set<uint64_t> inputSet(inputMap.begin(), inputMap.end());
std::set<uint64_t> expectedInputSet {0, 1};
#else
std::set<size_t> inputSet(inputMap.begin(), inputMap.end());
std::set<size_t> expectedInputSet {0, 1};
#endif
EXPECT_EQ(expectedInputSet, inputSet);
#ifdef __LP64__ // required for building on MacOS
std::set<uint64_t> outputSet(outputMap.begin(), outputMap.end());
std::set<uint64_t> expectedOutputSet {0, 1};
#else
std::set<size_t> outputSet(outputMap.begin(), outputMap.end());
std::set<size_t> expectedOutputSet {0, 1};
#endif
EXPECT_EQ(expectedOutputSet, outputSet);
}
@@ -64,8 +79,13 @@ TEST(Transaction, JSDescriptionRandomized) {
inputMap, outputMap,
0, 0, false, GenZero);
#ifdef __LP64__ // required for building on MacOS
boost::array<uint64_t, ZC_NUM_JS_INPUTS> expectedInputMap {1, 0};
boost::array<uint64_t, ZC_NUM_JS_OUTPUTS> expectedOutputMap {1, 0};
#else
boost::array<size_t, ZC_NUM_JS_INPUTS> expectedInputMap {1, 0};
boost::array<size_t, ZC_NUM_JS_OUTPUTS> expectedOutputMap {1, 0};
#endif
EXPECT_EQ(expectedInputMap, inputMap);
EXPECT_EQ(expectedOutputMap, outputMap);
}
@@ -77,8 +97,13 @@ TEST(Transaction, JSDescriptionRandomized) {
inputMap, outputMap,
0, 0, false, GenMax);
#ifdef __LP64__ // required for building on MacOS
boost::array<uint64_t, ZC_NUM_JS_INPUTS> expectedInputMap {0, 1};
boost::array<uint64_t, ZC_NUM_JS_OUTPUTS> expectedOutputMap {0, 1};
#else
boost::array<size_t, ZC_NUM_JS_INPUTS> expectedInputMap {0, 1};
boost::array<size_t, ZC_NUM_JS_OUTPUTS> expectedOutputMap {0, 1};
#endif
EXPECT_EQ(expectedInputMap, inputMap);
EXPECT_EQ(expectedOutputMap, outputMap);
}

View File

@@ -40,7 +40,7 @@
#include <stdint.h>
#include <stdio.h>
#ifndef WIN32
#ifndef _WIN32
#include <signal.h>
#endif
@@ -74,7 +74,7 @@ bool fFeeEstimatesInitialized = false;
static CZMQNotificationInterface* pzmqNotificationInterface = NULL;
#endif
#ifdef WIN32
#ifdef _WIN32
// Win32 LevelDB doesn't use file descriptors, and the ones used for
// accessing block files don't count towards the fd_set size limit
// anyway.
@@ -236,7 +236,7 @@ void Shutdown()
}
#endif
#ifndef WIN32
#ifndef _WIN32
try {
boost::filesystem::remove(GetPidFile());
} catch (const boost::filesystem::filesystem_error& e) {
@@ -334,7 +334,7 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-maxorphantx=<n>", strprintf(_("Keep at most <n> unconnectable transactions in memory (default: %u)"), DEFAULT_MAX_ORPHAN_TRANSACTIONS));
strUsage += HelpMessageOpt("-par=<n>", strprintf(_("Set the number of script verification threads (%u to %d, 0 = auto, <0 = leave that many cores free, default: %d)"),
-(int)boost::thread::hardware_concurrency(), MAX_SCRIPTCHECK_THREADS, DEFAULT_SCRIPTCHECK_THREADS));
#ifndef WIN32
#ifndef _WIN32
strUsage += HelpMessageOpt("-pid=<file>", strprintf(_("Specify pid file (default: %s)"), "komodod.pid"));
#endif
strUsage += HelpMessageOpt("-prune=<n>", strprintf(_("Reduce storage requirements by pruning (deleting) old blocks. This mode disables wallet support and is incompatible with -txindex. "
@@ -716,7 +716,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
// Disable confusing "helpful" text message on abort, Ctrl-C
_set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
#endif
#ifdef WIN32
#ifdef _WIN32
// Enable Data Execution Prevention (DEP)
// Minimum supported OS versions: WinXP SP3, WinVista >= SP1, Win Server 2008
// A failure is non-critical and needs no further attention!
@@ -733,7 +733,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
if (!SetupNetworking())
return InitError("Error: Initializing networking failed");
#ifndef WIN32
#ifndef _WIN32
if (GetBoolArg("-sysperms", false)) {
#ifdef ENABLE_WALLET
if (!GetBoolArg("-disablewallet", false))
@@ -1047,7 +1047,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
return InitError(strprintf(_("Cannot obtain a lock on data directory %s. Komodo is probably already running.") + " %s.", strDataDir, e.what()));
}
#ifndef WIN32
#ifndef _WIN32
CreatePidFile(GetPidFile(), getpid());
#endif
if (GetBoolArg("-shrinkdebugfile", !fDebug))

View File

@@ -42,7 +42,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block);
#include "komodo_utils.h"
#include "komodo_curve25519.h"
#include "cJSON.c"
#include "komodo_cJSON.c"
#include "komodo_bitcoind.h"
#include "komodo_interest.h"
#include "komodo_pax.h"
@@ -80,7 +80,8 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char
else matched = (strcmp(symbol,ASSETCHAINS_SYMBOL) == 0);
if ( fread(&ht,1,sizeof(ht),fp) != sizeof(ht) )
errs++;
//printf("fpos.%ld func.(%d %c) ht.%d ",ftell(fp),func,func,ht);
if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 && func != 'T' )
printf("[%s] matched.%d fpos.%ld func.(%d %c) ht.%d\n",ASSETCHAINS_SYMBOL,matched,ftell(fp),func,func,ht);
if ( func == 'P' )
{
if ( (num= fgetc(fp)) <= 64 )
@@ -103,8 +104,8 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char
errs++;
if ( fread(&notarized_desttxid,1,sizeof(notarized_desttxid),fp) != sizeof(notarized_desttxid) )
errs++;
if ( 0 && sp != 0 )
printf("%s load[%s.%d] NOTARIZED %d %s\n",ASSETCHAINS_SYMBOL,symbol,sp->NUM_NPOINTS,notarized_height,notarized_hash.ToString().c_str());
if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 && sp != 0 )
printf("%s load[%s.%d -> %s] NOTARIZED %d %s\n",ASSETCHAINS_SYMBOL,symbol,sp->NUM_NPOINTS,dest,notarized_height,notarized_hash.ToString().c_str());
//if ( matched != 0 ) global independent states -> inside *sp
komodo_eventadd_notarized(sp,symbol,ht,dest,notarized_hash,notarized_desttxid,notarized_height);
}
@@ -156,7 +157,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char
{
if ( fread(opret,1,olen,fp) != olen )
errs++;
if ( 0 && matched != 0 )
if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 && matched != 0 )
{
int32_t i; for (i=0; i<olen; i++)
printf("%02x",opret[i]);
@@ -204,8 +205,10 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar
if ( (sp= komodo_stateptr(symbol,dest)) == 0 )
{
KOMODO_INITDONE = (uint32_t)time(NULL);
printf("[%s] no komodo_stateptr\n",ASSETCHAINS_SYMBOL);
return;
}
//printf("[%s] (%s) -> (%s)\n",ASSETCHAINS_SYMBOL,symbol,dest);
if ( fp == 0 )
{
komodo_statefname(fname,ASSETCHAINS_SYMBOL,(char *)"komodostate");
@@ -389,6 +392,8 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr
opretlen = scriptbuf[len++];
opretlen += (scriptbuf[len++] << 8);
}
if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 )
printf("[%s] notarized.%d notarizedht.%d sp.Nht %d sp.ht %d opretlen.%d (%c %c %c)\n",ASSETCHAINS_SYMBOL,notarized,*notarizedheightp,sp->NOTARIZED_HEIGHT,sp->CURRENT_HEIGHT,opretlen,scriptbuf[len+32*2+4],scriptbuf[len+32*2+4+1],scriptbuf[len+32*2+4+2]);
if ( j == 1 && opretlen >= 32*2+4 && strcmp(ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,(char *)&scriptbuf[len+32*2+4]) == 0 )
{
len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&kmdtxid);
@@ -401,8 +406,8 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr
sp->NOTARIZED_DESTTXID = desttxid;
komodo_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0,0);
len += 4;
if ( 0 && ASSETCHAINS_SYMBOL[0] == 0 )
printf("%s ht.%d NOTARIZED.%d %s.%s %sTXID.%s (%s) lens.(%d %d)\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),(char *)&scriptbuf[len],opretlen,len);
if ( ASSETCHAINS_SYMBOL[0] != 0 )
printf("[%s] ht.%d NOTARIZED.%d %s.%s %sTXID.%s (%s) lens.(%d %d)\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),(char *)&scriptbuf[len],opretlen,len);
if ( ASSETCHAINS_SYMBOL[0] == 0 )
{
if ( signedfp == 0 )
@@ -545,9 +550,12 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
} else printf("cant get scriptPubKey for ht.%d txi.%d vin.%d\n",height,i,j);
}
numvalid = bitweight(signedmask);
if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || numvalid > (numnotaries/5)) )
if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) ||
(numvalid >= KOMODO_MINRATIFY && ASSETCHAINS_SYMBOL[0] != 0) ||
numvalid > (numnotaries/5)) )
{
printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts);
if ( height > 500000 || ASSETCHAINS_SYMBOL[0] != 0 )
printf("[%s] ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts);
notarized = 1;
}
if ( NOTARY_PUBKEY33[0] != 0 && ASSETCHAINS_SYMBOL[0] == 0 )
@@ -589,7 +597,8 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
}
if ( NOTARY_PUBKEY33[0] != 0 && ASSETCHAINS_SYMBOL[0] == 0 )
printf(") ");
//printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d notarized.%d special.%d isratification.%d\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts,notarized,specialtx,isratification);
if ( 0 && ASSETCHAINS_SYMBOL[0] == 0 )
printf("[%s] ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d notarized.%d special.%d isratification.%d\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts,notarized,specialtx,isratification);
if ( notarized != 0 && (notarizedheight != 0 || specialtx != 0) )
{
if ( isratification != 0 )

View File

@@ -23,7 +23,7 @@
#include <curl/easy.h>
#endif
#define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"curl",(char *)"http://127.0.0.1:7776",0,0,(char *)(cmdstr))
//#define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"curl",(char *)"http://127.0.0.1:7776",0,0,(char *)(cmdstr))
struct MemoryStruct { char *memory; size_t size; };
struct return_string { char *ptr; size_t len; };
@@ -339,7 +339,7 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port)
{
sprintf(url,(char *)"http://127.0.0.1:%u",port);
sprintf(postdata,"{\"method\":\"%s\",\"params\":%s}",method,params);
//printf("postdata.(%s) USERPASS.(%s)\n",postdata,KMDUSERPASS);
//printf("[%s] (%s) postdata.(%s) params.(%s) USERPASS.(%s)\n",ASSETCHAINS_SYMBOL,url,postdata,params,KMDUSERPASS);
retstr2 = bitcoind_RPC(&retstr,(char *)"debug",url,userpass,method,params);
//retstr = curl_post(&cHandle,url,USERPASS,postdata,0,0,0,0);
}
@@ -353,7 +353,7 @@ int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heig
*kmdnotarized_heightp = 0;
if ( strcmp(dest,"KMD") == 0 )
{
port = 7771;
port = KMD_PORT;
userpass = KMDUSERPASS;
}
else if ( strcmp(dest,"BTC") == 0 )
@@ -427,15 +427,18 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t
sprintf(params,"[\"%s\", 1]",NOTARIZED_DESTTXID.ToString().c_str());
if ( strcmp(symbol,ASSETCHAINS_SYMBOL[0]==0?(char *)"KMD":ASSETCHAINS_SYMBOL) != 0 )
return(0);
//printf("[%s] src.%s dest.%s params.[%s] ht.%d notarized.%d\n",ASSETCHAINS_SYMBOL,symbol,dest,params,height,NOTARIZED_HEIGHT);
if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 )
printf("[%s] src.%s dest.%s params.[%s] ht.%d notarized.%d\n",ASSETCHAINS_SYMBOL,symbol,dest,params,height,NOTARIZED_HEIGHT);
if ( strcmp(dest,"KMD") == 0 )
{
if ( KMDUSERPASS[0] != 0 )
{
if ( ASSETCHAINS_SYMBOL[0] != 0 )
jsonstr = komodo_issuemethod(KMDUSERPASS,(char *)"getrawtransaction",params,7771);
}
//else jsonstr = _dex_getrawtransaction();
{
jsonstr = komodo_issuemethod(KMDUSERPASS,(char *)"getrawtransaction",params,KMD_PORT);
//printf("userpass.(%s) got (%s)\n",KMDUSERPASS,jsonstr);
}
}//else jsonstr = _dex_getrawtransaction();
else return(0); // need universal way to issue DEX* API, since notaries mine most blocks, this ok
}
else if ( strcmp(dest,"BTC") == 0 )
@@ -460,7 +463,8 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t
if ( (txjson= jobj(json,(char *)"result")) != 0 && (vouts= jarray(&n,txjson,(char *)"vout")) > 0 )
{
vout = jitem(vouts,n-1);
//printf("vout.(%s)\n",jprint(vout,0));
if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 )
printf("vout.(%s)\n",jprint(vout,0));
if ( (skey= jobj(vout,(char *)"scriptPubKey")) != 0 )
{
if ( (hexstr= jstr(skey,(char *)"hex")) != 0 )

559
src/komodo_cJSON.c Executable file
View File

@@ -0,0 +1,559 @@
/*
Copyright (c) 2009 Dave Gamble
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/* cJSON */
/* JSON parser in C. */
#include <math.h>
#include "cJSON.h"
#include "komodo_cJSON.h"
#include "cJSON.c"
#ifndef DBL_EPSILON
#define DBL_EPSILON 2.2204460492503131E-16
#endif
static const char *ep;
long stripquotes(char *str)
{
long len,offset;
if ( str == 0 )
return(0);
len = strlen(str);
if ( str[0] == '"' && str[len-1] == '"' )
str[len-1] = 0, offset = 1;
else offset = 0;
return(offset);
}
static int32_t cJSON_strcasecmp(const char *s1,const char *s2)
{
if (!s1) return (s1==s2)?0:1;if (!s2) return 1;
for(; tolower((int32_t)(*s1)) == tolower((int32_t)(*s2)); ++s1, ++s2) if(*s1 == 0) return 0;
return tolower((int32_t)(*(const unsigned char *)s1)) - tolower((int32_t)(*(const unsigned char *)s2));
}
// the following written by jl777
/******************************************************************************
* Copyright © 2014-2017 The SuperNET Developers. *
* *
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at *
* the top-level directory of this distribution for the individual copyright *
* holder information and the developer policies on copyright and licensing. *
* *
* Unless otherwise agreed in a custom licensing agreement, no part of the *
* SuperNET software, including this file may be copied, modified, propagated *
* or distributed except according to the terms contained in the LICENSE file *
* *
* Removal or modification of this copyright notice is prohibited. *
* *
******************************************************************************/
void copy_cJSON(struct destbuf *dest,cJSON *obj)
{
char *str;
int i;
long offset;
dest->buf[0] = 0;
if ( obj != 0 )
{
str = cJSON_Print(obj);
if ( str != 0 )
{
offset = stripquotes(str);
//strcpy(dest,str+offset);
for (i=0; i<MAX_JSON_FIELD-1; i++)
if ( (dest->buf[i]= str[offset+i]) == 0 )
break;
dest->buf[i] = 0;
free(str);
}
}
}
void copy_cJSON2(char *dest,int32_t maxlen,cJSON *obj)
{
struct destbuf tmp;
maxlen--;
dest[0] = 0;
if ( maxlen > sizeof(tmp.buf) )
maxlen = sizeof(tmp.buf);
copy_cJSON(&tmp,obj);
if ( strlen(tmp.buf) < maxlen )
strcpy(dest,tmp.buf);
else dest[0] = 0;
}
int64_t _get_cJSON_int(cJSON *json)
{
struct destbuf tmp;
if ( json != 0 )
{
copy_cJSON(&tmp,json);
if ( tmp.buf[0] != 0 )
return(calc_nxt64bits(tmp.buf));
}
return(0);
}
int64_t get_cJSON_int(cJSON *json,char *field)
{
cJSON *numjson;
if ( json != 0 )
{
numjson = cJSON_GetObjectItem(json,field);
if ( numjson != 0 )
return(_get_cJSON_int(numjson));
}
return(0);
}
int64_t conv_floatstr(char *numstr)
{
double val,corr;
val = atof(numstr);
corr = (val < 0.) ? -0.50000000001 : 0.50000000001;
return((int64_t)(val * SATOSHIDEN + corr));
}
int64_t _conv_cJSON_float(cJSON *json)
{
int64_t conv_floatstr(char *);
struct destbuf tmp;
if ( json != 0 )
{
copy_cJSON(&tmp,json);
return(conv_floatstr(tmp.buf));
}
return(0);
}
int64_t conv_cJSON_float(cJSON *json,char *field)
{
if ( json != 0 )
return(_conv_cJSON_float(cJSON_GetObjectItem(json,field)));
return(0);
}
int32_t extract_cJSON_str(char *dest,int32_t max,cJSON *json,char *field)
{
int32_t safecopy(char *dest,char *src,long len);
char *str;
cJSON *obj;
int32_t len;
long offset;
dest[0] = 0;
obj = cJSON_GetObjectItem(json,field);
if ( obj != 0 )
{
str = cJSON_Print(obj);
offset = stripquotes(str);
len = safecopy(dest,str+offset,max);
free(str);
return(len);
}
return(0);
}
cJSON *gen_list_json(char **list)
{
cJSON *array,*item;
array = cJSON_CreateArray();
while ( list != 0 && *list != 0 && *list[0] != 0 )
{
item = cJSON_CreateString(*list++);
cJSON_AddItemToArray(array,item);
}
return(array);
}
uint64_t get_API_nxt64bits(cJSON *obj)
{
uint64_t nxt64bits = 0;
struct destbuf tmp;
if ( obj != 0 )
{
if ( cJSON_IsNumber(obj) != 0 )
return((uint64_t)obj->valuedouble);
copy_cJSON(&tmp,obj);
nxt64bits = calc_nxt64bits(tmp.buf);
}
return(nxt64bits);
}
uint64_t j64bits(cJSON *json,char *field) { if ( field == 0 ) return(get_API_nxt64bits(json)); return(get_API_nxt64bits(cJSON_GetObjectItem(json,field))); }
uint64_t j64bitsi(cJSON *json,int32_t i) { return(get_API_nxt64bits(cJSON_GetArrayItem(json,i))); }
uint64_t get_satoshi_obj(cJSON *json,char *field)
{
int32_t i,n;
uint64_t prev,satoshis,mult = 1;
struct destbuf numstr,checkstr;
cJSON *numjson;
numjson = cJSON_GetObjectItem(json,field);
copy_cJSON(&numstr,numjson);
satoshis = prev = 0; mult = 1; n = (int32_t)strlen(numstr.buf);
for (i=n-1; i>=0; i--,mult*=10)
{
satoshis += (mult * (numstr.buf[i] - '0'));
if ( satoshis < prev )
printf("get_satoshi_obj numstr.(%s) i.%d prev.%llu vs satoshis.%llu\n",numstr.buf,i,(unsigned long long)prev,(unsigned long long)satoshis);
prev = satoshis;
}
sprintf(checkstr.buf,"%llu",(long long)satoshis);
if ( strcmp(checkstr.buf,numstr.buf) != 0 )
{
printf("SATOSHI GREMLIN?? numstr.(%s) -> %.8f -> (%s)\n",numstr.buf,dstr(satoshis),checkstr.buf);
}
return(satoshis);
}
void add_satoshis_json(cJSON *json,char *field,uint64_t satoshis)
{
cJSON *obj;
char numstr[64];
sprintf(numstr,"%lld",(long long)satoshis);
obj = cJSON_CreateString(numstr);
cJSON_AddItemToObject(json,field,obj);
if ( satoshis != get_satoshi_obj(json,field) )
printf("error adding satoshi obj %ld -> %ld\n",(unsigned long)satoshis,(unsigned long)get_satoshi_obj(json,field));
}
char *cJSON_str(cJSON *json)
{
if ( json != 0 && cJSON_IsString(json) != 0 )
return(json->valuestring);
return(0);
}
void jadd(cJSON *json,char *field,cJSON *item) { if ( json != 0 )cJSON_AddItemToObject(json,field,item); }
void jaddstr(cJSON *json,char *field,char *str) { if ( json != 0 && str != 0 ) cJSON_AddItemToObject(json,field,cJSON_CreateString(str)); }
void jaddnum(cJSON *json,char *field,double num) { if ( json != 0 )cJSON_AddItemToObject(json,field,cJSON_CreateNumber(num)); }
void jadd64bits(cJSON *json,char *field,uint64_t nxt64bits) { char numstr[64]; sprintf(numstr,"%llu",(long long)nxt64bits), jaddstr(json,field,numstr); }
void jaddi(cJSON *json,cJSON *item) { if ( json != 0 ) cJSON_AddItemToArray(json,item); }
void jaddistr(cJSON *json,char *str) { if ( json != 0 ) cJSON_AddItemToArray(json,cJSON_CreateString(str)); }
void jaddinum(cJSON *json,double num) { if ( json != 0 ) cJSON_AddItemToArray(json,cJSON_CreateNumber(num)); }
void jaddi64bits(cJSON *json,uint64_t nxt64bits) { char numstr[64]; sprintf(numstr,"%llu",(long long)nxt64bits), jaddistr(json,numstr); }
char *jstr(cJSON *json,char *field) { if ( json == 0 ) return(0); if ( field == 0 ) return(cJSON_str(json)); return(cJSON_str(cJSON_GetObjectItem(json,field))); }
char *jstri(cJSON *json,int32_t i) { return(cJSON_str(cJSON_GetArrayItem(json,i))); }
char *jprint(cJSON *json,int32_t freeflag)
{
char *str;
/*static portable_mutex_t mutex; static int32_t initflag;
if ( initflag == 0 )
{
portable_mutex_init(&mutex);
initflag = 1;
}*/
if ( json == 0 )
return(clonestr((char *)"{}"));
//portable_mutex_lock(&mutex);
//usleep(5000);
str = cJSON_Print(json), _stripwhite(str,' ');
if ( freeflag != 0 )
free_json(json);
//portable_mutex_unlock(&mutex);
return(str);
}
bits256 get_API_bits256(cJSON *obj)
{
bits256 hash; char *str;
memset(hash.bytes,0,sizeof(hash));
if ( obj != 0 )
{
if ( cJSON_IsString(obj) != 0 && (str= obj->valuestring) != 0 && strlen(str) == 64 )
decode_hex(hash.bytes,sizeof(hash),str);
}
return(hash);
}
bits256 jbits256(cJSON *json,char *field) { if ( field == 0 ) return(get_API_bits256(json)); return(get_API_bits256(cJSON_GetObjectItem(json,field))); }
bits256 jbits256i(cJSON *json,int32_t i) { return(get_API_bits256(cJSON_GetArrayItem(json,i))); }
void jaddbits256(cJSON *json,char *field,bits256 hash) { char str[65]; bits256_str(str,hash), jaddstr(json,field,str); }
void jaddibits256(cJSON *json,bits256 hash) { char str[65]; bits256_str(str,hash), jaddistr(json,str); }
char *get_cJSON_fieldname(cJSON *obj)
{
if ( obj != 0 )
{
if ( obj->child != 0 && obj->child->string != 0 )
return(obj->child->string);
else if ( obj->string != 0 )
return(obj->string);
}
return((char *)"<no cJSON string field>");
}
int32_t jnum(cJSON *obj,char *field)
{
char *str; int32_t polarity = 1;
if ( field != 0 )
obj = jobj(obj,field);
if ( obj != 0 )
{
if ( cJSON_IsNumber(obj) != 0 )
return(obj->valuedouble);
else if ( cJSON_IsString(obj) != 0 && (str= jstr(obj,0)) != 0 )
{
if ( str[0] == '-' )
polarity = -1, str++;
return(polarity * (int32_t)calc_nxt64bits(str));
}
}
return(0);
}
void ensure_jsonitem(cJSON *json,char *field,char *value)
{
cJSON *obj = cJSON_GetObjectItem(json,field);
if ( obj == 0 )
cJSON_AddItemToObject(json,field,cJSON_CreateString(value));
else cJSON_ReplaceItemInObject(json,field,cJSON_CreateString(value));
}
int32_t in_jsonarray(cJSON *array,char *value)
{
int32_t i,n;
struct destbuf remote;
if ( array != 0 && cJSON_IsArray(array) != 0 )
{
n = cJSON_GetArraySize(array);
for (i=0; i<n; i++)
{
if ( array == 0 || n == 0 )
break;
copy_cJSON(&remote,cJSON_GetArrayItem(array,i));
if ( strcmp(remote.buf,value) == 0 )
return(1);
}
}
return(0);
}
int32_t myatoi(char *str,int32_t range)
{
long x; char *ptr;
x = strtol(str,&ptr,10);
if ( range != 0 && x >= range )
x = (range - 1);
return((int32_t)x);
}
int32_t get_API_int(cJSON *obj,int32_t val)
{
struct destbuf buf;
if ( obj != 0 )
{
if ( cJSON_IsNumber(obj) != 0 )
return((int32_t)obj->valuedouble);
copy_cJSON(&buf,obj);
val = myatoi(buf.buf,0);
if ( val < 0 )
val = 0;
}
return(val);
}
int32_t jint(cJSON *json,char *field) { if ( json == 0 ) return(0); if ( field == 0 ) return(get_API_int(json,0)); return(get_API_int(cJSON_GetObjectItem(json,field),0)); }
int32_t jinti(cJSON *json,int32_t i) { if ( json == 0 ) return(0); return(get_API_int(cJSON_GetArrayItem(json,i),0)); }
uint32_t get_API_uint(cJSON *obj,uint32_t val)
{
struct destbuf buf;
if ( obj != 0 )
{
if ( cJSON_IsNumber(obj) != 0 )
return((uint32_t)obj->valuedouble);
copy_cJSON(&buf,obj);
val = myatoi(buf.buf,0);
}
return(val);
}
uint32_t juint(cJSON *json,char *field) { if ( json == 0 ) return(0); if ( field == 0 ) return(get_API_uint(json,0)); return(get_API_uint(cJSON_GetObjectItem(json,field),0)); }
uint32_t juinti(cJSON *json,int32_t i) { if ( json == 0 ) return(0); return(get_API_uint(cJSON_GetArrayItem(json,i),0)); }
double get_API_float(cJSON *obj)
{
double val = 0.;
struct destbuf buf;
if ( obj != 0 )
{
if ( cJSON_IsNumber(obj) != 0 )
return(obj->valuedouble);
copy_cJSON(&buf,obj);
val = atof(buf.buf);
}
return(val);
}
double jdouble(cJSON *json,char *field)
{
if ( json != 0 )
{
if ( field == 0 )
return(get_API_float(json));
else return(get_API_float(cJSON_GetObjectItem(json,field)));
} else return(0.);
}
double jdoublei(cJSON *json,int32_t i)
{
if ( json != 0 )
return(get_API_float(cJSON_GetArrayItem(json,i)));
else return(0.);
}
cJSON *jobj(cJSON *json,char *field) { if ( json != 0 ) return(cJSON_GetObjectItem(json,field)); return(0); }
void jdelete(cJSON *json,char *field)
{
if ( jobj(json,field) != 0 )
cJSON_DeleteItemFromObject(json,field);
}
cJSON *jduplicate(cJSON *json) { return(cJSON_Duplicate(json,1)); }
cJSON *jitem(cJSON *array,int32_t i) { if ( array != 0 && cJSON_IsArray(array) != 0 && cJSON_GetArraySize(array) > i ) return(cJSON_GetArrayItem(array,i)); return(0); }
cJSON *jarray(int32_t *nump,cJSON *json,char *field)
{
cJSON *array;
if ( json != 0 )
{
if ( field == 0 )
array = json;
else array = cJSON_GetObjectItem(json,field);
if ( array != 0 && cJSON_IsArray(array) != 0 && (*nump= cJSON_GetArraySize(array)) > 0 )
return(array);
}
*nump = 0;
return(0);
}
int32_t expand_nxt64bits(char *NXTaddr,uint64_t nxt64bits)
{
int32_t i,n;
uint64_t modval;
char rev[64];
for (i=0; nxt64bits!=0; i++)
{
modval = nxt64bits % 10;
rev[i] = (char)(modval + '0');
nxt64bits /= 10;
}
n = i;
for (i=0; i<n; i++)
NXTaddr[i] = rev[n-1-i];
NXTaddr[i] = 0;
return(n);
}
char *nxt64str(uint64_t nxt64bits)
{
static char NXTaddr[64];
expand_nxt64bits(NXTaddr,nxt64bits);
return(NXTaddr);
}
char *nxt64str2(uint64_t nxt64bits)
{
static char NXTaddr[64];
expand_nxt64bits(NXTaddr,nxt64bits);
return(NXTaddr);
}
int32_t cmp_nxt64bits(const char *str,uint64_t nxt64bits)
{
char expanded[64];
if ( str == 0 )//|| str[0] == 0 || nxt64bits == 0 )
return(-1);
if ( nxt64bits == 0 && str[0] == 0 )
return(0);
expand_nxt64bits(expanded,nxt64bits);
return(strcmp(str,expanded));
}
uint64_t calc_nxt64bits(const char *NXTaddr)
{
int32_t c;
int64_t n,i,polarity = 1;
uint64_t lastval,mult,nxt64bits = 0;
if ( NXTaddr == 0 )
{
printf("calling calc_nxt64bits with null ptr!\n");
return(0);
}
n = strlen(NXTaddr);
if ( n >= 22 )
{
printf("calc_nxt64bits: illegal NXTaddr.(%s) too long\n",NXTaddr);
return(0);
}
else if ( strcmp(NXTaddr,"0") == 0 || strcmp(NXTaddr,"false") == 0 )
{
// printf("zero address?\n"); getchar();
return(0);
}
if ( NXTaddr[0] == '-' )
polarity = -1, NXTaddr++, n--;
mult = 1;
lastval = 0;
for (i=n-1; i>=0; i--,mult*=10)
{
c = NXTaddr[i];
if ( c < '0' || c > '9' )
{
printf("calc_nxt64bits: illegal char.(%c %d) in (%s).%d\n",c,c,NXTaddr,(int32_t)i);
#ifdef __APPLE__
//while ( 1 )
{
//sleep(60);
printf("calc_nxt64bits: illegal char.(%c %d) in (%s).%d\n",c,c,NXTaddr,(int32_t)i);
}
#endif
return(0);
}
nxt64bits += mult * (c - '0');
if ( nxt64bits < lastval )
printf("calc_nxt64bits: warning: 64bit overflow %llx < %llx\n",(long long)nxt64bits,(long long)lastval);
lastval = nxt64bits;
}
while ( *NXTaddr == '0' && *NXTaddr != 0 )
NXTaddr++;
if ( cmp_nxt64bits(NXTaddr,nxt64bits) != 0 )
printf("error calculating nxt64bits: %s -> %llx -> %s\n",NXTaddr,(long long)nxt64bits,nxt64str(nxt64bits));
if ( polarity < 0 )
return(-(int64_t)nxt64bits);
return(nxt64bits);
}
cJSON *addrs_jsonarray(uint64_t *addrs,int32_t num)
{
int32_t j; cJSON *array;
array = cJSON_CreateArray();
for (j=0; j<num; j++)
jaddi64bits(array,addrs[j]);
return(array);
}
void free_json(cJSON *json) { if ( json != 0 ) cJSON_Delete(json); }

127
src/komodo_cJSON.h Executable file
View File

@@ -0,0 +1,127 @@
/*
Copyright (c) 2009 Dave Gamble
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef komodo_cJSON__h
#define komodo_cJSON__h
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <math.h>
#include <ctype.h>
#include <float.h>
#include <memory.h>
#include "cJSON.h"
//#include "../crypto777/OS_portable.h"
#define MAX_JSON_FIELD 4096 // on the big side
#ifdef __cplusplus
extern "C"
{
#endif
/* Macros for creating things quickly. */
#define cJSON_AddNullToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateNull())
#define cJSON_AddTrueToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateTrue())
#define cJSON_AddFalseToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateFalse())
#define cJSON_AddBoolToObject(object,name,b) cJSON_AddItemToObject(object, name, cJSON_CreateBool(b))
#define cJSON_AddNumberToObject(object,name,n) cJSON_AddItemToObject(object, name, cJSON_CreateNumber(n))
#define cJSON_AddStringToObject(object,name,s) cJSON_AddItemToObject(object, name, cJSON_CreateString(s))
struct destbuf { char buf[MAX_JSON_FIELD]; };
#define jfieldstr get_cJSON_fieldname
char *cJSON_str(cJSON *json);
char *jstr(cJSON *json,char *field);
char *jprint(cJSON *json,int32_t freeflag);
int32_t jint(cJSON *json,char *field);
uint32_t juint(cJSON *json,char *field);
char *jstri(cJSON *json,int32_t i);
int32_t jinti(cJSON *json,int32_t i);
uint32_t juinti(cJSON *json,int32_t i);
uint64_t j64bitsi(cJSON *json,int32_t i);
double jdoublei(cJSON *json,int32_t i);
double jdouble(cJSON *json,char *field);
cJSON *jobj(cJSON *json,char *field);
cJSON *jarray(int32_t *nump,cJSON *json,char *field);
cJSON *jitem(cJSON *array,int32_t i);
uint64_t j64bits(cJSON *json,char *field);
void jadd(cJSON *json,char *field,cJSON *item);
void jaddstr(cJSON *json,char *field,char *str);
void jaddnum(cJSON *json,char *field,double num);
void jadd64bits(cJSON *json,char *field,uint64_t nxt64bits);
void jaddi(cJSON *json,cJSON *item);
void jaddistr(cJSON *json,char *str);
void jaddinum(cJSON *json,double num);
void jaddi64bits(cJSON *json,uint64_t nxt64bits);
void jdelete(cJSON *object,char *string);
cJSON *jduplicate(cJSON *json);
int32_t jnum(cJSON *obj,char *field);
bits256 jbits256(cJSON *json,char *field);
bits256 jbits256i(cJSON *json,int32_t i);
void jaddbits256(cJSON *json,char *field,bits256 hash);
void jaddibits256(cJSON *json,bits256 hash);
void copy_cJSON(struct destbuf *dest,cJSON *obj);
void copy_cJSON2(char *dest,int32_t maxlen,cJSON *obj);
cJSON *gen_list_json(char **list);
int32_t extract_cJSON_str(char *dest,int32_t max,cJSON *json,char *field);
void free_json(cJSON *json);
int64_t _conv_cJSON_float(cJSON *json);
int64_t conv_cJSON_float(cJSON *json,char *field);
int64_t get_cJSON_int(cJSON *json,char *field);
void add_satoshis_json(cJSON *json,char *field,uint64_t satoshis);
uint64_t get_satoshi_obj(cJSON *json,char *field);
int32_t get_API_int(cJSON *obj,int32_t val);
uint32_t get_API_uint(cJSON *obj,uint32_t val);
uint64_t get_API_nxt64bits(cJSON *obj);
double get_API_float(cJSON *obj);
char *get_cJSON_fieldname(cJSON *obj);
void ensure_jsonitem(cJSON *json,char *field,char *value);
int32_t in_jsonarray(cJSON *array,char *value);
char *bitcoind_RPC(char **retstrp,char *debugstr,char *url,char *userpass,char *command,char *params);
uint64_t calc_nxt64bits(const char *str);
int32_t expand_nxt64bits(char *str,uint64_t nxt64bits);
char *nxt64str(uint64_t nxt64bits);
char *nxt64str2(uint64_t nxt64bits);
cJSON *addrs_jsonarray(uint64_t *addrs,int32_t num);
int32_t myatoi(char *str,int32_t range);
char *stringifyM(char *str);
#define replace_backslashquotes unstringify
char *unstringify(char *str);
#define jtrue cJSON_CreateTrue
#define jfalse cJSON_CreateFalse
#define jfieldname get_cJSON_fieldname
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -41,12 +41,13 @@ void komodo_eventadd_notarized(struct komodo_state *sp,char *symbol,int32_t heig
struct komodo_event_notarized N;
if ( komodo_verifynotarization(symbol,dest,height,notarizedheight,notarized_hash,notarized_desttxid) != 0 )
{
if ( height > 50000 )
if ( height > 50000 || ASSETCHAINS_SYMBOL[0] != 0 )
printf("[%s] error validating notarization ht.%d notarized_height.%d, if on a pruned %s node this can be ignored\n",ASSETCHAINS_SYMBOL,height,notarizedheight,dest);
}
else
{
//fprintf(stderr,"validated %s ht.%d notarized %d\n",ASSETCHAINS_SYMBOL,height,notarizedheight);
if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 )
fprintf(stderr,"validated [%s] ht.%d notarized %d\n",ASSETCHAINS_SYMBOL,height,notarizedheight);
memset(&N,0,sizeof(N));
N.blockhash = notarized_hash;
N.desttxid = notarized_desttxid;

View File

@@ -52,7 +52,7 @@ uint32_t ASSETCHAINS_MAGIC = 2387029918;
uint64_t ASSETCHAINS_SUPPLY = 10;
uint32_t KOMODO_INITDONE;
char KMDUSERPASS[4096],BTCUSERPASS[4096]; uint16_t BITCOIND_PORT = 7771;
char KMDUSERPASS[4096],BTCUSERPASS[4096]; uint16_t KMD_PORT = 7771,BITCOIND_PORT = 7771;
uint64_t PENDING_KOMODO_TX;
struct komodo_kv *KOMODO_KV;

View File

@@ -13,13 +13,18 @@
* *
******************************************************************************/
#define SATOSHIDEN ((uint64_t)100000000L)
#define dstr(x) ((double)(x) / SATOSHIDEN)
#define KOMODO_INTEREST ((uint64_t)(0.05 * COIN)) // 5%
int64_t MAX_MONEY = 200000000 * 100000000LL;
uint64_t komodo_earned_interest(int32_t height,int64_t paidinterest)
{
static uint64_t *interests; static int32_t maxheight;
uint64_t total; int32_t ind,incr = 100000;
uint64_t total; int32_t ind,incr = 10000;
// need to make interests persistent before 2030, or just hardfork interest/mining rewards disable after MAX_MONEY is exceeded
return(0);
if ( height >= maxheight )
{
if ( interests == 0 )
@@ -36,16 +41,20 @@ uint64_t komodo_earned_interest(int32_t height,int64_t paidinterest)
}
ind = (height << 1);
if ( paidinterest < 0 ) // request
{
return(interests[ind]);
}
else
{
if ( interests[ind + 1] != paidinterest )
if ( interests[ind + 1] != paidinterest ) // need to handle skips like at 80000
{
//fprintf(stderr,"interests.%d %.8f %.8f vs paidinterest %.8f\n",height,dstr(interests[ind]),dstr(interests[ind+1]),dstr(paidinterest));
interests[ind + 1] = paidinterest;
if ( height == 0 )
interests[ind] = interests[ind + 1];
else interests[ind] = interests[ind - 2] + interests[ind + 1];
total = interests[ind];
if ( height <= 1 )
interests[ind] = 0;
else interests[ind] = interests[ind - 2] + interests[ind - 1];
total = interests[ind] + paidinterest;
//fprintf(stderr,"reset interests[height.%d to maxheight.%d] <- %.8f\n",height,maxheight,dstr(total));
for (++height; height<maxheight; height++)
{
ind = (height << 1);
@@ -53,6 +62,7 @@ uint64_t komodo_earned_interest(int32_t height,int64_t paidinterest)
interests[ind + 1] = 0;
}
}
//else fprintf(stderr,"interests.%d %.8f %.8f\n",height,dstr(interests[ind]),dstr(interests[ind+1]));
}
return(0);
}
@@ -64,9 +74,30 @@ uint64_t komodo_moneysupply(int32_t height)
else return(COIN * 100000000 + (height-1) * 3 + komodo_earned_interest(height,-1));
}
uint64_t _komodo_interestnew(uint64_t nValue,uint32_t nLockTime,uint32_t tiptime)
{
int32_t minutes; uint64_t interest = 0;
if ( (minutes= (tiptime - nLockTime) / 60) >= 60 )
{
if ( minutes > 365 * 24 * 60 )
minutes = 365 * 24 * 60;
minutes -= 59;
interest = ((nValue / 10512000) * minutes);
}
return(interest);
}
uint64_t komodo_interestnew(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uint32_t tiptime)
{
uint64_t interest = 0;
if ( komodo_moneysupply(txheight) < MAX_MONEY && nLockTime >= LOCKTIME_THRESHOLD && tiptime != 0 && nLockTime < tiptime && nValue >= 10*COIN )
interest = _komodo_interestnew(nValue,nLockTime,tiptime);
return(interest);
}
uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uint32_t tiptime)
{
int32_t minutes,exception; uint64_t numerator,denominator,interest = 0; uint32_t activation;
int32_t minutes,exception; uint64_t interestnew,numerator,denominator,interest = 0; uint32_t activation;
activation = 1491350400; // 1491350400 5th April
if ( ASSETCHAINS_SYMBOL[0] != 0 )
return(0);
@@ -109,13 +140,24 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin
numerator = (nValue / 20); // assumes 5%!
if ( txheight < 250000 )
interest = (numerator / denominator);
else interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60);
else if ( txheight < 1000000 )
{
interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60);
interestnew = _komodo_interestnew(nValue,nLockTime,tiptime);
if ( interest < interestnew )
printf("path0 current interest %.8f vs new %.8f for ht.%d %.8f locktime.%u tiptime.%u\n",dstr(interest),dstr(interestnew),txheight,dstr(nValue),nLockTime,tiptime);
}
else interest = _komodo_interestnew(nValue,nLockTime,tiptime);
}
else
else if ( txheight < 1000000 )
{
numerator = (nValue * KOMODO_INTEREST);
interest = (numerator / denominator) / COIN;
interestnew = _komodo_interestnew(nValue,nLockTime,tiptime);
if ( interest < interestnew )
printf("path0 current interest %.8f vs new %.8f for ht.%d %.8f locktime.%u tiptime.%u\n",dstr(interest),dstr(interestnew),txheight,dstr(nValue),nLockTime,tiptime);
}
else interest = _komodo_interestnew(nValue,nLockTime,tiptime);
}
else
{
@@ -132,12 +174,16 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin
interest = (numerator / denominator) / COIN;
else interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN;
}
else
else if ( txheight < 1000000 )
{
numerator = (nValue / 20); // assumes 5%!
interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60));
//fprintf(stderr,"interest %llu %.8f <- numerator.%llu minutes.%d\n",(long long)interest,(double)interest/COIN,(long long)numerator,(int32_t)minutes);
interestnew = _komodo_interestnew(nValue,nLockTime,tiptime);
if ( interest < interestnew )//|| (interestnew < 0.9999*interest && (interest-interestnew) > 50000) )
printf("path1 current interest %.8f vs new %.8f for ht.%d %.8f locktime.%u tiptime.%u\n",dstr(interest),dstr(interestnew),txheight,dstr(nValue),nLockTime,tiptime);
}
else interest = _komodo_interestnew(nValue,nLockTime,tiptime);
}
if ( 0 && numerator == (nValue * KOMODO_INTEREST) )
fprintf(stderr,"komodo_interest.%d %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu) prod.%llu\n",txheight,(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator,(long long)(numerator * minutes));

View File

@@ -141,7 +141,7 @@ int32_t Jumblr_depositaddradd(char *depositaddr) // external
{
if ( (retjson= cJSON_Parse(retstr)) != 0 )
{
if ( (ismine= jobj(retjson,(char *)"ismine")) != 0 && is_cJSON_True(ismine) != 0 )
if ( (ismine= jobj(retjson,(char *)"ismine")) != 0 && cJSON_IsTrue(ismine) != 0 )
{
retval = 0;
safecopy(Jumblr_deposit,depositaddr,sizeof(Jumblr_deposit));
@@ -149,7 +149,7 @@ int32_t Jumblr_depositaddradd(char *depositaddr) // external
else
{
retval = JUMBLR_ERROR_NOTINWALLET;
printf("%s not in wallet: ismine.%p %d %s\n",depositaddr,ismine,is_cJSON_True(ismine),jprint(retjson,0));
printf("%s not in wallet: ismine.%p %d %s\n",depositaddr,ismine,cJSON_IsTrue(ismine),jprint(retjson,0));
}
free_json(retjson);
}
@@ -366,7 +366,7 @@ int64_t jumblr_balance(char *addr)
//printf("jumblr.[%s].(%s)\n","KMD",retstr);
if ( (retjson= cJSON_Parse(retstr)) != 0 )
{
if ( (n= cJSON_GetArraySize(retjson)) > 0 && is_cJSON_Array(retjson) != 0 )
if ( (n= cJSON_GetArraySize(retjson)) > 0 && cJSON_IsArray(retjson) != 0 )
for (i=0; i<n; i++)
balance += SATOSHIDEN * jdouble(jitem(retjson,i),(char *)"amount");
free_json(retjson);
@@ -436,7 +436,7 @@ void jumblr_opidupdate(struct jumblr_item *ptr)
{
if ( (retjson= cJSON_Parse(retstr)) != 0 )
{
if ( cJSON_GetArraySize(retjson) == 1 && is_cJSON_Array(retjson) != 0 )
if ( cJSON_GetArraySize(retjson) == 1 && cJSON_IsArray(retjson) != 0 )
{
item = jitem(retjson,0);
//printf("%s\n",jprint(item,0));
@@ -496,6 +496,10 @@ void jumblr_prune(struct jumblr_item *ptr)
}
}
bits256 jbits256(cJSON *json,char *field);
void jumblr_zaddrinit(char *zaddr)
{
struct jumblr_item *ptr; char *retstr,*totalstr; cJSON *item,*array; double total; bits256 txid; char txidstr[65],t_z,z_z;
@@ -508,7 +512,7 @@ void jumblr_zaddrinit(char *zaddr)
if ( (array= cJSON_Parse(retstr)) != 0 )
{
t_z = z_z = 0;
if ( cJSON_GetArraySize(array) == 1 && is_cJSON_Array(array) != 0 )
if ( cJSON_GetArraySize(array) == 1 && cJSON_IsArray(array) != 0 )
{
item = jitem(array,0);
if ( (uint64_t)((total+0.0000000049) * SATOSHIDEN) == (uint64_t)((jdouble(item,(char *)"amount")+0.0000000049) * SATOSHIDEN) )
@@ -559,7 +563,7 @@ void jumblr_opidsupdate()
{
if ( (array= cJSON_Parse(retstr)) != 0 )
{
if ( (n= cJSON_GetArraySize(array)) > 0 && is_cJSON_Array(array) != 0 )
if ( (n= cJSON_GetArraySize(array)) > 0 && cJSON_IsArray(array) != 0 )
{
//printf("%s -> n%d\n",retstr,n);
for (i=0; i<n; i++)
@@ -631,7 +635,7 @@ void jumblr_iteration()
{
if ( (array= cJSON_Parse(retstr)) != 0 )
{
if ( (n= cJSON_GetArraySize(array)) > 0 && is_cJSON_Array(array) != 0 )
if ( (n= cJSON_GetArraySize(array)) > 0 && cJSON_IsArray(array) != 0 )
{
for (i=0; i<n; i++)
jumblr_zaddrinit(jstri(array,i));

View File

@@ -13,6 +13,8 @@
* *
******************************************************************************/
#include "komodo_cJSON.h"
#define KOMODO_MAINNET_START 178999
const char *Notaries_genesis[][2] =
@@ -170,7 +172,7 @@ int32_t komodo_ratify_threshold(int32_t height,uint64_t signedmask)
int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height)
{
int32_t i,htind,n; uint64_t mask = 0; struct knotary_entry *kp,*tmp;
if ( height >= 180000 )
if ( height >= 180000 || ASSETCHAINS_SYMBOL[0] != 0 )
{
n = (int32_t)(sizeof(Notaries_elected)/sizeof(*Notaries_elected));
for (i=0; i<n; i++)
@@ -289,6 +291,8 @@ void komodo_notarized_update(struct komodo_state *sp,int32_t nHeight,int32_t not
printf("komodo_notarized_update REJECT notarized_height %d > %d nHeight\n",notarized_height,nHeight);
return;
}
if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 )
printf("[%s] komodo_notarized_update nHeight.%d notarized_height.%d\n",ASSETCHAINS_SYMBOL,nHeight,notarized_height);
portable_mutex_lock(&komodo_mutex);
sp->NPOINTS = (struct notarized_checkpoint *)realloc(sp->NPOINTS,(sp->NUM_NPOINTS+1) * sizeof(*sp->NPOINTS));
np = &sp->NPOINTS[sp->NUM_NPOINTS++];
@@ -320,26 +324,57 @@ int32_t komodo_notarized_height(uint256 *hashp,uint256 *txidp)
int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp)
{
struct notarized_checkpoint *np = 0; int32_t i; char symbol[16],dest[16]; struct komodo_state *sp;
struct notarized_checkpoint *np = 0; int32_t i=0,flag = 0; char symbol[16],dest[16]; struct komodo_state *sp;
if ( (sp= komodo_stateptr(symbol,dest)) != 0 )
{
if ( sp->NUM_NPOINTS > 0 )
{
for (i=0; i<sp->NUM_NPOINTS; i++)
flag = 0;
if ( sp->last_NPOINTSi < sp->NUM_NPOINTS && sp->last_NPOINTSi > 0 )
{
if ( sp->NPOINTS[i].nHeight >= nHeight )
break;
np = &sp->NPOINTS[i];
np = &sp->NPOINTS[sp->last_NPOINTSi-1];
if ( np->nHeight < nHeight )
{
for (i=sp->last_NPOINTSi; i<sp->NUM_NPOINTS; i++)
{
if ( sp->NPOINTS[i].nHeight >= nHeight )
{
//printf("flag.1 i.%d np->ht %d [%d].ht %d >= nHeight.%d, last.%d num.%d\n",i,np->nHeight,i,sp->NPOINTS[i].nHeight,nHeight,sp->last_NPOINTSi,sp->NUM_NPOINTS);
flag = 1;
break;
}
np = &sp->NPOINTS[i];
sp->last_NPOINTSi = i;
}
}
}
if ( flag == 0 )
{
np = 0;
for (i=0; i<sp->NUM_NPOINTS; i++)
{
if ( sp->NPOINTS[i].nHeight >= nHeight )
{
//printf("i.%d np->ht %d [%d].ht %d >= nHeight.%d\n",i,np->nHeight,i,sp->NPOINTS[i].nHeight,nHeight);
break;
}
np = &sp->NPOINTS[i];
sp->last_NPOINTSi = i;
}
}
}
if ( np != 0 )
{
//char str[65],str2[65]; printf("[%s] notarized_ht.%d\n",ASSETCHAINS_SYMBOL,np->notarized_height);
if ( np->nHeight >= nHeight || (i < sp->NUM_NPOINTS && np[1].nHeight < nHeight) )
printf("warning: flag.%d i.%d np->ht %d [1].ht %d >= nHeight.%d\n",flag,i,np->nHeight,np[1].nHeight,nHeight);
*notarized_hashp = np->notarized_hash;
*notarized_desttxidp = np->notarized_desttxid;
return(np->notarized_height);
}
}
memset(notarized_hashp,0,sizeof(*notarized_hashp));
memset(notarized_desttxidp,0,sizeof(*notarized_desttxidp));
return(0);
}

View File

@@ -233,7 +233,7 @@ int32_t komodo_pax_opreturn(int32_t height,uint8_t *opret,int32_t maxsize)
{
static uint32_t lastcrc;
FILE *fp; char fname[512]; uint32_t crc32,check,timestamp; int32_t i,n=0,retval,fsize,len=0; uint8_t data[8192];
#ifdef WIN32
#ifdef _WIN32
sprintf(fname,"%s\\%s",GetDataDir(false).string().c_str(),(char *)"komodofeed");
#else
sprintf(fname,"%s/%s",GetDataDir(false).string().c_str(),(char *)"komodofeed");
@@ -638,7 +638,11 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin
if ( ASSETCHAINS_SYMBOL[0] == 0 && chainActive.Tip() != 0 && height > chainActive.Tip()->nHeight )
{
if ( height < 100000000 )
printf("komodo_paxprice height.%d vs tip.%d\n",height,chainActive.Tip()->nHeight);
{
static uint32_t counter;
if ( counter++ < 3 )
printf("komodo_paxprice height.%d vs tip.%d\n",height,chainActive.Tip()->nHeight);
}
return(0);
}
*seedp = komodo_seed(height);

View File

@@ -16,7 +16,7 @@
#include "uthash.h"
#include "utlist.h"
/*#ifdef WIN32
/*#ifdef _WIN32
#define PACKED
#else
#define PACKED __attribute__((packed))
@@ -84,7 +84,7 @@ struct komodo_state
int32_t SAVEDHEIGHT,CURRENT_HEIGHT,NOTARIZED_HEIGHT;
uint32_t SAVEDTIMESTAMP;
uint64_t deposited,issued,withdrawn,approved,redeemed,shorted;
struct notarized_checkpoint *NPOINTS; int32_t NUM_NPOINTS;
struct notarized_checkpoint *NPOINTS; int32_t NUM_NPOINTS,last_NPOINTSi;
struct komodo_event **Komodo_events; int32_t Komodo_numevents;
uint32_t RTbufs[64][3]; uint64_t RTmask;
};

View File

@@ -1261,9 +1261,9 @@ void iguana_initQ(queue_t *Q,char *name)
free(item);
}
void komodo_userpass(char *username,char *password,FILE *fp)
uint16_t komodo_userpass(char *username,char *password,FILE *fp)
{
char *rpcuser,*rpcpassword,*str,line[8192];
char *rpcuser,*rpcpassword,*str,line[8192]; uint16_t port = 0;
rpcuser = rpcpassword = 0;
username[0] = password[0] = 0;
while ( fgets(line,sizeof(line),fp) != 0 )
@@ -1275,6 +1275,11 @@ void komodo_userpass(char *username,char *password,FILE *fp)
rpcuser = parse_conf_line(str,(char *)"rpcuser");
else if ( (str= strstr(line,(char *)"rpcpassword")) != 0 )
rpcpassword = parse_conf_line(str,(char *)"rpcpassword");
else if ( (str= strstr(line,(char *)"rpcport")) != 0 )
{
port = atoi(parse_conf_line(str,(char *)"rpcport"));
//printf("rpcport.%u in file\n",port);
}
}
if ( rpcuser != 0 && rpcpassword != 0 )
{
@@ -1286,6 +1291,7 @@ void komodo_userpass(char *username,char *password,FILE *fp)
free(rpcuser);
if ( rpcpassword != 0 )
free(rpcpassword);
return(port);
}
void komodo_statefname(char *fname,char *symbol,char *str)
@@ -1305,7 +1311,7 @@ void komodo_statefname(char *fname,char *symbol,char *str)
}
else
{
#ifdef WIN32
#ifdef _WIN32
strcat(fname,"\\");
#else
strcat(fname,"/");
@@ -1315,7 +1321,7 @@ void komodo_statefname(char *fname,char *symbol,char *str)
{
strcat(fname,symbol);
//printf("statefname.(%s) -> (%s)\n",symbol,fname);
#ifdef WIN32
#ifdef _WIN32
strcat(fname,"\\");
#else
strcat(fname,"/");
@@ -1328,7 +1334,7 @@ void komodo_statefname(char *fname,char *symbol,char *str)
void komodo_configfile(char *symbol,uint16_t port)
{
static char myusername[512],mypassword[8192];
FILE *fp; uint8_t buf2[33]; char fname[512],buf[128],username[512],password[8192]; uint32_t crc,r,r2,i;
FILE *fp; uint16_t kmdport; uint8_t buf2[33]; char fname[512],buf[128],username[512],password[8192]; uint32_t crc,r,r2,i;
if ( symbol != 0 && port != 0 )
{
r = (uint32_t)time(NULL);
@@ -1347,7 +1353,7 @@ void komodo_configfile(char *symbol,uint16_t port)
password[i*2] = 0;
sprintf(buf,"%s.conf",symbol);
BITCOIND_PORT = port;
#ifdef WIN32
#ifdef _WIN32
sprintf(fname,"%s\\%s",GetDataDir(false).string().c_str(),buf);
#else
sprintf(fname,"%s/%s",GetDataDir(false).string().c_str(),buf);
@@ -1371,7 +1377,7 @@ void komodo_configfile(char *symbol,uint16_t port)
}
}
strcpy(fname,GetDataDir().string().c_str());
#ifdef WIN32
#ifdef _WIN32
while ( fname[strlen(fname)-1] != '\\' )
fname[strlen(fname)-1] = 0;
strcat(fname,"komodo.conf");
@@ -1386,16 +1392,17 @@ void komodo_configfile(char *symbol,uint16_t port)
#endif
if ( (fp= fopen(fname,"rb")) != 0 )
{
komodo_userpass(username,password,fp);
if ( (kmdport= komodo_userpass(username,password,fp)) != 0 )
KMD_PORT = kmdport;
sprintf(KMDUSERPASS,"%s:%s",username,password);
fclose(fp);
//printf("KOMODO.(%s) -> userpass.(%s)\n",fname,KMDUSERPASS);
} else printf("couldnt open.(%s)\n",fname);
}
int32_t komodo_userpass(char *userpass,char *symbol)
uint16_t komodo_userpass(char *userpass,char *symbol)
{
FILE *fp; char fname[512],username[512],password[512],confname[16];
FILE *fp; uint16_t port = 0; char fname[512],username[512],password[512],confname[16];
userpass[0] = 0;
if ( strcmp("KMD",symbol) == 0 )
{
@@ -1409,12 +1416,12 @@ int32_t komodo_userpass(char *userpass,char *symbol)
komodo_statefname(fname,symbol,confname);
if ( (fp= fopen(fname,"rb")) != 0 )
{
komodo_userpass(username,password,fp);
port = komodo_userpass(username,password,fp);
sprintf(userpass,"%s:%s",username,password);
fclose(fp);
return((int32_t)strlen(userpass));
}
return(-1);
return(port);
}
uint32_t komodo_assetmagic(char *symbol,uint64_t supply)
@@ -1507,17 +1514,17 @@ void komodo_args(char *argv0)
KOMODO_PAX = 1;
} else KOMODO_PAX = GetArg("-pax",0);
name = GetArg("-ac_name","");
if ( argv0 != 0 )
{
len = (int32_t)strlen(argv0);
for (i=0; i<sizeof(argv0suffix)/sizeof(*argv0suffix); i++)
{
n = (int32_t)strlen(argv0suffix[i]);
if ( strcmp(&argv0[len - n],argv0suffix[i]) == 0 )
{
printf("ARGV0.(%s) -> matches suffix (%s) -> ac_name.(%s)\n",argv0,argv0suffix[i],argv0names[i]);
name = argv0names[i];
break;
if ( argv0 != 0 )
{
len = (int32_t)strlen(argv0);
for (i=0; i<sizeof(argv0suffix)/sizeof(*argv0suffix); i++)
{
n = (int32_t)strlen(argv0suffix[i]);
if ( strcmp(&argv0[len - n],argv0suffix[i]) == 0 )
{
//printf("ARGV0.(%s) -> matches suffix (%s) -> ac_name.(%s)\n",argv0,argv0suffix[i],argv0names[i]);
name = argv0names[i];
break;
}
}
}
@@ -1576,12 +1583,12 @@ void komodo_args(char *argv0)
for (iter=0; iter<2; iter++)
{
strcpy(fname,GetDataDir().string().c_str());
#ifdef WIN32
#ifdef _WIN32
while ( fname[strlen(fname)-1] != '\\' )
fname[strlen(fname)-1] = 0;
if ( iter == 0 )
strcat(fname,".komodo\\komodo.conf");
else strcat(fname,".bitcoin\\bitcoin.conf");
strcat(fname,"Komodo\\komodo.conf");
else strcat(fname,"Bitcoin\\bitcoin.conf");
#else
while ( fname[strlen(fname)-1] != '/' )
fname[strlen(fname)-1] = 0;

View File

@@ -2365,7 +2365,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
return false;
control.Add(vChecks);
}
komodo_earned_interest(pindex->nHeight,sum);
if ( ASSETCHAINS_SYMBOL[0] == 0 )
komodo_earned_interest(pindex->nHeight,sum);
CTxUndo undoDummy;
if (i > 0) {
blockundo.vtxundo.push_back(CTxUndo());

View File

@@ -411,7 +411,7 @@ void ThreadShowMetricsScreen()
// Get current window size
if (isTTY) {
#ifdef WIN32
#ifdef _WIN32
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
cols = csbi.srWindow.Right - csbi.srWindow.Left + 1;
@@ -421,7 +421,7 @@ void ThreadShowMetricsScreen()
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) != -1 && w.ws_col != 0) {
cols = w.ws_col;
}
#endif
#endif
}
if (isScreen) {

View File

@@ -17,7 +17,7 @@
#include "ui_interface.h"
#include "crypto/common.h"
#ifdef WIN32
#ifdef _WIN32
#include <string.h>
#else
#include <fcntl.h>
@@ -42,7 +42,7 @@
// Fix for ancient MinGW versions, that don't have defined these in ws2tcpip.h.
// Todo: Can be removed when our pull-tester is upgraded to a modern MinGW version.
#ifdef WIN32
#ifdef _WIN32
#ifndef PROTECTION_LEVEL_UNRESTRICTED
#define PROTECTION_LEVEL_UNRESTRICTED 10
#endif
@@ -930,7 +930,7 @@ static void AcceptConnection(const ListenSocket& hListenSocket) {
// According to the internet TCP_NODELAY is not carried into accepted sockets
// on all platforms. Set it again here just to be sure.
int set = 1;
#ifdef WIN32
#ifdef _WIN32
setsockopt(hSocket, IPPROTO_TCP, TCP_NODELAY, (const char*)&set, sizeof(int));
#else
setsockopt(hSocket, IPPROTO_TCP, TCP_NODELAY, (void*)&set, sizeof(int));
@@ -1727,7 +1727,7 @@ bool BindListenPort(const CService &addrBind, string& strError, bool fWhiteliste
}
#ifndef WIN32
#ifndef _WIN32
#ifdef SO_NOSIGPIPE
// Different way of disabling SIGPIPE on BSD
setsockopt(hListenSocket, SOL_SOCKET, SO_NOSIGPIPE, (void*)&nOne, sizeof(int));
@@ -1753,13 +1753,13 @@ bool BindListenPort(const CService &addrBind, string& strError, bool fWhiteliste
// and enable it by default or not. Try to enable it, if possible.
if (addrBind.IsIPv6()) {
#ifdef IPV6_V6ONLY
#ifdef WIN32
#ifdef _WIN32
setsockopt(hListenSocket, IPPROTO_IPV6, IPV6_V6ONLY, (const char*)&nOne, sizeof(int));
#else
setsockopt(hListenSocket, IPPROTO_IPV6, IPV6_V6ONLY, (void*)&nOne, sizeof(int));
#endif
#endif
#ifdef WIN32
#ifdef _WIN32
int nProtLevel = PROTECTION_LEVEL_UNRESTRICTED;
setsockopt(hListenSocket, IPPROTO_IPV6, IPV6_PROTECTION_LEVEL, (const char*)&nProtLevel, sizeof(int));
#endif
@@ -1800,7 +1800,7 @@ void static Discover(boost::thread_group& threadGroup)
if (!fDiscover)
return;
#ifdef WIN32
#ifdef _WIN32
// Get local host IP
char pszHostName[256] = "";
if (gethostname(pszHostName, sizeof(pszHostName)) != SOCKET_ERROR)
@@ -1945,7 +1945,7 @@ public:
delete pnodeLocalHost;
pnodeLocalHost = NULL;
#ifdef WIN32
#ifdef _WIN32
// Shutdown Windows Sockets
WSACleanup();
#endif

View File

@@ -22,7 +22,7 @@
#include <deque>
#include <stdint.h>
#ifndef WIN32
#ifndef _WIN32
#include <arpa/inet.h>
#endif

View File

@@ -26,7 +26,7 @@
#include <netdb.h>
#endif
#ifndef WIN32
#ifndef _WIN32
#if HAVE_INET_PTON
#include <arpa/inet.h>
#endif
@@ -129,7 +129,7 @@ bool static LookupIntern(const char *pszName, std::vector<CNetAddr>& vIP, unsign
aiHint.ai_socktype = SOCK_STREAM;
aiHint.ai_protocol = IPPROTO_TCP;
aiHint.ai_family = AF_UNSPEC;
#ifdef WIN32
#ifdef _WIN32
aiHint.ai_flags = fAllowLookup ? 0 : AI_NUMERICHOST;
#else
aiHint.ai_flags = fAllowLookup ? AI_ADDRCONFIG : AI_NUMERICHOST;
@@ -454,7 +454,7 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe
#endif
//Disable Nagle's algorithm
#ifdef WIN32
#ifdef _WIN32
setsockopt(hSocket, IPPROTO_TCP, TCP_NODELAY, (const char*)&set, sizeof(int));
#else
setsockopt(hSocket, IPPROTO_TCP, TCP_NODELAY, (void*)&set, sizeof(int));
@@ -488,7 +488,7 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe
return false;
}
socklen_t nRetSize = sizeof(nRet);
#ifdef WIN32
#ifdef _WIN32
if (getsockopt(hSocket, SOL_SOCKET, SO_ERROR, (char*)(&nRet), &nRetSize) == SOCKET_ERROR)
#else
if (getsockopt(hSocket, SOL_SOCKET, SO_ERROR, &nRet, &nRetSize) == SOCKET_ERROR)
@@ -505,7 +505,7 @@ bool static ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRe
return false;
}
}
#ifdef WIN32
#ifdef _WIN32
else if (WSAGetLastError() != WSAEISCONN)
#else
else
@@ -1348,7 +1348,7 @@ bool operator<(const CSubNet& a, const CSubNet& b)
return (a.network < b.network || (a.network == b.network && memcmp(a.netmask, b.netmask, 16) < 0));
}
#ifdef WIN32
#ifdef _WIN32
std::string NetworkErrorString(int err)
{
char buf[256];
@@ -1386,7 +1386,7 @@ bool CloseSocket(SOCKET& hSocket)
{
if (hSocket == INVALID_SOCKET)
return false;
#ifdef WIN32
#ifdef _WIN32
int ret = closesocket(hSocket);
#else
int ret = close(hSocket);
@@ -1398,7 +1398,7 @@ bool CloseSocket(SOCKET& hSocket)
bool SetSocketNonBlocking(SOCKET& hSocket, bool fNonBlocking)
{
if (fNonBlocking) {
#ifdef WIN32
#ifdef _WIN32
u_long nOne = 1;
if (ioctlsocket(hSocket, FIONBIO, &nOne) == SOCKET_ERROR) {
#else
@@ -1409,7 +1409,7 @@ bool SetSocketNonBlocking(SOCKET& hSocket, bool fNonBlocking)
return false;
}
} else {
#ifdef WIN32
#ifdef _WIN32
u_long nZero = 0;
if (ioctlsocket(hSocket, FIONBIO, &nZero) == SOCKET_ERROR) {
#else

View File

@@ -22,7 +22,7 @@ extern bool fNameLookup;
/** -timeout default */
static const int DEFAULT_CONNECT_TIMEOUT = 5000;
#ifdef WIN32
#ifdef _WIN32
// In MSVC, this is defined as a macro, undefine it to prevent a compile and link error
#undef SetPort
#endif

View File

@@ -12,7 +12,10 @@
#include "serialize.h"
#include "uint256.h"
#include "consensus/consensus.h"
#ifndef __APPLE__
#include <stdint.h>
#endif
#include <boost/array.hpp>

View File

@@ -8,7 +8,7 @@
#include "util.h"
#include "utilstrencodings.h"
#ifndef WIN32
#ifndef _WIN32
# include <arpa/inet.h>
#endif

View File

@@ -6,7 +6,7 @@
#include "random.h"
#include "support/cleanse.h"
#ifdef WIN32
#ifdef _WIN32
#include "compat.h" // for Windows API
#endif
#include "serialize.h" // for begin_ptr(vec)
@@ -15,7 +15,7 @@
#include <limits>
#ifndef WIN32
#ifndef _WIN32
#include <sys/time.h>
#endif
@@ -24,7 +24,7 @@
static inline int64_t GetPerformanceCounter()
{
int64_t nCounter = 0;
#ifdef WIN32
#ifdef _WIN32
QueryPerformanceCounter((LARGE_INTEGER*)&nCounter);
#else
timeval t;

View File

@@ -8,7 +8,7 @@
#include "config/bitcoin-config.h"
#endif
#ifdef WIN32
#ifdef _WIN32
#ifdef _WIN32_WINNT
#undef _WIN32_WINNT
#endif
@@ -49,7 +49,7 @@ static inline size_t GetSystemPageSize()
bool MemoryPageLocker::Lock(const void* addr, size_t len)
{
#ifdef WIN32
#ifdef _WIN32
return VirtualLock(const_cast<void*>(addr), len) != 0;
#else
return mlock(addr, len) == 0;
@@ -58,7 +58,7 @@ bool MemoryPageLocker::Lock(const void* addr, size_t len)
bool MemoryPageLocker::Unlock(const void* addr, size_t len)
{
#ifdef WIN32
#ifdef _WIN32
return VirtualUnlock(const_cast<void*>(addr), len) != 0;
#else
return munlock(addr, len) == 0;

View File

@@ -340,7 +340,7 @@ BOOST_AUTO_TEST_CASE(AlertNotify)
// Windows built-in echo semantics are different than posixy shells. Quotes and
// whitespace are printed literally.
#ifndef WIN32
#ifndef _WIN32
BOOST_CHECK_EQUAL(r[0], "Alert 1");
BOOST_CHECK_EQUAL(r[1], "Alert 2, cancels 1");
BOOST_CHECK_EQUAL(r[2], "Alert 2, cancels 1");

View File

@@ -23,7 +23,7 @@
#include <pthread_np.h>
#endif
#ifndef WIN32
#ifndef _WIN32
// for posix_fallocate
#ifdef __linux__
@@ -335,7 +335,7 @@ void ParseParameters(int argc, const char* const argv[])
strValue = str.substr(is_index+1);
str = str.substr(0, is_index);
}
#ifdef WIN32
#ifdef _WIN32
boost::to_lower(str);
if (boost::algorithm::starts_with(str, "/"))
str = "-" + str.substr(1);
@@ -419,7 +419,7 @@ std::string HelpMessageOpt(const std::string &option, const std::string &message
static std::string FormatException(const std::exception* pex, const char* pszThread)
{
#ifdef WIN32
#ifdef _WIN32
char pszModule[MAX_PATH] = "";
GetModuleFileNameA(NULL, pszModule, sizeof(pszModule));
#else
@@ -455,7 +455,7 @@ boost::filesystem::path GetDefaultDataDir()
// Windows >= Vista: C:\Users\Username\AppData\Roaming\Zcash
// Mac: ~/Library/Application Support/Zcash
// Unix: ~/.zcash
#ifdef WIN32
#ifdef _WIN32
// Windows
if ( symbol[0] == 0 )
return GetSpecialFolderPath(CSIDL_APPDATA) / "Komodo";
@@ -502,7 +502,7 @@ static boost::filesystem::path ZC_GetBaseParamsDir()
// Windows >= Vista: C:\Users\Username\AppData\Roaming\ZcashParams
// Mac: ~/Library/Application Support/ZcashParams
// Unix: ~/.zcash-params
#ifdef WIN32
#ifdef _WIN32
// Windows
return GetSpecialFolderPath(CSIDL_APPDATA) / "ZcashParams";
#else
@@ -648,7 +648,7 @@ void ReadConfigFile(map<string, string>& mapSettingsRet,
//fprintf(stderr,"from conf file %s RPC %u, used to be %u\n",ASSETCHAINS_SYMBOL,BITCOIND_PORT,BITCOIND_PORT);
}
#ifndef WIN32
#ifndef _WIN32
boost::filesystem::path GetPidFile()
{
boost::filesystem::path pathPidFile(GetArg("-pid", "komodod.pid"));
@@ -669,13 +669,13 @@ void CreatePidFile(const boost::filesystem::path &path, pid_t pid)
bool RenameOver(boost::filesystem::path src, boost::filesystem::path dest)
{
#ifdef WIN32
#ifdef _WIN32
return MoveFileExA(src.string().c_str(), dest.string().c_str(),
MOVEFILE_REPLACE_EXISTING) != 0;
#else
int rc = std::rename(src.string().c_str(), dest.string().c_str());
return (rc == 0);
#endif /* WIN32 */
#endif /* _WIN32 */
}
/**
@@ -700,7 +700,7 @@ bool TryCreateDirectory(const boost::filesystem::path& p)
void FileCommit(FILE *fileout)
{
fflush(fileout); // harmless if redundantly called
#ifdef WIN32
#ifdef _WIN32
HANDLE hFile = (HANDLE)_get_osfhandle(_fileno(fileout));
FlushFileBuffers(hFile);
#else
@@ -815,7 +815,7 @@ void ShrinkDebugFile()
fclose(file);
}
#ifdef WIN32
#ifdef _WIN32
boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate)
{
namespace fs = boost::filesystem;
@@ -838,7 +838,7 @@ boost::filesystem::path GetTempPath() {
#else
// TODO: remove when we don't support filesystem v2 anymore
boost::filesystem::path path;
#ifdef WIN32
#ifdef _WIN32
char pszPath[MAX_PATH] = "";
if (GetTempPathA(MAX_PATH, pszPath))
@@ -898,7 +898,7 @@ void SetupEnvironment()
bool SetupNetworking()
{
#ifdef WIN32
#ifdef _WIN32
// Initialize Windows Sockets
WSADATA wsadata;
int ret = WSAStartup(MAKEWORD(2,2), &wsadata);
@@ -910,15 +910,15 @@ bool SetupNetworking()
void SetThreadPriority(int nPriority)
{
#ifdef WIN32
#ifdef _WIN32
SetThreadPriority(GetCurrentThread(), nPriority);
#else // WIN32
#else // _WIN32
#ifdef PRIO_THREAD
setpriority(PRIO_THREAD, 0, nPriority);
#else // PRIO_THREAD
setpriority(PRIO_PROCESS, 0, nPriority);
#endif // PRIO_THREAD
#endif // WIN32
#endif // _WIN32
}
std::string PrivacyInfo()

View File

@@ -124,7 +124,7 @@ boost::filesystem::path GetDefaultDataDir();
const boost::filesystem::path &GetDataDir(bool fNetSpecific = true);
void ClearDatadirCache();
boost::filesystem::path GetConfigFile();
#ifndef WIN32
#ifndef _WIN32
boost::filesystem::path GetPidFile();
void CreatePidFile(const boost::filesystem::path &path, pid_t pid);
#endif
@@ -133,7 +133,7 @@ public:
missing_zcash_conf() : std::runtime_error("Missing komodo.conf") { }
};
void ReadConfigFile(std::map<std::string, std::string>& mapSettingsRet, std::map<std::string, std::vector<std::string> >& mapMultiSettingsRet);
#ifdef WIN32
#ifdef _WIN32
boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate = true);
#endif
boost::filesystem::path GetTempPath();
@@ -150,7 +150,7 @@ std::string LicenseInfo();
inline bool IsSwitchChar(char c)
{
#ifdef WIN32
#ifdef _WIN32
return c == '-' || c == '/';
#else
return c == '-';

View File

@@ -13,7 +13,7 @@
#include <stdint.h>
#ifndef WIN32
#ifndef _WIN32
#include <sys/stat.h>
#endif

View File

@@ -2202,7 +2202,7 @@ CAmount CWallet::GetImmatureWatchOnlyBalance() const
/**
* populate vCoins with vector of available COutputs.
*/
uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uint32_t tiptime);
uint64_t komodo_interestnew(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uint32_t tiptime);
uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 hash,int32_t n,int32_t checkheight,uint64_t checkvalue);
void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const CCoinControl *coinControl, bool fIncludeZeroValue, bool fIncludeCoinBase) const
@@ -2250,9 +2250,9 @@ void CWallet::AvailableCoins(vector<COutput>& vCoins, bool fOnlyConfirmed, const
komodo_accrued_interest(&txheight,&locktime,wtxid,i,0,pcoin->vout[i].nValue);
if ( (tipindex= chainActive.Tip()) != 0 )
{
interest = komodo_interest(txheight,pcoin->vout[i].nValue,locktime,tipindex->nTime);
interest = komodo_interestnew(txheight,pcoin->vout[i].nValue,locktime,tipindex->nTime);
} else interest = 0;
//interest = komodo_interest(chainActive.Tip()->nHeight+1,pcoin->vout[i].nValue,pcoin->nLockTime,chainActive.Tip()->nTime);
//interest = komodo_interestnew(chainActive.Tip()->nHeight+1,pcoin->vout[i].nValue,pcoin->nLockTime,chainActive.Tip()->nTime);
if ( interest != 0 )
{
//printf("wallet nValueRet %.8f += interest %.8f ht.%d lock.%u/%u tip.%u\n",(double)pcoin->vout[i].nValue/COIN,(double)interest/COIN,txheight,locktime,pcoin->nLockTime,tipindex->nTime);
@@ -2333,13 +2333,12 @@ static void ApproximateBestSubset(vector<pair<CAmount, pair<const CWalletTx*,uns
}
}
bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int nConfTheirs, vector<COutput> vCoins,set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, CAmount& nValueRet, uint64_t *interestp) const
bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int nConfTheirs, vector<COutput> vCoins,set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, CAmount& nValueRet) const
{
uint64_t interests[10000],lowest_interest = 0; int32_t count = 0;
int32_t count = 0; //uint64_t lowest_interest = 0;
setCoinsRet.clear();
memset(interests,0,sizeof(interests));
//memset(interests,0,sizeof(interests));
nValueRet = 0;
//*interestp = 0;
// List of values less than target
pair<CAmount, pair<const CWalletTx*,unsigned int> > coinLowestLarger;
coinLowestLarger.first = std::numeric_limits<CAmount>::max();
@@ -2368,20 +2367,20 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int
{
setCoinsRet.insert(coin.second);
nValueRet += coin.first;
if ( KOMODO_EXCHANGEWALLET == 0 )
*interestp += pcoin->vout[i].interest;
//if ( KOMODO_EXCHANGEWALLET == 0 )
// *interestp += pcoin->vout[i].interest;
return true;
}
else if (n < nTargetValue + CENT)
{
vValue.push_back(coin);
nTotalLower += n;
if ( KOMODO_EXCHANGEWALLET == 0 && count < sizeof(interests)/sizeof(*interests) )
{
//if ( KOMODO_EXCHANGEWALLET == 0 && count < sizeof(interests)/sizeof(*interests) )
//{
//fprintf(stderr,"count.%d %.8f\n",count,(double)pcoin->vout[i].interest/COIN);
interests[count++] = pcoin->vout[i].interest;
}
if ( count >= sizeof(interests)/sizeof(*interests) && nTotalLower > 2*nTargetValue + CENT )
//interests[count++] = pcoin->vout[i].interest;
//}
if ( nTotalLower > 4*nTargetValue + CENT )
{
//fprintf(stderr,"why bother with all the utxo if we have double what is needed?\n");
break;
@@ -2390,8 +2389,8 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int
else if (n < coinLowestLarger.first)
{
coinLowestLarger = coin;
if ( KOMODO_EXCHANGEWALLET == 0 )
lowest_interest = pcoin->vout[i].interest;
//if ( KOMODO_EXCHANGEWALLET == 0 )
// lowest_interest = pcoin->vout[i].interest;
}
}
@@ -2401,8 +2400,8 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int
{
setCoinsRet.insert(vValue[i].second);
nValueRet += vValue[i].first;
if ( KOMODO_EXCHANGEWALLET == 0 && i < count )
*interestp += interests[i];
//if ( KOMODO_EXCHANGEWALLET == 0 && i < count )
// *interestp += interests[i];
}
return true;
}
@@ -2413,8 +2412,8 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int
return false;
setCoinsRet.insert(coinLowestLarger.second);
nValueRet += coinLowestLarger.first;
if ( KOMODO_EXCHANGEWALLET == 0 )
*interestp += lowest_interest;
//if ( KOMODO_EXCHANGEWALLET == 0 )
// *interestp += lowest_interest;
return true;
}
@@ -2434,8 +2433,8 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int
{
setCoinsRet.insert(coinLowestLarger.second);
nValueRet += coinLowestLarger.first;
if ( KOMODO_EXCHANGEWALLET == 0 )
*interestp += lowest_interest;
//if ( KOMODO_EXCHANGEWALLET == 0 )
// *interestp += lowest_interest;
}
else {
for (unsigned int i = 0; i < vValue.size(); i++)
@@ -2443,8 +2442,8 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int
{
setCoinsRet.insert(vValue[i].second);
nValueRet += vValue[i].first;
if ( KOMODO_EXCHANGEWALLET == 0 && i < count )
*interestp += interests[i];
//if ( KOMODO_EXCHANGEWALLET == 0 && i < count )
// *interestp += interests[i];
}
LogPrint("selectcoins", "SelectCoins() best subset: ");
@@ -2457,15 +2456,15 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int
return true;
}
bool CWallet::SelectCoins(const CAmount& nTargetValue, set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, CAmount& nValueRet, bool& fOnlyCoinbaseCoinsRet, bool& fNeedCoinbaseCoinsRet, const CCoinControl* coinControl,uint64_t *interestp) const
bool CWallet::SelectCoins(const CAmount& nTargetValue, set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, CAmount& nValueRet, bool& fOnlyCoinbaseCoinsRet, bool& fNeedCoinbaseCoinsRet, const CCoinControl* coinControl) const
{
// Output parameter fOnlyCoinbaseCoinsRet is set to true when the only available coins are coinbase utxos.
uint64_t tmp,interest = 0; int32_t retval;
if ( interestp == 0 )
{
interestp = &tmp;
*interestp = 0;
}
uint64_t tmp; int32_t retval;
//if ( interestp == 0 )
//{
// interestp = &tmp;
// *interestp = 0;
//}
vector<COutput> vCoinsNoCoinbase, vCoinsWithCoinbase;
AvailableCoins(vCoinsNoCoinbase, true, coinControl, false, false);
AvailableCoins(vCoinsWithCoinbase, true, coinControl, false, true);
@@ -2507,8 +2506,8 @@ bool CWallet::SelectCoins(const CAmount& nTargetValue, set<pair<const CWalletTx*
if (!out.fSpendable)
continue;
nValueRet += out.tx->vout[out.i].nValue;
if ( KOMODO_EXCHANGEWALLET == 0 )
*interestp += out.tx->vout[out.i].interest;
//if ( KOMODO_EXCHANGEWALLET == 0 )
// *interestp += out.tx->vout[out.i].interest;
setCoinsRet.insert(make_pair(out.tx, out.i));
}
return (nValueRet >= nTargetValue);
@@ -2548,36 +2547,16 @@ bool CWallet::SelectCoins(const CAmount& nTargetValue, set<pair<const CWalletTx*
retval = false;
if ( nTargetValue <= nValueFromPresetInputs )
retval = true;
else if ( SelectCoinsMinConf(nTargetValue, 1, 6, vCoins, setCoinsRet, nValueRet,&interest) != 0 )
{
*interestp += interest;
else if ( SelectCoinsMinConf(nTargetValue, 1, 6, vCoins, setCoinsRet, nValueRet) != 0 )
retval = true;
}
else if ( SelectCoinsMinConf(nTargetValue, 1, 1, vCoins, setCoinsRet, nValueRet,&interest) != 0 )
{
*interestp += interest;
else if ( SelectCoinsMinConf(nTargetValue, 1, 1, vCoins, setCoinsRet, nValueRet) != 0 )
retval = true;
}
else if ( bSpendZeroConfChange && SelectCoinsMinConf(nTargetValue, 0, 1, vCoins, setCoinsRet, nValueRet,&interest) != 0 )
{
*interestp += interest;
else if ( bSpendZeroConfChange && SelectCoinsMinConf(nTargetValue, 0, 1, vCoins, setCoinsRet, nValueRet) != 0 )
retval = true;
}
//return (SelectCoinsMinConf(nTargetValue, 1, 6, vCoins, setCoinsRet, nValueRet,interestp) ||
// SelectCoinsMinConf(nTargetValue, 1, 1, vCoins, setCoinsRet, nValueRet,interestp) ||
// (bSpendZeroConfChange && SelectCoinsMinConf(nTargetValue, 0, 1, vCoins, setCoinsRet, nValueRet,interestp)));
/*bool res = nTargetValue <= nValueFromPresetInputs ||
SelectCoinsMinConf(nTargetValue - nValueFromPresetInputs, 1, 6, vCoins, setCoinsRet, nValueRet) ||
SelectCoinsMinConf(nTargetValue - nValueFromPresetInputs, 1, 1, vCoins, setCoinsRet, nValueRet) ||
(bSpendZeroConfChange && SelectCoinsMinConf(nTargetValue - nValueFromPresetInputs, 0, 1, vCoins, setCoinsRet, nValueRet));*/
// because SelectCoinsMinConf clears the setCoinsRet, we now add the possible inputs to the coinset
setCoinsRet.insert(setPresetCoins.begin(), setPresetCoins.end());
// add preset inputs to the total value selected
nValueRet += nValueFromPresetInputs;
return retval;
}
@@ -2627,7 +2606,7 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount &nFeeRet, int& nC
bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, CAmount& nFeeRet,
int& nChangePosRet, std::string& strFailReason, const CCoinControl* coinControl, bool sign)
{
uint64_t interest2,interest = 0; CAmount nValue = 0; unsigned int nSubtractFeeFromAmount = 0;
uint64_t interest2 = 0; CAmount nValue = 0; unsigned int nSubtractFeeFromAmount = 0;
BOOST_FOREACH (const CRecipient& recipient, vecSend)
{
if (nValue < 0 || recipient.nAmount < 0)
@@ -2684,7 +2663,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
nFeeRet = 0;
while (true)
{
interest = 0;
//interest = 0;
txNew.vin.clear();
txNew.vout.clear();
wtxNew.fFromMe = true;
@@ -2733,7 +2712,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
bool fOnlyCoinbaseCoins = false;
bool fNeedCoinbaseCoins = false;
interest2 = 0;
if (!SelectCoins(nTotalValue, setCoins, nValueIn, fOnlyCoinbaseCoins, fNeedCoinbaseCoins, coinControl,&interest))
if (!SelectCoins(nTotalValue, setCoins, nValueIn, fOnlyCoinbaseCoins, fNeedCoinbaseCoins, coinControl))
{
if (fOnlyCoinbaseCoins && Params().GetConsensus().fCoinbaseMustBeProtected) {
strFailReason = _("Coinbase funds can only be sent to a zaddr");
@@ -2762,13 +2741,13 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
age += 1;
dPriority += (double)nCredit * age;
}
if ( KOMODO_EXCHANGEWALLET != 0 )
{
//if ( KOMODO_EXCHANGEWALLET != 0 )
//{
//fprintf(stderr,"KOMODO_EXCHANGEWALLET disable interest sum %.8f, interest2 %.8f\n",(double)interest/COIN,(double)interest2/COIN);
interest = 0; // interest2 also
}
//interest = 0; // interest2 also
//}
CAmount nChange = (nValueIn - nValue + interest2);
fprintf(stderr,"wallet change %.8f (%.8f - %.8f) interest %.8f interest2 %.8f total %.8f\n",(double)nChange/COIN,(double)nValueIn/COIN,(double)nValue/COIN,(double)interest2/COIN,(double)interest/COIN,(double)nTotalValue/COIN);
fprintf(stderr,"wallet change %.8f (%.8f - %.8f) interest2 %.8f total %.8f\n",(double)nChange/COIN,(double)nValueIn/COIN,(double)nValue/COIN,(double)interest2/COIN,(double)nTotalValue/COIN);
if (nSubtractFeeFromAmount == 0)
nChange -= nFeeRet;

View File

@@ -584,7 +584,7 @@ public:
class CWallet : public CCryptoKeyStore, public CValidationInterface
{
private:
bool SelectCoins(const CAmount& nTargetValue, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, CAmount& nValueRet, bool& fOnlyCoinbaseCoinsRet, bool& fNeedCoinbaseCoinsRet, const CCoinControl *coinControl = NULL,uint64_t *interestp = NULL) const;
bool SelectCoins(const CAmount& nTargetValue, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, CAmount& nValueRet, bool& fOnlyCoinbaseCoinsRet, bool& fNeedCoinbaseCoinsRet, const CCoinControl *coinControl = NULL) const;
CWalletDB *pwalletdbEncryption;
@@ -811,7 +811,7 @@ public:
bool CanSupportFeature(enum WalletFeature wf) { AssertLockHeld(cs_wallet); return nWalletMaxVersion >= wf; }
void AvailableCoins(std::vector<COutput>& vCoins, bool fOnlyConfirmed=true, const CCoinControl *coinControl = NULL, bool fIncludeZeroValue=false, bool fIncludeCoinBase=true) const;
bool SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int nConfTheirs, std::vector<COutput> vCoins, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, CAmount& nValueRet,uint64_t *interestp) const;
bool SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int nConfTheirs, std::vector<COutput> vCoins, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, CAmount& nValueRet) const;
bool IsSpent(const uint256& hash, unsigned int n) const;
bool IsSpent(const uint256& nullifier) const;

1
user-config.jam Normal file
View File

@@ -0,0 +1 @@
using : : : <cxxflags>" " <linkflags>"" <archiver>"" <striper>"" <ranlib>"" <rc>"" : ;

View File

@@ -43,7 +43,7 @@ PREFIX="$(pwd)/depends/$TRIPLET"
make "$@" -C ./depends/ V=1 NO_QT=1
./autogen.sh
CPPFLAGS="-I$PREFIX/include -arch x86_64" LDFLAGS="-L$PREFIX/lib -arch x86_64 -Wl,-no_pie -fopenmp" \
CPPFLAGS="-I$PREFIX/include -arch x86_64" LDFLAGS="-L$PREFIX/lib -arch x86_64 -Wl,-no_pie" \
CXXFLAGS='-arch x86_64 -I/usr/local/Cellar/gcc5/5.4.0/include/c++/5.4.0 -I$PREFIX/include -fwrapv -fno-strict-aliasing -Werror -g -Wl,-undefined -Wl,dynamic_lookup' \
./configure --prefix="${PREFIX}" --with-gui=no "$HARDENING_ARG" "$LCOV_ARG"