From d708378c75e6cd42a86e82e1f75be2d70f3e823f Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Fri, 30 Mar 2018 16:52:26 +0700 Subject: [PATCH 001/139] Do not do autosplit temporary. --- iguana/exchanges/LP_ordermatch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index 9c7d029ff..fab82a94c 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -1489,9 +1489,9 @@ char *LP_autobuy(void *ctx,int32_t fomoflag,char *myipaddr,int32_t mypubsock,cha if ( time(NULL) > relcoin->lastautosplit+300 ) { relcoin->lastautosplit = (uint32_t)time(NULL); - return(LP_autosplit(relcoin)); + //return(LP_autosplit(relcoin)); } - return(clonestr("{\"error\":\"not enough utxo, please make more deposits\"}")); + //return(clonestr("{\"error\":\"not enough utxo, please make more deposits\"}")); } LP_txfees(&txfee,&desttxfee,base,rel); if ( txfee != 0 && txfee < 10000 ) From 21e44c948d652dafa5b494ad59ac9b8a7953f805 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Fri, 30 Mar 2018 18:29:30 +0700 Subject: [PATCH 002/139] Put back utxo autosplit. --- iguana/exchanges/LP_ordermatch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index fab82a94c..9c7d029ff 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -1489,9 +1489,9 @@ char *LP_autobuy(void *ctx,int32_t fomoflag,char *myipaddr,int32_t mypubsock,cha if ( time(NULL) > relcoin->lastautosplit+300 ) { relcoin->lastautosplit = (uint32_t)time(NULL); - //return(LP_autosplit(relcoin)); + return(LP_autosplit(relcoin)); } - //return(clonestr("{\"error\":\"not enough utxo, please make more deposits\"}")); + return(clonestr("{\"error\":\"not enough utxo, please make more deposits\"}")); } LP_txfees(&txfee,&desttxfee,base,rel); if ( txfee != 0 && txfee < 10000 ) From 50039e133fd217265eb1d02ea86a05bfec71621a Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Fri, 30 Mar 2018 19:39:26 +0700 Subject: [PATCH 003/139] Cache hunter dir for appveyor CI. --- appveyor.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index de2123bc5..6e9d287c4 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,4 +3,6 @@ branches: only: - etomic build_script: -- cmd: marketmaker_build_etomic.cmd \ No newline at end of file +- cmd: marketmaker_build_etomic.cmd +cache: + - C:\.hunter \ No newline at end of file From ff8bb561ba7ae895e80cb99c5d52800c143c7b06 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Fri, 30 Mar 2018 20:33:35 +0700 Subject: [PATCH 004/139] Cache cpp-ethereum dir for appveyor CI. --- appveyor.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 6e9d287c4..69d821f95 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,4 +5,5 @@ branches: build_script: - cmd: marketmaker_build_etomic.cmd cache: - - C:\.hunter \ No newline at end of file + - C:\.hunter + - cpp-ethereum \ No newline at end of file From fadfed170a34226b5f4f6c3f048e09cc81ebdfa6 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Mon, 2 Apr 2018 14:54:17 +0700 Subject: [PATCH 005/139] Add deployment to travis. --- .travis.yml | 18 +++++++++++++++++- cpp-ethereum | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5730c4869..95c2e01d1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,23 @@ script: - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cmake -DCMAKE_C_COMPILER=/usr/bin/gcc-7 -DCMAKE_CXX_COMPILER=/usr/bin/g++-7 ..; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cmake ..; fi - cmake --build . --target marketmaker-mainnet + - cmake --build . --target marketmaker-testnet cache: directories: - - $HOME/.hunter \ No newline at end of file + - $HOME/.hunter + +before_deploy: + - export TAG=`echo "$(git rev-parse --short HEAD)"` + - mkdir deploy + - cp build/iguana/exchanges/marketmaker-mainnet deploy/marketmaket-mainnet-"$TRAVIS_OS_NAME"-"$TAG" + - cp build/iguana/exchanges/marketmaker-testnet deploy/marketmaket-testnet-"$TRAVIS_OS_NAME"-"$TAG" +deploy: + provider: releases + api_key: + secure: "KT5rtFexiRqOE39yeEXHa23cL1h4tPIKdWtlDoLr/E8eLA+X+4C6tyYuoZc1tqB/ZD3Wx3YovffAX0iHei61Je+So2mFp79+7XFPh08U1xi1g92KvGrjVnZcF+2KEwh6Yan+IcpQKvSlJAEYB2BPmxLNdYKSc1NNOT5vcjaPNhoDzqmz2V01bcePj8QbipgB2aeWl0Wvp+2mt/NsYF12DYLKHWKFITEXrAbgTp9jzczIhRBH4o83ZQhWZKAMl+X8Bo15WLGMTvd5dnjfix85LQIBJZ2D+piVDdjIIXJhdKK3/zVQMMGwrSvv/a0H5UOktpbUWpnK/W5TkkB3LWOdIifNY35KTics6PQevJq61fX8lWP0t4fMLzwqTNyMZnZmHUt/+eLPbFFmM0Kvje1x+FkQ5279OnNG1EMdfqwhmxs1j4G+37yz9+9hfqODhg70sqSDSzx+sWtBDl0/2EmdIsVq+UcT2xOWqwUqNLkO5/1LNHpNrB1UVQTnYIrF7tE1WoZcZy/9E9vxz1bQguzllv6boNtHdSejsDRKvAgUYivVqmrgjgIUfBFQxvxtrZJvmk8BHlI81AcxKc4Xf3H3sAEq7ssC8gQIBs6AcZdofdx/XSHQnq+EnMDBBNz2whV3BjsxN839AtM9C8yHZJbnue7dZwjp/vXE/s7eRwF094I=" + file: + - deploy/marketmaket-mainnet-"$TRAVIS_OS_NAME"-"$TAG" + - deploy/marketmaket-testnet-"$TRAVIS_OS_NAME"-"$TAG" + on: + tags: false \ No newline at end of file diff --git a/cpp-ethereum b/cpp-ethereum index c25a98257..2b552430d 160000 --- a/cpp-ethereum +++ b/cpp-ethereum @@ -1 +1 @@ -Subproject commit c25a98257e7104875503e183dd0f27d49b3efd56 +Subproject commit 2b552430d57c247d526394cf0075ebb7a680d725 From dddb7f68b6382da6faf26c64b861c33ad9118877 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Mon, 2 Apr 2018 15:07:02 +0700 Subject: [PATCH 006/139] Publish release on etomic branch only. --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 95c2e01d1..7075dbc5f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,4 +43,7 @@ deploy: - deploy/marketmaket-mainnet-"$TRAVIS_OS_NAME"-"$TAG" - deploy/marketmaket-testnet-"$TRAVIS_OS_NAME"-"$TAG" on: - tags: false \ No newline at end of file + tags: false + branches: + only: + - etomic \ No newline at end of file From ba8595033a19fa50c69a8ec5d2bf1060f80bed9e Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Mon, 2 Apr 2018 15:22:51 +0700 Subject: [PATCH 007/139] Remove etomic only branch from travis. --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7075dbc5f..1c557263a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,6 +44,3 @@ deploy: - deploy/marketmaket-testnet-"$TRAVIS_OS_NAME"-"$TAG" on: tags: false - branches: - only: - - etomic \ No newline at end of file From f1dea172f60433535d397ec9d58708f069f703ac Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Mon, 2 Apr 2018 17:10:42 +0700 Subject: [PATCH 008/139] Fix deploy. --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1c557263a..a1646b762 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,8 +33,8 @@ cache: before_deploy: - export TAG=`echo "$(git rev-parse --short HEAD)"` - mkdir deploy - - cp build/iguana/exchanges/marketmaker-mainnet deploy/marketmaket-mainnet-"$TRAVIS_OS_NAME"-"$TAG" - - cp build/iguana/exchanges/marketmaker-testnet deploy/marketmaket-testnet-"$TRAVIS_OS_NAME"-"$TAG" + - cp iguana/exchanges/marketmaker-mainnet deploy/marketmaket-mainnet-"$TRAVIS_OS_NAME"-"$TAG" + - cp iguana/exchanges/marketmaker-testnet deploy/marketmaket-testnet-"$TRAVIS_OS_NAME"-"$TAG" deploy: provider: releases api_key: From 1a5460111faf30a75370c646523d71d98ea0b155 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Mon, 2 Apr 2018 17:25:59 +0700 Subject: [PATCH 009/139] Fix deploy. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a1646b762..02ae6f3b2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,7 +38,7 @@ before_deploy: deploy: provider: releases api_key: - secure: "KT5rtFexiRqOE39yeEXHa23cL1h4tPIKdWtlDoLr/E8eLA+X+4C6tyYuoZc1tqB/ZD3Wx3YovffAX0iHei61Je+So2mFp79+7XFPh08U1xi1g92KvGrjVnZcF+2KEwh6Yan+IcpQKvSlJAEYB2BPmxLNdYKSc1NNOT5vcjaPNhoDzqmz2V01bcePj8QbipgB2aeWl0Wvp+2mt/NsYF12DYLKHWKFITEXrAbgTp9jzczIhRBH4o83ZQhWZKAMl+X8Bo15WLGMTvd5dnjfix85LQIBJZ2D+piVDdjIIXJhdKK3/zVQMMGwrSvv/a0H5UOktpbUWpnK/W5TkkB3LWOdIifNY35KTics6PQevJq61fX8lWP0t4fMLzwqTNyMZnZmHUt/+eLPbFFmM0Kvje1x+FkQ5279OnNG1EMdfqwhmxs1j4G+37yz9+9hfqODhg70sqSDSzx+sWtBDl0/2EmdIsVq+UcT2xOWqwUqNLkO5/1LNHpNrB1UVQTnYIrF7tE1WoZcZy/9E9vxz1bQguzllv6boNtHdSejsDRKvAgUYivVqmrgjgIUfBFQxvxtrZJvmk8BHlI81AcxKc4Xf3H3sAEq7ssC8gQIBs6AcZdofdx/XSHQnq+EnMDBBNz2whV3BjsxN839AtM9C8yHZJbnue7dZwjp/vXE/s7eRwF094I=" + secure: "JDwFBGO4WLra9bXr2dsovet8y/ymC0Y+LJNr5/qlUIDt97zVytGbIlUc8BuI2VZFcnAvrtfOGdCs9m/PcLzZd4bMxXSsuaU0AJk/Vj9KzrIIGPJ4uS39KpO1USUpPW+5e0Bisf30JN3N2NypwMbMu42TKjVqaXSbVQfh79Iu6PdnyfiFbbTEfMeiRRrD72c00rwAw7kmndf7Sv9MiMN8WTFe0cQz5eH8GU/BSbnDorSrtClU4r7McR98zXaig/8XVcT543tcqdYW95QO7OqOjAid3XzzA/bPUTjC/nF/AyTJDco26nts0bCrCYeZRXIWdEInFLIeRHhHD7sW7dILRT/I7WlaLWnRtwo8e1L+U1k1yZ84dQMpgBznttdwH3vSj0crwCbFuMaRMMbPeW0H8C1VitLy1mlapw3RDI9yKlcw4V6WjPbz0YKhAoZgT/M/SaGr4ZkoWNCPoV5+Gub78p24Y8Y9BptJgj5t9KAcmDwbJ9wPt006ObWnbXvapo+6N5Dk2zuyQe9seoupzy4CAiNdluzAAVWsV/SjnN2aapjXoxaAaLQC6T8C1l1BpYri9LSKrjerr4QLVl/nw2yovAKNEobLLBVpSwfg4R72fu1BMS65gVsOqtFfs+R47CY+1D1Slev+UmKNMdE51+aXM+1XeC6wDUS5d13mW1NLhOE=" file: - deploy/marketmaket-mainnet-"$TRAVIS_OS_NAME"-"$TAG" - deploy/marketmaket-testnet-"$TRAVIS_OS_NAME"-"$TAG" From 6f1f8e7e0948c16a01891d7e6d7ed5f32546830a Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Mon, 2 Apr 2018 17:37:21 +0700 Subject: [PATCH 010/139] Skip cleanup. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 02ae6f3b2..92f30a8e0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,3 +44,4 @@ deploy: - deploy/marketmaket-testnet-"$TRAVIS_OS_NAME"-"$TAG" on: tags: false + skip_cleanup: true From 58b3c9c9256b70cacf1b2936d193123aa24b4949 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Mon, 2 Apr 2018 18:41:37 +0700 Subject: [PATCH 011/139] Use file_glob for travis deployment. --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 92f30a8e0..16488f158 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,9 +39,8 @@ deploy: provider: releases api_key: secure: "JDwFBGO4WLra9bXr2dsovet8y/ymC0Y+LJNr5/qlUIDt97zVytGbIlUc8BuI2VZFcnAvrtfOGdCs9m/PcLzZd4bMxXSsuaU0AJk/Vj9KzrIIGPJ4uS39KpO1USUpPW+5e0Bisf30JN3N2NypwMbMu42TKjVqaXSbVQfh79Iu6PdnyfiFbbTEfMeiRRrD72c00rwAw7kmndf7Sv9MiMN8WTFe0cQz5eH8GU/BSbnDorSrtClU4r7McR98zXaig/8XVcT543tcqdYW95QO7OqOjAid3XzzA/bPUTjC/nF/AyTJDco26nts0bCrCYeZRXIWdEInFLIeRHhHD7sW7dILRT/I7WlaLWnRtwo8e1L+U1k1yZ84dQMpgBznttdwH3vSj0crwCbFuMaRMMbPeW0H8C1VitLy1mlapw3RDI9yKlcw4V6WjPbz0YKhAoZgT/M/SaGr4ZkoWNCPoV5+Gub78p24Y8Y9BptJgj5t9KAcmDwbJ9wPt006ObWnbXvapo+6N5Dk2zuyQe9seoupzy4CAiNdluzAAVWsV/SjnN2aapjXoxaAaLQC6T8C1l1BpYri9LSKrjerr4QLVl/nw2yovAKNEobLLBVpSwfg4R72fu1BMS65gVsOqtFfs+R47CY+1D1Slev+UmKNMdE51+aXM+1XeC6wDUS5d13mW1NLhOE=" - file: - - deploy/marketmaket-mainnet-"$TRAVIS_OS_NAME"-"$TAG" - - deploy/marketmaket-testnet-"$TRAVIS_OS_NAME"-"$TAG" + file_glob: true + file: "deploy/*" on: tags: false skip_cleanup: true From ab2d0c414215b3cca72d41d12fb9515c0e2d889f Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Mon, 2 Apr 2018 19:26:55 +0700 Subject: [PATCH 012/139] Strip and pack executables on deployment. --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 16488f158..77823b9df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,8 +33,9 @@ cache: before_deploy: - export TAG=`echo "$(git rev-parse --short HEAD)"` - mkdir deploy - - cp iguana/exchanges/marketmaker-mainnet deploy/marketmaket-mainnet-"$TRAVIS_OS_NAME"-"$TAG" - - cp iguana/exchanges/marketmaker-testnet deploy/marketmaket-testnet-"$TRAVIS_OS_NAME"-"$TAG" + - strip iguana/exchanges/marketmaker-mainnet + - strip iguana/exchanges/marketmaker-testnet + - tar -cvzf deploy/marketmaker-"$TRAVIS_OS_NAME"-"$TAG".tar.gz iguana/exchanges/marketmaker-mainnet iguana/exchanges/marketmaker-testnet deploy: provider: releases api_key: From 8eca77a2077005125a168845fb9134c94e30ee95 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Mon, 2 Apr 2018 19:57:56 +0700 Subject: [PATCH 013/139] Avoid iguana/exchanges path adding to binaries archive. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 77823b9df..f2ea4f5f1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,7 +35,7 @@ before_deploy: - mkdir deploy - strip iguana/exchanges/marketmaker-mainnet - strip iguana/exchanges/marketmaker-testnet - - tar -cvzf deploy/marketmaker-"$TRAVIS_OS_NAME"-"$TAG".tar.gz iguana/exchanges/marketmaker-mainnet iguana/exchanges/marketmaker-testnet + - tar -cvzf deploy/marketmaker-"$TRAVIS_OS_NAME"-"$TAG".tar.gz -C iguana/exchanges marketmaker-mainnet marketmaker-testnet deploy: provider: releases api_key: From 75b4c347f7ac73fa2a6fd30458bb42bb0fe326db Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Mon, 2 Apr 2018 20:44:53 +0700 Subject: [PATCH 014/139] Add deploy stage to appveyor build. --- appveyor.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 69d821f95..2df4a603d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,4 +6,15 @@ build_script: - cmd: marketmaker_build_etomic.cmd cache: - C:\.hunter - - cpp-ethereum \ No newline at end of file + - cpp-ethereum + +deploy: + release: marketmaker-v$(appveyor_build_version) + provider: GitHub + auth_token: + secure: iabzoz73JgtOIyE/Nmz4a4XefmK+7pIeup+1Hunj4hGKrdfesFN+176DMApgfu8t + artifact: build_win64_release\iguana\exchanges\marketmaker-mainnet.exe + draft: false + prerelease: false + on: + branch: master From b6d3045c1cec698e6b47e38842a971f093f5e199 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Mon, 2 Apr 2018 20:49:18 +0700 Subject: [PATCH 015/139] Build only master by appveyor. --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 2df4a603d..816837e4a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,7 @@ version: 1.0.{build} branches: only: - - etomic + - master build_script: - cmd: marketmaker_build_etomic.cmd cache: From dab9f1e82fbb3c8a9f108584c1c4561960363d3f Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Mon, 2 Apr 2018 21:16:23 +0700 Subject: [PATCH 016/139] Deploy appveyor not only on tags pushing. --- appveyor.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/appveyor.yml b/appveyor.yml index 816837e4a..e2c31e2b0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -18,3 +18,4 @@ deploy: prerelease: false on: branch: master + appveyor_repo_tag: false \ No newline at end of file From ce83ab03f32bb94642ff9eb6a6ed12b5814683b8 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Tue, 3 Apr 2018 12:30:45 +0700 Subject: [PATCH 017/139] Update executable path for appveyor deploy. --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index e2c31e2b0..31792e96e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -13,7 +13,7 @@ deploy: provider: GitHub auth_token: secure: iabzoz73JgtOIyE/Nmz4a4XefmK+7pIeup+1Hunj4hGKrdfesFN+176DMApgfu8t - artifact: build_win64_release\iguana\exchanges\marketmaker-mainnet.exe + artifact: build_win64_release\iguana\exchanges\Release\marketmaker-mainnet.exe draft: false prerelease: false on: From 3265b13222c5383e70c368679843d1b4c62dbf27 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Tue, 3 Apr 2018 13:01:03 +0700 Subject: [PATCH 018/139] Add mm executable to appveyor artifacts. --- appveyor.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 31792e96e..64e37c4d4 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -8,12 +8,16 @@ cache: - C:\.hunter - cpp-ethereum +artifacts: + - path: build_win64_release\iguana\exchanges\Release\marketmaker-mainnet.exe + name: marketmaker-mainnet.exe + deploy: release: marketmaker-v$(appveyor_build_version) provider: GitHub auth_token: secure: iabzoz73JgtOIyE/Nmz4a4XefmK+7pIeup+1Hunj4hGKrdfesFN+176DMApgfu8t - artifact: build_win64_release\iguana\exchanges\Release\marketmaker-mainnet.exe + artifact: marketmaker-mainnet.exe draft: false prerelease: false on: From dd89db07c71760c2a7034447d85fd0220e47c44b Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Tue, 3 Apr 2018 14:15:36 +0700 Subject: [PATCH 019/139] Pack win exe and dlls to archive. --- appveyor.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 64e37c4d4..4c5a92ea0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -7,17 +7,21 @@ build_script: cache: - C:\.hunter - cpp-ethereum + - marketmaker_depends + +after_build: + - 7z a mm-win.zip build_win64_release\iguana\exchanges\Release\marketmaker-mainnet.exe marketmaker_depends/curl/build_msvc_2015_win64/lib/Release/libcurl.dll marketmaker_depends/nanomsg/build_msvc_2015_win64/Release/nanomsg.dll artifacts: - - path: build_win64_release\iguana\exchanges\Release\marketmaker-mainnet.exe - name: marketmaker-mainnet.exe + - path: mm-win.zip + name: marketmaker-mainnet deploy: release: marketmaker-v$(appveyor_build_version) provider: GitHub auth_token: secure: iabzoz73JgtOIyE/Nmz4a4XefmK+7pIeup+1Hunj4hGKrdfesFN+176DMApgfu8t - artifact: marketmaker-mainnet.exe + artifact: marketmaker-mainnet draft: false prerelease: false on: From 1d3ba0816e44ef71aa990cf27a8ef39d281964ca Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Tue, 3 Apr 2018 14:45:08 +0700 Subject: [PATCH 020/139] Don't include path to windows release archive. --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 4c5a92ea0..014b4c4d2 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -10,7 +10,7 @@ cache: - marketmaker_depends after_build: - - 7z a mm-win.zip build_win64_release\iguana\exchanges\Release\marketmaker-mainnet.exe marketmaker_depends/curl/build_msvc_2015_win64/lib/Release/libcurl.dll marketmaker_depends/nanomsg/build_msvc_2015_win64/Release/nanomsg.dll + - 7z a mm-win.zip .\build_win64_release\iguana\exchanges\Release\marketmaker-mainnet.exe .\marketmaker_depends\curl\build_msvc_2015_win64\lib\Release\libcurl.dll .\marketmaker_depends\nanomsg\build_msvc_2015_win64\Release\nanomsg.dll artifacts: - path: mm-win.zip From f6cdc4ecdbfedbf4949d8a0948e379c032f6e6f8 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Tue, 3 Apr 2018 17:36:17 +0700 Subject: [PATCH 021/139] Deploy on tags only. --- .travis.yml | 2 +- appveyor.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f2ea4f5f1..145e4ba91 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,5 +43,5 @@ deploy: file_glob: true file: "deploy/*" on: - tags: false + tags: true skip_cleanup: true diff --git a/appveyor.yml b/appveyor.yml index 014b4c4d2..014ce03c4 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -26,4 +26,4 @@ deploy: prerelease: false on: branch: master - appveyor_repo_tag: false \ No newline at end of file + appveyor_repo_tag: true \ No newline at end of file From bc40f32cdfb36f92ea659552d10e59daf04941e1 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Tue, 3 Apr 2018 19:08:15 +0700 Subject: [PATCH 022/139] Update appveyor.yml. --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 014ce03c4..63302d68f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,5 @@ version: 1.0.{build} +shallow_clone: true branches: only: - master @@ -25,5 +26,4 @@ deploy: draft: false prerelease: false on: - branch: master appveyor_repo_tag: true \ No newline at end of file From 160700d73d0486a33f95288eb5eac3b486353ea1 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Tue, 3 Apr 2018 20:11:51 +0700 Subject: [PATCH 023/139] Tag by appveyor and then travis build will be trigerred. --- appveyor.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 63302d68f..a909db77a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,8 +1,5 @@ version: 1.0.{build} shallow_clone: true -branches: - only: - - master build_script: - cmd: marketmaker_build_etomic.cmd cache: @@ -26,4 +23,5 @@ deploy: draft: false prerelease: false on: - appveyor_repo_tag: true \ No newline at end of file + branch: master + appveyor_repo_tag: false \ No newline at end of file From e01e0ba283e9856e5a426aea4ad6f6afb546543b Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Mon, 9 Apr 2018 18:12:43 +0700 Subject: [PATCH 024/139] Display appveyor build number as marketmaker version. --- .travis.yml | 3 ++- appveyor.yml | 2 +- iguana/exchanges/CMakeLists.txt | 7 ++++++- iguana/exchanges/LP_nativeDEX.c | 8 +++++--- iguana/exchanges/mm.c | 1 + marketmaker_build_etomic.cmd | 2 +- 6 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 145e4ba91..5134babf8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,8 +20,9 @@ before_install: - git submodule update --init --recursive script: + - export VERSION=`echo "$(git tag -l --points-at HEAD)"` - mkdir build && cd build - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cmake -DCMAKE_C_COMPILER=/usr/bin/gcc-7 -DCMAKE_CXX_COMPILER=/usr/bin/g++-7 ..; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cmake -DMM_VERSION="$VERSION" -DCMAKE_C_COMPILER=/usr/bin/gcc-7 -DCMAKE_CXX_COMPILER=/usr/bin/g++-7 ..; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cmake ..; fi - cmake --build . --target marketmaker-mainnet - cmake --build . --target marketmaker-testnet diff --git a/appveyor.yml b/appveyor.yml index a909db77a..c227d9031 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -15,7 +15,7 @@ artifacts: name: marketmaker-mainnet deploy: - release: marketmaker-v$(appveyor_build_version) + release: v$(appveyor_build_version) provider: GitHub auth_token: secure: iabzoz73JgtOIyE/Nmz4a4XefmK+7pIeup+1Hunj4hGKrdfesFN+176DMApgfu8t diff --git a/iguana/exchanges/CMakeLists.txt b/iguana/exchanges/CMakeLists.txt index 793aeb5a4..011e4cd37 100644 --- a/iguana/exchanges/CMakeLists.txt +++ b/iguana/exchanges/CMakeLists.txt @@ -31,4 +31,9 @@ target_link_libraries(marketmaker-mainnet ${MM_LIBS} etomiclib-mainnet) if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") target_link_libraries(marketmaker-mainnet -static-libgcc -static-libstdc++) target_link_libraries(marketmaker-testnet -static-libgcc -static-libstdc++) -endif() \ No newline at end of file +endif() +if(NOT DEFINED MM_VERSION) + SET(MM_VERSION UNKNOWN) +endif() +target_compile_definitions(marketmaker-mainnet PRIVATE -DMM_VERSION="${MM_VERSION}") +target_compile_definitions(marketmaker-testnet PRIVATE -DMM_VERSION="${MM_VERSION}") \ No newline at end of file diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index d715efc8c..55d74e87a 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -30,6 +30,9 @@ // there is an issue about waiting for notarization for a swap that never starts (expiration ok) #include +#ifndef MM_VERSION +#define MM_VERSION "UNKNOWN" +#endif long LP_cjson_allocated,LP_cjson_total,LP_cjson_count; @@ -1290,8 +1293,7 @@ extern int32_t bitcoind_RPC_inittime; void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybusport,char *passphrase,int32_t amclient,char *userhome,cJSON *argjson) { - char *myipaddr=0,version[64]; long filesize,n; int32_t valid,timeout; struct LP_peerinfo *mypeer=0; char pushaddr[128],subaddr[128],bindaddr[128],*coins_str=0; cJSON *coinsjson=0; void *ctx = bitcoin_ctx(); - sprintf(version,"Marketmaker %s.%s %s rsize.%ld",LP_MAJOR_VERSION,LP_MINOR_VERSION,LP_BUILD_NUMBER,sizeof(struct basilisk_request)); + char *myipaddr=0; long filesize,n; int32_t valid,timeout; struct LP_peerinfo *mypeer=0; char pushaddr[128],subaddr[128],bindaddr[128],*coins_str=0; cJSON *coinsjson=0; void *ctx = bitcoin_ctx(); bitcoind_RPC_inittime = 1; if ( LP_MAXPRICEINFOS > 256 ) { @@ -1299,7 +1301,7 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybu exit(-1); } LP_showwif = juint(argjson,"wif"); - printf("showwif.%d %s %u\n",LP_showwif,version,calc_crc32(0,version,(int32_t)strlen(version))); + printf("showwif.%d version: %s %u\n",LP_showwif,MM_VERSION,calc_crc32(0,MM_VERSION,(int32_t)strlen(MM_VERSION))); if ( passphrase == 0 || passphrase[0] == 0 ) { printf("jeezy says we cant use the nullstring as passphrase and I agree\n"); diff --git a/iguana/exchanges/mm.c b/iguana/exchanges/mm.c index c35046538..f83b6c2a2 100644 --- a/iguana/exchanges/mm.c +++ b/iguana/exchanges/mm.c @@ -164,6 +164,7 @@ int main(int argc, const char * argv[]) { char dirname[512]; double incr; cJSON *retjson; OS_init(); + printf("BarterDEX Marketmaker %s \n",MM_VERSION); if ( strstr(argv[0],"btc2kmd") != 0 && argv[1] != 0 ) { bits256 privkey,checkkey; uint8_t tmptype; char kmdwif[64],str[65],str2[65],*retstr; diff --git a/marketmaker_build_etomic.cmd b/marketmaker_build_etomic.cmd index ed76db72c..cd0d5bbd0 100644 --- a/marketmaker_build_etomic.cmd +++ b/marketmaker_build_etomic.cmd @@ -16,7 +16,7 @@ call scripts\install_deps.bat cd .. mkdir build_win64_release cd build_win64_release -cmake .. -G "Visual Studio 14 2015 Win64" +cmake .. -G "Visual Studio 14 2015 Win64" -DMM_VERSION="%APPVEYOR_BUILD_VERSION%" rem Steps before build: rem From 0c0bb4552d81a61dce247c69e61bede001ca6687 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Mon, 9 Apr 2018 20:01:10 +0700 Subject: [PATCH 025/139] Display appveyor build number as marketmaker version. Fix MacOS. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5134babf8..dc356dfa7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,7 @@ script: - export VERSION=`echo "$(git tag -l --points-at HEAD)"` - mkdir build && cd build - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cmake -DMM_VERSION="$VERSION" -DCMAKE_C_COMPILER=/usr/bin/gcc-7 -DCMAKE_CXX_COMPILER=/usr/bin/g++-7 ..; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cmake ..; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cmake -DMM_VERSION="$VERSION" ..; fi - cmake --build . --target marketmaker-mainnet - cmake --build . --target marketmaker-testnet From 3c25484e41452edffc9865d7fab2091b7496a730 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Mon, 9 Apr 2018 20:34:27 +0700 Subject: [PATCH 026/139] Include MSVC++ redistributable DLLs to Windows release. --- appveyor.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index c227d9031..0acf13812 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -8,7 +8,12 @@ cache: - marketmaker_depends after_build: - - 7z a mm-win.zip .\build_win64_release\iguana\exchanges\Release\marketmaker-mainnet.exe .\marketmaker_depends\curl\build_msvc_2015_win64\lib\Release\libcurl.dll .\marketmaker_depends\nanomsg\build_msvc_2015_win64\Release\nanomsg.dll + - > 7z a mm-win.zip + .\build_win64_release\iguana\exchanges\Release\marketmaker-mainnet.exe + .\marketmaker_depends\curl\build_msvc_2015_win64\lib\Release\libcurl.dll + .\marketmaker_depends\nanomsg\build_msvc_2015_win64\Release\nanomsg.dll + "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\redist\\x64\\Microsoft.VC140.CRT\\msvcp140.dll" + "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\redist\\x64\\Microsoft.VC140.CRT\\vcruntime140.dll" artifacts: - path: mm-win.zip From d4535037c38111f748e440e90ad2b9933c1bab71 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Mon, 9 Apr 2018 20:36:28 +0700 Subject: [PATCH 027/139] Include MSVC++ redistributable DLLs to Windows release. --- appveyor.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 0acf13812..11c050b61 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -8,12 +8,12 @@ cache: - marketmaker_depends after_build: - - > 7z a mm-win.zip - .\build_win64_release\iguana\exchanges\Release\marketmaker-mainnet.exe - .\marketmaker_depends\curl\build_msvc_2015_win64\lib\Release\libcurl.dll - .\marketmaker_depends\nanomsg\build_msvc_2015_win64\Release\nanomsg.dll - "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\redist\\x64\\Microsoft.VC140.CRT\\msvcp140.dll" - "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\redist\\x64\\Microsoft.VC140.CRT\\vcruntime140.dll" + - '7z a mm-win.zip + .\build_win64_release\iguana\exchanges\Release\marketmaker-mainnet.exe + .\marketmaker_depends\curl\build_msvc_2015_win64\lib\Release\libcurl.dll + .\marketmaker_depends\nanomsg\build_msvc_2015_win64\Release\nanomsg.dll + "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\redist\\x64\\Microsoft.VC140.CRT\\msvcp140.dll" + "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\redist\\x64\\Microsoft.VC140.CRT\\vcruntime140.dll"' artifacts: - path: mm-win.zip From bebf5d50506bb71496b37acc8c130e122b672c0d Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Tue, 10 Apr 2018 16:10:06 +0700 Subject: [PATCH 028/139] #19 Add gas usage estimation on ERC20 transfer. --- iguana/exchanges/etomicswap/etomiccurl.c | 22 +++++++++++++++++++++- iguana/exchanges/etomicswap/etomiccurl.h | 1 + iguana/exchanges/etomicswap/etomiclib.cpp | 10 ++++++++-- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/etomicswap/etomiccurl.c b/iguana/exchanges/etomicswap/etomiccurl.c index e7f1296ee..51dc9efc8 100644 --- a/iguana/exchanges/etomicswap/etomiccurl.c +++ b/iguana/exchanges/etomicswap/etomiccurl.c @@ -186,7 +186,7 @@ char* getEthBalanceRequest(char* address) return balance; } -char* ethCall(char* to, const char* data) +char *ethCall(char *to, const char *data) { cJSON *params = cJSON_CreateArray(); cJSON *txObject = cJSON_CreateObject(); @@ -205,6 +205,26 @@ char* ethCall(char* to, const char* data) return result; } +uint64_t estimateGas(char *from, char *to, const char *data) +{ + cJSON *params = cJSON_CreateArray(); + cJSON *txObject = cJSON_CreateObject(); + cJSON_AddStringToObject(txObject, "from", from); + cJSON_AddStringToObject(txObject, "to", to); + cJSON_AddStringToObject(txObject, "data", data); + cJSON_AddItemToArray(params, txObject); + cJSON_AddItemToArray(params, cJSON_CreateString("latest")); + cJSON *resultJson = sendRpcRequest("eth_estimateGas", params); + cJSON_Delete(params); + uint64_t result = 0; + if (resultJson != NULL && is_cJSON_String(resultJson) && resultJson->valuestring != NULL) { + result = (uint64_t)strtoul(resultJson->valuestring, NULL, 0); + result = (result / 100) * 120; // add 20% because real gas usage might differ from estimate + } + cJSON_Delete(resultJson); + return result; +} + EthTxReceipt getEthTxReceipt(char *txId) { EthTxReceipt result; diff --git a/iguana/exchanges/etomicswap/etomiccurl.h b/iguana/exchanges/etomicswap/etomiccurl.h index c0433bc75..ef58f82fa 100644 --- a/iguana/exchanges/etomicswap/etomiccurl.h +++ b/iguana/exchanges/etomicswap/etomiccurl.h @@ -39,6 +39,7 @@ typedef struct char* sendRawTx(char* rawTx); char* sendRawTxWaitConfirm(char* rawTx); char* ethCall(char* to, const char* data); +uint64_t estimateGas(char *from, char *to, const char *data); int64_t getNonce(char* address); char* getEthBalanceRequest(char* address); EthTxReceipt getEthTxReceipt(char *txId); diff --git a/iguana/exchanges/etomicswap/etomiclib.cpp b/iguana/exchanges/etomicswap/etomiclib.cpp index 204848477..80513e7f5 100644 --- a/iguana/exchanges/etomicswap/etomiclib.cpp +++ b/iguana/exchanges/etomicswap/etomiclib.cpp @@ -624,15 +624,21 @@ char *sendErc20(char *tokenAddress, char *to, char *amount, char *privKey, uint8 { TransactionSkeleton tx; char *from = privKey2Addr(privKey), *result; + std::stringstream ss = getErc20TransferData(tokenAddress, to, amount); + tx.from = jsToAddress(from); tx.to = jsToAddress(tokenAddress); tx.value = 0; - tx.gas = 60000; + uint64_t gas = estimateGas(from, tokenAddress, ss.str().c_str()); + if (gas > 0) { + tx.gas = gas; + } else { + tx.gas = 150000; + } tx.gasPrice = getGasPriceFromStation() * boost::multiprecision::pow(u256(10), 9); tx.nonce = getNonce(from); free(from); - std::stringstream ss = getErc20TransferData(tokenAddress, to, amount); tx.data = jsToBytes(ss.str()); char *rawTx = signTx(tx, privKey); From 1319802aa0078203d6c0ae8ca6764a939a795edd Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Tue, 10 Apr 2018 19:14:51 +0700 Subject: [PATCH 029/139] #16 Add gas and gas price to eth_withdraw. Add eth_gas_price method. --- iguana/exchanges/LP_commands.c | 6 ++++ iguana/exchanges/LP_etomic.c | 4 +-- iguana/exchanges/LP_transaction.c | 36 +++++++++++++++++++---- iguana/exchanges/etomicswap/etomiclib.cpp | 30 ++++++++++++++----- iguana/exchanges/etomicswap/etomiclib.h | 4 +-- 5 files changed, 64 insertions(+), 16 deletions(-) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index a73e28b2e..e55714f42 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -437,6 +437,12 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\ } else if ( strcmp(method,"inuse") == 0 ) return(jprint(LP_inuse_json(),1)); +#ifndef NOTETOMIC + else if ( strcmp(method,"eth_gas_price") == 0 ) + { + return LP_eth_gas_price(ptr); + } +#endif else if ( (retstr= LP_istradebots_command(ctx,pubsock,method,argjson)) != 0 ) return(retstr); if ( base[0] != 0 && rel[0] != 0 ) diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index c6f135a42..5c1e50e63 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -42,9 +42,9 @@ char *LP_etomicalice_send_fee(struct basilisk_swap *swap) uint8arrayToHex(secretKey, swap->persistent_privkey.bytes, 32); LP_etomic_pubkeystr_to_addr(INSTANTDEX_PUBKEY, dexaddr); if (strcmp(swap->I.alicestr,"ETH") == 0 ) { - return(sendEth(dexaddr, amount, secretKey, 1)); + return(sendEth(dexaddr, amount, secretKey, 1, 0, 0)); } else { - return(sendErc20(swap->I.alicetomic, dexaddr, amount, secretKey, 1)); + return(sendErc20(swap->I.alicetomic, dexaddr, amount, secretKey, 1, 0, 0)); } } diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index c1489a30a..615b03dd3 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -1694,28 +1694,54 @@ char *LP_autosplit(struct iguana_info *coin) char *LP_eth_withdraw(struct iguana_info *coin,cJSON *argjson) { cJSON *retjson = cJSON_CreateObject(); + cJSON *gas_json = cJSON_GetObjectItem(argjson, "gas"); + cJSON *gas_price_json = cJSON_GetObjectItem(argjson, "gas_price"); char *dest_addr, *tx_id, privkey_str[70], amount_str[100]; - int64_t amount; + int64_t amount = 0, gas = 0, gas_price = 0; bits256 privkey; dest_addr = jstr(argjson, "to"); + if (dest_addr == NULL) { + return(clonestr("{\"error\":\"param 'to' is required!\"}")); + } amount = jdouble(argjson, "amount") * 100000000; + if (amount == 0) { + return(clonestr("{\"error\":\"'amount' is not set or equal to zero!\"}")); + } + if (gas_json != NULL && is_cJSON_Number(gas_json)) { + gas = gas_json->valueint; + if (gas < 21000) { + return (clonestr("{\"error\":\"'gas' can't be lower than 21000!\"}")); + } + } + if (gas_price_json != NULL && is_cJSON_Number(gas_price_json)) { + gas_price = gas_price_json->valueint; + if (gas_price < 1) { + return (clonestr("{\"error\":\"'gas_price' can't be lower than 1!\"}")); + } + } privkey = LP_privkey(coin->symbol, coin->smartaddr, coin->taddr); uint8arrayToHex(privkey_str, privkey.bytes, 32); satoshisToWei(amount_str, amount); if (strcmp(coin->symbol, "ETH") == 0) { - tx_id = sendEth(dest_addr, amount_str, privkey_str, 0); + tx_id = sendEth(dest_addr, amount_str, privkey_str, 0, gas, gas_price); } else { - tx_id = sendErc20(coin->etomic, dest_addr, amount_str, privkey_str, 0); + tx_id = sendErc20(coin->etomic, dest_addr, amount_str, privkey_str, 0, gas, gas_price); } jaddstr(retjson, "tx_id", tx_id); + free(tx_id); return(jprint(retjson,1)); } +char *LP_eth_gas_price() +{ + cJSON *retjson = cJSON_CreateObject(); + uint64_t gas_price = getGasPriceFromStation(); + cJSON_AddNumberToObject(retjson, "gas_price", gas_price); + return(jprint(retjson,1)); +} #endif - - int32_t basilisk_rawtx_gen(void *ctx,char *str,uint32_t swapstarted,uint8_t *pubkey33,int32_t iambob,int32_t lockinputs,struct basilisk_rawtx *rawtx,uint32_t locktime,uint8_t *script,int32_t scriptlen,int64_t txfee,int32_t minconf,int32_t delay,bits256 privkey,uint8_t *changermd160,char *vinaddr) { struct iguana_info *coin; int32_t len,retval=-1; char *retstr,*hexstr; cJSON *argjson,*outputs,*item,*retjson,*obj; diff --git a/iguana/exchanges/etomicswap/etomiclib.cpp b/iguana/exchanges/etomicswap/etomiclib.cpp index 80513e7f5..f19f9c8ae 100644 --- a/iguana/exchanges/etomicswap/etomiclib.cpp +++ b/iguana/exchanges/etomicswap/etomiclib.cpp @@ -582,15 +582,23 @@ uint64_t weiToSatoshi(char *wei) return static_cast(satoshi); } -char *sendEth(char *to, char *amount, char *privKey, uint8_t waitConfirm) +char *sendEth(char *to, char *amount, char *privKey, uint8_t waitConfirm, int64_t gas, int64_t gasPrice) { TransactionSkeleton tx; char *from = privKey2Addr(privKey), *result; tx.from = jsToAddress(from); tx.to = jsToAddress(to); tx.value = jsToU256(amount); - tx.gas = 21000; - tx.gasPrice = getGasPriceFromStation() * boost::multiprecision::pow(u256(10), 9); + if (gas > 0) { + tx.gas = gas; + } else { + tx.gas = 21000; + } + if (gasPrice > 0) { + tx.gasPrice = gasPrice * boost::multiprecision::pow(u256(10), 9); + } else { + tx.gasPrice = getGasPriceFromStation() * boost::multiprecision::pow(u256(10), 9); + } tx.nonce = getNonce(from); free(from); @@ -620,7 +628,7 @@ std::stringstream getErc20TransferData(char *tokenAddress, char *to, char *amoun return ss; } -char *sendErc20(char *tokenAddress, char *to, char *amount, char *privKey, uint8_t waitConfirm) +char *sendErc20(char *tokenAddress, char *to, char *amount, char *privKey, uint8_t waitConfirm, int64_t gas, int64_t gasPrice) { TransactionSkeleton tx; char *from = privKey2Addr(privKey), *result; @@ -629,13 +637,21 @@ char *sendErc20(char *tokenAddress, char *to, char *amount, char *privKey, uint8 tx.from = jsToAddress(from); tx.to = jsToAddress(tokenAddress); tx.value = 0; - uint64_t gas = estimateGas(from, tokenAddress, ss.str().c_str()); if (gas > 0) { tx.gas = gas; } else { - tx.gas = 150000; + uint64_t gasEstimation = estimateGas(from, tokenAddress, ss.str().c_str()); + if (gasEstimation > 0) { + tx.gas = gasEstimation; + } else { + tx.gas = 150000; + } + } + if (gasPrice > 0) { + tx.gasPrice = gasPrice * boost::multiprecision::pow(u256(10), 9); + } else { + tx.gasPrice = getGasPriceFromStation() * boost::multiprecision::pow(u256(10), 9); } - tx.gasPrice = getGasPriceFromStation() * boost::multiprecision::pow(u256(10), 9); tx.nonce = getNonce(from); free(from); diff --git a/iguana/exchanges/etomicswap/etomiclib.h b/iguana/exchanges/etomicswap/etomiclib.h index c7b846ddb..f409f9381 100644 --- a/iguana/exchanges/etomicswap/etomiclib.h +++ b/iguana/exchanges/etomicswap/etomiclib.h @@ -177,8 +177,8 @@ void uint8arrayToHex(char *dest, uint8_t *input, int len); void satoshisToWei(char *dest, uint64_t input); uint64_t weiToSatoshi(char *wei); -char *sendEth(char *to, char *amount, char *privKey, uint8_t waitConfirm); -char *sendErc20(char *tokenAddress, char *to, char *amount, char *privKey, uint8_t waitConfirm); +char *sendEth(char *to, char *amount, char *privKey, uint8_t waitConfirm, int64_t gas, int64_t gasPrice); +char *sendErc20(char *tokenAddress, char *to, char *amount, char *privKey, uint8_t waitConfirm, int64_t gas, int64_t gasPrice); uint8_t verifyAliceErc20FeeData(char* tokenAddress, char *to, char *amount, char *data); // Your prototype or Definition From 6c4910fa5e7a715c994601d4708d8ebd7671b263 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Tue, 10 Apr 2018 19:39:32 +0700 Subject: [PATCH 030/139] Remove not needed argument for LP_eth_gas_price. --- iguana/exchanges/LP_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index e55714f42..28f7a0c51 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -440,7 +440,7 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\ #ifndef NOTETOMIC else if ( strcmp(method,"eth_gas_price") == 0 ) { - return LP_eth_gas_price(ptr); + return LP_eth_gas_price(); } #endif else if ( (retstr= LP_istradebots_command(ctx,pubsock,method,argjson)) != 0 ) From a35ef8ed1449f0b1c79d4a33e557f47cc023f823 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Tue, 10 Apr 2018 20:52:04 +0700 Subject: [PATCH 031/139] Update cpp-ethereum dependency - remove a lot of unused code. --- appveyor.yml | 1 - cpp-ethereum | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 11c050b61..d38c6773d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,7 +4,6 @@ build_script: - cmd: marketmaker_build_etomic.cmd cache: - C:\.hunter - - cpp-ethereum - marketmaker_depends after_build: diff --git a/cpp-ethereum b/cpp-ethereum index 2b552430d..e804e95d9 160000 --- a/cpp-ethereum +++ b/cpp-ethereum @@ -1 +1 @@ -Subproject commit 2b552430d57c247d526394cf0075ebb7a680d725 +Subproject commit e804e95d9a71e87fc5e3e69a2888448f23bc724f From 14a936d3ee365977a0865c4e1f9eae389477b969 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Tue, 10 Apr 2018 21:02:39 +0700 Subject: [PATCH 032/139] Remove cpp-ethereum submodule init from win build script. --- marketmaker_build_etomic.cmd | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/marketmaker_build_etomic.cmd b/marketmaker_build_etomic.cmd index cd0d5bbd0..4329fff8f 100644 --- a/marketmaker_build_etomic.cmd +++ b/marketmaker_build_etomic.cmd @@ -10,9 +10,7 @@ echo [#2] Prepare build etomic needed things ... git submodule init git submodule update --init --recursive cd cpp-ethereum -rem git submodule init -rem git submodule update --init -call scripts\install_deps.bat +call scripts\install_deps.bat cd .. mkdir build_win64_release cd build_win64_release From ab821529bfd4397a1ca624e77718bb3b78971d96 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Tue, 10 Apr 2018 21:08:59 +0700 Subject: [PATCH 033/139] Fix windows build script. --- marketmaker_build_etomic.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/marketmaker_build_etomic.cmd b/marketmaker_build_etomic.cmd index 4329fff8f..227fd74ab 100644 --- a/marketmaker_build_etomic.cmd +++ b/marketmaker_build_etomic.cmd @@ -11,7 +11,7 @@ git submodule init git submodule update --init --recursive cd cpp-ethereum call scripts\install_deps.bat -cd .. +cd . mkdir build_win64_release cd build_win64_release cmake .. -G "Visual Studio 14 2015 Win64" -DMM_VERSION="%APPVEYOR_BUILD_VERSION%" From a8f9c4156bf439b84ef8bfc8ddfd8f8ca1df24f0 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Tue, 10 Apr 2018 21:29:33 +0700 Subject: [PATCH 034/139] Trying to fix win build script. --- marketmaker_build_etomic.cmd | 1 - 1 file changed, 1 deletion(-) diff --git a/marketmaker_build_etomic.cmd b/marketmaker_build_etomic.cmd index 227fd74ab..48b879666 100644 --- a/marketmaker_build_etomic.cmd +++ b/marketmaker_build_etomic.cmd @@ -7,7 +7,6 @@ copy marketmaker_depends\curl\build_msvc_2015_win64\lib\Release\libcurl_imp.lib copy marketmaker_depends\pthread-win32\bin\x64_MSVC2015.Release\pthread_lib.lib marketmaker_depends\pthread-win32\bin\x64_MSVC2015.Release\pthread.lib echo [#2] Prepare build etomic needed things ... -git submodule init git submodule update --init --recursive cd cpp-ethereum call scripts\install_deps.bat From 57cda507eac5a7cc53e9632bc0ef268bc5896a86 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Wed, 11 Apr 2018 13:28:04 +0700 Subject: [PATCH 035/139] Remove shallow clone to avoid issues with submodule init. --- appveyor.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index d38c6773d..3c82ea80a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,4 @@ version: 1.0.{build} -shallow_clone: true build_script: - cmd: marketmaker_build_etomic.cmd cache: From 855bd85cc5d460fb284f98ddbebcbfead894cf5d Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Wed, 11 Apr 2018 13:53:21 +0700 Subject: [PATCH 036/139] Try to build linux with gcc4.8. --- .travis.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index dc356dfa7..fe95858ac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,13 +4,6 @@ matrix: include: - os: linux compiler: gcc - addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - g++-7 - env: OS_NAME=Linux MATRIX_EVAL="CC=gcc-7 && CXX=g++-7" - os: osx compiler: clang env: OS_NAME=Darwin @@ -22,7 +15,7 @@ before_install: script: - export VERSION=`echo "$(git tag -l --points-at HEAD)"` - mkdir build && cd build - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cmake -DMM_VERSION="$VERSION" -DCMAKE_C_COMPILER=/usr/bin/gcc-7 -DCMAKE_CXX_COMPILER=/usr/bin/g++-7 ..; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cmake -DMM_VERSION="$VERSION" ..; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cmake -DMM_VERSION="$VERSION" ..; fi - cmake --build . --target marketmaker-mainnet - cmake --build . --target marketmaker-testnet From 436164cf6dcc5e2fdf2189e06cbe35d4d8fb3721 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Wed, 11 Apr 2018 14:16:28 +0700 Subject: [PATCH 037/139] Keep using gcc7 on Linux because gcc4.8 has bugs and mm doesn't build. --- .travis.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index fe95858ac..dc356dfa7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,13 @@ matrix: include: - os: linux compiler: gcc + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-7 + env: OS_NAME=Linux MATRIX_EVAL="CC=gcc-7 && CXX=g++-7" - os: osx compiler: clang env: OS_NAME=Darwin @@ -15,7 +22,7 @@ before_install: script: - export VERSION=`echo "$(git tag -l --points-at HEAD)"` - mkdir build && cd build - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cmake -DMM_VERSION="$VERSION" ..; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cmake -DMM_VERSION="$VERSION" -DCMAKE_C_COMPILER=/usr/bin/gcc-7 -DCMAKE_CXX_COMPILER=/usr/bin/g++-7 ..; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cmake -DMM_VERSION="$VERSION" ..; fi - cmake --build . --target marketmaker-mainnet - cmake --build . --target marketmaker-testnet From 02d674a47d9b460e097426d2e3996c014230b06a Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Wed, 11 Apr 2018 14:26:29 +0700 Subject: [PATCH 038/139] Install g++-7 on before_install. Cache apt on travis build. --- .travis.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index dc356dfa7..867c7f193 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,12 +4,6 @@ matrix: include: - os: linux compiler: gcc - addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - g++-7 env: OS_NAME=Linux MATRIX_EVAL="CC=gcc-7 && CXX=g++-7" - os: osx compiler: clang @@ -17,6 +11,7 @@ matrix: osx_image: xcode9.2 before_install: + - sudo add-apt-repository ppa:ubuntu-toolchain-r/test && sudo apt-get update && sudo apt-get install -y g++-7 - git submodule update --init --recursive script: @@ -28,8 +23,9 @@ script: - cmake --build . --target marketmaker-testnet cache: - directories: - - $HOME/.hunter + apt: true + directories: + - $HOME/.hunter before_deploy: - export TAG=`echo "$(git rev-parse --short HEAD)"` From 734f1ab3ac3875d8711e4d38c2c6c7c6410a1774 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Wed, 11 Apr 2018 14:27:32 +0700 Subject: [PATCH 039/139] Apt install only on Linux. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 867c7f193..984ebb433 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ matrix: osx_image: xcode9.2 before_install: - - sudo add-apt-repository ppa:ubuntu-toolchain-r/test && sudo apt-get update && sudo apt-get install -y g++-7 + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo add-apt-repository ppa:ubuntu-toolchain-r/test && sudo apt-get update && sudo apt-get install -y g++-7; fi - git submodule update --init --recursive script: From eb5d8cf8f03d816f2d105beb505609c160485c56 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Wed, 11 Apr 2018 14:30:55 +0700 Subject: [PATCH 040/139] -y on gcc7 ppa addition. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 984ebb433..b77bb4622 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ matrix: osx_image: xcode9.2 before_install: - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo add-apt-repository ppa:ubuntu-toolchain-r/test && sudo apt-get update && sudo apt-get install -y g++-7; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && sudo apt-get update && sudo apt-get install -y g++-7; fi - git submodule update --init --recursive script: From 8bcb55b7a63bad06836a659fd6ed674f01b024de Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Wed, 11 Apr 2018 14:53:08 +0700 Subject: [PATCH 041/139] Try another ppa for gcc7. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b77bb4622..fd1322776 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ matrix: osx_image: xcode9.2 before_install: - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && sudo apt-get update && sudo apt-get install -y g++-7; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo add-apt-repository ppa:jonathonf/gcc-7.1 -y && sudo apt-get update && sudo apt-get install -y gcc-7 g++-7; fi - git submodule update --init --recursive script: From 6cf0c5986cfc6917c757a56dc41fee3652a257cc Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Wed, 11 Apr 2018 15:01:12 +0700 Subject: [PATCH 042/139] Put back ubuntu toolchain ppa. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index fd1322776..b77bb4622 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ matrix: osx_image: xcode9.2 before_install: - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo add-apt-repository ppa:jonathonf/gcc-7.1 -y && sudo apt-get update && sudo apt-get install -y gcc-7 g++-7; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && sudo apt-get update && sudo apt-get install -y g++-7; fi - git submodule update --init --recursive script: From 719db158db95882daa0a0ae58389f7a8685971e2 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Wed, 11 Apr 2018 15:35:46 +0700 Subject: [PATCH 043/139] Fix windows build script. --- marketmaker_build_etomic.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/marketmaker_build_etomic.cmd b/marketmaker_build_etomic.cmd index 48b879666..2b8f9a02d 100644 --- a/marketmaker_build_etomic.cmd +++ b/marketmaker_build_etomic.cmd @@ -10,7 +10,7 @@ echo [#2] Prepare build etomic needed things ... git submodule update --init --recursive cd cpp-ethereum call scripts\install_deps.bat -cd . +cd .. mkdir build_win64_release cd build_win64_release cmake .. -G "Visual Studio 14 2015 Win64" -DMM_VERSION="%APPVEYOR_BUILD_VERSION%" From d36d38572611b435d8432e594d9a979bb4558e3c Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Wed, 11 Apr 2018 16:08:13 +0700 Subject: [PATCH 044/139] Do not rebuild win dependencies if they are already built. --- marketmaker_build_depends.cmd | 60 +++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/marketmaker_build_depends.cmd b/marketmaker_build_depends.cmd index a09e0ea04..6a294d20c 100644 --- a/marketmaker_build_depends.cmd +++ b/marketmaker_build_depends.cmd @@ -36,54 +36,66 @@ exit rem MSBuild /help echo. echo Decker will automatically download and build all needed *.dll and *.lib for you ;) -timeout /t 5 /nobreak mkdir marketmaker_depends mkdir x64\Release rem --- pthreads --- :compile_pthreads +if not exist marketmaker_depends\pthread-win32\bin\x64_MSVC2015.Release\pthread_lib.lib ( cd marketmaker_depends git clone https://github.com/DeckerSU/pthread-win32 cd pthread-win32 MSBuild pthread.2015.sln /t:Rebuild /p:Configuration=Release /p:Platform=Win32 MSBuild pthread.2015.sln /t:Rebuild /p:Configuration=Release /p:Platform=x64 cd ../.. +) copy marketmaker_depends\pthread-win32\bin\x64_MSVC2015.Release\pthread_lib.lib OSlibs\win\x64\pthread_lib.lib rem --- nanomsg --- :compile_nanomsg - -cd marketmaker_depends -git clone https://github.com/nanomsg/nanomsg -cd nanomsg -mkdir build_msvc_2015_win32 -mkdir build_msvc_2015_win64 -cd build_msvc_2015_win64 -cmake -G "Visual Studio 14 2015 Win64" .. -cmake --build . --config Release --target nanomsg -cd ../../.. +if not exist marketmaker_depends\nanomsg\build_msvc_2015_win64\Release\nanomsg.lib ( + if not exist marketmaker_depends\nanomsg\build_msvc_2015_win64\Release\nanomsg.exp ( + if not exist marketmaker_depends\nanomsg\build_msvc_2015_win64\Release\nanomsg.dll ( + cd marketmaker_depends + git clone https://github.com/nanomsg/nanomsg + cd nanomsg + mkdir build_msvc_2015_win32 + mkdir build_msvc_2015_win64 + cd build_msvc_2015_win64 + cmake -G "Visual Studio 14 2015 Win64" .. + cmake --build . --config Release --target nanomsg + cd ../../.. + ) + ) +) copy marketmaker_depends\nanomsg\build_msvc_2015_win64\Release\nanomsg.lib OSlibs\win\x64\release\nanomsg.lib copy marketmaker_depends\nanomsg\build_msvc_2015_win64\Release\nanomsg.exp OSlibs\win\x64\release\nanomsg.exp copy marketmaker_depends\nanomsg\build_msvc_2015_win64\Release\nanomsg.dll x64\Release\nanomsg.dll rem --- curl --- :compile_curl -cd marketmaker_depends -git clone https://github.com/curl/curl -cd curl -mkdir build_msvc_2015_win32 -mkdir build_msvc_2015_win64 -cd build_msvc_2015_win64 -cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_USE_WINSSL:BOOL=ON .. -cmake --build . --config Release --target libcurl +if not exist marketmaker_depends\curl\build_msvc_2015_win64\lib\Release\libcurl_imp.lib ( + if not exist marketmaker_depends\curl\build_msvc_2015_win64\lib\Release\libcurl_imp.exp ( + if not exist marketmaker_depends\curl\build_msvc_2015_win64\lib\Release\libcurl.dll ( + cd marketmaker_depends + git clone https://github.com/curl/curl + cd curl + mkdir build_msvc_2015_win32 + mkdir build_msvc_2015_win64 + cd build_msvc_2015_win64 + cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_USE_WINSSL:BOOL=ON .. + cmake --build . --config Release --target libcurl -rem cmake .. -G"Visual Studio 14 2015 Win64" -DCURL_STATICLIB=ON -DCURL_DISABLE_LDAP=ON -DCURL_STATIC_CRT=ON -rem cmake .. -G"Visual Studio 14 2015 Win64" -DCURL_STATICLIB:BOOL=ON -DCURL_STATIC_CRT:BOOL=ON -DHTTP_ONLY:BOOL=ON -DCMAKE_BUILD_TYPE:STRING=RELEASE .. -rem cmake --build . --config Release -rem cmake --build . --config Release --target libcurl + rem cmake .. -G"Visual Studio 14 2015 Win64" -DCURL_STATICLIB=ON -DCURL_DISABLE_LDAP=ON -DCURL_STATIC_CRT=ON + rem cmake .. -G"Visual Studio 14 2015 Win64" -DCURL_STATICLIB:BOOL=ON -DCURL_STATIC_CRT:BOOL=ON -DHTTP_ONLY:BOOL=ON -DCMAKE_BUILD_TYPE:STRING=RELEASE .. + rem cmake --build . --config Release + rem cmake --build . --config Release --target libcurl -cd ../../.. + cd ../../.. + ) + ) +) copy marketmaker_depends\curl\build_msvc_2015_win64\lib\Release\libcurl_imp.lib OSlibs\win\x64\release\libcurl.lib copy marketmaker_depends\curl\build_msvc_2015_win64\lib\Release\libcurl_imp.exp OSlibs\win\x64\release\libcurl.exp copy marketmaker_depends\curl\build_msvc_2015_win64\lib\Release\libcurl.dll x64\Release\libcurl.dll \ No newline at end of file From 5309449e3a81a0374965d9ca995a3e3c527e4551 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Fri, 13 Apr 2018 17:44:55 +0700 Subject: [PATCH 045/139] Use "any" agent for Jenkins. --- Jenkinsfile | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index f7bb536b0..e3dc5323c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,10 +1,5 @@ pipeline { - agent { - docker { - image 'artempikulin/cmake-ubuntu' - } - - } + agent any stages { stage('Build') { steps { From ced658071cde22d69783beed28d167aafaaef25d Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Fri, 13 Apr 2018 18:07:24 +0700 Subject: [PATCH 046/139] Added Jenkinsfile --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index e3dc5323c..87c694e60 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,7 +3,8 @@ pipeline { stages { stage('Build') { steps { - sh '''git submodule update --init --recursive + sh '''echo $HOME +git submodule update --init --recursive rm -rf build mkdir build cd build From 7d01a4d31e696f182cc045c6bdbad51600dd1724 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Fri, 13 Apr 2018 18:50:17 +0700 Subject: [PATCH 047/139] Add "Prepare" stage to Jenkins. --- Jenkinsfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index e3dc5323c..7c858cab7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,11 @@ pipeline { agent any stages { + stage('Prepare') { + steps { + cp -r /root/.env .env + cat .env + } stage('Build') { steps { sh '''git submodule update --init --recursive From 13a4518b945f569d0db8f30965e9c2d8024ba28b Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Fri, 13 Apr 2018 18:57:30 +0700 Subject: [PATCH 048/139] Add scripts to perform swaps via docker-compose for Jenkins. --- .dockerignore | 3 +++ Dockerfile.clientnode | 7 ++++++ Dockerfile.seednode | 7 ++++++ docker-compose.yml | 37 ++++++++++++++++++++++++++++++ etomic_build/client | 5 ---- etomic_build/client1/buy_BEER_ETH | 4 ++++ etomic_build/client1/client | 4 ++++ etomic_build/client1/enable | 6 +++++ etomic_build/client1/passphrase | 1 + etomic_build/client1/setpassphrase | 4 ++++ etomic_build/client1/userpass | 2 ++ etomic_build/passphrase | 1 - etomic_build/run | 5 ---- etomic_build/seed/enable | 6 +++++ etomic_build/seed/myipaddr | 1 + etomic_build/seed/passphrase | 1 + etomic_build/seed/run | 4 ++++ etomic_build/seed/sell_BEER_ETH | 4 ++++ etomic_build/seed/setpassphrase | 4 ++++ etomic_build/seed/userpass | 2 ++ iguana/exchanges/LP_nativeDEX.c | 6 ++--- start_BEER_ETH_trade.sh | 12 ++++++++++ 22 files changed, 112 insertions(+), 14 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile.clientnode create mode 100644 Dockerfile.seednode create mode 100644 docker-compose.yml delete mode 100755 etomic_build/client create mode 100755 etomic_build/client1/buy_BEER_ETH create mode 100755 etomic_build/client1/client create mode 100755 etomic_build/client1/enable create mode 100644 etomic_build/client1/passphrase create mode 100755 etomic_build/client1/setpassphrase create mode 100644 etomic_build/client1/userpass delete mode 100644 etomic_build/passphrase delete mode 100755 etomic_build/run create mode 100755 etomic_build/seed/enable create mode 100644 etomic_build/seed/myipaddr create mode 100644 etomic_build/seed/passphrase create mode 100755 etomic_build/seed/run create mode 100755 etomic_build/seed/sell_BEER_ETH create mode 100755 etomic_build/seed/setpassphrase create mode 100644 etomic_build/seed/userpass create mode 100755 start_BEER_ETH_trade.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..128c6ac20 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +.git +.vscode +cmake-build-debug \ No newline at end of file diff --git a/Dockerfile.clientnode b/Dockerfile.clientnode new file mode 100644 index 000000000..80c218661 --- /dev/null +++ b/Dockerfile.clientnode @@ -0,0 +1,7 @@ +FROM ubuntu:17.10 +USER root +RUN apt-get update && apt-get install -y rinetd curl libcurl3-gnutls +RUN echo "0.0.0.0 10271 10.100.0.1 10271" >> /etc/rinetd.conf +RUN echo "0.0.0.0 8923 10.100.0.1 8923" >> /etc/rinetd.conf +WORKDIR /usr/mm/etomic_build/client +CMD /usr/sbin/rinetd && rm -rf DB && ./client \ No newline at end of file diff --git a/Dockerfile.seednode b/Dockerfile.seednode new file mode 100644 index 000000000..8aca382f6 --- /dev/null +++ b/Dockerfile.seednode @@ -0,0 +1,7 @@ +FROM ubuntu:17.10 +USER root +RUN apt-get update && apt-get install -y rinetd curl libcurl3-gnutls +RUN echo "0.0.0.0 10271 10.100.0.1 10271" >> /etc/rinetd.conf +RUN echo "0.0.0.0 8923 10.100.0.1 8923" >> /etc/rinetd.conf +WORKDIR /usr/mm/etomic_build/seed +CMD /usr/sbin/rinetd && rm -rf DB && ./run diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..d48bcff7e --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,37 @@ +version: '2' +services: + seednode: + build: + context: ./ + dockerfile: Dockerfile.seednode + volumes: + - ~/.zcash-params:/root/.zcash-params + - ~/.komodo:/root/.komodo + - .:/usr/mm + tty: true + networks: + default: + ipv4_address: 10.100.0.2 + + clientnode: + build: + context: ./ + dockerfile: Dockerfile.clientnode + volumes: + - ~/.zcash-params:/root/.zcash-params + - ~/.komodo:/root/.komodo + - .:/usr/mm + links: + - seednode + tty: true + networks: + default: + ipv4_address: 10.100.0.3 + +networks: + default: + driver: bridge + ipam: + config: + - subnet: 10.100.0.0/16 + gateway: 10.100.0.1 \ No newline at end of file diff --git a/etomic_build/client b/etomic_build/client deleted file mode 100755 index fb4f0c935..000000000 --- a/etomic_build/client +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -source passphrase -source coins -./stop -iguana/exchanges/marketmaker "{\"netid\":9999,\"seednode\":\"5.9.253.204\",\"gui\":\"nogui\",\"client\":1, \"userhome\":\"/${HOME#"/"}\", \"passphrase\":\"$passphrase\", \"coins\":$coins}" & diff --git a/etomic_build/client1/buy_BEER_ETH b/etomic_build/client1/buy_BEER_ETH new file mode 100755 index 000000000..3fd43cf77 --- /dev/null +++ b/etomic_build/client1/buy_BEER_ETH @@ -0,0 +1,4 @@ +#!/bin/bash +source userpass +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"setprice\",\"base\":\"ETH\",\"rel\":\"BEER\",\"price\":1}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"sell\",\"base\":\"ETH\",\"rel\":\"BEER\",\"basevolume\":0.1,\"price\":1}" \ No newline at end of file diff --git a/etomic_build/client1/client b/etomic_build/client1/client new file mode 100755 index 000000000..22f5c462e --- /dev/null +++ b/etomic_build/client1/client @@ -0,0 +1,4 @@ +#!/bin/bash +source passphrase +source ../coins +../../build/iguana/exchanges/marketmaker-testnet "{\"netid\":9999,\"seednode\":\"10.100.0.2\",\"gui\":\"nogui\",\"client\":1, \"userhome\":\"/${HOME#"/"}\", \"passphrase\":\"$passphrase\", \"coins\":$coins}" diff --git a/etomic_build/client1/enable b/etomic_build/client1/enable new file mode 100755 index 000000000..8c9bfe2f4 --- /dev/null +++ b/etomic_build/client1/enable @@ -0,0 +1,6 @@ +#!/bin/bash +source userpass +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"ETH\"}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"KMD\"}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"ETOMIC\"}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"BEER\"}" diff --git a/etomic_build/client1/passphrase b/etomic_build/client1/passphrase new file mode 100644 index 000000000..d54ee899d --- /dev/null +++ b/etomic_build/client1/passphrase @@ -0,0 +1 @@ +export passphrase="$PASSPHRASE" diff --git a/etomic_build/client1/setpassphrase b/etomic_build/client1/setpassphrase new file mode 100755 index 000000000..81cc0b28f --- /dev/null +++ b/etomic_build/client1/setpassphrase @@ -0,0 +1,4 @@ +#!/bin/bash +source userpass +source passphrase +curl --url "http://127.0.0.1:7783" --data "{\"netid\":9999,\"seednode\":\"10.100.0.2\",\"userpass\":\"1d8b27b21efabcd96571cd56f91a40fb9aa4cc623d273c63bf9223dc6f8cd81f\",\"method\":\"passphrase\",\"passphrase\":\"$passphrase\",\"gui\":\"nogui\"}" diff --git a/etomic_build/client1/userpass b/etomic_build/client1/userpass new file mode 100644 index 000000000..19fc21189 --- /dev/null +++ b/etomic_build/client1/userpass @@ -0,0 +1,2 @@ +#export userpass="" +export userpass="$USERPASS" diff --git a/etomic_build/passphrase b/etomic_build/passphrase deleted file mode 100644 index eb00095d6..000000000 --- a/etomic_build/passphrase +++ /dev/null @@ -1 +0,0 @@ -export passphrase="" diff --git a/etomic_build/run b/etomic_build/run deleted file mode 100755 index b757bb993..000000000 --- a/etomic_build/run +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -source passphrase -source coins -./stop - $1 iguana/exchanges/marketmaker "{\"netid\":9999,\"gui\":\"nogui\", \"profitmargin\":0.01, \"userhome\":\"/${HOME#"/"}\", \"passphrase\":\"$passphrase\", \"coins\":$coins}" & diff --git a/etomic_build/seed/enable b/etomic_build/seed/enable new file mode 100755 index 000000000..8c9bfe2f4 --- /dev/null +++ b/etomic_build/seed/enable @@ -0,0 +1,6 @@ +#!/bin/bash +source userpass +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"ETH\"}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"KMD\"}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"ETOMIC\"}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"BEER\"}" diff --git a/etomic_build/seed/myipaddr b/etomic_build/seed/myipaddr new file mode 100644 index 000000000..da7788dc2 --- /dev/null +++ b/etomic_build/seed/myipaddr @@ -0,0 +1 @@ +10.100.0.2 diff --git a/etomic_build/seed/passphrase b/etomic_build/seed/passphrase new file mode 100644 index 000000000..d54ee899d --- /dev/null +++ b/etomic_build/seed/passphrase @@ -0,0 +1 @@ +export passphrase="$PASSPHRASE" diff --git a/etomic_build/seed/run b/etomic_build/seed/run new file mode 100755 index 000000000..96ceba6ca --- /dev/null +++ b/etomic_build/seed/run @@ -0,0 +1,4 @@ +#!/bin/bash +source passphrase +source ../coins +../../build/iguana/exchanges/marketmaker-testnet "{\"netid\":9999,\"gui\":\"nogui\", \"profitmargin\":0.01, \"userhome\":\"/${HOME#"/"}\", \"passphrase\":\"$passphrase\", \"coins\":$coins}" diff --git a/etomic_build/seed/sell_BEER_ETH b/etomic_build/seed/sell_BEER_ETH new file mode 100755 index 000000000..90b0e6073 --- /dev/null +++ b/etomic_build/seed/sell_BEER_ETH @@ -0,0 +1,4 @@ +#!/bin/bash +source userpass +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"setprice\",\"base\":\"BEER\",\"rel\":\"ETH\",\"price\":0.9}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"sell\",\"base\":\"BEER\",\"rel\":\"ETH\",\"basevolume\":0.1,\"price\":0.9}" \ No newline at end of file diff --git a/etomic_build/seed/setpassphrase b/etomic_build/seed/setpassphrase new file mode 100755 index 000000000..b3df81427 --- /dev/null +++ b/etomic_build/seed/setpassphrase @@ -0,0 +1,4 @@ +#!/bin/bash +source userpass +source passphrase +curl --url "http://127.0.0.1:7783" --data "{\"netid\":9999,\"seednode\":\"5.9.253.204\",\"userpass\":\"1d8b27b21efabcd96571cd56f91a40fb9aa4cc623d273c63bf9223dc6f8cd81f\",\"method\":\"passphrase\",\"passphrase\":\"$passphrase\",\"gui\":\"nogui\"}" diff --git a/etomic_build/seed/userpass b/etomic_build/seed/userpass new file mode 100644 index 000000000..19fc21189 --- /dev/null +++ b/etomic_build/seed/userpass @@ -0,0 +1,2 @@ +#export userpass="" +export userpass="$USERPASS" diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 03e6b0ec4..dc5f59a3a 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -1381,10 +1381,10 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybu myipaddr = clonestr("127.0.0.1"); #ifndef _WIN32 #ifndef FROM_JS - if ( system("curl -s4 checkip.amazonaws.com > myipaddr") == 0 ) + char ipfname[64]; + strcpy(ipfname,"myipaddr"); + if ( access( ipfname, F_OK ) != -1 || system("curl -s4 checkip.amazonaws.com > myipaddr") == 0 ) { - char ipfname[64]; - strcpy(ipfname,"myipaddr"); if ( (myipaddr= OS_filestr(&filesize,ipfname)) != 0 && myipaddr[0] != 0 ) { n = strlen(myipaddr); diff --git a/start_BEER_ETH_trade.sh b/start_BEER_ETH_trade.sh new file mode 100755 index 000000000..fec9dc369 --- /dev/null +++ b/start_BEER_ETH_trade.sh @@ -0,0 +1,12 @@ +#!/bin/bash +docker-compose exec clientnode ./setpassphrase +sleep 1 +docker-compose exec clientnode ./enable +sleep 1 +docker-compose exec seednode ./setpassphrase +sleep 1 +docker-compose exec seednode ./enable +sleep 1 +docker-compose exec seednode ./sell_BEER_ETH +sleep 3 +docker-compose exec clientnode ./buy_BEER_ETH \ No newline at end of file From d8366e9e9cc37d2eb4b43a6a005726aed5cd83a9 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Fri, 13 Apr 2018 18:58:02 +0700 Subject: [PATCH 049/139] Rename client1 to client. --- etomic_build/{client1 => client}/buy_BEER_ETH | 0 etomic_build/{client1 => client}/client | 0 etomic_build/{client1 => client}/enable | 0 etomic_build/{client1 => client}/passphrase | 0 etomic_build/{client1 => client}/setpassphrase | 0 etomic_build/{client1 => client}/userpass | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename etomic_build/{client1 => client}/buy_BEER_ETH (100%) rename etomic_build/{client1 => client}/client (100%) rename etomic_build/{client1 => client}/enable (100%) rename etomic_build/{client1 => client}/passphrase (100%) rename etomic_build/{client1 => client}/setpassphrase (100%) rename etomic_build/{client1 => client}/userpass (100%) diff --git a/etomic_build/client1/buy_BEER_ETH b/etomic_build/client/buy_BEER_ETH similarity index 100% rename from etomic_build/client1/buy_BEER_ETH rename to etomic_build/client/buy_BEER_ETH diff --git a/etomic_build/client1/client b/etomic_build/client/client similarity index 100% rename from etomic_build/client1/client rename to etomic_build/client/client diff --git a/etomic_build/client1/enable b/etomic_build/client/enable similarity index 100% rename from etomic_build/client1/enable rename to etomic_build/client/enable diff --git a/etomic_build/client1/passphrase b/etomic_build/client/passphrase similarity index 100% rename from etomic_build/client1/passphrase rename to etomic_build/client/passphrase diff --git a/etomic_build/client1/setpassphrase b/etomic_build/client/setpassphrase similarity index 100% rename from etomic_build/client1/setpassphrase rename to etomic_build/client/setpassphrase diff --git a/etomic_build/client1/userpass b/etomic_build/client/userpass similarity index 100% rename from etomic_build/client1/userpass rename to etomic_build/client/userpass From 7dcaf9cb2f36d7dbc39629a21cac5a9fadf25516 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Fri, 13 Apr 2018 19:00:46 +0700 Subject: [PATCH 050/139] Fix Jenkins file. --- Jenkinsfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4f7b1a7a0..3f5059046 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,8 +3,7 @@ pipeline { stages { stage('Prepare') { steps { - cp -r /root/.env .env - cat .env + sh '''cp -r /root/.env .env && cat .env''' } stage('Build') { steps { From d09b00f9dccc2544552bdb62dcb9dcfd362a0770 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Fri, 13 Apr 2018 19:01:33 +0700 Subject: [PATCH 051/139] Fix Jenkins file. --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index 3f5059046..c166400df 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,6 +5,7 @@ pipeline { steps { sh '''cp -r /root/.env .env && cat .env''' } + } stage('Build') { steps { sh '''echo $HOME From c451ae5c294adddbcdc85c5799422c09f0d239db Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Mon, 16 Apr 2018 13:12:18 +0700 Subject: [PATCH 052/139] Set passphrase and userpass via docker env for tests. --- .gitignore | 3 +++ docker-compose.yml | 4 ++++ etomic_build/client/myipaddr | 1 + 3 files changed, 8 insertions(+) create mode 100644 etomic_build/client/myipaddr diff --git a/.gitignore b/.gitignore index 5cb2be3fe..cc36615c4 100755 --- a/.gitignore +++ b/.gitignore @@ -262,3 +262,6 @@ Release/* build_win64_release/* DB/* + +.env.client +.env.seed \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index d48bcff7e..9609e152a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,6 +9,8 @@ services: - ~/.komodo:/root/.komodo - .:/usr/mm tty: true + env_file: + - .env.seed networks: default: ipv4_address: 10.100.0.2 @@ -24,6 +26,8 @@ services: links: - seednode tty: true + env_file: + - .env.client networks: default: ipv4_address: 10.100.0.3 diff --git a/etomic_build/client/myipaddr b/etomic_build/client/myipaddr new file mode 100644 index 000000000..f1649949c --- /dev/null +++ b/etomic_build/client/myipaddr @@ -0,0 +1 @@ +10.100.0.3 From 4bc964a116b9abd4ea030fb45843a6ecc136d4d6 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Mon, 16 Apr 2018 13:38:27 +0700 Subject: [PATCH 053/139] Try to perform first trade with Jenkins. --- Jenkinsfile | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c166400df..45cf4a450 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,7 +3,8 @@ pipeline { stages { stage('Prepare') { steps { - sh '''cp -r /root/.env .env && cat .env''' + sh '''cp -r /root/.env.client .env.client +cp -r /root/.env.seed .env.seed''' } } stage('Build') { @@ -14,7 +15,12 @@ rm -rf build mkdir build cd build cmake .. -cmake --build . --target marketmaker-testnet''' +cmake --build . --target marketmaker-testnet +docker-compose build +docker-compose up -d +./start_BEER_ETH_trade.sh +sleep 300 +docker-compose down''' } } } From f639b824c4d57f8c2c8ee641b6ba629c3bf7e35a Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Mon, 16 Apr 2018 13:53:57 +0700 Subject: [PATCH 054/139] Add Trade stage to Jenkins pipeline. --- Jenkinsfile | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 45cf4a450..769d4921f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,14 +9,17 @@ cp -r /root/.env.seed .env.seed''' } stage('Build') { steps { - sh '''echo $HOME -git submodule update --init --recursive + sh '''git submodule update --init --recursive rm -rf build mkdir build cd build cmake .. -cmake --build . --target marketmaker-testnet -docker-compose build +cmake --build . --target marketmaker-testnet''' + } + } + stage('Trade') { + steps { + sh '''docker-compose build docker-compose up -d ./start_BEER_ETH_trade.sh sleep 300 From 577d5f0c60249b38a1edb54ff29d869d2d884c34 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Mon, 16 Apr 2018 13:58:25 +0700 Subject: [PATCH 055/139] Update gitignore. --- .gitignore | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index cc36615c4..22d44b8a7 100755 --- a/.gitignore +++ b/.gitignore @@ -264,4 +264,10 @@ build_win64_release/* DB/* .env.client -.env.seed \ No newline at end of file +.env.seed +etomic_build/client/DB +etomic_build/client/stats.log +etomic_build/client/unparsed.txt +etomic_build/seed/DB +etomic_build/seed/stats.log +etomic_build/seed/unparsed.txt From 7f46a5d5ceff5aa71b7aed6f52039e1ccf4e8f34 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Mon, 16 Apr 2018 14:35:00 +0700 Subject: [PATCH 056/139] Add jenkins user to dockerfiles. --- Dockerfile.clientnode | 2 ++ Dockerfile.seednode | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Dockerfile.clientnode b/Dockerfile.clientnode index 80c218661..2fb7423e5 100644 --- a/Dockerfile.clientnode +++ b/Dockerfile.clientnode @@ -3,5 +3,7 @@ USER root RUN apt-get update && apt-get install -y rinetd curl libcurl3-gnutls RUN echo "0.0.0.0 10271 10.100.0.1 10271" >> /etc/rinetd.conf RUN echo "0.0.0.0 8923 10.100.0.1 8923" >> /etc/rinetd.conf +RUN useradd -ms /bin/bash jenkins +USER jenkins WORKDIR /usr/mm/etomic_build/client CMD /usr/sbin/rinetd && rm -rf DB && ./client \ No newline at end of file diff --git a/Dockerfile.seednode b/Dockerfile.seednode index 8aca382f6..e5407f3e6 100644 --- a/Dockerfile.seednode +++ b/Dockerfile.seednode @@ -3,5 +3,7 @@ USER root RUN apt-get update && apt-get install -y rinetd curl libcurl3-gnutls RUN echo "0.0.0.0 10271 10.100.0.1 10271" >> /etc/rinetd.conf RUN echo "0.0.0.0 8923 10.100.0.1 8923" >> /etc/rinetd.conf +RUN useradd -ms /bin/bash jenkins +USER jenkins WORKDIR /usr/mm/etomic_build/seed CMD /usr/sbin/rinetd && rm -rf DB && ./run From bba879593b7df5499d446f10ad7d4e98ed6e818e Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Mon, 16 Apr 2018 14:53:13 +0700 Subject: [PATCH 057/139] Try to map host user to docker-compose. --- docker-compose.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 9609e152a..bc15ff740 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,6 +11,8 @@ services: tty: true env_file: - .env.seed + user: + - jenkins:jenkins networks: default: ipv4_address: 10.100.0.2 @@ -25,6 +27,8 @@ services: - .:/usr/mm links: - seednode + user: + - jenkins:jenkins tty: true env_file: - .env.client From 9b4db7801c19a091dcc1dea308b6d352da343912 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Mon, 16 Apr 2018 15:00:20 +0700 Subject: [PATCH 058/139] Set jenkins user id same as host. --- Dockerfile.clientnode | 2 +- docker-compose.yml | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/Dockerfile.clientnode b/Dockerfile.clientnode index 2fb7423e5..96d9177df 100644 --- a/Dockerfile.clientnode +++ b/Dockerfile.clientnode @@ -3,7 +3,7 @@ USER root RUN apt-get update && apt-get install -y rinetd curl libcurl3-gnutls RUN echo "0.0.0.0 10271 10.100.0.1 10271" >> /etc/rinetd.conf RUN echo "0.0.0.0 8923 10.100.0.1 8923" >> /etc/rinetd.conf -RUN useradd -ms /bin/bash jenkins +RUN useradd -u 111 jenkins USER jenkins WORKDIR /usr/mm/etomic_build/client CMD /usr/sbin/rinetd && rm -rf DB && ./client \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index bc15ff740..9609e152a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,8 +11,6 @@ services: tty: true env_file: - .env.seed - user: - - jenkins:jenkins networks: default: ipv4_address: 10.100.0.2 @@ -27,8 +25,6 @@ services: - .:/usr/mm links: - seednode - user: - - jenkins:jenkins tty: true env_file: - .env.client From 8d6c55ea354150306fafba3bc51f260bdbd5fb4f Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Mon, 16 Apr 2018 15:19:02 +0700 Subject: [PATCH 059/139] Try -T option for docker-compose launch. --- start_BEER_ETH_trade.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/start_BEER_ETH_trade.sh b/start_BEER_ETH_trade.sh index fec9dc369..84775a209 100755 --- a/start_BEER_ETH_trade.sh +++ b/start_BEER_ETH_trade.sh @@ -1,12 +1,12 @@ #!/bin/bash -docker-compose exec clientnode ./setpassphrase +docker-compose exec -T clientnode ./setpassphrase sleep 1 -docker-compose exec clientnode ./enable +docker-compose exec -T clientnode ./enable sleep 1 -docker-compose exec seednode ./setpassphrase +docker-compose exec -T seednode ./setpassphrase sleep 1 -docker-compose exec seednode ./enable +docker-compose exec -T seednode ./enable sleep 1 -docker-compose exec seednode ./sell_BEER_ETH +docker-compose exec -T seednode ./sell_BEER_ETH sleep 3 -docker-compose exec clientnode ./buy_BEER_ETH \ No newline at end of file +docker-compose exec -T clientnode ./buy_BEER_ETH \ No newline at end of file From da56b21769880d71d82cfcc53f65c7bd0119c1b3 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Mon, 16 Apr 2018 15:47:49 +0700 Subject: [PATCH 060/139] Fix seednode dockerfile. Map .komodo and .zcash-params properly. --- Dockerfile.seednode | 2 +- docker-compose.yml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Dockerfile.seednode b/Dockerfile.seednode index e5407f3e6..d431296b6 100644 --- a/Dockerfile.seednode +++ b/Dockerfile.seednode @@ -3,7 +3,7 @@ USER root RUN apt-get update && apt-get install -y rinetd curl libcurl3-gnutls RUN echo "0.0.0.0 10271 10.100.0.1 10271" >> /etc/rinetd.conf RUN echo "0.0.0.0 8923 10.100.0.1 8923" >> /etc/rinetd.conf -RUN useradd -ms /bin/bash jenkins +RUN useradd -u 111 jenkins USER jenkins WORKDIR /usr/mm/etomic_build/seed CMD /usr/sbin/rinetd && rm -rf DB && ./run diff --git a/docker-compose.yml b/docker-compose.yml index 9609e152a..c2695b500 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,8 +5,8 @@ services: context: ./ dockerfile: Dockerfile.seednode volumes: - - ~/.zcash-params:/root/.zcash-params - - ~/.komodo:/root/.komodo + - ~/.zcash-params:/home/jenkins/.zcash-params + - ~/.komodo:/home/jenkins/.komodo - .:/usr/mm tty: true env_file: @@ -20,8 +20,8 @@ services: context: ./ dockerfile: Dockerfile.clientnode volumes: - - ~/.zcash-params:/root/.zcash-params - - ~/.komodo:/root/.komodo + - ~/.zcash-params:/home/jenkins/.zcash-params + - ~/.komodo:/home/jenkins/.komodo - .:/usr/mm links: - seednode From 15d7eb7da37a2c4ae3ffae9c8a96b8b4ece21703 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Mon, 16 Apr 2018 17:49:14 +0700 Subject: [PATCH 061/139] Increase timeout between commands executions on CI. --- start_BEER_ETH_trade.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/start_BEER_ETH_trade.sh b/start_BEER_ETH_trade.sh index 84775a209..e192baea4 100755 --- a/start_BEER_ETH_trade.sh +++ b/start_BEER_ETH_trade.sh @@ -1,12 +1,12 @@ #!/bin/bash docker-compose exec -T clientnode ./setpassphrase -sleep 1 +sleep 5 docker-compose exec -T clientnode ./enable -sleep 1 +sleep 5 docker-compose exec -T seednode ./setpassphrase -sleep 1 +sleep 5 docker-compose exec -T seednode ./enable -sleep 1 +sleep 5 docker-compose exec -T seednode ./sell_BEER_ETH -sleep 3 +sleep 5 docker-compose exec -T clientnode ./buy_BEER_ETH \ No newline at end of file From 58b1245f1aca8c0ba664afff438727bef90a34f0 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Tue, 17 Apr 2018 14:19:46 +0700 Subject: [PATCH 062/139] Jenkins. Wait for 'SWAP completed' message to appear in console. --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 769d4921f..b4eed4398 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -22,7 +22,8 @@ cmake --build . --target marketmaker-testnet''' sh '''docker-compose build docker-compose up -d ./start_BEER_ETH_trade.sh -sleep 300 +timeout 300 grep -q 'SWAP completed' <(docker-compose logs -f clientnode) +timeout 300 grep -q 'SWAP completed' <(docker-compose logs -f seednode) docker-compose down''' } } From acde075c3cc1328bd719572d96ddc58c70476f89 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Tue, 17 Apr 2018 14:27:46 +0700 Subject: [PATCH 063/139] Jenkins. Fix Jenkins file. --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index b4eed4398..1bc22eb5f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -22,8 +22,8 @@ cmake --build . --target marketmaker-testnet''' sh '''docker-compose build docker-compose up -d ./start_BEER_ETH_trade.sh -timeout 300 grep -q 'SWAP completed' <(docker-compose logs -f clientnode) -timeout 300 grep -q 'SWAP completed' <(docker-compose logs -f seednode) +timeout 300 grep -q "SWAP completed" <(docker-compose logs -f clientnode) +timeout 300 grep -q "SWAP completed" <(docker-compose logs -f seednode) docker-compose down''' } } From 828e929af036294115d439df90697f25112add5a Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Tue, 17 Apr 2018 14:49:07 +0700 Subject: [PATCH 064/139] Jenkins. Try to reduce timeout to trigger build error. --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1bc22eb5f..a7d61612d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -22,8 +22,8 @@ cmake --build . --target marketmaker-testnet''' sh '''docker-compose build docker-compose up -d ./start_BEER_ETH_trade.sh -timeout 300 grep -q "SWAP completed" <(docker-compose logs -f clientnode) -timeout 300 grep -q "SWAP completed" <(docker-compose logs -f seednode) +timeout 30 grep -q "SWAP completed" <(docker-compose logs -f clientnode) +timeout 30 grep -q "SWAP completed" <(docker-compose logs -f seednode) docker-compose down''' } } From 96cfaed2398fffc5e8c0f6f798192db92be21c39 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Tue, 17 Apr 2018 15:01:47 +0700 Subject: [PATCH 065/139] Jenkins. Put back 5 minutes to wait for swap to finish. --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index a7d61612d..1bc22eb5f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -22,8 +22,8 @@ cmake --build . --target marketmaker-testnet''' sh '''docker-compose build docker-compose up -d ./start_BEER_ETH_trade.sh -timeout 30 grep -q "SWAP completed" <(docker-compose logs -f clientnode) -timeout 30 grep -q "SWAP completed" <(docker-compose logs -f seednode) +timeout 300 grep -q "SWAP completed" <(docker-compose logs -f clientnode) +timeout 300 grep -q "SWAP completed" <(docker-compose logs -f seednode) docker-compose down''' } } From cf81d25eb7b0806767e83d7070bd7dd03f9e7725 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Tue, 17 Apr 2018 17:52:25 +0700 Subject: [PATCH 066/139] Jenkins. Add properties to trigger build on Github push. --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index 1bc22eb5f..edb6b2849 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,6 @@ pipeline { agent any + properties([pipelineTriggers([[$class: 'GitHubPushTrigger'], pollSCM('H/15 * * * *')])]) stages { stage('Prepare') { steps { From 1c539a5cddccffd398a6529cd4c9116fc8f7d9c0 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Tue, 17 Apr 2018 17:54:26 +0700 Subject: [PATCH 067/139] Jenkins. Remove properties as it fails build. --- Jenkinsfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index edb6b2849..1bc22eb5f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,5 @@ pipeline { agent any - properties([pipelineTriggers([[$class: 'GitHubPushTrigger'], pollSCM('H/15 * * * *')])]) stages { stage('Prepare') { steps { From 17f5bcb9576bce58b32c207adf75fc692c4f1991 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Mon, 30 Apr 2018 19:18:49 +0700 Subject: [PATCH 068/139] Increase swap wait timeout on Jenkins test. --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1bc22eb5f..977ce4200 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -22,8 +22,8 @@ cmake --build . --target marketmaker-testnet''' sh '''docker-compose build docker-compose up -d ./start_BEER_ETH_trade.sh -timeout 300 grep -q "SWAP completed" <(docker-compose logs -f clientnode) -timeout 300 grep -q "SWAP completed" <(docker-compose logs -f seednode) +timeout 600 grep -q "SWAP completed" <(docker-compose logs -f clientnode) +timeout 600 grep -q "SWAP completed" <(docker-compose logs -f seednode) docker-compose down''' } } From 225d9939746cb9ca0cbdc3ceeae04f14bf5e1e5c Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Mon, 30 Apr 2018 19:26:22 +0700 Subject: [PATCH 069/139] Remove tty:true to fix failing Jenkins builds sometimes. --- docker-compose.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index c2695b500..051471d3f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,6 @@ services: - ~/.zcash-params:/home/jenkins/.zcash-params - ~/.komodo:/home/jenkins/.komodo - .:/usr/mm - tty: true env_file: - .env.seed networks: @@ -25,7 +24,6 @@ services: - .:/usr/mm links: - seednode - tty: true env_file: - .env.client networks: From 3f7b0df651132d7c55cff3a86a9d1d346ec44cb8 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Fri, 4 May 2018 13:46:50 +0700 Subject: [PATCH 070/139] Put back tty:true as container logs were cut for some reason without it. --- docker-compose.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 051471d3f..52da982c7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,6 +10,7 @@ services: - .:/usr/mm env_file: - .env.seed + tty: true networks: default: ipv4_address: 10.100.0.2 @@ -24,6 +25,7 @@ services: - .:/usr/mm links: - seednode + tty: true env_file: - .env.client networks: From 3d8540a5d5bda99a5da4c4fbcc8d8e122fa6494c Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Tue, 8 May 2018 14:05:27 +0700 Subject: [PATCH 071/139] Remove "ethaddr" field from calcaddress as it provided invalid value. --- iguana/exchanges/LP_commands.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index 1458f59e4..b9c9cddad 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -391,11 +391,6 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\ jaddbits256(retjson,"privkey",privkey); bitcoin_priv2wif(coin,wiftaddr,wifstr,privkey,wiftype); jaddstr(retjson,"wif",wifstr); -#ifndef NOTETOMIC - char ethaddr[50]; - LP_etomic_pubkeystr_to_addr(pubsecp, ethaddr); - jaddstr(retjson,"ethaddr",ethaddr); -#endif return(jprint(retjson,1)); } else return(clonestr("{\"error\":\"need to have passphrase\"}")); } From 1a65ec313bbef5024b8a7bdfa3ac97d2883f51fa Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Tue, 15 May 2018 15:16:31 +0700 Subject: [PATCH 072/139] Increase default gas price. Eth_withdraw errors if station request fails. --- iguana/exchanges/LP_etomic.c | 4 ++-- iguana/exchanges/LP_transaction.c | 20 ++++++++++++----- iguana/exchanges/etomicswap/etomiccurl.c | 9 ++++++-- iguana/exchanges/etomicswap/etomiccurl.h | 4 ++-- iguana/exchanges/etomicswap/etomiclib.cpp | 27 ++++++++++++++--------- iguana/exchanges/etomicswap/etomiclib.h | 4 ++-- 6 files changed, 44 insertions(+), 24 deletions(-) diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index 76323f485..abd47ae22 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -42,9 +42,9 @@ char *LP_etomicalice_send_fee(struct basilisk_swap *swap) uint8arrayToHex(secretKey, swap->persistent_privkey.bytes, 32); LP_etomic_pubkeystr_to_addr(INSTANTDEX_PUBKEY, dexaddr); if (strcmp(swap->I.alicestr,"ETH") == 0 ) { - return(sendEth(dexaddr, amount, secretKey, 1, 0, 0)); + return(sendEth(dexaddr, amount, secretKey, 1, 0, 0, 1)); } else { - return(sendErc20(swap->I.alicetomic, dexaddr, amount, secretKey, 1, 0, 0)); + return(sendErc20(swap->I.alicetomic, dexaddr, amount, secretKey, 1, 0, 0, 1)); } } diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index 4da934d36..daf1dbf88 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -1982,20 +1982,28 @@ char *LP_eth_withdraw(struct iguana_info *coin,cJSON *argjson) uint8arrayToHex(privkey_str, privkey.bytes, 32); satoshisToWei(amount_str, amount); if (strcmp(coin->symbol, "ETH") == 0) { - tx_id = sendEth(dest_addr, amount_str, privkey_str, 0, gas, gas_price); + tx_id = sendEth(dest_addr, amount_str, privkey_str, 0, gas, gas_price, 0); } else { - tx_id = sendErc20(coin->etomic, dest_addr, amount_str, privkey_str, 0, gas, gas_price); + tx_id = sendErc20(coin->etomic, dest_addr, amount_str, privkey_str, 0, gas, gas_price, 0); + } + if (tx_id != NULL) { + jaddstr(retjson, "tx_id", tx_id); + free(tx_id); + } else { + jaddstr(retjson, "error", "Error sending transaction"); } - jaddstr(retjson, "tx_id", tx_id); - free(tx_id); return(jprint(retjson,1)); } char *LP_eth_gas_price() { cJSON *retjson = cJSON_CreateObject(); - uint64_t gas_price = getGasPriceFromStation(); - cJSON_AddNumberToObject(retjson, "gas_price", gas_price); + uint64_t gas_price = getGasPriceFromStation(0); + if (gas_price > 0) { + cJSON_AddNumberToObject(retjson, "gas_price", gas_price); + } else { + cJSON_AddStringToObject(retjson, "error", "Could not get gas price from station!"); + } return(jprint(retjson,1)); } #endif diff --git a/iguana/exchanges/etomicswap/etomiccurl.c b/iguana/exchanges/etomicswap/etomiccurl.c index 51dc9efc8..d15b15c33 100644 --- a/iguana/exchanges/etomicswap/etomiccurl.c +++ b/iguana/exchanges/etomicswap/etomiccurl.c @@ -285,7 +285,7 @@ EthTxData getEthTxData(char *txId) return result; } -uint64_t getGasPriceFromStation() +uint64_t getGasPriceFromStation(uint8_t defaultOnErr) { CURL *curl; CURLcode res; @@ -303,6 +303,12 @@ uint64_t getGasPriceFromStation() curl_easy_setopt(curl, CURLOPT_URL, "https://ethgasstation.info/json/ethgasAPI.json"); /* Perform the request, res will get the return code */ res = curl_easy_perform(curl); + uint64_t result; + if (defaultOnErr == 1) { + result = DEFAULT_GAS_PRICE; + } else { + result = 0; + } /* Check for errors */ if (res != CURLE_OK) { fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res)); @@ -312,7 +318,6 @@ uint64_t getGasPriceFromStation() /* always cleanup */ curl_easy_cleanup(curl); cJSON *resultJson = cJSON_Parse(s.ptr); - uint64_t result = DEFAULT_GAS_PRICE; free(s.ptr); if (resultJson == NULL) { return result; diff --git a/iguana/exchanges/etomicswap/etomiccurl.h b/iguana/exchanges/etomicswap/etomiccurl.h index ef58f82fa..0e0832e9c 100644 --- a/iguana/exchanges/etomicswap/etomiccurl.h +++ b/iguana/exchanges/etomicswap/etomiccurl.h @@ -16,7 +16,7 @@ extern "C"{ #define DEFAULT_GAS_PRICE 100 #else #define ETOMIC_URL "http://195.201.0.6:8555" -#define DEFAULT_GAS_PRICE 4 +#define DEFAULT_GAS_PRICE 10 #endif typedef struct @@ -45,7 +45,7 @@ char* getEthBalanceRequest(char* address); EthTxReceipt getEthTxReceipt(char *txId); EthTxData getEthTxData(char *txId); uint64_t getEthBlockNumber(); -uint64_t getGasPriceFromStation(); +uint64_t getGasPriceFromStation(uint8_t defaultOnErr); int32_t waitForConfirmation(char *txId); #ifdef __cplusplus diff --git a/iguana/exchanges/etomicswap/etomiclib.cpp b/iguana/exchanges/etomicswap/etomiclib.cpp index f19f9c8ae..51052713c 100644 --- a/iguana/exchanges/etomicswap/etomiclib.cpp +++ b/iguana/exchanges/etomicswap/etomiclib.cpp @@ -27,7 +27,7 @@ TransactionSkeleton txDataToSkeleton(BasicTxData txData) tx.to = jsToAddress(txData.to); tx.value = jsToU256(txData.amount); tx.gas = 200000; - tx.gasPrice = getGasPriceFromStation() * boost::multiprecision::pow(u256(10), 9); + tx.gasPrice = getGasPriceFromStation(1) * boost::multiprecision::pow(u256(10), 9); tx.nonce = getNonce(txData.from); return tx; } @@ -50,7 +50,7 @@ char *approveErc20(ApproveErc20Input input) tx.to = jsToAddress(input.tokenAddress); tx.value = 0; tx.gas = 300000; - tx.gasPrice = getGasPriceFromStation() * boost::multiprecision::pow(u256(10), 9); + tx.gasPrice = getGasPriceFromStation(1) * boost::multiprecision::pow(u256(10), 9); tx.nonce = getNonce(input.owner); std::stringstream ss; ss << "0x095ea7b3" @@ -582,13 +582,15 @@ uint64_t weiToSatoshi(char *wei) return static_cast(satoshi); } -char *sendEth(char *to, char *amount, char *privKey, uint8_t waitConfirm, int64_t gas, int64_t gasPrice) +char *sendEth(char *to, char *amount, char *privKey, uint8_t waitConfirm, int64_t gas, int64_t gasPrice, uint8_t defaultGasOnErr) { TransactionSkeleton tx; char *from = privKey2Addr(privKey), *result; tx.from = jsToAddress(from); tx.to = jsToAddress(to); tx.value = jsToU256(amount); + tx.nonce = getNonce(from); + free(from); if (gas > 0) { tx.gas = gas; } else { @@ -597,10 +599,11 @@ char *sendEth(char *to, char *amount, char *privKey, uint8_t waitConfirm, int64_ if (gasPrice > 0) { tx.gasPrice = gasPrice * boost::multiprecision::pow(u256(10), 9); } else { - tx.gasPrice = getGasPriceFromStation() * boost::multiprecision::pow(u256(10), 9); + tx.gasPrice = getGasPriceFromStation(defaultGasOnErr) * boost::multiprecision::pow(u256(10), 9); + if (!defaultGasOnErr) { + return NULL; + } } - tx.nonce = getNonce(from); - free(from); char *rawTx = signTx(tx, privKey); if (waitConfirm == 0) { @@ -628,7 +631,7 @@ std::stringstream getErc20TransferData(char *tokenAddress, char *to, char *amoun return ss; } -char *sendErc20(char *tokenAddress, char *to, char *amount, char *privKey, uint8_t waitConfirm, int64_t gas, int64_t gasPrice) +char *sendErc20(char *tokenAddress, char *to, char *amount, char *privKey, uint8_t waitConfirm, int64_t gas, int64_t gasPrice, uint8_t defaultGasOnErr) { TransactionSkeleton tx; char *from = privKey2Addr(privKey), *result; @@ -637,6 +640,9 @@ char *sendErc20(char *tokenAddress, char *to, char *amount, char *privKey, uint8 tx.from = jsToAddress(from); tx.to = jsToAddress(tokenAddress); tx.value = 0; + tx.nonce = getNonce(from); + free(from); + if (gas > 0) { tx.gas = gas; } else { @@ -650,10 +656,11 @@ char *sendErc20(char *tokenAddress, char *to, char *amount, char *privKey, uint8 if (gasPrice > 0) { tx.gasPrice = gasPrice * boost::multiprecision::pow(u256(10), 9); } else { - tx.gasPrice = getGasPriceFromStation() * boost::multiprecision::pow(u256(10), 9); + tx.gasPrice = getGasPriceFromStation(defaultGasOnErr) * boost::multiprecision::pow(u256(10), 9); + if (!defaultGasOnErr) { + return NULL; + } } - tx.nonce = getNonce(from); - free(from); tx.data = jsToBytes(ss.str()); diff --git a/iguana/exchanges/etomicswap/etomiclib.h b/iguana/exchanges/etomicswap/etomiclib.h index f409f9381..2ba9893e6 100644 --- a/iguana/exchanges/etomicswap/etomiclib.h +++ b/iguana/exchanges/etomicswap/etomiclib.h @@ -177,8 +177,8 @@ void uint8arrayToHex(char *dest, uint8_t *input, int len); void satoshisToWei(char *dest, uint64_t input); uint64_t weiToSatoshi(char *wei); -char *sendEth(char *to, char *amount, char *privKey, uint8_t waitConfirm, int64_t gas, int64_t gasPrice); -char *sendErc20(char *tokenAddress, char *to, char *amount, char *privKey, uint8_t waitConfirm, int64_t gas, int64_t gasPrice); +char *sendEth(char *to, char *amount, char *privKey, uint8_t waitConfirm, int64_t gas, int64_t gasPrice, uint8_t defaultGasOnErr); +char *sendErc20(char *tokenAddress, char *to, char *amount, char *privKey, uint8_t waitConfirm, int64_t gas, int64_t gasPrice, uint8_t defaultGasOnErr); uint8_t verifyAliceErc20FeeData(char* tokenAddress, char *to, char *amount, char *data); // Your prototype or Definition From c0184eb8acb90f3aa2563648103f761dd3d985a1 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Wed, 16 May 2018 12:12:06 +0700 Subject: [PATCH 073/139] Fix eth_withdraw tx send and dead lock. --- iguana/exchanges/etomicswap/etomiccurl.c | 5 +++++ iguana/exchanges/etomicswap/etomiccurl.h | 1 + iguana/exchanges/etomicswap/etomiclib.cpp | 6 ++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/etomicswap/etomiccurl.c b/iguana/exchanges/etomicswap/etomiccurl.c index d15b15c33..ab026f134 100644 --- a/iguana/exchanges/etomicswap/etomiccurl.c +++ b/iguana/exchanges/etomicswap/etomiccurl.c @@ -367,3 +367,8 @@ int32_t waitForConfirmation(char *txId) return((int32_t)receipt.confirmations); } + +void unlock_send_tx_mutex() +{ + pthread_mutex_unlock(&sendTxMutex); +} diff --git a/iguana/exchanges/etomicswap/etomiccurl.h b/iguana/exchanges/etomicswap/etomiccurl.h index 0e0832e9c..36a15546a 100644 --- a/iguana/exchanges/etomicswap/etomiccurl.h +++ b/iguana/exchanges/etomicswap/etomiccurl.h @@ -47,6 +47,7 @@ EthTxData getEthTxData(char *txId); uint64_t getEthBlockNumber(); uint64_t getGasPriceFromStation(uint8_t defaultOnErr); int32_t waitForConfirmation(char *txId); +void unlock_send_tx_mutex(); #ifdef __cplusplus } diff --git a/iguana/exchanges/etomicswap/etomiclib.cpp b/iguana/exchanges/etomicswap/etomiclib.cpp index 51052713c..969197c2f 100644 --- a/iguana/exchanges/etomicswap/etomiclib.cpp +++ b/iguana/exchanges/etomicswap/etomiclib.cpp @@ -600,7 +600,8 @@ char *sendEth(char *to, char *amount, char *privKey, uint8_t waitConfirm, int64_ tx.gasPrice = gasPrice * boost::multiprecision::pow(u256(10), 9); } else { tx.gasPrice = getGasPriceFromStation(defaultGasOnErr) * boost::multiprecision::pow(u256(10), 9); - if (!defaultGasOnErr) { + if (tx.gasPrice == 0 && !defaultGasOnErr) { + unlock_send_tx_mutex(); return NULL; } } @@ -657,7 +658,8 @@ char *sendErc20(char *tokenAddress, char *to, char *amount, char *privKey, uint8 tx.gasPrice = gasPrice * boost::multiprecision::pow(u256(10), 9); } else { tx.gasPrice = getGasPriceFromStation(defaultGasOnErr) * boost::multiprecision::pow(u256(10), 9); - if (!defaultGasOnErr) { + if (tx.gasPrice == 0 && !defaultGasOnErr) { + unlock_send_tx_mutex(); return NULL; } } From 36f6b187e5682bed4e1112d338283facd4e4bdf7 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 17 May 2018 12:32:25 +0700 Subject: [PATCH 074/139] Fix gas price estimation on sendErc20. --- iguana/exchanges/etomicswap/etomiclib.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/etomicswap/etomiclib.cpp b/iguana/exchanges/etomicswap/etomiclib.cpp index 969197c2f..58139ee65 100644 --- a/iguana/exchanges/etomicswap/etomiclib.cpp +++ b/iguana/exchanges/etomicswap/etomiclib.cpp @@ -642,7 +642,6 @@ char *sendErc20(char *tokenAddress, char *to, char *amount, char *privKey, uint8 tx.to = jsToAddress(tokenAddress); tx.value = 0; tx.nonce = getNonce(from); - free(from); if (gas > 0) { tx.gas = gas; @@ -654,6 +653,7 @@ char *sendErc20(char *tokenAddress, char *to, char *amount, char *privKey, uint8 tx.gas = 150000; } } + free(from); if (gasPrice > 0) { tx.gasPrice = gasPrice * boost::multiprecision::pow(u256(10), 9); } else { From c2ed80b006d81f76574ea983249124feac5c0f8a Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 24 May 2018 16:07:26 +0700 Subject: [PATCH 075/139] Add etomic faucet request when ETH/ERC20 coin is getting enabled. --- iguana/exchanges/LP_commands.c | 21 ++++++++++ iguana/exchanges/LP_nativeDEX.c | 2 +- iguana/exchanges/etomicswap/etomiccurl.c | 49 +++++++++++++++++++++--- iguana/exchanges/etomicswap/etomiccurl.h | 3 ++ 4 files changed, 68 insertions(+), 7 deletions(-) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index d15dd9311..ad78f84dc 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -554,6 +554,27 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\ jaddstr(retjson,"coin",coin); return(jprint(retjson,1)); } +#ifndef NOT_ETOMIC + if (ptr->etomic[0] != 0) { + struct iguana_info *etomic_coin = LP_coinsearch("ETOMIC"); + if (etomic_coin->inactive != 0) { + return(clonestr("{\"error\":\"Enable ETOMIC first to use ETH/ERC20!\"}")); + } + + if (ptr->inactive != 0) { + uint64_t balance = LP_etomic_get_balance(ptr, ptr->smartaddr); + uint64_t new_required = G.LP_required_etomic_balance + (balance * 9) / 4; + uint64_t etomic_balance = LP_RTsmartbalance(etomic_coin); + if (etomic_balance < new_required) { + printf("Need additional ETOMIC amount: %" PRIu64 "\n", new_required - etomic_balance); + if (get_etomic_from_faucet(ptr->smartaddr, etomic_coin->smartaddr, ptr->etomic) != 1) { + return(clonestr("{\"error\":\"Could not get ETOMIC from faucet!\"}")); + } + } + G.LP_required_etomic_balance = new_required; + } + } +#endif if ( LP_conflicts_find(ptr) == 0 ) { cJSON *array; diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index a0506d545..b3ec8c798 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -120,7 +120,7 @@ struct LP_globals { //struct LP_utxoinfo *LP_utxoinfos[2],*LP_utxoinfos2[2]; bits256 LP_mypub25519,LP_privkey,LP_mypriv25519,LP_passhash; - uint64_t LP_skipstatus[10000]; + uint64_t LP_skipstatus[10000], LP_required_etomic_balance; uint16_t netid; uint8_t LP_myrmd160[20],LP_pubsecp[33]; uint32_t LP_sessionid,counter; diff --git a/iguana/exchanges/etomicswap/etomiccurl.c b/iguana/exchanges/etomicswap/etomiccurl.c index ab026f134..e4bf3f532 100644 --- a/iguana/exchanges/etomicswap/etomiccurl.c +++ b/iguana/exchanges/etomicswap/etomiccurl.c @@ -1,7 +1,6 @@ #include "etomiccurl.h" #include -static char *ethRpcUrl = ETOMIC_URL; pthread_mutex_t sendTxMutex = PTHREAD_MUTEX_INITIALIZER; struct string { @@ -56,7 +55,7 @@ cJSON *parseEthRpcResponse(char *requestResult) return result; } -char* sendRequest(char* request) +char* sendRequest(char *request, char *url) { CURL *curl; CURLcode res; @@ -72,13 +71,15 @@ char* sendRequest(char* request) curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST"); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writefunc); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &s); - curl_easy_setopt(curl, CURLOPT_URL, ethRpcUrl); + curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, request); /* Perform the request, res will get the return code */ res = curl_easy_perform(curl); /* Check for errors */ if (res != CURLE_OK) { fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res)); + curl_easy_cleanup(curl); + return NULL; } /* always cleanup */ @@ -98,7 +99,7 @@ cJSON *sendRpcRequest(char *method, cJSON *params) cJSON_AddItemToObject(request, "params", cJSON_Duplicate(params, 1)); cJSON_AddNumberToObject(request, "id", 1); string = cJSON_PrintUnformatted(request); - char* requestResult = sendRequest(string); + char* requestResult = sendRequest(string, ETOMIC_URL); free(string); cJSON_Delete(request); cJSON *result = parseEthRpcResponse(requestResult); @@ -151,8 +152,8 @@ char* sendRawTx(char* rawTx) int64_t getNonce(char* address) { - // we should lock this mutex and unlock it only when transaction was already sent. - // make sure that sendRawTx is called after getting a nonce! + // we should lock this mutex and unlock it only when transaction was already sent or failed. + // make sure that sendRawTx or unlock_send_tx_mutex is called after getting a nonce! if (pthread_mutex_lock(&sendTxMutex) != 0) { printf("Nonce mutex lock failed\n"); }; @@ -372,3 +373,39 @@ void unlock_send_tx_mutex() { pthread_mutex_unlock(&sendTxMutex); } + +uint8_t get_etomic_from_faucet(char *eth_addr, char *etomic_addr, char *token_addr) +{ + char* string; + cJSON *request = cJSON_CreateObject(); + cJSON_AddStringToObject(request, "ethAddress", eth_addr); + cJSON_AddStringToObject(request, "etomicAddress", etomic_addr); + if (strcmp(token_addr, "0x0000000000000000000000000000000000000000") != 0) { + cJSON_AddStringToObject(request, "tokenAddress", token_addr); + } + string = cJSON_PrintUnformatted(request); + char* requestResult = sendRequest(string, FAUCET_URL); + free(string); + cJSON_Delete(request); + + if (requestResult == NULL) { + return 0; + } + + cJSON *json = cJSON_Parse(requestResult); + if (json == NULL) { + printf("ETOMIC faucet response parse failed!\n"); + return 0; + } + cJSON *error = cJSON_GetObjectItem(json, "error"); + uint8_t result = 0; + if (error != NULL && !is_cJSON_Null(error)) { + char *errorString = cJSON_PrintUnformatted(error); + printf("Got ETOMIC faucet error: %s\n", errorString); + free(errorString); + } else { + result = 1; + } + cJSON_Delete(json); + return result; +} diff --git a/iguana/exchanges/etomicswap/etomiccurl.h b/iguana/exchanges/etomicswap/etomiccurl.h index 36a15546a..a340a604c 100644 --- a/iguana/exchanges/etomicswap/etomiccurl.h +++ b/iguana/exchanges/etomicswap/etomiccurl.h @@ -19,6 +19,8 @@ extern "C"{ #define DEFAULT_GAS_PRICE 10 #endif +#define FAUCET_URL "http://195.201.116.176:8000/getEtomic" + typedef struct { uint64_t blockNumber; @@ -48,6 +50,7 @@ uint64_t getEthBlockNumber(); uint64_t getGasPriceFromStation(uint8_t defaultOnErr); int32_t waitForConfirmation(char *txId); void unlock_send_tx_mutex(); +uint8_t get_etomic_from_faucet(char *eth_addr, char *etomic_addr, char *token_addr); #ifdef __cplusplus } From 7640af3de1ba6db8543634b651ce3b96b68b5510 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 24 May 2018 16:49:22 +0700 Subject: [PATCH 076/139] Set COMPOSE_HTTP_TIMEOUT=601 for Jenkins pipeline compose logs. --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 977ce4200..9bc1ac407 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -22,8 +22,8 @@ cmake --build . --target marketmaker-testnet''' sh '''docker-compose build docker-compose up -d ./start_BEER_ETH_trade.sh -timeout 600 grep -q "SWAP completed" <(docker-compose logs -f clientnode) -timeout 600 grep -q "SWAP completed" <(docker-compose logs -f seednode) +COMPOSE_HTTP_TIMEOUT=601 timeout 600 grep -q "SWAP completed" <(docker-compose logs -f clientnode) +COMPOSE_HTTP_TIMEOUT=601 timeout 600 grep -q "SWAP completed" <(docker-compose logs -f seednode) docker-compose down''' } } From fe8592b9327308e4c9bf53f169a7a81bff66964f Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 24 May 2018 21:31:14 +0700 Subject: [PATCH 077/139] Enable ETOMIC first on running CI build. --- etomic_build/client/enable | 2 +- etomic_build/seed/enable | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/etomic_build/client/enable b/etomic_build/client/enable index 8c9bfe2f4..0ae602f7a 100755 --- a/etomic_build/client/enable +++ b/etomic_build/client/enable @@ -1,6 +1,6 @@ #!/bin/bash source userpass +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"ETOMIC\"}" curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"ETH\"}" curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"KMD\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"ETOMIC\"}" curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"BEER\"}" diff --git a/etomic_build/seed/enable b/etomic_build/seed/enable index 8c9bfe2f4..79350a008 100755 --- a/etomic_build/seed/enable +++ b/etomic_build/seed/enable @@ -1,6 +1,6 @@ #!/bin/bash source userpass -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"ETH\"}" curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"KMD\"}" curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"ETOMIC\"}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"ETH\"}" curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"BEER\"}" From 18873c4502e357ef1972b537ae125ea852fcee1d Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Mon, 28 May 2018 17:38:28 +0700 Subject: [PATCH 078/139] Add "decimals" field for ERC20 tokens without decimals function. --- etomic_build/coins | 2 +- iguana/exchanges/LP_coins.c | 3 + iguana/exchanges/LP_etomic.c | 55 +++++++-- iguana/exchanges/LP_include.h | 2 +- iguana/exchanges/LP_transaction.c | 2 +- iguana/exchanges/etomicswap/etomiclib.cpp | 144 +++++++++++++++++----- iguana/exchanges/etomicswap/etomiclib.h | 29 ++++- 7 files changed, 188 insertions(+), 49 deletions(-) diff --git a/etomic_build/coins b/etomic_build/coins index 988b79784..988240877 100755 --- a/etomic_build/coins +++ b/etomic_build/coins @@ -1,3 +1,3 @@ -export coins="[{\"coin\":\"OOT\",\"asset\":\"OOT\",\"rpcport\":12467}, {\"coin\":\"ETH\",\"name\":\"ethereum\",\"etomic\":\"0x0000000000000000000000000000000000000000\",\"rpcport\":80}, {\"coin\":\"EOS\",\"name\":\"EOS\",\"etomic\":\"0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0\",\"rpcport\":80}, {\"coin\":\"ZOI\",\"name\":\"zoin\",\"rpcport\":8255,\"pubtype\":80,\"p2shtype\":7,\"wiftype\":208,\"txfee\":1000}, {\"coin\": \"PIZZA\",\"asset\": \"PIZZA\",\"rpcport\": 11116},{\"coin\": \"BEER\",\"asset\": \"BEER\",\"rpcport\": 8923}, {\"coin\":\"GRS\",\"name\":\"groestlcoin\",\"rpcport\":1441,\"pubtype\":36,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"XMCC\",\"name\":\"monoeci\",\"confpath\":\"${HOME#}/.monoeciCore/monoeci.conf\",\"rpcport\":24156,\"pubtype\":50,\"p2shtype\":73,\"wiftype\":77,\"txfee\":10000}, {\"coin\":\"BTCH\",\"asset\":\"BTCH\",\"rpcport\":8800},{\"coin\":\"ETOMIC\",\"asset\":\"ETOMIC\",\"rpcport\":10271},{\"coin\":\"AXO\",\"asset\":\"AXO\",\"rpcport\":12927},{\"coin\":\"CRC\",\"name\":\"crowdcoin\",\"confpath\":\"${HOME#}/.crowdcoincore/crowdcoin.conf\",\"rpcport\":11998,\"pubtype\":28,\"p2shtype\":88,\"wiftype\":0,\"txfee\":10000}, {\"coin\":\"VOT\",\"name\":\"votecoin\",\"rpcport\":8232,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"INN\",\"name\":\"innova\",\"confpath\":\"${HOME#}/.innovacore/innova.conf\",\"rpcport\":8818,\"pubtype\":102,\"p2shtype\":20,\"wiftype\":195,\"txfee\":10000}, {\"coin\":\"MOON\",\"name\":\"mooncoin\",\"rpcport\":44663,\"pubtype\":3,\"p2shtype\":22,\"wiftype\":131,\"txfee\":100000}, {\"coin\":\"CRW\",\"name\":\"crown\",\"rpcport\":9341,\"pubtype\":0,\"p2shtype\":28,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"EFL\",\"name\":\"egulden\",\"confpath\":\"${HOME#}/.egulden/coin.conf\",\"rpcport\":21015,\"pubtype\":48,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"GBX\",\"name\":\"gobyte\",\"confpath\":\"${HOME#}/.gobytecore/gobyte.conf\",\"rpcport\":12454,\"pubtype\":38,\"p2shtype\":10,\"wiftype\":198,\"txfee\":10000}, {\"coin\":\"BCO\",\"name\":\"bridgecoin\",\"rpcport\":6332,\"pubtype\":27,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"BLK\",\"name\":\"blackcoin\",\"confpath\":\"${HOME#}/.lore/blackcoin.conf\",\"isPoS\":1,\"rpcport\":15715,\"pubtype\":25,\"p2shtype\":85,\"wiftype\":153,\"txfee\":100000}, {\"coin\":\"BTG\",\"name\":\"bitcoingold\",\"rpcport\":8332,\"pubtype\":38,\"p2shtype\":23,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"BCH\",\"name\":\"bch\",\"rpcport\":33333,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":1000}, {\"coin\":\"ABY\",\"name\":\"applebyte\",\"rpcport\":8607,\"pubtype\":23,\"p2shtype\":5,\"wiftype\":151,\"txfee\":100000}, {\"coin\":\"STAK\",\"name\":\"straks\",\"rpcport\":7574,\"pubtype\":63,\"p2shtype\":5,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"XZC\",\"name\":\"zcoin\",\"rpcport\":8888,\"pubtype\":82,\"p2shtype\":7,\"wiftype\":210,\"txfee\":10000}, {\"coin\":\"QTUM\",\"name\":\"qtum\",\"rpcport\":3889,\"pubtype\":58,\"p2shtype\":50,\"wiftype\":128,\"txfee\":400000}, {\"coin\":\"PURA\",\"name\":\"pura\",\"rpcport\":55555,\"pubtype\":55,\"p2shtype\":16,\"wiftype\":150,\"txfee\":10000}, {\"coin\":\"DSR\",\"name\":\"desire\",\"confpath\":\"${HOME#}/.desirecore/desire.conf\",\"rpcport\":9918,\"pubtype\":30,\"p2shtype\":16,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"MNZ\",\"asset\":\"MNZ\",\"rpcport\":14337},{\"coin\":\"BTCZ\",\"name\":\"bitcoinz\",\"rpcport\":1979,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"MAGA\",\"name\":\"magacoin\",\"rpcport\":5332,\"pubtype\":23,\"p2shtype\":50,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"BSD\",\"name\":\"bitsend\",\"rpcport\":8800,\"pubtype\":102,\"p2shtype\":5,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"IOP\",\"name\":\"IoP\",\"rpcport\":8337,\"pubtype\":117,\"p2shtype\":174,\"wiftype\":49,\"txfee\":10000}, {\"coin\":\"BLOCK\",\"name\":\"blocknetdx\",\"rpcport\":41414,\"pubtype\":26,\"p2shtype\":28,\"wiftype\":154,\"txfee\":10000}, {\"coin\":\"CHIPS\", \"name\": \"chips\", \"rpcport\":57776,\"pubtype\":60, \"p2shtype\":85, \"wiftype\":188, \"txfee\":10000}, {\"coin\":\"888\",\"name\":\"octocoin\",\"rpcport\":22888,\"pubtype\":18,\"p2shtype\":5,\"wiftype\":176,\"txfee\":2000000}, {\"coin\":\"ARG\",\"name\":\"argentum\",\"rpcport\":13581,\"pubtype\":23,\"p2shtype\":5,\"wiftype\":151,\"txfee\":50000}, {\"coin\":\"GLT\",\"name\":\"globaltoken\",\"rpcport\":9320,\"pubtype\":38,\"p2shtype\":5,\"wiftype\":166,\"txfee\":10000}, {\"coin\":\"ZER\",\"name\":\"zero\",\"rpcport\":23801,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":1000}, {\"coin\":\"HODLC\",\"name\":\"hodlcoin\",\"rpcport\":11989,\"pubtype\":40,\"p2shtype\":5,\"wiftype\":168,\"txfee\":5000}, {\"coin\":\"UIS\",\"name\":\"unitus\",\"rpcport\":50604,\"pubtype\":68,\"p2shtype\":10,\"wiftype\":132,\"txfee\":2000000}, {\"coin\":\"HUC\",\"name\":\"huntercoin\",\"rpcport\":8399,\"pubtype\":40,\"p2shtype\":13,\"wiftype\":168,\"txfee\":100000}, {\"coin\":\"BDL\",\"name\":\"bitdeal\",\"rpcport\":9332,\"pubtype\":38,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"ARC\",\"name\":\"arcticcoin\",\"confpath\":\"${HOME#}/.arcticcore/arcticcoin.conf\",\"rpcport\":7208,\"pubtype\":23,\"p2shtype\":8,\"wiftype\":176,\"txfee\":10000}, {\"coin\":\"ZCL\",\"name\":\"zclassic\",\"rpcport\":8023,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":1000}, {\"coin\":\"VIA\",\"name\":\"viacoin\",\"rpcport\":5222,\"pubtype\":71,\"p2shtype\":33,\"wiftype\":199,\"txfee\":100000}, {\"coin\":\"ERC\",\"name\":\"europecoin\",\"rpcport\":11989,\"pubtype\":33,\"p2shtype\":5,\"wiftype\":168,\"txfee\":10000},{\"coin\":\"FAIR\",\"name\":\"faircoin\",\"confpath\":\"${HOME#}/.faircoin2/faircoin.conf\",\"rpcport\":40405,\"pubtype\":95,\"p2shtype\":36,\"wiftype\":223,\"txfee\":1000000}, {\"coin\":\"FLO\",\"name\":\"florincoin\",\"rpcport\":7313,\"pubtype\":35,\"p2shtype\":8,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"SXC\",\"name\":\"sexcoin\",\"rpcport\":9561,\"pubtype\":62,\"p2shtype\":5,\"wiftype\":190,\"txfee\":100000}, {\"coin\":\"CREA\",\"name\":\"creativecoin\",\"rpcport\":17711,\"pubtype\":28,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"TRC\",\"name\":\"terracoin\",\"confpath\":\"${HOME#}/.terracoincore/terracoin.conf\",\"rpcport\":13332,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"BTA\",\"name\":\"bata\",\"rpcport\":5493,\"pubtype\":25,\"p2shtype\":5,\"wiftype\":188,\"txfee\":100000}, {\"coin\":\"SMC\",\"name\":\"smartcoin\",\"rpcport\":58583,\"pubtype\":63,\"p2shtype\":5,\"wiftype\":191,\"txfee\":1000000}, {\"coin\":\"NMC\",\"name\":\"namecoin\",\"rpcport\":8336,\"pubtype\":52,\"p2shtype\":13,\"wiftype\":180,\"txfee\":100000}, {\"coin\":\"NAV\",\"name\":\"navcoin\",\"isPoS\":1,\"confpath\":\"${HOME#}/.navcoin4/navcoin.conf\",\"rpcport\":44444,\"pubtype\":53,\"p2shtype\":85,\"wiftype\":150,\"txfee\":10000}, {\"coin\":\"EMC2\",\"name\":\"einsteinium\",\"rpcport\":41879,\"pubtype\":33,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000},{\"coin\":\"SYS\",\"name\":\"syscoin\",\"rpcport\":8370,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"I0C\",\"name\":\"i0coin\",\"rpcport\":7332,\"pubtype\":105,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"DASH\",\"confpath\":\"${HOME#}/.dashcore/dash.conf\",\"name\":\"dashcore\",\"rpcport\":9998,\"pubtype\":76,\"p2shtype\":16,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"STRAT\", \"name\": \"stratis\", \"active\":0, \"rpcport\":16174,\"pubtype\":63, \"p2shtype\":125, \"wiftype\":191, \"txfee\":10000}, {\"confpath\":\"${HOME#}/.muecore/mue.conf\",\"coin\":\"MUE\",\"name\":\"muecore\",\"rpcport\":29683,\"pubtype\":16,\"p2shtype\":76,\"wiftype\":126,\"txfee\":10000}, {\"coin\":\"MONA\",\"name\":\"monacoin\",\"rpcport\":9402,\"pubtype\":50,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000},{\"coin\":\"XMY\",\"name\":\"myriadcoin\",\"rpcport\":10889,\"pubtype\":50,\"p2shtype\":9,\"wiftype\":178,\"txfee\":5000}, {\"coin\":\"MAC\",\"name\":\"machinecoin\",\"rpcport\":40332,\"pubtype\":50,\"p2shtype\":5,\"wiftype\":178,\"txfee\":100000}, {\"coin\":\"BTX\",\"name\":\"bitcore\",\"rpcport\":8556,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":50000}, {\"coin\":\"XRE\",\"name\":\"revolvercoin\",\"rpcport\":8775,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"LBC\",\"name\":\"lbrycrd\",\"rpcport\":9245,\"pubtype\":85,\"p2shtype\":122,\"wiftype\":28,\"txfee\":10000}, {\"coin\":\"SIB\",\"name\":\"sibcoin\",\"rpcport\":1944,\"pubtype\":63,\"p2shtype\":40,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"VTC\", \"name\":\"vertcoin\", \"rpcport\":5888, \"pubtype\":71, \"p2shtype\":5, \"wiftype\":128, \"txfee\":100000 }, {\"coin\":\"REVS\",\"active\":0, \"asset\":\"REVS\",\"rpcport\":10196}, {\"coin\":\"JUMBLR\",\"active\":0, \"asset\":\"JUMBLR\",\"rpcport\":15106}, {\"coin\":\"DOGE\",\"name\":\"dogecoin\",\"rpcport\":22555,\"pubtype\":30,\"p2shtype\":22,\"wiftype\":158,\"txfee\":100000000}, {\"coin\":\"HUSH\",\"name\":\"hush\",\"rpcport\":8822,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":1000 }, {\"active\":0,\"coin\":\"ZEC\",\"name\":\"zcash\",\"rpcport\":8232,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":10000 }, {\"coin\":\"DGB\",\"name\":\"digibyte\",\"rpcport\":14022,\"pubtype\":30,\"p2shtype\":5,\"wiftype\":128,\"txfee\":100000}, {\"coin\":\"ZET\", \"name\":\"zetacoin\", \"pubtype\":80, \"p2shtype\":9,\"rpcport\":8332, \"wiftype\":224, \"txfee\":10000}, {\"coin\":\"GAME\", \"rpcport\":40001, \"name\":\"gamecredits\", \"pubtype\":38, \"p2shtype\":5, \"wiftype\":166, \"txfee\":100000}, {\"coin\":\"LTC\", \"name\":\"litecoin\", \"rpcport\":9332, \"pubtype\":48, \"p2shtype\":5, \"wiftype\":176, \"txfee\":100000 }, {\"coin\":\"SUPERNET\",\"asset\":\"SUPERNET\",\"rpcport\":11341}, {\"coin\":\"WLC\",\"asset\":\"WLC\",\"rpcport\":12167}, {\"coin\":\"PANGEA\",\"asset\":\"PANGEA\",\"rpcport\":14068}, {\"coin\":\"DEX\",\"asset\":\"DEX\",\"rpcport\":11890}, {\"coin\":\"BET\",\"asset\":\"BET\",\"rpcport\":14250}, {\"coin\":\"CRYPTO\",\"asset\":\"CRYPTO\",\"rpcport\":8516}, {\"coin\":\"HODL\",\"asset\":\"HODL\",\"rpcport\":14431}, {\"coin\":\"MSHARK\",\"asset\":\"MSHARK\",\"rpcport\":8846}, {\"coin\":\"BOTS\",\"asset\":\"BOTS\",\"rpcport\":11964}, {\"coin\":\"MGW\",\"asset\":\"MGW\",\"rpcport\":12386}, {\"coin\":\"COQUI\",\"asset\":\"COQUI\",\"rpcport\":14276}, {\"coin\":\"KV\",\"asset\":\"KV\",\"rpcport\":8299}, {\"coin\":\"CEAL\",\"asset\":\"CEAL\",\"rpcport\":11116}, {\"coin\":\"MESH\",\"asset\":\"MESH\",\"rpcport\":9455}]" +export coins="[{\"coin\":\"OOT\",\"asset\":\"OOT\",\"rpcport\":12467}, {\"coin\":\"ETH\",\"name\":\"ethereum\",\"etomic\":\"0x0000000000000000000000000000000000000000\",\"rpcport\":80}, {\"coin\":\"EOS\",\"name\":\"EOS\",\"etomic\":\"0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0\",\"rpcport\":80},{\"coin\":\"JST\", \"name\":\"JST\",\"etomic\":\"0xc0eb7aed740e1796992a08962c15661bdeb58003\",\"rpcport\":80,\"decimals\":18}, {\"coin\":\"ZOI\",\"name\":\"zoin\",\"rpcport\":8255,\"pubtype\":80,\"p2shtype\":7,\"wiftype\":208,\"txfee\":1000}, {\"coin\": \"PIZZA\",\"asset\": \"PIZZA\",\"rpcport\": 11116},{\"coin\": \"BEER\",\"asset\": \"BEER\",\"rpcport\": 8923}, {\"coin\":\"GRS\",\"name\":\"groestlcoin\",\"rpcport\":1441,\"pubtype\":36,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"XMCC\",\"name\":\"monoeci\",\"confpath\":\"${HOME#}/.monoeciCore/monoeci.conf\",\"rpcport\":24156,\"pubtype\":50,\"p2shtype\":73,\"wiftype\":77,\"txfee\":10000}, {\"coin\":\"BTCH\",\"asset\":\"BTCH\",\"rpcport\":8800},{\"coin\":\"ETOMIC\",\"asset\":\"ETOMIC\",\"rpcport\":10271},{\"coin\":\"AXO\",\"asset\":\"AXO\",\"rpcport\":12927},{\"coin\":\"CRC\",\"name\":\"crowdcoin\",\"confpath\":\"${HOME#}/.crowdcoincore/crowdcoin.conf\",\"rpcport\":11998,\"pubtype\":28,\"p2shtype\":88,\"wiftype\":0,\"txfee\":10000}, {\"coin\":\"VOT\",\"name\":\"votecoin\",\"rpcport\":8232,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"INN\",\"name\":\"innova\",\"confpath\":\"${HOME#}/.innovacore/innova.conf\",\"rpcport\":8818,\"pubtype\":102,\"p2shtype\":20,\"wiftype\":195,\"txfee\":10000}, {\"coin\":\"MOON\",\"name\":\"mooncoin\",\"rpcport\":44663,\"pubtype\":3,\"p2shtype\":22,\"wiftype\":131,\"txfee\":100000}, {\"coin\":\"CRW\",\"name\":\"crown\",\"rpcport\":9341,\"pubtype\":0,\"p2shtype\":28,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"EFL\",\"name\":\"egulden\",\"confpath\":\"${HOME#}/.egulden/coin.conf\",\"rpcport\":21015,\"pubtype\":48,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"GBX\",\"name\":\"gobyte\",\"confpath\":\"${HOME#}/.gobytecore/gobyte.conf\",\"rpcport\":12454,\"pubtype\":38,\"p2shtype\":10,\"wiftype\":198,\"txfee\":10000}, {\"coin\":\"BCO\",\"name\":\"bridgecoin\",\"rpcport\":6332,\"pubtype\":27,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"BLK\",\"name\":\"blackcoin\",\"confpath\":\"${HOME#}/.lore/blackcoin.conf\",\"isPoS\":1,\"rpcport\":15715,\"pubtype\":25,\"p2shtype\":85,\"wiftype\":153,\"txfee\":100000}, {\"coin\":\"BTG\",\"name\":\"bitcoingold\",\"rpcport\":8332,\"pubtype\":38,\"p2shtype\":23,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"BCH\",\"name\":\"bch\",\"rpcport\":33333,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":1000}, {\"coin\":\"ABY\",\"name\":\"applebyte\",\"rpcport\":8607,\"pubtype\":23,\"p2shtype\":5,\"wiftype\":151,\"txfee\":100000}, {\"coin\":\"STAK\",\"name\":\"straks\",\"rpcport\":7574,\"pubtype\":63,\"p2shtype\":5,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"XZC\",\"name\":\"zcoin\",\"rpcport\":8888,\"pubtype\":82,\"p2shtype\":7,\"wiftype\":210,\"txfee\":10000}, {\"coin\":\"QTUM\",\"name\":\"qtum\",\"rpcport\":3889,\"pubtype\":58,\"p2shtype\":50,\"wiftype\":128,\"txfee\":400000}, {\"coin\":\"PURA\",\"name\":\"pura\",\"rpcport\":55555,\"pubtype\":55,\"p2shtype\":16,\"wiftype\":150,\"txfee\":10000}, {\"coin\":\"DSR\",\"name\":\"desire\",\"confpath\":\"${HOME#}/.desirecore/desire.conf\",\"rpcport\":9918,\"pubtype\":30,\"p2shtype\":16,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"MNZ\",\"asset\":\"MNZ\",\"rpcport\":14337},{\"coin\":\"BTCZ\",\"name\":\"bitcoinz\",\"rpcport\":1979,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"MAGA\",\"name\":\"magacoin\",\"rpcport\":5332,\"pubtype\":23,\"p2shtype\":50,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"BSD\",\"name\":\"bitsend\",\"rpcport\":8800,\"pubtype\":102,\"p2shtype\":5,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"IOP\",\"name\":\"IoP\",\"rpcport\":8337,\"pubtype\":117,\"p2shtype\":174,\"wiftype\":49,\"txfee\":10000}, {\"coin\":\"BLOCK\",\"name\":\"blocknetdx\",\"rpcport\":41414,\"pubtype\":26,\"p2shtype\":28,\"wiftype\":154,\"txfee\":10000}, {\"coin\":\"CHIPS\", \"name\": \"chips\", \"rpcport\":57776,\"pubtype\":60, \"p2shtype\":85, \"wiftype\":188, \"txfee\":10000}, {\"coin\":\"888\",\"name\":\"octocoin\",\"rpcport\":22888,\"pubtype\":18,\"p2shtype\":5,\"wiftype\":176,\"txfee\":2000000}, {\"coin\":\"ARG\",\"name\":\"argentum\",\"rpcport\":13581,\"pubtype\":23,\"p2shtype\":5,\"wiftype\":151,\"txfee\":50000}, {\"coin\":\"GLT\",\"name\":\"globaltoken\",\"rpcport\":9320,\"pubtype\":38,\"p2shtype\":5,\"wiftype\":166,\"txfee\":10000}, {\"coin\":\"ZER\",\"name\":\"zero\",\"rpcport\":23801,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":1000}, {\"coin\":\"HODLC\",\"name\":\"hodlcoin\",\"rpcport\":11989,\"pubtype\":40,\"p2shtype\":5,\"wiftype\":168,\"txfee\":5000}, {\"coin\":\"UIS\",\"name\":\"unitus\",\"rpcport\":50604,\"pubtype\":68,\"p2shtype\":10,\"wiftype\":132,\"txfee\":2000000}, {\"coin\":\"HUC\",\"name\":\"huntercoin\",\"rpcport\":8399,\"pubtype\":40,\"p2shtype\":13,\"wiftype\":168,\"txfee\":100000}, {\"coin\":\"BDL\",\"name\":\"bitdeal\",\"rpcport\":9332,\"pubtype\":38,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"ARC\",\"name\":\"arcticcoin\",\"confpath\":\"${HOME#}/.arcticcore/arcticcoin.conf\",\"rpcport\":7208,\"pubtype\":23,\"p2shtype\":8,\"wiftype\":176,\"txfee\":10000}, {\"coin\":\"ZCL\",\"name\":\"zclassic\",\"rpcport\":8023,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":1000}, {\"coin\":\"VIA\",\"name\":\"viacoin\",\"rpcport\":5222,\"pubtype\":71,\"p2shtype\":33,\"wiftype\":199,\"txfee\":100000}, {\"coin\":\"ERC\",\"name\":\"europecoin\",\"rpcport\":11989,\"pubtype\":33,\"p2shtype\":5,\"wiftype\":168,\"txfee\":10000},{\"coin\":\"FAIR\",\"name\":\"faircoin\",\"confpath\":\"${HOME#}/.faircoin2/faircoin.conf\",\"rpcport\":40405,\"pubtype\":95,\"p2shtype\":36,\"wiftype\":223,\"txfee\":1000000}, {\"coin\":\"FLO\",\"name\":\"florincoin\",\"rpcport\":7313,\"pubtype\":35,\"p2shtype\":8,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"SXC\",\"name\":\"sexcoin\",\"rpcport\":9561,\"pubtype\":62,\"p2shtype\":5,\"wiftype\":190,\"txfee\":100000}, {\"coin\":\"CREA\",\"name\":\"creativecoin\",\"rpcport\":17711,\"pubtype\":28,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"TRC\",\"name\":\"terracoin\",\"confpath\":\"${HOME#}/.terracoincore/terracoin.conf\",\"rpcport\":13332,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"BTA\",\"name\":\"bata\",\"rpcport\":5493,\"pubtype\":25,\"p2shtype\":5,\"wiftype\":188,\"txfee\":100000}, {\"coin\":\"SMC\",\"name\":\"smartcoin\",\"rpcport\":58583,\"pubtype\":63,\"p2shtype\":5,\"wiftype\":191,\"txfee\":1000000}, {\"coin\":\"NMC\",\"name\":\"namecoin\",\"rpcport\":8336,\"pubtype\":52,\"p2shtype\":13,\"wiftype\":180,\"txfee\":100000}, {\"coin\":\"NAV\",\"name\":\"navcoin\",\"isPoS\":1,\"confpath\":\"${HOME#}/.navcoin4/navcoin.conf\",\"rpcport\":44444,\"pubtype\":53,\"p2shtype\":85,\"wiftype\":150,\"txfee\":10000}, {\"coin\":\"EMC2\",\"name\":\"einsteinium\",\"rpcport\":41879,\"pubtype\":33,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000},{\"coin\":\"SYS\",\"name\":\"syscoin\",\"rpcport\":8370,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"I0C\",\"name\":\"i0coin\",\"rpcport\":7332,\"pubtype\":105,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"DASH\",\"confpath\":\"${HOME#}/.dashcore/dash.conf\",\"name\":\"dashcore\",\"rpcport\":9998,\"pubtype\":76,\"p2shtype\":16,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"STRAT\", \"name\": \"stratis\", \"active\":0, \"rpcport\":16174,\"pubtype\":63, \"p2shtype\":125, \"wiftype\":191, \"txfee\":10000}, {\"confpath\":\"${HOME#}/.muecore/mue.conf\",\"coin\":\"MUE\",\"name\":\"muecore\",\"rpcport\":29683,\"pubtype\":16,\"p2shtype\":76,\"wiftype\":126,\"txfee\":10000}, {\"coin\":\"MONA\",\"name\":\"monacoin\",\"rpcport\":9402,\"pubtype\":50,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000},{\"coin\":\"XMY\",\"name\":\"myriadcoin\",\"rpcport\":10889,\"pubtype\":50,\"p2shtype\":9,\"wiftype\":178,\"txfee\":5000}, {\"coin\":\"MAC\",\"name\":\"machinecoin\",\"rpcport\":40332,\"pubtype\":50,\"p2shtype\":5,\"wiftype\":178,\"txfee\":100000}, {\"coin\":\"BTX\",\"name\":\"bitcore\",\"rpcport\":8556,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":50000}, {\"coin\":\"XRE\",\"name\":\"revolvercoin\",\"rpcport\":8775,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"LBC\",\"name\":\"lbrycrd\",\"rpcport\":9245,\"pubtype\":85,\"p2shtype\":122,\"wiftype\":28,\"txfee\":10000}, {\"coin\":\"SIB\",\"name\":\"sibcoin\",\"rpcport\":1944,\"pubtype\":63,\"p2shtype\":40,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"VTC\", \"name\":\"vertcoin\", \"rpcport\":5888, \"pubtype\":71, \"p2shtype\":5, \"wiftype\":128, \"txfee\":100000 }, {\"coin\":\"REVS\",\"active\":0, \"asset\":\"REVS\",\"rpcport\":10196}, {\"coin\":\"JUMBLR\",\"active\":0, \"asset\":\"JUMBLR\",\"rpcport\":15106}, {\"coin\":\"DOGE\",\"name\":\"dogecoin\",\"rpcport\":22555,\"pubtype\":30,\"p2shtype\":22,\"wiftype\":158,\"txfee\":100000000}, {\"coin\":\"HUSH\",\"name\":\"hush\",\"rpcport\":8822,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":1000 }, {\"active\":0,\"coin\":\"ZEC\",\"name\":\"zcash\",\"rpcport\":8232,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":10000 }, {\"coin\":\"DGB\",\"name\":\"digibyte\",\"rpcport\":14022,\"pubtype\":30,\"p2shtype\":5,\"wiftype\":128,\"txfee\":100000}, {\"coin\":\"ZET\", \"name\":\"zetacoin\", \"pubtype\":80, \"p2shtype\":9,\"rpcport\":8332, \"wiftype\":224, \"txfee\":10000}, {\"coin\":\"GAME\", \"rpcport\":40001, \"name\":\"gamecredits\", \"pubtype\":38, \"p2shtype\":5, \"wiftype\":166, \"txfee\":100000}, {\"coin\":\"LTC\", \"name\":\"litecoin\", \"rpcport\":9332, \"pubtype\":48, \"p2shtype\":5, \"wiftype\":176, \"txfee\":100000 }, {\"coin\":\"SUPERNET\",\"asset\":\"SUPERNET\",\"rpcport\":11341}, {\"coin\":\"WLC\",\"asset\":\"WLC\",\"rpcport\":12167}, {\"coin\":\"PANGEA\",\"asset\":\"PANGEA\",\"rpcport\":14068}, {\"coin\":\"DEX\",\"asset\":\"DEX\",\"rpcport\":11890}, {\"coin\":\"BET\",\"asset\":\"BET\",\"rpcport\":14250}, {\"coin\":\"CRYPTO\",\"asset\":\"CRYPTO\",\"rpcport\":8516}, {\"coin\":\"HODL\",\"asset\":\"HODL\",\"rpcport\":14431}, {\"coin\":\"MSHARK\",\"asset\":\"MSHARK\",\"rpcport\":8846}, {\"coin\":\"BOTS\",\"asset\":\"BOTS\",\"rpcport\":11964}, {\"coin\":\"MGW\",\"asset\":\"MGW\",\"rpcport\":12386}, {\"coin\":\"COQUI\",\"asset\":\"COQUI\",\"rpcport\":14276}, {\"coin\":\"KV\",\"asset\":\"KV\",\"rpcport\":8299}, {\"coin\":\"CEAL\",\"asset\":\"CEAL\",\"rpcport\":11116}, {\"coin\":\"MESH\",\"asset\":\"MESH\",\"rpcport\":9455}]" #, {\"coin\":\"AUD\",\"asset\":\"AUD\",\"rpcport\":8045}, {\"coin\":\"BGN\",\"asset\":\"BGN\",\"rpcport\":9110}, {\"coin\":\"CAD\",\"asset\":\"CAD\",\"rpcport\":8720}, {\"coin\":\"CHF\",\"asset\":\"CHF\",\"rpcport\":15312}, {\"coin\":\"CNY\",\"asset\":\"CNY\",\"rpcport\":10384}, {\"coin\":\"CZK\",\"asset\":\"CZK\",\"rpcport\":9482}, {\"coin\":\"DKK\",\"asset\":\"DKK\",\"rpcport\":13830}, {\"coin\":\"EUR\",\"asset\":\"EUR\",\"rpcport\":8065}, {\"coin\":\"GBP\",\"asset\":\"GBP\",\"rpcport\":11505}, {\"coin\":\"HKD\",\"asset\":\"HKD\",\"rpcport\":15409}, {\"coin\":\"HRK\",\"asset\":\"HRK\",\"rpcport\":12617}, {\"coin\":\"HUF\",\"asset\":\"HUF\",\"rpcport\":13699}, {\"coin\":\"IDR\",\"asset\":\"IDR\",\"rpcport\":14459}, {\"coin\":\"ILS\",\"asset\":\"ILS\",\"rpcport\":14638}, {\"coin\":\"INR\",\"asset\":\"INR\",\"rpcport\":10536}, {\"coin\":\"JPY\",\"asset\":\"JPY\",\"rpcport\":13145}, {\"coin\":\"KRW\",\"asset\":\"KRW\",\"rpcport\":14020}, {\"coin\":\"MXN\",\"asset\":\"MXN\",\"rpcport\":13970}, {\"coin\":\"MYR\",\"asset\":\"MYR\",\"rpcport\":10688}, {\"coin\":\"NOK\",\"asset\":\"NOK\",\"rpcport\":11588}, {\"coin\":\"NZD\",\"asset\":\"NZD\",\"rpcport\":10915}, {\"coin\":\"PHP\",\"asset\":\"PHP\",\"rpcport\":11181}, {\"coin\":\"PLN\",\"asset\":\"PLN\",\"rpcport\":13493}, {\"coin\":\"BRL\",\"asset\":\"BRL\",\"rpcport\":9914}, {\"coin\":\"RON\",\"asset\":\"RON\",\"rpcport\":8675}, {\"coin\":\"RUB\",\"asset\":\"RUB\",\"rpcport\":8199}, {\"coin\":\"SEK\",\"asset\":\"SEK\",\"rpcport\":11447}, {\"coin\":\"SGD\",\"asset\":\"SGD\",\"rpcport\":14475}, {\"coin\":\"THB\",\"asset\":\"THB\",\"rpcport\":11847}, {\"coin\":\"TRY\",\"asset\":\"TRY\",\"rpcport\":13924}, {\"coin\":\"USD\",\"asset\":\"USD\",\"rpcport\":13967}, {\"coin\":\"ZAR\",\"asset\":\"ZAR\",\"rpcport\":15160}]" #{\"coin\":\"PIVX\",\"name\":\"pivx\",\"rpcport\":51473,\"pubtype\":30,\"p2shtype\":13,\"wiftype\":212,\"txfee\":10000}, diff --git a/iguana/exchanges/LP_coins.c b/iguana/exchanges/LP_coins.c index 3722ad819..6344cf278 100644 --- a/iguana/exchanges/LP_coins.c +++ b/iguana/exchanges/LP_coins.c @@ -496,6 +496,7 @@ struct iguana_info *LP_coinfind(char *symbol) struct iguana_info *LP_coincreate(cJSON *item) { struct iguana_info cdata,*coin=0; int32_t isPoS,longestchain = 1; uint16_t port; uint64_t txfee; double estimatedrate; uint8_t pubtype,p2shtype,wiftype; char *name=0,*symbol,*assetname=0; + if ( (symbol= jstr(item,"coin")) != 0 && symbol[0] != 0 && strlen(symbol) < 16 && LP_coinfind(symbol) == 0 && (port= juint(item,"rpcport")) != 0 ) { isPoS = jint(item,"isPoS"); @@ -514,6 +515,8 @@ struct iguana_info *LP_coincreate(cJSON *item) } else if ( (name= jstr(item,"name")) == 0 ) name = symbol; + + cdata.decimals = juint(item,"decimals"); if ( LP_coininit(&cdata,symbol,name,assetname==0?"":assetname,isPoS,port,pubtype,p2shtype,wiftype,txfee,estimatedrate,longestchain,juint(item,"wiftaddr"),juint(item,"taddr"),LP_busport(port),jstr(item,"confpath")) < 0 ) { coin = LP_coinadd(&cdata); diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index abd47ae22..6ffceacaa 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -44,7 +44,9 @@ char *LP_etomicalice_send_fee(struct basilisk_swap *swap) if (strcmp(swap->I.alicestr,"ETH") == 0 ) { return(sendEth(dexaddr, amount, secretKey, 1, 0, 0, 1)); } else { - return(sendErc20(swap->I.alicetomic, dexaddr, amount, secretKey, 1, 0, 0, 1)); + struct iguana_info *alicecoin = LP_coinfind(swap->I.alicestr); + + return(sendErc20(swap->I.alicetomic, dexaddr, amount, secretKey, 1, 0, 0, 1, alicecoin->decimals)); } } @@ -74,13 +76,15 @@ uint8_t LP_etomic_verify_alice_fee(struct basilisk_swap *swap) } return(1); } else { + struct iguana_info *alicecoin = LP_coinfind(swap->I.alicestr); + if (strcmp(data.to, swap->I.alicetomic) != 0) { printf("Alice ERC20 fee %s token address %s is not equal to expected %s\n", swap->otherfee.I.ethTxid, data.to, swap->I.alicetomic); return(0); } char weiAmount[70]; satoshisToWei(weiAmount, swap->otherfee.I.amount); - return(verifyAliceErc20FeeData(swap->I.alicetomic, dexaddr, weiAmount, data.input)); + return(verifyAliceErc20FeeData(swap->I.alicetomic, dexaddr, weiAmount, data.input, alicecoin->decimals)); } } @@ -107,6 +111,8 @@ char *LP_etomicalice_send_payment(struct basilisk_swap *swap) } else { + struct iguana_info *alicecoin = LP_coinfind(swap->I.alicestr); + memset(&input20,0,sizeof(input20)); strcpy(input20.bobAddress, swap->I.etomicsrc); uint8arrayToHex(input20.bobHash, swap->I.secretBn, 20); @@ -114,13 +120,14 @@ char *LP_etomicalice_send_payment(struct basilisk_swap *swap) uint8arrayToHex(input20.dealId, swap->alicepayment.I.actualtxid.bytes, 32); strcpy(input20.tokenAddress, swap->I.alicetomic); satoshisToWei(input20.amount, swap->I.alicesatoshis); + input20.decimals = alicecoin->decimals; strcpy(txData.from, swap->I.etomicdest); strcpy(txData.to, ETOMIC_ALICECONTRACT); strcpy(txData.amount, "0"); uint8arrayToHex(txData.secretKey, swap->persistent_privkey.bytes, 32); - uint64_t allowance = getErc20Allowance(swap->I.etomicdest, ETOMIC_ALICECONTRACT, swap->I.alicetomic); + uint64_t allowance = getErc20Allowance(swap->I.etomicdest, ETOMIC_ALICECONTRACT, swap->I.alicetomic, alicecoin->decimals); if (allowance < swap->I.alicesatoshis) { printf("Alice token allowance is too low, setting new allowance\n"); ApproveErc20Input approveErc20Input; @@ -173,6 +180,8 @@ uint8_t LP_etomic_verify_alice_payment(struct basilisk_swap *swap, char *txId) return(verifyAliceEthPaymentData(input, data.input)); } else { + struct iguana_info *alicecoin = LP_coinfind(swap->I.alicestr); + memset(&input20,0,sizeof(input20)); strcpy(input20.bobAddress, swap->I.etomicsrc); uint8arrayToHex(input20.bobHash, swap->I.secretBn, 20); @@ -180,6 +189,7 @@ uint8_t LP_etomic_verify_alice_payment(struct basilisk_swap *swap, char *txId) uint8arrayToHex(input20.dealId, swap->alicepayment.I.actualtxid.bytes, 32); strcpy(input20.tokenAddress, swap->I.alicetomic); satoshisToWei(input20.amount, swap->I.alicesatoshis); + input20.decimals = alicecoin->decimals; return(verifyAliceErc20PaymentData(input20, data.input)); } @@ -223,6 +233,9 @@ char *LP_etomicalice_reclaims_payment(struct LP_swap_remember *swap) } uint8arrayToHex(input.bobSecret, invertedSecret.bytes, 32); + struct iguana_info *alice_coin = LP_coinfind(swap->alicecoin); + input.decimals = alice_coin->decimals; + strcpy(txData.from, swap->etomicdest); strcpy(txData.to, ETOMIC_ALICECONTRACT); strcpy(txData.amount, "0"); @@ -268,6 +281,8 @@ char *LP_etomicbob_spends_alice_payment(struct LP_swap_remember *swap) } uint8arrayToHex(input.aliceSecret, invertedSecret.bytes, 32); uint8arrayToHex(input.bobHash, swap->secretBn, 20); + struct iguana_info *alice_coin = LP_coinfind(swap->alicecoin); + input.decimals = alice_coin->decimals; strcpy(txData.from, swap->etomicsrc); strcpy(txData.to, ETOMIC_ALICECONTRACT); @@ -296,19 +311,22 @@ char *LP_etomicbob_sends_deposit(struct basilisk_swap *swap) uint8arrayToHex(txData.secretKey, swap->persistent_privkey.bytes, 32); return bobSendsEthDeposit(input, txData); } else { + struct iguana_info *bobcoin = LP_coinfind(swap->I.bobstr); + uint8arrayToHex(input20.depositId, swap->bobdeposit.I.actualtxid.bytes, 32); strcpy(input20.aliceAddress, swap->I.etomicdest); uint8arrayToHex(input20.bobHash, swap->I.secretBn, 20); satoshisToWei(input20.amount, swap->bobdeposit.I.amount); strcpy(input20.tokenAddress, swap->I.bobtomic); input20.lockTime = swap->bobdeposit.I.locktime; + input20.decimals = bobcoin->decimals; strcpy(txData.from, swap->I.etomicsrc); strcpy(txData.to, ETOMIC_BOBCONTRACT); strcpy(txData.amount, "0"); uint8arrayToHex(txData.secretKey, swap->persistent_privkey.bytes, 32); - uint64_t allowance = getErc20Allowance(swap->I.etomicsrc, ETOMIC_BOBCONTRACT, swap->I.bobtomic); + uint64_t allowance = getErc20Allowance(swap->I.etomicsrc, ETOMIC_BOBCONTRACT, swap->I.bobtomic, bobcoin->decimals); if (allowance < swap->bobdeposit.I.amount) { printf("Bob token allowance is too low, setting new allowance\n"); ApproveErc20Input approveErc20Input; @@ -362,12 +380,15 @@ uint8_t LP_etomic_verify_bob_deposit(struct basilisk_swap *swap, char *txId) return verifyBobEthDepositData(input, data.input); } else { + struct iguana_info *bobcoin = LP_coinfind(swap->I.bobstr); + uint8arrayToHex(input20.depositId, swap->bobdeposit.I.actualtxid.bytes, 32); strcpy(input20.aliceAddress, swap->I.etomicdest); uint8arrayToHex(input20.bobHash, swap->I.secretBn, 20); satoshisToWei(input20.amount, swap->bobdeposit.I.amount); strcpy(input20.tokenAddress, swap->I.bobtomic); input20.lockTime = swap->bobdeposit.I.locktime; + input20.decimals = bobcoin->decimals; return verifyBobErc20DepositData(input20, data.input); } @@ -384,9 +405,10 @@ char *LP_etomicbob_refunds_deposit(struct LP_swap_remember *swap) memset(&txData,0,sizeof(txData)); memset(&input,0,sizeof(input)); - struct iguana_info *ecoin; + struct iguana_info *ecoin, *bobcoin; bits256 privkey; ecoin = LP_coinfind("ETOMIC"); + bobcoin = LP_coinfind(swap->bobcoin); privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr); EthTxReceipt receipt = getEthTxReceipt(swap->bobDepositEthTx); @@ -410,6 +432,7 @@ char *LP_etomicbob_refunds_deposit(struct LP_swap_remember *swap) strcpy(input.tokenAddress, "0x0000000000000000000000000000000000000000"); } satoshisToWei(input.amount, swap->values[BASILISK_BOBDEPOSIT]); + input.decimals = bobcoin->decimals; strcpy(txData.from, swap->etomicsrc); strcpy(txData.to, ETOMIC_BOBCONTRACT); @@ -439,19 +462,22 @@ char *LP_etomicbob_sends_payment(struct basilisk_swap *swap) uint8arrayToHex(txData.secretKey, swap->persistent_privkey.bytes, 32); return bobSendsEthPayment(input, txData); } else { + struct iguana_info *bobcoin = LP_coinfind(swap->I.bobstr); + uint8arrayToHex(input20.paymentId, swap->bobpayment.I.actualtxid.bytes, 32); strcpy(input20.aliceAddress, swap->I.etomicdest); uint8arrayToHex(input20.aliceHash, swap->I.secretAm, 20); satoshisToWei(input20.amount, swap->bobpayment.I.amount); strcpy(input20.tokenAddress, swap->I.bobtomic); input20.lockTime = swap->bobpayment.I.locktime; + input20.decimals = bobcoin->decimals; strcpy(txData.from, swap->I.etomicsrc); strcpy(txData.to, ETOMIC_BOBCONTRACT); strcpy(txData.amount, "0"); uint8arrayToHex(txData.secretKey, swap->persistent_privkey.bytes, 32); - uint64_t allowance = getErc20Allowance(swap->I.etomicsrc, ETOMIC_BOBCONTRACT, swap->I.bobtomic); + uint64_t allowance = getErc20Allowance(swap->I.etomicsrc, ETOMIC_BOBCONTRACT, swap->I.bobtomic, bobcoin->decimals); if (allowance < swap->bobpayment.I.amount) { printf("Bob token allowance is too low, setting new allowance\n"); ApproveErc20Input approveErc20Input; @@ -504,12 +530,15 @@ uint8_t LP_etomic_verify_bob_payment(struct basilisk_swap *swap, char *txId) return verifyBobEthPaymentData(input, data.input); } else { + struct iguana_info *bobcoin = LP_coinfind(swap->I.bobstr); + uint8arrayToHex(input20.paymentId, swap->bobpayment.I.actualtxid.bytes, 32); strcpy(input20.aliceAddress, swap->I.etomicdest); uint8arrayToHex(input20.aliceHash, swap->I.secretAm, 20); satoshisToWei(input20.amount, swap->bobpayment.I.amount); strcpy(input20.tokenAddress, swap->I.bobtomic); input20.lockTime = swap->bobpayment.I.locktime; + input20.decimals = bobcoin->decimals; return verifyBobErc20PaymentData(input20, data.input); } @@ -526,9 +555,10 @@ char *LP_etomicbob_reclaims_payment(struct LP_swap_remember *swap) memset(&txData,0,sizeof(txData)); memset(&input,0,sizeof(input)); - struct iguana_info *ecoin; + struct iguana_info *ecoin, *bobcoin; bits256 privkey; ecoin = LP_coinfind("ETOMIC"); + bobcoin = LP_coinfind(swap->bobcoin); privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr); EthTxReceipt receipt = getEthTxReceipt(swap->bobPaymentEthTx); @@ -546,6 +576,7 @@ char *LP_etomicbob_reclaims_payment(struct LP_swap_remember *swap) strcpy(input.tokenAddress, "0x0000000000000000000000000000000000000000"); } satoshisToWei(input.amount, swap->values[BASILISK_BOBPAYMENT]); + input.decimals = bobcoin->decimals; strcpy(txData.from, swap->etomicsrc); strcpy(txData.to, ETOMIC_BOBCONTRACT); @@ -570,9 +601,10 @@ char *LP_etomicalice_spends_bob_payment(struct LP_swap_remember *swap) printf("Bob payment %s receipt status failed, can't spend\n", swap->bobPaymentEthTx); return NULL; } - struct iguana_info *ecoin; + struct iguana_info *ecoin, *bobcoin; bits256 privkey; ecoin = LP_coinfind("ETOMIC"); + bobcoin = LP_coinfind(swap->bobcoin); privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr); uint8arrayToHex(input.paymentId, swap->txids[BASILISK_BOBPAYMENT].bytes, 32); @@ -591,6 +623,7 @@ char *LP_etomicalice_spends_bob_payment(struct LP_swap_remember *swap) invertedSecret.bytes[i] = swap->privAm.bytes[31 - i]; } uint8arrayToHex(input.aliceSecret, invertedSecret.bytes, 32); + input.decimals = bobcoin->decimals; strcpy(txData.from, swap->etomicdest); strcpy(txData.to, ETOMIC_BOBCONTRACT); @@ -616,9 +649,10 @@ char *LP_etomicalice_claims_bob_deposit(struct LP_swap_remember *swap) return NULL; } - struct iguana_info *ecoin; + struct iguana_info *ecoin, *bobcoin; bits256 privkey; ecoin = LP_coinfind("ETOMIC"); + bobcoin = LP_coinfind(swap->bobcoin); privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr); uint8arrayToHex(input.depositId, swap->txids[BASILISK_BOBDEPOSIT].bytes, 32); @@ -632,6 +666,7 @@ char *LP_etomicalice_claims_bob_deposit(struct LP_swap_remember *swap) strcpy(input.bobAddress, swap->etomicsrc); uint8arrayToHex(input.bobHash, swap->secretBn, 20); + input.decimals = bobcoin->decimals; strcpy(txData.from, swap->etomicdest); strcpy(txData.to, ETOMIC_BOBCONTRACT); @@ -718,6 +753,6 @@ uint64_t LP_etomic_get_balance(struct iguana_info *coin, char *coinaddr) if (strcmp(coin->symbol, "ETH") == 0) { return getEthBalance(coinaddr); } else { - return getErc20BalanceSatoshi(coinaddr, coin->etomic); + return getErc20BalanceSatoshi(coinaddr, coin->etomic, coin->decimals); } } diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index 4080ba31c..83e4ff577 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -312,7 +312,7 @@ struct iguana_info double price_kmd,force,perc,goal,goalperc,relvolume,rate; void *electrum; void *ctx; uint64_t maxamount,kmd_equiv,balanceA,balanceB,valuesumA,valuesumB; - uint8_t pubkey33[33],zcash; + uint8_t pubkey33[33],zcash,decimals; int32_t privkeydepth; bits256 cachedtxid,notarizationtxid; uint8_t *cachedtxiddata; int32_t cachedtxidlen; bits256 cachedmerkle,notarizedhash; int32_t cachedmerkleheight; diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index 0019db68c..22b7645ca 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -1987,7 +1987,7 @@ char *LP_eth_withdraw(struct iguana_info *coin,cJSON *argjson) if (strcmp(coin->symbol, "ETH") == 0) { tx_id = sendEth(dest_addr, amount_str, privkey_str, 0, gas, gas_price, 0); } else { - tx_id = sendErc20(coin->etomic, dest_addr, amount_str, privkey_str, 0, gas, gas_price, 0); + tx_id = sendErc20(coin->etomic, dest_addr, amount_str, privkey_str, 0, gas, gas_price, 0, coin->decimals); } if (tx_id != NULL) { jaddstr(retjson, "tx_id", tx_id); diff --git a/iguana/exchanges/etomicswap/etomiclib.cpp b/iguana/exchanges/etomicswap/etomiclib.cpp index 58139ee65..d5987ae19 100644 --- a/iguana/exchanges/etomicswap/etomiclib.cpp +++ b/iguana/exchanges/etomicswap/etomiclib.cpp @@ -34,11 +34,11 @@ TransactionSkeleton txDataToSkeleton(BasicTxData txData) char *signTx(TransactionSkeleton& tx, char* secret) { - Secret& secretKey = *(new Secret(secret)); - auto baseTx = new TransactionBase(tx, secretKey); - RLPStream& rlpStream = *(new RLPStream()); - baseTx->streamRLP(rlpStream); - std::stringstream& ss = *(new std::stringstream); + Secret secretKey(secret); + TransactionBase baseTx(tx, secretKey); + RLPStream rlpStream; + baseTx.streamRLP(rlpStream); + std::stringstream ss; ss << rlpStream.out(); return stringStreamToChar(ss); } @@ -101,7 +101,12 @@ uint8_t verifyAliceEthPaymentData(AliceSendsEthPaymentInput input, char *data) std::stringstream aliceSendsErc20PaymentData(AliceSendsErc20PaymentInput input) { - uint8_t decimals = getErc20Decimals(input.tokenAddress); + uint8_t decimals; + if (input.decimals > 0) { + decimals = input.decimals; + } else { + decimals = getErc20Decimals(input.tokenAddress); + } u256 amount = jsToU256(input.amount); if (decimals < 18) { amount /= boost::multiprecision::pow(u256(10), 18 - decimals); @@ -148,12 +153,20 @@ char* aliceReclaimsAlicePayment(AliceReclaimsAlicePaymentInput input, BasicTxDat std::stringstream ss; u256 amount = jsToU256(input.amount); dev::Address tokenAddress = jsToAddress(input.tokenAddress); + if (tokenAddress != ZeroAddress) { - uint8_t decimals = getErc20Decimals(input.tokenAddress); + uint8_t decimals; + if (input.decimals > 0) { + decimals = input.decimals; + } else { + decimals = getErc20Decimals(input.tokenAddress); + } + if (decimals < 18) { amount /= boost::multiprecision::pow(u256(10), 18 - decimals); } } + ss << "0x8b9a167a" << toHex(jsToBytes(input.dealId)) << toHex(toBigEndian(amount)) @@ -179,12 +192,20 @@ char* bobSpendsAlicePayment(BobSpendsAlicePaymentInput input, BasicTxData txData std::stringstream ss; u256 amount = jsToU256(input.amount); dev::Address tokenAddress = jsToAddress(input.tokenAddress); + if (tokenAddress != ZeroAddress) { - uint8_t decimals = getErc20Decimals(input.tokenAddress); + uint8_t decimals; + if (input.decimals > 0) { + decimals = input.decimals; + } else { + decimals = getErc20Decimals(input.tokenAddress); + } + if (decimals < 18) { amount /= boost::multiprecision::pow(u256(10), 18 - decimals); } } + ss << "0x392ec66b" << toHex(jsToBytes(input.dealId)) << toHex(toBigEndian(amount)) @@ -241,7 +262,13 @@ uint8_t verifyBobEthDepositData(BobSendsEthDepositInput input, char *data) std::stringstream bobSendsErc20DepositData(BobSendsErc20DepositInput input) { - uint8_t decimals = getErc20Decimals(input.tokenAddress); + uint8_t decimals; + if (input.decimals > 0) { + decimals = input.decimals; + } else { + decimals = getErc20Decimals(input.tokenAddress); + } + u256 amount = jsToU256(input.amount); u256 lockTime = input.lockTime; if (decimals < 18) { @@ -289,7 +316,13 @@ char* bobRefundsDeposit(BobRefundsDepositInput input, BasicTxData txData) u256 amount = jsToU256(input.amount); dev::Address tokenAddress = jsToAddress(input.tokenAddress); if (tokenAddress != ZeroAddress) { - uint8_t decimals = getErc20Decimals(input.tokenAddress); + uint8_t decimals; + if (input.decimals > 0) { + decimals = input.decimals; + } else { + decimals = getErc20Decimals(input.tokenAddress); + } + if (decimals < 18) { amount /= boost::multiprecision::pow(u256(10), 18 - decimals); } @@ -316,7 +349,13 @@ char* aliceClaimsBobDeposit(AliceClaimsBobDepositInput input, BasicTxData txData u256 amount = jsToU256(input.amount); dev::Address tokenAddress = jsToAddress(input.tokenAddress); if (tokenAddress != ZeroAddress) { - uint8_t decimals = getErc20Decimals(input.tokenAddress); + uint8_t decimals; + if (input.decimals > 0) { + decimals = input.decimals; + } else { + decimals = getErc20Decimals(input.tokenAddress); + } + if (decimals < 18) { amount /= boost::multiprecision::pow(u256(10), 18 - decimals); } @@ -374,9 +413,15 @@ uint8_t verifyBobEthPaymentData(BobSendsEthPaymentInput input, char *data) std::stringstream bobSendsErc20PaymentData(BobSendsErc20PaymentInput input) { - uint8_t decimals = getErc20Decimals(input.tokenAddress); u256 amount = jsToU256(input.amount); u256 lockTime = input.lockTime; + uint8_t decimals; + if (input.decimals > 0) { + decimals = input.decimals; + } else { + decimals = getErc20Decimals(input.tokenAddress); + } + if (decimals < 18) { amount /= boost::multiprecision::pow(u256(10), 18 - decimals); } @@ -422,7 +467,13 @@ char* bobReclaimsBobPayment(BobReclaimsBobPaymentInput input, BasicTxData txData u256 amount = jsToU256(input.amount); dev::Address tokenAddress = jsToAddress(input.tokenAddress); if (tokenAddress != ZeroAddress) { - uint8_t decimals = getErc20Decimals(input.tokenAddress); + uint8_t decimals; + if (input.decimals > 0) { + decimals = input.decimals; + } else { + decimals = getErc20Decimals(input.tokenAddress); + } + if (decimals < 18) { amount /= boost::multiprecision::pow(u256(10), 18 - decimals); } @@ -450,7 +501,13 @@ char* aliceSpendsBobPayment(AliceSpendsBobPaymentInput input, BasicTxData txData u256 amount = jsToU256(input.amount); dev::Address tokenAddress = jsToAddress(input.tokenAddress); if (tokenAddress != ZeroAddress) { - uint8_t decimals = getErc20Decimals(input.tokenAddress); + uint8_t decimals; + if (input.decimals > 0) { + decimals = input.decimals; + } else { + decimals = getErc20Decimals(input.tokenAddress); + } + if (decimals < 18) { amount /= boost::multiprecision::pow(u256(10), 18 - decimals); } @@ -472,24 +529,24 @@ char* aliceSpendsBobPayment(AliceSpendsBobPaymentInput input, BasicTxData txData char* privKey2Addr(char* privKey) { - Secret& secretKey = *(new Secret(privKey)); - std::stringstream& ss = *(new std::stringstream); + Secret secretKey(privKey); + std::stringstream ss; ss << "0x" << toAddress(secretKey); return stringStreamToChar(ss); }; char* pubKey2Addr(char* pubKey) { - Public& publicKey = *(new Public(pubKey)); - std::stringstream& ss = *(new std::stringstream); + Public publicKey(pubKey); + std::stringstream ss; ss << "0x" << toAddress(publicKey); return stringStreamToChar(ss); }; char* getPubKeyFromPriv(char* privKey) { - Public publicKey = toPublic(*(new Secret(privKey))); - std::stringstream& ss = *(new std::stringstream); + Public publicKey = toPublic(Secret(privKey)); + std::stringstream ss; ss << "0x" << publicKey; return stringStreamToChar(ss); } @@ -503,16 +560,21 @@ uint64_t getEthBalance(char* address) return static_cast(balance); } -uint64_t getErc20BalanceSatoshi(char *address, char *tokenAddress) +uint64_t getErc20BalanceSatoshi(char *address, char *tokenAddress, uint8_t setDecimals) { std::stringstream ss; ss << "0x70a08231" << "000000000000000000000000" << toHex(jsToAddress(address)); - std::stringstream& resultStream = *(new std::stringstream); char* hexBalance = ethCall(tokenAddress, ss.str().c_str()); // convert wei to satoshi - uint8_t decimals = getErc20Decimals(tokenAddress); + uint8_t decimals; + if (setDecimals > 0) { + decimals = setDecimals; + } else { + decimals = getErc20Decimals(tokenAddress); + } + u256 balance = jsToU256(hexBalance); if (decimals < 18) { balance *= boost::multiprecision::pow(u256(10), 18 - decimals); @@ -532,7 +594,7 @@ char *getErc20BalanceHexWei(char *address, char *tokenAddress) return hexBalance; } -uint64_t getErc20Allowance(char *owner, char *spender, char *tokenAddress) +uint64_t getErc20Allowance(char *owner, char *spender, char *tokenAddress, uint8_t set_decimals) { std::stringstream ss; ss << "0xdd62ed3e" @@ -541,7 +603,12 @@ uint64_t getErc20Allowance(char *owner, char *spender, char *tokenAddress) << "000000000000000000000000" << toHex(jsToAddress(spender)); char* hexAllowance = ethCall(tokenAddress, ss.str().c_str()); - uint8_t decimals = getErc20Decimals(tokenAddress); + uint8_t decimals; + if (set_decimals > 0) { + decimals = set_decimals; + } else { + decimals = getErc20Decimals(tokenAddress); + } u256 allowance = jsToU256(hexAllowance); if (decimals < 18) { allowance *= boost::multiprecision::pow(u256(10), 18 - decimals); @@ -616,10 +683,15 @@ char *sendEth(char *to, char *amount, char *privKey, uint8_t waitConfirm, int64_ return result; } -std::stringstream getErc20TransferData(char *tokenAddress, char *to, char *amount) +std::stringstream getErc20TransferData(char *tokenAddress, char *to, char *amount, uint8_t setDecimals) { u256 amountWei = jsToU256(amount); - uint8_t decimals = getErc20Decimals(tokenAddress); + uint8_t decimals; + if (setDecimals > 0) { + decimals = setDecimals; + } else { + decimals = getErc20Decimals(tokenAddress); + } if (decimals < 18) { amountWei /= boost::multiprecision::pow(u256(10), 18 - decimals); } @@ -632,11 +704,21 @@ std::stringstream getErc20TransferData(char *tokenAddress, char *to, char *amoun return ss; } -char *sendErc20(char *tokenAddress, char *to, char *amount, char *privKey, uint8_t waitConfirm, int64_t gas, int64_t gasPrice, uint8_t defaultGasOnErr) +char *sendErc20( + char *tokenAddress, + char *to, + char *amount, + char *privKey, + uint8_t waitConfirm, + int64_t gas, + int64_t gasPrice, + uint8_t defaultGasOnErr, + uint8_t decimals +) { TransactionSkeleton tx; char *from = privKey2Addr(privKey), *result; - std::stringstream ss = getErc20TransferData(tokenAddress, to, amount); + std::stringstream ss = getErc20TransferData(tokenAddress, to, amount, decimals); tx.from = jsToAddress(from); tx.to = jsToAddress(tokenAddress); @@ -676,9 +758,9 @@ char *sendErc20(char *tokenAddress, char *to, char *amount, char *privKey, uint8 return result; } -uint8_t verifyAliceErc20FeeData(char* tokenAddress, char *to, char *amount, char *data) +uint8_t verifyAliceErc20FeeData(char* tokenAddress, char *to, char *amount, char *data, uint8_t decimals) { - std::stringstream ss = getErc20TransferData(tokenAddress, to, amount); + std::stringstream ss = getErc20TransferData(tokenAddress, to, amount, decimals); if (strcmp(ss.str().c_str(), data) != 0) { printf("Alice ERC20 fee data %s is not equal to expected %s\n", data, ss.str().c_str()); return 0; diff --git a/iguana/exchanges/etomicswap/etomiclib.h b/iguana/exchanges/etomicswap/etomiclib.h index 2ba9893e6..97fa29f18 100644 --- a/iguana/exchanges/etomicswap/etomiclib.h +++ b/iguana/exchanges/etomicswap/etomiclib.h @@ -38,6 +38,7 @@ typedef struct { char bobAddress[65]; char aliceHash[65]; char bobHash[65]; + uint8_t decimals; } AliceSendsErc20PaymentInput; typedef struct { @@ -47,6 +48,7 @@ typedef struct { char bobAddress[65]; char aliceHash[65]; char bobSecret[70]; + uint8_t decimals; } AliceReclaimsAlicePaymentInput; typedef struct { @@ -56,6 +58,7 @@ typedef struct { char aliceAddress[65]; char aliceSecret[70]; char bobHash[65]; + uint8_t decimals; } BobSpendsAlicePaymentInput; typedef struct { @@ -72,6 +75,7 @@ typedef struct { char aliceAddress[65]; char bobHash[65]; uint64_t lockTime; + uint8_t decimals; } BobSendsErc20DepositInput; typedef struct { @@ -80,6 +84,7 @@ typedef struct { char tokenAddress[65]; char aliceAddress[65]; char bobSecret[70]; + uint8_t decimals; } BobRefundsDepositInput; typedef struct { @@ -88,6 +93,7 @@ typedef struct { char tokenAddress[65]; char bobAddress[65]; char bobHash[65]; + uint8_t decimals; } AliceClaimsBobDepositInput; typedef struct { @@ -104,6 +110,7 @@ typedef struct { char aliceAddress[65]; char aliceHash[65]; uint64_t lockTime; + uint8_t decimals; } BobSendsErc20PaymentInput; typedef struct { @@ -112,6 +119,7 @@ typedef struct { char tokenAddress[65]; char aliceAddress[65]; char aliceHash[65]; + uint8_t decimals; } BobReclaimsBobPaymentInput; typedef struct { @@ -120,6 +128,7 @@ typedef struct { char tokenAddress[65]; char aliceSecret[70]; char bobAddress[65]; + uint8_t decimals; } AliceSpendsBobPaymentInput; typedef struct { @@ -165,22 +174,32 @@ char* getPubKeyFromPriv(char* privKey); // returns satoshis, not wei! uint64_t getEthBalance(char* address); -uint64_t getErc20BalanceSatoshi(char* address, char tokenAddress[65]); +uint64_t getErc20BalanceSatoshi(char *address, char *tokenAddress, uint8_t setDecimals); char *getErc20BalanceHexWei(char* address, char tokenAddress[65]); uint8_t getErc20Decimals(char *tokenAddress); // returns satoshis, not wei! -uint64_t getErc20Allowance(char *owner, char *spender, char *tokenAddress); +uint64_t getErc20Allowance(char *owner, char *spender, char *tokenAddress, uint8_t set_decimals); void uint8arrayToHex(char *dest, uint8_t *input, int len); void satoshisToWei(char *dest, uint64_t input); uint64_t weiToSatoshi(char *wei); char *sendEth(char *to, char *amount, char *privKey, uint8_t waitConfirm, int64_t gas, int64_t gasPrice, uint8_t defaultGasOnErr); -char *sendErc20(char *tokenAddress, char *to, char *amount, char *privKey, uint8_t waitConfirm, int64_t gas, int64_t gasPrice, uint8_t defaultGasOnErr); - -uint8_t verifyAliceErc20FeeData(char* tokenAddress, char *to, char *amount, char *data); +char *sendErc20( + char *tokenAddress, + char *to, + char *amount, + char *privKey, + uint8_t waitConfirm, + int64_t gas, + int64_t gasPrice, + uint8_t defaultGasOnErr, + uint8_t decimals +); + +uint8_t verifyAliceErc20FeeData(char* tokenAddress, char *to, char *amount, char *data, uint8_t decimals); // Your prototype or Definition #ifdef __cplusplus } From 2eeb227a1bcf0dc35c969219ab37b56789e35bc7 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Tue, 29 May 2018 14:30:04 +0700 Subject: [PATCH 079/139] Fix decimals value handling for ERC20 tokens. --- Jenkinsfile | 18 ++++++++++++++---- etomic_build/client/buy_BEER_ETH | 4 ---- etomic_build/client/buy_BEER_OTHER | 4 ++++ etomic_build/client/enable | 3 ++- etomic_build/coins | 2 +- etomic_build/seed/enable | 3 ++- etomic_build/seed/sell_BEER_ETH | 4 ---- etomic_build/seed/sell_BEER_OTHER | 4 ++++ iguana/exchanges/LP_coins.c | 9 +++++---- iguana/exchanges/LP_etomic.c | 14 +++++++------- ...R_ETH_trade.sh => start_BEER_OTHER_trade.sh | 4 ++-- start_BEER_OTHER_trade_inverted.sh | 12 ++++++++++++ 12 files changed, 53 insertions(+), 28 deletions(-) delete mode 100755 etomic_build/client/buy_BEER_ETH create mode 100755 etomic_build/client/buy_BEER_OTHER delete mode 100755 etomic_build/seed/sell_BEER_ETH create mode 100755 etomic_build/seed/sell_BEER_OTHER rename start_BEER_ETH_trade.sh => start_BEER_OTHER_trade.sh (68%) create mode 100755 start_BEER_OTHER_trade_inverted.sh diff --git a/Jenkinsfile b/Jenkinsfile index 9bc1ac407..5fca2513d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,13 +17,23 @@ cmake .. cmake --build . --target marketmaker-testnet''' } } - stage('Trade') { + stage('Trade BEER/ETH') { steps { sh '''docker-compose build docker-compose up -d -./start_BEER_ETH_trade.sh -COMPOSE_HTTP_TIMEOUT=601 timeout 600 grep -q "SWAP completed" <(docker-compose logs -f clientnode) -COMPOSE_HTTP_TIMEOUT=601 timeout 600 grep -q "SWAP completed" <(docker-compose logs -f seednode) +./start_BEER_OTHER_trade.sh ETH +timeout 600 grep -q "SWAP completed" <(docker-compose logs -f clientnode) +timeout 600 grep -q "SWAP completed" <(docker-compose logs -f seednode) +docker-compose down''' + } + } + stage('Trade ETH/BEER') { + steps { + sh '''docker-compose build +docker-compose up -d +./start_BEER_OTHER_trade_inverted.sh ETH +timeout 600 grep -q "SWAP completed" <(docker-compose logs -f clientnode) +timeout 600 grep -q "SWAP completed" <(docker-compose logs -f seednode) docker-compose down''' } } diff --git a/etomic_build/client/buy_BEER_ETH b/etomic_build/client/buy_BEER_ETH deleted file mode 100755 index 3fd43cf77..000000000 --- a/etomic_build/client/buy_BEER_ETH +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -source userpass -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"setprice\",\"base\":\"ETH\",\"rel\":\"BEER\",\"price\":1}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"sell\",\"base\":\"ETH\",\"rel\":\"BEER\",\"basevolume\":0.1,\"price\":1}" \ No newline at end of file diff --git a/etomic_build/client/buy_BEER_OTHER b/etomic_build/client/buy_BEER_OTHER new file mode 100755 index 000000000..be2acb4da --- /dev/null +++ b/etomic_build/client/buy_BEER_OTHER @@ -0,0 +1,4 @@ +#!/bin/bash +source userpass +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"setprice\",\"base\":\"$1\",\"rel\":\"BEER\",\"price\":1}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"sell\",\"base\":\"$1\",\"rel\":\"BEER\",\"basevolume\":0.1,\"price\":1}" \ No newline at end of file diff --git a/etomic_build/client/enable b/etomic_build/client/enable index 0ae602f7a..0bda2f3ce 100755 --- a/etomic_build/client/enable +++ b/etomic_build/client/enable @@ -2,5 +2,6 @@ source userpass curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"ETOMIC\"}" curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"ETH\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"KMD\"}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"NODEC\"}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"JST\"}" curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"BEER\"}" diff --git a/etomic_build/coins b/etomic_build/coins index 988240877..db9100c13 100755 --- a/etomic_build/coins +++ b/etomic_build/coins @@ -1,3 +1,3 @@ -export coins="[{\"coin\":\"OOT\",\"asset\":\"OOT\",\"rpcport\":12467}, {\"coin\":\"ETH\",\"name\":\"ethereum\",\"etomic\":\"0x0000000000000000000000000000000000000000\",\"rpcport\":80}, {\"coin\":\"EOS\",\"name\":\"EOS\",\"etomic\":\"0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0\",\"rpcport\":80},{\"coin\":\"JST\", \"name\":\"JST\",\"etomic\":\"0xc0eb7aed740e1796992a08962c15661bdeb58003\",\"rpcport\":80,\"decimals\":18}, {\"coin\":\"ZOI\",\"name\":\"zoin\",\"rpcport\":8255,\"pubtype\":80,\"p2shtype\":7,\"wiftype\":208,\"txfee\":1000}, {\"coin\": \"PIZZA\",\"asset\": \"PIZZA\",\"rpcport\": 11116},{\"coin\": \"BEER\",\"asset\": \"BEER\",\"rpcport\": 8923}, {\"coin\":\"GRS\",\"name\":\"groestlcoin\",\"rpcport\":1441,\"pubtype\":36,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"XMCC\",\"name\":\"monoeci\",\"confpath\":\"${HOME#}/.monoeciCore/monoeci.conf\",\"rpcport\":24156,\"pubtype\":50,\"p2shtype\":73,\"wiftype\":77,\"txfee\":10000}, {\"coin\":\"BTCH\",\"asset\":\"BTCH\",\"rpcport\":8800},{\"coin\":\"ETOMIC\",\"asset\":\"ETOMIC\",\"rpcport\":10271},{\"coin\":\"AXO\",\"asset\":\"AXO\",\"rpcport\":12927},{\"coin\":\"CRC\",\"name\":\"crowdcoin\",\"confpath\":\"${HOME#}/.crowdcoincore/crowdcoin.conf\",\"rpcport\":11998,\"pubtype\":28,\"p2shtype\":88,\"wiftype\":0,\"txfee\":10000}, {\"coin\":\"VOT\",\"name\":\"votecoin\",\"rpcport\":8232,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"INN\",\"name\":\"innova\",\"confpath\":\"${HOME#}/.innovacore/innova.conf\",\"rpcport\":8818,\"pubtype\":102,\"p2shtype\":20,\"wiftype\":195,\"txfee\":10000}, {\"coin\":\"MOON\",\"name\":\"mooncoin\",\"rpcport\":44663,\"pubtype\":3,\"p2shtype\":22,\"wiftype\":131,\"txfee\":100000}, {\"coin\":\"CRW\",\"name\":\"crown\",\"rpcport\":9341,\"pubtype\":0,\"p2shtype\":28,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"EFL\",\"name\":\"egulden\",\"confpath\":\"${HOME#}/.egulden/coin.conf\",\"rpcport\":21015,\"pubtype\":48,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"GBX\",\"name\":\"gobyte\",\"confpath\":\"${HOME#}/.gobytecore/gobyte.conf\",\"rpcport\":12454,\"pubtype\":38,\"p2shtype\":10,\"wiftype\":198,\"txfee\":10000}, {\"coin\":\"BCO\",\"name\":\"bridgecoin\",\"rpcport\":6332,\"pubtype\":27,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"BLK\",\"name\":\"blackcoin\",\"confpath\":\"${HOME#}/.lore/blackcoin.conf\",\"isPoS\":1,\"rpcport\":15715,\"pubtype\":25,\"p2shtype\":85,\"wiftype\":153,\"txfee\":100000}, {\"coin\":\"BTG\",\"name\":\"bitcoingold\",\"rpcport\":8332,\"pubtype\":38,\"p2shtype\":23,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"BCH\",\"name\":\"bch\",\"rpcport\":33333,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":1000}, {\"coin\":\"ABY\",\"name\":\"applebyte\",\"rpcport\":8607,\"pubtype\":23,\"p2shtype\":5,\"wiftype\":151,\"txfee\":100000}, {\"coin\":\"STAK\",\"name\":\"straks\",\"rpcport\":7574,\"pubtype\":63,\"p2shtype\":5,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"XZC\",\"name\":\"zcoin\",\"rpcport\":8888,\"pubtype\":82,\"p2shtype\":7,\"wiftype\":210,\"txfee\":10000}, {\"coin\":\"QTUM\",\"name\":\"qtum\",\"rpcport\":3889,\"pubtype\":58,\"p2shtype\":50,\"wiftype\":128,\"txfee\":400000}, {\"coin\":\"PURA\",\"name\":\"pura\",\"rpcport\":55555,\"pubtype\":55,\"p2shtype\":16,\"wiftype\":150,\"txfee\":10000}, {\"coin\":\"DSR\",\"name\":\"desire\",\"confpath\":\"${HOME#}/.desirecore/desire.conf\",\"rpcport\":9918,\"pubtype\":30,\"p2shtype\":16,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"MNZ\",\"asset\":\"MNZ\",\"rpcport\":14337},{\"coin\":\"BTCZ\",\"name\":\"bitcoinz\",\"rpcport\":1979,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"MAGA\",\"name\":\"magacoin\",\"rpcport\":5332,\"pubtype\":23,\"p2shtype\":50,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"BSD\",\"name\":\"bitsend\",\"rpcport\":8800,\"pubtype\":102,\"p2shtype\":5,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"IOP\",\"name\":\"IoP\",\"rpcport\":8337,\"pubtype\":117,\"p2shtype\":174,\"wiftype\":49,\"txfee\":10000}, {\"coin\":\"BLOCK\",\"name\":\"blocknetdx\",\"rpcport\":41414,\"pubtype\":26,\"p2shtype\":28,\"wiftype\":154,\"txfee\":10000}, {\"coin\":\"CHIPS\", \"name\": \"chips\", \"rpcport\":57776,\"pubtype\":60, \"p2shtype\":85, \"wiftype\":188, \"txfee\":10000}, {\"coin\":\"888\",\"name\":\"octocoin\",\"rpcport\":22888,\"pubtype\":18,\"p2shtype\":5,\"wiftype\":176,\"txfee\":2000000}, {\"coin\":\"ARG\",\"name\":\"argentum\",\"rpcport\":13581,\"pubtype\":23,\"p2shtype\":5,\"wiftype\":151,\"txfee\":50000}, {\"coin\":\"GLT\",\"name\":\"globaltoken\",\"rpcport\":9320,\"pubtype\":38,\"p2shtype\":5,\"wiftype\":166,\"txfee\":10000}, {\"coin\":\"ZER\",\"name\":\"zero\",\"rpcport\":23801,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":1000}, {\"coin\":\"HODLC\",\"name\":\"hodlcoin\",\"rpcport\":11989,\"pubtype\":40,\"p2shtype\":5,\"wiftype\":168,\"txfee\":5000}, {\"coin\":\"UIS\",\"name\":\"unitus\",\"rpcport\":50604,\"pubtype\":68,\"p2shtype\":10,\"wiftype\":132,\"txfee\":2000000}, {\"coin\":\"HUC\",\"name\":\"huntercoin\",\"rpcport\":8399,\"pubtype\":40,\"p2shtype\":13,\"wiftype\":168,\"txfee\":100000}, {\"coin\":\"BDL\",\"name\":\"bitdeal\",\"rpcport\":9332,\"pubtype\":38,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"ARC\",\"name\":\"arcticcoin\",\"confpath\":\"${HOME#}/.arcticcore/arcticcoin.conf\",\"rpcport\":7208,\"pubtype\":23,\"p2shtype\":8,\"wiftype\":176,\"txfee\":10000}, {\"coin\":\"ZCL\",\"name\":\"zclassic\",\"rpcport\":8023,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":1000}, {\"coin\":\"VIA\",\"name\":\"viacoin\",\"rpcport\":5222,\"pubtype\":71,\"p2shtype\":33,\"wiftype\":199,\"txfee\":100000}, {\"coin\":\"ERC\",\"name\":\"europecoin\",\"rpcport\":11989,\"pubtype\":33,\"p2shtype\":5,\"wiftype\":168,\"txfee\":10000},{\"coin\":\"FAIR\",\"name\":\"faircoin\",\"confpath\":\"${HOME#}/.faircoin2/faircoin.conf\",\"rpcport\":40405,\"pubtype\":95,\"p2shtype\":36,\"wiftype\":223,\"txfee\":1000000}, {\"coin\":\"FLO\",\"name\":\"florincoin\",\"rpcport\":7313,\"pubtype\":35,\"p2shtype\":8,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"SXC\",\"name\":\"sexcoin\",\"rpcport\":9561,\"pubtype\":62,\"p2shtype\":5,\"wiftype\":190,\"txfee\":100000}, {\"coin\":\"CREA\",\"name\":\"creativecoin\",\"rpcport\":17711,\"pubtype\":28,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"TRC\",\"name\":\"terracoin\",\"confpath\":\"${HOME#}/.terracoincore/terracoin.conf\",\"rpcport\":13332,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"BTA\",\"name\":\"bata\",\"rpcport\":5493,\"pubtype\":25,\"p2shtype\":5,\"wiftype\":188,\"txfee\":100000}, {\"coin\":\"SMC\",\"name\":\"smartcoin\",\"rpcport\":58583,\"pubtype\":63,\"p2shtype\":5,\"wiftype\":191,\"txfee\":1000000}, {\"coin\":\"NMC\",\"name\":\"namecoin\",\"rpcport\":8336,\"pubtype\":52,\"p2shtype\":13,\"wiftype\":180,\"txfee\":100000}, {\"coin\":\"NAV\",\"name\":\"navcoin\",\"isPoS\":1,\"confpath\":\"${HOME#}/.navcoin4/navcoin.conf\",\"rpcport\":44444,\"pubtype\":53,\"p2shtype\":85,\"wiftype\":150,\"txfee\":10000}, {\"coin\":\"EMC2\",\"name\":\"einsteinium\",\"rpcport\":41879,\"pubtype\":33,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000},{\"coin\":\"SYS\",\"name\":\"syscoin\",\"rpcport\":8370,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"I0C\",\"name\":\"i0coin\",\"rpcport\":7332,\"pubtype\":105,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"DASH\",\"confpath\":\"${HOME#}/.dashcore/dash.conf\",\"name\":\"dashcore\",\"rpcport\":9998,\"pubtype\":76,\"p2shtype\":16,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"STRAT\", \"name\": \"stratis\", \"active\":0, \"rpcport\":16174,\"pubtype\":63, \"p2shtype\":125, \"wiftype\":191, \"txfee\":10000}, {\"confpath\":\"${HOME#}/.muecore/mue.conf\",\"coin\":\"MUE\",\"name\":\"muecore\",\"rpcport\":29683,\"pubtype\":16,\"p2shtype\":76,\"wiftype\":126,\"txfee\":10000}, {\"coin\":\"MONA\",\"name\":\"monacoin\",\"rpcport\":9402,\"pubtype\":50,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000},{\"coin\":\"XMY\",\"name\":\"myriadcoin\",\"rpcport\":10889,\"pubtype\":50,\"p2shtype\":9,\"wiftype\":178,\"txfee\":5000}, {\"coin\":\"MAC\",\"name\":\"machinecoin\",\"rpcport\":40332,\"pubtype\":50,\"p2shtype\":5,\"wiftype\":178,\"txfee\":100000}, {\"coin\":\"BTX\",\"name\":\"bitcore\",\"rpcport\":8556,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":50000}, {\"coin\":\"XRE\",\"name\":\"revolvercoin\",\"rpcport\":8775,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"LBC\",\"name\":\"lbrycrd\",\"rpcport\":9245,\"pubtype\":85,\"p2shtype\":122,\"wiftype\":28,\"txfee\":10000}, {\"coin\":\"SIB\",\"name\":\"sibcoin\",\"rpcport\":1944,\"pubtype\":63,\"p2shtype\":40,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"VTC\", \"name\":\"vertcoin\", \"rpcport\":5888, \"pubtype\":71, \"p2shtype\":5, \"wiftype\":128, \"txfee\":100000 }, {\"coin\":\"REVS\",\"active\":0, \"asset\":\"REVS\",\"rpcport\":10196}, {\"coin\":\"JUMBLR\",\"active\":0, \"asset\":\"JUMBLR\",\"rpcport\":15106}, {\"coin\":\"DOGE\",\"name\":\"dogecoin\",\"rpcport\":22555,\"pubtype\":30,\"p2shtype\":22,\"wiftype\":158,\"txfee\":100000000}, {\"coin\":\"HUSH\",\"name\":\"hush\",\"rpcport\":8822,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":1000 }, {\"active\":0,\"coin\":\"ZEC\",\"name\":\"zcash\",\"rpcport\":8232,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":10000 }, {\"coin\":\"DGB\",\"name\":\"digibyte\",\"rpcport\":14022,\"pubtype\":30,\"p2shtype\":5,\"wiftype\":128,\"txfee\":100000}, {\"coin\":\"ZET\", \"name\":\"zetacoin\", \"pubtype\":80, \"p2shtype\":9,\"rpcport\":8332, \"wiftype\":224, \"txfee\":10000}, {\"coin\":\"GAME\", \"rpcport\":40001, \"name\":\"gamecredits\", \"pubtype\":38, \"p2shtype\":5, \"wiftype\":166, \"txfee\":100000}, {\"coin\":\"LTC\", \"name\":\"litecoin\", \"rpcport\":9332, \"pubtype\":48, \"p2shtype\":5, \"wiftype\":176, \"txfee\":100000 }, {\"coin\":\"SUPERNET\",\"asset\":\"SUPERNET\",\"rpcport\":11341}, {\"coin\":\"WLC\",\"asset\":\"WLC\",\"rpcport\":12167}, {\"coin\":\"PANGEA\",\"asset\":\"PANGEA\",\"rpcport\":14068}, {\"coin\":\"DEX\",\"asset\":\"DEX\",\"rpcport\":11890}, {\"coin\":\"BET\",\"asset\":\"BET\",\"rpcport\":14250}, {\"coin\":\"CRYPTO\",\"asset\":\"CRYPTO\",\"rpcport\":8516}, {\"coin\":\"HODL\",\"asset\":\"HODL\",\"rpcport\":14431}, {\"coin\":\"MSHARK\",\"asset\":\"MSHARK\",\"rpcport\":8846}, {\"coin\":\"BOTS\",\"asset\":\"BOTS\",\"rpcport\":11964}, {\"coin\":\"MGW\",\"asset\":\"MGW\",\"rpcport\":12386}, {\"coin\":\"COQUI\",\"asset\":\"COQUI\",\"rpcport\":14276}, {\"coin\":\"KV\",\"asset\":\"KV\",\"rpcport\":8299}, {\"coin\":\"CEAL\",\"asset\":\"CEAL\",\"rpcport\":11116}, {\"coin\":\"MESH\",\"asset\":\"MESH\",\"rpcport\":9455}]" +export coins="[{\"coin\":\"OOT\",\"asset\":\"OOT\",\"rpcport\":12467}, {\"coin\":\"ETH\",\"name\":\"ethereum\",\"etomic\":\"0x0000000000000000000000000000000000000000\",\"rpcport\":80}, {\"coin\":\"EOS\",\"name\":\"EOS\",\"etomic\":\"0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0\",\"rpcport\":80},{\"coin\":\"JST\", \"name\":\"JST\",\"etomic\":\"0xc0eb7aed740e1796992a08962c15661bdeb58003\",\"rpcport\":80},{\"coin\":\"NODEC\",\"name\":\"NODEC\",\"etomic\":\"0x05beb0a9ead354283041a6d35f3b833450fb5680\",\"rpcport\":80,\"decimals\":18},{\"coin\":\"ZOI\",\"name\":\"zoin\",\"rpcport\":8255,\"pubtype\":80,\"p2shtype\":7,\"wiftype\":208,\"txfee\":1000}, {\"coin\": \"PIZZA\",\"asset\": \"PIZZA\",\"rpcport\": 11116},{\"coin\": \"BEER\",\"asset\": \"BEER\",\"rpcport\": 8923}, {\"coin\":\"GRS\",\"name\":\"groestlcoin\",\"rpcport\":1441,\"pubtype\":36,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"XMCC\",\"name\":\"monoeci\",\"confpath\":\"${HOME#}/.monoeciCore/monoeci.conf\",\"rpcport\":24156,\"pubtype\":50,\"p2shtype\":73,\"wiftype\":77,\"txfee\":10000}, {\"coin\":\"BTCH\",\"asset\":\"BTCH\",\"rpcport\":8800},{\"coin\":\"ETOMIC\",\"asset\":\"ETOMIC\",\"rpcport\":10271},{\"coin\":\"AXO\",\"asset\":\"AXO\",\"rpcport\":12927},{\"coin\":\"CRC\",\"name\":\"crowdcoin\",\"confpath\":\"${HOME#}/.crowdcoincore/crowdcoin.conf\",\"rpcport\":11998,\"pubtype\":28,\"p2shtype\":88,\"wiftype\":0,\"txfee\":10000}, {\"coin\":\"VOT\",\"name\":\"votecoin\",\"rpcport\":8232,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"INN\",\"name\":\"innova\",\"confpath\":\"${HOME#}/.innovacore/innova.conf\",\"rpcport\":8818,\"pubtype\":102,\"p2shtype\":20,\"wiftype\":195,\"txfee\":10000}, {\"coin\":\"MOON\",\"name\":\"mooncoin\",\"rpcport\":44663,\"pubtype\":3,\"p2shtype\":22,\"wiftype\":131,\"txfee\":100000}, {\"coin\":\"CRW\",\"name\":\"crown\",\"rpcport\":9341,\"pubtype\":0,\"p2shtype\":28,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"EFL\",\"name\":\"egulden\",\"confpath\":\"${HOME#}/.egulden/coin.conf\",\"rpcport\":21015,\"pubtype\":48,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"GBX\",\"name\":\"gobyte\",\"confpath\":\"${HOME#}/.gobytecore/gobyte.conf\",\"rpcport\":12454,\"pubtype\":38,\"p2shtype\":10,\"wiftype\":198,\"txfee\":10000}, {\"coin\":\"BCO\",\"name\":\"bridgecoin\",\"rpcport\":6332,\"pubtype\":27,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"BLK\",\"name\":\"blackcoin\",\"confpath\":\"${HOME#}/.lore/blackcoin.conf\",\"isPoS\":1,\"rpcport\":15715,\"pubtype\":25,\"p2shtype\":85,\"wiftype\":153,\"txfee\":100000}, {\"coin\":\"BTG\",\"name\":\"bitcoingold\",\"rpcport\":8332,\"pubtype\":38,\"p2shtype\":23,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"BCH\",\"name\":\"bch\",\"rpcport\":33333,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":1000}, {\"coin\":\"ABY\",\"name\":\"applebyte\",\"rpcport\":8607,\"pubtype\":23,\"p2shtype\":5,\"wiftype\":151,\"txfee\":100000}, {\"coin\":\"STAK\",\"name\":\"straks\",\"rpcport\":7574,\"pubtype\":63,\"p2shtype\":5,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"XZC\",\"name\":\"zcoin\",\"rpcport\":8888,\"pubtype\":82,\"p2shtype\":7,\"wiftype\":210,\"txfee\":10000}, {\"coin\":\"QTUM\",\"name\":\"qtum\",\"rpcport\":3889,\"pubtype\":58,\"p2shtype\":50,\"wiftype\":128,\"txfee\":400000}, {\"coin\":\"PURA\",\"name\":\"pura\",\"rpcport\":55555,\"pubtype\":55,\"p2shtype\":16,\"wiftype\":150,\"txfee\":10000}, {\"coin\":\"DSR\",\"name\":\"desire\",\"confpath\":\"${HOME#}/.desirecore/desire.conf\",\"rpcport\":9918,\"pubtype\":30,\"p2shtype\":16,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"MNZ\",\"asset\":\"MNZ\",\"rpcport\":14337},{\"coin\":\"BTCZ\",\"name\":\"bitcoinz\",\"rpcport\":1979,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"MAGA\",\"name\":\"magacoin\",\"rpcport\":5332,\"pubtype\":23,\"p2shtype\":50,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"BSD\",\"name\":\"bitsend\",\"rpcport\":8800,\"pubtype\":102,\"p2shtype\":5,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"IOP\",\"name\":\"IoP\",\"rpcport\":8337,\"pubtype\":117,\"p2shtype\":174,\"wiftype\":49,\"txfee\":10000}, {\"coin\":\"BLOCK\",\"name\":\"blocknetdx\",\"rpcport\":41414,\"pubtype\":26,\"p2shtype\":28,\"wiftype\":154,\"txfee\":10000}, {\"coin\":\"CHIPS\", \"name\": \"chips\", \"rpcport\":57776,\"pubtype\":60, \"p2shtype\":85, \"wiftype\":188, \"txfee\":10000}, {\"coin\":\"888\",\"name\":\"octocoin\",\"rpcport\":22888,\"pubtype\":18,\"p2shtype\":5,\"wiftype\":176,\"txfee\":2000000}, {\"coin\":\"ARG\",\"name\":\"argentum\",\"rpcport\":13581,\"pubtype\":23,\"p2shtype\":5,\"wiftype\":151,\"txfee\":50000}, {\"coin\":\"GLT\",\"name\":\"globaltoken\",\"rpcport\":9320,\"pubtype\":38,\"p2shtype\":5,\"wiftype\":166,\"txfee\":10000}, {\"coin\":\"ZER\",\"name\":\"zero\",\"rpcport\":23801,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":1000}, {\"coin\":\"HODLC\",\"name\":\"hodlcoin\",\"rpcport\":11989,\"pubtype\":40,\"p2shtype\":5,\"wiftype\":168,\"txfee\":5000}, {\"coin\":\"UIS\",\"name\":\"unitus\",\"rpcport\":50604,\"pubtype\":68,\"p2shtype\":10,\"wiftype\":132,\"txfee\":2000000}, {\"coin\":\"HUC\",\"name\":\"huntercoin\",\"rpcport\":8399,\"pubtype\":40,\"p2shtype\":13,\"wiftype\":168,\"txfee\":100000}, {\"coin\":\"BDL\",\"name\":\"bitdeal\",\"rpcport\":9332,\"pubtype\":38,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"ARC\",\"name\":\"arcticcoin\",\"confpath\":\"${HOME#}/.arcticcore/arcticcoin.conf\",\"rpcport\":7208,\"pubtype\":23,\"p2shtype\":8,\"wiftype\":176,\"txfee\":10000}, {\"coin\":\"ZCL\",\"name\":\"zclassic\",\"rpcport\":8023,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":1000}, {\"coin\":\"VIA\",\"name\":\"viacoin\",\"rpcport\":5222,\"pubtype\":71,\"p2shtype\":33,\"wiftype\":199,\"txfee\":100000}, {\"coin\":\"ERC\",\"name\":\"europecoin\",\"rpcport\":11989,\"pubtype\":33,\"p2shtype\":5,\"wiftype\":168,\"txfee\":10000},{\"coin\":\"FAIR\",\"name\":\"faircoin\",\"confpath\":\"${HOME#}/.faircoin2/faircoin.conf\",\"rpcport\":40405,\"pubtype\":95,\"p2shtype\":36,\"wiftype\":223,\"txfee\":1000000}, {\"coin\":\"FLO\",\"name\":\"florincoin\",\"rpcport\":7313,\"pubtype\":35,\"p2shtype\":8,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"SXC\",\"name\":\"sexcoin\",\"rpcport\":9561,\"pubtype\":62,\"p2shtype\":5,\"wiftype\":190,\"txfee\":100000}, {\"coin\":\"CREA\",\"name\":\"creativecoin\",\"rpcport\":17711,\"pubtype\":28,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"TRC\",\"name\":\"terracoin\",\"confpath\":\"${HOME#}/.terracoincore/terracoin.conf\",\"rpcport\":13332,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"BTA\",\"name\":\"bata\",\"rpcport\":5493,\"pubtype\":25,\"p2shtype\":5,\"wiftype\":188,\"txfee\":100000}, {\"coin\":\"SMC\",\"name\":\"smartcoin\",\"rpcport\":58583,\"pubtype\":63,\"p2shtype\":5,\"wiftype\":191,\"txfee\":1000000}, {\"coin\":\"NMC\",\"name\":\"namecoin\",\"rpcport\":8336,\"pubtype\":52,\"p2shtype\":13,\"wiftype\":180,\"txfee\":100000}, {\"coin\":\"NAV\",\"name\":\"navcoin\",\"isPoS\":1,\"confpath\":\"${HOME#}/.navcoin4/navcoin.conf\",\"rpcport\":44444,\"pubtype\":53,\"p2shtype\":85,\"wiftype\":150,\"txfee\":10000}, {\"coin\":\"EMC2\",\"name\":\"einsteinium\",\"rpcport\":41879,\"pubtype\":33,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000},{\"coin\":\"SYS\",\"name\":\"syscoin\",\"rpcport\":8370,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"I0C\",\"name\":\"i0coin\",\"rpcport\":7332,\"pubtype\":105,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"DASH\",\"confpath\":\"${HOME#}/.dashcore/dash.conf\",\"name\":\"dashcore\",\"rpcport\":9998,\"pubtype\":76,\"p2shtype\":16,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"STRAT\", \"name\": \"stratis\", \"active\":0, \"rpcport\":16174,\"pubtype\":63, \"p2shtype\":125, \"wiftype\":191, \"txfee\":10000}, {\"confpath\":\"${HOME#}/.muecore/mue.conf\",\"coin\":\"MUE\",\"name\":\"muecore\",\"rpcport\":29683,\"pubtype\":16,\"p2shtype\":76,\"wiftype\":126,\"txfee\":10000}, {\"coin\":\"MONA\",\"name\":\"monacoin\",\"rpcport\":9402,\"pubtype\":50,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000},{\"coin\":\"XMY\",\"name\":\"myriadcoin\",\"rpcport\":10889,\"pubtype\":50,\"p2shtype\":9,\"wiftype\":178,\"txfee\":5000}, {\"coin\":\"MAC\",\"name\":\"machinecoin\",\"rpcport\":40332,\"pubtype\":50,\"p2shtype\":5,\"wiftype\":178,\"txfee\":100000}, {\"coin\":\"BTX\",\"name\":\"bitcore\",\"rpcport\":8556,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":50000}, {\"coin\":\"XRE\",\"name\":\"revolvercoin\",\"rpcport\":8775,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"LBC\",\"name\":\"lbrycrd\",\"rpcport\":9245,\"pubtype\":85,\"p2shtype\":122,\"wiftype\":28,\"txfee\":10000}, {\"coin\":\"SIB\",\"name\":\"sibcoin\",\"rpcport\":1944,\"pubtype\":63,\"p2shtype\":40,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"VTC\", \"name\":\"vertcoin\", \"rpcport\":5888, \"pubtype\":71, \"p2shtype\":5, \"wiftype\":128, \"txfee\":100000 }, {\"coin\":\"REVS\",\"active\":0, \"asset\":\"REVS\",\"rpcport\":10196}, {\"coin\":\"JUMBLR\",\"active\":0, \"asset\":\"JUMBLR\",\"rpcport\":15106}, {\"coin\":\"DOGE\",\"name\":\"dogecoin\",\"rpcport\":22555,\"pubtype\":30,\"p2shtype\":22,\"wiftype\":158,\"txfee\":100000000}, {\"coin\":\"HUSH\",\"name\":\"hush\",\"rpcport\":8822,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":1000 }, {\"active\":0,\"coin\":\"ZEC\",\"name\":\"zcash\",\"rpcport\":8232,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":10000 }, {\"coin\":\"DGB\",\"name\":\"digibyte\",\"rpcport\":14022,\"pubtype\":30,\"p2shtype\":5,\"wiftype\":128,\"txfee\":100000}, {\"coin\":\"ZET\", \"name\":\"zetacoin\", \"pubtype\":80, \"p2shtype\":9,\"rpcport\":8332, \"wiftype\":224, \"txfee\":10000}, {\"coin\":\"GAME\", \"rpcport\":40001, \"name\":\"gamecredits\", \"pubtype\":38, \"p2shtype\":5, \"wiftype\":166, \"txfee\":100000}, {\"coin\":\"LTC\", \"name\":\"litecoin\", \"rpcport\":9332, \"pubtype\":48, \"p2shtype\":5, \"wiftype\":176, \"txfee\":100000 }, {\"coin\":\"SUPERNET\",\"asset\":\"SUPERNET\",\"rpcport\":11341}, {\"coin\":\"WLC\",\"asset\":\"WLC\",\"rpcport\":12167}, {\"coin\":\"PANGEA\",\"asset\":\"PANGEA\",\"rpcport\":14068}, {\"coin\":\"DEX\",\"asset\":\"DEX\",\"rpcport\":11890}, {\"coin\":\"BET\",\"asset\":\"BET\",\"rpcport\":14250}, {\"coin\":\"CRYPTO\",\"asset\":\"CRYPTO\",\"rpcport\":8516}, {\"coin\":\"HODL\",\"asset\":\"HODL\",\"rpcport\":14431}, {\"coin\":\"MSHARK\",\"asset\":\"MSHARK\",\"rpcport\":8846}, {\"coin\":\"BOTS\",\"asset\":\"BOTS\",\"rpcport\":11964}, {\"coin\":\"MGW\",\"asset\":\"MGW\",\"rpcport\":12386}, {\"coin\":\"COQUI\",\"asset\":\"COQUI\",\"rpcport\":14276}, {\"coin\":\"KV\",\"asset\":\"KV\",\"rpcport\":8299}, {\"coin\":\"CEAL\",\"asset\":\"CEAL\",\"rpcport\":11116}, {\"coin\":\"MESH\",\"asset\":\"MESH\",\"rpcport\":9455}]" #, {\"coin\":\"AUD\",\"asset\":\"AUD\",\"rpcport\":8045}, {\"coin\":\"BGN\",\"asset\":\"BGN\",\"rpcport\":9110}, {\"coin\":\"CAD\",\"asset\":\"CAD\",\"rpcport\":8720}, {\"coin\":\"CHF\",\"asset\":\"CHF\",\"rpcport\":15312}, {\"coin\":\"CNY\",\"asset\":\"CNY\",\"rpcport\":10384}, {\"coin\":\"CZK\",\"asset\":\"CZK\",\"rpcport\":9482}, {\"coin\":\"DKK\",\"asset\":\"DKK\",\"rpcport\":13830}, {\"coin\":\"EUR\",\"asset\":\"EUR\",\"rpcport\":8065}, {\"coin\":\"GBP\",\"asset\":\"GBP\",\"rpcport\":11505}, {\"coin\":\"HKD\",\"asset\":\"HKD\",\"rpcport\":15409}, {\"coin\":\"HRK\",\"asset\":\"HRK\",\"rpcport\":12617}, {\"coin\":\"HUF\",\"asset\":\"HUF\",\"rpcport\":13699}, {\"coin\":\"IDR\",\"asset\":\"IDR\",\"rpcport\":14459}, {\"coin\":\"ILS\",\"asset\":\"ILS\",\"rpcport\":14638}, {\"coin\":\"INR\",\"asset\":\"INR\",\"rpcport\":10536}, {\"coin\":\"JPY\",\"asset\":\"JPY\",\"rpcport\":13145}, {\"coin\":\"KRW\",\"asset\":\"KRW\",\"rpcport\":14020}, {\"coin\":\"MXN\",\"asset\":\"MXN\",\"rpcport\":13970}, {\"coin\":\"MYR\",\"asset\":\"MYR\",\"rpcport\":10688}, {\"coin\":\"NOK\",\"asset\":\"NOK\",\"rpcport\":11588}, {\"coin\":\"NZD\",\"asset\":\"NZD\",\"rpcport\":10915}, {\"coin\":\"PHP\",\"asset\":\"PHP\",\"rpcport\":11181}, {\"coin\":\"PLN\",\"asset\":\"PLN\",\"rpcport\":13493}, {\"coin\":\"BRL\",\"asset\":\"BRL\",\"rpcport\":9914}, {\"coin\":\"RON\",\"asset\":\"RON\",\"rpcport\":8675}, {\"coin\":\"RUB\",\"asset\":\"RUB\",\"rpcport\":8199}, {\"coin\":\"SEK\",\"asset\":\"SEK\",\"rpcport\":11447}, {\"coin\":\"SGD\",\"asset\":\"SGD\",\"rpcport\":14475}, {\"coin\":\"THB\",\"asset\":\"THB\",\"rpcport\":11847}, {\"coin\":\"TRY\",\"asset\":\"TRY\",\"rpcport\":13924}, {\"coin\":\"USD\",\"asset\":\"USD\",\"rpcport\":13967}, {\"coin\":\"ZAR\",\"asset\":\"ZAR\",\"rpcport\":15160}]" #{\"coin\":\"PIVX\",\"name\":\"pivx\",\"rpcport\":51473,\"pubtype\":30,\"p2shtype\":13,\"wiftype\":212,\"txfee\":10000}, diff --git a/etomic_build/seed/enable b/etomic_build/seed/enable index 79350a008..0bda2f3ce 100755 --- a/etomic_build/seed/enable +++ b/etomic_build/seed/enable @@ -1,6 +1,7 @@ #!/bin/bash source userpass -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"KMD\"}" curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"ETOMIC\"}" curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"ETH\"}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"NODEC\"}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"JST\"}" curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"BEER\"}" diff --git a/etomic_build/seed/sell_BEER_ETH b/etomic_build/seed/sell_BEER_ETH deleted file mode 100755 index 90b0e6073..000000000 --- a/etomic_build/seed/sell_BEER_ETH +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -source userpass -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"setprice\",\"base\":\"BEER\",\"rel\":\"ETH\",\"price\":0.9}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"sell\",\"base\":\"BEER\",\"rel\":\"ETH\",\"basevolume\":0.1,\"price\":0.9}" \ No newline at end of file diff --git a/etomic_build/seed/sell_BEER_OTHER b/etomic_build/seed/sell_BEER_OTHER new file mode 100755 index 000000000..cd11fc044 --- /dev/null +++ b/etomic_build/seed/sell_BEER_OTHER @@ -0,0 +1,4 @@ +#!/bin/bash +source userpass +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"setprice\",\"base\":\"BEER\",\"rel\":\"$1\",\"price\":0.9}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"sell\",\"base\":\"BEER\",\"rel\":\"$1\",\"basevolume\":0.1,\"price\":0.9}" \ No newline at end of file diff --git a/iguana/exchanges/LP_coins.c b/iguana/exchanges/LP_coins.c index 6344cf278..79a0da9b4 100644 --- a/iguana/exchanges/LP_coins.c +++ b/iguana/exchanges/LP_coins.c @@ -373,7 +373,7 @@ struct iguana_info *LP_coinadd(struct iguana_info *cdata) return(coin); } -uint16_t LP_coininit(struct iguana_info *coin,char *symbol,char *name,char *assetname,int32_t isPoS,uint16_t port,uint8_t pubtype,uint8_t p2shtype,uint8_t wiftype,uint64_t txfee,double estimatedrate,int32_t longestchain,uint8_t wiftaddr,uint8_t taddr,uint16_t busport,char *confpath) +uint16_t LP_coininit(struct iguana_info *coin,char *symbol,char *name,char *assetname,int32_t isPoS,uint16_t port,uint8_t pubtype,uint8_t p2shtype,uint8_t wiftype,uint64_t txfee,double estimatedrate,int32_t longestchain,uint8_t wiftaddr,uint8_t taddr,uint16_t busport,char *confpath,uint8_t decimals) { static void *ctx; char *name2; uint16_t origport = port; @@ -429,6 +429,7 @@ uint16_t LP_coininit(struct iguana_info *coin,char *symbol,char *name,char *asse coin->zcash = LP_IS_BITCOINGOLD; printf("set coin.%s <- LP_IS_BITCOINGOLD %d\n",symbol,coin->zcash); } + coin->decimals = decimals; return(port); } @@ -472,7 +473,7 @@ struct iguana_info *LP_coinfind(char *symbol) else if ( strcmp(symbol,"KMD") == 0 ) name = "komodo"; else return(0); - port = LP_coininit(&cdata,symbol,name,assetname,isPoS,port,pubtype,p2shtype,wiftype,txfee,estimatedrate,longestchain,0,0,busport,0); + port = LP_coininit(&cdata,symbol,name,assetname,isPoS,port,pubtype,p2shtype,wiftype,txfee,estimatedrate,longestchain,0,0,busport,0,0); if ( port == 0 ) isinactive = 1; else isinactive = 0; @@ -516,8 +517,8 @@ struct iguana_info *LP_coincreate(cJSON *item) else if ( (name= jstr(item,"name")) == 0 ) name = symbol; - cdata.decimals = juint(item,"decimals"); - if ( LP_coininit(&cdata,symbol,name,assetname==0?"":assetname,isPoS,port,pubtype,p2shtype,wiftype,txfee,estimatedrate,longestchain,juint(item,"wiftaddr"),juint(item,"taddr"),LP_busport(port),jstr(item,"confpath")) < 0 ) + uint8_t decimals = juint(item,"decimals"); + if ( LP_coininit(&cdata,symbol,name,assetname==0?"":assetname,isPoS,port,pubtype,p2shtype,wiftype,txfee,estimatedrate,longestchain,juint(item,"wiftaddr"),juint(item,"taddr"),LP_busport(port),jstr(item,"confpath"),decimals) < 0 ) { coin = LP_coinadd(&cdata); coin->inactive = (uint32_t)time(NULL); diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index 6ffceacaa..b211b4c9f 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -211,9 +211,10 @@ char *LP_etomicalice_reclaims_payment(struct LP_swap_remember *swap) memset(&txData,0,sizeof(txData)); memset(&input,0,sizeof(input)); - struct iguana_info *ecoin; + struct iguana_info *ecoin, *alice_coin; bits256 privkey; ecoin = LP_coinfind("ETOMIC"); + alice_coin = LP_coinfind(swap->dest); privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr); uint8arrayToHex(input.dealId, swap->txids[BASILISK_ALICEPAYMENT].bytes, 32); @@ -233,7 +234,6 @@ char *LP_etomicalice_reclaims_payment(struct LP_swap_remember *swap) } uint8arrayToHex(input.bobSecret, invertedSecret.bytes, 32); - struct iguana_info *alice_coin = LP_coinfind(swap->alicecoin); input.decimals = alice_coin->decimals; strcpy(txData.from, swap->etomicdest); @@ -281,7 +281,7 @@ char *LP_etomicbob_spends_alice_payment(struct LP_swap_remember *swap) } uint8arrayToHex(input.aliceSecret, invertedSecret.bytes, 32); uint8arrayToHex(input.bobHash, swap->secretBn, 20); - struct iguana_info *alice_coin = LP_coinfind(swap->alicecoin); + struct iguana_info *alice_coin = LP_coinfind(swap->dest); input.decimals = alice_coin->decimals; strcpy(txData.from, swap->etomicsrc); @@ -408,7 +408,7 @@ char *LP_etomicbob_refunds_deposit(struct LP_swap_remember *swap) struct iguana_info *ecoin, *bobcoin; bits256 privkey; ecoin = LP_coinfind("ETOMIC"); - bobcoin = LP_coinfind(swap->bobcoin); + bobcoin = LP_coinfind(swap->src); privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr); EthTxReceipt receipt = getEthTxReceipt(swap->bobDepositEthTx); @@ -558,7 +558,7 @@ char *LP_etomicbob_reclaims_payment(struct LP_swap_remember *swap) struct iguana_info *ecoin, *bobcoin; bits256 privkey; ecoin = LP_coinfind("ETOMIC"); - bobcoin = LP_coinfind(swap->bobcoin); + bobcoin = LP_coinfind(swap->src); privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr); EthTxReceipt receipt = getEthTxReceipt(swap->bobPaymentEthTx); @@ -604,7 +604,7 @@ char *LP_etomicalice_spends_bob_payment(struct LP_swap_remember *swap) struct iguana_info *ecoin, *bobcoin; bits256 privkey; ecoin = LP_coinfind("ETOMIC"); - bobcoin = LP_coinfind(swap->bobcoin); + bobcoin = LP_coinfind(swap->src); privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr); uint8arrayToHex(input.paymentId, swap->txids[BASILISK_BOBPAYMENT].bytes, 32); @@ -652,7 +652,7 @@ char *LP_etomicalice_claims_bob_deposit(struct LP_swap_remember *swap) struct iguana_info *ecoin, *bobcoin; bits256 privkey; ecoin = LP_coinfind("ETOMIC"); - bobcoin = LP_coinfind(swap->bobcoin); + bobcoin = LP_coinfind(swap->src); privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr); uint8arrayToHex(input.depositId, swap->txids[BASILISK_BOBDEPOSIT].bytes, 32); diff --git a/start_BEER_ETH_trade.sh b/start_BEER_OTHER_trade.sh similarity index 68% rename from start_BEER_ETH_trade.sh rename to start_BEER_OTHER_trade.sh index e192baea4..23a5acee1 100755 --- a/start_BEER_ETH_trade.sh +++ b/start_BEER_OTHER_trade.sh @@ -7,6 +7,6 @@ docker-compose exec -T seednode ./setpassphrase sleep 5 docker-compose exec -T seednode ./enable sleep 5 -docker-compose exec -T seednode ./sell_BEER_ETH +docker-compose exec -T seednode ./sell_BEER_OTHER $1 sleep 5 -docker-compose exec -T clientnode ./buy_BEER_ETH \ No newline at end of file +docker-compose exec -T clientnode ./buy_BEER_OTHER $1 \ No newline at end of file diff --git a/start_BEER_OTHER_trade_inverted.sh b/start_BEER_OTHER_trade_inverted.sh new file mode 100755 index 000000000..68ef9ab3f --- /dev/null +++ b/start_BEER_OTHER_trade_inverted.sh @@ -0,0 +1,12 @@ +#!/bin/bash +docker-compose exec -T clientnode ./setpassphrase +sleep 5 +docker-compose exec -T clientnode ./enable +sleep 5 +docker-compose exec -T seednode ./setpassphrase +sleep 5 +docker-compose exec -T seednode ./enable +sleep 5 +docker-compose exec -T clientnode ./buy_BEER_OTHER $1 +sleep 5 +docker-compose exec -T seednode ./sell_BEER_OTHER $1 \ No newline at end of file From 5a5a620fbdb79f40bda7d91fd39f72aee2685bb2 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Tue, 29 May 2018 19:04:24 +0700 Subject: [PATCH 080/139] Put back ETH/ERC20 calls to portfolio. Without cache for now. --- iguana/exchanges/LP_coins.c | 9 ++++++--- iguana/exchanges/LP_portfolio.c | 4 +--- iguana/exchanges/etomicswap/etomiccurl.c | 3 +-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/iguana/exchanges/LP_coins.c b/iguana/exchanges/LP_coins.c index 79a0da9b4..b1f2a995d 100644 --- a/iguana/exchanges/LP_coins.c +++ b/iguana/exchanges/LP_coins.c @@ -251,10 +251,13 @@ cJSON *LP_coinjson(struct iguana_info *coin,int32_t showwif) } #ifndef NOTETOMIC else if (coin->etomic[0] != 0) { - //balance = LP_etomic_get_balance(coin, coin->smartaddr); + if (coin->inactive == 0) { + balance = LP_etomic_get_balance(coin, coin->smartaddr); + } else { + balance = 0; + } jaddnum(item,"height",-1); - //jaddnum(item,"balance",dstr(balance)); - jaddnum(item,"balance",0); + jaddnum(item,"balance",dstr(balance)); } #endif else diff --git a/iguana/exchanges/LP_portfolio.c b/iguana/exchanges/LP_portfolio.c index 29d54d1ee..b38a08c89 100644 --- a/iguana/exchanges/LP_portfolio.c +++ b/iguana/exchanges/LP_portfolio.c @@ -95,14 +95,12 @@ uint64_t LP_balance(uint64_t *valuep,int32_t iambob,char *symbol,char *coinaddr) cJSON *array,*item; bits256 zero; int32_t i,n; uint64_t valuesum,satoshisum,value; valuesum = satoshisum = 0; memset(zero.bytes,0,sizeof(zero)); -/* #ifndef NOTETOMIC struct iguana_info *coin = LP_coinfind(symbol); - if (coin->etomic[0] != 0) { + if (coin->etomic[0] != 0 && coin->inactive == 0) { valuesum = LP_etomic_get_balance(coin, coinaddr); } else #endif -*/ if ( (array= LP_listunspent(symbol,coinaddr,zero,zero)) != 0 ) { if ( is_cJSON_Array(array) != 0 && (n= cJSON_GetArraySize(array)) > 0 ) diff --git a/iguana/exchanges/etomicswap/etomiccurl.c b/iguana/exchanges/etomicswap/etomiccurl.c index e4bf3f532..1db357b7f 100644 --- a/iguana/exchanges/etomicswap/etomiccurl.c +++ b/iguana/exchanges/etomicswap/etomiccurl.c @@ -35,10 +35,9 @@ size_t writefunc(void *ptr, size_t size, size_t nmemb, struct string *s) cJSON *parseEthRpcResponse(char *requestResult) { - printf("Trying to parse ETH RPC response: %s\n", requestResult); cJSON *json = cJSON_Parse(requestResult); if (json == NULL) { - printf("ETH RPC response parse failed!\n"); + printf("ETH RPC response parse failed: %s!\n", requestResult); return NULL; } cJSON *tmp = cJSON_GetObjectItem(json, "result"); From 453fa12d1c1b7c912d291f635b93f35d2f906e5d Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Wed, 30 May 2018 18:53:53 +0700 Subject: [PATCH 081/139] Rework faucet integration, abort ETH/ERC20 swap if ETH balance < 0.005. --- iguana/exchanges/LP_commands.c | 22 +++++++++------------- iguana/exchanges/LP_swap.c | 23 +++++++++++++++++++++-- iguana/exchanges/etomicswap/etomiccurl.c | 5 +---- iguana/exchanges/etomicswap/etomiccurl.h | 2 +- 4 files changed, 32 insertions(+), 20 deletions(-) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index 84b6a0984..7279e13fa 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -581,24 +581,20 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\ return(jprint(retjson,1)); } #ifndef NOT_ETOMIC + if (strcmp(coin, "ETOMIC") == 0) { + char eth_addr[100]; + bits256 privkey = LP_privkey("ETOMIC", ptr->smartaddr, ptr->taddr); + LP_etomic_priv2addr(eth_addr, privkey); + if (get_etomic_from_faucet(eth_addr, ptr->smartaddr) != 1) { + return(clonestr("{\"error\":\"Could not get ETOMIC from faucet!\"}")); + } + } + if (ptr->etomic[0] != 0) { struct iguana_info *etomic_coin = LP_coinsearch("ETOMIC"); if (etomic_coin->inactive != 0) { return(clonestr("{\"error\":\"Enable ETOMIC first to use ETH/ERC20!\"}")); } - - if (ptr->inactive != 0) { - uint64_t balance = LP_etomic_get_balance(ptr, ptr->smartaddr); - uint64_t new_required = G.LP_required_etomic_balance + (balance * 9) / 4; - uint64_t etomic_balance = LP_RTsmartbalance(etomic_coin); - if (etomic_balance < new_required) { - printf("Need additional ETOMIC amount: %" PRIu64 "\n", new_required - etomic_balance); - if (get_etomic_from_faucet(ptr->smartaddr, etomic_coin->smartaddr, ptr->etomic) != 1) { - return(clonestr("{\"error\":\"Could not get ETOMIC from faucet!\"}")); - } - } - G.LP_required_etomic_balance = new_required; - } } #endif if ( LP_conflicts_find(ptr) == 0 ) diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index c28f06495..1a080839d 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -854,7 +854,16 @@ void LP_bobloop(void *_swap) expiration = (uint32_t)time(NULL) + LP_SWAPSTEP_TIMEOUT; bobwaittimeout = LP_calc_waittimeout(bobstr); alicewaittimeout = LP_calc_waittimeout(alicestr); - if ( swap != 0 ) +#ifndef NOTETOMIC + if (swap->I.bobtomic[0] != 0 || swap->I.alicetomic != 0) { + uint64_t eth_balance = getEthBalance(swap->I.etomicsrc); + if (eth_balance < 500000) { + err = -5000, printf("Bob ETH balance too low, aborting swap!\n"); + } + } +#endif + + if ( swap != 0 && err == 0) { if ( LP_waitsend("pubkeys",120,swap->N.pair,swap,data,maxlen,LP_pubkeys_verify,LP_pubkeys_data) < 0 ) err = -2000, printf("error waitsend pubkeys\n"); @@ -947,7 +956,17 @@ void LP_aliceloop(void *_swap) expiration = (uint32_t)time(NULL) + LP_SWAPSTEP_TIMEOUT; bobwaittimeout = LP_calc_waittimeout(bobstr); alicewaittimeout = LP_calc_waittimeout(alicestr); - if ( swap != 0 ) + +#ifndef NOTETOMIC + if (swap->I.bobtomic[0] != 0 || swap->I.alicetomic != 0) { + uint64_t eth_balance = getEthBalance(swap->I.etomicdest); + if (eth_balance < 500000) { + err = -5001, printf("Alice ETH balance too low, aborting swap!\n"); + } + } +#endif + + if ( swap != 0 && err == 0) { printf("start swap iamalice pair.%d\n",swap->N.pair); if ( LP_sendwait("pubkeys",120,swap->N.pair,swap,data,maxlen,LP_pubkeys_verify,LP_pubkeys_data) < 0 ) diff --git a/iguana/exchanges/etomicswap/etomiccurl.c b/iguana/exchanges/etomicswap/etomiccurl.c index 1db357b7f..9618eb200 100644 --- a/iguana/exchanges/etomicswap/etomiccurl.c +++ b/iguana/exchanges/etomicswap/etomiccurl.c @@ -373,15 +373,12 @@ void unlock_send_tx_mutex() pthread_mutex_unlock(&sendTxMutex); } -uint8_t get_etomic_from_faucet(char *eth_addr, char *etomic_addr, char *token_addr) +uint8_t get_etomic_from_faucet(char *eth_addr, char *etomic_addr) { char* string; cJSON *request = cJSON_CreateObject(); cJSON_AddStringToObject(request, "ethAddress", eth_addr); cJSON_AddStringToObject(request, "etomicAddress", etomic_addr); - if (strcmp(token_addr, "0x0000000000000000000000000000000000000000") != 0) { - cJSON_AddStringToObject(request, "tokenAddress", token_addr); - } string = cJSON_PrintUnformatted(request); char* requestResult = sendRequest(string, FAUCET_URL); free(string); diff --git a/iguana/exchanges/etomicswap/etomiccurl.h b/iguana/exchanges/etomicswap/etomiccurl.h index a340a604c..6e5036739 100644 --- a/iguana/exchanges/etomicswap/etomiccurl.h +++ b/iguana/exchanges/etomicswap/etomiccurl.h @@ -50,7 +50,7 @@ uint64_t getEthBlockNumber(); uint64_t getGasPriceFromStation(uint8_t defaultOnErr); int32_t waitForConfirmation(char *txId); void unlock_send_tx_mutex(); -uint8_t get_etomic_from_faucet(char *eth_addr, char *etomic_addr, char *token_addr); +uint8_t get_etomic_from_faucet(char *eth_addr, char *etomic_addr); #ifdef __cplusplus } From a291ae5f4f087fddaef3a1d59c09321305819805 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Wed, 6 Jun 2018 17:53:02 +0700 Subject: [PATCH 082/139] Fix non-etomic swap start crash. --- iguana/exchanges/LP_swap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index d48d1f63a..cf2c68c53 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -855,7 +855,7 @@ void LP_bobloop(void *_swap) bobwaittimeout = LP_calc_waittimeout(bobstr); alicewaittimeout = LP_calc_waittimeout(alicestr); #ifndef NOTETOMIC - if (swap->I.bobtomic[0] != 0 || swap->I.alicetomic != 0) { + if (swap->I.bobtomic[0] != 0 || swap->I.alicetomic[0] != 0) { uint64_t eth_balance = getEthBalance(swap->I.etomicsrc); if (eth_balance < 500000) { err = -5000, printf("Bob ETH balance too low, aborting swap!\n"); @@ -958,7 +958,7 @@ void LP_aliceloop(void *_swap) alicewaittimeout = LP_calc_waittimeout(alicestr); #ifndef NOTETOMIC - if (swap->I.bobtomic[0] != 0 || swap->I.alicetomic != 0) { + if (swap->I.bobtomic[0] != 0 || swap->I.alicetomic[0] != 0) { uint64_t eth_balance = getEthBalance(swap->I.etomicdest); if (eth_balance < 500000) { err = -5001, printf("Alice ETH balance too low, aborting swap!\n"); From 4e50178ca00319e8da80db300896171722d3c11d Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Fri, 8 Jun 2018 16:49:50 +0700 Subject: [PATCH 083/139] #59 Check ETH/ERC20 payment/deposit status before trying to spend it. --- Jenkinsfile | 8 ++--- iguana/exchanges/LP_etomic.c | 30 ++++++++++++++++++ iguana/exchanges/etomicswap/etomiccurl.c | 2 +- iguana/exchanges/etomicswap/etomiclib.cpp | 38 ++++++++++++++++++++++- iguana/exchanges/etomicswap/etomiclib.h | 6 +++- 5 files changed, 77 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5fca2513d..5415b55c7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -22,8 +22,8 @@ cmake --build . --target marketmaker-testnet''' sh '''docker-compose build docker-compose up -d ./start_BEER_OTHER_trade.sh ETH -timeout 600 grep -q "SWAP completed" <(docker-compose logs -f clientnode) -timeout 600 grep -q "SWAP completed" <(docker-compose logs -f seednode) +timeout 600 grep -q "SWAP completed" <(COMPOSE_HTTP_TIMEOUT=600 docker-compose logs -f clientnode) +timeout 600 grep -q "SWAP completed" <(COMPOSE_HTTP_TIMEOUT=600 docker-compose logs -f seednode) docker-compose down''' } } @@ -32,8 +32,8 @@ docker-compose down''' sh '''docker-compose build docker-compose up -d ./start_BEER_OTHER_trade_inverted.sh ETH -timeout 600 grep -q "SWAP completed" <(docker-compose logs -f clientnode) -timeout 600 grep -q "SWAP completed" <(docker-compose logs -f seednode) +timeout 600 grep -q "SWAP completed" <(COMPOSE_HTTP_TIMEOUT=600 docker-compose logs -f clientnode) +timeout 600 grep -q "SWAP completed" <(COMPOSE_HTTP_TIMEOUT=600 docker-compose logs -f seednode) docker-compose down''' } } diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index b211b4c9f..4c6c57f15 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -22,6 +22,9 @@ // Created by artem on 24.01.18. // #include "LP_etomic.h" +#define ALICE_PAYMENT_SENT 1 +#define BOB_DEPOSIT_SENT 1 +#define BOB_PAYMENT_SENT 1 int32_t LP_etomic_wait_for_confirmation(char *txId) { @@ -218,6 +221,10 @@ char *LP_etomicalice_reclaims_payment(struct LP_swap_remember *swap) privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr); uint8arrayToHex(input.dealId, swap->txids[BASILISK_ALICEPAYMENT].bytes, 32); + if (alicePaymentStatus(input.dealId + 2) != ALICE_PAYMENT_SENT) { + printf("Alice payment smart contract status check failed, can't spend\n"); + return NULL; + } satoshisToWei(input.amount, swap->destamount); if (swap->alicetomic[0] != 0) { @@ -266,6 +273,11 @@ char *LP_etomicbob_spends_alice_payment(struct LP_swap_remember *swap) privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr); uint8arrayToHex(input.dealId, swap->txids[BASILISK_ALICEPAYMENT].bytes, 32); + if (alicePaymentStatus(input.dealId + 2) != ALICE_PAYMENT_SENT) { + printf("Alice payment smart contract status check failed, can't spend\n"); + return NULL; + } + satoshisToWei(input.amount, swap->destamount); if (swap->alicetomic[0] != 0) { @@ -417,6 +429,11 @@ char *LP_etomicbob_refunds_deposit(struct LP_swap_remember *swap) return NULL; } uint8arrayToHex(input.depositId, swap->txids[BASILISK_BOBDEPOSIT].bytes, 32); + if (bobDepositStatus(input.depositId + 2) != BOB_DEPOSIT_SENT) { + printf("Bob deposit smart contract status check failed, can't claim\n"); + return NULL; + } + strcpy(input.aliceAddress, swap->etomicdest); bits256 invertedSecret; @@ -567,6 +584,10 @@ char *LP_etomicbob_reclaims_payment(struct LP_swap_remember *swap) return NULL; } uint8arrayToHex(input.paymentId, swap->txids[BASILISK_BOBPAYMENT].bytes, 32); + if (bobPaymentStatus(input.paymentId + 2) != BOB_PAYMENT_SENT) { + printf("Bob payment smart contract status check failed, can't spend\n"); + return NULL; + } strcpy(input.aliceAddress, swap->etomicdest); uint8arrayToHex(input.aliceHash, swap->secretAm, 20); @@ -608,6 +629,10 @@ char *LP_etomicalice_spends_bob_payment(struct LP_swap_remember *swap) privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr); uint8arrayToHex(input.paymentId, swap->txids[BASILISK_BOBPAYMENT].bytes, 32); + if (bobPaymentStatus(input.paymentId + 2) != BOB_PAYMENT_SENT) { + printf("Bob payment smart contract status check failed, can't spend\n"); + return NULL; + } satoshisToWei(input.amount, swap->values[BASILISK_BOBPAYMENT]); if (swap->bobtomic[0] != 0) { @@ -656,6 +681,11 @@ char *LP_etomicalice_claims_bob_deposit(struct LP_swap_remember *swap) privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr); uint8arrayToHex(input.depositId, swap->txids[BASILISK_BOBDEPOSIT].bytes, 32); + if (bobDepositStatus(input.depositId + 2) != BOB_DEPOSIT_SENT) { + printf("Bob deposit smart contract status check failed, can't claim\n"); + return NULL; + } + satoshisToWei(input.amount, swap->values[BASILISK_BOBDEPOSIT]); if (swap->bobtomic[0] != 0) { diff --git a/iguana/exchanges/etomicswap/etomiccurl.c b/iguana/exchanges/etomicswap/etomiccurl.c index 9618eb200..84985f828 100644 --- a/iguana/exchanges/etomicswap/etomiccurl.c +++ b/iguana/exchanges/etomicswap/etomiccurl.c @@ -196,7 +196,7 @@ char *ethCall(char *to, const char *data) cJSON_AddItemToArray(params, cJSON_CreateString("latest")); cJSON *resultJson = sendRpcRequest("eth_call", params); cJSON_Delete(params); - char* result = NULL; + char *result = NULL; if (resultJson != NULL && is_cJSON_String(resultJson) && resultJson->valuestring != NULL) { result = (char *) malloc(strlen(resultJson->valuestring) + 1); strcpy(result, resultJson->valuestring); diff --git a/iguana/exchanges/etomicswap/etomiclib.cpp b/iguana/exchanges/etomicswap/etomiclib.cpp index d5987ae19..50d2e70c0 100644 --- a/iguana/exchanges/etomicswap/etomiclib.cpp +++ b/iguana/exchanges/etomicswap/etomiclib.cpp @@ -758,7 +758,7 @@ char *sendErc20( return result; } -uint8_t verifyAliceErc20FeeData(char* tokenAddress, char *to, char *amount, char *data, uint8_t decimals) +uint8_t verifyAliceErc20FeeData(char *tokenAddress, char *to, char *amount, char *data, uint8_t decimals) { std::stringstream ss = getErc20TransferData(tokenAddress, to, amount, decimals); if (strcmp(ss.str().c_str(), data) != 0) { @@ -767,3 +767,39 @@ uint8_t verifyAliceErc20FeeData(char* tokenAddress, char *to, char *amount, char } return 1; } + +uint8_t alicePaymentStatus(char *paymentId) +{ + char buffer[100]; + memset(buffer, 0, sizeof(buffer)); + strcpy(buffer, "0x81cd872a"); + strcat(buffer, paymentId); + char *hexStatus = ethCall(ETOMIC_ALICECONTRACT, buffer); + auto status = (uint8_t) strtol(hexStatus + 66, NULL, 0); + free(hexStatus); + return status; +} + +uint8_t bobDepositStatus(char *depositId) +{ + char buffer[100]; + memset(buffer, 0, sizeof(buffer)); + strcpy(buffer, "0x3d4dff7b"); + strcat(buffer, depositId); + char *hexStatus = ethCall(ETOMIC_BOBCONTRACT, buffer); + auto status = (uint8_t) strtol(hexStatus + 130, NULL, 0); + free(hexStatus); + return status; +} + +uint8_t bobPaymentStatus(char *paymentId) +{ + char buffer[100]; + memset(buffer, 0, sizeof(buffer)); + strcpy(buffer, "0x0716326d"); + strcat(buffer, paymentId); + char *hexStatus = ethCall(ETOMIC_BOBCONTRACT, buffer); + auto status = (uint8_t) strtol(hexStatus + 130, NULL, 0); + free(hexStatus); + return status; +} diff --git a/iguana/exchanges/etomicswap/etomiclib.h b/iguana/exchanges/etomicswap/etomiclib.h index 97fa29f18..0e981dc1f 100644 --- a/iguana/exchanges/etomicswap/etomiclib.h +++ b/iguana/exchanges/etomicswap/etomiclib.h @@ -200,7 +200,11 @@ char *sendErc20( ); uint8_t verifyAliceErc20FeeData(char* tokenAddress, char *to, char *amount, char *data, uint8_t decimals); -// Your prototype or Definition + +uint8_t alicePaymentStatus(char *paymentId); +uint8_t bobDepositStatus(char *depositId); +uint8_t bobPaymentStatus(char *paymentId); + #ifdef __cplusplus } #endif From efd963831fb0ef55c7a064c06b4dc33189ca2a15 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Fri, 8 Jun 2018 19:09:40 +0700 Subject: [PATCH 084/139] #62 Add "version" RPC method. --- iguana/exchanges/LP_commands.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index b42ab7a31..9df4c1581 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -176,7 +176,13 @@ getfee(coin)\n\ sleep(seconds=60)\n\ listtransactions(coin, address, count=10, skip=0)\n\ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\ +version\n\ \"}")); + if ( strcmp(method,"version") == 0 ) { + retjson = cJSON_CreateObject(); + jaddstr(retjson,"result",MM_VERSION); + return(jprint(retjson,1)); + } if ( (base= jstr(argjson,"base")) == 0 ) base = ""; From adb23640565fdcd12e1d9ee62b5720f95f9083d3 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Mon, 11 Jun 2018 14:21:27 +0700 Subject: [PATCH 085/139] #57. Add "broadcast" parameter to eth_withdraw method. --- iguana/exchanges/LP_commands.c | 1 + iguana/exchanges/LP_transaction.c | 68 ++++++++++++++++++----- iguana/exchanges/etomicswap/etomiclib.cpp | 15 +++++ iguana/exchanges/etomicswap/etomiclib.h | 8 +++ 4 files changed, 79 insertions(+), 13 deletions(-) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index 9df4c1581..9a865aafc 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -120,6 +120,7 @@ cancel(uuid)\n\ buy(base, rel, price, relvolume, timeout=10, duration=3600, nonce)\n\ sell(base, rel, price, basevolume, timeout=10, duration=3600, nonce)\n\ withdraw(coin, outputs[], broadcast=0)\n\ +eth_withdraw(coin, to, amount, gas, gas_price, broadcast=0)\n\ txblast(coin, utxotxid, utxovout, utxovalue, txfee, passphrase, outputs[], broadcast=0)\n\ sendrawtransaction(coin, signedtx)\n\ swapstatus(pending=0, fast=0)\n\ diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index 228e62835..ef27a86a0 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -2046,13 +2046,49 @@ char *LP_movecoinbases(char *symbol) #ifndef NOTETOMIC +char *LP_eth_tx_fee(struct iguana_info *coin, char *dest_addr, char *amount, int64_t gas, int64_t gas_price) +{ + bits256 privkey; + cJSON *retjson = cJSON_CreateObject(); + int64_t actual_gas_price = 0, actual_gas = 0; + char privkey_str[70]; + + if (gas_price > 0) { + actual_gas_price = gas_price; + } else { + actual_gas_price = getGasPriceFromStation(0); + if (actual_gas_price == 0) { + return (clonestr("{\"error\":\"Couldn't get gas price from station!\"}")); + } + } + cJSON_AddNumberToObject(retjson, "gas_price", actual_gas_price); + + if (gas > 0) { + actual_gas = gas; + } else if (strcmp(coin->symbol, "ETH") == 0) { + actual_gas = 21000; + } else { + privkey = LP_privkey(coin->symbol, coin->smartaddr, coin->taddr); + uint8arrayToHex(privkey_str, privkey.bytes, 32); + actual_gas = estimate_erc20_gas(coin->etomic, dest_addr, amount, privkey_str, coin->decimals); + if (actual_gas == 0) { + return (clonestr("{\"error\":\"Couldn't estimate erc20 transfer gas usage!\"}")); + } + } + cJSON_AddNumberToObject(retjson, "gas", actual_gas); + + double_t eth_fee = (actual_gas_price * actual_gas) / 1000000000.0; + cJSON_AddNumberToObject(retjson, "eth_fee", eth_fee); + return(jprint(retjson,1)); +} + char *LP_eth_withdraw(struct iguana_info *coin,cJSON *argjson) { cJSON *retjson = cJSON_CreateObject(); cJSON *gas_json = cJSON_GetObjectItem(argjson, "gas"); cJSON *gas_price_json = cJSON_GetObjectItem(argjson, "gas_price"); char *dest_addr, *tx_id, privkey_str[70], amount_str[100]; - int64_t amount = 0, gas = 0, gas_price = 0; + int64_t amount = 0, gas = 0, gas_price = 0, broadcast = 0; bits256 privkey; dest_addr = jstr(argjson, "to"); @@ -2075,21 +2111,27 @@ char *LP_eth_withdraw(struct iguana_info *coin,cJSON *argjson) return (clonestr("{\"error\":\"'gas_price' can't be lower than 1!\"}")); } } - privkey = LP_privkey(coin->symbol, coin->smartaddr, coin->taddr); - uint8arrayToHex(privkey_str, privkey.bytes, 32); + + broadcast = jint(argjson, "broadcast"); satoshisToWei(amount_str, amount); - if (strcmp(coin->symbol, "ETH") == 0) { - tx_id = sendEth(dest_addr, amount_str, privkey_str, 0, gas, gas_price, 0); + if (broadcast == 1) { + privkey = LP_privkey(coin->symbol, coin->smartaddr, coin->taddr); + uint8arrayToHex(privkey_str, privkey.bytes, 32); + if (strcmp(coin->symbol, "ETH") == 0) { + tx_id = sendEth(dest_addr, amount_str, privkey_str, 0, gas, gas_price, 0); + } else { + tx_id = sendErc20(coin->etomic, dest_addr, amount_str, privkey_str, 0, gas, gas_price, 0, coin->decimals); + } + if (tx_id != NULL) { + jaddstr(retjson, "tx_id", tx_id); + free(tx_id); + } else { + jaddstr(retjson, "error", "Error sending transaction"); + } + return (jprint(retjson, 1)); } else { - tx_id = sendErc20(coin->etomic, dest_addr, amount_str, privkey_str, 0, gas, gas_price, 0, coin->decimals); + return LP_eth_tx_fee(coin, dest_addr, amount_str, gas, gas_price); } - if (tx_id != NULL) { - jaddstr(retjson, "tx_id", tx_id); - free(tx_id); - } else { - jaddstr(retjson, "error", "Error sending transaction"); - } - return(jprint(retjson,1)); } char *LP_eth_gas_price() diff --git a/iguana/exchanges/etomicswap/etomiclib.cpp b/iguana/exchanges/etomicswap/etomiclib.cpp index 50d2e70c0..10d749224 100644 --- a/iguana/exchanges/etomicswap/etomiclib.cpp +++ b/iguana/exchanges/etomicswap/etomiclib.cpp @@ -704,6 +704,21 @@ std::stringstream getErc20TransferData(char *tokenAddress, char *to, char *amoun return ss; } +uint64_t estimate_erc20_gas( + char *tokenAddress, + char *to, + char *amount, + char *privKey, + uint8_t decimals +) +{ + std::stringstream ss = getErc20TransferData(tokenAddress, to, amount, decimals); + char *from = privKey2Addr(privKey); + uint64_t result = estimateGas(from, tokenAddress, ss.str().c_str()); + free(from); + return result; +} + char *sendErc20( char *tokenAddress, char *to, diff --git a/iguana/exchanges/etomicswap/etomiclib.h b/iguana/exchanges/etomicswap/etomiclib.h index 0e981dc1f..db1547f4e 100644 --- a/iguana/exchanges/etomicswap/etomiclib.h +++ b/iguana/exchanges/etomicswap/etomiclib.h @@ -205,6 +205,14 @@ uint8_t alicePaymentStatus(char *paymentId); uint8_t bobDepositStatus(char *depositId); uint8_t bobPaymentStatus(char *paymentId); +uint64_t estimate_erc20_gas( + char *tokenAddress, + char *to, + char *amount, + char *privKey, + uint8_t decimals +); + #ifdef __cplusplus } #endif From 869e57a8af79f70a71ed0bf9fb7ed335219f8aa7 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Tue, 12 Jun 2018 11:51:58 +0700 Subject: [PATCH 086/139] #69 Add ETH/ERC20 balance to LP_RTsmartbalance. --- Jenkinsfile | 28 +++++++++++++++++++++++----- iguana/exchanges/LP_rpc.c | 5 +++++ 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5415b55c7..ee317926f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -14,13 +14,14 @@ rm -rf build mkdir build cd build cmake .. -cmake --build . --target marketmaker-testnet''' +cmake --build . --target marketmaker-testnet +cd ../ +docker-compose build''' } } stage('Trade BEER/ETH') { steps { - sh '''docker-compose build -docker-compose up -d + sh '''docker-compose up -d ./start_BEER_OTHER_trade.sh ETH timeout 600 grep -q "SWAP completed" <(COMPOSE_HTTP_TIMEOUT=600 docker-compose logs -f clientnode) timeout 600 grep -q "SWAP completed" <(COMPOSE_HTTP_TIMEOUT=600 docker-compose logs -f seednode) @@ -29,11 +30,28 @@ docker-compose down''' } stage('Trade ETH/BEER') { steps { - sh '''docker-compose build -docker-compose up -d + sh '''docker-compose up -d ./start_BEER_OTHER_trade_inverted.sh ETH timeout 600 grep -q "SWAP completed" <(COMPOSE_HTTP_TIMEOUT=600 docker-compose logs -f clientnode) timeout 600 grep -q "SWAP completed" <(COMPOSE_HTTP_TIMEOUT=600 docker-compose logs -f seednode) +docker-compose down''' + } + } + stage('Trade BEER/ETOMIC') { + steps { + sh '''docker-compose up -d +./start_BEER_OTHER_trade.sh ETOMIC +timeout 600 grep -q "SWAP completed" <(COMPOSE_HTTP_TIMEOUT=600 docker-compose logs -f clientnode) +timeout 600 grep -q "SWAP completed" <(COMPOSE_HTTP_TIMEOUT=600 docker-compose logs -f seednode) +docker-compose down''' + } + } + stage('Trade ETOMIC/BEER') { + steps { + sh '''docker-compose up -d +./start_BEER_OTHER_trade_inverted.sh ETOMIC +timeout 600 grep -q "SWAP completed" <(COMPOSE_HTTP_TIMEOUT=600 docker-compose logs -f clientnode) +timeout 600 grep -q "SWAP completed" <(COMPOSE_HTTP_TIMEOUT=600 docker-compose logs -f seednode) docker-compose down''' } } diff --git a/iguana/exchanges/LP_rpc.c b/iguana/exchanges/LP_rpc.c index 0e59fc626..9c1bca6c2 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -137,6 +137,11 @@ int32_t LP_getheight(int32_t *notarizedp,struct iguana_info *coin) uint64_t LP_RTsmartbalance(struct iguana_info *coin) { +#ifndef NOTETOMIC + if (coin->etomic[0] != 0) { + return LP_etomic_get_balance(coin, coin->smartaddr); + } +#endif cJSON *array,*item; char buf[512],*retstr; int32_t i,n; uint64_t valuesum,value; bits256 zero; valuesum = 0; memset(zero.bytes,0,sizeof(zero)); From 245325e5a27c5239ce86516cc546fe9cecbb0e2f Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Tue, 12 Jun 2018 12:08:38 +0700 Subject: [PATCH 087/139] #70 Make instantdex_deposit method error more clear. --- iguana/exchanges/LP_commands.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index 9a865aafc..4e2e08ba6 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -239,9 +239,14 @@ version\n\ { if ( (ptr= LP_coinsearch("KMD")) != 0 ) { - if ( jint(argjson,"weeks") <= 0 || jdouble(argjson,"amount") < 10. ) - return(clonestr("{\"error\":\"instantdex_deposit needs to have weeks and amount\"}")); - else return(LP_instantdex_deposit(ptr,juint(argjson,"weeks"),jdouble(argjson,"amount"),jobj(argjson,"broadcast") != 0 ? jint(argjson,"broadcast") : 1)); + if ( jint(argjson,"weeks") <= 0 ) { + return(clonestr("{\"error\":\"instantdex_deposit weeks param must be greater than zero\"}")); + } + if ( jdouble(argjson,"amount") < 10. ) { + return(clonestr("{\"error\":\"instantdex_deposit amount param must be equal or greater than 10\"}")); + } + + return(LP_instantdex_deposit(ptr,juint(argjson,"weeks"),jdouble(argjson,"amount"),jobj(argjson,"broadcast") != 0 ? jint(argjson,"broadcast") : 1)); } return(clonestr("{\"error\":\"cant find KMD\"}")); } From 7eeb533b745603afedf8032a672d87c5f4c15eac Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Wed, 13 Jun 2018 14:14:55 +0700 Subject: [PATCH 088/139] #71 Fix crash on failing ETH/ERC20 balance requests. --- iguana/exchanges/etomicswap/etomiclib.cpp | 38 ++++++++++++++--------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/iguana/exchanges/etomicswap/etomiclib.cpp b/iguana/exchanges/etomicswap/etomiclib.cpp index 10d749224..ee0e03d6f 100644 --- a/iguana/exchanges/etomicswap/etomiclib.cpp +++ b/iguana/exchanges/etomicswap/etomiclib.cpp @@ -554,10 +554,14 @@ char* getPubKeyFromPriv(char* privKey) uint64_t getEthBalance(char* address) { char* hexBalance = getEthBalanceRequest(address); - // convert wei to satoshi - u256 balance = jsToU256(hexBalance) / boost::multiprecision::pow(u256(10), 10); - free(hexBalance); - return static_cast(balance); + if (hexBalance != NULL) { + // convert wei to satoshi + u256 balance = jsToU256(hexBalance) / boost::multiprecision::pow(u256(10), 10); + free(hexBalance); + return static_cast(balance); + } else { + return 0; + } } uint64_t getErc20BalanceSatoshi(char *address, char *tokenAddress, uint8_t setDecimals) @@ -569,19 +573,23 @@ uint64_t getErc20BalanceSatoshi(char *address, char *tokenAddress, uint8_t setDe char* hexBalance = ethCall(tokenAddress, ss.str().c_str()); // convert wei to satoshi uint8_t decimals; - if (setDecimals > 0) { - decimals = setDecimals; - } else { - decimals = getErc20Decimals(tokenAddress); - } + if (hexBalance != NULL) { + if (setDecimals > 0) { + decimals = setDecimals; + } else { + decimals = getErc20Decimals(tokenAddress); + } - u256 balance = jsToU256(hexBalance); - if (decimals < 18) { - balance *= boost::multiprecision::pow(u256(10), 18 - decimals); + u256 balance = jsToU256(hexBalance); + if (decimals < 18) { + balance *= boost::multiprecision::pow(u256(10), 18 - decimals); + } + balance /= boost::multiprecision::pow(u256(10), 10); + free(hexBalance); + return static_cast(balance); + } else { + return 0; } - balance /= boost::multiprecision::pow(u256(10), 10); - free(hexBalance); - return static_cast(balance); } char *getErc20BalanceHexWei(char *address, char *tokenAddress) From 1ff4621fde9350971a02ce35ba6d2a6e85e94d09 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Wed, 13 Jun 2018 18:18:18 +0700 Subject: [PATCH 089/139] #58 Add ETH/ERC20 avevolume/maxvolume to orderbooks. --- iguana/exchanges/LP_signatures.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/iguana/exchanges/LP_signatures.c b/iguana/exchanges/LP_signatures.c index 91667fa2e..2d8e45750 100644 --- a/iguana/exchanges/LP_signatures.c +++ b/iguana/exchanges/LP_signatures.c @@ -442,6 +442,16 @@ char *LP_pricepings(void *ctx,char *myipaddr,int32_t pubsock,char *base,char *re jaddstr(reqjson,"pubsecp",pubsecpstr); if ( (kmd= LP_coinfind("KMD")) != 0 && (ap= LP_address(kmd,kmd->smartaddr)) != 0 && ap->instantdex_credits != 0 ) jaddnum(reqjson,"credits",dstr(ap->instantdex_credits)); +#ifndef NOTETOMIC + if (basecoin->etomic[0] != 0) { + uint64_t etomic_coin_balance = LP_etomic_get_balance(basecoin, basecoin->smartaddr); + jaddstr(reqjson,"utxocoin","ETH_OR_ERC20"); + jaddnum(reqjson,"bal",dstr(etomic_coin_balance)); + jaddnum(reqjson,"min",dstr(etomic_coin_balance)); + jaddnum(reqjson,"max",dstr(etomic_coin_balance)); + jaddnum(reqjson,"n",1); + } else +#endif if ( (numutxos= LP_address_minmax(1,&median,&minsize,&maxsize,basecoin,basecoin->smartaddr)) != 0 ) { //printf("send %s numutxos.%d median %.8f min %.8f max %.8f\n",base,numutxos,dstr(median),dstr(minsize),dstr(maxsize)); From 9d35f61c0d1f1dcd6ca844fac9a695200fe98908 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 14 Jun 2018 12:43:02 +0700 Subject: [PATCH 090/139] #66 hardcode 1 ETOMIC for all ETOMIC trades on order to test. --- iguana/exchanges/LP_swap.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index cf2c68c53..b69eacca7 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -1197,6 +1197,14 @@ struct basilisk_swap *bitcoin_swapinit(bits256 privkey,uint8_t *pubkey33,bits256 free(swap); return(0); } +#ifndef NOTETOMIC + if (strcmp(alicestr, "ETOMIC") == 0) { + swap->I.alicesatoshis = 100000000; + } + if (strcmp(bobstr, "ETOMIC") == 0) { + swap->I.bobsatoshis = 100000000; + } +#endif if ( (swap->I.bobinsurance= (swap->I.bobsatoshis / INSTANTDEX_INSURANCEDIV)) < LP_MIN_TXFEE ) swap->I.bobinsurance = LP_MIN_TXFEE; if ( (swap->I.aliceinsurance= (swap->I.alicesatoshis / INSTANTDEX_INSURANCEDIV)) < LP_MIN_TXFEE ) From 963c8fcc7cae7aa8ab001cd7b8bc2644779e4613 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 14 Jun 2018 14:41:43 +0700 Subject: [PATCH 091/139] #66 Use only 1 ETOMIC for ETH/ERC20 trades instead of using 1:1 amount. --- iguana/exchanges/LP_etomic.c | 56 +++++++++++++++++----------------- iguana/exchanges/LP_include.h | 4 +-- iguana/exchanges/LP_remember.c | 6 ++++ iguana/exchanges/LP_swap.c | 2 ++ 4 files changed, 38 insertions(+), 30 deletions(-) diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index 4c6c57f15..9d0a7e468 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -41,7 +41,7 @@ void LP_etomic_pubkeystr_to_addr(char *pubkey, char *output) char *LP_etomicalice_send_fee(struct basilisk_swap *swap) { char amount[100], secretKey[70], dexaddr[50]; - satoshisToWei(amount, swap->myfee.I.amount); + satoshisToWei(amount, LP_DEXFEE(swap->I.alicerealsat)); uint8arrayToHex(secretKey, swap->persistent_privkey.bytes, 32); LP_etomic_pubkeystr_to_addr(INSTANTDEX_PUBKEY, dexaddr); if (strcmp(swap->I.alicestr,"ETH") == 0 ) { @@ -73,8 +73,8 @@ uint8_t LP_etomic_verify_alice_fee(struct basilisk_swap *swap) return(0); } uint64_t txValue = weiToSatoshi(data.valueHex); - if (txValue != swap->otherfee.I.amount) { - printf("Alice fee %s amount %" PRIu64 " is not equal to expected %" PRIu64 "\n", swap->otherfee.I.ethTxid, txValue, swap->otherfee.I.amount); + if (txValue != LP_DEXFEE(swap->I.alicerealsat)) { + printf("Alice fee %s amount %" PRIu64 " is not equal to expected %" PRId64 "\n", swap->otherfee.I.ethTxid, txValue, LP_DEXFEE(swap->I.alicerealsat)); return(0); } return(1); @@ -86,7 +86,7 @@ uint8_t LP_etomic_verify_alice_fee(struct basilisk_swap *swap) return(0); } char weiAmount[70]; - satoshisToWei(weiAmount, swap->otherfee.I.amount); + satoshisToWei(weiAmount, LP_DEXFEE(swap->I.alicerealsat)); return(verifyAliceErc20FeeData(swap->I.alicetomic, dexaddr, weiAmount, data.input, alicecoin->decimals)); } } @@ -107,7 +107,7 @@ char *LP_etomicalice_send_payment(struct basilisk_swap *swap) strcpy(txData.from, swap->I.etomicdest); strcpy(txData.to, ETOMIC_ALICECONTRACT); - satoshisToWei(txData.amount, swap->I.alicesatoshis); + satoshisToWei(txData.amount, swap->I.alicerealsat); uint8arrayToHex(txData.secretKey, swap->persistent_privkey.bytes, 32); return(aliceSendsEthPayment(input,txData)); @@ -122,7 +122,7 @@ char *LP_etomicalice_send_payment(struct basilisk_swap *swap) uint8arrayToHex(input20.aliceHash, swap->I.secretAm, 20); uint8arrayToHex(input20.dealId, swap->alicepayment.I.actualtxid.bytes, 32); strcpy(input20.tokenAddress, swap->I.alicetomic); - satoshisToWei(input20.amount, swap->I.alicesatoshis); + satoshisToWei(input20.amount, swap->I.alicerealsat); input20.decimals = alicecoin->decimals; strcpy(txData.from, swap->I.etomicdest); @@ -131,7 +131,7 @@ char *LP_etomicalice_send_payment(struct basilisk_swap *swap) uint8arrayToHex(txData.secretKey, swap->persistent_privkey.bytes, 32); uint64_t allowance = getErc20Allowance(swap->I.etomicdest, ETOMIC_ALICECONTRACT, swap->I.alicetomic, alicecoin->decimals); - if (allowance < swap->I.alicesatoshis) { + if (allowance < swap->I.alicerealsat) { printf("Alice token allowance is too low, setting new allowance\n"); ApproveErc20Input approveErc20Input; strcpy(approveErc20Input.tokenAddress, swap->I.alicetomic); @@ -171,8 +171,8 @@ uint8_t LP_etomic_verify_alice_payment(struct basilisk_swap *swap, char *txId) if ( strcmp(swap->I.alicestr,"ETH") == 0 ) { uint64_t paymentAmount = weiToSatoshi(data.valueHex); - if (paymentAmount != swap->I.alicesatoshis) { - printf("Alice payment amount %" PRIu64 " does not match expected %" PRIu64 "\n", paymentAmount, swap->I.alicesatoshis); + if (paymentAmount != swap->I.alicerealsat) { + printf("Alice payment amount %" PRIu64 " does not match expected %" PRIu64 "\n", paymentAmount, swap->I.alicerealsat); return(0); } memset(&input,0,sizeof(input)); @@ -191,7 +191,7 @@ uint8_t LP_etomic_verify_alice_payment(struct basilisk_swap *swap, char *txId) uint8arrayToHex(input20.aliceHash, swap->I.secretAm, 20); uint8arrayToHex(input20.dealId, swap->alicepayment.I.actualtxid.bytes, 32); strcpy(input20.tokenAddress, swap->I.alicetomic); - satoshisToWei(input20.amount, swap->I.alicesatoshis); + satoshisToWei(input20.amount, swap->I.alicerealsat); input20.decimals = alicecoin->decimals; return(verifyAliceErc20PaymentData(input20, data.input)); @@ -225,7 +225,7 @@ char *LP_etomicalice_reclaims_payment(struct LP_swap_remember *swap) printf("Alice payment smart contract status check failed, can't spend\n"); return NULL; } - satoshisToWei(input.amount, swap->destamount); + satoshisToWei(input.amount, swap->alicerealsat); if (swap->alicetomic[0] != 0) { strcpy(input.tokenAddress, swap->alicetomic); @@ -278,7 +278,7 @@ char *LP_etomicbob_spends_alice_payment(struct LP_swap_remember *swap) return NULL; } - satoshisToWei(input.amount, swap->destamount); + satoshisToWei(input.amount, swap->alicerealsat); if (swap->alicetomic[0] != 0) { strcpy(input.tokenAddress, swap->alicetomic); @@ -319,7 +319,7 @@ char *LP_etomicbob_sends_deposit(struct basilisk_swap *swap) strcpy(txData.from, swap->I.etomicsrc); strcpy(txData.to, ETOMIC_BOBCONTRACT); - satoshisToWei(txData.amount, swap->bobdeposit.I.amount); + satoshisToWei(txData.amount, LP_DEPOSITSATOSHIS(swap->I.bobrealsat)); uint8arrayToHex(txData.secretKey, swap->persistent_privkey.bytes, 32); return bobSendsEthDeposit(input, txData); } else { @@ -328,7 +328,7 @@ char *LP_etomicbob_sends_deposit(struct basilisk_swap *swap) uint8arrayToHex(input20.depositId, swap->bobdeposit.I.actualtxid.bytes, 32); strcpy(input20.aliceAddress, swap->I.etomicdest); uint8arrayToHex(input20.bobHash, swap->I.secretBn, 20); - satoshisToWei(input20.amount, swap->bobdeposit.I.amount); + satoshisToWei(input20.amount, LP_DEPOSITSATOSHIS(swap->I.bobrealsat)); strcpy(input20.tokenAddress, swap->I.bobtomic); input20.lockTime = swap->bobdeposit.I.locktime; input20.decimals = bobcoin->decimals; @@ -339,7 +339,7 @@ char *LP_etomicbob_sends_deposit(struct basilisk_swap *swap) uint8arrayToHex(txData.secretKey, swap->persistent_privkey.bytes, 32); uint64_t allowance = getErc20Allowance(swap->I.etomicsrc, ETOMIC_BOBCONTRACT, swap->I.bobtomic, bobcoin->decimals); - if (allowance < swap->bobdeposit.I.amount) { + if (allowance < LP_DEPOSITSATOSHIS(swap->I.bobrealsat)) { printf("Bob token allowance is too low, setting new allowance\n"); ApproveErc20Input approveErc20Input; strcpy(approveErc20Input.tokenAddress, swap->I.bobtomic); @@ -381,8 +381,8 @@ uint8_t LP_etomic_verify_bob_deposit(struct basilisk_swap *swap, char *txId) memset(&input20,0,sizeof(input20)); if ( strcmp(swap->I.bobstr,"ETH") == 0 ) { uint64_t depositAmount = weiToSatoshi(data.valueHex); - if (depositAmount != swap->bobdeposit.I.amount) { - printf("Bob deposit %s amount %" PRIu64 " != expected %" PRIu64 "\n", txId, depositAmount, swap->bobdeposit.I.amount); + if (depositAmount != LP_DEPOSITSATOSHIS(swap->I.bobrealsat)) { + printf("Bob deposit %s amount %" PRIu64 " != expected %" PRIu64 "\n", txId, depositAmount, LP_DEPOSITSATOSHIS(swap->I.bobrealsat)); return(0); } uint8arrayToHex(input.depositId, swap->bobdeposit.I.actualtxid.bytes, 32); @@ -397,7 +397,7 @@ uint8_t LP_etomic_verify_bob_deposit(struct basilisk_swap *swap, char *txId) uint8arrayToHex(input20.depositId, swap->bobdeposit.I.actualtxid.bytes, 32); strcpy(input20.aliceAddress, swap->I.etomicdest); uint8arrayToHex(input20.bobHash, swap->I.secretBn, 20); - satoshisToWei(input20.amount, swap->bobdeposit.I.amount); + satoshisToWei(input20.amount, LP_DEPOSITSATOSHIS(swap->I.bobrealsat)); strcpy(input20.tokenAddress, swap->I.bobtomic); input20.lockTime = swap->bobdeposit.I.locktime; input20.decimals = bobcoin->decimals; @@ -448,7 +448,7 @@ char *LP_etomicbob_refunds_deposit(struct LP_swap_remember *swap) } else { strcpy(input.tokenAddress, "0x0000000000000000000000000000000000000000"); } - satoshisToWei(input.amount, swap->values[BASILISK_BOBDEPOSIT]); + satoshisToWei(input.amount, LP_DEPOSITSATOSHIS(swap->bobrealsat)); input.decimals = bobcoin->decimals; strcpy(txData.from, swap->etomicsrc); @@ -475,7 +475,7 @@ char *LP_etomicbob_sends_payment(struct basilisk_swap *swap) strcpy(txData.from, swap->I.etomicsrc); strcpy(txData.to, ETOMIC_BOBCONTRACT); - satoshisToWei(txData.amount, swap->bobpayment.I.amount); + satoshisToWei(txData.amount, swap->I.bobrealsat); uint8arrayToHex(txData.secretKey, swap->persistent_privkey.bytes, 32); return bobSendsEthPayment(input, txData); } else { @@ -484,7 +484,7 @@ char *LP_etomicbob_sends_payment(struct basilisk_swap *swap) uint8arrayToHex(input20.paymentId, swap->bobpayment.I.actualtxid.bytes, 32); strcpy(input20.aliceAddress, swap->I.etomicdest); uint8arrayToHex(input20.aliceHash, swap->I.secretAm, 20); - satoshisToWei(input20.amount, swap->bobpayment.I.amount); + satoshisToWei(input20.amount, swap->I.bobrealsat); strcpy(input20.tokenAddress, swap->I.bobtomic); input20.lockTime = swap->bobpayment.I.locktime; input20.decimals = bobcoin->decimals; @@ -495,7 +495,7 @@ char *LP_etomicbob_sends_payment(struct basilisk_swap *swap) uint8arrayToHex(txData.secretKey, swap->persistent_privkey.bytes, 32); uint64_t allowance = getErc20Allowance(swap->I.etomicsrc, ETOMIC_BOBCONTRACT, swap->I.bobtomic, bobcoin->decimals); - if (allowance < swap->bobpayment.I.amount) { + if (allowance < swap->I.bobrealsat) { printf("Bob token allowance is too low, setting new allowance\n"); ApproveErc20Input approveErc20Input; strcpy(approveErc20Input.tokenAddress, swap->I.bobtomic); @@ -536,8 +536,8 @@ uint8_t LP_etomic_verify_bob_payment(struct basilisk_swap *swap, char *txId) if ( strcmp(swap->I.bobstr,"ETH") == 0 ) { uint64_t paymentAmount = weiToSatoshi(data.valueHex); - if (paymentAmount != swap->bobpayment.I.amount) { - printf("Bob payment %s amount %" PRIu64 " != expected %" PRIu64 "\n", txId, paymentAmount, swap->bobpayment.I.amount); + if (paymentAmount != swap->I.bobrealsat) { + printf("Bob payment %s amount %" PRIu64 " != expected %" PRIu64 "\n", txId, paymentAmount, swap->I.bobrealsat); return(0); } uint8arrayToHex(input.paymentId, swap->bobpayment.I.actualtxid.bytes, 32); @@ -552,7 +552,7 @@ uint8_t LP_etomic_verify_bob_payment(struct basilisk_swap *swap, char *txId) uint8arrayToHex(input20.paymentId, swap->bobpayment.I.actualtxid.bytes, 32); strcpy(input20.aliceAddress, swap->I.etomicdest); uint8arrayToHex(input20.aliceHash, swap->I.secretAm, 20); - satoshisToWei(input20.amount, swap->bobpayment.I.amount); + satoshisToWei(input20.amount, swap->I.bobrealsat); strcpy(input20.tokenAddress, swap->I.bobtomic); input20.lockTime = swap->bobpayment.I.locktime; input20.decimals = bobcoin->decimals; @@ -596,7 +596,7 @@ char *LP_etomicbob_reclaims_payment(struct LP_swap_remember *swap) } else { strcpy(input.tokenAddress, "0x0000000000000000000000000000000000000000"); } - satoshisToWei(input.amount, swap->values[BASILISK_BOBPAYMENT]); + satoshisToWei(input.amount, swap->bobrealsat); input.decimals = bobcoin->decimals; strcpy(txData.from, swap->etomicsrc); @@ -633,7 +633,7 @@ char *LP_etomicalice_spends_bob_payment(struct LP_swap_remember *swap) printf("Bob payment smart contract status check failed, can't spend\n"); return NULL; } - satoshisToWei(input.amount, swap->values[BASILISK_BOBPAYMENT]); + satoshisToWei(input.amount, swap->bobrealsat); if (swap->bobtomic[0] != 0) { strcpy(input.tokenAddress, swap->bobtomic); @@ -686,7 +686,7 @@ char *LP_etomicalice_claims_bob_deposit(struct LP_swap_remember *swap) return NULL; } - satoshisToWei(input.amount, swap->values[BASILISK_BOBDEPOSIT]); + satoshisToWei(input.amount, LP_DEPOSITSATOSHIS(swap->bobrealsat)); if (swap->bobtomic[0] != 0) { strcpy(input.tokenAddress, swap->bobtomic); diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index f2b73cd22..c5cd36b40 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -241,7 +241,7 @@ struct basilisk_swapinfo bits256 myhash,otherhash,orderhash; uint32_t statebits,otherstatebits,started,expiration,finished,dead,reftime,putduration,callduration; int32_t bobconfirms,aliceconfirms,iambob,reclaimed,bobspent,alicespent,pad,aliceistrusted,bobistrusted,otheristrusted,otherstrust,alicemaxconfirms,bobmaxconfirms; - int64_t alicesatoshis,bobsatoshis,bobinsurance,aliceinsurance,Atxfee,Btxfee; + int64_t alicesatoshis,bobsatoshis,bobinsurance,aliceinsurance,Atxfee,Btxfee,alicerealsat,bobrealsat; bits256 myprivs[2],mypubs[2],otherpubs[2],pubA0,pubA1,pubB0,pubB1,privAm,pubAm,privBn,pubBn; uint32_t crcs_mypub[2],crcs_mychoosei[2],crcs_myprivs[2],crcs_mypriv[2]; @@ -273,7 +273,7 @@ static char *txnames[] = { "alicespend", "bobspend", "bobpayment", "alicepayment struct LP_swap_remember { bits256 pubA0,pubB0,pubB1,privAm,privBn,paymentspent,Apaymentspent,depositspent,myprivs[2],txids[sizeof(txnames)/sizeof(*txnames)]; - uint64_t Atxfee,Btxfee,srcamount,destamount,aliceid; + uint64_t Atxfee,Btxfee,srcamount,destamount,aliceid,alicerealsat,bobrealsat; int64_t values[sizeof(txnames)/sizeof(*txnames)]; uint32_t finishtime,tradeid,requestid,quoteid,plocktime,dlocktime,expiration,state,otherstate; int32_t iambob,finishedflag,origfinishedflag,Predeemlen,Dredeemlen,sentflags[sizeof(txnames)/sizeof(*txnames)]; diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index deaacf1c9..630910f3d 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -80,6 +80,9 @@ void basilisk_dontforget(struct basilisk_swap *swap,struct basilisk_rawtx *rawtx fprintf(fp,",\"alicePaymentEthTx\":\"%s\"", swap->alicepayment.I.ethTxid); } + fprintf(fp,",\"aliceRealSat\":\"%" PRId64 "\"", swap->I.alicerealsat); + fprintf(fp,",\"bobRealSat\":\"%" PRId64 "\"", swap->I.bobrealsat); + fprintf(fp,",\"alicecoin\":\"%s\"",swap->I.alicestr); if ( swap->I.alicetomic[0] != 0 ) fprintf(fp,",\"alicetomic\":\"%s\"",swap->I.alicetomic); @@ -921,6 +924,9 @@ int32_t LP_swap_load(struct LP_swap_remember *rswap,int32_t forceflag) strcpy(rswap->alicetomic, jstr(txobj,"alicetomic")); } + rswap->bobrealsat = jint(txobj, "bobRealSat"); + rswap->alicerealsat = jint(txobj, "aliceRealSat"); + rswap->txids[i] = txid; if ( jstr(txobj,"Apayment") != 0 ) safecopy(rswap->alicepaymentaddr,jstr(txobj,"Apayment"),sizeof(rswap->alicepaymentaddr)); diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index b69eacca7..e5243174a 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -1199,9 +1199,11 @@ struct basilisk_swap *bitcoin_swapinit(bits256 privkey,uint8_t *pubkey33,bits256 } #ifndef NOTETOMIC if (strcmp(alicestr, "ETOMIC") == 0) { + swap->I.alicerealsat = swap->I.alicesatoshis; swap->I.alicesatoshis = 100000000; } if (strcmp(bobstr, "ETOMIC") == 0) { + swap->I.bobrealsat = swap->I.bobsatoshis; swap->I.bobsatoshis = 100000000; } #endif From 68c3a42eac985c97233a12945c0c724460e30f3a Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 14 Jun 2018 15:15:02 +0700 Subject: [PATCH 092/139] #73 Add more console logs when eth tx sends fails. --- iguana/exchanges/etomicswap/etomiccurl.c | 1 + iguana/exchanges/etomicswap/etomiclib.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/iguana/exchanges/etomicswap/etomiccurl.c b/iguana/exchanges/etomicswap/etomiccurl.c index 84985f828..c6a493f33 100644 --- a/iguana/exchanges/etomicswap/etomiccurl.c +++ b/iguana/exchanges/etomicswap/etomiccurl.c @@ -320,6 +320,7 @@ uint64_t getGasPriceFromStation(uint8_t defaultOnErr) cJSON *resultJson = cJSON_Parse(s.ptr); free(s.ptr); if (resultJson == NULL) { + printf("Could not parse gas station response!\n"); return result; } diff --git a/iguana/exchanges/etomicswap/etomiclib.cpp b/iguana/exchanges/etomicswap/etomiclib.cpp index ee0e03d6f..b1bcbe7c1 100644 --- a/iguana/exchanges/etomicswap/etomiclib.cpp +++ b/iguana/exchanges/etomicswap/etomiclib.cpp @@ -676,6 +676,7 @@ char *sendEth(char *to, char *amount, char *privKey, uint8_t waitConfirm, int64_ } else { tx.gasPrice = getGasPriceFromStation(defaultGasOnErr) * boost::multiprecision::pow(u256(10), 9); if (tx.gasPrice == 0 && !defaultGasOnErr) { + printf("Could not get gas price from station!\n"); unlock_send_tx_mutex(); return NULL; } @@ -764,6 +765,7 @@ char *sendErc20( } else { tx.gasPrice = getGasPriceFromStation(defaultGasOnErr) * boost::multiprecision::pow(u256(10), 9); if (tx.gasPrice == 0 && !defaultGasOnErr) { + printf("Could not get gas price from station!\n"); unlock_send_tx_mutex(); return NULL; } From b0d9e5f22bd0574475a1f89c3dae128558de899e Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Fri, 15 Jun 2018 11:29:57 +0700 Subject: [PATCH 093/139] #66 Do not forcefully use 1 ETOMIC for ETH/ERC20 trades yet. --- iguana/exchanges/LP_swap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index 5c7af583e..f16efbd20 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -1201,11 +1201,11 @@ struct basilisk_swap *bitcoin_swapinit(bits256 privkey,uint8_t *pubkey33,bits256 #ifndef NOTETOMIC if (strcmp(alicestr, "ETOMIC") == 0) { swap->I.alicerealsat = swap->I.alicesatoshis; - swap->I.alicesatoshis = 100000000; + //swap->I.alicesatoshis = 100000000; } if (strcmp(bobstr, "ETOMIC") == 0) { swap->I.bobrealsat = swap->I.bobsatoshis; - swap->I.bobsatoshis = 100000000; + //swap->I.bobsatoshis = 100000000; } #endif if ( (swap->I.bobinsurance= (swap->I.bobsatoshis / INSTANTDEX_INSURANCEDIV)) < LP_MIN_TXFEE ) From 7844891d1e22c1677b9cdb6e4010f554ed160cb9 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Fri, 15 Jun 2018 14:44:23 +0700 Subject: [PATCH 094/139] #75 Do not call ETH/ERC20 balance for disabled coins. --- iguana/exchanges/LP_utxo.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index eb4b37131..4e9928aa2 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -787,7 +787,14 @@ cJSON *LP_balances(char *coinaddr) } else { - if ( (balance= LP_RTsmartbalance(coin)) != 0 ) +#ifndef NOTETOMIC + if (coin->etomic[0] == 0 || coin->inactive == 0) { +#endif + balance = LP_RTsmartbalance(coin); +#ifndef NOTETOMIC + } +#endif + if ( balance != 0 ) { item = cJSON_CreateObject(); jaddstr(item,"coin",coin->symbol); From bfdf9a3265a97452a512aa4e179de338975bda4f Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Fri, 15 Jun 2018 17:30:07 +0700 Subject: [PATCH 095/139] #66 Possibly finish forcing 1 ETOMIC for ETH/ERC20 trades. --- iguana/exchanges/LP_ordermatch.c | 24 ++++++++++++++++++------ iguana/exchanges/LP_swap.c | 4 ++-- iguana/exchanges/LP_utxo.c | 2 +- start_BEER_OTHER_trade.sh | 10 +++------- start_BEER_OTHER_trade_inverted.sh | 10 +++------- 5 files changed, 27 insertions(+), 23 deletions(-) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index 7dc3b7c0c..957e87d45 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -195,7 +195,7 @@ double LP_quote_validate(struct LP_utxoinfo *autxo,struct LP_utxoinfo *butxo,str printf("destvalue %.8f destsatoshis %.8f is too small txfee %.8f?\n",dstr(destvalue),dstr(qp->destsatoshis),dstr(qp->desttxfee)); return(-11); } - if ( butxo != 0 && srcvalue < qp->txfee+qp->satoshis ) + if ( strcmp(srccoin, "ETOMIC") != 0 && butxo != 0 && srcvalue < qp->txfee+qp->satoshis ) { printf("srcvalue %.8f [%.8f] satoshis %.8f is too small txfee %.8f?\n",dstr(srcvalue),dstr(srcvalue) - dstr(qp->txfee+qp->satoshis),dstr(qp->satoshis),dstr(qp->txfee)); return(-33); @@ -213,7 +213,7 @@ double LP_quote_validate(struct LP_utxoinfo *autxo,struct LP_utxoinfo *butxo,str printf("error -14: txfee %.8f < %.8f or desttxfee %.8f < %.8f\n",dstr(qp->txfee),dstr(LP_REQUIRED_TXFEE*txfee),dstr(qp->desttxfee),dstr(LP_REQUIRED_TXFEE*desttxfee)); return(-14); } - if ( butxo != 0 ) + if ( butxo != 0 && strcmp(srccoin, "ETOMIC") != 0) { if ( qp->satoshis < (srcvalue / LP_MINVOL) || srcvalue < qp->txfee*LP_MINSIZE_TXFEEMULT ) { @@ -413,14 +413,22 @@ struct LP_utxoinfo *LP_address_myutxopair(struct LP_utxoinfo *butxo,int32_t iamb memset(butxo,0,sizeof(*butxo)); if ( iambob != 0 ) { - targetval = LP_basesatoshis(relvolume,price,txfee,desttxfee) + 3*txfee; + if (strcmp(coin->symbol, "ETOMIC") == 0) { + targetval = 100000000 + 3*txfee; + } else { + targetval = LP_basesatoshis(relvolume,price,txfee,desttxfee) + 3*txfee; + } targetval2 = (targetval / 8) * 9 + 3*txfee; fee = txfee; ratio = LP_MINVOL; } else { - targetval = relvolume*SATOSHIDEN + 3*desttxfee; + if (strcmp(coin->symbol, "ETOMIC") == 0) { + targetval = 100000000 + 3*desttxfee; + } else { + targetval = relvolume*SATOSHIDEN + 3*desttxfee; + } targetval2 = (targetval / 777) + 3*desttxfee; fee = desttxfee; ratio = LP_MINCLIENTVOL; @@ -906,7 +914,7 @@ double LP_trades_pricevalidate(struct LP_quoteinfo *qp,struct iguana_info *coin, printf("quote %s/%s validate error %.0f\n",qp->srccoin,qp->destcoin,qprice); return(-3); } - if ( qprice < (price - 0.00000001) * 0.998 ) + if ( qprice < (price - 0.00000001) * 0.998) { printf(" quote price %.8f (%llu/%llu %.8f) too low vs %.8f for %s/%s price %.8f %.8f\n",qprice,(long long)qp->destsatoshis,(long long)(qp->satoshis-qp->txfee),(double)qp->destsatoshis/(qp->satoshis-qp->txfee),price,qp->srccoin,qp->destcoin,price,(price - 0.00000001) * 0.998); return(-77); @@ -1009,7 +1017,11 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru qp->vout = butxo->payment.vout; qp->txid2 = butxo->deposit.txid; qp->vout2 = butxo->deposit.vout; - qp->satoshis = butxo->swap_satoshis;// + qp->txfee; + if (coin->etomic[0] == 0) { + qp->satoshis = butxo->swap_satoshis;// + qp->txfee; + } else { + qp->satoshis = LP_basesatoshis(dstr(qp->destsatoshis), price, qp->txfee, qp->desttxfee); + } qp->quotetime = (uint32_t)time(NULL); } else diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index f16efbd20..5c7af583e 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -1201,11 +1201,11 @@ struct basilisk_swap *bitcoin_swapinit(bits256 privkey,uint8_t *pubkey33,bits256 #ifndef NOTETOMIC if (strcmp(alicestr, "ETOMIC") == 0) { swap->I.alicerealsat = swap->I.alicesatoshis; - //swap->I.alicesatoshis = 100000000; + swap->I.alicesatoshis = 100000000; } if (strcmp(bobstr, "ETOMIC") == 0) { swap->I.bobrealsat = swap->I.bobsatoshis; - //swap->I.bobsatoshis = 100000000; + swap->I.bobsatoshis = 100000000; } #endif if ( (swap->I.bobinsurance= (swap->I.bobsatoshis / INSTANTDEX_INSURANCEDIV)) < LP_MIN_TXFEE ) diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index 4e9928aa2..944876a90 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -1192,7 +1192,7 @@ int32_t LP_iseligible(uint64_t *valp,uint64_t *val2p,int32_t iambob,char *symbol return(-1); } destaddr[0] = destaddr2[0] = 0; - if ( coin != 0 && IAMLP != 0 && coin->inactive != 0 ) + if ( coin != 0 && (strcmp(coin->symbol, "ETOMIC") == 0 || (coin->inactive != 0 && IAMLP != 0))) bypass = 1; if ( bypass != 0 ) val = satoshis; diff --git a/start_BEER_OTHER_trade.sh b/start_BEER_OTHER_trade.sh index 23a5acee1..a81500397 100755 --- a/start_BEER_OTHER_trade.sh +++ b/start_BEER_OTHER_trade.sh @@ -1,12 +1,8 @@ #!/bin/bash -docker-compose exec -T clientnode ./setpassphrase -sleep 5 docker-compose exec -T clientnode ./enable -sleep 5 -docker-compose exec -T seednode ./setpassphrase -sleep 5 +sleep 3 docker-compose exec -T seednode ./enable -sleep 5 +sleep 3 docker-compose exec -T seednode ./sell_BEER_OTHER $1 -sleep 5 +sleep 3 docker-compose exec -T clientnode ./buy_BEER_OTHER $1 \ No newline at end of file diff --git a/start_BEER_OTHER_trade_inverted.sh b/start_BEER_OTHER_trade_inverted.sh index 68ef9ab3f..1b0f9d4be 100755 --- a/start_BEER_OTHER_trade_inverted.sh +++ b/start_BEER_OTHER_trade_inverted.sh @@ -1,12 +1,8 @@ #!/bin/bash -docker-compose exec -T clientnode ./setpassphrase -sleep 5 docker-compose exec -T clientnode ./enable -sleep 5 -docker-compose exec -T seednode ./setpassphrase -sleep 5 +sleep 3 docker-compose exec -T seednode ./enable -sleep 5 +sleep 3 docker-compose exec -T clientnode ./buy_BEER_OTHER $1 -sleep 5 +sleep 3 docker-compose exec -T seednode ./sell_BEER_OTHER $1 \ No newline at end of file From c64228ba6ba24b7916db0fc89385af04e58d5a13 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Mon, 18 Jun 2018 11:48:17 +0700 Subject: [PATCH 096/139] #66 Possibly finish using only 1 ETOMIC for ETH/ERC20 trades. --- etomic_build/client/buy_BEER_OTHER | 4 ++-- etomic_build/seed/sell_BEER_OTHER | 4 ++-- iguana/exchanges/LP_ordermatch.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/etomic_build/client/buy_BEER_OTHER b/etomic_build/client/buy_BEER_OTHER index be2acb4da..09dd12fdb 100755 --- a/etomic_build/client/buy_BEER_OTHER +++ b/etomic_build/client/buy_BEER_OTHER @@ -1,4 +1,4 @@ #!/bin/bash source userpass -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"setprice\",\"base\":\"$1\",\"rel\":\"BEER\",\"price\":1}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"sell\",\"base\":\"$1\",\"rel\":\"BEER\",\"basevolume\":0.1,\"price\":1}" \ No newline at end of file +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"setprice\",\"base\":\"$1\",\"rel\":\"BEER\",\"price\":2}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"buy\",\"base\":\"BEER\",\"rel\":\"$1\",\"relvolume\":3,\"price\":2}" diff --git a/etomic_build/seed/sell_BEER_OTHER b/etomic_build/seed/sell_BEER_OTHER index cd11fc044..bc9231bc7 100755 --- a/etomic_build/seed/sell_BEER_OTHER +++ b/etomic_build/seed/sell_BEER_OTHER @@ -1,4 +1,4 @@ #!/bin/bash source userpass -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"setprice\",\"base\":\"BEER\",\"rel\":\"$1\",\"price\":0.9}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"sell\",\"base\":\"BEER\",\"rel\":\"$1\",\"basevolume\":0.1,\"price\":0.9}" \ No newline at end of file +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"setprice\",\"base\":\"BEER\",\"rel\":\"$1\",\"price\":1.9}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"sell\",\"base\":\"BEER\",\"rel\":\"$1\",\"basevolume\":3,\"price\":1.9}" diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index 957e87d45..a37d7b57c 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -190,7 +190,7 @@ double LP_quote_validate(struct LP_utxoinfo *autxo,struct LP_utxoinfo *butxo,str if ( strcmp(autxo->coinaddr,qp->destaddr) != 0 ) return(-10); } - if ( autxo != 0 && destvalue < qp->desttxfee+qp->destsatoshis ) + if ( strcmp(destcoin, "ETOMIC") != 0 && autxo != 0 && destvalue < qp->desttxfee+qp->destsatoshis ) { printf("destvalue %.8f destsatoshis %.8f is too small txfee %.8f?\n",dstr(destvalue),dstr(qp->destsatoshis),dstr(qp->desttxfee)); return(-11); @@ -1616,7 +1616,7 @@ char *LP_autobuy(void *ctx,int32_t fomoflag,char *myipaddr,int32_t mypubsock,cha autxo->swap_satoshis = destsatoshis; //printf("first path dest %.8f from %.8f\n",dstr(destsatoshis),dstr(autxo->swap_satoshis)); } - else if ( autxo->swap_satoshis - desttxfee < destsatoshis ) + else if ( autxo->swap_satoshis - desttxfee < destsatoshis && relcoin->etomic[0] == 0) { autxo->swap_satoshis -= desttxfee; destsatoshis = autxo->swap_satoshis; From 79f7579e5a160ce0edf3567e78a223bde4b94a8a Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Tue, 19 Jun 2018 13:39:46 +0700 Subject: [PATCH 097/139] #79 Add proper ETH address comparison based on cpp-ethereum code. --- etomic_build/client/buy_BEER_OTHER | 4 ++-- etomic_build/coins | 2 +- etomic_build/seed/sell_BEER_OTHER | 4 ++-- iguana/exchanges/LP_etomic.c | 18 +++++++++--------- iguana/exchanges/etomicswap/etomiclib.cpp | 7 +++++++ iguana/exchanges/etomicswap/etomiclib.h | 2 ++ 6 files changed, 23 insertions(+), 14 deletions(-) diff --git a/etomic_build/client/buy_BEER_OTHER b/etomic_build/client/buy_BEER_OTHER index 09dd12fdb..9c4123e44 100755 --- a/etomic_build/client/buy_BEER_OTHER +++ b/etomic_build/client/buy_BEER_OTHER @@ -1,4 +1,4 @@ #!/bin/bash source userpass -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"setprice\",\"base\":\"$1\",\"rel\":\"BEER\",\"price\":2}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"buy\",\"base\":\"BEER\",\"rel\":\"$1\",\"relvolume\":3,\"price\":2}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"setprice\",\"base\":\"$1\",\"rel\":\"BEER\",\"price\":1}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"buy\",\"base\":\"BEER\",\"rel\":\"$1\",\"relvolume\":3,\"price\":1}" diff --git a/etomic_build/coins b/etomic_build/coins index db9100c13..4afe84fea 100755 --- a/etomic_build/coins +++ b/etomic_build/coins @@ -1,3 +1,3 @@ -export coins="[{\"coin\":\"OOT\",\"asset\":\"OOT\",\"rpcport\":12467}, {\"coin\":\"ETH\",\"name\":\"ethereum\",\"etomic\":\"0x0000000000000000000000000000000000000000\",\"rpcport\":80}, {\"coin\":\"EOS\",\"name\":\"EOS\",\"etomic\":\"0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0\",\"rpcport\":80},{\"coin\":\"JST\", \"name\":\"JST\",\"etomic\":\"0xc0eb7aed740e1796992a08962c15661bdeb58003\",\"rpcport\":80},{\"coin\":\"NODEC\",\"name\":\"NODEC\",\"etomic\":\"0x05beb0a9ead354283041a6d35f3b833450fb5680\",\"rpcport\":80,\"decimals\":18},{\"coin\":\"ZOI\",\"name\":\"zoin\",\"rpcport\":8255,\"pubtype\":80,\"p2shtype\":7,\"wiftype\":208,\"txfee\":1000}, {\"coin\": \"PIZZA\",\"asset\": \"PIZZA\",\"rpcport\": 11116},{\"coin\": \"BEER\",\"asset\": \"BEER\",\"rpcport\": 8923}, {\"coin\":\"GRS\",\"name\":\"groestlcoin\",\"rpcport\":1441,\"pubtype\":36,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"XMCC\",\"name\":\"monoeci\",\"confpath\":\"${HOME#}/.monoeciCore/monoeci.conf\",\"rpcport\":24156,\"pubtype\":50,\"p2shtype\":73,\"wiftype\":77,\"txfee\":10000}, {\"coin\":\"BTCH\",\"asset\":\"BTCH\",\"rpcport\":8800},{\"coin\":\"ETOMIC\",\"asset\":\"ETOMIC\",\"rpcport\":10271},{\"coin\":\"AXO\",\"asset\":\"AXO\",\"rpcport\":12927},{\"coin\":\"CRC\",\"name\":\"crowdcoin\",\"confpath\":\"${HOME#}/.crowdcoincore/crowdcoin.conf\",\"rpcport\":11998,\"pubtype\":28,\"p2shtype\":88,\"wiftype\":0,\"txfee\":10000}, {\"coin\":\"VOT\",\"name\":\"votecoin\",\"rpcport\":8232,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"INN\",\"name\":\"innova\",\"confpath\":\"${HOME#}/.innovacore/innova.conf\",\"rpcport\":8818,\"pubtype\":102,\"p2shtype\":20,\"wiftype\":195,\"txfee\":10000}, {\"coin\":\"MOON\",\"name\":\"mooncoin\",\"rpcport\":44663,\"pubtype\":3,\"p2shtype\":22,\"wiftype\":131,\"txfee\":100000}, {\"coin\":\"CRW\",\"name\":\"crown\",\"rpcport\":9341,\"pubtype\":0,\"p2shtype\":28,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"EFL\",\"name\":\"egulden\",\"confpath\":\"${HOME#}/.egulden/coin.conf\",\"rpcport\":21015,\"pubtype\":48,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"GBX\",\"name\":\"gobyte\",\"confpath\":\"${HOME#}/.gobytecore/gobyte.conf\",\"rpcport\":12454,\"pubtype\":38,\"p2shtype\":10,\"wiftype\":198,\"txfee\":10000}, {\"coin\":\"BCO\",\"name\":\"bridgecoin\",\"rpcport\":6332,\"pubtype\":27,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"BLK\",\"name\":\"blackcoin\",\"confpath\":\"${HOME#}/.lore/blackcoin.conf\",\"isPoS\":1,\"rpcport\":15715,\"pubtype\":25,\"p2shtype\":85,\"wiftype\":153,\"txfee\":100000}, {\"coin\":\"BTG\",\"name\":\"bitcoingold\",\"rpcport\":8332,\"pubtype\":38,\"p2shtype\":23,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"BCH\",\"name\":\"bch\",\"rpcport\":33333,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":1000}, {\"coin\":\"ABY\",\"name\":\"applebyte\",\"rpcport\":8607,\"pubtype\":23,\"p2shtype\":5,\"wiftype\":151,\"txfee\":100000}, {\"coin\":\"STAK\",\"name\":\"straks\",\"rpcport\":7574,\"pubtype\":63,\"p2shtype\":5,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"XZC\",\"name\":\"zcoin\",\"rpcport\":8888,\"pubtype\":82,\"p2shtype\":7,\"wiftype\":210,\"txfee\":10000}, {\"coin\":\"QTUM\",\"name\":\"qtum\",\"rpcport\":3889,\"pubtype\":58,\"p2shtype\":50,\"wiftype\":128,\"txfee\":400000}, {\"coin\":\"PURA\",\"name\":\"pura\",\"rpcport\":55555,\"pubtype\":55,\"p2shtype\":16,\"wiftype\":150,\"txfee\":10000}, {\"coin\":\"DSR\",\"name\":\"desire\",\"confpath\":\"${HOME#}/.desirecore/desire.conf\",\"rpcport\":9918,\"pubtype\":30,\"p2shtype\":16,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"MNZ\",\"asset\":\"MNZ\",\"rpcport\":14337},{\"coin\":\"BTCZ\",\"name\":\"bitcoinz\",\"rpcport\":1979,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"MAGA\",\"name\":\"magacoin\",\"rpcport\":5332,\"pubtype\":23,\"p2shtype\":50,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"BSD\",\"name\":\"bitsend\",\"rpcport\":8800,\"pubtype\":102,\"p2shtype\":5,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"IOP\",\"name\":\"IoP\",\"rpcport\":8337,\"pubtype\":117,\"p2shtype\":174,\"wiftype\":49,\"txfee\":10000}, {\"coin\":\"BLOCK\",\"name\":\"blocknetdx\",\"rpcport\":41414,\"pubtype\":26,\"p2shtype\":28,\"wiftype\":154,\"txfee\":10000}, {\"coin\":\"CHIPS\", \"name\": \"chips\", \"rpcport\":57776,\"pubtype\":60, \"p2shtype\":85, \"wiftype\":188, \"txfee\":10000}, {\"coin\":\"888\",\"name\":\"octocoin\",\"rpcport\":22888,\"pubtype\":18,\"p2shtype\":5,\"wiftype\":176,\"txfee\":2000000}, {\"coin\":\"ARG\",\"name\":\"argentum\",\"rpcport\":13581,\"pubtype\":23,\"p2shtype\":5,\"wiftype\":151,\"txfee\":50000}, {\"coin\":\"GLT\",\"name\":\"globaltoken\",\"rpcport\":9320,\"pubtype\":38,\"p2shtype\":5,\"wiftype\":166,\"txfee\":10000}, {\"coin\":\"ZER\",\"name\":\"zero\",\"rpcport\":23801,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":1000}, {\"coin\":\"HODLC\",\"name\":\"hodlcoin\",\"rpcport\":11989,\"pubtype\":40,\"p2shtype\":5,\"wiftype\":168,\"txfee\":5000}, {\"coin\":\"UIS\",\"name\":\"unitus\",\"rpcport\":50604,\"pubtype\":68,\"p2shtype\":10,\"wiftype\":132,\"txfee\":2000000}, {\"coin\":\"HUC\",\"name\":\"huntercoin\",\"rpcport\":8399,\"pubtype\":40,\"p2shtype\":13,\"wiftype\":168,\"txfee\":100000}, {\"coin\":\"BDL\",\"name\":\"bitdeal\",\"rpcport\":9332,\"pubtype\":38,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"ARC\",\"name\":\"arcticcoin\",\"confpath\":\"${HOME#}/.arcticcore/arcticcoin.conf\",\"rpcport\":7208,\"pubtype\":23,\"p2shtype\":8,\"wiftype\":176,\"txfee\":10000}, {\"coin\":\"ZCL\",\"name\":\"zclassic\",\"rpcport\":8023,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":1000}, {\"coin\":\"VIA\",\"name\":\"viacoin\",\"rpcport\":5222,\"pubtype\":71,\"p2shtype\":33,\"wiftype\":199,\"txfee\":100000}, {\"coin\":\"ERC\",\"name\":\"europecoin\",\"rpcport\":11989,\"pubtype\":33,\"p2shtype\":5,\"wiftype\":168,\"txfee\":10000},{\"coin\":\"FAIR\",\"name\":\"faircoin\",\"confpath\":\"${HOME#}/.faircoin2/faircoin.conf\",\"rpcport\":40405,\"pubtype\":95,\"p2shtype\":36,\"wiftype\":223,\"txfee\":1000000}, {\"coin\":\"FLO\",\"name\":\"florincoin\",\"rpcport\":7313,\"pubtype\":35,\"p2shtype\":8,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"SXC\",\"name\":\"sexcoin\",\"rpcport\":9561,\"pubtype\":62,\"p2shtype\":5,\"wiftype\":190,\"txfee\":100000}, {\"coin\":\"CREA\",\"name\":\"creativecoin\",\"rpcport\":17711,\"pubtype\":28,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"TRC\",\"name\":\"terracoin\",\"confpath\":\"${HOME#}/.terracoincore/terracoin.conf\",\"rpcport\":13332,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"BTA\",\"name\":\"bata\",\"rpcport\":5493,\"pubtype\":25,\"p2shtype\":5,\"wiftype\":188,\"txfee\":100000}, {\"coin\":\"SMC\",\"name\":\"smartcoin\",\"rpcport\":58583,\"pubtype\":63,\"p2shtype\":5,\"wiftype\":191,\"txfee\":1000000}, {\"coin\":\"NMC\",\"name\":\"namecoin\",\"rpcport\":8336,\"pubtype\":52,\"p2shtype\":13,\"wiftype\":180,\"txfee\":100000}, {\"coin\":\"NAV\",\"name\":\"navcoin\",\"isPoS\":1,\"confpath\":\"${HOME#}/.navcoin4/navcoin.conf\",\"rpcport\":44444,\"pubtype\":53,\"p2shtype\":85,\"wiftype\":150,\"txfee\":10000}, {\"coin\":\"EMC2\",\"name\":\"einsteinium\",\"rpcport\":41879,\"pubtype\":33,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000},{\"coin\":\"SYS\",\"name\":\"syscoin\",\"rpcport\":8370,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"I0C\",\"name\":\"i0coin\",\"rpcport\":7332,\"pubtype\":105,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"DASH\",\"confpath\":\"${HOME#}/.dashcore/dash.conf\",\"name\":\"dashcore\",\"rpcport\":9998,\"pubtype\":76,\"p2shtype\":16,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"STRAT\", \"name\": \"stratis\", \"active\":0, \"rpcport\":16174,\"pubtype\":63, \"p2shtype\":125, \"wiftype\":191, \"txfee\":10000}, {\"confpath\":\"${HOME#}/.muecore/mue.conf\",\"coin\":\"MUE\",\"name\":\"muecore\",\"rpcport\":29683,\"pubtype\":16,\"p2shtype\":76,\"wiftype\":126,\"txfee\":10000}, {\"coin\":\"MONA\",\"name\":\"monacoin\",\"rpcport\":9402,\"pubtype\":50,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000},{\"coin\":\"XMY\",\"name\":\"myriadcoin\",\"rpcport\":10889,\"pubtype\":50,\"p2shtype\":9,\"wiftype\":178,\"txfee\":5000}, {\"coin\":\"MAC\",\"name\":\"machinecoin\",\"rpcport\":40332,\"pubtype\":50,\"p2shtype\":5,\"wiftype\":178,\"txfee\":100000}, {\"coin\":\"BTX\",\"name\":\"bitcore\",\"rpcport\":8556,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":50000}, {\"coin\":\"XRE\",\"name\":\"revolvercoin\",\"rpcport\":8775,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"LBC\",\"name\":\"lbrycrd\",\"rpcport\":9245,\"pubtype\":85,\"p2shtype\":122,\"wiftype\":28,\"txfee\":10000}, {\"coin\":\"SIB\",\"name\":\"sibcoin\",\"rpcport\":1944,\"pubtype\":63,\"p2shtype\":40,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"VTC\", \"name\":\"vertcoin\", \"rpcport\":5888, \"pubtype\":71, \"p2shtype\":5, \"wiftype\":128, \"txfee\":100000 }, {\"coin\":\"REVS\",\"active\":0, \"asset\":\"REVS\",\"rpcport\":10196}, {\"coin\":\"JUMBLR\",\"active\":0, \"asset\":\"JUMBLR\",\"rpcport\":15106}, {\"coin\":\"DOGE\",\"name\":\"dogecoin\",\"rpcport\":22555,\"pubtype\":30,\"p2shtype\":22,\"wiftype\":158,\"txfee\":100000000}, {\"coin\":\"HUSH\",\"name\":\"hush\",\"rpcport\":8822,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":1000 }, {\"active\":0,\"coin\":\"ZEC\",\"name\":\"zcash\",\"rpcport\":8232,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":10000 }, {\"coin\":\"DGB\",\"name\":\"digibyte\",\"rpcport\":14022,\"pubtype\":30,\"p2shtype\":5,\"wiftype\":128,\"txfee\":100000}, {\"coin\":\"ZET\", \"name\":\"zetacoin\", \"pubtype\":80, \"p2shtype\":9,\"rpcport\":8332, \"wiftype\":224, \"txfee\":10000}, {\"coin\":\"GAME\", \"rpcport\":40001, \"name\":\"gamecredits\", \"pubtype\":38, \"p2shtype\":5, \"wiftype\":166, \"txfee\":100000}, {\"coin\":\"LTC\", \"name\":\"litecoin\", \"rpcport\":9332, \"pubtype\":48, \"p2shtype\":5, \"wiftype\":176, \"txfee\":100000 }, {\"coin\":\"SUPERNET\",\"asset\":\"SUPERNET\",\"rpcport\":11341}, {\"coin\":\"WLC\",\"asset\":\"WLC\",\"rpcport\":12167}, {\"coin\":\"PANGEA\",\"asset\":\"PANGEA\",\"rpcport\":14068}, {\"coin\":\"DEX\",\"asset\":\"DEX\",\"rpcport\":11890}, {\"coin\":\"BET\",\"asset\":\"BET\",\"rpcport\":14250}, {\"coin\":\"CRYPTO\",\"asset\":\"CRYPTO\",\"rpcport\":8516}, {\"coin\":\"HODL\",\"asset\":\"HODL\",\"rpcport\":14431}, {\"coin\":\"MSHARK\",\"asset\":\"MSHARK\",\"rpcport\":8846}, {\"coin\":\"BOTS\",\"asset\":\"BOTS\",\"rpcport\":11964}, {\"coin\":\"MGW\",\"asset\":\"MGW\",\"rpcport\":12386}, {\"coin\":\"COQUI\",\"asset\":\"COQUI\",\"rpcport\":14276}, {\"coin\":\"KV\",\"asset\":\"KV\",\"rpcport\":8299}, {\"coin\":\"CEAL\",\"asset\":\"CEAL\",\"rpcport\":11116}, {\"coin\":\"MESH\",\"asset\":\"MESH\",\"rpcport\":9455}]" +export coins="[{\"coin\":\"OOT\",\"asset\":\"OOT\",\"rpcport\":12467}, {\"coin\":\"ETH\",\"name\":\"ethereum\",\"etomic\":\"0x0000000000000000000000000000000000000000\",\"rpcport\":80}, {\"coin\":\"EOS\",\"name\":\"EOS\",\"etomic\":\"0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0\",\"rpcport\":80},{\"coin\":\"JST\", \"name\":\"JST\",\"etomic\":\"0xc0eb7AeD740E1796992A08962c15661bDEB58003\",\"rpcport\":80},{\"coin\":\"NODEC\",\"name\":\"NODEC\",\"etomic\":\"0x05beb0a9ead354283041a6d35f3b833450fb5680\",\"rpcport\":80,\"decimals\":18},{\"coin\":\"ZOI\",\"name\":\"zoin\",\"rpcport\":8255,\"pubtype\":80,\"p2shtype\":7,\"wiftype\":208,\"txfee\":1000}, {\"coin\": \"PIZZA\",\"asset\": \"PIZZA\",\"rpcport\": 11116},{\"coin\": \"BEER\",\"asset\": \"BEER\",\"rpcport\": 8923}, {\"coin\":\"GRS\",\"name\":\"groestlcoin\",\"rpcport\":1441,\"pubtype\":36,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"XMCC\",\"name\":\"monoeci\",\"confpath\":\"${HOME#}/.monoeciCore/monoeci.conf\",\"rpcport\":24156,\"pubtype\":50,\"p2shtype\":73,\"wiftype\":77,\"txfee\":10000}, {\"coin\":\"BTCH\",\"asset\":\"BTCH\",\"rpcport\":8800},{\"coin\":\"ETOMIC\",\"asset\":\"ETOMIC\",\"rpcport\":10271},{\"coin\":\"AXO\",\"asset\":\"AXO\",\"rpcport\":12927},{\"coin\":\"CRC\",\"name\":\"crowdcoin\",\"confpath\":\"${HOME#}/.crowdcoincore/crowdcoin.conf\",\"rpcport\":11998,\"pubtype\":28,\"p2shtype\":88,\"wiftype\":0,\"txfee\":10000}, {\"coin\":\"VOT\",\"name\":\"votecoin\",\"rpcport\":8232,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"INN\",\"name\":\"innova\",\"confpath\":\"${HOME#}/.innovacore/innova.conf\",\"rpcport\":8818,\"pubtype\":102,\"p2shtype\":20,\"wiftype\":195,\"txfee\":10000}, {\"coin\":\"MOON\",\"name\":\"mooncoin\",\"rpcport\":44663,\"pubtype\":3,\"p2shtype\":22,\"wiftype\":131,\"txfee\":100000}, {\"coin\":\"CRW\",\"name\":\"crown\",\"rpcport\":9341,\"pubtype\":0,\"p2shtype\":28,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"EFL\",\"name\":\"egulden\",\"confpath\":\"${HOME#}/.egulden/coin.conf\",\"rpcport\":21015,\"pubtype\":48,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"GBX\",\"name\":\"gobyte\",\"confpath\":\"${HOME#}/.gobytecore/gobyte.conf\",\"rpcport\":12454,\"pubtype\":38,\"p2shtype\":10,\"wiftype\":198,\"txfee\":10000}, {\"coin\":\"BCO\",\"name\":\"bridgecoin\",\"rpcport\":6332,\"pubtype\":27,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"BLK\",\"name\":\"blackcoin\",\"confpath\":\"${HOME#}/.lore/blackcoin.conf\",\"isPoS\":1,\"rpcport\":15715,\"pubtype\":25,\"p2shtype\":85,\"wiftype\":153,\"txfee\":100000}, {\"coin\":\"BTG\",\"name\":\"bitcoingold\",\"rpcport\":8332,\"pubtype\":38,\"p2shtype\":23,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"BCH\",\"name\":\"bch\",\"rpcport\":33333,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":1000}, {\"coin\":\"ABY\",\"name\":\"applebyte\",\"rpcport\":8607,\"pubtype\":23,\"p2shtype\":5,\"wiftype\":151,\"txfee\":100000}, {\"coin\":\"STAK\",\"name\":\"straks\",\"rpcport\":7574,\"pubtype\":63,\"p2shtype\":5,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"XZC\",\"name\":\"zcoin\",\"rpcport\":8888,\"pubtype\":82,\"p2shtype\":7,\"wiftype\":210,\"txfee\":10000}, {\"coin\":\"QTUM\",\"name\":\"qtum\",\"rpcport\":3889,\"pubtype\":58,\"p2shtype\":50,\"wiftype\":128,\"txfee\":400000}, {\"coin\":\"PURA\",\"name\":\"pura\",\"rpcport\":55555,\"pubtype\":55,\"p2shtype\":16,\"wiftype\":150,\"txfee\":10000}, {\"coin\":\"DSR\",\"name\":\"desire\",\"confpath\":\"${HOME#}/.desirecore/desire.conf\",\"rpcport\":9918,\"pubtype\":30,\"p2shtype\":16,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"MNZ\",\"asset\":\"MNZ\",\"rpcport\":14337},{\"coin\":\"BTCZ\",\"name\":\"bitcoinz\",\"rpcport\":1979,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"MAGA\",\"name\":\"magacoin\",\"rpcport\":5332,\"pubtype\":23,\"p2shtype\":50,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"BSD\",\"name\":\"bitsend\",\"rpcport\":8800,\"pubtype\":102,\"p2shtype\":5,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"IOP\",\"name\":\"IoP\",\"rpcport\":8337,\"pubtype\":117,\"p2shtype\":174,\"wiftype\":49,\"txfee\":10000}, {\"coin\":\"BLOCK\",\"name\":\"blocknetdx\",\"rpcport\":41414,\"pubtype\":26,\"p2shtype\":28,\"wiftype\":154,\"txfee\":10000}, {\"coin\":\"CHIPS\", \"name\": \"chips\", \"rpcport\":57776,\"pubtype\":60, \"p2shtype\":85, \"wiftype\":188, \"txfee\":10000}, {\"coin\":\"888\",\"name\":\"octocoin\",\"rpcport\":22888,\"pubtype\":18,\"p2shtype\":5,\"wiftype\":176,\"txfee\":2000000}, {\"coin\":\"ARG\",\"name\":\"argentum\",\"rpcport\":13581,\"pubtype\":23,\"p2shtype\":5,\"wiftype\":151,\"txfee\":50000}, {\"coin\":\"GLT\",\"name\":\"globaltoken\",\"rpcport\":9320,\"pubtype\":38,\"p2shtype\":5,\"wiftype\":166,\"txfee\":10000}, {\"coin\":\"ZER\",\"name\":\"zero\",\"rpcport\":23801,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":1000}, {\"coin\":\"HODLC\",\"name\":\"hodlcoin\",\"rpcport\":11989,\"pubtype\":40,\"p2shtype\":5,\"wiftype\":168,\"txfee\":5000}, {\"coin\":\"UIS\",\"name\":\"unitus\",\"rpcport\":50604,\"pubtype\":68,\"p2shtype\":10,\"wiftype\":132,\"txfee\":2000000}, {\"coin\":\"HUC\",\"name\":\"huntercoin\",\"rpcport\":8399,\"pubtype\":40,\"p2shtype\":13,\"wiftype\":168,\"txfee\":100000}, {\"coin\":\"BDL\",\"name\":\"bitdeal\",\"rpcport\":9332,\"pubtype\":38,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"ARC\",\"name\":\"arcticcoin\",\"confpath\":\"${HOME#}/.arcticcore/arcticcoin.conf\",\"rpcport\":7208,\"pubtype\":23,\"p2shtype\":8,\"wiftype\":176,\"txfee\":10000}, {\"coin\":\"ZCL\",\"name\":\"zclassic\",\"rpcport\":8023,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":1000}, {\"coin\":\"VIA\",\"name\":\"viacoin\",\"rpcport\":5222,\"pubtype\":71,\"p2shtype\":33,\"wiftype\":199,\"txfee\":100000}, {\"coin\":\"ERC\",\"name\":\"europecoin\",\"rpcport\":11989,\"pubtype\":33,\"p2shtype\":5,\"wiftype\":168,\"txfee\":10000},{\"coin\":\"FAIR\",\"name\":\"faircoin\",\"confpath\":\"${HOME#}/.faircoin2/faircoin.conf\",\"rpcport\":40405,\"pubtype\":95,\"p2shtype\":36,\"wiftype\":223,\"txfee\":1000000}, {\"coin\":\"FLO\",\"name\":\"florincoin\",\"rpcport\":7313,\"pubtype\":35,\"p2shtype\":8,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"SXC\",\"name\":\"sexcoin\",\"rpcport\":9561,\"pubtype\":62,\"p2shtype\":5,\"wiftype\":190,\"txfee\":100000}, {\"coin\":\"CREA\",\"name\":\"creativecoin\",\"rpcport\":17711,\"pubtype\":28,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"TRC\",\"name\":\"terracoin\",\"confpath\":\"${HOME#}/.terracoincore/terracoin.conf\",\"rpcport\":13332,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"BTA\",\"name\":\"bata\",\"rpcport\":5493,\"pubtype\":25,\"p2shtype\":5,\"wiftype\":188,\"txfee\":100000}, {\"coin\":\"SMC\",\"name\":\"smartcoin\",\"rpcport\":58583,\"pubtype\":63,\"p2shtype\":5,\"wiftype\":191,\"txfee\":1000000}, {\"coin\":\"NMC\",\"name\":\"namecoin\",\"rpcport\":8336,\"pubtype\":52,\"p2shtype\":13,\"wiftype\":180,\"txfee\":100000}, {\"coin\":\"NAV\",\"name\":\"navcoin\",\"isPoS\":1,\"confpath\":\"${HOME#}/.navcoin4/navcoin.conf\",\"rpcport\":44444,\"pubtype\":53,\"p2shtype\":85,\"wiftype\":150,\"txfee\":10000}, {\"coin\":\"EMC2\",\"name\":\"einsteinium\",\"rpcport\":41879,\"pubtype\":33,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000},{\"coin\":\"SYS\",\"name\":\"syscoin\",\"rpcport\":8370,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"I0C\",\"name\":\"i0coin\",\"rpcport\":7332,\"pubtype\":105,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"DASH\",\"confpath\":\"${HOME#}/.dashcore/dash.conf\",\"name\":\"dashcore\",\"rpcport\":9998,\"pubtype\":76,\"p2shtype\":16,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"STRAT\", \"name\": \"stratis\", \"active\":0, \"rpcport\":16174,\"pubtype\":63, \"p2shtype\":125, \"wiftype\":191, \"txfee\":10000}, {\"confpath\":\"${HOME#}/.muecore/mue.conf\",\"coin\":\"MUE\",\"name\":\"muecore\",\"rpcport\":29683,\"pubtype\":16,\"p2shtype\":76,\"wiftype\":126,\"txfee\":10000}, {\"coin\":\"MONA\",\"name\":\"monacoin\",\"rpcport\":9402,\"pubtype\":50,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000},{\"coin\":\"XMY\",\"name\":\"myriadcoin\",\"rpcport\":10889,\"pubtype\":50,\"p2shtype\":9,\"wiftype\":178,\"txfee\":5000}, {\"coin\":\"MAC\",\"name\":\"machinecoin\",\"rpcport\":40332,\"pubtype\":50,\"p2shtype\":5,\"wiftype\":178,\"txfee\":100000}, {\"coin\":\"BTX\",\"name\":\"bitcore\",\"rpcport\":8556,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":50000}, {\"coin\":\"XRE\",\"name\":\"revolvercoin\",\"rpcport\":8775,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"LBC\",\"name\":\"lbrycrd\",\"rpcport\":9245,\"pubtype\":85,\"p2shtype\":122,\"wiftype\":28,\"txfee\":10000}, {\"coin\":\"SIB\",\"name\":\"sibcoin\",\"rpcport\":1944,\"pubtype\":63,\"p2shtype\":40,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"VTC\", \"name\":\"vertcoin\", \"rpcport\":5888, \"pubtype\":71, \"p2shtype\":5, \"wiftype\":128, \"txfee\":100000 }, {\"coin\":\"REVS\",\"active\":0, \"asset\":\"REVS\",\"rpcport\":10196}, {\"coin\":\"JUMBLR\",\"active\":0, \"asset\":\"JUMBLR\",\"rpcport\":15106}, {\"coin\":\"DOGE\",\"name\":\"dogecoin\",\"rpcport\":22555,\"pubtype\":30,\"p2shtype\":22,\"wiftype\":158,\"txfee\":100000000}, {\"coin\":\"HUSH\",\"name\":\"hush\",\"rpcport\":8822,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":1000 }, {\"active\":0,\"coin\":\"ZEC\",\"name\":\"zcash\",\"rpcport\":8232,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":10000 }, {\"coin\":\"DGB\",\"name\":\"digibyte\",\"rpcport\":14022,\"pubtype\":30,\"p2shtype\":5,\"wiftype\":128,\"txfee\":100000}, {\"coin\":\"ZET\", \"name\":\"zetacoin\", \"pubtype\":80, \"p2shtype\":9,\"rpcport\":8332, \"wiftype\":224, \"txfee\":10000}, {\"coin\":\"GAME\", \"rpcport\":40001, \"name\":\"gamecredits\", \"pubtype\":38, \"p2shtype\":5, \"wiftype\":166, \"txfee\":100000}, {\"coin\":\"LTC\", \"name\":\"litecoin\", \"rpcport\":9332, \"pubtype\":48, \"p2shtype\":5, \"wiftype\":176, \"txfee\":100000 }, {\"coin\":\"SUPERNET\",\"asset\":\"SUPERNET\",\"rpcport\":11341}, {\"coin\":\"WLC\",\"asset\":\"WLC\",\"rpcport\":12167}, {\"coin\":\"PANGEA\",\"asset\":\"PANGEA\",\"rpcport\":14068}, {\"coin\":\"DEX\",\"asset\":\"DEX\",\"rpcport\":11890}, {\"coin\":\"BET\",\"asset\":\"BET\",\"rpcport\":14250}, {\"coin\":\"CRYPTO\",\"asset\":\"CRYPTO\",\"rpcport\":8516}, {\"coin\":\"HODL\",\"asset\":\"HODL\",\"rpcport\":14431}, {\"coin\":\"MSHARK\",\"asset\":\"MSHARK\",\"rpcport\":8846}, {\"coin\":\"BOTS\",\"asset\":\"BOTS\",\"rpcport\":11964}, {\"coin\":\"MGW\",\"asset\":\"MGW\",\"rpcport\":12386}, {\"coin\":\"COQUI\",\"asset\":\"COQUI\",\"rpcport\":14276}, {\"coin\":\"KV\",\"asset\":\"KV\",\"rpcport\":8299}, {\"coin\":\"CEAL\",\"asset\":\"CEAL\",\"rpcport\":11116}, {\"coin\":\"MESH\",\"asset\":\"MESH\",\"rpcport\":9455}]" #, {\"coin\":\"AUD\",\"asset\":\"AUD\",\"rpcport\":8045}, {\"coin\":\"BGN\",\"asset\":\"BGN\",\"rpcport\":9110}, {\"coin\":\"CAD\",\"asset\":\"CAD\",\"rpcport\":8720}, {\"coin\":\"CHF\",\"asset\":\"CHF\",\"rpcport\":15312}, {\"coin\":\"CNY\",\"asset\":\"CNY\",\"rpcport\":10384}, {\"coin\":\"CZK\",\"asset\":\"CZK\",\"rpcport\":9482}, {\"coin\":\"DKK\",\"asset\":\"DKK\",\"rpcport\":13830}, {\"coin\":\"EUR\",\"asset\":\"EUR\",\"rpcport\":8065}, {\"coin\":\"GBP\",\"asset\":\"GBP\",\"rpcport\":11505}, {\"coin\":\"HKD\",\"asset\":\"HKD\",\"rpcport\":15409}, {\"coin\":\"HRK\",\"asset\":\"HRK\",\"rpcport\":12617}, {\"coin\":\"HUF\",\"asset\":\"HUF\",\"rpcport\":13699}, {\"coin\":\"IDR\",\"asset\":\"IDR\",\"rpcport\":14459}, {\"coin\":\"ILS\",\"asset\":\"ILS\",\"rpcport\":14638}, {\"coin\":\"INR\",\"asset\":\"INR\",\"rpcport\":10536}, {\"coin\":\"JPY\",\"asset\":\"JPY\",\"rpcport\":13145}, {\"coin\":\"KRW\",\"asset\":\"KRW\",\"rpcport\":14020}, {\"coin\":\"MXN\",\"asset\":\"MXN\",\"rpcport\":13970}, {\"coin\":\"MYR\",\"asset\":\"MYR\",\"rpcport\":10688}, {\"coin\":\"NOK\",\"asset\":\"NOK\",\"rpcport\":11588}, {\"coin\":\"NZD\",\"asset\":\"NZD\",\"rpcport\":10915}, {\"coin\":\"PHP\",\"asset\":\"PHP\",\"rpcport\":11181}, {\"coin\":\"PLN\",\"asset\":\"PLN\",\"rpcport\":13493}, {\"coin\":\"BRL\",\"asset\":\"BRL\",\"rpcport\":9914}, {\"coin\":\"RON\",\"asset\":\"RON\",\"rpcport\":8675}, {\"coin\":\"RUB\",\"asset\":\"RUB\",\"rpcport\":8199}, {\"coin\":\"SEK\",\"asset\":\"SEK\",\"rpcport\":11447}, {\"coin\":\"SGD\",\"asset\":\"SGD\",\"rpcport\":14475}, {\"coin\":\"THB\",\"asset\":\"THB\",\"rpcport\":11847}, {\"coin\":\"TRY\",\"asset\":\"TRY\",\"rpcport\":13924}, {\"coin\":\"USD\",\"asset\":\"USD\",\"rpcport\":13967}, {\"coin\":\"ZAR\",\"asset\":\"ZAR\",\"rpcport\":15160}]" #{\"coin\":\"PIVX\",\"name\":\"pivx\",\"rpcport\":51473,\"pubtype\":30,\"p2shtype\":13,\"wiftype\":212,\"txfee\":10000}, diff --git a/etomic_build/seed/sell_BEER_OTHER b/etomic_build/seed/sell_BEER_OTHER index bc9231bc7..676404d15 100755 --- a/etomic_build/seed/sell_BEER_OTHER +++ b/etomic_build/seed/sell_BEER_OTHER @@ -1,4 +1,4 @@ #!/bin/bash source userpass -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"setprice\",\"base\":\"BEER\",\"rel\":\"$1\",\"price\":1.9}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"sell\",\"base\":\"BEER\",\"rel\":\"$1\",\"basevolume\":3,\"price\":1.9}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"setprice\",\"base\":\"BEER\",\"rel\":\"$1\",\"price\":0.9}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"sell\",\"base\":\"BEER\",\"rel\":\"$1\",\"basevolume\":3,\"price\":0.9}" diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index 9d0a7e468..8c03e7810 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -60,7 +60,7 @@ uint8_t LP_etomic_verify_alice_fee(struct basilisk_swap *swap) return(0); } EthTxData data = getEthTxData(swap->otherfee.I.ethTxid); - if (strcmp(data.from, swap->I.etomicdest) != 0) { + if (compareAddresses(data.from, swap->I.etomicdest) == 0) { printf("Alice fee tx %s was sent from wrong address %s\n", swap->otherfee.I.ethTxid, data.from); return(0); } @@ -68,7 +68,7 @@ uint8_t LP_etomic_verify_alice_fee(struct basilisk_swap *swap) char dexaddr[50]; LP_etomic_pubkeystr_to_addr(INSTANTDEX_PUBKEY, dexaddr); if ( strcmp(swap->I.alicestr,"ETH") == 0 ) { - if (strcmp(data.to, dexaddr) != 0) { + if (compareAddresses(data.to, dexaddr) == 0) { printf("Alice fee %s was sent to wrong address %s\n", swap->otherfee.I.ethTxid, data.to); return(0); } @@ -81,7 +81,7 @@ uint8_t LP_etomic_verify_alice_fee(struct basilisk_swap *swap) } else { struct iguana_info *alicecoin = LP_coinfind(swap->I.alicestr); - if (strcmp(data.to, swap->I.alicetomic) != 0) { + if (compareAddresses(data.to, swap->I.alicetomic) == 0) { printf("Alice ERC20 fee %s token address %s is not equal to expected %s\n", swap->otherfee.I.ethTxid, data.to, swap->I.alicetomic); return(0); } @@ -159,11 +159,11 @@ uint8_t LP_etomic_verify_alice_payment(struct basilisk_swap *swap, char *txId) return(0); } EthTxData data = getEthTxData(txId); - if (strcmp(data.to, ETOMIC_ALICECONTRACT) != 0) { + if (compareAddresses(data.to, ETOMIC_ALICECONTRACT) == 0) { printf("Alice payment %s was sent to wrong address %s\n", txId, data.to); return(0); } - if (strcmp(data.from, swap->I.etomicdest) != 0) { + if (compareAddresses(data.from, swap->I.etomicdest) == 0) { printf("Alice payment %s was done from wrong address %s\n", txId, data.from); return(0); } @@ -367,11 +367,11 @@ uint8_t LP_etomic_verify_bob_deposit(struct basilisk_swap *swap, char *txId) return(0); } EthTxData data = getEthTxData(txId); - if (strcmp(data.to, ETOMIC_BOBCONTRACT) != 0) { + if (compareAddresses(data.to, ETOMIC_BOBCONTRACT) == 0) { printf("Bob deposit txid %s was sent to wrong address %s\n", txId, data.to); return(0); } - if (strcmp(data.from, swap->I.etomicsrc) != 0) { + if (compareAddresses(data.from, swap->I.etomicsrc) == 0) { printf("Bob deposit txid %s was sent from wrong address %s\n", txId, data.from); return(0); } @@ -523,10 +523,10 @@ uint8_t LP_etomic_verify_bob_payment(struct basilisk_swap *swap, char *txId) return 0; } EthTxData data = getEthTxData(txId); - if (strcmp(data.to, ETOMIC_BOBCONTRACT) != 0) { + if (compareAddresses(data.to, ETOMIC_BOBCONTRACT) == 0) { printf("Bob payment %s was sent to wrong address %s\n", txId, data.to); } - if (strcmp(data.from, swap->I.etomicsrc) != 0) { + if (compareAddresses(data.from, swap->I.etomicsrc) == 0) { printf("Bob payment %s was sent from wrong address %s\n", txId, data.from); } BobSendsEthPaymentInput input; diff --git a/iguana/exchanges/etomicswap/etomiclib.cpp b/iguana/exchanges/etomicswap/etomiclib.cpp index b1bcbe7c1..68e49f9d8 100644 --- a/iguana/exchanges/etomicswap/etomiclib.cpp +++ b/iguana/exchanges/etomicswap/etomiclib.cpp @@ -828,3 +828,10 @@ uint8_t bobPaymentStatus(char *paymentId) free(hexStatus); return status; } + +uint8_t compareAddresses(char *address1, char *address2) +{ + auto addr_bytes_1 = jsToAddress(address1); + auto addr_bytes_2 = jsToAddress(address2); + return static_cast(addr_bytes_1 == addr_bytes_2); +} diff --git a/iguana/exchanges/etomicswap/etomiclib.h b/iguana/exchanges/etomicswap/etomiclib.h index db1547f4e..bfd0b81d3 100644 --- a/iguana/exchanges/etomicswap/etomiclib.h +++ b/iguana/exchanges/etomicswap/etomiclib.h @@ -213,6 +213,8 @@ uint64_t estimate_erc20_gas( uint8_t decimals ); +uint8_t compareAddresses(char *address1, char *address2); + #ifdef __cplusplus } #endif From 6db6af6fe4d7adca45c75494007f227cd4f46bb3 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Wed, 20 Jun 2018 15:16:54 +0700 Subject: [PATCH 098/139] #81 Add ETH address validation upon coin enable and eth_withdraw. --- iguana/exchanges/LP_commands.c | 4 ++++ iguana/exchanges/LP_transaction.c | 5 +++++ iguana/exchanges/etomicswap/etomiclib.cpp | 7 +++++++ iguana/exchanges/etomicswap/etomiclib.h | 1 + 4 files changed, 17 insertions(+) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index 4e2e08ba6..147e777b9 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -608,6 +608,10 @@ version\n\ } if (ptr->etomic[0] != 0) { + if (isValidAddress(ptr->etomic) == 0) { + return(clonestr("{\"error\":\"'etomic' field is not valid address!\"}")); + } + struct iguana_info *etomic_coin = LP_coinsearch("ETOMIC"); if (etomic_coin->inactive != 0) { return(clonestr("{\"error\":\"Enable ETOMIC first to use ETH/ERC20!\"}")); diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index ef27a86a0..69fece8b6 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -2095,6 +2095,11 @@ char *LP_eth_withdraw(struct iguana_info *coin,cJSON *argjson) if (dest_addr == NULL) { return(clonestr("{\"error\":\"param 'to' is required!\"}")); } + + if (isValidAddress(dest_addr) == 0) { + return(clonestr("{\"error\":\"'to' address is not valid!\"}")); + } + amount = jdouble(argjson, "amount") * 100000000; if (amount == 0) { return(clonestr("{\"error\":\"'amount' is not set or equal to zero!\"}")); diff --git a/iguana/exchanges/etomicswap/etomiclib.cpp b/iguana/exchanges/etomicswap/etomiclib.cpp index 68e49f9d8..921a89342 100644 --- a/iguana/exchanges/etomicswap/etomiclib.cpp +++ b/iguana/exchanges/etomicswap/etomiclib.cpp @@ -4,6 +4,7 @@ #include "etomiclib.h" #include "etomiccurl.h" #include +#include #include #include #include @@ -835,3 +836,9 @@ uint8_t compareAddresses(char *address1, char *address2) auto addr_bytes_2 = jsToAddress(address2); return static_cast(addr_bytes_1 == addr_bytes_2); } + +uint8_t isValidAddress(char *address) +{ + std::regex r("^(0x|0X)?[a-fA-F0-9]{40}$"); + return static_cast(std::regex_match(address, r)); +} diff --git a/iguana/exchanges/etomicswap/etomiclib.h b/iguana/exchanges/etomicswap/etomiclib.h index bfd0b81d3..78a6e3ad3 100644 --- a/iguana/exchanges/etomicswap/etomiclib.h +++ b/iguana/exchanges/etomicswap/etomiclib.h @@ -214,6 +214,7 @@ uint64_t estimate_erc20_gas( ); uint8_t compareAddresses(char *address1, char *address2); +uint8_t isValidAddress(char *address); #ifdef __cplusplus } From b8890ba2e9d621d10d13051222c9db9d41797dad Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Wed, 20 Jun 2018 15:48:05 +0700 Subject: [PATCH 099/139] #80 Set ERC20 decimals upon coin enable to avoid repetitive requests. --- iguana/exchanges/LP_commands.c | 7 +++++++ iguana/exchanges/etomicswap/etomiclib.cpp | 12 ++++++++++++ iguana/exchanges/etomicswap/etomiclib.h | 1 + 3 files changed, 20 insertions(+) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index 147e777b9..7714e2d63 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -616,6 +616,13 @@ version\n\ if (etomic_coin->inactive != 0) { return(clonestr("{\"error\":\"Enable ETOMIC first to use ETH/ERC20!\"}")); } + + if (ptr->decimals == 0 && strcmp(coin, "ETH") != 0) { + ptr->decimals = getErc20DecimalsZeroOnError(ptr->etomic); + if (ptr->decimals == 0) { + return(clonestr("{\"error\":\"Could not get token decimals or token has zero decimals which is not supported!\"}")); + } + } } #endif if ( LP_conflicts_find(ptr) == 0 ) diff --git a/iguana/exchanges/etomicswap/etomiclib.cpp b/iguana/exchanges/etomicswap/etomiclib.cpp index 921a89342..ab60510fd 100644 --- a/iguana/exchanges/etomicswap/etomiclib.cpp +++ b/iguana/exchanges/etomicswap/etomiclib.cpp @@ -636,6 +636,18 @@ uint8_t getErc20Decimals(char *tokenAddress) return decimals; } +uint8_t getErc20DecimalsZeroOnError(char *tokenAddress) +{ + char* hexDecimals = ethCall(tokenAddress, "0x313ce567"); + if (hexDecimals != NULL) { + auto decimals = (uint8_t) strtol(hexDecimals, NULL, 0); + free(hexDecimals); + return decimals; + } else { + return 0; + } +} + void uint8arrayToHex(char *dest, uint8_t *input, int len) { strcpy(dest, "0x"); diff --git a/iguana/exchanges/etomicswap/etomiclib.h b/iguana/exchanges/etomicswap/etomiclib.h index 78a6e3ad3..3557e4191 100644 --- a/iguana/exchanges/etomicswap/etomiclib.h +++ b/iguana/exchanges/etomicswap/etomiclib.h @@ -215,6 +215,7 @@ uint64_t estimate_erc20_gas( uint8_t compareAddresses(char *address1, char *address2); uint8_t isValidAddress(char *address); +uint8_t getErc20DecimalsZeroOnError(char *tokenAddress); #ifdef __cplusplus } From 437d9b23dfcac0590e7632e980b8eee7ffcb690f Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Wed, 20 Jun 2018 17:23:51 +0700 Subject: [PATCH 100/139] #82 Use prev ETH/ERC20 balance on portfolio in case of request error. --- iguana/exchanges/LP_coins.c | 3 ++- iguana/exchanges/LP_etomic.c | 6 +++--- iguana/exchanges/LP_etomic.h | 2 +- iguana/exchanges/LP_portfolio.c | 8 +++++++- iguana/exchanges/LP_rpc.c | 3 ++- iguana/exchanges/LP_signatures.c | 3 ++- iguana/exchanges/LP_swap.c | 6 ++++-- iguana/exchanges/LP_utxo.c | 3 ++- iguana/exchanges/etomicswap/etomiclib.cpp | 8 +++++--- iguana/exchanges/etomicswap/etomiclib.h | 4 ++-- 10 files changed, 30 insertions(+), 16 deletions(-) diff --git a/iguana/exchanges/LP_coins.c b/iguana/exchanges/LP_coins.c index e413ffa64..ce948fa95 100644 --- a/iguana/exchanges/LP_coins.c +++ b/iguana/exchanges/LP_coins.c @@ -251,8 +251,9 @@ cJSON *LP_coinjson(struct iguana_info *coin,int32_t showwif) } #ifndef NOTETOMIC else if (coin->etomic[0] != 0) { + int error = 0; if (coin->inactive == 0) { - balance = LP_etomic_get_balance(coin, coin->smartaddr); + balance = LP_etomic_get_balance(coin, coin->smartaddr, &error); } else { balance = 0; } diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index 8c03e7810..3b7c7aa8f 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -773,7 +773,7 @@ uint8_t LP_etomic_is_empty_tx_id(char *txId) return 0; } -uint64_t LP_etomic_get_balance(struct iguana_info *coin, char *coinaddr) +uint64_t LP_etomic_get_balance(struct iguana_info *coin, char *coinaddr, int *error) { if (coin->etomic[0] == 0) { printf("Trying to get etomic balance for non-etomic coin %s!", coin->symbol); @@ -781,8 +781,8 @@ uint64_t LP_etomic_get_balance(struct iguana_info *coin, char *coinaddr) } if (strcmp(coin->symbol, "ETH") == 0) { - return getEthBalance(coinaddr); + return getEthBalance(coinaddr, error); } else { - return getErc20BalanceSatoshi(coinaddr, coin->etomic, coin->decimals); + return getErc20BalanceSatoshi(coinaddr, coin->etomic, coin->decimals, error); } } diff --git a/iguana/exchanges/LP_etomic.h b/iguana/exchanges/LP_etomic.h index af5de5f63..8a744cb3d 100644 --- a/iguana/exchanges/LP_etomic.h +++ b/iguana/exchanges/LP_etomic.h @@ -49,7 +49,7 @@ int32_t LP_etomic_pub2addr(char *coinaddr,uint8_t pub64[64]); uint8_t LP_etomic_is_empty_tx_id(char *txId); -uint64_t LP_etomic_get_balance(struct iguana_info *coin, char *coinaddr); +uint64_t LP_etomic_get_balance(struct iguana_info *coin, char *coinaddr, int *error); void LP_etomic_pubkeystr_to_addr(char *pubkey, char *output); diff --git a/iguana/exchanges/LP_portfolio.c b/iguana/exchanges/LP_portfolio.c index b38a08c89..dda09ec54 100644 --- a/iguana/exchanges/LP_portfolio.c +++ b/iguana/exchanges/LP_portfolio.c @@ -98,7 +98,13 @@ uint64_t LP_balance(uint64_t *valuep,int32_t iambob,char *symbol,char *coinaddr) #ifndef NOTETOMIC struct iguana_info *coin = LP_coinfind(symbol); if (coin->etomic[0] != 0 && coin->inactive == 0) { - valuesum = LP_etomic_get_balance(coin, coinaddr); + int error = 0; + uint64_t etomic_balance = LP_etomic_get_balance(coin, coinaddr, &error); + if (error == 0) { + valuesum = etomic_balance; + } else { + valuesum = *valuep; + } } else #endif if ( (array= LP_listunspent(symbol,coinaddr,zero,zero)) != 0 ) diff --git a/iguana/exchanges/LP_rpc.c b/iguana/exchanges/LP_rpc.c index 9c1bca6c2..800214ba4 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -139,7 +139,8 @@ uint64_t LP_RTsmartbalance(struct iguana_info *coin) { #ifndef NOTETOMIC if (coin->etomic[0] != 0) { - return LP_etomic_get_balance(coin, coin->smartaddr); + int error = 0; + return LP_etomic_get_balance(coin, coin->smartaddr, &error); } #endif cJSON *array,*item; char buf[512],*retstr; int32_t i,n; uint64_t valuesum,value; bits256 zero; diff --git a/iguana/exchanges/LP_signatures.c b/iguana/exchanges/LP_signatures.c index 2d8e45750..a280ae9d4 100644 --- a/iguana/exchanges/LP_signatures.c +++ b/iguana/exchanges/LP_signatures.c @@ -444,7 +444,8 @@ char *LP_pricepings(void *ctx,char *myipaddr,int32_t pubsock,char *base,char *re jaddnum(reqjson,"credits",dstr(ap->instantdex_credits)); #ifndef NOTETOMIC if (basecoin->etomic[0] != 0) { - uint64_t etomic_coin_balance = LP_etomic_get_balance(basecoin, basecoin->smartaddr); + int error = 0; + uint64_t etomic_coin_balance = LP_etomic_get_balance(basecoin, basecoin->smartaddr, &error); jaddstr(reqjson,"utxocoin","ETH_OR_ERC20"); jaddnum(reqjson,"bal",dstr(etomic_coin_balance)); jaddnum(reqjson,"min",dstr(etomic_coin_balance)); diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index 5c7af583e..8a1efb9bf 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -856,7 +856,8 @@ void LP_bobloop(void *_swap) alicewaittimeout = LP_calc_waittimeout(alicestr); #ifndef NOTETOMIC if (swap->I.bobtomic[0] != 0 || swap->I.alicetomic[0] != 0) { - uint64_t eth_balance = getEthBalance(swap->I.etomicsrc); + int error = 0; + uint64_t eth_balance = getEthBalance(swap->I.etomicsrc, &error); if (eth_balance < 500000) { err = -5000, printf("Bob ETH balance too low, aborting swap!\n"); } @@ -960,7 +961,8 @@ void LP_aliceloop(void *_swap) #ifndef NOTETOMIC if (swap->I.bobtomic[0] != 0 || swap->I.alicetomic[0] != 0) { - uint64_t eth_balance = getEthBalance(swap->I.etomicdest); + int error = 0; + uint64_t eth_balance = getEthBalance(swap->I.etomicdest, &error); if (eth_balance < 500000) { err = -5001, printf("Alice ETH balance too low, aborting swap!\n"); } diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index 944876a90..f241e73c5 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -699,7 +699,8 @@ cJSON *LP_address_balance(struct iguana_info *coin,char *coinaddr,int32_t electr //printf("address balance call LP_listunspent %s electrum.%p etomic.%d\n",coin->symbol,coin->electrum,coin->etomic[0]); #ifndef NOTETOMIC if (coin->etomic[0] != 0) { - balance = LP_etomic_get_balance(coin, coinaddr); + int error = 0; + balance = LP_etomic_get_balance(coin, coinaddr, &error); } else #endif if ( coin->electrum == 0 ) diff --git a/iguana/exchanges/etomicswap/etomiclib.cpp b/iguana/exchanges/etomicswap/etomiclib.cpp index ab60510fd..f80ba22f4 100644 --- a/iguana/exchanges/etomicswap/etomiclib.cpp +++ b/iguana/exchanges/etomicswap/etomiclib.cpp @@ -544,7 +544,7 @@ char* pubKey2Addr(char* pubKey) return stringStreamToChar(ss); }; -char* getPubKeyFromPriv(char* privKey) +char* getPubKeyFromPriv(char *privKey) { Public publicKey = toPublic(Secret(privKey)); std::stringstream ss; @@ -552,7 +552,7 @@ char* getPubKeyFromPriv(char* privKey) return stringStreamToChar(ss); } -uint64_t getEthBalance(char* address) +uint64_t getEthBalance(char *address, int *error) { char* hexBalance = getEthBalanceRequest(address); if (hexBalance != NULL) { @@ -561,11 +561,12 @@ uint64_t getEthBalance(char* address) free(hexBalance); return static_cast(balance); } else { + *error = 1; return 0; } } -uint64_t getErc20BalanceSatoshi(char *address, char *tokenAddress, uint8_t setDecimals) +uint64_t getErc20BalanceSatoshi(char *address, char *tokenAddress, uint8_t setDecimals, int *error) { std::stringstream ss; ss << "0x70a08231" @@ -589,6 +590,7 @@ uint64_t getErc20BalanceSatoshi(char *address, char *tokenAddress, uint8_t setDe free(hexBalance); return static_cast(balance); } else { + *error = 1; return 0; } } diff --git a/iguana/exchanges/etomicswap/etomiclib.h b/iguana/exchanges/etomicswap/etomiclib.h index 3557e4191..6075124a5 100644 --- a/iguana/exchanges/etomicswap/etomiclib.h +++ b/iguana/exchanges/etomicswap/etomiclib.h @@ -173,8 +173,8 @@ char* pubKey2Addr(char* pubKey); char* getPubKeyFromPriv(char* privKey); // returns satoshis, not wei! -uint64_t getEthBalance(char* address); -uint64_t getErc20BalanceSatoshi(char *address, char *tokenAddress, uint8_t setDecimals); +uint64_t getEthBalance(char* address, int *error); +uint64_t getErc20BalanceSatoshi(char *address, char *tokenAddress, uint8_t setDecimals, int *error); char *getErc20BalanceHexWei(char* address, char tokenAddress[65]); uint8_t getErc20Decimals(char *tokenAddress); From 209ca12da74e76106f2f55ed926df8b94c273877 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Wed, 20 Jun 2018 17:51:42 +0700 Subject: [PATCH 101/139] Put back 0.1 amount for test trades. --- etomic_build/client/buy_BEER_OTHER | 2 +- etomic_build/seed/sell_BEER_OTHER | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/etomic_build/client/buy_BEER_OTHER b/etomic_build/client/buy_BEER_OTHER index 9c4123e44..1b4fb5ff6 100755 --- a/etomic_build/client/buy_BEER_OTHER +++ b/etomic_build/client/buy_BEER_OTHER @@ -1,4 +1,4 @@ #!/bin/bash source userpass curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"setprice\",\"base\":\"$1\",\"rel\":\"BEER\",\"price\":1}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"buy\",\"base\":\"BEER\",\"rel\":\"$1\",\"relvolume\":3,\"price\":1}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"buy\",\"base\":\"BEER\",\"rel\":\"$1\",\"relvolume\":0.1,\"price\":1}" diff --git a/etomic_build/seed/sell_BEER_OTHER b/etomic_build/seed/sell_BEER_OTHER index 676404d15..6ec45e1b9 100755 --- a/etomic_build/seed/sell_BEER_OTHER +++ b/etomic_build/seed/sell_BEER_OTHER @@ -1,4 +1,4 @@ #!/bin/bash source userpass curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"setprice\",\"base\":\"BEER\",\"rel\":\"$1\",\"price\":0.9}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"sell\",\"base\":\"BEER\",\"rel\":\"$1\",\"basevolume\":3,\"price\":0.9}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"sell\",\"base\":\"BEER\",\"rel\":\"$1\",\"basevolume\":0.1,\"price\":0.9}" From ccc95df4e6831aee6a34e8f7d72ee2203d62597d Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 21 Jun 2018 15:29:11 +0700 Subject: [PATCH 102/139] #84 Request ETOMIC from faucet when enable in electrum mode. --- iguana/exchanges/LP_commands.c | 12 ++++++++---- iguana/exchanges/etomicswap/etomiccurl.c | 3 +-- iguana/exchanges/etomicswap/etomiccurl.h | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index 7714e2d63..4357af2cb 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -599,10 +599,7 @@ version\n\ } #ifndef NOT_ETOMIC if (strcmp(coin, "ETOMIC") == 0) { - char eth_addr[100]; - bits256 privkey = LP_privkey("ETOMIC", ptr->smartaddr, ptr->taddr); - LP_etomic_priv2addr(eth_addr, privkey); - if (get_etomic_from_faucet(eth_addr, ptr->smartaddr) != 1) { + if (get_etomic_from_faucet(ptr->smartaddr) != 1) { return(clonestr("{\"error\":\"Could not get ETOMIC from faucet!\"}")); } } @@ -696,6 +693,13 @@ version\n\ { if ( (ptr= LP_coinsearch(coin)) != 0 ) { +#ifndef NOTETOMIC + if (strcmp(coin, "ETOMIC") == 0) { + if (get_etomic_from_faucet(ptr->smartaddr) != 1) { + return(clonestr("{\"error\":\"Could not get ETOMIC from faucet!\"}")); + } + } +#endif ptr->inactive = 0; return(jprint(LP_electrumserver(ptr,jstr(argjson,"ipaddr"),juint(argjson,"port")),1)); } else return(clonestr("{\"error\":\"cant find coind\"}")); diff --git a/iguana/exchanges/etomicswap/etomiccurl.c b/iguana/exchanges/etomicswap/etomiccurl.c index c6a493f33..a43e2c292 100644 --- a/iguana/exchanges/etomicswap/etomiccurl.c +++ b/iguana/exchanges/etomicswap/etomiccurl.c @@ -374,11 +374,10 @@ void unlock_send_tx_mutex() pthread_mutex_unlock(&sendTxMutex); } -uint8_t get_etomic_from_faucet(char *eth_addr, char *etomic_addr) +uint8_t get_etomic_from_faucet(char *etomic_addr) { char* string; cJSON *request = cJSON_CreateObject(); - cJSON_AddStringToObject(request, "ethAddress", eth_addr); cJSON_AddStringToObject(request, "etomicAddress", etomic_addr); string = cJSON_PrintUnformatted(request); char* requestResult = sendRequest(string, FAUCET_URL); diff --git a/iguana/exchanges/etomicswap/etomiccurl.h b/iguana/exchanges/etomicswap/etomiccurl.h index 6e5036739..2b765b150 100644 --- a/iguana/exchanges/etomicswap/etomiccurl.h +++ b/iguana/exchanges/etomicswap/etomiccurl.h @@ -50,7 +50,7 @@ uint64_t getEthBlockNumber(); uint64_t getGasPriceFromStation(uint8_t defaultOnErr); int32_t waitForConfirmation(char *txId); void unlock_send_tx_mutex(); -uint8_t get_etomic_from_faucet(char *eth_addr, char *etomic_addr); +uint8_t get_etomic_from_faucet(char *etomic_addr); #ifdef __cplusplus } From 89a1f9ff2c86132ab7a2492d0a4bf101b0661fb2 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Sun, 24 Jun 2018 21:11:32 +0700 Subject: [PATCH 103/139] Merge latest from jl777 dev: "fill", "gtc" options. --- build_testnet | 6 - build_testnet_inverted | 6 - etomic_build/client/balances | 3 - etomic_build/client/enable_my | 198 ----------------------------- etomic_build/client/enable_my.save | 6 - etomic_build/client/eth_withdraw | 3 - etomic_build/client/jst_withdraw | 3 - etomic_build/client/portfolio | 3 - 8 files changed, 228 deletions(-) delete mode 100755 build_testnet delete mode 100755 build_testnet_inverted delete mode 100755 etomic_build/client/balances delete mode 100755 etomic_build/client/enable_my delete mode 100755 etomic_build/client/enable_my.save delete mode 100755 etomic_build/client/eth_withdraw delete mode 100755 etomic_build/client/jst_withdraw delete mode 100755 etomic_build/client/portfolio diff --git a/build_testnet b/build_testnet deleted file mode 100755 index 9c3707541..000000000 --- a/build_testnet +++ /dev/null @@ -1,6 +0,0 @@ -docker-compose down -cd build -cmake --build . --target marketmaker-testnet -cd ../ -docker-compose up -d -./start_BEER_OTHER_trade.sh ETH diff --git a/build_testnet_inverted b/build_testnet_inverted deleted file mode 100755 index f561d188f..000000000 --- a/build_testnet_inverted +++ /dev/null @@ -1,6 +0,0 @@ -docker-compose down -cd build -cmake --build . --target marketmaker-testnet -cd ../ -docker-compose up -d -./start_BEER_OTHER_trade_inverted.sh ETH diff --git a/etomic_build/client/balances b/etomic_build/client/balances deleted file mode 100755 index 1eb527b8f..000000000 --- a/etomic_build/client/balances +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -source userpass -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"balances\"}" diff --git a/etomic_build/client/enable_my b/etomic_build/client/enable_my deleted file mode 100755 index 46f6ac722..000000000 --- a/etomic_build/client/enable_my +++ /dev/null @@ -1,198 +0,0 @@ -source userpass -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"BTC\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10000}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"BTC\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10000}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"KMD\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10001}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"KMD\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10001}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"MNZ\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10002}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"MNZ\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10002}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"REVS\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10003}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"REVS\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10003}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"JUMBLR\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10004}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"JUMBLR\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10004}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"SUPERNET\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10005}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"SUPERNET\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10005}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"DEX\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10006}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"DEX\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10006}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"BOTS\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10007}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"BOTS\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10007}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"CRYPTO\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10008}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"CRYPTO\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10008}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"HODL\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10009}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"HODL\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10009}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"PANGEA\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10010}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"PANGEA\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10010}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"COQUI\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10011}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"COQUI\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10011}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"BET\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10012}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"BET\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10012}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"MSHARK\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10013}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"MSHARK\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10013}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"WLC\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10014}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"WLC\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10014}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"MGW\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10015}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"MGW\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10015}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"KV\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10016}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"KV\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10016}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"BTCH\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10020}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"BTCH\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10020}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"BEER\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10022}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"BEER\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10022}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"PIZZA\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10024}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"PIZZA\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10024}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"ETOMIC\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10025}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"ETOMIC\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10025}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"BNTN\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10026}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"BNTN\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10026}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"DSEC\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10027}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"DSEC\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10027}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"ZILLA\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10028}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"ZILLA\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10028}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"SIB\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10050}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"SIB\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10050}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"BCH\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10051}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"BCH\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10051}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"BTG\",\"ipaddr\":\"173.212.225.176\",\"port\":10052}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"BTG\",\"ipaddr\":\"94.130.224.11\",\"port\":10052}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"CHIPS\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10053}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"CHIPS\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10053}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"BLK\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10054}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"BLK\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10054}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"ZCL\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10055}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"ZCL\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10055}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"BTCZ\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10056}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"BTCZ\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10056}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"BTX\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10057}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"BTX\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10057}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"ZEC\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10058}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"ZEC\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10058}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"DGB\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10059}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"DGB\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10059}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"DOGE\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10060}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"DOGE\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10060}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"DASH\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10061}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"DASH\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10061}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"EMC2\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10062}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"EMC2\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10062}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"FAIR\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10063}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"FAIR\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10063}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"HUSH\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10064}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"HUSH\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10064}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"LTC\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10065}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"LTC\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10065}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"NMC\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10066}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"NMC\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10066}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"VIA\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10067}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"VIA\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10067}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"ARG\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10068}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"ARG\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10068}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"CRW\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10069}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"CRW\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10069}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"MONA\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10070}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"MONA\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10070}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"VTC\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10071}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"VTC\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10071}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"GAME\",\"ipaddr\":\"electrum2.cipig.net\",\"port\":10072}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"GAME\",\"ipaddr\":\"electrum1.cipig.net\",\"port\":10072}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"OOT\",\"ipaddr\":\"electrum1.utrum.io\",\"port\":10088}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"OOT\",\"ipaddr\":\"electrum2.utrum.io\",\"port\":10088}" -#curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"BTCP\",\"ipaddr\":\"electrum.btcprivate.org\",\"port\":5222}" -#curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"BTCP\",\"ipaddr\":\"electrum2.btcprivate.org\",\"port\":5222}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"EQL\",\"ipaddr\":\"159.65.91.235\",\"port\":10801}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"EQL\",\"ipaddr\":\"167.99.204.42\",\"port\":10801}" -#curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"HODLC\",\"ipaddr\":\"hodl.amit.systems\",\"port\":17989}" -#curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"HODLC\",\"ipaddr\":\"hodl2.amit.systems\",\"port\":17898}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"GRS\",\"ipaddr\":\"electrum10.groestlcoin.org\",\"port\":50001}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"GRS\",\"ipaddr\":\"electrum11.groestlcoin.org\",\"port\":50001}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"GRS\",\"ipaddr\":\"electrum13.groestlcoin.org\",\"port\":50001}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"GRS\",\"ipaddr\":\"electrum14.groestlcoin.org\",\"port\":50001}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"QTUM\",\"ipaddr\":\"s1.qtum.info\",\"port\":50001}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"QTUM\",\"ipaddr\":\"s2.qtum.info\",\"port\":50001}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"QTUM\",\"ipaddr\":\"s3.qtum.info\",\"port\":50001}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"QTUM\",\"ipaddr\":\"s4.qtum.info\",\"port\":50001}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"BCBC\",\"ipaddr\":\"bsmn0.cleanblockchain.io\",\"port\":50001}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"BCBC\",\"ipaddr\":\"bsmn1.cleanblockchain.org\",\"port\":50001}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"DNR\",\"ipaddr\":\"45.77.137.111\",\"port\":50001}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"DNR\",\"ipaddr\":\"144.202.95.223\",\"port\":50001}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"FJC\",\"ipaddr\":\"electrumx3.fujicoin.org\",\"port\":50001}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"FJC\",\"ipaddr\":\"electrumx2.fujicoin.org\",\"port\":50001}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"FJC\",\"ipaddr\":\"electrumx1.fujicoin.org\",\"port\":50001}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"SNG\",\"ipaddr\":\"electrumsvr.snowgem.org\",\"port\":50001}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"SNG\",\"ipaddr\":\"electrumsvr2.snowgem.org\",\"port\":50001}" - -#curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"ETOMIC\"}" - -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"ADT\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"AE\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"AION\"}" -#curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"ANN\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"BAT\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"BNT\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"BTCL\"}" -#curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"BTK\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"BTM\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"CENNZ\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"CIPHS\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"CIX\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"DAI\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"DCN\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"DGD\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"DGPT\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"DRGN\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"DROP\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"DRT\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"DTX\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"ELD\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"ELF\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"EOS\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"ETH\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"FLLW\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"FSN\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"FUN\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"GNO\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"GPN\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"GUP\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"HYD\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"ICX\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"IOST\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"KNC\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"LOOM\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"LRC\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"LUN\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"LYS\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"MCO\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"MGO\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"MKR\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"NAS\"}" -#curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"OCC\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"OCT\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"OMG\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"ONNI\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"PAT\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"PAY\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"PCL\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"POWR\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"PRL\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"REP\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"REQ\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"RHOC\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"RLTY\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"RVT\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"SAN\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"SANC\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"SLVT\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"SRN\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"STORJ\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"STWY\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"SVD\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"SWT\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"TIME\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"TUSD\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"UCASH\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"USDT\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"VEN\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"VSL\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"WTC\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"XOV\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"ZIL\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"ZRX\"}" - diff --git a/etomic_build/client/enable_my.save b/etomic_build/client/enable_my.save deleted file mode 100755 index 114cb1670..000000000 --- a/etomic_build/client/enable_my.save +++ /dev/null @@ -1,6 +0,0 @@ -source userpass -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"WTC\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"XOV\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"ZIL\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"ZRX\"}" - diff --git a/etomic_build/client/eth_withdraw b/etomic_build/client/eth_withdraw deleted file mode 100755 index 6b5bf91f5..000000000 --- a/etomic_build/client/eth_withdraw +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -source userpass -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"eth_withdraw\",\"coin\":\"ETH\",\"amount\":0.01,\"to\":\"0xbab36286672fbdc7b250804bf6d14be0df69fa29\",\"broadcast\":1}" diff --git a/etomic_build/client/jst_withdraw b/etomic_build/client/jst_withdraw deleted file mode 100755 index 091d88349..000000000 --- a/etomic_build/client/jst_withdraw +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -source userpass -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"eth_withdraw\",\"coin\":\"JST\",\"amount\":0.01,\"to\":\"0xdf90cbdd4e3ad2b76114a252424b08fc34a7b66c\",\"broadcast\":1,\"gas\":44280,\"gas_price\":3}" diff --git a/etomic_build/client/portfolio b/etomic_build/client/portfolio deleted file mode 100755 index b22adbc06..000000000 --- a/etomic_build/client/portfolio +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -source userpass -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"portfolio\"}" From 17dc46e1b58d172a6ddd2d1b5845b716db74ca25 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Mon, 25 Jun 2018 11:23:03 +0700 Subject: [PATCH 104/139] Update issue templates --- .github/ISSUE_TEMPLATE/bug_report.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 000000000..2d0819b89 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,17 @@ +--- +name: Bug report +about: Marketmaker 1.0 bug report + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**Please answer following questions and attach requested info - it'll help to solve issue faster** +- What OS do you use? +- What marketmaker version do you run? +- Attach your coins.json config. +- Provide your enable script. +- Provide other curl scripts which were executed prior to error. +- Attach full marketmaker console logs (start collecting right after marketmaker execution). +- Provide info for all nodes involved (e.g. if error occurs during atomic swap you should provide info for both Bob and Alice). From a12eb5507d9a2f59d6721cd6d4f5197d5196a903 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Mon, 25 Jun 2018 17:10:38 +0700 Subject: [PATCH 105/139] Update issue templates --- .github/ISSUE_TEMPLATE/bug_report.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 2d0819b89..440838e30 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -11,7 +11,8 @@ A clear and concise description of what the bug is. - What OS do you use? - What marketmaker version do you run? - Attach your coins.json config. -- Provide your enable script. -- Provide other curl scripts which were executed prior to error. +- Provide your enable script with response. +- Provide other curl scripts (with responses) which were executed prior to error. - Attach full marketmaker console logs (start collecting right after marketmaker execution). +- ***Make sure that you don't send your passphrase, userpass and privkeys. Your funds might be stolen if you reveal this info publicly!*** - Provide info for all nodes involved (e.g. if error occurs during atomic swap you should provide info for both Bob and Alice). From 3ec274b4a56d7b09fa49ca8c188709bc0d4eefe4 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Mon, 2 Jul 2018 18:03:00 +0700 Subject: [PATCH 106/139] #89 Properly log "error" field from ETH node response. --- etomic_build/enable | 3 +-- etomic_build/userpass | 2 +- iguana/exchanges/etomicswap/etomiccurl.c | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/etomic_build/enable b/etomic_build/enable index 0bcf62166..f43d63ff7 100755 --- a/etomic_build/enable +++ b/etomic_build/enable @@ -1,5 +1,4 @@ #!/bin/bash source userpass -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"ETH\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"KMD\"}" curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"ETOMIC\"}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"ETH\"}" diff --git a/etomic_build/userpass b/etomic_build/userpass index d097e0445..19fc21189 100644 --- a/etomic_build/userpass +++ b/etomic_build/userpass @@ -1,2 +1,2 @@ #export userpass="" -export userpass="c3d8c2a364b7d18c1f9d7321d017b92e9f9c791e4f5c741214fefdea8a071256" +export userpass="$USERPASS" diff --git a/iguana/exchanges/etomicswap/etomiccurl.c b/iguana/exchanges/etomicswap/etomiccurl.c index a43e2c292..a547111e0 100644 --- a/iguana/exchanges/etomicswap/etomiccurl.c +++ b/iguana/exchanges/etomicswap/etomiccurl.c @@ -43,7 +43,7 @@ cJSON *parseEthRpcResponse(char *requestResult) cJSON *tmp = cJSON_GetObjectItem(json, "result"); cJSON *error = cJSON_GetObjectItem(json, "error"); cJSON *result = NULL; - if (!is_cJSON_Null(tmp)) { + if (tmp != NULL && !is_cJSON_Null(tmp)) { result = cJSON_Duplicate(tmp, 1); } else if (error != NULL && !is_cJSON_Null(error)) { char *errorString = cJSON_PrintUnformatted(error); From c8016d182922f3767c52c0a0efa622ed6935d619 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 5 Jul 2018 11:09:58 +0700 Subject: [PATCH 107/139] Update Jenkinsfile. Remove ETOMIC/BEER trade. --- Jenkinsfile | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ee317926f..ef2e76a87 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -14,7 +14,7 @@ rm -rf build mkdir build cd build cmake .. -cmake --build . --target marketmaker-testnet +cmake --build . --target marketmaker-testnet -j 4 cd ../ docker-compose build''' } @@ -34,24 +34,6 @@ docker-compose down''' ./start_BEER_OTHER_trade_inverted.sh ETH timeout 600 grep -q "SWAP completed" <(COMPOSE_HTTP_TIMEOUT=600 docker-compose logs -f clientnode) timeout 600 grep -q "SWAP completed" <(COMPOSE_HTTP_TIMEOUT=600 docker-compose logs -f seednode) -docker-compose down''' - } - } - stage('Trade BEER/ETOMIC') { - steps { - sh '''docker-compose up -d -./start_BEER_OTHER_trade.sh ETOMIC -timeout 600 grep -q "SWAP completed" <(COMPOSE_HTTP_TIMEOUT=600 docker-compose logs -f clientnode) -timeout 600 grep -q "SWAP completed" <(COMPOSE_HTTP_TIMEOUT=600 docker-compose logs -f seednode) -docker-compose down''' - } - } - stage('Trade ETOMIC/BEER') { - steps { - sh '''docker-compose up -d -./start_BEER_OTHER_trade_inverted.sh ETOMIC -timeout 600 grep -q "SWAP completed" <(COMPOSE_HTTP_TIMEOUT=600 docker-compose logs -f clientnode) -timeout 600 grep -q "SWAP completed" <(COMPOSE_HTTP_TIMEOUT=600 docker-compose logs -f seednode) docker-compose down''' } } From 6b94fcb8241a97598dabd9407240f4d53fbd0fa8 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 5 Jul 2018 11:23:48 +0700 Subject: [PATCH 108/139] Experiment with travis to get number of cores. --- .travis.yml | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index b77bb4622..52b82c204 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,17 +10,8 @@ matrix: env: OS_NAME=Darwin osx_image: xcode9.2 -before_install: - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && sudo apt-get update && sudo apt-get install -y g++-7; fi - - git submodule update --init --recursive - script: - - export VERSION=`echo "$(git tag -l --points-at HEAD)"` - - mkdir build && cd build - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cmake -DMM_VERSION="$VERSION" -DCMAKE_C_COMPILER=/usr/bin/gcc-7 -DCMAKE_CXX_COMPILER=/usr/bin/g++-7 ..; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cmake -DMM_VERSION="$VERSION" ..; fi - - cmake --build . --target marketmaker-mainnet - - cmake --build . --target marketmaker-testnet + - nproc --all cache: apt: true From 1079ae8e042e720edde9a8ef31754d2b55e88e8a Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 5 Jul 2018 11:33:24 +0700 Subject: [PATCH 109/139] Where is cmake on Linux on Travis. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 52b82c204..8174dde63 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ matrix: osx_image: xcode9.2 script: - - nproc --all + - whereis cmake cache: apt: true From d48858ec45726f02bb0178890117b1b00d25e75d Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 5 Jul 2018 11:47:25 +0700 Subject: [PATCH 110/139] Try to install higher version of cmake on travis. --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 8174dde63..e9431257e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,11 @@ matrix: osx_image: xcode9.2 script: + - wget https://cmake.org/files/v3.12/cmake-3.12.0-rc2-Linux-x86_64.sh + - chmod +x cmake-3.12.0-rc2-Linux-x86_64.sh + - sudo ./cmake-3.12.0-rc2-Linux-x86_64.sh --skip-license --exclude-subdir --prefix=/usr/local - whereis cmake + - cmake --version cache: apt: true From d0e779b5bac9a6de7ded31a48d557524e9e5bd04 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 5 Jul 2018 11:54:30 +0700 Subject: [PATCH 111/139] Try to install higher version of cmake on travis. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index e9431257e..dc7bd38e1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,7 @@ matrix: osx_image: xcode9.2 script: + - sudo apt-get remove cmake - wget https://cmake.org/files/v3.12/cmake-3.12.0-rc2-Linux-x86_64.sh - chmod +x cmake-3.12.0-rc2-Linux-x86_64.sh - sudo ./cmake-3.12.0-rc2-Linux-x86_64.sh --skip-license --exclude-subdir --prefix=/usr/local From b336840aaf2fccad65fad59d5b377ebba54299be Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 5 Jul 2018 12:10:21 +0700 Subject: [PATCH 112/139] Try to install higher version of cmake on travis. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index dc7bd38e1..ae0bb0c84 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ matrix: osx_image: xcode9.2 script: - - sudo apt-get remove cmake + - find / | grep cmake - wget https://cmake.org/files/v3.12/cmake-3.12.0-rc2-Linux-x86_64.sh - chmod +x cmake-3.12.0-rc2-Linux-x86_64.sh - sudo ./cmake-3.12.0-rc2-Linux-x86_64.sh --skip-license --exclude-subdir --prefix=/usr/local From 093c23da1d0873a00f144141620f0d1cee390126 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 5 Jul 2018 12:14:28 +0700 Subject: [PATCH 113/139] Try to install higher version of cmake on travis. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ae0bb0c84..00ca4bbdb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ matrix: osx_image: xcode9.2 script: - - find / | grep cmake + - sudo rm -rf /usr/local/cmake-3.9.2 && sudo rm -rf /usr/local/cmake - wget https://cmake.org/files/v3.12/cmake-3.12.0-rc2-Linux-x86_64.sh - chmod +x cmake-3.12.0-rc2-Linux-x86_64.sh - sudo ./cmake-3.12.0-rc2-Linux-x86_64.sh --skip-license --exclude-subdir --prefix=/usr/local From 8cc516577d1885db0fd19b070a003b2221606d0f Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 5 Jul 2018 12:20:30 +0700 Subject: [PATCH 114/139] Install 3.12.0 cmake on travis Linux. --- .travis.yml | 17 +++++++++++------ travis_cmake_linux.sh | 5 +++++ 2 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 travis_cmake_linux.sh diff --git a/.travis.yml b/.travis.yml index 00ca4bbdb..7ff6f6372 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,13 +10,18 @@ matrix: env: OS_NAME=Darwin osx_image: xcode9.2 +before_install: + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && sudo apt-get update && sudo apt-get install -y g++-7; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./travis_cmake_linux.sh; fi + - git submodule update --init --recursive + script: - - sudo rm -rf /usr/local/cmake-3.9.2 && sudo rm -rf /usr/local/cmake - - wget https://cmake.org/files/v3.12/cmake-3.12.0-rc2-Linux-x86_64.sh - - chmod +x cmake-3.12.0-rc2-Linux-x86_64.sh - - sudo ./cmake-3.12.0-rc2-Linux-x86_64.sh --skip-license --exclude-subdir --prefix=/usr/local - - whereis cmake - - cmake --version + - export VERSION=`echo "$(git tag -l --points-at HEAD)"` + - mkdir build && cd build + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cmake -DMM_VERSION="$VERSION" -DCMAKE_C_COMPILER=/usr/bin/gcc-7 -DCMAKE_CXX_COMPILER=/usr/bin/g++-7 ..; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cmake -DMM_VERSION="$VERSION" ..; fi + - cmake --build . --target marketmaker-mainnet -j $(nproc --all) + - cmake --build . --target marketmaker-testnet -j $(nproc --all) cache: apt: true diff --git a/travis_cmake_linux.sh b/travis_cmake_linux.sh new file mode 100644 index 000000000..f11b08e4d --- /dev/null +++ b/travis_cmake_linux.sh @@ -0,0 +1,5 @@ +#!/bin/bash +sudo rm -rf /usr/local/cmake-3.9.2 && sudo rm -rf /usr/local/cmake +wget https://cmake.org/files/v3.12/cmake-3.12.0-rc2-Linux-x86_64.sh +chmod +x cmake-3.12.0-rc2-Linux-x86_64.sh +sudo ./cmake-3.12.0-rc2-Linux-x86_64.sh --skip-license --exclude-subdir --prefix=/usr/local \ No newline at end of file From 8b5e2af227479e441f8553379cf83dcf227bcc1b Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 5 Jul 2018 12:29:16 +0700 Subject: [PATCH 115/139] Install 3.12.0 cmake on travis Linux. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7ff6f6372..bf35a7592 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ matrix: before_install: - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && sudo apt-get update && sudo apt-get install -y g++-7; fi - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./travis_cmake_linux.sh; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then chmod +x travis_cmake_linux.sh && ./travis_cmake_linux.sh; fi - git submodule update --init --recursive script: From 91bb1c603aa6d5a62b9a9fa1ac11c32c9ebe3422 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 5 Jul 2018 12:42:29 +0700 Subject: [PATCH 116/139] Try to update cmake on Mac travis. --- .travis.yml | 1 + travis_cmake_mac.sh | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 travis_cmake_mac.sh diff --git a/.travis.yml b/.travis.yml index bf35a7592..2705e75df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ matrix: before_install: - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && sudo apt-get update && sudo apt-get install -y g++-7; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then chmod +x travis_cmake_linux.sh && ./travis_cmake_linux.sh; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then chmod +x travis_cmake_mac.sh && ./travis_cmake_mac.sh; fi - git submodule update --init --recursive script: diff --git a/travis_cmake_mac.sh b/travis_cmake_mac.sh new file mode 100644 index 000000000..09268c6ce --- /dev/null +++ b/travis_cmake_mac.sh @@ -0,0 +1,6 @@ +#!/bin/bash +wget https://cmake.org/files/v3.12/cmake-3.12.0-rc2-Darwin-x86_64.dmg +sudo hdiutil attach cmake-3.12.0-rc2-Darwin-x86_64.dmg +sudo installer -package /Volumes/cmake-3.12.0-rc2-Darwin-x86_64/cmake-3.12.0-rc2-Darwin-x86_64.pkg -target / +sudo hdiutil detach /Volumes/cmake-3.12.0-rc2-Darwin-x86_64 +cmake --version \ No newline at end of file From 09a32b57378819d1095ae81383723c2a5d7c8b40 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 5 Jul 2018 12:44:41 +0700 Subject: [PATCH 117/139] Try to update cmake on Mac travis. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2705e75df..424e5aa5a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ matrix: before_install: - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && sudo apt-get update && sudo apt-get install -y g++-7; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then chmod +x travis_cmake_linux.sh && ./travis_cmake_linux.sh; fi - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then chmod +x travis_cmake_mac.sh && ./travis_cmake_mac.sh; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then chmod +x travis_cmake_mac.sh && ./travis_cmake_mac.sh; fi - git submodule update --init --recursive script: From 3aebdaa3048f12de7cc7b8ea2c0efa4cd236fb56 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 5 Jul 2018 12:53:50 +0700 Subject: [PATCH 118/139] Try to update cmake on Mac travis. --- travis_cmake_linux.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/travis_cmake_linux.sh b/travis_cmake_linux.sh index f11b08e4d..b2ed5d4d3 100644 --- a/travis_cmake_linux.sh +++ b/travis_cmake_linux.sh @@ -1,5 +1,2 @@ #!/bin/bash -sudo rm -rf /usr/local/cmake-3.9.2 && sudo rm -rf /usr/local/cmake -wget https://cmake.org/files/v3.12/cmake-3.12.0-rc2-Linux-x86_64.sh -chmod +x cmake-3.12.0-rc2-Linux-x86_64.sh -sudo ./cmake-3.12.0-rc2-Linux-x86_64.sh --skip-license --exclude-subdir --prefix=/usr/local \ No newline at end of file +ls /Applications \ No newline at end of file From cdc9bd0fd95d698b63b52e0b0343f1588f4c89c7 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 5 Jul 2018 12:56:21 +0700 Subject: [PATCH 119/139] Try to update cmake on Mac travis. --- travis_cmake_linux.sh | 5 ++++- travis_cmake_mac.sh | 6 +----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/travis_cmake_linux.sh b/travis_cmake_linux.sh index b2ed5d4d3..f11b08e4d 100644 --- a/travis_cmake_linux.sh +++ b/travis_cmake_linux.sh @@ -1,2 +1,5 @@ #!/bin/bash -ls /Applications \ No newline at end of file +sudo rm -rf /usr/local/cmake-3.9.2 && sudo rm -rf /usr/local/cmake +wget https://cmake.org/files/v3.12/cmake-3.12.0-rc2-Linux-x86_64.sh +chmod +x cmake-3.12.0-rc2-Linux-x86_64.sh +sudo ./cmake-3.12.0-rc2-Linux-x86_64.sh --skip-license --exclude-subdir --prefix=/usr/local \ No newline at end of file diff --git a/travis_cmake_mac.sh b/travis_cmake_mac.sh index 09268c6ce..b2ed5d4d3 100644 --- a/travis_cmake_mac.sh +++ b/travis_cmake_mac.sh @@ -1,6 +1,2 @@ #!/bin/bash -wget https://cmake.org/files/v3.12/cmake-3.12.0-rc2-Darwin-x86_64.dmg -sudo hdiutil attach cmake-3.12.0-rc2-Darwin-x86_64.dmg -sudo installer -package /Volumes/cmake-3.12.0-rc2-Darwin-x86_64/cmake-3.12.0-rc2-Darwin-x86_64.pkg -target / -sudo hdiutil detach /Volumes/cmake-3.12.0-rc2-Darwin-x86_64 -cmake --version \ No newline at end of file +ls /Applications \ No newline at end of file From 2b875196d80f72e9d981bcfccdb93d002ff0a5bd Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 5 Jul 2018 13:00:32 +0700 Subject: [PATCH 120/139] Try to update cmake on Mac travis. --- travis_cmake_mac.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/travis_cmake_mac.sh b/travis_cmake_mac.sh index b2ed5d4d3..ede85cd12 100644 --- a/travis_cmake_mac.sh +++ b/travis_cmake_mac.sh @@ -1,2 +1,3 @@ #!/bin/bash -ls /Applications \ No newline at end of file +sudo find / | grep cmake +sysctl -n hw.physicalcpu \ No newline at end of file From 05d11deac6d5f45fcdcb2927a861c45810532db5 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 5 Jul 2018 13:07:31 +0700 Subject: [PATCH 121/139] Try to update cmake on Mac travis. --- travis_cmake_mac.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/travis_cmake_mac.sh b/travis_cmake_mac.sh index ede85cd12..d858c870c 100644 --- a/travis_cmake_mac.sh +++ b/travis_cmake_mac.sh @@ -1,3 +1,6 @@ #!/bin/bash -sudo find / | grep cmake +which cmake +brew uninstall cmake --force +brew cleanup +which cmake sysctl -n hw.physicalcpu \ No newline at end of file From 69747ef0ca874d153ded00a63287942d265a210b Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 5 Jul 2018 13:37:47 +0700 Subject: [PATCH 122/139] Try to update cmake on Mac travis. --- travis_cmake_mac.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/travis_cmake_mac.sh b/travis_cmake_mac.sh index d858c870c..208954a10 100644 --- a/travis_cmake_mac.sh +++ b/travis_cmake_mac.sh @@ -1,6 +1,9 @@ #!/bin/bash -which cmake brew uninstall cmake --force brew cleanup +wget https://cmake.org/files/v3.12/cmake-3.12.0-rc2-Darwin-x86_64.tar.gz +tar -xvzf cmake-3.12.0-rc2-Darwin-x86_64.tar.gz +cp -r cmake-3.12.0-rc2-Darwin-x86_64/CMake.app /Applications +sysctl -n hw.physicalcpu which cmake -sysctl -n hw.physicalcpu \ No newline at end of file +cmake --version \ No newline at end of file From 2701d3f7f1385088df117ffc1df2229f5e08c81d Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 5 Jul 2018 13:44:05 +0700 Subject: [PATCH 123/139] Try to update cmake on Mac travis. --- travis_cmake_mac.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/travis_cmake_mac.sh b/travis_cmake_mac.sh index 208954a10..a60ef95aa 100644 --- a/travis_cmake_mac.sh +++ b/travis_cmake_mac.sh @@ -1,9 +1,5 @@ #!/bin/bash -brew uninstall cmake --force -brew cleanup -wget https://cmake.org/files/v3.12/cmake-3.12.0-rc2-Darwin-x86_64.tar.gz -tar -xvzf cmake-3.12.0-rc2-Darwin-x86_64.tar.gz -cp -r cmake-3.12.0-rc2-Darwin-x86_64/CMake.app /Applications +brew reinstall --HEAD cmake sysctl -n hw.physicalcpu which cmake cmake --version \ No newline at end of file From 1b68fe57f451191a15aa56944d24d866a5aa7a9e Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 5 Jul 2018 14:04:53 +0700 Subject: [PATCH 124/139] Try to update cmake on Mac travis. --- travis_cmake_mac.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/travis_cmake_mac.sh b/travis_cmake_mac.sh index a60ef95aa..9c8de4ff7 100644 --- a/travis_cmake_mac.sh +++ b/travis_cmake_mac.sh @@ -1,5 +1,9 @@ #!/bin/bash -brew reinstall --HEAD cmake +brew uninstall cmake --force +wget https://cmake.org/files/v3.12/cmake-3.12.0-rc2-Darwin-x86_64.dmg +hdiutil convert -quiet cmake-3.12.0-rc2-Darwin-x86_64.dmg -format UDTO -o bar +hdiutil attach -quiet -nobrowse -noverify -noautoopen -mountpoint right_here bar.cdr +sudo installer -package right_here/cmake-3.12.0-rc2-Darwin-x86_64/cmake-3.12.0-rc2-Darwin-x86_64.pkg -target / sysctl -n hw.physicalcpu which cmake cmake --version \ No newline at end of file From c310e6708c3095132e10ed945fa8a426df659326 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 5 Jul 2018 14:07:27 +0700 Subject: [PATCH 125/139] Try to update cmake on Mac travis. --- travis_cmake_mac.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/travis_cmake_mac.sh b/travis_cmake_mac.sh index 9c8de4ff7..b44373d39 100644 --- a/travis_cmake_mac.sh +++ b/travis_cmake_mac.sh @@ -3,6 +3,7 @@ brew uninstall cmake --force wget https://cmake.org/files/v3.12/cmake-3.12.0-rc2-Darwin-x86_64.dmg hdiutil convert -quiet cmake-3.12.0-rc2-Darwin-x86_64.dmg -format UDTO -o bar hdiutil attach -quiet -nobrowse -noverify -noautoopen -mountpoint right_here bar.cdr +ls right_here sudo installer -package right_here/cmake-3.12.0-rc2-Darwin-x86_64/cmake-3.12.0-rc2-Darwin-x86_64.pkg -target / sysctl -n hw.physicalcpu which cmake From ae7a11c194384486397478b777ae07cd05b75520 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 5 Jul 2018 14:10:42 +0700 Subject: [PATCH 126/139] Try to update cmake on Mac travis. --- travis_cmake_mac.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis_cmake_mac.sh b/travis_cmake_mac.sh index b44373d39..459029d74 100644 --- a/travis_cmake_mac.sh +++ b/travis_cmake_mac.sh @@ -3,7 +3,7 @@ brew uninstall cmake --force wget https://cmake.org/files/v3.12/cmake-3.12.0-rc2-Darwin-x86_64.dmg hdiutil convert -quiet cmake-3.12.0-rc2-Darwin-x86_64.dmg -format UDTO -o bar hdiutil attach -quiet -nobrowse -noverify -noautoopen -mountpoint right_here bar.cdr -ls right_here +find right_here -print sudo installer -package right_here/cmake-3.12.0-rc2-Darwin-x86_64/cmake-3.12.0-rc2-Darwin-x86_64.pkg -target / sysctl -n hw.physicalcpu which cmake From ceddc12c2960f059d3cfd70b68083bb2b4043b30 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 5 Jul 2018 14:19:46 +0700 Subject: [PATCH 127/139] Try to update cmake on Mac travis. --- travis_cmake_mac.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/travis_cmake_mac.sh b/travis_cmake_mac.sh index 459029d74..6b139728e 100644 --- a/travis_cmake_mac.sh +++ b/travis_cmake_mac.sh @@ -1,10 +1,8 @@ #!/bin/bash brew uninstall cmake --force -wget https://cmake.org/files/v3.12/cmake-3.12.0-rc2-Darwin-x86_64.dmg -hdiutil convert -quiet cmake-3.12.0-rc2-Darwin-x86_64.dmg -format UDTO -o bar -hdiutil attach -quiet -nobrowse -noverify -noautoopen -mountpoint right_here bar.cdr -find right_here -print -sudo installer -package right_here/cmake-3.12.0-rc2-Darwin-x86_64/cmake-3.12.0-rc2-Darwin-x86_64.pkg -target / +wget https://cmake.org/files/v3.12/cmake-3.12.0-rc2-Darwin-x86_64.tar.gz +tar -xvzf cmake-3.12.0-rc2-Darwin-x86_64.tar.gz +cp -r cmake-3.12.0-rc2-Darwin-x86_64/CMake.app/Contents/bin/* /usr/local/bin/ sysctl -n hw.physicalcpu which cmake cmake --version \ No newline at end of file From 4523c5a9f321a125edad0e882846b12774ad148b Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 5 Jul 2018 14:24:14 +0700 Subject: [PATCH 128/139] Try to update cmake on Mac travis. --- travis_cmake_mac.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/travis_cmake_mac.sh b/travis_cmake_mac.sh index 6b139728e..4f5d1ddef 100644 --- a/travis_cmake_mac.sh +++ b/travis_cmake_mac.sh @@ -3,6 +3,7 @@ brew uninstall cmake --force wget https://cmake.org/files/v3.12/cmake-3.12.0-rc2-Darwin-x86_64.tar.gz tar -xvzf cmake-3.12.0-rc2-Darwin-x86_64.tar.gz cp -r cmake-3.12.0-rc2-Darwin-x86_64/CMake.app/Contents/bin/* /usr/local/bin/ +cp -r cmake-3.12.0-rc2-Darwin-x86_64/CMake.app/Contents/share/* /usr/local/share/ sysctl -n hw.physicalcpu which cmake cmake --version \ No newline at end of file From f38a02f4e8f97c350511e2ab739077deeb15b5e9 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 5 Jul 2018 15:37:26 +0700 Subject: [PATCH 129/139] Try to update cmake on Mac travis. --- .travis.yml | 7 +++++-- travis_cmake_mac.sh | 7 ++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 424e5aa5a..581c49ba1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,11 +18,14 @@ before_install: script: - export VERSION=`echo "$(git tag -l --points-at HEAD)"` + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export THREAD_COUNT=`echo "$(nproc --all)"`; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export THREAD_COUNT=`echo "$(sysctl -n hw.physicalcpu)"`; fi - mkdir build && cd build - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cmake -DMM_VERSION="$VERSION" -DCMAKE_C_COMPILER=/usr/bin/gcc-7 -DCMAKE_CXX_COMPILER=/usr/bin/g++-7 ..; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cmake -DMM_VERSION="$VERSION" ..; fi - - cmake --build . --target marketmaker-mainnet -j $(nproc --all) - - cmake --build . --target marketmaker-testnet -j $(nproc --all) + - echo "cmake --build . --target marketmaker-mainnet -j $THREAD_COUNT" + - cmake --build . --target marketmaker-mainnet -j $THREAD_COUNT + - cmake --build . --target marketmaker-testnet -j $THREAD_COUNT cache: apt: true diff --git a/travis_cmake_mac.sh b/travis_cmake_mac.sh index 4f5d1ddef..f2fbadca0 100644 --- a/travis_cmake_mac.sh +++ b/travis_cmake_mac.sh @@ -1,9 +1,6 @@ #!/bin/bash brew uninstall cmake --force wget https://cmake.org/files/v3.12/cmake-3.12.0-rc2-Darwin-x86_64.tar.gz -tar -xvzf cmake-3.12.0-rc2-Darwin-x86_64.tar.gz +tar -xzf cmake-3.12.0-rc2-Darwin-x86_64.tar.gz cp -r cmake-3.12.0-rc2-Darwin-x86_64/CMake.app/Contents/bin/* /usr/local/bin/ -cp -r cmake-3.12.0-rc2-Darwin-x86_64/CMake.app/Contents/share/* /usr/local/share/ -sysctl -n hw.physicalcpu -which cmake -cmake --version \ No newline at end of file +cp -r cmake-3.12.0-rc2-Darwin-x86_64/CMake.app/Contents/share/* /usr/local/share/ \ No newline at end of file From 2fac766a7b865b2541ee93176d9b479091d0fb5f Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Mon, 9 Jul 2018 17:13:12 +0700 Subject: [PATCH 130/139] #84 Disable some checks when ETOMIC coin order is getting placed. --- iguana/exchanges/LP_ordermatch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index 045f58e15..fc48bbf3e 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -1789,7 +1789,7 @@ char *LP_autobuy(void *ctx,int32_t fomoflag,char *myipaddr,int32_t mypubsock,cha destsatoshis = autxo->swap_satoshis; printf("second path dest %.8f from %.8f\n",dstr(destsatoshis),dstr(autxo->swap_satoshis)); } - if ( destsatoshis < (autxo->payment.value / LP_MINCLIENTVOL) || autxo->payment.value < desttxfee*LP_MINSIZE_TXFEEMULT ) + if ( relcoin->etomic[0] == 0 && (destsatoshis < (autxo->payment.value / LP_MINCLIENTVOL) || autxo->payment.value < desttxfee*LP_MINSIZE_TXFEEMULT )) { printf("destsatoshis %.8f vs utxo %.8f this would have triggered an quote error -13\n",dstr(destsatoshis),dstr(autxo->payment.value)); return(clonestr("{\"error\":\"cant find a deposit that is close enough in size. make another deposit that is a bit larger than what you want to trade\"}")); From 1cefa815042edf9abdad02f50d8cff537fa3709f Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 12 Jul 2018 23:46:15 +0700 Subject: [PATCH 131/139] Use compareAddresses instead of string comparison on quoteparse. --- iguana/exchanges/LP_signatures.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_signatures.c b/iguana/exchanges/LP_signatures.c index 9acdbf330..00318551b 100644 --- a/iguana/exchanges/LP_signatures.c +++ b/iguana/exchanges/LP_signatures.c @@ -128,25 +128,29 @@ int32_t LP_quoteparse(struct LP_quoteinfo *qp,cJSON *argjson) safecopy(qp->gui,LP_gui,sizeof(qp->gui)); safecopy(qp->srccoin,jstr(argjson,"base"),sizeof(qp->srccoin)); safecopy(qp->uuidstr,jstr(argjson,"uuid"),sizeof(qp->uuidstr)); +#ifndef NOTETOMIC if ( LP_etomicsymbol(activesymbol,etomic,qp->srccoin) != 0 ) { - if ( (etomicstr= jstr(argjson,"bobtomic")) == 0 || strcmp(etomicstr,etomic) != 0 ) + if ( (etomicstr= jstr(argjson,"bobtomic")) == 0 || compareAddresses(etomicstr,etomic) == 0 ) { printf("etomic src mismatch (%s) vs (%s)\n",etomicstr!=0?etomicstr:"",etomic); return(-1); } } +#endif safecopy(qp->coinaddr,jstr(argjson,"address"),sizeof(qp->coinaddr)); safecopy(qp->etomicsrc,jstr(argjson,"etomicsrc"),sizeof(qp->etomicsrc)); safecopy(qp->destcoin,jstr(argjson,"rel"),sizeof(qp->destcoin)); +#ifndef NOTETOMIC if ( LP_etomicsymbol(activesymbol,etomic,qp->destcoin) != 0 ) { - if ( (etomicstr= jstr(argjson,"alicetomic")) == 0 || strcmp(etomicstr,etomic) != 0 ) + if ( (etomicstr= jstr(argjson,"alicetomic")) == 0 || compareAddresses(etomicstr,etomic) == 0 ) { printf("etomic dest mismatch (%s) vs (%s)\n",etomicstr!=0?etomicstr:"",etomic); return(-1); } } +#endif safecopy(qp->destaddr,jstr(argjson,"destaddr"),sizeof(qp->destaddr)); safecopy(qp->etomicdest,jstr(argjson,"etomicdest"),sizeof(qp->etomicdest)); qp->aliceid = j64bits(argjson,"aliceid"); From f56f2d6effd3227868054ce9b2b8424c12315912 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Fri, 13 Jul 2018 16:15:37 +0700 Subject: [PATCH 132/139] Add additional logging to LP_iseligible. --- iguana/exchanges/LP_utxo.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index 35482f3b5..b81ec3449 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -1217,16 +1217,27 @@ int32_t LP_iseligible(uint64_t *valp,uint64_t *val2p,int32_t iambob,char *symbol strcpy(destaddr,destaddr2); if ( coin != 0 ) { - if ( (txobj= LP_gettxout(coin->symbol,destaddr,txid,vout)) == 0 ) - return(0); + char txid_str[100], txid2_str[100]; + bits256_str(txid_str, txid); + bits256_str(txid2_str, txid2); + if ( (txobj= LP_gettxout(coin->symbol,destaddr,txid,vout)) == 0 ) { + printf("Could not find tx out: %s %d\n", txid_str, vout); + return (0); + } else free_json(txobj); - if ( (txobj= LP_gettxout(coin->symbol,destaddr,txid2,vout2)) == 0 ) - return(0); + if ( (txobj= LP_gettxout(coin->symbol,destaddr,txid2,vout2)) == 0 ) { + printf("Could not find tx out: %s %d\n", txid_str, vout2); + return (0); + } else free_json(txobj); - if ( LP_numconfirms(coin->symbol,destaddr,txid,vout,0) <= 0 ) - return(0); - if ( LP_numconfirms(coin->symbol,destaddr,txid2,vout2,0) <= 0 ) - return(0); + if ( LP_numconfirms(coin->symbol,destaddr,txid,vout,0) <= 0 ) { + printf("Txid numconfirms is less or equal to zero: %s %d\n", txid_str, vout); + return (0); + } + if ( LP_numconfirms(coin->symbol,destaddr,txid2,vout2,0) <= 0 ) { + printf("Txid numconfirms is less or equal to zero: %s %d\n", txid2_str, vout2); + return (0); + } } return(1); } From ddab1eb95969a7676db06f9f837b11e26cf76727 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Tue, 17 Jul 2018 15:55:39 +0700 Subject: [PATCH 133/139] Set G.LP_myrmd160 only once on LP_passphrase_init. --- iguana/exchanges/LP_privkey.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_privkey.c b/iguana/exchanges/LP_privkey.c index 073e189f2..727f5f358 100644 --- a/iguana/exchanges/LP_privkey.c +++ b/iguana/exchanges/LP_privkey.c @@ -352,6 +352,7 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan { //static uint32_t counter; bits256 privkey,userpub,zero,userpass,checkkey,tmpkey; char str[65],str2[65],tmpstr[128]; cJSON *retjson; uint8_t tmptype,sig[128]; int32_t notarized,siglen; uint64_t nxtaddr; + uint8_t rmd160[20]; if ( (wifstr == 0 || wifstr[0] == 0) && LP_wifstr_valid(coin->symbol,passphrase) > 0 ) { wifstr = passphrase; @@ -399,7 +400,7 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan #ifndef NOTETOMIC if ( coin->etomic[0] != 0 ) { - uint8_t check64[64],checktype,checkrmd160[20],rmd160[20]; char checkaddr[64],checkaddr2[64]; + uint8_t check64[64],checktype,checkrmd160[20]; char checkaddr[64],checkaddr2[64]; if ( LP_etomic_priv2pub(check64,privkey) == 0 ) { if ( memcmp(check64,coin->pubkey33+1,32) == 0 ) @@ -434,8 +435,8 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan coin->counter++; memcpy(G.LP_pubsecp,coin->pubkey33,33); bitcoin_priv2wif(coin->symbol,coin->wiftaddr,tmpstr,privkey,coin->wiftype); - bitcoin_addr2rmd160(coin->symbol,coin->taddr,&tmptype,G.LP_myrmd160,coin->smartaddr); - LP_privkeyadd(privkey,G.LP_myrmd160); + bitcoin_addr2rmd160(coin->symbol,coin->taddr,&tmptype,rmd160,coin->smartaddr); + LP_privkeyadd(privkey,rmd160); G.LP_privkey = privkey; if ( G.counter++ == 0 ) { @@ -705,6 +706,7 @@ void LP_privkey_updates(void *ctx,int32_t pubsock,char *passphrase) int32_t LP_passphrase_init(char *passphrase,char *gui,uint16_t netid,char *seednode) { static void *ctx; struct iguana_info *coin,*tmp; int32_t counter; + uint8_t pubkey33[100]; if ( ctx == 0 ) ctx = bitcoin_ctx(); if ( G.LP_pendingswaps != 0 ) @@ -739,8 +741,11 @@ int32_t LP_passphrase_init(char *passphrase,char *gui,uint16_t netid,char *seedn memset(&G,0,sizeof(G)); G.netid = netid; safecopy(G.seednode,seednode,sizeof(G.seednode)); + vcalc_sha256(0,G.LP_passhash.bytes,(uint8_t *)passphrase,(int32_t)strlen(passphrase)); LP_privkey_updates(ctx,LP_mypubsock,passphrase); + bitcoin_pubkey33(ctx, pubkey33, G.LP_privkey); + calc_rmd160_sha256(G.LP_myrmd160, pubkey33, 33); init_hexbytes_noT(G.LP_myrmd160str,G.LP_myrmd160,20); G.LP_sessionid = (uint32_t)time(NULL); safecopy(G.gui,gui,sizeof(G.gui)); From 9cf5e88a3036c3db9326a3107de947b54f422f17 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Fri, 20 Jul 2018 14:12:25 +0700 Subject: [PATCH 134/139] #104. Expose ETH transactions data on WS events. --- iguana/exchanges/LP_commands.c | 2 +- iguana/exchanges/LP_etomic.c | 7 ++--- iguana/exchanges/LP_include.h | 4 +-- iguana/exchanges/LP_remember.c | 56 +++++++++++++++++++++++++++++++++- iguana/exchanges/LP_swap.c | 14 +++++++++ 5 files changed, 75 insertions(+), 8 deletions(-) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index 95295dc74..871d04195 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -612,7 +612,7 @@ version\n\ jaddstr(retjson,"coin",coin); return(jprint(retjson,1)); } -#ifndef NOT_ETOMIC +#ifndef NOTETOMIC if (strcmp(coin, "ETOMIC") == 0) { if (get_etomic_from_faucet(ptr->smartaddr) != 1) { return(clonestr("{\"error\":\"Could not get ETOMIC from faucet!\"}")); diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index 3b7c7aa8f..3d03bec75 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -42,6 +42,7 @@ char *LP_etomicalice_send_fee(struct basilisk_swap *swap) { char amount[100], secretKey[70], dexaddr[50]; satoshisToWei(amount, LP_DEXFEE(swap->I.alicerealsat)); + swap->myfee.I.eth_amount = LP_DEXFEE(swap->I.alicerealsat); uint8arrayToHex(secretKey, swap->persistent_privkey.bytes, 32); LP_etomic_pubkeystr_to_addr(INSTANTDEX_PUBKEY, dexaddr); if (strcmp(swap->I.alicestr,"ETH") == 0 ) { @@ -94,7 +95,7 @@ uint8_t LP_etomic_verify_alice_fee(struct basilisk_swap *swap) char *LP_etomicalice_send_payment(struct basilisk_swap *swap) { AliceSendsEthPaymentInput input; AliceSendsErc20PaymentInput input20; BasicTxData txData; - + swap->alicepayment.I.eth_amount = swap->I.alicerealsat; // set input and txData fields from the swap data structure memset(&txData,0,sizeof(txData)); if ( strcmp(swap->I.alicestr,"ETH") == 0 ) @@ -168,7 +169,6 @@ uint8_t LP_etomic_verify_alice_payment(struct basilisk_swap *swap, char *txId) return(0); } AliceSendsEthPaymentInput input; AliceSendsErc20PaymentInput input20; - if ( strcmp(swap->I.alicestr,"ETH") == 0 ) { uint64_t paymentAmount = weiToSatoshi(data.valueHex); if (paymentAmount != swap->I.alicerealsat) { @@ -533,7 +533,6 @@ uint8_t LP_etomic_verify_bob_payment(struct basilisk_swap *swap, char *txId) BobSendsErc20PaymentInput input20; memset(&input,0,sizeof(input)); memset(&input20,0,sizeof(input20)); - if ( strcmp(swap->I.bobstr,"ETH") == 0 ) { uint64_t paymentAmount = weiToSatoshi(data.valueHex); if (paymentAmount != swap->I.bobrealsat) { @@ -767,7 +766,7 @@ int32_t LP_etomic_pub2addr(char *coinaddr,uint8_t pub64[64]) uint8_t LP_etomic_is_empty_tx_id(char *txId) { - if (strcmp(txId, EMPTY_ETH_TX_ID) == 0) { + if (txId[0] == 0 || strcmp(txId, EMPTY_ETH_TX_ID) == 0) { return 1; } return 0; diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index 8503a65f9..b8ff8a194 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -206,7 +206,7 @@ struct basilisk_rawtxinfo { char destaddr[64],ethTxid[75]; bits256 txid,signedtxid,actualtxid; - int64_t amount,change,inputsum; + int64_t amount,change,inputsum,eth_amount; int32_t redeemlen,datalen,completed,vintype,vouttype,numconfirms,spendlen,secretstart,suppress_pubkeys; uint32_t locktime,crcs[2]; uint8_t addrtype,pubkey33[33],rmd160[20]; @@ -278,7 +278,7 @@ struct LP_swap_remember uint32_t finishtime,tradeid,requestid,quoteid,plocktime,dlocktime,expiration,state,otherstate; int32_t iambob,finishedflag,origfinishedflag,Predeemlen,Dredeemlen,sentflags[sizeof(txnames)/sizeof(*txnames)]; uint8_t secretAm[20],secretAm256[32],secretBn[20],secretBn256[32],Predeemscript[1024],Dredeemscript[1024],pubkey33[33],other33[33]; - char uuidstr[65],Agui[65],Bgui[65],gui[65],src[65],dest[65],bobtomic[128],alicetomic[128],etomicsrc[65],etomicdest[65],destaddr[64],Adestaddr[64],Sdestaddr[64],alicepaymentaddr[64],bobpaymentaddr[64],bobdepositaddr[64],alicecoin[65],bobcoin[65],*txbytes[sizeof(txnames)/sizeof(*txnames)],bobDepositEthTx[75],bobPaymentEthTx[75],alicePaymentEthTx[75]; + char uuidstr[65],Agui[65],Bgui[65],gui[65],src[65],dest[65],bobtomic[128],alicetomic[128],etomicsrc[65],etomicdest[65],destaddr[64],Adestaddr[64],Sdestaddr[64],alicepaymentaddr[64],bobpaymentaddr[64],bobdepositaddr[64],alicecoin[65],bobcoin[65],*txbytes[sizeof(txnames)/sizeof(*txnames)],bobDepositEthTx[75],bobPaymentEthTx[75],aliceFeeEthTx[75],alicePaymentEthTx[75]; }; struct LP_outpoint diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 732d0f73b..1772b3d05 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -70,6 +70,12 @@ void basilisk_dontforget(struct basilisk_swap *swap,struct basilisk_rawtx *rawtx fprintf(fp,",\"bobtomic\":\"%s\"",swap->I.bobtomic); if ( swap->I.etomicsrc[0] != 0 ) fprintf(fp,",\"etomicsrc\":\"%s\"",swap->I.etomicsrc); + if (swap->myfee.I.ethTxid[0] != 0) { + fprintf(fp,",\"aliceFeeEthTx\":\"%s\"", swap->myfee.I.ethTxid); + } + if (swap->otherfee.I.ethTxid[0] != 0) { + fprintf(fp,",\"aliceFeeEthTx\":\"%s\"", swap->otherfee.I.ethTxid); + } if (swap->bobdeposit.I.ethTxid[0] != 0) { fprintf(fp,",\"bobDepositEthTx\":\"%s\"", swap->bobdeposit.I.ethTxid); } @@ -253,6 +259,22 @@ void basilisk_dontforget_update(struct basilisk_swap *swap,struct basilisk_rawtx { if ( (reqjson= cJSON_Parse(fstr)) != 0 ) { +#ifndef NOTETOMIC + if (strcmp(rawtx->symbol,"ETOMIC") == 0) { + jdelete(reqjson,"txid"); + jdelete(reqjson,"amount"); + jaddstr(reqjson,"txid", rawtx->I.ethTxid); + jaddnum(reqjson,"amount", dstr(rawtx->I.eth_amount)); + jdelete(reqjson, "coin"); + if (rawtx == &swap->myfee || rawtx == &swap->otherfee || rawtx == &swap->alicepayment || rawtx == &swap->bobspend || rawtx == &swap->alicereclaim) { + jaddstr(reqjson,"coin", swap->I.alicestr); + } + + if (rawtx == &swap->bobdeposit || rawtx == &swap->bobrefund || rawtx == &swap->aliceclaim || rawtx == &swap->bobpayment || rawtx == &swap->bobreclaim || rawtx == &swap->alicespend) { + jaddstr(reqjson,"coin", swap->I.bobstr); + } + } +#endif if ( jobj(reqjson,"method") != 0 ) jdelete(reqjson,"method"); jaddstr(reqjson,"method","update"); @@ -685,7 +707,35 @@ cJSON *LP_swap_json(struct LP_swap_remember *rswap) jaddbits256(item,"Apaymentspent",rswap->Apaymentspent); jaddbits256(item,"depositspent",rswap->depositspent); jaddbits256(item,"alicedexfee",rswap->iambob == 0 ? rswap->txids[BASILISK_MYFEE] : rswap->txids[BASILISK_OTHERFEE]); - + if ( rswap->bobtomic[0] != 0 || rswap->alicetomic[0] != 0) { + cJSON *eth_info = cJSON_CreateObject(); + if (rswap->alicetomic[0] != 0) { + cJSON *a_fee = cJSON_CreateObject(); + jaddstr(a_fee, "txid", rswap->aliceFeeEthTx); + jaddnum(a_fee, "amount", dstr(LP_DEXFEE(rswap->alicerealsat))); + cJSON_AddItemToObject(eth_info, "alicefee", a_fee); + + cJSON *a_payment = cJSON_CreateObject(); + jaddstr(a_payment, "txid", rswap->alicePaymentEthTx); + jaddnum(a_payment, "amount", dstr(rswap->alicerealsat)); + cJSON_AddItemToObject(eth_info, "alicepayment", a_payment); + } + + if (rswap->bobtomic[0] != 0) { + cJSON *b_deposit = cJSON_CreateObject(); + jaddstr(b_deposit, "txid", rswap->bobDepositEthTx); + jaddnum(b_deposit, "amount", dstr(LP_DEPOSITSATOSHIS(rswap->bobrealsat))); + cJSON_AddItemToObject(eth_info, "bobdeposit", b_deposit); + + cJSON *b_payment = cJSON_CreateObject(); + jaddstr(b_payment, "txid", rswap->bobPaymentEthTx); + jaddnum(b_payment, "amount", dstr(rswap->bobrealsat)); + cJSON_AddItemToObject(eth_info, "bobpayment", b_payment); + } + + cJSON_AddItemToObject(item, "eth_info", eth_info); + } + return(item); } @@ -906,6 +956,10 @@ int32_t LP_swap_load(struct LP_swap_remember *rswap,int32_t forceflag) strcpy(rswap->etomicdest,jstr(txobj,"etomicdest")); } + if (jstr(txobj,"aliceFeeEthTx") != 0) { + strcpy(rswap->aliceFeeEthTx, jstr(txobj,"aliceFeeEthTx")); + } + if (jstr(txobj,"bobDepositEthTx") != 0) { strcpy(rswap->bobDepositEthTx, jstr(txobj,"bobDepositEthTx")); } diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index 8d6a9c1e5..b4113840f 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -1342,6 +1342,20 @@ struct basilisk_swap *bitcoin_swapinit(bits256 privkey,uint8_t *pubkey33,bits256 swap->bobpayment.utxotxid = qp->txid, swap->bobpayment.utxovout = qp->vout; swap->bobdeposit.utxotxid = qp->txid2, swap->bobdeposit.utxovout = qp->vout2; swap->alicepayment.utxotxid = qp->desttxid, swap->alicepayment.utxovout = qp->destvout; +#ifndef NOTETOMIC + if (strcmp(alicestr, "ETOMIC") == 0) { + swap->alicepayment.I.eth_amount = swap->I.alicerealsat; + if (swap->I.iambob == 1) { + swap->otherfee.I.eth_amount = LP_DEXFEE(swap->I.alicerealsat); + } else { + swap->myfee.I.eth_amount = LP_DEXFEE(swap->I.alicerealsat); + } + } + if (strcmp(bobstr, "ETOMIC") == 0) { + swap->bobpayment.I.eth_amount = swap->I.bobrealsat; + swap->bobdeposit.I.eth_amount = LP_DEPOSITSATOSHIS(swap->I.bobrealsat); + } +#endif LP_mark_spent(bobstr,qp->txid,qp->vout); LP_mark_spent(bobstr,qp->txid2,qp->vout2); LP_mark_spent(alicestr,qp->desttxid,qp->destvout); From 38bf61e56c23ebfc11afc87f06ea195621ec05a6 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Sun, 22 Jul 2018 19:28:45 +0700 Subject: [PATCH 135/139] #97 Do not request ETOMIC from faucet if balance >= 20. --- iguana/exchanges/LP_commands.c | 11 +---------- iguana/exchanges/LP_socket.c | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index 871d04195..1c77bc4f7 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -613,7 +613,7 @@ version\n\ return(jprint(retjson,1)); } #ifndef NOTETOMIC - if (strcmp(coin, "ETOMIC") == 0) { + if (strcmp(coin, "ETOMIC") == 0 && LP_RTsmartbalance(ptr) < 20 * SATOSHIDEN) { if (get_etomic_from_faucet(ptr->smartaddr) != 1) { return(clonestr("{\"error\":\"Could not get ETOMIC from faucet!\"}")); } @@ -641,8 +641,6 @@ version\n\ { cJSON *array; ptr->inactive = 0; - if ( ptr->smartaddr[0] != 0 ) - LP_unspents_load(coin,ptr->smartaddr); LP_unspents_load(coin,ptr->smartaddr); if ( strcmp(ptr->symbol,"KMD") == 0 ) LP_importaddress("KMD",BOTS_BONDADDRESS); @@ -708,13 +706,6 @@ version\n\ { if ( (ptr= LP_coinsearch(coin)) != 0 ) { -#ifndef NOTETOMIC - if (strcmp(coin, "ETOMIC") == 0) { - if (get_etomic_from_faucet(ptr->smartaddr) != 1) { - return(clonestr("{\"error\":\"Could not get ETOMIC from faucet!\"}")); - } - } -#endif ptr->inactive = 0; return(jprint(LP_electrumserver(ptr,jstr(argjson,"ipaddr"),juint(argjson,"port")),1)); } else return(clonestr("{\"error\":\"cant find coind\"}")); diff --git a/iguana/exchanges/LP_socket.c b/iguana/exchanges/LP_socket.c index 71162b67d..8c71e1586 100644 --- a/iguana/exchanges/LP_socket.c +++ b/iguana/exchanges/LP_socket.c @@ -1277,7 +1277,21 @@ cJSON *LP_electrumserver(struct iguana_info *coin,char *ipaddr,uint16_t port) jaddnum(retjson,"restart",kickval); } } +#ifndef NOTETOMIC + if (strcmp(coin->symbol, "ETOMIC") == 0) { + cJSON *balance = cJSON_CreateObject(); + electrum_address_getbalance(coin->symbol, ep, &balance, coin->smartaddr); + int64_t confirmed = get_cJSON_int(balance, "confirmed"); + int64_t unconfirmed = get_cJSON_int(balance, "unconfirmed"); + if ((confirmed + unconfirmed) < 20 * SATOSHIDEN && get_etomic_from_faucet(coin->smartaddr) != 1) { + coin->inactive = (uint32_t)time(NULL); + coin->electrum = ep->prev; + cJSON_Delete(balance); + return(cJSON_Parse("{\"error\":\"Could not get ETOMIC from faucet!\"}")); + } + cJSON_Delete(balance); + } +#endif //printf("(%s)\n",jprint(retjson,0)); return(retjson); } - From a7e4f5810bd662e1d6caa4a2e62c82d603eb5df5 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Sun, 22 Jul 2018 20:45:17 +0700 Subject: [PATCH 136/139] #104 Expose ETH/ERC20 spending txs data on WS endpoint and trade status. --- iguana/exchanges/LP_include.h | 3 ++- iguana/exchanges/LP_remember.c | 35 ++++++++++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index b8ff8a194..3a2e26606 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -278,7 +278,8 @@ struct LP_swap_remember uint32_t finishtime,tradeid,requestid,quoteid,plocktime,dlocktime,expiration,state,otherstate; int32_t iambob,finishedflag,origfinishedflag,Predeemlen,Dredeemlen,sentflags[sizeof(txnames)/sizeof(*txnames)]; uint8_t secretAm[20],secretAm256[32],secretBn[20],secretBn256[32],Predeemscript[1024],Dredeemscript[1024],pubkey33[33],other33[33]; - char uuidstr[65],Agui[65],Bgui[65],gui[65],src[65],dest[65],bobtomic[128],alicetomic[128],etomicsrc[65],etomicdest[65],destaddr[64],Adestaddr[64],Sdestaddr[64],alicepaymentaddr[64],bobpaymentaddr[64],bobdepositaddr[64],alicecoin[65],bobcoin[65],*txbytes[sizeof(txnames)/sizeof(*txnames)],bobDepositEthTx[75],bobPaymentEthTx[75],aliceFeeEthTx[75],alicePaymentEthTx[75]; + char uuidstr[65],Agui[65],Bgui[65],gui[65],src[65],dest[65],bobtomic[128],alicetomic[128],etomicsrc[65],etomicdest[65],destaddr[64],Adestaddr[64],Sdestaddr[64],alicepaymentaddr[64],bobpaymentaddr[64],bobdepositaddr[64],alicecoin[65],bobcoin[65],*txbytes[sizeof(txnames)/sizeof(*txnames)]; + char bobDepositEthTx[75],bobPaymentEthTx[75],aliceFeeEthTx[75],alicePaymentEthTx[75],bobPaymentSpentEth[75],alicePaymentSpentEth[75],bobDepositSpentEth[75]; }; struct LP_outpoint diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 1772b3d05..200e1fac5 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -707,6 +707,7 @@ cJSON *LP_swap_json(struct LP_swap_remember *rswap) jaddbits256(item,"Apaymentspent",rswap->Apaymentspent); jaddbits256(item,"depositspent",rswap->depositspent); jaddbits256(item,"alicedexfee",rswap->iambob == 0 ? rswap->txids[BASILISK_MYFEE] : rswap->txids[BASILISK_OTHERFEE]); +#ifndef NOTETOMIC if ( rswap->bobtomic[0] != 0 || rswap->alicetomic[0] != 0) { cJSON *eth_info = cJSON_CreateObject(); if (rswap->alicetomic[0] != 0) { @@ -719,6 +720,13 @@ cJSON *LP_swap_json(struct LP_swap_remember *rswap) jaddstr(a_payment, "txid", rswap->alicePaymentEthTx); jaddnum(a_payment, "amount", dstr(rswap->alicerealsat)); cJSON_AddItemToObject(eth_info, "alicepayment", a_payment); + + if (rswap->alicePaymentSpentEth[0] != 0) { + cJSON *a_payment_spent = cJSON_CreateObject(); + jaddstr(a_payment_spent, "txid", rswap->alicePaymentSpentEth); + jaddnum(a_payment_spent, "amount", dstr(rswap->alicerealsat)); + cJSON_AddItemToObject(eth_info, "alicepaymentspent", a_payment_spent); + } } if (rswap->bobtomic[0] != 0) { @@ -731,11 +739,24 @@ cJSON *LP_swap_json(struct LP_swap_remember *rswap) jaddstr(b_payment, "txid", rswap->bobPaymentEthTx); jaddnum(b_payment, "amount", dstr(rswap->bobrealsat)); cJSON_AddItemToObject(eth_info, "bobpayment", b_payment); + if (rswap->bobDepositSpentEth[0] != 0) { + cJSON *b_deposit_spent = cJSON_CreateObject(); + jaddstr(b_deposit_spent, "txid", rswap->bobDepositSpentEth); + jaddnum(b_deposit_spent, "amount", dstr(LP_DEPOSITSATOSHIS(rswap->bobrealsat))); + cJSON_AddItemToObject(eth_info, "bobdepositspent", b_deposit_spent); + } + + if (rswap->bobPaymentSpentEth[0] != 0) { + cJSON *b_payment_spent = cJSON_CreateObject(); + jaddstr(b_payment_spent, "txid", rswap->bobPaymentSpentEth); + jaddnum(b_payment_spent, "amount", dstr(rswap->bobrealsat)); + cJSON_AddItemToObject(eth_info, "bobpaymentspent", b_payment_spent); + } } cJSON_AddItemToObject(item, "eth_info", eth_info); } - +#endif return(item); } @@ -1337,6 +1358,7 @@ cJSON *basilisk_remember(int32_t fastflag,int64_t *KMDtotals,int64_t *BTCtotals, { char *aliceSpendEthTxId = LP_etomicalice_spends_bob_payment(&rswap); if (aliceSpendEthTxId != NULL) { + strcpy(rswap.bobPaymentSpentEth, aliceSpendEthTxId); free(aliceSpendEthTxId); } else { printf("Alice spend ETH tx send failed!\n"); @@ -1386,6 +1408,7 @@ cJSON *basilisk_remember(int32_t fastflag,int64_t *KMDtotals,int64_t *BTCtotals, { char *aliceClaimsEthTxId = LP_etomicalice_claims_bob_deposit(&rswap); if (aliceClaimsEthTxId != NULL) { + strcpy(rswap.bobDepositSpentEth, aliceClaimsEthTxId); free(aliceClaimsEthTxId); } else { printf("Alice Bob deposit claim ETH tx failed!\n"); @@ -1418,7 +1441,12 @@ cJSON *basilisk_remember(int32_t fastflag,int64_t *KMDtotals,int64_t *BTCtotals, if ( rswap.alicetomic[0] != 0 ) { char *aliceReclaimEthTx = LP_etomicalice_reclaims_payment(&rswap); - free(aliceReclaimEthTx); + if (aliceReclaimEthTx != NULL) { + strcpy(rswap.alicePaymentSpentEth, aliceReclaimEthTx); + free(aliceReclaimEthTx); + } else { + printf("Alice could not reclaim ETH/ERC20 payment!\n"); + } } #endif } @@ -1462,6 +1490,7 @@ cJSON *basilisk_remember(int32_t fastflag,int64_t *KMDtotals,int64_t *BTCtotals, { char *bobSpendEthTx = LP_etomicbob_spends_alice_payment(&rswap); if (bobSpendEthTx != NULL) { + strcpy(rswap.alicePaymentSpentEth, bobSpendEthTx); free(bobSpendEthTx); } else { printf("Bob spends Alice payment ETH tx send failed!\n"); @@ -1499,6 +1528,7 @@ cJSON *basilisk_remember(int32_t fastflag,int64_t *KMDtotals,int64_t *BTCtotals, { char *bobReclaimEthTx = LP_etomicbob_reclaims_payment(&rswap); if (bobReclaimEthTx != NULL) { + strcpy(rswap.bobPaymentSpentEth, bobReclaimEthTx); free(bobReclaimEthTx); } else { printf("Bob reclaims payment ETH tx send failed!\n"); @@ -1552,6 +1582,7 @@ cJSON *basilisk_remember(int32_t fastflag,int64_t *KMDtotals,int64_t *BTCtotals, { char *bobRefundsEthTx = LP_etomicbob_refunds_deposit(&rswap); if (bobRefundsEthTx != NULL) { + strcpy(rswap.bobDepositSpentEth, bobRefundsEthTx); free(bobRefundsEthTx); } else { printf("Bob refunds deposit ETH tx send failed!\n"); From 4093b4b948928d5a3eeaf709668e208519993751 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Mon, 23 Jul 2018 13:31:00 +0700 Subject: [PATCH 137/139] #104 Fix eth_info MMJson_decode. --- crypto777/cJSON.c | 6 +++--- iguana/exchanges/LP_mmjson.c | 10 +++++++++- iguana/exchanges/LP_nativeDEX.c | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/crypto777/cJSON.c b/crypto777/cJSON.c index d62b71683..e0665e378 100755 --- a/crypto777/cJSON.c +++ b/crypto777/cJSON.c @@ -902,10 +902,10 @@ 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 ) + if ( obj->string != 0 ) return(obj->string); + if ( obj->child != 0 && obj->child->string != 0 ) + return(obj->child->string); } return((char *)""); } diff --git a/iguana/exchanges/LP_mmjson.c b/iguana/exchanges/LP_mmjson.c index 0dc67da56..354a52409 100644 --- a/iguana/exchanges/LP_mmjson.c +++ b/iguana/exchanges/LP_mmjson.c @@ -259,7 +259,15 @@ int32_t MMJSON_decodeitem(cJSON *lineobj,uint8_t *linebuf,int32_t i,int32_t len, arbstr[j++] = c; } arbstr[j] = 0; - jaddstr(lineobj,fieldstr,arbstr); +#ifndef NOTETOMIC + if (strcmp(fieldstr, "eth_info") == 0) { + cJSON_AddItemToObject(lineobj, fieldstr, cJSON_Parse(arbstr)); + } else { +#endif + jaddstr(lineobj, fieldstr, arbstr); +#ifndef NOTETOMIC + } +#endif break; default: if ( valind < MMJSON_BOUNDARY ) diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 76939ae18..7e8b66f4d 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -1226,7 +1226,7 @@ void queue_loop(void *ctx) } if ( (json= cJSON_Parse((char *)ptr->msg)) != 0 ) { - if ( 1 && ptr->msglen < sizeof(linebuf) ) + if ( ptr->msglen < sizeof(linebuf) ) { if ( (k= MMJSON_encode(linebuf,(char *)ptr->msg)) > 0 ) { From 59a700d6292c11589fa000090f4b3b82de53875b Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Wed, 25 Jul 2018 12:07:54 +0700 Subject: [PATCH 138/139] #108 do not wait for bob deposit if it was failed so send. --- iguana/exchanges/LP_swap.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index b4113840f..746f9e1cd 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -876,7 +876,6 @@ void LP_bobloop(void *_swap) err = -2003, printf("error bobscripts deposit\n"); else { - uint8_t error = 0; swap->bobrefund.utxovout = 0; swap->bobrefund.utxotxid = swap->bobdeposit.I.signedtxid; basilisk_bobdeposit_refund(swap,swap->I.putduration); @@ -886,33 +885,32 @@ void LP_bobloop(void *_swap) LP_unavailableset(swap->bobdeposit.utxotxid,swap->bobdeposit.utxovout,(uint32_t)time(NULL)+60,swap->I.otherhash); if ( LP_waitfor(swap->N.pair,swap,bobwaittimeout,LP_verify_otherfee) < 0 ) { - error = 1; err = -2004, printf("error waiting for alicefee\n"); } - if ( error == 0 ) + if ( err == 0 ) { if ( LP_swapdata_rawtxsend(swap->N.pair,swap,0x200,data,maxlen,&swap->bobdeposit,0x100,0) == 0 ) { - error = 1; err = -2005, printf("error sending bobdeposit\n"); } } - LP_unavailableset(swap->bobpayment.utxotxid,swap->bobpayment.utxovout,(uint32_t)time(NULL)+60,swap->I.otherhash); - m = swap->I.bobconfirms; - while ( (n= LP_numconfirms(bobstr,swap->bobdeposit.I.destaddr,swap->bobdeposit.I.signedtxid,0,1)) < m ) - { - LP_swap_critical = (uint32_t)time(NULL); + if (err == 0) { LP_unavailableset(swap->bobpayment.utxotxid,swap->bobpayment.utxovout,(uint32_t)time(NULL)+60,swap->I.otherhash); - char str[65];printf("%d wait for bobdeposit %s numconfs.%d %s %s\n",n,swap->bobdeposit.I.destaddr,m,bobstr,bits256_str(str,swap->bobdeposit.I.signedtxid)); - sleep(10); - } - printf("wait for alicepayment\n"); - if ( error == 0 && LP_waitfor(swap->N.pair,swap,bobwaittimeout + alicewaittimeout,LP_verify_alicepayment) < 0 ) - { - error = 1; - err = -2006, printf("error waiting for alicepayment\n"); + m = swap->I.bobconfirms; + while ((n = LP_numconfirms(bobstr, swap->bobdeposit.I.destaddr, swap->bobdeposit.I.signedtxid, 0, 1)) < m) { + LP_swap_critical = (uint32_t) time(NULL); + LP_unavailableset(swap->bobpayment.utxotxid, swap->bobpayment.utxovout, (uint32_t) time(NULL) + 60, swap->I.otherhash); + char str[65]; + printf("%d wait for bobdeposit %s numconfs.%d %s %s\n", n, swap->bobdeposit.I.destaddr, m, bobstr, bits256_str(str, swap->bobdeposit.I.signedtxid)); + sleep(10); + } + + printf("wait for alicepayment\n"); + if (LP_waitfor(swap->N.pair, swap, bobwaittimeout + alicewaittimeout, LP_verify_alicepayment) < 0) { + err = -2006, printf("error waiting for alicepayment\n"); + } } - if (error == 0) + if (err == 0) { LP_swap_critical = (uint32_t)time(NULL); if ( basilisk_bobscripts_set(swap,0,1) < 0 ) From 6f64ac0f18a093cbec662753c1f2d9bb4d11a554 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Fri, 27 Jul 2018 13:28:09 +0700 Subject: [PATCH 139/139] #104 Add txChain field to tradestatus. --- iguana/exchanges/LP_etomic.c | 40 +++++----- iguana/exchanges/LP_include.h | 17 ++-- iguana/exchanges/LP_mmjson.c | 6 +- iguana/exchanges/LP_remember.c | 139 +++++++++++++++++---------------- 4 files changed, 103 insertions(+), 99 deletions(-) diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index 3d03bec75..2964ea03d 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -200,11 +200,11 @@ uint8_t LP_etomic_verify_alice_payment(struct basilisk_swap *swap, char *txId) char *LP_etomicalice_reclaims_payment(struct LP_swap_remember *swap) { - if (waitForConfirmation(swap->alicePaymentEthTx) < 0) { - printf("Alice ETH payment %s is not found, can't reclaim\n", swap->alicePaymentEthTx); + if (waitForConfirmation(swap->eth_tx_ids[BASILISK_ALICEPAYMENT]) < 0) { + printf("Alice ETH payment %s is not found, can't reclaim\n", swap->eth_tx_ids[BASILISK_ALICEPAYMENT]); return NULL; } - EthTxReceipt receipt = getEthTxReceipt(swap->alicePaymentEthTx); + EthTxReceipt receipt = getEthTxReceipt(swap->eth_tx_ids[BASILISK_ALICEPAYMENT]); if (strcmp(receipt.status, "0x1") != 0) { printf("Alice payment receipt status failed, can't reclaim\n"); return NULL; @@ -252,11 +252,11 @@ char *LP_etomicalice_reclaims_payment(struct LP_swap_remember *swap) char *LP_etomicbob_spends_alice_payment(struct LP_swap_remember *swap) { - if (waitForConfirmation(swap->alicePaymentEthTx) < 0) { - printf("Alice ETH payment %s is not found, can't spend\n", swap->alicePaymentEthTx); + if (waitForConfirmation(swap->eth_tx_ids[BASILISK_ALICEPAYMENT]) < 0) { + printf("Alice ETH payment %s is not found, can't spend\n", swap->eth_tx_ids[BASILISK_ALICEPAYMENT]); return NULL; } - EthTxReceipt receipt = getEthTxReceipt(swap->alicePaymentEthTx); + EthTxReceipt receipt = getEthTxReceipt(swap->eth_tx_ids[BASILISK_ALICEPAYMENT]); if (strcmp(receipt.status, "0x1") != 0) { printf("Alice payment receipt status failed, can't spend\n"); return NULL; @@ -408,8 +408,8 @@ uint8_t LP_etomic_verify_bob_deposit(struct basilisk_swap *swap, char *txId) char *LP_etomicbob_refunds_deposit(struct LP_swap_remember *swap) { - if (waitForConfirmation(swap->bobDepositEthTx) < 0) { - printf("Bob deposit %s is not found, can't refund\n", swap->bobDepositEthTx); + if (waitForConfirmation(swap->eth_tx_ids[BASILISK_BOBDEPOSIT]) < 0) { + printf("Bob deposit %s is not found, can't refund\n", swap->eth_tx_ids[BASILISK_BOBDEPOSIT]); return NULL; } BobRefundsDepositInput input; @@ -423,9 +423,9 @@ char *LP_etomicbob_refunds_deposit(struct LP_swap_remember *swap) bobcoin = LP_coinfind(swap->src); privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr); - EthTxReceipt receipt = getEthTxReceipt(swap->bobDepositEthTx); + EthTxReceipt receipt = getEthTxReceipt(swap->eth_tx_ids[BASILISK_BOBDEPOSIT]); if (strcmp(receipt.status, "0x1") != 0) { - printf("Bob deposit %s receipt status failed, can't refund\n", swap->bobDepositEthTx); + printf("Bob deposit %s receipt status failed, can't refund\n", swap->eth_tx_ids[BASILISK_BOBDEPOSIT]); return NULL; } uint8arrayToHex(input.depositId, swap->txids[BASILISK_BOBDEPOSIT].bytes, 32); @@ -562,8 +562,8 @@ uint8_t LP_etomic_verify_bob_payment(struct basilisk_swap *swap, char *txId) char *LP_etomicbob_reclaims_payment(struct LP_swap_remember *swap) { - if (waitForConfirmation(swap->bobPaymentEthTx) < 0) { - printf("Bob payment %s is not found, can't reclaim\n", swap->bobPaymentEthTx); + if (waitForConfirmation(swap->eth_tx_ids[BASILISK_BOBPAYMENT]) < 0) { + printf("Bob payment %s is not found, can't reclaim\n", swap->eth_tx_ids[BASILISK_BOBPAYMENT]); return NULL; } BobReclaimsBobPaymentInput input; @@ -577,7 +577,7 @@ char *LP_etomicbob_reclaims_payment(struct LP_swap_remember *swap) bobcoin = LP_coinfind(swap->src); privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr); - EthTxReceipt receipt = getEthTxReceipt(swap->bobPaymentEthTx); + EthTxReceipt receipt = getEthTxReceipt(swap->eth_tx_ids[BASILISK_BOBPAYMENT]); if (strcmp(receipt.status, "0x1") != 0) { printf("Bob payment receipt status failed, can't reclaim\n"); return NULL; @@ -607,8 +607,8 @@ char *LP_etomicbob_reclaims_payment(struct LP_swap_remember *swap) char *LP_etomicalice_spends_bob_payment(struct LP_swap_remember *swap) { - if (waitForConfirmation(swap->bobPaymentEthTx) < 0) { - printf("Bob payment %s is not found, can't spend\n", swap->bobPaymentEthTx); + if (waitForConfirmation(swap->eth_tx_ids[BASILISK_BOBPAYMENT]) < 0) { + printf("Bob payment %s is not found, can't spend\n", swap->eth_tx_ids[BASILISK_BOBPAYMENT]); return NULL; } AliceSpendsBobPaymentInput input; @@ -616,9 +616,9 @@ char *LP_etomicalice_spends_bob_payment(struct LP_swap_remember *swap) memset(&txData,0,sizeof(txData)); memset(&input,0,sizeof(input)); - EthTxReceipt receipt = getEthTxReceipt(swap->bobPaymentEthTx); + EthTxReceipt receipt = getEthTxReceipt(swap->eth_tx_ids[BASILISK_BOBPAYMENT]); if (strcmp(receipt.status, "0x1") != 0) { - printf("Bob payment %s receipt status failed, can't spend\n", swap->bobPaymentEthTx); + printf("Bob payment %s receipt status failed, can't spend\n", swap->eth_tx_ids[BASILISK_BOBPAYMENT]); return NULL; } struct iguana_info *ecoin, *bobcoin; @@ -658,8 +658,8 @@ char *LP_etomicalice_spends_bob_payment(struct LP_swap_remember *swap) char *LP_etomicalice_claims_bob_deposit(struct LP_swap_remember *swap) { - if (waitForConfirmation(swap->bobDepositEthTx) < 0) { - printf("Bob deposit %s is not found, can't claim\n", swap->bobDepositEthTx); + if (waitForConfirmation(swap->eth_tx_ids[BASILISK_BOBDEPOSIT]) < 0) { + printf("Bob deposit %s is not found, can't claim\n", swap->eth_tx_ids[BASILISK_BOBDEPOSIT]); return NULL; } AliceClaimsBobDepositInput input; @@ -667,7 +667,7 @@ char *LP_etomicalice_claims_bob_deposit(struct LP_swap_remember *swap) memset(&txData,0,sizeof(txData)); memset(&input,0,sizeof(input)); - EthTxReceipt receipt = getEthTxReceipt(swap->bobDepositEthTx); + EthTxReceipt receipt = getEthTxReceipt(swap->eth_tx_ids[BASILISK_BOBDEPOSIT]); if (strcmp(receipt.status, "0x1") != 0) { printf("Bob deposit receipt status failed, can't claim\n"); return NULL; diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index 3a2e26606..dbb46e4f1 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -256,19 +256,19 @@ struct basilisk_swapinfo uint8_t userdata_bobrefund[256],userdata_bobrefundlen; }; -#define BASILISK_ALICESPEND 0 -#define BASILISK_BOBSPEND 1 -#define BASILISK_BOBPAYMENT 2 +#define BASILISK_MYFEE 0 +#define BASILISK_OTHERFEE 1 +#define BASILISK_BOBDEPOSIT 2 #define BASILISK_ALICEPAYMENT 3 -#define BASILISK_BOBDEPOSIT 4 -#define BASILISK_OTHERFEE 5 -#define BASILISK_MYFEE 6 +#define BASILISK_BOBPAYMENT 4 +#define BASILISK_ALICESPEND 5 +#define BASILISK_BOBSPEND 6 #define BASILISK_BOBREFUND 7 #define BASILISK_BOBRECLAIM 8 #define BASILISK_ALICERECLAIM 9 #define BASILISK_ALICECLAIM 10 //0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0 -static char *txnames[] = { "alicespend", "bobspend", "bobpayment", "alicepayment", "bobdeposit", "otherfee", "myfee", "bobrefund", "bobreclaim", "alicereclaim", "aliceclaim" }; +static char *txnames[] = { "myfee", "otherfee", "bobdeposit", "alicepayment", "bobpayment", "alicespend", "bobspend", "bobrefund", "bobreclaim", "alicereclaim", "aliceclaim" }; struct LP_swap_remember { @@ -279,7 +279,8 @@ struct LP_swap_remember int32_t iambob,finishedflag,origfinishedflag,Predeemlen,Dredeemlen,sentflags[sizeof(txnames)/sizeof(*txnames)]; uint8_t secretAm[20],secretAm256[32],secretBn[20],secretBn256[32],Predeemscript[1024],Dredeemscript[1024],pubkey33[33],other33[33]; char uuidstr[65],Agui[65],Bgui[65],gui[65],src[65],dest[65],bobtomic[128],alicetomic[128],etomicsrc[65],etomicdest[65],destaddr[64],Adestaddr[64],Sdestaddr[64],alicepaymentaddr[64],bobpaymentaddr[64],bobdepositaddr[64],alicecoin[65],bobcoin[65],*txbytes[sizeof(txnames)/sizeof(*txnames)]; - char bobDepositEthTx[75],bobPaymentEthTx[75],aliceFeeEthTx[75],alicePaymentEthTx[75],bobPaymentSpentEth[75],alicePaymentSpentEth[75],bobDepositSpentEth[75]; + char eth_tx_ids[sizeof(txnames)/sizeof(*txnames)][75]; + int64_t eth_values[sizeof(txnames)/sizeof(*txnames)]; }; struct LP_outpoint diff --git a/iguana/exchanges/LP_mmjson.c b/iguana/exchanges/LP_mmjson.c index 354a52409..591f46025 100644 --- a/iguana/exchanges/LP_mmjson.c +++ b/iguana/exchanges/LP_mmjson.c @@ -259,15 +259,11 @@ int32_t MMJSON_decodeitem(cJSON *lineobj,uint8_t *linebuf,int32_t i,int32_t len, arbstr[j++] = c; } arbstr[j] = 0; -#ifndef NOTETOMIC - if (strcmp(fieldstr, "eth_info") == 0) { + if (strcmp(fieldstr, "txChain") == 0) { cJSON_AddItemToObject(lineobj, fieldstr, cJSON_Parse(arbstr)); } else { -#endif jaddstr(lineobj, fieldstr, arbstr); -#ifndef NOTETOMIC } -#endif break; default: if ( valind < MMJSON_BOUNDARY ) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 200e1fac5..dd694d9ab 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -13,10 +13,33 @@ * Removal or modification of this copyright notice is prohibited. * * * ******************************************************************************/ +#include "LP_include.h" +#include "../../includes/cJSON.h" // // LP_remember.c // marketmaker // +char *coin_name_by_tx_index(struct LP_swap_remember *rswap, int32_t tx_index) +{ + switch (tx_index) { + case BASILISK_MYFEE: + case BASILISK_OTHERFEE: + case BASILISK_ALICEPAYMENT: + case BASILISK_ALICERECLAIM: + case BASILISK_BOBSPEND: + return rswap->dest; + case BASILISK_BOBDEPOSIT: + case BASILISK_BOBPAYMENT: + case BASILISK_BOBRECLAIM: + case BASILISK_BOBREFUND: + case BASILISK_ALICESPEND: + case BASILISK_ALICECLAIM: + return rswap->src; + default: + return 0; + } +} + void basilisk_dontforget_userdata(char *userdataname,FILE *fp,uint8_t *script,int32_t scriptlen) { int32_t i; char scriptstr[513]; @@ -70,6 +93,7 @@ void basilisk_dontforget(struct basilisk_swap *swap,struct basilisk_rawtx *rawtx fprintf(fp,",\"bobtomic\":\"%s\"",swap->I.bobtomic); if ( swap->I.etomicsrc[0] != 0 ) fprintf(fp,",\"etomicsrc\":\"%s\"",swap->I.etomicsrc); +#ifndef NOTETOMIC if (swap->myfee.I.ethTxid[0] != 0) { fprintf(fp,",\"aliceFeeEthTx\":\"%s\"", swap->myfee.I.ethTxid); } @@ -88,7 +112,7 @@ void basilisk_dontforget(struct basilisk_swap *swap,struct basilisk_rawtx *rawtx fprintf(fp,",\"aliceRealSat\":\"%" PRId64 "\"", swap->I.alicerealsat); fprintf(fp,",\"bobRealSat\":\"%" PRId64 "\"", swap->I.bobrealsat); - +#endif fprintf(fp,",\"alicecoin\":\"%s\"",swap->I.alicestr); if ( swap->I.alicetomic[0] != 0 ) fprintf(fp,",\"alicetomic\":\"%s\"",swap->I.alicetomic); @@ -681,13 +705,31 @@ cJSON *LP_swap_json(struct LP_swap_remember *rswap) jaddnum(item,"alicetxfee",dstr(rswap->Atxfee)); jadd64bits(item,"aliceid",rswap->aliceid); array = cJSON_CreateArray(); + cJSON *tx_chain = cJSON_CreateArray(); for (i=0; isentflags[i] != 0 ) - jaddistr(array,txnames[i]); + if ( rswap->sentflags[i] != 0 ) { + jaddistr(array, txnames[i]); + cJSON *tx = cJSON_CreateObject(); + jaddstr(tx, "stage", txnames[i]); + jaddstr(tx, "coin", coin_name_by_tx_index(rswap, i)); +#ifndef NOTETOMIC + if (LP_etomic_is_empty_tx_id(rswap->eth_tx_ids[i]) == 0) { + jaddstr(tx, "txid", rswap->eth_tx_ids[i]); + jaddnum(tx, "amount", dstr(rswap->eth_values[i])); + } else { +#endif + jaddbits256(tx, "txid", rswap->txids[i]); + jaddnum(tx, "amount", dstr(rswap->values[i])); +#ifndef NOTETOMIC + } +#endif + jaddi(tx_chain, tx); + } if ( rswap->txbytes[i] != 0 ) free(rswap->txbytes[i]), rswap->txbytes[i] = 0; } + jadd(item, "txChain", tx_chain); jadd(item,"sentflags",array); array = cJSON_CreateArray(); for (i=0; iApaymentspent); jaddbits256(item,"depositspent",rswap->depositspent); jaddbits256(item,"alicedexfee",rswap->iambob == 0 ? rswap->txids[BASILISK_MYFEE] : rswap->txids[BASILISK_OTHERFEE]); -#ifndef NOTETOMIC - if ( rswap->bobtomic[0] != 0 || rswap->alicetomic[0] != 0) { - cJSON *eth_info = cJSON_CreateObject(); - if (rswap->alicetomic[0] != 0) { - cJSON *a_fee = cJSON_CreateObject(); - jaddstr(a_fee, "txid", rswap->aliceFeeEthTx); - jaddnum(a_fee, "amount", dstr(LP_DEXFEE(rswap->alicerealsat))); - cJSON_AddItemToObject(eth_info, "alicefee", a_fee); - - cJSON *a_payment = cJSON_CreateObject(); - jaddstr(a_payment, "txid", rswap->alicePaymentEthTx); - jaddnum(a_payment, "amount", dstr(rswap->alicerealsat)); - cJSON_AddItemToObject(eth_info, "alicepayment", a_payment); - - if (rswap->alicePaymentSpentEth[0] != 0) { - cJSON *a_payment_spent = cJSON_CreateObject(); - jaddstr(a_payment_spent, "txid", rswap->alicePaymentSpentEth); - jaddnum(a_payment_spent, "amount", dstr(rswap->alicerealsat)); - cJSON_AddItemToObject(eth_info, "alicepaymentspent", a_payment_spent); - } - } - - if (rswap->bobtomic[0] != 0) { - cJSON *b_deposit = cJSON_CreateObject(); - jaddstr(b_deposit, "txid", rswap->bobDepositEthTx); - jaddnum(b_deposit, "amount", dstr(LP_DEPOSITSATOSHIS(rswap->bobrealsat))); - cJSON_AddItemToObject(eth_info, "bobdeposit", b_deposit); - - cJSON *b_payment = cJSON_CreateObject(); - jaddstr(b_payment, "txid", rswap->bobPaymentEthTx); - jaddnum(b_payment, "amount", dstr(rswap->bobrealsat)); - cJSON_AddItemToObject(eth_info, "bobpayment", b_payment); - if (rswap->bobDepositSpentEth[0] != 0) { - cJSON *b_deposit_spent = cJSON_CreateObject(); - jaddstr(b_deposit_spent, "txid", rswap->bobDepositSpentEth); - jaddnum(b_deposit_spent, "amount", dstr(LP_DEPOSITSATOSHIS(rswap->bobrealsat))); - cJSON_AddItemToObject(eth_info, "bobdepositspent", b_deposit_spent); - } - - if (rswap->bobPaymentSpentEth[0] != 0) { - cJSON *b_payment_spent = cJSON_CreateObject(); - jaddstr(b_payment_spent, "txid", rswap->bobPaymentSpentEth); - jaddnum(b_payment_spent, "amount", dstr(rswap->bobrealsat)); - cJSON_AddItemToObject(eth_info, "bobpaymentspent", b_payment_spent); - } - } - - cJSON_AddItemToObject(item, "eth_info", eth_info); - } -#endif return(item); } @@ -977,20 +969,32 @@ int32_t LP_swap_load(struct LP_swap_remember *rswap,int32_t forceflag) strcpy(rswap->etomicdest,jstr(txobj,"etomicdest")); } + rswap->bobrealsat = jint(txobj, "bobRealSat"); + rswap->alicerealsat = jint(txobj, "aliceRealSat"); + if (jstr(txobj,"aliceFeeEthTx") != 0) { - strcpy(rswap->aliceFeeEthTx, jstr(txobj,"aliceFeeEthTx")); + if (rswap->iambob == 0) { + strcpy(rswap->eth_tx_ids[BASILISK_MYFEE], jstr(txobj, "aliceFeeEthTx")); + rswap->eth_values[BASILISK_MYFEE] = LP_DEXFEE(rswap->alicerealsat); + } else { + strcpy(rswap->eth_tx_ids[BASILISK_OTHERFEE], jstr(txobj, "aliceFeeEthTx")); + rswap->eth_values[BASILISK_OTHERFEE] = LP_DEXFEE(rswap->alicerealsat); + } } if (jstr(txobj,"bobDepositEthTx") != 0) { - strcpy(rswap->bobDepositEthTx, jstr(txobj,"bobDepositEthTx")); + strcpy(rswap->eth_tx_ids[BASILISK_BOBDEPOSIT], jstr(txobj,"bobDepositEthTx")); + rswap->eth_values[BASILISK_BOBDEPOSIT] = LP_DEPOSITSATOSHIS(rswap->bobrealsat); } if (jstr(txobj,"bobPaymentEthTx") != 0) { - strcpy(rswap->bobPaymentEthTx, jstr(txobj,"bobPaymentEthTx")); + strcpy(rswap->eth_tx_ids[BASILISK_BOBPAYMENT], jstr(txobj,"bobPaymentEthTx")); + rswap->eth_values[BASILISK_BOBPAYMENT] = rswap->bobrealsat; } if (jstr(txobj,"alicePaymentEthTx") != 0) { - strcpy(rswap->alicePaymentEthTx, jstr(txobj,"alicePaymentEthTx")); + strcpy(rswap->eth_tx_ids[BASILISK_ALICEPAYMENT], jstr(txobj,"alicePaymentEthTx")); + rswap->eth_values[BASILISK_ALICEPAYMENT] = rswap->alicerealsat; } if (jstr(txobj,"bobtomic") != 0) { @@ -1001,9 +1005,6 @@ int32_t LP_swap_load(struct LP_swap_remember *rswap,int32_t forceflag) strcpy(rswap->alicetomic, jstr(txobj,"alicetomic")); } - rswap->bobrealsat = jint(txobj, "bobRealSat"); - rswap->alicerealsat = jint(txobj, "aliceRealSat"); - rswap->txids[i] = txid; if ( jstr(txobj,"Apayment") != 0 ) safecopy(rswap->alicepaymentaddr,jstr(txobj,"Apayment"),sizeof(rswap->alicepaymentaddr)); @@ -1358,7 +1359,8 @@ cJSON *basilisk_remember(int32_t fastflag,int64_t *KMDtotals,int64_t *BTCtotals, { char *aliceSpendEthTxId = LP_etomicalice_spends_bob_payment(&rswap); if (aliceSpendEthTxId != NULL) { - strcpy(rswap.bobPaymentSpentEth, aliceSpendEthTxId); + strcpy(rswap.eth_tx_ids[BASILISK_ALICESPEND], aliceSpendEthTxId); + rswap.eth_values[BASILISK_ALICESPEND] = rswap.bobrealsat; free(aliceSpendEthTxId); } else { printf("Alice spend ETH tx send failed!\n"); @@ -1408,7 +1410,8 @@ cJSON *basilisk_remember(int32_t fastflag,int64_t *KMDtotals,int64_t *BTCtotals, { char *aliceClaimsEthTxId = LP_etomicalice_claims_bob_deposit(&rswap); if (aliceClaimsEthTxId != NULL) { - strcpy(rswap.bobDepositSpentEth, aliceClaimsEthTxId); + strcpy(rswap.eth_tx_ids[BASILISK_ALICECLAIM], aliceClaimsEthTxId); + rswap.eth_values[BASILISK_ALICECLAIM] = LP_DEPOSITSATOSHIS(rswap.bobrealsat); free(aliceClaimsEthTxId); } else { printf("Alice Bob deposit claim ETH tx failed!\n"); @@ -1442,7 +1445,8 @@ cJSON *basilisk_remember(int32_t fastflag,int64_t *KMDtotals,int64_t *BTCtotals, { char *aliceReclaimEthTx = LP_etomicalice_reclaims_payment(&rswap); if (aliceReclaimEthTx != NULL) { - strcpy(rswap.alicePaymentSpentEth, aliceReclaimEthTx); + strcpy(rswap.eth_tx_ids[BASILISK_ALICERECLAIM], aliceReclaimEthTx); + rswap.eth_values[BASILISK_ALICERECLAIM] = rswap.alicerealsat; free(aliceReclaimEthTx); } else { printf("Alice could not reclaim ETH/ERC20 payment!\n"); @@ -1490,7 +1494,8 @@ cJSON *basilisk_remember(int32_t fastflag,int64_t *KMDtotals,int64_t *BTCtotals, { char *bobSpendEthTx = LP_etomicbob_spends_alice_payment(&rswap); if (bobSpendEthTx != NULL) { - strcpy(rswap.alicePaymentSpentEth, bobSpendEthTx); + strcpy(rswap.eth_tx_ids[BASILISK_BOBSPEND], bobSpendEthTx); + rswap.eth_values[BASILISK_BOBSPEND] = rswap.alicerealsat; free(bobSpendEthTx); } else { printf("Bob spends Alice payment ETH tx send failed!\n"); @@ -1528,7 +1533,8 @@ cJSON *basilisk_remember(int32_t fastflag,int64_t *KMDtotals,int64_t *BTCtotals, { char *bobReclaimEthTx = LP_etomicbob_reclaims_payment(&rswap); if (bobReclaimEthTx != NULL) { - strcpy(rswap.bobPaymentSpentEth, bobReclaimEthTx); + strcpy(rswap.eth_tx_ids[BASILISK_BOBRECLAIM], bobReclaimEthTx); + rswap.eth_values[BASILISK_BOBRECLAIM] = rswap.bobrealsat; free(bobReclaimEthTx); } else { printf("Bob reclaims payment ETH tx send failed!\n"); @@ -1582,7 +1588,8 @@ cJSON *basilisk_remember(int32_t fastflag,int64_t *KMDtotals,int64_t *BTCtotals, { char *bobRefundsEthTx = LP_etomicbob_refunds_deposit(&rswap); if (bobRefundsEthTx != NULL) { - strcpy(rswap.bobDepositSpentEth, bobRefundsEthTx); + strcpy(rswap.eth_tx_ids[BASILISK_BOBREFUND], bobRefundsEthTx); + rswap.eth_values[BASILISK_BOBREFUND] = LP_DEPOSITSATOSHIS(rswap.bobrealsat); free(bobRefundsEthTx); } else { printf("Bob refunds deposit ETH tx send failed!\n");