From d708378c75e6cd42a86e82e1f75be2d70f3e823f Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Fri, 30 Mar 2018 16:52:26 +0700 Subject: [PATCH 01/92] 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 02/92] 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 03/92] 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 04/92] 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 05/92] 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 06/92] 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 07/92] 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 08/92] 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 09/92] 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 10/92] 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 11/92] 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 12/92] 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 13/92] 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 14/92] 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 15/92] 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 16/92] 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 17/92] 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 18/92] 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 19/92] 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 20/92] 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 21/92] 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 22/92] 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 23/92] 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 24/92] 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 25/92] 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 26/92] 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 27/92] 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 28/92] #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 29/92] #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 30/92] 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 31/92] 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 32/92] 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 33/92] 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 34/92] 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 35/92] 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 36/92] 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 37/92] 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 38/92] 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 39/92] 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 40/92] -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 41/92] 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 42/92] 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 43/92] 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 44/92] 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 45/92] 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 46/92] 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 47/92] 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 48/92] 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 49/92] 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 50/92] 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 51/92] 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 52/92] 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 53/92] 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 54/92] 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 55/92] 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 56/92] 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 57/92] 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 58/92] 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 59/92] 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 60/92] 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 61/92] 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 62/92] 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 63/92] 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 64/92] 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 65/92] 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 66/92] 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 67/92] 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 68/92] 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 69/92] 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 70/92] 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 71/92] 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 72/92] 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 73/92] 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 74/92] 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 75/92] 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 76/92] 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 77/92] 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 78/92] 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 79/92] 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 80/92] 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 81/92] 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 82/92] 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 83/92] #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 84/92] #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 85/92] #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 86/92] #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 87/92] #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 88/92] #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 89/92] #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 90/92] #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 91/92] #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 92/92] #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; }