From b0d9e5f22bd0574475a1f89c3dae128558de899e Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Fri, 15 Jun 2018 11:29:57 +0700 Subject: [PATCH 01/10] #66 Do not forcefully use 1 ETOMIC for ETH/ERC20 trades yet. --- iguana/exchanges/LP_swap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index 5c7af583e..f16efbd20 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -1201,11 +1201,11 @@ struct basilisk_swap *bitcoin_swapinit(bits256 privkey,uint8_t *pubkey33,bits256 #ifndef NOTETOMIC if (strcmp(alicestr, "ETOMIC") == 0) { swap->I.alicerealsat = swap->I.alicesatoshis; - swap->I.alicesatoshis = 100000000; + //swap->I.alicesatoshis = 100000000; } if (strcmp(bobstr, "ETOMIC") == 0) { swap->I.bobrealsat = swap->I.bobsatoshis; - swap->I.bobsatoshis = 100000000; + //swap->I.bobsatoshis = 100000000; } #endif if ( (swap->I.bobinsurance= (swap->I.bobsatoshis / INSTANTDEX_INSURANCEDIV)) < LP_MIN_TXFEE ) From 7844891d1e22c1677b9cdb6e4010f554ed160cb9 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Fri, 15 Jun 2018 14:44:23 +0700 Subject: [PATCH 02/10] #75 Do not call ETH/ERC20 balance for disabled coins. --- iguana/exchanges/LP_utxo.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index eb4b37131..4e9928aa2 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -787,7 +787,14 @@ cJSON *LP_balances(char *coinaddr) } else { - if ( (balance= LP_RTsmartbalance(coin)) != 0 ) +#ifndef NOTETOMIC + if (coin->etomic[0] == 0 || coin->inactive == 0) { +#endif + balance = LP_RTsmartbalance(coin); +#ifndef NOTETOMIC + } +#endif + if ( balance != 0 ) { item = cJSON_CreateObject(); jaddstr(item,"coin",coin->symbol); From bfdf9a3265a97452a512aa4e179de338975bda4f Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Fri, 15 Jun 2018 17:30:07 +0700 Subject: [PATCH 03/10] #66 Possibly finish forcing 1 ETOMIC for ETH/ERC20 trades. --- iguana/exchanges/LP_ordermatch.c | 24 ++++++++++++++++++------ iguana/exchanges/LP_swap.c | 4 ++-- iguana/exchanges/LP_utxo.c | 2 +- start_BEER_OTHER_trade.sh | 10 +++------- start_BEER_OTHER_trade_inverted.sh | 10 +++------- 5 files changed, 27 insertions(+), 23 deletions(-) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index 7dc3b7c0c..957e87d45 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -195,7 +195,7 @@ double LP_quote_validate(struct LP_utxoinfo *autxo,struct LP_utxoinfo *butxo,str printf("destvalue %.8f destsatoshis %.8f is too small txfee %.8f?\n",dstr(destvalue),dstr(qp->destsatoshis),dstr(qp->desttxfee)); return(-11); } - if ( butxo != 0 && srcvalue < qp->txfee+qp->satoshis ) + if ( strcmp(srccoin, "ETOMIC") != 0 && butxo != 0 && srcvalue < qp->txfee+qp->satoshis ) { printf("srcvalue %.8f [%.8f] satoshis %.8f is too small txfee %.8f?\n",dstr(srcvalue),dstr(srcvalue) - dstr(qp->txfee+qp->satoshis),dstr(qp->satoshis),dstr(qp->txfee)); return(-33); @@ -213,7 +213,7 @@ double LP_quote_validate(struct LP_utxoinfo *autxo,struct LP_utxoinfo *butxo,str printf("error -14: txfee %.8f < %.8f or desttxfee %.8f < %.8f\n",dstr(qp->txfee),dstr(LP_REQUIRED_TXFEE*txfee),dstr(qp->desttxfee),dstr(LP_REQUIRED_TXFEE*desttxfee)); return(-14); } - if ( butxo != 0 ) + if ( butxo != 0 && strcmp(srccoin, "ETOMIC") != 0) { if ( qp->satoshis < (srcvalue / LP_MINVOL) || srcvalue < qp->txfee*LP_MINSIZE_TXFEEMULT ) { @@ -413,14 +413,22 @@ struct LP_utxoinfo *LP_address_myutxopair(struct LP_utxoinfo *butxo,int32_t iamb memset(butxo,0,sizeof(*butxo)); if ( iambob != 0 ) { - targetval = LP_basesatoshis(relvolume,price,txfee,desttxfee) + 3*txfee; + if (strcmp(coin->symbol, "ETOMIC") == 0) { + targetval = 100000000 + 3*txfee; + } else { + targetval = LP_basesatoshis(relvolume,price,txfee,desttxfee) + 3*txfee; + } targetval2 = (targetval / 8) * 9 + 3*txfee; fee = txfee; ratio = LP_MINVOL; } else { - targetval = relvolume*SATOSHIDEN + 3*desttxfee; + if (strcmp(coin->symbol, "ETOMIC") == 0) { + targetval = 100000000 + 3*desttxfee; + } else { + targetval = relvolume*SATOSHIDEN + 3*desttxfee; + } targetval2 = (targetval / 777) + 3*desttxfee; fee = desttxfee; ratio = LP_MINCLIENTVOL; @@ -906,7 +914,7 @@ double LP_trades_pricevalidate(struct LP_quoteinfo *qp,struct iguana_info *coin, printf("quote %s/%s validate error %.0f\n",qp->srccoin,qp->destcoin,qprice); return(-3); } - if ( qprice < (price - 0.00000001) * 0.998 ) + if ( qprice < (price - 0.00000001) * 0.998) { printf(" quote price %.8f (%llu/%llu %.8f) too low vs %.8f for %s/%s price %.8f %.8f\n",qprice,(long long)qp->destsatoshis,(long long)(qp->satoshis-qp->txfee),(double)qp->destsatoshis/(qp->satoshis-qp->txfee),price,qp->srccoin,qp->destcoin,price,(price - 0.00000001) * 0.998); return(-77); @@ -1009,7 +1017,11 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru qp->vout = butxo->payment.vout; qp->txid2 = butxo->deposit.txid; qp->vout2 = butxo->deposit.vout; - qp->satoshis = butxo->swap_satoshis;// + qp->txfee; + if (coin->etomic[0] == 0) { + qp->satoshis = butxo->swap_satoshis;// + qp->txfee; + } else { + qp->satoshis = LP_basesatoshis(dstr(qp->destsatoshis), price, qp->txfee, qp->desttxfee); + } qp->quotetime = (uint32_t)time(NULL); } else diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index f16efbd20..5c7af583e 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -1201,11 +1201,11 @@ struct basilisk_swap *bitcoin_swapinit(bits256 privkey,uint8_t *pubkey33,bits256 #ifndef NOTETOMIC if (strcmp(alicestr, "ETOMIC") == 0) { swap->I.alicerealsat = swap->I.alicesatoshis; - //swap->I.alicesatoshis = 100000000; + swap->I.alicesatoshis = 100000000; } if (strcmp(bobstr, "ETOMIC") == 0) { swap->I.bobrealsat = swap->I.bobsatoshis; - //swap->I.bobsatoshis = 100000000; + swap->I.bobsatoshis = 100000000; } #endif if ( (swap->I.bobinsurance= (swap->I.bobsatoshis / INSTANTDEX_INSURANCEDIV)) < LP_MIN_TXFEE ) diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index 4e9928aa2..944876a90 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -1192,7 +1192,7 @@ int32_t LP_iseligible(uint64_t *valp,uint64_t *val2p,int32_t iambob,char *symbol return(-1); } destaddr[0] = destaddr2[0] = 0; - if ( coin != 0 && IAMLP != 0 && coin->inactive != 0 ) + if ( coin != 0 && (strcmp(coin->symbol, "ETOMIC") == 0 || (coin->inactive != 0 && IAMLP != 0))) bypass = 1; if ( bypass != 0 ) val = satoshis; diff --git a/start_BEER_OTHER_trade.sh b/start_BEER_OTHER_trade.sh index 23a5acee1..a81500397 100755 --- a/start_BEER_OTHER_trade.sh +++ b/start_BEER_OTHER_trade.sh @@ -1,12 +1,8 @@ #!/bin/bash -docker-compose exec -T clientnode ./setpassphrase -sleep 5 docker-compose exec -T clientnode ./enable -sleep 5 -docker-compose exec -T seednode ./setpassphrase -sleep 5 +sleep 3 docker-compose exec -T seednode ./enable -sleep 5 +sleep 3 docker-compose exec -T seednode ./sell_BEER_OTHER $1 -sleep 5 +sleep 3 docker-compose exec -T clientnode ./buy_BEER_OTHER $1 \ No newline at end of file diff --git a/start_BEER_OTHER_trade_inverted.sh b/start_BEER_OTHER_trade_inverted.sh index 68ef9ab3f..1b0f9d4be 100755 --- a/start_BEER_OTHER_trade_inverted.sh +++ b/start_BEER_OTHER_trade_inverted.sh @@ -1,12 +1,8 @@ #!/bin/bash -docker-compose exec -T clientnode ./setpassphrase -sleep 5 docker-compose exec -T clientnode ./enable -sleep 5 -docker-compose exec -T seednode ./setpassphrase -sleep 5 +sleep 3 docker-compose exec -T seednode ./enable -sleep 5 +sleep 3 docker-compose exec -T clientnode ./buy_BEER_OTHER $1 -sleep 5 +sleep 3 docker-compose exec -T seednode ./sell_BEER_OTHER $1 \ No newline at end of file From c64228ba6ba24b7916db0fc89385af04e58d5a13 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Mon, 18 Jun 2018 11:48:17 +0700 Subject: [PATCH 04/10] #66 Possibly finish using only 1 ETOMIC for ETH/ERC20 trades. --- etomic_build/client/buy_BEER_OTHER | 4 ++-- etomic_build/seed/sell_BEER_OTHER | 4 ++-- iguana/exchanges/LP_ordermatch.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/etomic_build/client/buy_BEER_OTHER b/etomic_build/client/buy_BEER_OTHER index be2acb4da..09dd12fdb 100755 --- a/etomic_build/client/buy_BEER_OTHER +++ b/etomic_build/client/buy_BEER_OTHER @@ -1,4 +1,4 @@ #!/bin/bash source userpass -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"setprice\",\"base\":\"$1\",\"rel\":\"BEER\",\"price\":1}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"sell\",\"base\":\"$1\",\"rel\":\"BEER\",\"basevolume\":0.1,\"price\":1}" \ No newline at end of file +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"setprice\",\"base\":\"$1\",\"rel\":\"BEER\",\"price\":2}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"buy\",\"base\":\"BEER\",\"rel\":\"$1\",\"relvolume\":3,\"price\":2}" diff --git a/etomic_build/seed/sell_BEER_OTHER b/etomic_build/seed/sell_BEER_OTHER index cd11fc044..bc9231bc7 100755 --- a/etomic_build/seed/sell_BEER_OTHER +++ b/etomic_build/seed/sell_BEER_OTHER @@ -1,4 +1,4 @@ #!/bin/bash source userpass -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"setprice\",\"base\":\"BEER\",\"rel\":\"$1\",\"price\":0.9}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"sell\",\"base\":\"BEER\",\"rel\":\"$1\",\"basevolume\":0.1,\"price\":0.9}" \ No newline at end of file +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"setprice\",\"base\":\"BEER\",\"rel\":\"$1\",\"price\":1.9}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"sell\",\"base\":\"BEER\",\"rel\":\"$1\",\"basevolume\":3,\"price\":1.9}" diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index 957e87d45..a37d7b57c 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -190,7 +190,7 @@ double LP_quote_validate(struct LP_utxoinfo *autxo,struct LP_utxoinfo *butxo,str if ( strcmp(autxo->coinaddr,qp->destaddr) != 0 ) return(-10); } - if ( autxo != 0 && destvalue < qp->desttxfee+qp->destsatoshis ) + if ( strcmp(destcoin, "ETOMIC") != 0 && autxo != 0 && destvalue < qp->desttxfee+qp->destsatoshis ) { printf("destvalue %.8f destsatoshis %.8f is too small txfee %.8f?\n",dstr(destvalue),dstr(qp->destsatoshis),dstr(qp->desttxfee)); return(-11); @@ -1616,7 +1616,7 @@ char *LP_autobuy(void *ctx,int32_t fomoflag,char *myipaddr,int32_t mypubsock,cha autxo->swap_satoshis = destsatoshis; //printf("first path dest %.8f from %.8f\n",dstr(destsatoshis),dstr(autxo->swap_satoshis)); } - else if ( autxo->swap_satoshis - desttxfee < destsatoshis ) + else if ( autxo->swap_satoshis - desttxfee < destsatoshis && relcoin->etomic[0] == 0) { autxo->swap_satoshis -= desttxfee; destsatoshis = autxo->swap_satoshis; From 79f7579e5a160ce0edf3567e78a223bde4b94a8a Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Tue, 19 Jun 2018 13:39:46 +0700 Subject: [PATCH 05/10] #79 Add proper ETH address comparison based on cpp-ethereum code. --- etomic_build/client/buy_BEER_OTHER | 4 ++-- etomic_build/coins | 2 +- etomic_build/seed/sell_BEER_OTHER | 4 ++-- iguana/exchanges/LP_etomic.c | 18 +++++++++--------- iguana/exchanges/etomicswap/etomiclib.cpp | 7 +++++++ iguana/exchanges/etomicswap/etomiclib.h | 2 ++ 6 files changed, 23 insertions(+), 14 deletions(-) diff --git a/etomic_build/client/buy_BEER_OTHER b/etomic_build/client/buy_BEER_OTHER index 09dd12fdb..9c4123e44 100755 --- a/etomic_build/client/buy_BEER_OTHER +++ b/etomic_build/client/buy_BEER_OTHER @@ -1,4 +1,4 @@ #!/bin/bash source userpass -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"setprice\",\"base\":\"$1\",\"rel\":\"BEER\",\"price\":2}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"buy\",\"base\":\"BEER\",\"rel\":\"$1\",\"relvolume\":3,\"price\":2}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"setprice\",\"base\":\"$1\",\"rel\":\"BEER\",\"price\":1}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"buy\",\"base\":\"BEER\",\"rel\":\"$1\",\"relvolume\":3,\"price\":1}" diff --git a/etomic_build/coins b/etomic_build/coins index db9100c13..4afe84fea 100755 --- a/etomic_build/coins +++ b/etomic_build/coins @@ -1,3 +1,3 @@ -export coins="[{\"coin\":\"OOT\",\"asset\":\"OOT\",\"rpcport\":12467}, {\"coin\":\"ETH\",\"name\":\"ethereum\",\"etomic\":\"0x0000000000000000000000000000000000000000\",\"rpcport\":80}, {\"coin\":\"EOS\",\"name\":\"EOS\",\"etomic\":\"0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0\",\"rpcport\":80},{\"coin\":\"JST\", \"name\":\"JST\",\"etomic\":\"0xc0eb7aed740e1796992a08962c15661bdeb58003\",\"rpcport\":80},{\"coin\":\"NODEC\",\"name\":\"NODEC\",\"etomic\":\"0x05beb0a9ead354283041a6d35f3b833450fb5680\",\"rpcport\":80,\"decimals\":18},{\"coin\":\"ZOI\",\"name\":\"zoin\",\"rpcport\":8255,\"pubtype\":80,\"p2shtype\":7,\"wiftype\":208,\"txfee\":1000}, {\"coin\": \"PIZZA\",\"asset\": \"PIZZA\",\"rpcport\": 11116},{\"coin\": \"BEER\",\"asset\": \"BEER\",\"rpcport\": 8923}, {\"coin\":\"GRS\",\"name\":\"groestlcoin\",\"rpcport\":1441,\"pubtype\":36,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"XMCC\",\"name\":\"monoeci\",\"confpath\":\"${HOME#}/.monoeciCore/monoeci.conf\",\"rpcport\":24156,\"pubtype\":50,\"p2shtype\":73,\"wiftype\":77,\"txfee\":10000}, {\"coin\":\"BTCH\",\"asset\":\"BTCH\",\"rpcport\":8800},{\"coin\":\"ETOMIC\",\"asset\":\"ETOMIC\",\"rpcport\":10271},{\"coin\":\"AXO\",\"asset\":\"AXO\",\"rpcport\":12927},{\"coin\":\"CRC\",\"name\":\"crowdcoin\",\"confpath\":\"${HOME#}/.crowdcoincore/crowdcoin.conf\",\"rpcport\":11998,\"pubtype\":28,\"p2shtype\":88,\"wiftype\":0,\"txfee\":10000}, {\"coin\":\"VOT\",\"name\":\"votecoin\",\"rpcport\":8232,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"INN\",\"name\":\"innova\",\"confpath\":\"${HOME#}/.innovacore/innova.conf\",\"rpcport\":8818,\"pubtype\":102,\"p2shtype\":20,\"wiftype\":195,\"txfee\":10000}, {\"coin\":\"MOON\",\"name\":\"mooncoin\",\"rpcport\":44663,\"pubtype\":3,\"p2shtype\":22,\"wiftype\":131,\"txfee\":100000}, {\"coin\":\"CRW\",\"name\":\"crown\",\"rpcport\":9341,\"pubtype\":0,\"p2shtype\":28,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"EFL\",\"name\":\"egulden\",\"confpath\":\"${HOME#}/.egulden/coin.conf\",\"rpcport\":21015,\"pubtype\":48,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"GBX\",\"name\":\"gobyte\",\"confpath\":\"${HOME#}/.gobytecore/gobyte.conf\",\"rpcport\":12454,\"pubtype\":38,\"p2shtype\":10,\"wiftype\":198,\"txfee\":10000}, {\"coin\":\"BCO\",\"name\":\"bridgecoin\",\"rpcport\":6332,\"pubtype\":27,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"BLK\",\"name\":\"blackcoin\",\"confpath\":\"${HOME#}/.lore/blackcoin.conf\",\"isPoS\":1,\"rpcport\":15715,\"pubtype\":25,\"p2shtype\":85,\"wiftype\":153,\"txfee\":100000}, {\"coin\":\"BTG\",\"name\":\"bitcoingold\",\"rpcport\":8332,\"pubtype\":38,\"p2shtype\":23,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"BCH\",\"name\":\"bch\",\"rpcport\":33333,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":1000}, {\"coin\":\"ABY\",\"name\":\"applebyte\",\"rpcport\":8607,\"pubtype\":23,\"p2shtype\":5,\"wiftype\":151,\"txfee\":100000}, {\"coin\":\"STAK\",\"name\":\"straks\",\"rpcport\":7574,\"pubtype\":63,\"p2shtype\":5,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"XZC\",\"name\":\"zcoin\",\"rpcport\":8888,\"pubtype\":82,\"p2shtype\":7,\"wiftype\":210,\"txfee\":10000}, {\"coin\":\"QTUM\",\"name\":\"qtum\",\"rpcport\":3889,\"pubtype\":58,\"p2shtype\":50,\"wiftype\":128,\"txfee\":400000}, {\"coin\":\"PURA\",\"name\":\"pura\",\"rpcport\":55555,\"pubtype\":55,\"p2shtype\":16,\"wiftype\":150,\"txfee\":10000}, {\"coin\":\"DSR\",\"name\":\"desire\",\"confpath\":\"${HOME#}/.desirecore/desire.conf\",\"rpcport\":9918,\"pubtype\":30,\"p2shtype\":16,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"MNZ\",\"asset\":\"MNZ\",\"rpcport\":14337},{\"coin\":\"BTCZ\",\"name\":\"bitcoinz\",\"rpcport\":1979,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"MAGA\",\"name\":\"magacoin\",\"rpcport\":5332,\"pubtype\":23,\"p2shtype\":50,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"BSD\",\"name\":\"bitsend\",\"rpcport\":8800,\"pubtype\":102,\"p2shtype\":5,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"IOP\",\"name\":\"IoP\",\"rpcport\":8337,\"pubtype\":117,\"p2shtype\":174,\"wiftype\":49,\"txfee\":10000}, {\"coin\":\"BLOCK\",\"name\":\"blocknetdx\",\"rpcport\":41414,\"pubtype\":26,\"p2shtype\":28,\"wiftype\":154,\"txfee\":10000}, {\"coin\":\"CHIPS\", \"name\": \"chips\", \"rpcport\":57776,\"pubtype\":60, \"p2shtype\":85, \"wiftype\":188, \"txfee\":10000}, {\"coin\":\"888\",\"name\":\"octocoin\",\"rpcport\":22888,\"pubtype\":18,\"p2shtype\":5,\"wiftype\":176,\"txfee\":2000000}, {\"coin\":\"ARG\",\"name\":\"argentum\",\"rpcport\":13581,\"pubtype\":23,\"p2shtype\":5,\"wiftype\":151,\"txfee\":50000}, {\"coin\":\"GLT\",\"name\":\"globaltoken\",\"rpcport\":9320,\"pubtype\":38,\"p2shtype\":5,\"wiftype\":166,\"txfee\":10000}, {\"coin\":\"ZER\",\"name\":\"zero\",\"rpcport\":23801,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":1000}, {\"coin\":\"HODLC\",\"name\":\"hodlcoin\",\"rpcport\":11989,\"pubtype\":40,\"p2shtype\":5,\"wiftype\":168,\"txfee\":5000}, {\"coin\":\"UIS\",\"name\":\"unitus\",\"rpcport\":50604,\"pubtype\":68,\"p2shtype\":10,\"wiftype\":132,\"txfee\":2000000}, {\"coin\":\"HUC\",\"name\":\"huntercoin\",\"rpcport\":8399,\"pubtype\":40,\"p2shtype\":13,\"wiftype\":168,\"txfee\":100000}, {\"coin\":\"BDL\",\"name\":\"bitdeal\",\"rpcport\":9332,\"pubtype\":38,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"ARC\",\"name\":\"arcticcoin\",\"confpath\":\"${HOME#}/.arcticcore/arcticcoin.conf\",\"rpcport\":7208,\"pubtype\":23,\"p2shtype\":8,\"wiftype\":176,\"txfee\":10000}, {\"coin\":\"ZCL\",\"name\":\"zclassic\",\"rpcport\":8023,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":1000}, {\"coin\":\"VIA\",\"name\":\"viacoin\",\"rpcport\":5222,\"pubtype\":71,\"p2shtype\":33,\"wiftype\":199,\"txfee\":100000}, {\"coin\":\"ERC\",\"name\":\"europecoin\",\"rpcport\":11989,\"pubtype\":33,\"p2shtype\":5,\"wiftype\":168,\"txfee\":10000},{\"coin\":\"FAIR\",\"name\":\"faircoin\",\"confpath\":\"${HOME#}/.faircoin2/faircoin.conf\",\"rpcport\":40405,\"pubtype\":95,\"p2shtype\":36,\"wiftype\":223,\"txfee\":1000000}, {\"coin\":\"FLO\",\"name\":\"florincoin\",\"rpcport\":7313,\"pubtype\":35,\"p2shtype\":8,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"SXC\",\"name\":\"sexcoin\",\"rpcport\":9561,\"pubtype\":62,\"p2shtype\":5,\"wiftype\":190,\"txfee\":100000}, {\"coin\":\"CREA\",\"name\":\"creativecoin\",\"rpcport\":17711,\"pubtype\":28,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"TRC\",\"name\":\"terracoin\",\"confpath\":\"${HOME#}/.terracoincore/terracoin.conf\",\"rpcport\":13332,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"BTA\",\"name\":\"bata\",\"rpcport\":5493,\"pubtype\":25,\"p2shtype\":5,\"wiftype\":188,\"txfee\":100000}, {\"coin\":\"SMC\",\"name\":\"smartcoin\",\"rpcport\":58583,\"pubtype\":63,\"p2shtype\":5,\"wiftype\":191,\"txfee\":1000000}, {\"coin\":\"NMC\",\"name\":\"namecoin\",\"rpcport\":8336,\"pubtype\":52,\"p2shtype\":13,\"wiftype\":180,\"txfee\":100000}, {\"coin\":\"NAV\",\"name\":\"navcoin\",\"isPoS\":1,\"confpath\":\"${HOME#}/.navcoin4/navcoin.conf\",\"rpcport\":44444,\"pubtype\":53,\"p2shtype\":85,\"wiftype\":150,\"txfee\":10000}, {\"coin\":\"EMC2\",\"name\":\"einsteinium\",\"rpcport\":41879,\"pubtype\":33,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000},{\"coin\":\"SYS\",\"name\":\"syscoin\",\"rpcport\":8370,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"I0C\",\"name\":\"i0coin\",\"rpcport\":7332,\"pubtype\":105,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"DASH\",\"confpath\":\"${HOME#}/.dashcore/dash.conf\",\"name\":\"dashcore\",\"rpcport\":9998,\"pubtype\":76,\"p2shtype\":16,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"STRAT\", \"name\": \"stratis\", \"active\":0, \"rpcport\":16174,\"pubtype\":63, \"p2shtype\":125, \"wiftype\":191, \"txfee\":10000}, {\"confpath\":\"${HOME#}/.muecore/mue.conf\",\"coin\":\"MUE\",\"name\":\"muecore\",\"rpcport\":29683,\"pubtype\":16,\"p2shtype\":76,\"wiftype\":126,\"txfee\":10000}, {\"coin\":\"MONA\",\"name\":\"monacoin\",\"rpcport\":9402,\"pubtype\":50,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000},{\"coin\":\"XMY\",\"name\":\"myriadcoin\",\"rpcport\":10889,\"pubtype\":50,\"p2shtype\":9,\"wiftype\":178,\"txfee\":5000}, {\"coin\":\"MAC\",\"name\":\"machinecoin\",\"rpcport\":40332,\"pubtype\":50,\"p2shtype\":5,\"wiftype\":178,\"txfee\":100000}, {\"coin\":\"BTX\",\"name\":\"bitcore\",\"rpcport\":8556,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":50000}, {\"coin\":\"XRE\",\"name\":\"revolvercoin\",\"rpcport\":8775,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"LBC\",\"name\":\"lbrycrd\",\"rpcport\":9245,\"pubtype\":85,\"p2shtype\":122,\"wiftype\":28,\"txfee\":10000}, {\"coin\":\"SIB\",\"name\":\"sibcoin\",\"rpcport\":1944,\"pubtype\":63,\"p2shtype\":40,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"VTC\", \"name\":\"vertcoin\", \"rpcport\":5888, \"pubtype\":71, \"p2shtype\":5, \"wiftype\":128, \"txfee\":100000 }, {\"coin\":\"REVS\",\"active\":0, \"asset\":\"REVS\",\"rpcport\":10196}, {\"coin\":\"JUMBLR\",\"active\":0, \"asset\":\"JUMBLR\",\"rpcport\":15106}, {\"coin\":\"DOGE\",\"name\":\"dogecoin\",\"rpcport\":22555,\"pubtype\":30,\"p2shtype\":22,\"wiftype\":158,\"txfee\":100000000}, {\"coin\":\"HUSH\",\"name\":\"hush\",\"rpcport\":8822,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":1000 }, {\"active\":0,\"coin\":\"ZEC\",\"name\":\"zcash\",\"rpcport\":8232,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":10000 }, {\"coin\":\"DGB\",\"name\":\"digibyte\",\"rpcport\":14022,\"pubtype\":30,\"p2shtype\":5,\"wiftype\":128,\"txfee\":100000}, {\"coin\":\"ZET\", \"name\":\"zetacoin\", \"pubtype\":80, \"p2shtype\":9,\"rpcport\":8332, \"wiftype\":224, \"txfee\":10000}, {\"coin\":\"GAME\", \"rpcport\":40001, \"name\":\"gamecredits\", \"pubtype\":38, \"p2shtype\":5, \"wiftype\":166, \"txfee\":100000}, {\"coin\":\"LTC\", \"name\":\"litecoin\", \"rpcport\":9332, \"pubtype\":48, \"p2shtype\":5, \"wiftype\":176, \"txfee\":100000 }, {\"coin\":\"SUPERNET\",\"asset\":\"SUPERNET\",\"rpcport\":11341}, {\"coin\":\"WLC\",\"asset\":\"WLC\",\"rpcport\":12167}, {\"coin\":\"PANGEA\",\"asset\":\"PANGEA\",\"rpcport\":14068}, {\"coin\":\"DEX\",\"asset\":\"DEX\",\"rpcport\":11890}, {\"coin\":\"BET\",\"asset\":\"BET\",\"rpcport\":14250}, {\"coin\":\"CRYPTO\",\"asset\":\"CRYPTO\",\"rpcport\":8516}, {\"coin\":\"HODL\",\"asset\":\"HODL\",\"rpcport\":14431}, {\"coin\":\"MSHARK\",\"asset\":\"MSHARK\",\"rpcport\":8846}, {\"coin\":\"BOTS\",\"asset\":\"BOTS\",\"rpcport\":11964}, {\"coin\":\"MGW\",\"asset\":\"MGW\",\"rpcport\":12386}, {\"coin\":\"COQUI\",\"asset\":\"COQUI\",\"rpcport\":14276}, {\"coin\":\"KV\",\"asset\":\"KV\",\"rpcport\":8299}, {\"coin\":\"CEAL\",\"asset\":\"CEAL\",\"rpcport\":11116}, {\"coin\":\"MESH\",\"asset\":\"MESH\",\"rpcport\":9455}]" +export coins="[{\"coin\":\"OOT\",\"asset\":\"OOT\",\"rpcport\":12467}, {\"coin\":\"ETH\",\"name\":\"ethereum\",\"etomic\":\"0x0000000000000000000000000000000000000000\",\"rpcport\":80}, {\"coin\":\"EOS\",\"name\":\"EOS\",\"etomic\":\"0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0\",\"rpcport\":80},{\"coin\":\"JST\", \"name\":\"JST\",\"etomic\":\"0xc0eb7AeD740E1796992A08962c15661bDEB58003\",\"rpcport\":80},{\"coin\":\"NODEC\",\"name\":\"NODEC\",\"etomic\":\"0x05beb0a9ead354283041a6d35f3b833450fb5680\",\"rpcport\":80,\"decimals\":18},{\"coin\":\"ZOI\",\"name\":\"zoin\",\"rpcport\":8255,\"pubtype\":80,\"p2shtype\":7,\"wiftype\":208,\"txfee\":1000}, {\"coin\": \"PIZZA\",\"asset\": \"PIZZA\",\"rpcport\": 11116},{\"coin\": \"BEER\",\"asset\": \"BEER\",\"rpcport\": 8923}, {\"coin\":\"GRS\",\"name\":\"groestlcoin\",\"rpcport\":1441,\"pubtype\":36,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"XMCC\",\"name\":\"monoeci\",\"confpath\":\"${HOME#}/.monoeciCore/monoeci.conf\",\"rpcport\":24156,\"pubtype\":50,\"p2shtype\":73,\"wiftype\":77,\"txfee\":10000}, {\"coin\":\"BTCH\",\"asset\":\"BTCH\",\"rpcport\":8800},{\"coin\":\"ETOMIC\",\"asset\":\"ETOMIC\",\"rpcport\":10271},{\"coin\":\"AXO\",\"asset\":\"AXO\",\"rpcport\":12927},{\"coin\":\"CRC\",\"name\":\"crowdcoin\",\"confpath\":\"${HOME#}/.crowdcoincore/crowdcoin.conf\",\"rpcport\":11998,\"pubtype\":28,\"p2shtype\":88,\"wiftype\":0,\"txfee\":10000}, {\"coin\":\"VOT\",\"name\":\"votecoin\",\"rpcport\":8232,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"INN\",\"name\":\"innova\",\"confpath\":\"${HOME#}/.innovacore/innova.conf\",\"rpcport\":8818,\"pubtype\":102,\"p2shtype\":20,\"wiftype\":195,\"txfee\":10000}, {\"coin\":\"MOON\",\"name\":\"mooncoin\",\"rpcport\":44663,\"pubtype\":3,\"p2shtype\":22,\"wiftype\":131,\"txfee\":100000}, {\"coin\":\"CRW\",\"name\":\"crown\",\"rpcport\":9341,\"pubtype\":0,\"p2shtype\":28,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"EFL\",\"name\":\"egulden\",\"confpath\":\"${HOME#}/.egulden/coin.conf\",\"rpcport\":21015,\"pubtype\":48,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"GBX\",\"name\":\"gobyte\",\"confpath\":\"${HOME#}/.gobytecore/gobyte.conf\",\"rpcport\":12454,\"pubtype\":38,\"p2shtype\":10,\"wiftype\":198,\"txfee\":10000}, {\"coin\":\"BCO\",\"name\":\"bridgecoin\",\"rpcport\":6332,\"pubtype\":27,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"BLK\",\"name\":\"blackcoin\",\"confpath\":\"${HOME#}/.lore/blackcoin.conf\",\"isPoS\":1,\"rpcport\":15715,\"pubtype\":25,\"p2shtype\":85,\"wiftype\":153,\"txfee\":100000}, {\"coin\":\"BTG\",\"name\":\"bitcoingold\",\"rpcport\":8332,\"pubtype\":38,\"p2shtype\":23,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"BCH\",\"name\":\"bch\",\"rpcport\":33333,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":1000}, {\"coin\":\"ABY\",\"name\":\"applebyte\",\"rpcport\":8607,\"pubtype\":23,\"p2shtype\":5,\"wiftype\":151,\"txfee\":100000}, {\"coin\":\"STAK\",\"name\":\"straks\",\"rpcport\":7574,\"pubtype\":63,\"p2shtype\":5,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"XZC\",\"name\":\"zcoin\",\"rpcport\":8888,\"pubtype\":82,\"p2shtype\":7,\"wiftype\":210,\"txfee\":10000}, {\"coin\":\"QTUM\",\"name\":\"qtum\",\"rpcport\":3889,\"pubtype\":58,\"p2shtype\":50,\"wiftype\":128,\"txfee\":400000}, {\"coin\":\"PURA\",\"name\":\"pura\",\"rpcport\":55555,\"pubtype\":55,\"p2shtype\":16,\"wiftype\":150,\"txfee\":10000}, {\"coin\":\"DSR\",\"name\":\"desire\",\"confpath\":\"${HOME#}/.desirecore/desire.conf\",\"rpcport\":9918,\"pubtype\":30,\"p2shtype\":16,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"MNZ\",\"asset\":\"MNZ\",\"rpcport\":14337},{\"coin\":\"BTCZ\",\"name\":\"bitcoinz\",\"rpcport\":1979,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"MAGA\",\"name\":\"magacoin\",\"rpcport\":5332,\"pubtype\":23,\"p2shtype\":50,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"BSD\",\"name\":\"bitsend\",\"rpcport\":8800,\"pubtype\":102,\"p2shtype\":5,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"IOP\",\"name\":\"IoP\",\"rpcport\":8337,\"pubtype\":117,\"p2shtype\":174,\"wiftype\":49,\"txfee\":10000}, {\"coin\":\"BLOCK\",\"name\":\"blocknetdx\",\"rpcport\":41414,\"pubtype\":26,\"p2shtype\":28,\"wiftype\":154,\"txfee\":10000}, {\"coin\":\"CHIPS\", \"name\": \"chips\", \"rpcport\":57776,\"pubtype\":60, \"p2shtype\":85, \"wiftype\":188, \"txfee\":10000}, {\"coin\":\"888\",\"name\":\"octocoin\",\"rpcport\":22888,\"pubtype\":18,\"p2shtype\":5,\"wiftype\":176,\"txfee\":2000000}, {\"coin\":\"ARG\",\"name\":\"argentum\",\"rpcport\":13581,\"pubtype\":23,\"p2shtype\":5,\"wiftype\":151,\"txfee\":50000}, {\"coin\":\"GLT\",\"name\":\"globaltoken\",\"rpcport\":9320,\"pubtype\":38,\"p2shtype\":5,\"wiftype\":166,\"txfee\":10000}, {\"coin\":\"ZER\",\"name\":\"zero\",\"rpcport\":23801,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":1000}, {\"coin\":\"HODLC\",\"name\":\"hodlcoin\",\"rpcport\":11989,\"pubtype\":40,\"p2shtype\":5,\"wiftype\":168,\"txfee\":5000}, {\"coin\":\"UIS\",\"name\":\"unitus\",\"rpcport\":50604,\"pubtype\":68,\"p2shtype\":10,\"wiftype\":132,\"txfee\":2000000}, {\"coin\":\"HUC\",\"name\":\"huntercoin\",\"rpcport\":8399,\"pubtype\":40,\"p2shtype\":13,\"wiftype\":168,\"txfee\":100000}, {\"coin\":\"BDL\",\"name\":\"bitdeal\",\"rpcport\":9332,\"pubtype\":38,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"ARC\",\"name\":\"arcticcoin\",\"confpath\":\"${HOME#}/.arcticcore/arcticcoin.conf\",\"rpcport\":7208,\"pubtype\":23,\"p2shtype\":8,\"wiftype\":176,\"txfee\":10000}, {\"coin\":\"ZCL\",\"name\":\"zclassic\",\"rpcport\":8023,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":1000}, {\"coin\":\"VIA\",\"name\":\"viacoin\",\"rpcport\":5222,\"pubtype\":71,\"p2shtype\":33,\"wiftype\":199,\"txfee\":100000}, {\"coin\":\"ERC\",\"name\":\"europecoin\",\"rpcport\":11989,\"pubtype\":33,\"p2shtype\":5,\"wiftype\":168,\"txfee\":10000},{\"coin\":\"FAIR\",\"name\":\"faircoin\",\"confpath\":\"${HOME#}/.faircoin2/faircoin.conf\",\"rpcport\":40405,\"pubtype\":95,\"p2shtype\":36,\"wiftype\":223,\"txfee\":1000000}, {\"coin\":\"FLO\",\"name\":\"florincoin\",\"rpcport\":7313,\"pubtype\":35,\"p2shtype\":8,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"SXC\",\"name\":\"sexcoin\",\"rpcport\":9561,\"pubtype\":62,\"p2shtype\":5,\"wiftype\":190,\"txfee\":100000}, {\"coin\":\"CREA\",\"name\":\"creativecoin\",\"rpcport\":17711,\"pubtype\":28,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000}, {\"coin\":\"TRC\",\"name\":\"terracoin\",\"confpath\":\"${HOME#}/.terracoincore/terracoin.conf\",\"rpcport\":13332,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"BTA\",\"name\":\"bata\",\"rpcport\":5493,\"pubtype\":25,\"p2shtype\":5,\"wiftype\":188,\"txfee\":100000}, {\"coin\":\"SMC\",\"name\":\"smartcoin\",\"rpcport\":58583,\"pubtype\":63,\"p2shtype\":5,\"wiftype\":191,\"txfee\":1000000}, {\"coin\":\"NMC\",\"name\":\"namecoin\",\"rpcport\":8336,\"pubtype\":52,\"p2shtype\":13,\"wiftype\":180,\"txfee\":100000}, {\"coin\":\"NAV\",\"name\":\"navcoin\",\"isPoS\":1,\"confpath\":\"${HOME#}/.navcoin4/navcoin.conf\",\"rpcport\":44444,\"pubtype\":53,\"p2shtype\":85,\"wiftype\":150,\"txfee\":10000}, {\"coin\":\"EMC2\",\"name\":\"einsteinium\",\"rpcport\":41879,\"pubtype\":33,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000},{\"coin\":\"SYS\",\"name\":\"syscoin\",\"rpcport\":8370,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"I0C\",\"name\":\"i0coin\",\"rpcport\":7332,\"pubtype\":105,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"DASH\",\"confpath\":\"${HOME#}/.dashcore/dash.conf\",\"name\":\"dashcore\",\"rpcport\":9998,\"pubtype\":76,\"p2shtype\":16,\"wiftype\":204,\"txfee\":10000}, {\"coin\":\"STRAT\", \"name\": \"stratis\", \"active\":0, \"rpcport\":16174,\"pubtype\":63, \"p2shtype\":125, \"wiftype\":191, \"txfee\":10000}, {\"confpath\":\"${HOME#}/.muecore/mue.conf\",\"coin\":\"MUE\",\"name\":\"muecore\",\"rpcport\":29683,\"pubtype\":16,\"p2shtype\":76,\"wiftype\":126,\"txfee\":10000}, {\"coin\":\"MONA\",\"name\":\"monacoin\",\"rpcport\":9402,\"pubtype\":50,\"p2shtype\":5,\"wiftype\":176,\"txfee\":100000},{\"coin\":\"XMY\",\"name\":\"myriadcoin\",\"rpcport\":10889,\"pubtype\":50,\"p2shtype\":9,\"wiftype\":178,\"txfee\":5000}, {\"coin\":\"MAC\",\"name\":\"machinecoin\",\"rpcport\":40332,\"pubtype\":50,\"p2shtype\":5,\"wiftype\":178,\"txfee\":100000}, {\"coin\":\"BTX\",\"name\":\"bitcore\",\"rpcport\":8556,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":50000}, {\"coin\":\"XRE\",\"name\":\"revolvercoin\",\"rpcport\":8775,\"pubtype\":0,\"p2shtype\":5,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"LBC\",\"name\":\"lbrycrd\",\"rpcport\":9245,\"pubtype\":85,\"p2shtype\":122,\"wiftype\":28,\"txfee\":10000}, {\"coin\":\"SIB\",\"name\":\"sibcoin\",\"rpcport\":1944,\"pubtype\":63,\"p2shtype\":40,\"wiftype\":128,\"txfee\":10000}, {\"coin\":\"VTC\", \"name\":\"vertcoin\", \"rpcport\":5888, \"pubtype\":71, \"p2shtype\":5, \"wiftype\":128, \"txfee\":100000 }, {\"coin\":\"REVS\",\"active\":0, \"asset\":\"REVS\",\"rpcport\":10196}, {\"coin\":\"JUMBLR\",\"active\":0, \"asset\":\"JUMBLR\",\"rpcport\":15106}, {\"coin\":\"DOGE\",\"name\":\"dogecoin\",\"rpcport\":22555,\"pubtype\":30,\"p2shtype\":22,\"wiftype\":158,\"txfee\":100000000}, {\"coin\":\"HUSH\",\"name\":\"hush\",\"rpcport\":8822,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":1000 }, {\"active\":0,\"coin\":\"ZEC\",\"name\":\"zcash\",\"rpcport\":8232,\"taddr\":28,\"pubtype\":184,\"p2shtype\":189,\"wiftype\":128,\"txfee\":10000 }, {\"coin\":\"DGB\",\"name\":\"digibyte\",\"rpcport\":14022,\"pubtype\":30,\"p2shtype\":5,\"wiftype\":128,\"txfee\":100000}, {\"coin\":\"ZET\", \"name\":\"zetacoin\", \"pubtype\":80, \"p2shtype\":9,\"rpcport\":8332, \"wiftype\":224, \"txfee\":10000}, {\"coin\":\"GAME\", \"rpcport\":40001, \"name\":\"gamecredits\", \"pubtype\":38, \"p2shtype\":5, \"wiftype\":166, \"txfee\":100000}, {\"coin\":\"LTC\", \"name\":\"litecoin\", \"rpcport\":9332, \"pubtype\":48, \"p2shtype\":5, \"wiftype\":176, \"txfee\":100000 }, {\"coin\":\"SUPERNET\",\"asset\":\"SUPERNET\",\"rpcport\":11341}, {\"coin\":\"WLC\",\"asset\":\"WLC\",\"rpcport\":12167}, {\"coin\":\"PANGEA\",\"asset\":\"PANGEA\",\"rpcport\":14068}, {\"coin\":\"DEX\",\"asset\":\"DEX\",\"rpcport\":11890}, {\"coin\":\"BET\",\"asset\":\"BET\",\"rpcport\":14250}, {\"coin\":\"CRYPTO\",\"asset\":\"CRYPTO\",\"rpcport\":8516}, {\"coin\":\"HODL\",\"asset\":\"HODL\",\"rpcport\":14431}, {\"coin\":\"MSHARK\",\"asset\":\"MSHARK\",\"rpcport\":8846}, {\"coin\":\"BOTS\",\"asset\":\"BOTS\",\"rpcport\":11964}, {\"coin\":\"MGW\",\"asset\":\"MGW\",\"rpcport\":12386}, {\"coin\":\"COQUI\",\"asset\":\"COQUI\",\"rpcport\":14276}, {\"coin\":\"KV\",\"asset\":\"KV\",\"rpcport\":8299}, {\"coin\":\"CEAL\",\"asset\":\"CEAL\",\"rpcport\":11116}, {\"coin\":\"MESH\",\"asset\":\"MESH\",\"rpcport\":9455}]" #, {\"coin\":\"AUD\",\"asset\":\"AUD\",\"rpcport\":8045}, {\"coin\":\"BGN\",\"asset\":\"BGN\",\"rpcport\":9110}, {\"coin\":\"CAD\",\"asset\":\"CAD\",\"rpcport\":8720}, {\"coin\":\"CHF\",\"asset\":\"CHF\",\"rpcport\":15312}, {\"coin\":\"CNY\",\"asset\":\"CNY\",\"rpcport\":10384}, {\"coin\":\"CZK\",\"asset\":\"CZK\",\"rpcport\":9482}, {\"coin\":\"DKK\",\"asset\":\"DKK\",\"rpcport\":13830}, {\"coin\":\"EUR\",\"asset\":\"EUR\",\"rpcport\":8065}, {\"coin\":\"GBP\",\"asset\":\"GBP\",\"rpcport\":11505}, {\"coin\":\"HKD\",\"asset\":\"HKD\",\"rpcport\":15409}, {\"coin\":\"HRK\",\"asset\":\"HRK\",\"rpcport\":12617}, {\"coin\":\"HUF\",\"asset\":\"HUF\",\"rpcport\":13699}, {\"coin\":\"IDR\",\"asset\":\"IDR\",\"rpcport\":14459}, {\"coin\":\"ILS\",\"asset\":\"ILS\",\"rpcport\":14638}, {\"coin\":\"INR\",\"asset\":\"INR\",\"rpcport\":10536}, {\"coin\":\"JPY\",\"asset\":\"JPY\",\"rpcport\":13145}, {\"coin\":\"KRW\",\"asset\":\"KRW\",\"rpcport\":14020}, {\"coin\":\"MXN\",\"asset\":\"MXN\",\"rpcport\":13970}, {\"coin\":\"MYR\",\"asset\":\"MYR\",\"rpcport\":10688}, {\"coin\":\"NOK\",\"asset\":\"NOK\",\"rpcport\":11588}, {\"coin\":\"NZD\",\"asset\":\"NZD\",\"rpcport\":10915}, {\"coin\":\"PHP\",\"asset\":\"PHP\",\"rpcport\":11181}, {\"coin\":\"PLN\",\"asset\":\"PLN\",\"rpcport\":13493}, {\"coin\":\"BRL\",\"asset\":\"BRL\",\"rpcport\":9914}, {\"coin\":\"RON\",\"asset\":\"RON\",\"rpcport\":8675}, {\"coin\":\"RUB\",\"asset\":\"RUB\",\"rpcport\":8199}, {\"coin\":\"SEK\",\"asset\":\"SEK\",\"rpcport\":11447}, {\"coin\":\"SGD\",\"asset\":\"SGD\",\"rpcport\":14475}, {\"coin\":\"THB\",\"asset\":\"THB\",\"rpcport\":11847}, {\"coin\":\"TRY\",\"asset\":\"TRY\",\"rpcport\":13924}, {\"coin\":\"USD\",\"asset\":\"USD\",\"rpcport\":13967}, {\"coin\":\"ZAR\",\"asset\":\"ZAR\",\"rpcport\":15160}]" #{\"coin\":\"PIVX\",\"name\":\"pivx\",\"rpcport\":51473,\"pubtype\":30,\"p2shtype\":13,\"wiftype\":212,\"txfee\":10000}, diff --git a/etomic_build/seed/sell_BEER_OTHER b/etomic_build/seed/sell_BEER_OTHER index bc9231bc7..676404d15 100755 --- a/etomic_build/seed/sell_BEER_OTHER +++ b/etomic_build/seed/sell_BEER_OTHER @@ -1,4 +1,4 @@ #!/bin/bash source userpass -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"setprice\",\"base\":\"BEER\",\"rel\":\"$1\",\"price\":1.9}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"sell\",\"base\":\"BEER\",\"rel\":\"$1\",\"basevolume\":3,\"price\":1.9}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"setprice\",\"base\":\"BEER\",\"rel\":\"$1\",\"price\":0.9}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"sell\",\"base\":\"BEER\",\"rel\":\"$1\",\"basevolume\":3,\"price\":0.9}" diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index 9d0a7e468..8c03e7810 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -60,7 +60,7 @@ uint8_t LP_etomic_verify_alice_fee(struct basilisk_swap *swap) return(0); } EthTxData data = getEthTxData(swap->otherfee.I.ethTxid); - if (strcmp(data.from, swap->I.etomicdest) != 0) { + if (compareAddresses(data.from, swap->I.etomicdest) == 0) { printf("Alice fee tx %s was sent from wrong address %s\n", swap->otherfee.I.ethTxid, data.from); return(0); } @@ -68,7 +68,7 @@ uint8_t LP_etomic_verify_alice_fee(struct basilisk_swap *swap) char dexaddr[50]; LP_etomic_pubkeystr_to_addr(INSTANTDEX_PUBKEY, dexaddr); if ( strcmp(swap->I.alicestr,"ETH") == 0 ) { - if (strcmp(data.to, dexaddr) != 0) { + if (compareAddresses(data.to, dexaddr) == 0) { printf("Alice fee %s was sent to wrong address %s\n", swap->otherfee.I.ethTxid, data.to); return(0); } @@ -81,7 +81,7 @@ uint8_t LP_etomic_verify_alice_fee(struct basilisk_swap *swap) } else { struct iguana_info *alicecoin = LP_coinfind(swap->I.alicestr); - if (strcmp(data.to, swap->I.alicetomic) != 0) { + if (compareAddresses(data.to, swap->I.alicetomic) == 0) { printf("Alice ERC20 fee %s token address %s is not equal to expected %s\n", swap->otherfee.I.ethTxid, data.to, swap->I.alicetomic); return(0); } @@ -159,11 +159,11 @@ uint8_t LP_etomic_verify_alice_payment(struct basilisk_swap *swap, char *txId) return(0); } EthTxData data = getEthTxData(txId); - if (strcmp(data.to, ETOMIC_ALICECONTRACT) != 0) { + if (compareAddresses(data.to, ETOMIC_ALICECONTRACT) == 0) { printf("Alice payment %s was sent to wrong address %s\n", txId, data.to); return(0); } - if (strcmp(data.from, swap->I.etomicdest) != 0) { + if (compareAddresses(data.from, swap->I.etomicdest) == 0) { printf("Alice payment %s was done from wrong address %s\n", txId, data.from); return(0); } @@ -367,11 +367,11 @@ uint8_t LP_etomic_verify_bob_deposit(struct basilisk_swap *swap, char *txId) return(0); } EthTxData data = getEthTxData(txId); - if (strcmp(data.to, ETOMIC_BOBCONTRACT) != 0) { + if (compareAddresses(data.to, ETOMIC_BOBCONTRACT) == 0) { printf("Bob deposit txid %s was sent to wrong address %s\n", txId, data.to); return(0); } - if (strcmp(data.from, swap->I.etomicsrc) != 0) { + if (compareAddresses(data.from, swap->I.etomicsrc) == 0) { printf("Bob deposit txid %s was sent from wrong address %s\n", txId, data.from); return(0); } @@ -523,10 +523,10 @@ uint8_t LP_etomic_verify_bob_payment(struct basilisk_swap *swap, char *txId) return 0; } EthTxData data = getEthTxData(txId); - if (strcmp(data.to, ETOMIC_BOBCONTRACT) != 0) { + if (compareAddresses(data.to, ETOMIC_BOBCONTRACT) == 0) { printf("Bob payment %s was sent to wrong address %s\n", txId, data.to); } - if (strcmp(data.from, swap->I.etomicsrc) != 0) { + if (compareAddresses(data.from, swap->I.etomicsrc) == 0) { printf("Bob payment %s was sent from wrong address %s\n", txId, data.from); } BobSendsEthPaymentInput input; diff --git a/iguana/exchanges/etomicswap/etomiclib.cpp b/iguana/exchanges/etomicswap/etomiclib.cpp index b1bcbe7c1..68e49f9d8 100644 --- a/iguana/exchanges/etomicswap/etomiclib.cpp +++ b/iguana/exchanges/etomicswap/etomiclib.cpp @@ -828,3 +828,10 @@ uint8_t bobPaymentStatus(char *paymentId) free(hexStatus); return status; } + +uint8_t compareAddresses(char *address1, char *address2) +{ + auto addr_bytes_1 = jsToAddress(address1); + auto addr_bytes_2 = jsToAddress(address2); + return static_cast(addr_bytes_1 == addr_bytes_2); +} diff --git a/iguana/exchanges/etomicswap/etomiclib.h b/iguana/exchanges/etomicswap/etomiclib.h index db1547f4e..bfd0b81d3 100644 --- a/iguana/exchanges/etomicswap/etomiclib.h +++ b/iguana/exchanges/etomicswap/etomiclib.h @@ -213,6 +213,8 @@ uint64_t estimate_erc20_gas( uint8_t decimals ); +uint8_t compareAddresses(char *address1, char *address2); + #ifdef __cplusplus } #endif From 6db6af6fe4d7adca45c75494007f227cd4f46bb3 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Wed, 20 Jun 2018 15:16:54 +0700 Subject: [PATCH 06/10] #81 Add ETH address validation upon coin enable and eth_withdraw. --- iguana/exchanges/LP_commands.c | 4 ++++ iguana/exchanges/LP_transaction.c | 5 +++++ iguana/exchanges/etomicswap/etomiclib.cpp | 7 +++++++ iguana/exchanges/etomicswap/etomiclib.h | 1 + 4 files changed, 17 insertions(+) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index 4e2e08ba6..147e777b9 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -608,6 +608,10 @@ version\n\ } if (ptr->etomic[0] != 0) { + if (isValidAddress(ptr->etomic) == 0) { + return(clonestr("{\"error\":\"'etomic' field is not valid address!\"}")); + } + struct iguana_info *etomic_coin = LP_coinsearch("ETOMIC"); if (etomic_coin->inactive != 0) { return(clonestr("{\"error\":\"Enable ETOMIC first to use ETH/ERC20!\"}")); diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index ef27a86a0..69fece8b6 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -2095,6 +2095,11 @@ char *LP_eth_withdraw(struct iguana_info *coin,cJSON *argjson) if (dest_addr == NULL) { return(clonestr("{\"error\":\"param 'to' is required!\"}")); } + + if (isValidAddress(dest_addr) == 0) { + return(clonestr("{\"error\":\"'to' address is not valid!\"}")); + } + amount = jdouble(argjson, "amount") * 100000000; if (amount == 0) { return(clonestr("{\"error\":\"'amount' is not set or equal to zero!\"}")); diff --git a/iguana/exchanges/etomicswap/etomiclib.cpp b/iguana/exchanges/etomicswap/etomiclib.cpp index 68e49f9d8..921a89342 100644 --- a/iguana/exchanges/etomicswap/etomiclib.cpp +++ b/iguana/exchanges/etomicswap/etomiclib.cpp @@ -4,6 +4,7 @@ #include "etomiclib.h" #include "etomiccurl.h" #include +#include #include #include #include @@ -835,3 +836,9 @@ uint8_t compareAddresses(char *address1, char *address2) auto addr_bytes_2 = jsToAddress(address2); return static_cast(addr_bytes_1 == addr_bytes_2); } + +uint8_t isValidAddress(char *address) +{ + std::regex r("^(0x|0X)?[a-fA-F0-9]{40}$"); + return static_cast(std::regex_match(address, r)); +} diff --git a/iguana/exchanges/etomicswap/etomiclib.h b/iguana/exchanges/etomicswap/etomiclib.h index bfd0b81d3..78a6e3ad3 100644 --- a/iguana/exchanges/etomicswap/etomiclib.h +++ b/iguana/exchanges/etomicswap/etomiclib.h @@ -214,6 +214,7 @@ uint64_t estimate_erc20_gas( ); uint8_t compareAddresses(char *address1, char *address2); +uint8_t isValidAddress(char *address); #ifdef __cplusplus } From b8890ba2e9d621d10d13051222c9db9d41797dad Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Wed, 20 Jun 2018 15:48:05 +0700 Subject: [PATCH 07/10] #80 Set ERC20 decimals upon coin enable to avoid repetitive requests. --- iguana/exchanges/LP_commands.c | 7 +++++++ iguana/exchanges/etomicswap/etomiclib.cpp | 12 ++++++++++++ iguana/exchanges/etomicswap/etomiclib.h | 1 + 3 files changed, 20 insertions(+) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index 147e777b9..7714e2d63 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -616,6 +616,13 @@ version\n\ if (etomic_coin->inactive != 0) { return(clonestr("{\"error\":\"Enable ETOMIC first to use ETH/ERC20!\"}")); } + + if (ptr->decimals == 0 && strcmp(coin, "ETH") != 0) { + ptr->decimals = getErc20DecimalsZeroOnError(ptr->etomic); + if (ptr->decimals == 0) { + return(clonestr("{\"error\":\"Could not get token decimals or token has zero decimals which is not supported!\"}")); + } + } } #endif if ( LP_conflicts_find(ptr) == 0 ) diff --git a/iguana/exchanges/etomicswap/etomiclib.cpp b/iguana/exchanges/etomicswap/etomiclib.cpp index 921a89342..ab60510fd 100644 --- a/iguana/exchanges/etomicswap/etomiclib.cpp +++ b/iguana/exchanges/etomicswap/etomiclib.cpp @@ -636,6 +636,18 @@ uint8_t getErc20Decimals(char *tokenAddress) return decimals; } +uint8_t getErc20DecimalsZeroOnError(char *tokenAddress) +{ + char* hexDecimals = ethCall(tokenAddress, "0x313ce567"); + if (hexDecimals != NULL) { + auto decimals = (uint8_t) strtol(hexDecimals, NULL, 0); + free(hexDecimals); + return decimals; + } else { + return 0; + } +} + void uint8arrayToHex(char *dest, uint8_t *input, int len) { strcpy(dest, "0x"); diff --git a/iguana/exchanges/etomicswap/etomiclib.h b/iguana/exchanges/etomicswap/etomiclib.h index 78a6e3ad3..3557e4191 100644 --- a/iguana/exchanges/etomicswap/etomiclib.h +++ b/iguana/exchanges/etomicswap/etomiclib.h @@ -215,6 +215,7 @@ uint64_t estimate_erc20_gas( uint8_t compareAddresses(char *address1, char *address2); uint8_t isValidAddress(char *address); +uint8_t getErc20DecimalsZeroOnError(char *tokenAddress); #ifdef __cplusplus } From 437d9b23dfcac0590e7632e980b8eee7ffcb690f Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Wed, 20 Jun 2018 17:23:51 +0700 Subject: [PATCH 08/10] #82 Use prev ETH/ERC20 balance on portfolio in case of request error. --- iguana/exchanges/LP_coins.c | 3 ++- iguana/exchanges/LP_etomic.c | 6 +++--- iguana/exchanges/LP_etomic.h | 2 +- iguana/exchanges/LP_portfolio.c | 8 +++++++- iguana/exchanges/LP_rpc.c | 3 ++- iguana/exchanges/LP_signatures.c | 3 ++- iguana/exchanges/LP_swap.c | 6 ++++-- iguana/exchanges/LP_utxo.c | 3 ++- iguana/exchanges/etomicswap/etomiclib.cpp | 8 +++++--- iguana/exchanges/etomicswap/etomiclib.h | 4 ++-- 10 files changed, 30 insertions(+), 16 deletions(-) diff --git a/iguana/exchanges/LP_coins.c b/iguana/exchanges/LP_coins.c index e413ffa64..ce948fa95 100644 --- a/iguana/exchanges/LP_coins.c +++ b/iguana/exchanges/LP_coins.c @@ -251,8 +251,9 @@ cJSON *LP_coinjson(struct iguana_info *coin,int32_t showwif) } #ifndef NOTETOMIC else if (coin->etomic[0] != 0) { + int error = 0; if (coin->inactive == 0) { - balance = LP_etomic_get_balance(coin, coin->smartaddr); + balance = LP_etomic_get_balance(coin, coin->smartaddr, &error); } else { balance = 0; } diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index 8c03e7810..3b7c7aa8f 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -773,7 +773,7 @@ uint8_t LP_etomic_is_empty_tx_id(char *txId) return 0; } -uint64_t LP_etomic_get_balance(struct iguana_info *coin, char *coinaddr) +uint64_t LP_etomic_get_balance(struct iguana_info *coin, char *coinaddr, int *error) { if (coin->etomic[0] == 0) { printf("Trying to get etomic balance for non-etomic coin %s!", coin->symbol); @@ -781,8 +781,8 @@ uint64_t LP_etomic_get_balance(struct iguana_info *coin, char *coinaddr) } if (strcmp(coin->symbol, "ETH") == 0) { - return getEthBalance(coinaddr); + return getEthBalance(coinaddr, error); } else { - return getErc20BalanceSatoshi(coinaddr, coin->etomic, coin->decimals); + return getErc20BalanceSatoshi(coinaddr, coin->etomic, coin->decimals, error); } } diff --git a/iguana/exchanges/LP_etomic.h b/iguana/exchanges/LP_etomic.h index af5de5f63..8a744cb3d 100644 --- a/iguana/exchanges/LP_etomic.h +++ b/iguana/exchanges/LP_etomic.h @@ -49,7 +49,7 @@ int32_t LP_etomic_pub2addr(char *coinaddr,uint8_t pub64[64]); uint8_t LP_etomic_is_empty_tx_id(char *txId); -uint64_t LP_etomic_get_balance(struct iguana_info *coin, char *coinaddr); +uint64_t LP_etomic_get_balance(struct iguana_info *coin, char *coinaddr, int *error); void LP_etomic_pubkeystr_to_addr(char *pubkey, char *output); diff --git a/iguana/exchanges/LP_portfolio.c b/iguana/exchanges/LP_portfolio.c index b38a08c89..dda09ec54 100644 --- a/iguana/exchanges/LP_portfolio.c +++ b/iguana/exchanges/LP_portfolio.c @@ -98,7 +98,13 @@ uint64_t LP_balance(uint64_t *valuep,int32_t iambob,char *symbol,char *coinaddr) #ifndef NOTETOMIC struct iguana_info *coin = LP_coinfind(symbol); if (coin->etomic[0] != 0 && coin->inactive == 0) { - valuesum = LP_etomic_get_balance(coin, coinaddr); + int error = 0; + uint64_t etomic_balance = LP_etomic_get_balance(coin, coinaddr, &error); + if (error == 0) { + valuesum = etomic_balance; + } else { + valuesum = *valuep; + } } else #endif if ( (array= LP_listunspent(symbol,coinaddr,zero,zero)) != 0 ) diff --git a/iguana/exchanges/LP_rpc.c b/iguana/exchanges/LP_rpc.c index 9c1bca6c2..800214ba4 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -139,7 +139,8 @@ uint64_t LP_RTsmartbalance(struct iguana_info *coin) { #ifndef NOTETOMIC if (coin->etomic[0] != 0) { - return LP_etomic_get_balance(coin, coin->smartaddr); + int error = 0; + return LP_etomic_get_balance(coin, coin->smartaddr, &error); } #endif cJSON *array,*item; char buf[512],*retstr; int32_t i,n; uint64_t valuesum,value; bits256 zero; diff --git a/iguana/exchanges/LP_signatures.c b/iguana/exchanges/LP_signatures.c index 2d8e45750..a280ae9d4 100644 --- a/iguana/exchanges/LP_signatures.c +++ b/iguana/exchanges/LP_signatures.c @@ -444,7 +444,8 @@ char *LP_pricepings(void *ctx,char *myipaddr,int32_t pubsock,char *base,char *re jaddnum(reqjson,"credits",dstr(ap->instantdex_credits)); #ifndef NOTETOMIC if (basecoin->etomic[0] != 0) { - uint64_t etomic_coin_balance = LP_etomic_get_balance(basecoin, basecoin->smartaddr); + int error = 0; + uint64_t etomic_coin_balance = LP_etomic_get_balance(basecoin, basecoin->smartaddr, &error); jaddstr(reqjson,"utxocoin","ETH_OR_ERC20"); jaddnum(reqjson,"bal",dstr(etomic_coin_balance)); jaddnum(reqjson,"min",dstr(etomic_coin_balance)); diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index 5c7af583e..8a1efb9bf 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -856,7 +856,8 @@ void LP_bobloop(void *_swap) alicewaittimeout = LP_calc_waittimeout(alicestr); #ifndef NOTETOMIC if (swap->I.bobtomic[0] != 0 || swap->I.alicetomic[0] != 0) { - uint64_t eth_balance = getEthBalance(swap->I.etomicsrc); + int error = 0; + uint64_t eth_balance = getEthBalance(swap->I.etomicsrc, &error); if (eth_balance < 500000) { err = -5000, printf("Bob ETH balance too low, aborting swap!\n"); } @@ -960,7 +961,8 @@ void LP_aliceloop(void *_swap) #ifndef NOTETOMIC if (swap->I.bobtomic[0] != 0 || swap->I.alicetomic[0] != 0) { - uint64_t eth_balance = getEthBalance(swap->I.etomicdest); + int error = 0; + uint64_t eth_balance = getEthBalance(swap->I.etomicdest, &error); if (eth_balance < 500000) { err = -5001, printf("Alice ETH balance too low, aborting swap!\n"); } diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index 944876a90..f241e73c5 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -699,7 +699,8 @@ cJSON *LP_address_balance(struct iguana_info *coin,char *coinaddr,int32_t electr //printf("address balance call LP_listunspent %s electrum.%p etomic.%d\n",coin->symbol,coin->electrum,coin->etomic[0]); #ifndef NOTETOMIC if (coin->etomic[0] != 0) { - balance = LP_etomic_get_balance(coin, coinaddr); + int error = 0; + balance = LP_etomic_get_balance(coin, coinaddr, &error); } else #endif if ( coin->electrum == 0 ) diff --git a/iguana/exchanges/etomicswap/etomiclib.cpp b/iguana/exchanges/etomicswap/etomiclib.cpp index ab60510fd..f80ba22f4 100644 --- a/iguana/exchanges/etomicswap/etomiclib.cpp +++ b/iguana/exchanges/etomicswap/etomiclib.cpp @@ -544,7 +544,7 @@ char* pubKey2Addr(char* pubKey) return stringStreamToChar(ss); }; -char* getPubKeyFromPriv(char* privKey) +char* getPubKeyFromPriv(char *privKey) { Public publicKey = toPublic(Secret(privKey)); std::stringstream ss; @@ -552,7 +552,7 @@ char* getPubKeyFromPriv(char* privKey) return stringStreamToChar(ss); } -uint64_t getEthBalance(char* address) +uint64_t getEthBalance(char *address, int *error) { char* hexBalance = getEthBalanceRequest(address); if (hexBalance != NULL) { @@ -561,11 +561,12 @@ uint64_t getEthBalance(char* address) free(hexBalance); return static_cast(balance); } else { + *error = 1; return 0; } } -uint64_t getErc20BalanceSatoshi(char *address, char *tokenAddress, uint8_t setDecimals) +uint64_t getErc20BalanceSatoshi(char *address, char *tokenAddress, uint8_t setDecimals, int *error) { std::stringstream ss; ss << "0x70a08231" @@ -589,6 +590,7 @@ uint64_t getErc20BalanceSatoshi(char *address, char *tokenAddress, uint8_t setDe free(hexBalance); return static_cast(balance); } else { + *error = 1; return 0; } } diff --git a/iguana/exchanges/etomicswap/etomiclib.h b/iguana/exchanges/etomicswap/etomiclib.h index 3557e4191..6075124a5 100644 --- a/iguana/exchanges/etomicswap/etomiclib.h +++ b/iguana/exchanges/etomicswap/etomiclib.h @@ -173,8 +173,8 @@ char* pubKey2Addr(char* pubKey); char* getPubKeyFromPriv(char* privKey); // returns satoshis, not wei! -uint64_t getEthBalance(char* address); -uint64_t getErc20BalanceSatoshi(char *address, char *tokenAddress, uint8_t setDecimals); +uint64_t getEthBalance(char* address, int *error); +uint64_t getErc20BalanceSatoshi(char *address, char *tokenAddress, uint8_t setDecimals, int *error); char *getErc20BalanceHexWei(char* address, char tokenAddress[65]); uint8_t getErc20Decimals(char *tokenAddress); From 209ca12da74e76106f2f55ed926df8b94c273877 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Wed, 20 Jun 2018 17:51:42 +0700 Subject: [PATCH 09/10] Put back 0.1 amount for test trades. --- etomic_build/client/buy_BEER_OTHER | 2 +- etomic_build/seed/sell_BEER_OTHER | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/etomic_build/client/buy_BEER_OTHER b/etomic_build/client/buy_BEER_OTHER index 9c4123e44..1b4fb5ff6 100755 --- a/etomic_build/client/buy_BEER_OTHER +++ b/etomic_build/client/buy_BEER_OTHER @@ -1,4 +1,4 @@ #!/bin/bash source userpass curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"setprice\",\"base\":\"$1\",\"rel\":\"BEER\",\"price\":1}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"buy\",\"base\":\"BEER\",\"rel\":\"$1\",\"relvolume\":3,\"price\":1}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"buy\",\"base\":\"BEER\",\"rel\":\"$1\",\"relvolume\":0.1,\"price\":1}" diff --git a/etomic_build/seed/sell_BEER_OTHER b/etomic_build/seed/sell_BEER_OTHER index 676404d15..6ec45e1b9 100755 --- a/etomic_build/seed/sell_BEER_OTHER +++ b/etomic_build/seed/sell_BEER_OTHER @@ -1,4 +1,4 @@ #!/bin/bash source userpass curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"setprice\",\"base\":\"BEER\",\"rel\":\"$1\",\"price\":0.9}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"sell\",\"base\":\"BEER\",\"rel\":\"$1\",\"basevolume\":3,\"price\":0.9}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"sell\",\"base\":\"BEER\",\"rel\":\"$1\",\"basevolume\":0.1,\"price\":0.9}" From ccc95df4e6831aee6a34e8f7d72ee2203d62597d Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 21 Jun 2018 15:29:11 +0700 Subject: [PATCH 10/10] #84 Request ETOMIC from faucet when enable in electrum mode. --- iguana/exchanges/LP_commands.c | 12 ++++++++---- iguana/exchanges/etomicswap/etomiccurl.c | 3 +-- iguana/exchanges/etomicswap/etomiccurl.h | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index 7714e2d63..4357af2cb 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -599,10 +599,7 @@ version\n\ } #ifndef NOT_ETOMIC if (strcmp(coin, "ETOMIC") == 0) { - char eth_addr[100]; - bits256 privkey = LP_privkey("ETOMIC", ptr->smartaddr, ptr->taddr); - LP_etomic_priv2addr(eth_addr, privkey); - if (get_etomic_from_faucet(eth_addr, ptr->smartaddr) != 1) { + if (get_etomic_from_faucet(ptr->smartaddr) != 1) { return(clonestr("{\"error\":\"Could not get ETOMIC from faucet!\"}")); } } @@ -696,6 +693,13 @@ version\n\ { if ( (ptr= LP_coinsearch(coin)) != 0 ) { +#ifndef NOTETOMIC + if (strcmp(coin, "ETOMIC") == 0) { + if (get_etomic_from_faucet(ptr->smartaddr) != 1) { + return(clonestr("{\"error\":\"Could not get ETOMIC from faucet!\"}")); + } + } +#endif ptr->inactive = 0; return(jprint(LP_electrumserver(ptr,jstr(argjson,"ipaddr"),juint(argjson,"port")),1)); } else return(clonestr("{\"error\":\"cant find coind\"}")); diff --git a/iguana/exchanges/etomicswap/etomiccurl.c b/iguana/exchanges/etomicswap/etomiccurl.c index c6a493f33..a43e2c292 100644 --- a/iguana/exchanges/etomicswap/etomiccurl.c +++ b/iguana/exchanges/etomicswap/etomiccurl.c @@ -374,11 +374,10 @@ void unlock_send_tx_mutex() pthread_mutex_unlock(&sendTxMutex); } -uint8_t get_etomic_from_faucet(char *eth_addr, char *etomic_addr) +uint8_t get_etomic_from_faucet(char *etomic_addr) { char* string; cJSON *request = cJSON_CreateObject(); - cJSON_AddStringToObject(request, "ethAddress", eth_addr); cJSON_AddStringToObject(request, "etomicAddress", etomic_addr); string = cJSON_PrintUnformatted(request); char* requestResult = sendRequest(string, FAUCET_URL); diff --git a/iguana/exchanges/etomicswap/etomiccurl.h b/iguana/exchanges/etomicswap/etomiccurl.h index 6e5036739..2b765b150 100644 --- a/iguana/exchanges/etomicswap/etomiccurl.h +++ b/iguana/exchanges/etomicswap/etomiccurl.h @@ -50,7 +50,7 @@ uint64_t getEthBlockNumber(); uint64_t getGasPriceFromStation(uint8_t defaultOnErr); int32_t waitForConfirmation(char *txId); void unlock_send_tx_mutex(); -uint8_t get_etomic_from_faucet(char *eth_addr, char *etomic_addr); +uint8_t get_etomic_from_faucet(char *etomic_addr); #ifdef __cplusplus }