From 1ce9aa236ee2f357f3599b5fee4c4a2f87237411 Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Mon, 9 Oct 2017 15:06:25 +0400 Subject: [PATCH 01/18] Building under Windows. Initial commit. --- OSlibs/win/mingw.h | 2 + iguana/exchanges/LP_coins.c | 4 +- iguana/exchanges/mm.c | 8 +- iguana/exchanges/stats.c | 20 ++- marketmaker.sln | 28 ++++ marketmaker.vcxproj | 257 +++++++++++++++++++++++++++++++ marketmaker.vcxproj.filters | 297 ++++++++++++++++++++++++++++++++++++ 7 files changed, 612 insertions(+), 4 deletions(-) create mode 100644 marketmaker.sln create mode 100644 marketmaker.vcxproj create mode 100644 marketmaker.vcxproj.filters diff --git a/OSlibs/win/mingw.h b/OSlibs/win/mingw.h index 6be81f99b..aa5ae5274 100755 --- a/OSlibs/win/mingw.h +++ b/OSlibs/win/mingw.h @@ -38,6 +38,8 @@ * @author - fadedreamz@gmail.com */ //TODO: need to update other values to match with WSAPoll() function +#define POLLRDNORM 0x0100 +#define POLLRDBAND 0x0200 #define POLLIN POLLRDNORM | POLLRDBAND /* There is data to read */ #define POLLOUT POLLWRNORM /* Writing now will not block */ #else diff --git a/iguana/exchanges/LP_coins.c b/iguana/exchanges/LP_coins.c index e1eca4ab0..6cc7fe983 100644 --- a/iguana/exchanges/LP_coins.c +++ b/iguana/exchanges/LP_coins.c @@ -96,7 +96,7 @@ void LP_statefname(char *fname,char *symbol,char *assetname,char *str,char *name #endif if ( strcmp(symbol,"BTC") == 0 ) { -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(NATIVE_WINDOWS) strcat(fname,"Bitcoin"); #else strcat(fname,".bitcoin"); @@ -120,7 +120,7 @@ void LP_statefname(char *fname,char *symbol,char *assetname,char *str,char *name } else { -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(NATIVE_WINDOWS) strcat(fname,"Komodo"); #else strcat(fname,".komodo"); diff --git a/iguana/exchanges/mm.c b/iguana/exchanges/mm.c index 618b9d494..84758ac24 100644 --- a/iguana/exchanges/mm.c +++ b/iguana/exchanges/mm.c @@ -22,7 +22,13 @@ #define FROM_MARKETMAKER #include #include -#include "OS_portable.h" +#ifndef NATIVE_WINDOWS + #include "OS_portable.h" +#else + #include "../../crypto777/OS_portable.h" +#endif // !_WIN_32 + + #define MAX(a,b) ((a) > (b) ? (a) : (b)) char *stats_JSON(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson,char *remoteaddr,uint16_t port); #include "stats.c" diff --git a/iguana/exchanges/stats.c b/iguana/exchanges/stats.c index 81562a46c..94a99ab53 100644 --- a/iguana/exchanges/stats.c +++ b/iguana/exchanges/stats.c @@ -19,6 +19,8 @@ // Copyright © 2017 SuperNET. All rights reserved. // + + #include #include #include "../../crypto777/OS_portable.h" @@ -70,7 +72,23 @@ int32_t iguana_socket(int32_t bindflag,char *hostname,uint16_t port) * it is standard posix function and is correctly supported in win32/win64/linux * @author - fadedreamz@gmail.com */ + + + #if defined(_M_X64) + typedef struct addrinfo + { + int ai_flags; // AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST + int ai_family; // PF_xxx + int ai_socktype; // SOCK_xxx + int ai_protocol; // 0 or IPPROTO_xxx for IPv4 and IPv6 + size_t ai_addrlen; // Length of ai_addr + char * ai_canonname; // Canonical name for nodename + _Field_size_bytes_(ai_addrlen) struct sockaddr * ai_addr; // Binary address + struct addrinfo * ai_next; // Next structure in linked list + } + ADDRINFOA, *PADDRINFOA; + struct addrinfo *addrresult = NULL; struct addrinfo *returnptr = NULL; struct addrinfo hints; @@ -82,7 +100,7 @@ int32_t iguana_socket(int32_t bindflag,char *hostname,uint16_t port) hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = IPPROTO_TCP; #endif - + if ( parse_ipaddr(ipaddr,hostname) != 0 ) port = parse_ipaddr(ipaddr,hostname); diff --git a/marketmaker.sln b/marketmaker.sln new file mode 100644 index 000000000..98097205c --- /dev/null +++ b/marketmaker.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "marketmaker", "marketmaker.vcxproj", "{BE4A118A-115D-44B5-B9D9-AD17C1C1AAE8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {BE4A118A-115D-44B5-B9D9-AD17C1C1AAE8}.Debug|x64.ActiveCfg = Debug|x64 + {BE4A118A-115D-44B5-B9D9-AD17C1C1AAE8}.Debug|x64.Build.0 = Debug|x64 + {BE4A118A-115D-44B5-B9D9-AD17C1C1AAE8}.Debug|x86.ActiveCfg = Debug|Win32 + {BE4A118A-115D-44B5-B9D9-AD17C1C1AAE8}.Debug|x86.Build.0 = Debug|Win32 + {BE4A118A-115D-44B5-B9D9-AD17C1C1AAE8}.Release|x64.ActiveCfg = Release|x64 + {BE4A118A-115D-44B5-B9D9-AD17C1C1AAE8}.Release|x64.Build.0 = Release|x64 + {BE4A118A-115D-44B5-B9D9-AD17C1C1AAE8}.Release|x86.ActiveCfg = Release|Win32 + {BE4A118A-115D-44B5-B9D9-AD17C1C1AAE8}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/marketmaker.vcxproj b/marketmaker.vcxproj new file mode 100644 index 000000000..20a6dec01 --- /dev/null +++ b/marketmaker.vcxproj @@ -0,0 +1,257 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {BE4A118A-115D-44B5-B9D9-AD17C1C1AAE8} + Win32Proj + + + + Application + true + v140 + + + Application + false + v140 + + + Application + true + v140 + + + Application + false + v140 + + + + + + + + + + + + + + + + + + + + + true + $(ProjectDir)\includes;$(ProjectDir)\includes\curl;$(IncludePath) + $(ProjectDir)\OSlibs\win;$(LibraryPath) + + + true + $(SolutionDir)/includes;$(SolutionDir)/includes/curl;$(IncludePath) + + + false + $(ProjectDir)\includes;$(ProjectDir)\includes\curl;$(IncludePath) + $(ProjectDir)\OSlibs\win;$(LibraryPath) + + + false + false + $(ProjectDir)\includes;$(ProjectDir)\includes\curl;$(IncludePath) + + + + + + Level2 + Disabled + _CRT_SECURE_NO_WARNINGS;NATIVE_WINDOWS;WIN32;_DEBUG;_CONSOLE;IGUANA_LOG2PACKETSIZE=20;IGUANA_MAXPACKETSIZE=1572864;%(PreprocessorDefinitions) + 1Byte + .\iguana;%(AdditionalIncludeDirectories) + + + Console + true + Ws2_32.lib;pthreadVC2.lib;nanomsg.lib;libcurl.lib;%(AdditionalDependencies) + .\iguana;.\OSlibs\win;%(AdditionalLibraryDirectories) + + + + + + + Level3 + Disabled + _DEBUG;_CONSOLE;NATIVE_WINDOWS;WIN32;IGUANA_LOG2PACKETSIZE=20;IGUANA_MAXPACKETSIZE=1572864;%(PreprocessorDefinitions) + 1Byte + + + Console + true + .\OSlibs\win\x64;%(AdditionalLibraryDirectories) + pthread_lib.lib;Ws2_32.lib;nanomsg.lib;libcurl.lib;%(AdditionalDependencies) + + + + + Level3 + + + MaxSpeed + true + true + _CRT_SECURE_NO_WARNINGS;NATIVE_WINDOWS;WIN32;_CONSOLE;NDEBUG;IGUANA_LOG2PACKETSIZE=20;IGUANA_MAXPACKETSIZE=1572864;%(PreprocessorDefinitions) + 1Byte + + + MachineX86 + true + Console + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN64;_WIN64;_CRT_SECURE_NO_WARNINGS;NATIVE_WINDOWS;WIN32;_CONSOLE;NDEBUG;IGUANA_LOG2PACKETSIZE=20;IGUANA_MAXPACKETSIZE=1572864;%(PreprocessorDefinitions) + 1Byte + MultiThreaded + + + Console + true + true + true + Ws2_32.lib;Advapi32.lib;$(SolutionDir)OSlibs\win\x64\pthread_lib.lib;libcurl.lib;nanomsg.lib;%(AdditionalDependencies) + .\OSlibs\win\x64\release;%(AdditionalLibraryDirectories) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/marketmaker.vcxproj.filters b/marketmaker.vcxproj.filters new file mode 100644 index 000000000..7875d7cf3 --- /dev/null +++ b/marketmaker.vcxproj.filters @@ -0,0 +1,297 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + + \ No newline at end of file From 39507b8b9007f6f92c2c336188c456d6a1c23a64 Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Mon, 9 Oct 2017 15:44:28 +0400 Subject: [PATCH 02/18] Ugly fix problem with WinSock2.h and Windows.h included twice. warning C4005: 'AF_IPX': macro redefinition and same problems. TODO: Need to properly include windows.h and WinSock2.h in all project. --- OSlibs/win/mingw.h | 3 +++ iguana/exchanges/LP_socket.c | 37 +++++++++++++++++++++++++++++++----- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/OSlibs/win/mingw.h b/OSlibs/win/mingw.h index aa5ae5274..37e1ea879 100755 --- a/OSlibs/win/mingw.h +++ b/OSlibs/win/mingw.h @@ -5,6 +5,8 @@ #include #define _USE_W32_SOCKETS 1 +//#define WIN32_LEAN_AND_MEAN +//#define _WINSOCKAPI_ #include #define PTW32_STATIC_LIB #include "pthread.h" @@ -40,6 +42,7 @@ //TODO: need to update other values to match with WSAPoll() function #define POLLRDNORM 0x0100 #define POLLRDBAND 0x0200 +#define POLLWRNORM 0x0010 #define POLLIN POLLRDNORM | POLLRDBAND /* There is data to read */ #define POLLOUT POLLWRNORM /* Writing now will not block */ #else diff --git a/iguana/exchanges/LP_socket.c b/iguana/exchanges/LP_socket.c index e4727bada..30f6ce0b7 100644 --- a/iguana/exchanges/LP_socket.c +++ b/iguana/exchanges/LP_socket.c @@ -21,10 +21,12 @@ * @remarks - #if (defined(_M_X64) || defined(__amd64__)) && defined(WIN32) * is equivalent to #if defined(_M_X64) as _M_X64 is defined for MSVC only */ -#if defined(_M_X64) -#define WIN32_LEAN_AND_MEAN -#include -#endif + +//#if defined(_M_X64) +//#define WIN32_LEAN_AND_MEAN +//#define _WINSOCKAPI_ +//#include +//#endif #define ELECTRUM_TIMEOUT 5 @@ -42,6 +44,20 @@ int32_t LP_socket(int32_t bindflag,char *hostname,uint16_t port) * @author - fadedreamz@gmail.com */ #if defined(_M_X64) + + typedef struct addrinfo + { + int ai_flags; // AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST + int ai_family; // PF_xxx + int ai_socktype; // SOCK_xxx + int ai_protocol; // 0 or IPPROTO_xxx for IPv4 and IPv6 + size_t ai_addrlen; // Length of ai_addr + char * ai_canonname; // Canonical name for nodename + _Field_size_bytes_(ai_addrlen) struct sockaddr * ai_addr; // Binary address + struct addrinfo * ai_next; // Next structure in linked list + } + ADDRINFOA, *PADDRINFOA; + struct addrinfo *addrresult = NULL; struct addrinfo *returnptr = NULL; struct addrinfo hints; @@ -805,7 +821,18 @@ int32_t LP_recvfunc(struct electrum_info *ep,char *str,int32_t len) void LP_dedicatedloop(void *arg) { - struct pollfd fds; int32_t i,len,flag,timeout = 10; struct iguana_info *coin; cJSON *retjson; struct stritem *sitem; struct electrum_info *ep = arg; +#if defined(_M_X64) + typedef struct pollfd { + + SOCKET fd; + SHORT events; + SHORT revents; + + } WSAPOLLFD, *PWSAPOLLFD, FAR *LPWSAPOLLFD; +#endif + + struct pollfd fds; + int32_t i,len,flag,timeout = 10; struct iguana_info *coin; cJSON *retjson; struct stritem *sitem; struct electrum_info *ep = arg; if ( (coin= LP_coinfind(ep->symbol)) != 0 ) ep->heightp = &coin->height, ep->heighttimep = &coin->heighttime; if ( (retjson= electrum_headers_subscribe(ep->symbol,ep,0)) != 0 ) From 94d322bc768ac7f668aa7e85034845dc599d401a Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Mon, 9 Oct 2017 16:41:38 +0400 Subject: [PATCH 03/18] Fix "DB/myipaddr" violation with ipfname Thx jl777. --- iguana/exchanges/LP_nativeDEX.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 0dac58e60..1147fbfb9 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -593,6 +593,7 @@ void LP_initpeers(int32_t pubsock,struct LP_peerinfo *mypeer,char *myipaddr,uint void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybusport,char *passphrase,int32_t amclient,char *userhome,cJSON *argjson) { + char *myip_path = ""; char *myipaddr=0; long filesize,n; int32_t timeout,pubsock=-1; struct LP_peerinfo *mypeer=0; char pushaddr[128],subaddr[128],bindaddr[128]; void *ctx = bitcoin_ctx(); LP_showwif = juint(argjson,"wif"); if ( passphrase == 0 || passphrase[0] == 0 ) @@ -653,7 +654,9 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybu portable_mutex_init(&LP_butxomutex); if ( system("curl -s4 checkip.amazonaws.com > DB/myipaddr") == 0 ) { - if ( (myipaddr= OS_filestr(&filesize,"DB/myipaddr")) != 0 && myipaddr[0] != 0 ) + char ipfname[64]; + strcpy(ipfname, "DB/myipaddr"); + if ((myipaddr = OS_filestr(&filesize, ipfname)) != 0 && myipaddr[0] != 0) { n = strlen(myipaddr); if ( myipaddr[n-1] == '\n' ) From 8c92ff7df8799233804f9b210aeb81ee73916971 Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Mon, 9 Oct 2017 20:44:57 +0400 Subject: [PATCH 04/18] correct windows.h / winsock2.h include order - changes to correctly include winsock2.h, according to this article: https://msdn.microsoft.com/ru-ru/library/windows/desktop/ms738562(v=vs.85).aspx - removed ugly "typedef struct addrinfo" definitions in code - added WIN32_LEAN_AND_MEAN flag in preprocessor directives - removed unused myip_path in LP_nativeDEX, error with "DB/myipaddr" violation with ipfname alredy fixed by jl777 --- OSlibs/win/mingw.h | 4 ++-- iguana/exchanges/LP_nativeDEX.c | 3 +-- iguana/exchanges/LP_socket.c | 24 +++++------------------- iguana/exchanges/stats.c | 15 --------------- marketmaker.vcxproj | 2 +- 5 files changed, 9 insertions(+), 39 deletions(-) diff --git a/OSlibs/win/mingw.h b/OSlibs/win/mingw.h index 37e1ea879..76802c56e 100755 --- a/OSlibs/win/mingw.h +++ b/OSlibs/win/mingw.h @@ -5,8 +5,8 @@ #include #define _USE_W32_SOCKETS 1 -//#define WIN32_LEAN_AND_MEAN -//#define _WINSOCKAPI_ +#define WIN32_LEAN_AND_MEAN +#include #include #define PTW32_STATIC_LIB #include "pthread.h" diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 1147fbfb9..921a47d13 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -593,8 +593,7 @@ void LP_initpeers(int32_t pubsock,struct LP_peerinfo *mypeer,char *myipaddr,uint void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybusport,char *passphrase,int32_t amclient,char *userhome,cJSON *argjson) { - char *myip_path = ""; - char *myipaddr=0; long filesize,n; int32_t timeout,pubsock=-1; struct LP_peerinfo *mypeer=0; char pushaddr[128],subaddr[128],bindaddr[128]; void *ctx = bitcoin_ctx(); + char *myipaddr=0; long filesize,n; int32_t timeout,pubsock=-1; struct LP_peerinfo *mypeer=0; char pushaddr[128],subaddr[128],bindaddr[128]; void *ctx = bitcoin_ctx(); LP_showwif = juint(argjson,"wif"); if ( passphrase == 0 || passphrase[0] == 0 ) { diff --git a/iguana/exchanges/LP_socket.c b/iguana/exchanges/LP_socket.c index 30f6ce0b7..750b5cbed 100644 --- a/iguana/exchanges/LP_socket.c +++ b/iguana/exchanges/LP_socket.c @@ -22,11 +22,11 @@ * is equivalent to #if defined(_M_X64) as _M_X64 is defined for MSVC only */ -//#if defined(_M_X64) -//#define WIN32_LEAN_AND_MEAN -//#define _WINSOCKAPI_ -//#include -//#endif +#if defined(_M_X64) +#define WIN32_LEAN_AND_MEAN +#define _WINSOCKAPI_ +#include +#endif #define ELECTRUM_TIMEOUT 5 @@ -44,20 +44,6 @@ int32_t LP_socket(int32_t bindflag,char *hostname,uint16_t port) * @author - fadedreamz@gmail.com */ #if defined(_M_X64) - - typedef struct addrinfo - { - int ai_flags; // AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST - int ai_family; // PF_xxx - int ai_socktype; // SOCK_xxx - int ai_protocol; // 0 or IPPROTO_xxx for IPv4 and IPv6 - size_t ai_addrlen; // Length of ai_addr - char * ai_canonname; // Canonical name for nodename - _Field_size_bytes_(ai_addrlen) struct sockaddr * ai_addr; // Binary address - struct addrinfo * ai_next; // Next structure in linked list - } - ADDRINFOA, *PADDRINFOA; - struct addrinfo *addrresult = NULL; struct addrinfo *returnptr = NULL; struct addrinfo hints; diff --git a/iguana/exchanges/stats.c b/iguana/exchanges/stats.c index 94a99ab53..52372a68a 100644 --- a/iguana/exchanges/stats.c +++ b/iguana/exchanges/stats.c @@ -73,22 +73,7 @@ int32_t iguana_socket(int32_t bindflag,char *hostname,uint16_t port) * @author - fadedreamz@gmail.com */ - - #if defined(_M_X64) - typedef struct addrinfo - { - int ai_flags; // AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST - int ai_family; // PF_xxx - int ai_socktype; // SOCK_xxx - int ai_protocol; // 0 or IPPROTO_xxx for IPv4 and IPv6 - size_t ai_addrlen; // Length of ai_addr - char * ai_canonname; // Canonical name for nodename - _Field_size_bytes_(ai_addrlen) struct sockaddr * ai_addr; // Binary address - struct addrinfo * ai_next; // Next structure in linked list - } - ADDRINFOA, *PADDRINFOA; - struct addrinfo *addrresult = NULL; struct addrinfo *returnptr = NULL; struct addrinfo hints; diff --git a/marketmaker.vcxproj b/marketmaker.vcxproj index 20a6dec01..b441d6ab4 100644 --- a/marketmaker.vcxproj +++ b/marketmaker.vcxproj @@ -140,7 +140,7 @@ MaxSpeed true true - WIN64;_WIN64;_CRT_SECURE_NO_WARNINGS;NATIVE_WINDOWS;WIN32;_CONSOLE;NDEBUG;IGUANA_LOG2PACKETSIZE=20;IGUANA_MAXPACKETSIZE=1572864;%(PreprocessorDefinitions) + WIN64;_WIN64;_CRT_SECURE_NO_WARNINGS;NATIVE_WINDOWS;WIN32;WIN32_LEAN_AND_MEAN;_CONSOLE;NDEBUG;IGUANA_LOG2PACKETSIZE=20;IGUANA_MAXPACKETSIZE=1572864;%(PreprocessorDefinitions) 1Byte MultiThreaded From 0c37a6dff7964bd36523d336ef71ffecf6d1ab1e Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Thu, 12 Oct 2017 21:15:37 +0400 Subject: [PATCH 05/18] add more informative logging when init and privkey updates --- iguana/exchanges/LP_utxos.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/iguana/exchanges/LP_utxos.c b/iguana/exchanges/LP_utxos.c index 9a67d2cda..35f8d2c1c 100644 --- a/iguana/exchanges/LP_utxos.c +++ b/iguana/exchanges/LP_utxos.c @@ -768,8 +768,11 @@ void LP_privkey_updates(void *ctx,int32_t pubsock,char *passphrase) initonly = (passphrase != 0); memset(privkey.bytes,0,sizeof(privkey)); memset(pubkey.bytes,0,sizeof(pubkey)); + printf("Total coins: %d\n", HASH_COUNT(LP_coins)); + int num_iter = 0; HASH_ITER(hh,LP_coins,coin,tmp) { + printf("LP_privkey_updates [%02d / %02d]\n", num_iter++, HASH_COUNT(LP_coins)); if ( initonly != 0 ) { coin->counter = 0; From 0e8cd85c01adcf2df1bd0b37b776fa8ddc466341 Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Thu, 12 Oct 2017 21:53:09 +0400 Subject: [PATCH 06/18] added readme for Windows version (it will be continued) --- README_decker.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 README_decker.md diff --git a/README_decker.md b/README_decker.md new file mode 100644 index 000000000..a9cccd878 --- /dev/null +++ b/README_decker.md @@ -0,0 +1,25 @@ +## What's this? + +This is a first build of **MarketMaker** app from barterDEX for Windows (64-bit) platform. This branch includes all that you need to build marketmaker for Windows. 64-bit build uses MSVC 2015 as a default C/C++ compiler, to build - simply open *marketmaker.sln* project file via File -> Open -> Project/Solution ... next choose Release / x64 configuration and build solution. Your binaries will be placed x64\Release folder. To run marketmaker you also need following dll libraries: + +- libcurl.dll +- nanomsg.dll +- curl.exe (win64 curl binary, used is scripts) + +It already included in this branch. + +## How to use? + +Please, refer to original barterDEX documentation and Komodo Platform + SuperNET resources to learn how to work this it. Later i will add some examples and useful links here. + +Important, coins.json on Windows shouldn't contain coins which haven't running daemons. Add to coins.json only coins that you plan to use, in other case starting marketmaker will too long: about 4 seconds on each not-running coin. + +Get the latest binary release from release section and step-by-step run cmd files: + +- 1-client.cmd - this runs marketmaker with passphrase taken from a passphrase file. +- 2-getuserpass.cmd - this will save and output your userpass in userpass file for future use. +- 3-orderbook.cmd - to get an orderbook (if u downloaded binary release from release section - it's have only REVS in coins.json and orderbook will be shown at KMD/REVS coins pair). + +Other scripts will be post later ... this is just for example that it works. + + \ No newline at end of file From 987b96ab64de236285dc0c94d2944d9705e8d877 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 19 Oct 2017 12:41:11 +0300 Subject: [PATCH 07/18] Test --- iguana/dpow/dpow_network.c | 10 +++++----- iguana/exchanges/LP_nativeDEX.c | 6 +++--- iguana/iguana777.h | 2 +- iguana/iguana_mofn.c | 19 ++++++------------- iguana/main.c | 8 ++++---- includes/iguana_structs.h | 4 ++-- 6 files changed, 21 insertions(+), 28 deletions(-) diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index ac2f99918..9899b9cac 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -170,7 +170,7 @@ int32_t signed_nn_recv(void **freeptrp,struct supernet_info *myinfo,uint8_t nota vcalc_sha256(0,packethash.bytes,(void *)&sigpacket->nonce,(int32_t)(sigpacket->packetlen+sizeof(sigpacket->nonce)+sizeof(sigpacket->packetlen))); if ( bits256_cmp(packethash,sigpacket->packethash) == 0 && sigpacket->packethash.bytes[0] == 0 ) { - if ( bitcoin_recoververify(myinfo->ctx[1],"nnrecv",sigpacket->sig64,sigpacket->packethash,pubkey33,33) == 0 ) + if ( bitcoin_recoververify(myinfo->ctx,"nnrecv",sigpacket->sig64,sigpacket->packethash,pubkey33,33) == 0 ) { char *notary0 = "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828"; // expand to official notaries @@ -2020,7 +2020,7 @@ void dpow_send(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_blo pfd.events = NN_POLLOUT; if ( nn_poll(&pfd,1,100) > 0 ) { - sentbytes = signed_nn_send(myinfo,myinfo->ctx[2],myinfo->persistent_priv,myinfo->dpowsock,np,size); + sentbytes = signed_nn_send(myinfo,myinfo->ctx,myinfo->persistent_priv,myinfo->dpowsock,np,size); break; } usleep(1000); @@ -2168,13 +2168,13 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo) //printf("REP got %d crc.%08x\n",size,calc_crc32(0,(void *)dexp,size)); if ( (retstr= dex_response(&broadcastflag,myinfo,dexp)) != 0 ) { - signed_nn_send(myinfo,myinfo->ctx[3],myinfo->persistent_priv,myinfo->repsock,retstr,(int32_t)strlen(retstr)+1); + signed_nn_send(myinfo,myinfo->ctx,myinfo->persistent_priv,myinfo->repsock,retstr,(int32_t)strlen(retstr)+1); //printf("send back[%ld]\n",strlen(retstr)+1); free(retstr); if ( broadcastflag != 0 ) { printf("BROADCAST dexp request.[%d]\n",size); - signed_nn_send(myinfo,myinfo->ctx[4],myinfo->persistent_priv,myinfo->dexsock,dexp,size); + signed_nn_send(myinfo,myinfo->ctx,myinfo->persistent_priv,myinfo->dexsock,dexp,size); //signed_nn_send(myinfo,myinfo->ctx,myinfo->persistent_priv,myinfo->pubsock,dexp,size); } } @@ -2183,7 +2183,7 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo) if ( (m= myinfo->numdpowipbits) > 0 ) { r = myinfo->dpowipbits[rand() % m]; - signed_nn_send(myinfo,myinfo->ctx[5],myinfo->persistent_priv,myinfo->repsock,&r,sizeof(r)); + signed_nn_send(myinfo,myinfo->ctx,myinfo->persistent_priv,myinfo->repsock,&r,sizeof(r)); printf("REP.%08x <- rand ip m.%d %x\n",dexp->crc32,m,r); } else printf("illegal state without dpowipbits?\n"); if ( dex_packetcheck(myinfo,dexp,size) == 0 ) diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 9037ee0e9..83522cdc8 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -18,11 +18,11 @@ // LP_nativeDEX.c // marketmaker // +// error if alice submits order too fast // dPoW security -> 4: KMD notarized, 5: BTC notarized +// new testchain // sign critical api calls (pubkey reg, listunspent, orders?) -// -// process stats.log local file -// +// process stats.log local file -> map of realtime activity! // handles <-> pubkeys, deal with offline pubkeys, reputations, bonds etc. // // alice only coins GAME UNO BTM ANC: GAME BTCD PPC RDD XZC POT EAC FTC BASH SPR WDC UNO XPM XCN BELA CHC DIME MEC NAUT MED AUR MAX DGC RIC EB3 DOT BTM GEO ANC CANN ICASH WBB SRC PTC ADZ TIPS EQT START EFL FST FJC NYC GCN diff --git a/iguana/iguana777.h b/iguana/iguana777.h index 444565658..74412e6f0 100755 --- a/iguana/iguana777.h +++ b/iguana/iguana777.h @@ -150,7 +150,7 @@ struct supernet_info struct queueitem *DEX_quotes; cJSON *Cunspents,*Cspends; struct basilisk_swap *swaps[256]; int32_t numswaps; struct basilisk_message *messagetable; portable_mutex_t messagemutex; queue_t msgQ,p2pQ; - void *ctx[8]; + void *ctx; uint8_t *pingbuf; struct basilisk_request DEXaccept; FILE *dexfp; diff --git a/iguana/iguana_mofn.c b/iguana/iguana_mofn.c index 946833dd1..b4d34230d 100755 --- a/iguana/iguana_mofn.c +++ b/iguana/iguana_mofn.c @@ -249,24 +249,17 @@ void *bitcoin_ctx() void iguana_fixsecp(struct supernet_info *myinfo) { - int32_t i; - for (i=0; ictx)/sizeof(*myinfo->ctx); i++) - { - myinfo->ctx[i] = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); - secp256k1_pedersen_context_initialize(myinfo->ctx[i]); - secp256k1_rangeproof_context_initialize(myinfo->ctx[i]); - } + myinfo->ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); + secp256k1_pedersen_context_initialize(myinfo->ctx); + secp256k1_rangeproof_context_initialize(myinfo->ctx); } void libgfshare_init(struct supernet_info *myinfo,uint8_t _logs[256],uint8_t _exps[510]) { uint32_t i,x = 1; - for (i=0; ictx)/sizeof(*myinfo->ctx); i++) - { - myinfo->ctx[i] = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); - secp256k1_pedersen_context_initialize(myinfo->ctx[i]); - secp256k1_rangeproof_context_initialize(myinfo->ctx[i]); - } + myinfo->ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); + secp256k1_pedersen_context_initialize(myinfo->ctx); + secp256k1_rangeproof_context_initialize(myinfo->ctx); for (i=0; i<255; i++) { _exps[i] = x; diff --git a/iguana/main.c b/iguana/main.c index b4ff56136..85510c3fb 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -77,11 +77,11 @@ void SuperNET_hex2str(char *str,uint8_t *hex,int32_t len) void *bitcoin_ctx(); struct supernet_info *SuperNET_MYINFO(char *passphrase) { - int32_t i; - if ( MYINFO.ctx[0] == 0 ) + //int32_t i; + if ( MYINFO.ctx == 0 ) { - for (i=0; i Date: Thu, 19 Oct 2017 12:46:05 +0300 Subject: [PATCH 08/18] Test --- iguana/exchanges/LP_coins.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/iguana/exchanges/LP_coins.c b/iguana/exchanges/LP_coins.c index 25d45a602..0f5cef6ee 100644 --- a/iguana/exchanges/LP_coins.c +++ b/iguana/exchanges/LP_coins.c @@ -195,8 +195,11 @@ cJSON *LP_coinjson(struct iguana_info *coin,int32_t showwif) jaddstr(item,"wif",wifstr); else jaddstr(item,"wif","error creating wif"); } + jadd(item,"installed",coin->userpass[0] == 0 ? jfalse() : jtrue()); if ( coin->inactive != 0 ) + { jaddstr(item,"status","inactive"); + } else jaddstr(item,"status","active"); if ( coin->isPoS != 0 ) jaddstr(item,"type","PoS"); From 457a1028c0abaadc9879914e1135f6d0afee6956 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 19 Oct 2017 12:49:09 +0300 Subject: [PATCH 09/18] Test --- iguana/exchanges/LP_utxos.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_utxos.c b/iguana/exchanges/LP_utxos.c index f2ce4ff9d..4d83eeb7c 100644 --- a/iguana/exchanges/LP_utxos.c +++ b/iguana/exchanges/LP_utxos.c @@ -771,11 +771,11 @@ void LP_privkey_updates(void *ctx,int32_t pubsock,char *passphrase) initonly = (passphrase != 0); memset(privkey.bytes,0,sizeof(privkey)); memset(pubkey.bytes,0,sizeof(pubkey)); - printf("Total coins: %d\n", HASH_COUNT(LP_coins)); - int num_iter = 0; + //printf("Total coins: %d\n", HASH_COUNT(LP_coins)); + //int num_iter = 0; HASH_ITER(hh,LP_coins,coin,tmp) { - printf("LP_privkey_updates [%02d / %02d]\n", num_iter++, HASH_COUNT(LP_coins)); + //printf("LP_privkey_updates [%02d / %02d]\n", num_iter++, HASH_COUNT(LP_coins)); if ( initonly != 0 ) { coin->counter = 0; From efbb5214853002bc2eb6ac379645a3b9edb4dd98 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 19 Oct 2017 13:05:03 +0300 Subject: [PATCH 10/18] Test --- iguana/exchanges/LP_coins.c | 2 ++ iguana/exchanges/LP_include.h | 1 + 2 files changed, 3 insertions(+) diff --git a/iguana/exchanges/LP_coins.c b/iguana/exchanges/LP_coins.c index 0f5cef6ee..f1bcef3de 100644 --- a/iguana/exchanges/LP_coins.c +++ b/iguana/exchanges/LP_coins.c @@ -196,6 +196,8 @@ cJSON *LP_coinjson(struct iguana_info *coin,int32_t showwif) else jaddstr(item,"wif","error creating wif"); } jadd(item,"installed",coin->userpass[0] == 0 ? jfalse() : jtrue()); + jaddnum(item,"height",LP_getheight(coin)); + if ( coin->inactive != 0 ) { jaddstr(item,"status","inactive"); diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index c18048077..a8890ac04 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -299,6 +299,7 @@ uint16_t LP_psock_get(char *connectaddr,char *publicaddr,int32_t ispaired); int32_t LP_coinbus(uint16_t coin_busport); int32_t LP_nanomsg_recvs(void *ctx); int32_t LP_reserved_msgs(); +int32_t LP_getheight(struct iguana_info *coin); int32_t LP_reserved_msg(char *base,char *rel,bits256 pubkey,char *msg); struct iguana_info *LP_coinfind(char *symbol); int32_t LP_crc32find(int32_t *duplicatep,int32_t ind,uint32_t crc32); From 1ffbaac87e7cb3fe49c6da5946f4b9c5ab48f1ae Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 19 Oct 2017 13:09:52 +0300 Subject: [PATCH 11/18] Test --- iguana/exchanges/LP_rpc.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_rpc.c b/iguana/exchanges/LP_rpc.c index 18a7c89e1..7620591c7 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -203,7 +203,7 @@ cJSON *LP_assethbla(char *assetid) int32_t LP_getheight(struct iguana_info *coin) { - cJSON *retjson; char *method = "getinfo"; int32_t height; + cJSON *retjson; char *retstr,*method = "getinfo"; int32_t height; if ( coin == 0 ) return(-1); height = coin->height; @@ -211,11 +211,16 @@ int32_t LP_getheight(struct iguana_info *coin) { if ( strcmp(coin->symbol,"BTC") == 0 ) method = "getblockchaininfo"; - if ( (retjson= bitcoin_json(coin,method,"[]")) != 0 ) + retstr = bitcoind_passthru(coin->symbol,coin->serverport,coin->userpass,method,"[]"); + printf("%s.(%s %s): %s.%s -> (%s)\n",coin->symbol,coin->serverport,coin->userpass,method,"[]",retstr); + if ( retstr != 0 && retstr[0] != 0 ) { + retjson = cJSON_Parse(retstr); coin->height = height = jint(retjson,"blocks"); free_json(retjson); - coin->heighttime = (uint32_t)time(NULL); + if ( coin->height > 0 ) + coin->heighttime = (uint32_t)time(NULL); + free(retstr); } } return(height); From b3fec41a1459f304d8777e4737f4a0a8c2fff566 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 19 Oct 2017 13:14:20 +0300 Subject: [PATCH 12/18] Test --- iguana/exchanges/LP_coins.c | 4 +++- iguana/exchanges/LP_rpc.c | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_coins.c b/iguana/exchanges/LP_coins.c index f1bcef3de..7b0d71693 100644 --- a/iguana/exchanges/LP_coins.c +++ b/iguana/exchanges/LP_coins.c @@ -196,7 +196,9 @@ cJSON *LP_coinjson(struct iguana_info *coin,int32_t showwif) else jaddstr(item,"wif","error creating wif"); } jadd(item,"installed",coin->userpass[0] == 0 ? jfalse() : jtrue()); - jaddnum(item,"height",LP_getheight(coin)); + if ( coin->userpass[0] != 0 ) + jaddnum(item,"height",LP_getheight(coin)); + else jaddnum(item,"height",-1); if ( coin->inactive != 0 ) { diff --git a/iguana/exchanges/LP_rpc.c b/iguana/exchanges/LP_rpc.c index 7620591c7..5d96b956b 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -212,7 +212,6 @@ int32_t LP_getheight(struct iguana_info *coin) if ( strcmp(coin->symbol,"BTC") == 0 ) method = "getblockchaininfo"; retstr = bitcoind_passthru(coin->symbol,coin->serverport,coin->userpass,method,"[]"); - printf("%s.(%s %s): %s.%s -> (%s)\n",coin->symbol,coin->serverport,coin->userpass,method,"[]",retstr); if ( retstr != 0 && retstr[0] != 0 ) { retjson = cJSON_Parse(retstr); From 840adc15628f395e18b299dba1463d43a7101834 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 19 Oct 2017 13:22:22 +0300 Subject: [PATCH 13/18] Test --- iguana/exchanges/LP_coins.c | 10 ++++++++-- iguana/exchanges/LP_include.h | 1 + iguana/exchanges/LP_rpc.c | 23 +++++++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_coins.c b/iguana/exchanges/LP_coins.c index 7b0d71693..586154564 100644 --- a/iguana/exchanges/LP_coins.c +++ b/iguana/exchanges/LP_coins.c @@ -197,9 +197,15 @@ cJSON *LP_coinjson(struct iguana_info *coin,int32_t showwif) } jadd(item,"installed",coin->userpass[0] == 0 ? jfalse() : jtrue()); if ( coin->userpass[0] != 0 ) + { jaddnum(item,"height",LP_getheight(coin)); - else jaddnum(item,"height",-1); - + jaddnum(item,"balance",dstr(LP_smartbalance(coin))); + } + else + { + jaddnum(item,"height",-1); + jaddnum(item,"balance",0); + } if ( coin->inactive != 0 ) { jaddstr(item,"status","inactive"); diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index a8890ac04..b4530087b 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -299,6 +299,7 @@ uint16_t LP_psock_get(char *connectaddr,char *publicaddr,int32_t ispaired); int32_t LP_coinbus(uint16_t coin_busport); int32_t LP_nanomsg_recvs(void *ctx); int32_t LP_reserved_msgs(); +uint64_t LP_smartbalance(struct iguana_info *coin); int32_t LP_getheight(struct iguana_info *coin); int32_t LP_reserved_msg(char *base,char *rel,bits256 pubkey,char *msg); struct iguana_info *LP_coinfind(char *symbol); diff --git a/iguana/exchanges/LP_rpc.c b/iguana/exchanges/LP_rpc.c index 5d96b956b..b81fb35f6 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -225,6 +225,29 @@ int32_t LP_getheight(struct iguana_info *coin) return(height); } +uint64_t LP_smartbalance(struct iguana_info *coin) +{ + cJSON *array,*item; char buf[512],*retstr; int32_t i,n; uint64_t valuesum,value; + valuesum = 0; + sprintf(buf,"[0, 99999999, [\"%s\"]]",coin->smartaddr); + retstr = bitcoind_passthru(coin->symbol,coin->serverport,coin->userpass,"listunspent","[]"); + if ( retstr != 0 && retstr[0] != 0 ) + { + array = cJSON_Parse(retstr); + if ( is_cJSON_Array(array) != 0 && (n= cJSON_GetArraySize(array)) > 0 ) + { + for (i=0; i Date: Thu, 19 Oct 2017 13:28:03 +0300 Subject: [PATCH 14/18] Test --- iguana/exchanges/LP_coins.c | 1 - 1 file changed, 1 deletion(-) diff --git a/iguana/exchanges/LP_coins.c b/iguana/exchanges/LP_coins.c index 586154564..5dbc20b49 100644 --- a/iguana/exchanges/LP_coins.c +++ b/iguana/exchanges/LP_coins.c @@ -186,7 +186,6 @@ cJSON *LP_coinjson(struct iguana_info *coin,int32_t showwif) { struct electrum_info *ep; char wifstr[128],ipaddr[64]; uint8_t tmptype; bits256 checkkey; cJSON *item = cJSON_CreateObject(); jaddstr(item,"coin",coin->symbol); - jaddnum(item,"height",coin->height); if ( showwif != 0 ) { bitcoin_priv2wif(coin->wiftaddr,wifstr,G.LP_mypriv25519,coin->wiftype); From f4b76a93cbcde9f44a037b1a0b778f98725b56c0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 19 Oct 2017 14:10:07 +0300 Subject: [PATCH 15/18] Test --- iguana/exchanges/LP_ordermatch.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index d1982812b..3a1a84de4 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -1057,6 +1057,14 @@ char *LP_autobuy(void *ctx,char *myipaddr,int32_t mypubsock,char *base,char *rel duration = LP_ORDERBOOK_DURATION; if ( timeout <= 0 ) timeout = LP_AUTOTRADE_TIMEOUT; + if ( time(NULL) < Alice_expiration ) + return(clonestr("{\"error\":\"only one pending request at a time\"}")); + else + { + Alice_expiration = 0; + memset(&LP_Alicequery,0,sizeof(LP_Alicequery)); + LP_Alicemaxprice = 0.; + } if ( maxprice <= 0. || relvolume <= 0. || LP_priceinfofind(base) == 0 || LP_priceinfofind(rel) == 0 ) return(clonestr("{\"error\":\"invalid parameter\"}")); //if ( strcmp("BTC",rel) == 0 ) From d1220393b7bd74a57773edf46c6e26460a97c322 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 19 Oct 2017 14:40:41 +0300 Subject: [PATCH 16/18] Test --- iguana/dPoW.h | 2 +- iguana/exchanges/LP_nativeDEX.c | 1 - iguana/exchanges/LP_ordermatch.c | 1 + iguana/iguana_notary.c | 3 ++- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/iguana/dPoW.h b/iguana/dPoW.h index b95c550f7..ba9e5c00e 100755 --- a/iguana/dPoW.h +++ b/iguana/dPoW.h @@ -134,7 +134,7 @@ struct dpow_info struct dpow_checkpoint checkpoint,last,destchaintip,srcfifo[DPOW_FIFOSIZE],destfifo[DPOW_FIFOSIZE]; struct dpow_hashheight approved[DPOW_FIFOSIZE],notarized[DPOW_FIFOSIZE]; bits256 activehash,lastnotarized,srctx[DPOW_MAXTX],desttx[DPOW_MAXTX]; - uint32_t SRCREALTIME,destupdated,srcconfirms,numdesttx,numsrctx,lastsplit,cancelratify; + uint32_t SRCREALTIME,lastsrcupdate,destupdated,srcconfirms,numdesttx,numsrctx,lastsplit,cancelratify; int32_t lastheight,maxblocks,SRCHEIGHT,SHORTFLAG,ratifying; struct pax_transaction *PAX; portable_mutex_t paxmutex,dexmutex; diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 83522cdc8..ea317996d 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -18,7 +18,6 @@ // LP_nativeDEX.c // marketmaker // -// error if alice submits order too fast // dPoW security -> 4: KMD notarized, 5: BTC notarized // new testchain // sign critical api calls (pubkey reg, listunspent, orders?) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index 3a1a84de4..5124c073d 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -816,6 +816,7 @@ void LP_reserved(void *ctx,char *myipaddr,int32_t mypubsock,struct LP_quoteinfo { memset(&LP_Alicequery,0,sizeof(LP_Alicequery)); LP_Alicemaxprice = 0.; + Alice_expiration = 0; LP_query(ctx,myipaddr,mypubsock,"connect",qp); } } diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index ed6d93c27..10744b6b5 100755 --- a/iguana/iguana_notary.c +++ b/iguana/iguana_notary.c @@ -318,11 +318,12 @@ void iguana_dPoWupdate(struct supernet_info *myinfo,struct dpow_info *dp) dpow_srcupdate(myinfo,dp,dp->lastheight++,blockhash,(uint32_t)time(NULL),blocktime); } } - else + else if ( time(NULL) > dp->lastsrcupdate+60 ) { dp->lastheight = height; blockhash = dpow_getblockhash(myinfo,src,dp->lastheight); dpow_srcupdate(myinfo,dp,dp->lastheight,blockhash,(uint32_t)time(NULL),blocktime); + dp->lastsrcupdate = (uint32_t)time(NULL); } } //else printf("error getchaintip for %s\n",dp->symbol); } else printf("iguana_dPoWupdate missing src.(%s) %p or dest.(%s) %p\n",dp->symbol,src,dp->dest,dest); From 21b572bb51c2bf697db747405af44726e21d0305 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 19 Oct 2017 14:42:07 +0300 Subject: [PATCH 17/18] Test --- iguana/iguana_notary.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index 10744b6b5..aba869865 100755 --- a/iguana/iguana_notary.c +++ b/iguana/iguana_notary.c @@ -318,12 +318,12 @@ void iguana_dPoWupdate(struct supernet_info *myinfo,struct dpow_info *dp) dpow_srcupdate(myinfo,dp,dp->lastheight++,blockhash,(uint32_t)time(NULL),blocktime); } } - else if ( time(NULL) > dp->lastsrcupdate+60 ) + else if ( time(NULL) > dp->lastsrcupdate+60 || height != dp->lastheight ) { + dp->lastsrcupdate = (uint32_t)time(NULL); dp->lastheight = height; blockhash = dpow_getblockhash(myinfo,src,dp->lastheight); dpow_srcupdate(myinfo,dp,dp->lastheight,blockhash,(uint32_t)time(NULL),blocktime); - dp->lastsrcupdate = (uint32_t)time(NULL); } } //else printf("error getchaintip for %s\n",dp->symbol); } else printf("iguana_dPoWupdate missing src.(%s) %p or dest.(%s) %p\n",dp->symbol,src,dp->dest,dest); From a9bce5b3c6d8ed4be7d008f2fd252a3cd67e2766 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 19 Oct 2017 15:00:28 +0300 Subject: [PATCH 18/18] Test --- iguana/exchanges/LP_nativeDEX.c | 1 + iguana/exchanges/LP_swap.c | 2 ++ iguana/exchanges/LP_transaction.c | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index ea317996d..43db6df03 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -19,6 +19,7 @@ // marketmaker // // dPoW security -> 4: KMD notarized, 5: BTC notarized +// locktime to fee // new testchain // sign critical api calls (pubkey reg, listunspent, orders?) // process stats.log local file -> map of realtime activity! diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index c7f4cd457..9118b4b49 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -1097,6 +1097,8 @@ struct basilisk_swap *bitcoin_swapinit(bits256 privkey,uint8_t *pubkey33,bits256 basilisk_rawtx_setparms("myfee",swap->I.req.quoteid,&swap->myfee,&swap->alicecoin,0,0,LP_DEXFEE(swap->I.alicesatoshis) + swap->alicecoin.txfee,0,0,jumblrflag); alicepub33 = pubkey33; } + swap->myfee.I.locktime = swap->I.started + 1; + swap->otherfee.I.locktime = swap->I.started + 1; basilisk_rawtx_setparms("bobdeposit",swap->I.req.quoteid,&swap->bobdeposit,&swap->bobcoin,swap->I.bobconfirms,0,LP_DEPOSITSATOSHIS(swap->I.bobsatoshis) + swap->bobcoin.txfee,4,0,jumblrflag); basilisk_rawtx_setparms("bobrefund",swap->I.req.quoteid,&swap->bobrefund,&swap->bobcoin,1,4,LP_DEPOSITSATOSHIS(swap->I.bobsatoshis),1,bobpub33,jumblrflag); swap->bobrefund.I.suppress_pubkeys = 1; diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index ff032f126..eaf6414f4 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -1630,7 +1630,7 @@ int32_t LP_verify_otherfee(struct basilisk_swap *swap,uint8_t *data,int32_t data { if ( LP_rawtx_spendscript(swap,swap->bobcoin.longestchain,&swap->otherfee,0,data,datalen,0) == 0 ) { - printf("otherfee amount %.8f -> %s vs %s\n",dstr(swap->otherfee.I.amount),swap->otherfee.p2shaddr,swap->otherfee.I.destaddr); + printf("otherfee amount %.8f -> %s vs %s locktime %u vs %u\n",dstr(swap->otherfee.I.amount),swap->otherfee.p2shaddr,swap->otherfee.I.destaddr,swap->otherfee.I.locktime,swap->I.started+1); if ( strcmp(swap->otherfee.I.destaddr,swap->otherfee.p2shaddr) == 0 ) { printf("dexfee verified\n");