From 5373e8718a8c8e8062d5f56760e8c493b3290332 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Feb 2018 14:33:29 +0200 Subject: [PATCH 001/197] Test --- iguana/exchanges/LP_bitcoin.c | 4 +- iguana/exchanges/LP_etomic.c | 149 ++++++++++++++++++++++++++++++++++ iguana/exchanges/LP_rpc.c | 5 +- 3 files changed, 153 insertions(+), 5 deletions(-) create mode 100644 iguana/exchanges/LP_etomic.c diff --git a/iguana/exchanges/LP_bitcoin.c b/iguana/exchanges/LP_bitcoin.c index 0343acc0b..e1df7d4c2 100644 --- a/iguana/exchanges/LP_bitcoin.c +++ b/iguana/exchanges/LP_bitcoin.c @@ -2041,10 +2041,10 @@ bits256 bits256_calcaddrhash(char *symbol,uint8_t *serialized,int32_t len) else { HashGroestl(hash.bytes,serialized,len); - /*int32_t i; char str[65]; + int32_t i; char str[65]; for (i=0; i %s\n",len,bits256_str(str,hash));*/ + printf(" HashGroestl %d -> %s\n",len,bits256_str(str,hash)); } return(hash); } diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c new file mode 100644 index 000000000..efa8c4232 --- /dev/null +++ b/iguana/exchanges/LP_etomic.c @@ -0,0 +1,149 @@ + +/****************************************************************************** + * Copyright © 2014-2017 The SuperNET Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * SuperNET software, including this file may be copied, modified, propagated * + * or distributed except according to the terms contained in the LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ +// +// LP_etomic.c +// marketmaker +// + +// +// Created by artem on 24.01.18. +// +#ifdef __cplusplus +extern "C" { +#endif + typedef struct { + char* from; + char* to; + char* amount; + int nonce; + char* secretKey; + } BasicTxData; + + typedef struct { + char* dealId; + char* bobAddress; + char* aliceHash; + char* bobHash; + } AliceInitEthInput; + + typedef struct { + char* dealId; + char* amount; + char* tokenAddress; + char* bobAddress; + char* aliceHash; + char* bobHash; + } AliceInitErc20Input; + + typedef struct { + char* dealId; + char* amount; + char* tokenAddress; + char* bobAddress; + char* aliceHash; + char* bobSecret; + } AliceClaimsAlicePaymentInput; + + typedef struct { + char* dealId; + char* amount; + char* tokenAddress; + char* aliceAddress; + char* aliceSecret; + char* bobHash; + } BobClaimsAlicePaymentInput; + + typedef struct { + char* depositId; + char* aliceAddress; + char* bobHash; + } BobMakesEthDepositInput; + + typedef struct { + char* depositId; + char* amount; + char* tokenAddress; + char* aliceAddress; + char* bobHash; + } BobMakesErc20DepositInput; + + typedef struct { + char* depositId; + char* amount; + char* tokenAddress; + char* aliceAddress; + char* bobSecret; + char* aliceCanClaimAfter; + } BobClaimsDepositInput; + + typedef struct { + char* depositId; + char* amount; + char* tokenAddress; + char* bobAddress; + char* bobHash; + char* aliceCanClaimAfter; + } AliceClaimsBobDepositInput; + + typedef struct { + char* paymentId; + char* aliceAddress; + char* aliceHash; + } BobMakesEthPaymentInput; + + typedef struct { + char* paymentId; + char* amount; + char* tokenAddress; + char* aliceAddress; + char* aliceHash; + } BobMakesErc20PaymentInput; + + typedef struct { + char* paymentId; + char* amount; + char* tokenAddress; + char* aliceAddress; + char* aliceHash; + char* bobCanClaimAfter; + } BobClaimsBobPaymentInput; + + typedef struct { + char* paymentId; + char* amount; + char* tokenAddress; + char* aliceSecret; + char* bobAddress; + char* bobCanClaimAfter; + } AliceClaimsBobPaymentInput; + + void approveErc20(char* amount, char* from, char* secret, char* buffer, int nonce); + void aliceInitsEthDeal(AliceInitEthInput input, BasicTxData txData, char* result); + void aliceInitsErc20Deal(AliceInitErc20Input input, BasicTxData txData, char* result); + void aliceClaimsAlicePayment(AliceClaimsAlicePaymentInput input, BasicTxData txData, char* result); + void bobClaimsAlicePayment(BobClaimsAlicePaymentInput input, BasicTxData txData, char* result); + void bobMakesEthDeposit(BobMakesEthDepositInput input, BasicTxData txData, char* result); + void bobMakesErc20Deposit(BobMakesErc20DepositInput input, BasicTxData txData, char* result); + void bobClaimsDeposit(BobClaimsDepositInput input, BasicTxData txData, char* result); + void aliceClaimsBobDeposit(AliceClaimsBobDepositInput input, BasicTxData txData, char* result); + void bobMakesEthPayment(BobMakesEthPaymentInput input, BasicTxData txData, char* result); + void bobMakesErc20Payment(BobMakesErc20PaymentInput input, BasicTxData txData, char* result); + void bobClaimsBobPayment(BobClaimsBobPaymentInput input, BasicTxData txData, char* result); + void aliceClaimsBobPayment(AliceClaimsBobPaymentInput input, BasicTxData txData, char* result); + // Your prototype or Definition +#ifdef __cplusplus +} +#endif diff --git a/iguana/exchanges/LP_rpc.c b/iguana/exchanges/LP_rpc.c index 76a4f820d..0735dbd78 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -573,13 +573,12 @@ cJSON *LP_importprivkey(char *symbol,char *wifstr,char *label,int32_t flag) ctx = bitcoin_ctx(); bitcoin_wif2addr(ctx,symbol,coin->wiftaddr,coin->taddr,coin->pubtype,address,wifstr); #ifdef LP_DONT_IMPORTPRIVKEY - bitcoin_wif2addr(ctx,symbol,coin->wiftaddr,coin->taddr,coin->pubtype,address,wifstr); + //bitcoin_wif2addr(ctx,symbol,coin->wiftaddr,coin->taddr,coin->pubtype,address,wifstr); if ( LP_importaddress(symbol,address) < 0 ) { printf("%s importaddress %s from %s failed, isvalid.%d\n",symbol,address,wifstr,bitcoin_validaddress(symbol,coin->taddr,coin->pubtype,coin->p2shtype,address)); return(cJSON_Parse("{\"error\":\"couldnt import\"}")); - } - else return(cJSON_Parse("{\"result\":\"success\"}")); + } else return(cJSON_Parse("{\"result\":\"success\"}")); #endif if ( (retjson= LP_validateaddress(symbol,address)) != 0 ) { From 689c63652ad5859457710e77fd312b154a58ea87 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 1 Feb 2018 21:18:06 +0200 Subject: [PATCH 002/197] Stubby release --- iguana/exchanges/LP_bitcoin.c | 4 +- iguana/exchanges/LP_commands.c | 4 +- iguana/exchanges/LP_etomic.c | 71 ++++++++++++++++++++++++-------- iguana/exchanges/LP_include.h | 4 +- iguana/exchanges/LP_mmjson.c | 2 +- iguana/exchanges/LP_nativeDEX.c | 14 +++++-- iguana/exchanges/LP_ordermatch.c | 6 ++- iguana/exchanges/LP_signatures.c | 24 ++++++++++- iguana/exchanges/LP_swap.c | 34 +++++++++------ iguana/exchanges/coins | 2 +- 10 files changed, 120 insertions(+), 45 deletions(-) diff --git a/iguana/exchanges/LP_bitcoin.c b/iguana/exchanges/LP_bitcoin.c index e1df7d4c2..0343acc0b 100644 --- a/iguana/exchanges/LP_bitcoin.c +++ b/iguana/exchanges/LP_bitcoin.c @@ -2041,10 +2041,10 @@ bits256 bits256_calcaddrhash(char *symbol,uint8_t *serialized,int32_t len) else { HashGroestl(hash.bytes,serialized,len); - int32_t i; char str[65]; + /*int32_t i; char str[65]; for (i=0; i %s\n",len,bits256_str(str,hash)); + printf(" HashGroestl %d -> %s\n",len,bits256_str(str,hash));*/ } return(hash); } diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index 94186c659..d4ab9756f 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -184,7 +184,9 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\ jaddstr(retjson,"pubsecp",pub33str); jadd(retjson,"coins",LP_coinsjson(LP_showwif)); LP_cmdcount++; - return(jprint(retjson,1)); + free_json(retjson); + retjson = 0; + //return(jprint(retjson,1)); } // if passphrase api and passphrase is right, ignore userpass, use hass of passphrase if ( strcmp(method,"passphrase") == 0 && (passphrase= jstr(argjson,"passphrase")) != 0 ) diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index efa8c4232..3485abfc3 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -55,7 +55,7 @@ extern "C" { char* bobAddress; char* aliceHash; char* bobSecret; - } AliceClaimsAlicePaymentInput; + } AliceReclaimsAlicePaymentInput; typedef struct { char* dealId; @@ -64,7 +64,7 @@ extern "C" { char* aliceAddress; char* aliceSecret; char* bobHash; - } BobClaimsAlicePaymentInput; + } BobSpendsAlicePaymentInput; typedef struct { char* depositId; @@ -87,7 +87,7 @@ extern "C" { char* aliceAddress; char* bobSecret; char* aliceCanClaimAfter; - } BobClaimsDepositInput; + } BobRefundsDepositInput; typedef struct { char* depositId; @@ -119,7 +119,7 @@ extern "C" { char* aliceAddress; char* aliceHash; char* bobCanClaimAfter; - } BobClaimsBobPaymentInput; + } BobReclaimsBobPaymentInput; typedef struct { char* paymentId; @@ -128,22 +128,57 @@ extern "C" { char* aliceSecret; char* bobAddress; char* bobCanClaimAfter; - } AliceClaimsBobPaymentInput; + } AliceSpendsBobPaymentInput; - void approveErc20(char* amount, char* from, char* secret, char* buffer, int nonce); - void aliceInitsEthDeal(AliceInitEthInput input, BasicTxData txData, char* result); - void aliceInitsErc20Deal(AliceInitErc20Input input, BasicTxData txData, char* result); - void aliceClaimsAlicePayment(AliceClaimsAlicePaymentInput input, BasicTxData txData, char* result); - void bobClaimsAlicePayment(BobClaimsAlicePaymentInput input, BasicTxData txData, char* result); - void bobMakesEthDeposit(BobMakesEthDepositInput input, BasicTxData txData, char* result); - void bobMakesErc20Deposit(BobMakesErc20DepositInput input, BasicTxData txData, char* result); - void bobClaimsDeposit(BobClaimsDepositInput input, BasicTxData txData, char* result); - void aliceClaimsBobDeposit(AliceClaimsBobDepositInput input, BasicTxData txData, char* result); - void bobMakesEthPayment(BobMakesEthPaymentInput input, BasicTxData txData, char* result); - void bobMakesErc20Payment(BobMakesErc20PaymentInput input, BasicTxData txData, char* result); - void bobClaimsBobPayment(BobClaimsBobPaymentInput input, BasicTxData txData, char* result); - void aliceClaimsBobPayment(AliceClaimsBobPaymentInput input, BasicTxData txData, char* result); // Your prototype or Definition #ifdef __cplusplus } #endif + +#define ETOMIC_ALICECONTRACT "0xe1D4236C5774D35Dc47dcc2E5E0CcFc463A3289c" +#define ETOMIC_BOBCONTRACT "0x9387Fd3a016bB0205e4e131Dde886B9d2BC000A2" +#define ETOMIC_SATOSHICAT "0000000000" + +char *aliceInitsEthDeal(AliceInitEthInput input,BasicTxData txData); +char *aliceInitsErc20Deal(AliceInitErc20Input input,BasicTxData txData); +char *aliceMakesEthPayment(AliceMakesEthPaymentInput input,BasicTxData txData); +char *aliceMakesErc20Payment(AliceMakesErc20PaymentInput input,BasicTxData txData); +char *aliceSpendsBobPayment(AliceSpendsBobPaymentInput input,BasicTxData txData); +char *aliceReclaimsAlicePayment(AliceReclaimsAlicePaymentInput input,BasicTxData txData); +char *aliceClaimsBobDeposit(AliceClaimsBobDepositInput input,BasicTxData txData); + +char *bobMakesEthDeposit(BobMakesEthDepositInput input,BasicTxData txData); +char *bobMakesErc20Deposit(BobMakesErc20DepositInput input,BasicTxData txData); +char *bobMakesEthPayment(BobMakesEthPaymentInput input,BasicTxData txData); +char *bobMakesErc20Payment(BobMakesErc20PaymentInput input,BasicTxData txData); +char *bobSpendsAlicePayment(BobSpendsAlicePaymentInput input,BasicTxData txData); +char *bobReclaimsBobPayment(BobReclaimsBobPaymentInput input,BasicTxData txData); +char *bobRefundsDeposit(BobRefundsDepositInput input,BasicTxData txData); + +char *approveErc20(char *amount,char *from,char *secret,char *buffer,int32_t nonce); + +int32_t LP_etomicsymbol(char *etomic,char *symbol) +{ + struct iguana_info *coin; + etomic[0] = 0; + if ( (coin= LP_coinfind(symbol)) != 0 ) + strcpy(etomic,coin->etomic); + return(etomic[0] != 0); +} + +char *LP_etomicalice_start(struct basilisk_swap *swap) +{ + AliceInitEthInput input; AliceInitErc20Input input20; BasicTxData txData; + // set input and txData fields from the swap data structure + memset(&txData,0,sizeof(txData)); + if ( strcmp(swap->I.alicestr,"ETH") == 0 ) + { + memset(&input,0,sizeof(input)); + return(aliceInitsEthDeal(input,txData)); + } + else + { + memset(&input20,0,sizeof(input20)); + return(aliceInitsErc20Deal(input20,txData)); + } +} diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index 96a94c08d..0d64f9de0 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -232,7 +232,7 @@ struct basilisk_rawtx struct basilisk_swapinfo { struct basilisk_request req; - char bobstr[128],alicestr[128]; + char bobstr[128],alicestr[128],bobtomic[64],alicetomic[64]; 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; @@ -302,7 +302,7 @@ struct iguana_info int32_t numutxos,notarized,longestchain,firstrefht,firstscanht,lastscanht,height; uint16_t busport; uint32_t txversion,dPoWtime,loadedcache,electrumlist,lastunspent,importedprivkey,lastpushtime,lastutxosync,addr_listunspent_requested,lastutxos,updaterate,counter,inactive,lastmempool,lastgetinfo,ratetime,heighttime,lastmonitor,obooktime; uint8_t pubtype,p2shtype,isPoS,wiftype,wiftaddr,taddr,noimportprivkey_flag,userconfirms,isassetchain,maxconfirms; - char symbol[128],smartaddr[64],userpass[1024],serverport[128],instantdex_address[64]; + char symbol[128],smartaddr[64],etomic[64],userpass[1024],serverport[128],instantdex_address[64]; // portfolio double price_kmd,force,perc,goal,goalperc,relvolume,rate; void *electrum; void *ctx; diff --git a/iguana/exchanges/LP_mmjson.c b/iguana/exchanges/LP_mmjson.c index 1239c4180..5663e6f67 100644 --- a/iguana/exchanges/LP_mmjson.c +++ b/iguana/exchanges/LP_mmjson.c @@ -51,7 +51,7 @@ int32_t MM_numfields; char *MM_fields[256] = { - "timestamp", "getdPoW", "dPoW", "aliceid", "src", "base", "basevol", "dest", "rel", "relvol", "price", "requestid", "quoteid", "finished", "expired", "bobdeposit", "alicepayment", "bobpayment", "paymentspent", "Apaymentspent", "depositspent", "ind", "method", "swapstatus", "method2", "gettradestatus", "coin", "rmd160", "pub", "pubsecp", "sig", "session", "notify", "pubkey", "price64", "credits", "utxocoin", "n", "bal", "min", "max", "postprice", "notarized", "notarizedhash", "notarizationtxid", "wantnotify", "isLP", "gui", "nogui", "tradeid", "address", "txid", "vout", "srchash", "txfee", "quotetime", "satoshis", "desthash", "txid2", "vout2", "destaddr", "desttxid", "destvout", "feetxid", "feevout", "desttxfee", "destsatoshis", "pending", "reserved", "broadcast", "ismine", "simplegui", "request", "proof", "connect", "expiration", "iambob", "Bgui", "", "Agui", "bob", "srcamount", "bobtxfee", "alice", "destamount", "alicetxfee", "sentflags", "values", "result", "success", "status", "finishtime", "tradestatus", "pair", "connected", "warning", "critical", "endcritical", + "timestamp", "getdPoW", "dPoW", "aliceid", "src", "base", "basevol", "dest", "rel", "relvol", "price", "requestid", "quoteid", "finished", "expired", "bobdeposit", "alicepayment", "bobpayment", "paymentspent", "Apaymentspent", "depositspent", "ind", "method", "swapstatus", "method2", "gettradestatus", "coin", "rmd160", "pub", "pubsecp", "sig", "session", "notify", "pubkey", "price64", "credits", "utxocoin", "n", "bal", "min", "max", "postprice", "notarized", "notarizedhash", "notarizationtxid", "wantnotify", "isLP", "gui", "nogui", "tradeid", "address", "txid", "vout", "srchash", "txfee", "quotetime", "satoshis", "desthash", "txid2", "vout2", "destaddr", "desttxid", "destvout", "feetxid", "feevout", "desttxfee", "destsatoshis", "pending", "reserved", "broadcast", "ismine", "simplegui", "request", "proof", "connect", "expiration", "iambob", "Bgui", "", "Agui", "bob", "srcamount", "bobtxfee", "alice", "destamount", "alicetxfee", "sentflags", "values", "result", "success", "status", "finishtime", "tradestatus", "pair", "connected", "warning", "critical", "endcritical", "etomic", "esrc", "edest" }; char *MM_coins[256] = diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 1fe39f0b9..1249a2acd 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -174,6 +174,7 @@ char *blocktrail_listtransactions(char *symbol,char *coinaddr,int32_t num,int32_ #include "LP_NXT.c" #include "LP_cache.c" #include "LP_RTmetrics.c" +#include "LP_etomic.c" #include "LP_utxo.c" #include "LP_prices.c" #include "LP_scan.c" @@ -795,7 +796,7 @@ void bech32_tests() void LP_initcoins(void *ctx,int32_t pubsock,cJSON *coins) { - int32_t i,n,notarized; cJSON *item; char *symbol; struct iguana_info *coin; + int32_t i,n,notarized; cJSON *item; char *symbol,*etomic; struct iguana_info *coin; for (i=0; iinactive = (uint32_t)time(NULL); - else LP_unspents_load(coin->symbol,coin->smartaddr); + if ( (etomic= jstr(item,"etomic")) != 0 ) + safecopy(coin->etomic,etomic,sizeof(coin->etomic)); + else + { + if ( LP_getheight(¬arized,coin) <= 0 ) + coin->inactive = (uint32_t)time(NULL); + else LP_unspents_load(coin->symbol,coin->smartaddr); + } if ( coin->txfee == 0 && strcmp(coin->symbol,"BTC") != 0 ) coin->txfee = LP_MIN_TXFEE; if ( 0 && strcmp(coin->symbol,"BCH") == 0 ) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index 3ec680e96..b8f337d54 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -1164,7 +1164,11 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson, char *method,str[65]; int32_t num,DEXselector = 0; uint64_t aliceid; double qprice,bestprice,price,bid,ask; cJSON *proof; struct iguana_info *coin; struct LP_quoteinfo Q,Q2; int32_t counter,retval=-1; if ( (method= jstr(argjson,"method")) != 0 && (strcmp(method,"reserved") == 0 ||strcmp(method,"connected") == 0 || strcmp(method,"request") == 0 || strcmp(method,"connect") == 0) ) { - LP_quoteparse(&Q,argjson); + if ( LP_quoteparse(&Q,argjson) < 0 ) + { + printf("ERROR parsing.(%s)\n",jprint(argjson,0)); + return(1); + } LP_requestinit(&Q.R,Q.srchash,Q.desthash,Q.srccoin,Q.satoshis-Q.txfee,Q.destcoin,Q.destsatoshis-Q.desttxfee,Q.timestamp,Q.quotetime,DEXselector); LP_tradecommand_log(argjson); printf("%-4d (%-10u %10u) %12s id.%-20llu %5s/%-5s %12.8f -> %12.8f (%11.8f) | RT.%d %d n%d\n",(uint32_t)time(NULL) % 3600,Q.R.requestid,Q.R.quoteid,method,(long long)Q.aliceid,Q.srccoin,Q.destcoin,dstr(Q.satoshis),dstr(Q.destsatoshis),(double)Q.destsatoshis/Q.satoshis,LP_RTcount,LP_swapscount,G.netid); diff --git a/iguana/exchanges/LP_signatures.c b/iguana/exchanges/LP_signatures.c index 00c92a8d8..40075c6d9 100644 --- a/iguana/exchanges/LP_signatures.c +++ b/iguana/exchanges/LP_signatures.c @@ -41,13 +41,17 @@ struct basilisk_request *LP_requestinit(struct basilisk_request *rp,bits256 srch cJSON *LP_quotejson(struct LP_quoteinfo *qp) { - double price; cJSON *retjson = cJSON_CreateObject(); + double price; char etomic[64]; cJSON *retjson = cJSON_CreateObject(); if ( jobj(retjson,"gui") == 0 ) jaddstr(retjson,"gui",qp->gui[0] != 0 ? qp->gui : LP_gui); jadd64bits(retjson,"aliceid",qp->aliceid); jaddnum(retjson,"tradeid",qp->tradeid); jaddstr(retjson,"base",qp->srccoin); + if ( LP_etomicsymbol(etomic,qp->srccoin) != 0 ) + jaddstr(retjson,"esrc",etomic); jaddstr(retjson,"rel",qp->destcoin); + if ( LP_etomicsymbol(etomic,qp->destcoin) != 0 ) + jaddstr(retjson,"edest",etomic); if ( qp->coinaddr[0] != 0 ) jaddstr(retjson,"address",qp->coinaddr); if ( qp->timestamp != 0 ) @@ -104,12 +108,28 @@ cJSON *LP_quotejson(struct LP_quoteinfo *qp) int32_t LP_quoteparse(struct LP_quoteinfo *qp,cJSON *argjson) { - uint32_t rid,qid; + uint32_t rid,qid; char etomic[64],*etomicstr; memset(qp,0,sizeof(*qp)); safecopy(qp->gui,LP_gui,sizeof(qp->gui)); safecopy(qp->srccoin,jstr(argjson,"base"),sizeof(qp->srccoin)); + if ( LP_etomicsymbol(etomic,qp->srccoin) != 0 ) + { + if ( (etomicstr= jstr(argjson,"esrc")) == 0 || strcmp(etomicstr,etomic) != 0 ) + { + printf("etomic src mismatch (%s) vs (%s)\n",etomicstr!=0?etomicstr:"",etomic); + return(-1); + } + } safecopy(qp->coinaddr,jstr(argjson,"address"),sizeof(qp->coinaddr)); safecopy(qp->destcoin,jstr(argjson,"rel"),sizeof(qp->destcoin)); + if ( LP_etomicsymbol(etomic,qp->destcoin) != 0 ) + { + if ( (etomicstr= jstr(argjson,"edest")) == 0 || strcmp(etomicstr,etomic) != 0 ) + { + printf("etomic dest mismatch (%s) vs (%s)\n",etomicstr!=0?etomicstr:"",etomic); + return(-1); + } + } safecopy(qp->destaddr,jstr(argjson,"destaddr"),sizeof(qp->destaddr)); qp->aliceid = j64bits(argjson,"aliceid"); qp->tradeid = juint(argjson,"tradeid"); diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index 2c2ad8b90..23da9a6d1 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -861,15 +861,21 @@ void LP_aliceloop(void *_swap) { LP_swapsfp_update(&swap->I.req); LP_swap_critical = (uint32_t)time(NULL); + if ( swap->I.alicetomic[0] != 0 ) + { + // artem: do stuff alice needs to do at the beginning of the swap, before dexfee + } if ( LP_swapdata_rawtxsend(swap->N.pair,swap,0x80,data,maxlen,&swap->myfee,0x40,0) == 0 ) printf("error sending alicefee\n"); else if ( LP_waitfor(swap->N.pair,swap,1800,LP_verify_bobdeposit) < 0 ) printf("error waiting for bobdeposit\n"); else { - /*if ( strcmp(swap->I.bobstr,"BTC") == 0 ) - m = 0; - else*/ m = swap->I.bobconfirms; + if ( swap->I.alicetomic[0] != 0 ) + { + // artem: do stuff alice needs to do after bobdeposit comes in + } + m = swap->I.bobconfirms; while ( (n= LP_numconfirms(swap->I.bobstr,swap->bobdeposit.I.destaddr,swap->bobdeposit.I.signedtxid,0,1)) < m ) { LP_swap_critical = (uint32_t)time(NULL); @@ -880,9 +886,11 @@ void LP_aliceloop(void *_swap) printf("error sending alicepayment\n"); else { - /*if ( strcmp(swap->I.alicestr,"BTC") == 0 ) - m = 0; - else*/ m = swap->I.aliceconfirms; + if ( swap->I.alicetomic[0] != 0 ) + { + // artem: do stuff alice needs to do right before alicepayment goes out + } + m = swap->I.aliceconfirms; while ( (n= LP_numconfirms(swap->I.alicestr,swap->alicepayment.I.destaddr,swap->alicepayment.I.signedtxid,0,1)) < m ) { LP_swap_critical = (uint32_t)time(NULL); @@ -895,22 +903,20 @@ void LP_aliceloop(void *_swap) printf("error waiting for bobpayment\n"); else { + if ( swap->I.alicetomic[0] != 0 ) + { + // artem: do stuff alice needs to do after bobpayment comes in + } LP_swap_endcritical = (uint32_t)time(NULL); while ( (n= LP_numconfirms(swap->I.bobstr,swap->bobpayment.I.destaddr,swap->bobpayment.I.signedtxid,0,1)) < swap->I.bobconfirms ) { char str[65];printf("%d wait for bobpayment %s numconfs.%d %s %s\n",n,swap->bobpayment.I.destaddr,swap->I.bobconfirms,swap->I.bobstr,bits256_str(str,swap->bobpayment.I.signedtxid)); sleep(10); } - /*if ( LP_swapdata_rawtxsend(swap->N.pair,swap,0x20000,data,maxlen,&swap->alicespend,0x40000,0) == 0 ) - printf("error sending alicespend\n"); - while ( (n= LP_numconfirms(swap->I.alicestr,swap->alicespend.I.destaddr,swap->alicespend.I.signedtxid,0,1)) < swap->I.aliceconfirms ) - { - char str[65];printf("%d wait for alicespend %s numconfs.%d %s %s\n",n,swap->alicespend.I.destaddr,swap->I.aliceconfirms,swap->I.bobstr,bits256_str(str,swap->alicespend.I.signedtxid)); - sleep(LP_SWAPSTEP_TIMEOUT); - }*/ if ( swap->N.pair >= 0 ) nn_close(swap->N.pair), swap->N.pair = -1; LP_swap_endcritical = (uint32_t)time(NULL); + // spending is done in LP_remember.c LP_swapwait(swap,swap->I.req.requestid,swap->I.req.quoteid,LP_atomic_locktime(swap->I.bobstr,swap->I.alicestr)*2,swap->I.aliceconfirms == 0 ? 3 : 30); } } @@ -1040,6 +1046,8 @@ struct basilisk_swap *bitcoin_swapinit(bits256 privkey,uint8_t *pubkey33,bits256 uint8_t *alicepub33=0,*bobpub33=0; int32_t jumblrflag=-2,x = -1; struct iguana_info *bobcoin,*alicecoin; strcpy(swap->I.bobstr,swap->I.req.src); strcpy(swap->I.alicestr,swap->I.req.dest); + LP_etomicsymbol(swap->I.bobtomic,swap->I.bobstr); + LP_etomicsymbol(swap->I.alicetomic,swap->I.bobstr); if ( (alicecoin= LP_coinfind(swap->I.alicestr)) == 0 ) { printf("missing alicecoin src.%p dest.%p\n",LP_coinfind(swap->I.req.src),LP_coinfind(swap->I.req.dest)); diff --git a/iguana/exchanges/coins b/iguana/exchanges/coins index b41a8b96f..0725602b8 100644 --- a/iguana/exchanges/coins +++ b/iguana/exchanges/coins @@ -1,3 +1,3 @@ -export coins="[{\"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\":\"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}]" #, {\"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}, From 207cfaa60918717a1f94ed1d6c24f436a31707d2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 2 Feb 2018 11:58:06 +0200 Subject: [PATCH 003/197] Test --- iguana/exchanges/LP_NXT.c | 4 +--- iguana/exchanges/LP_nativeDEX.c | 40 +++++++++++++++++++++++++++++++ iguana/exchanges/LP_portfolio.c | 7 +++++- iguana/exchanges/coins | 2 +- iguana/exchanges/prices/autoprice | 2 +- 5 files changed, 49 insertions(+), 6 deletions(-) diff --git a/iguana/exchanges/LP_NXT.c b/iguana/exchanges/LP_NXT.c index 6bc320925..88626ec0f 100644 --- a/iguana/exchanges/LP_NXT.c +++ b/iguana/exchanges/LP_NXT.c @@ -202,9 +202,7 @@ void NXTventure_liquidation() cJSON *LP_NXT_redeems() { char url[1024],*retstr,*recv,*method,*msgstr,assetname[128]; uint64_t totals[2][sizeof(assetids)/sizeof(*assetids)],mult,txnum,assetid,qty; int32_t i,ind,numtx=0,past_marker=0; cJSON *item,*attach,*decjson,*array,*msgjson,*encjson,*retjson=0; - //sleep 1; fiat/supernet sendtoaddress RNZZuQYu8xJLZHuekhd96hYfoQuiCMz99T 1001.44150000 # txnum.8537615468620726612 - //sleep 1; fiat/pangea sendtoaddress RWMdRaUmMZqKkEibwEhY6XS3RLCXJDWHTi 22.10910000 # txnum.2649622877615958504 - uint64_t txnum_marker = calc_nxt64bits("8537615468620726612"); // 2649622877615958504"); // set to most recent processed + uint64_t txnum_marker = calc_nxt64bits("4114304329372848717"); // 8537615468620726612"); // set to most recent processed uint64_t txnum_marker2 = calc_nxt64bits("7256847492742571143"); // dont change, end marker char *passphrase = ""; char *account = "NXT-MRBN-8DFH-PFMK-A4DBM"; diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 1249a2acd..e099c5160 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -483,6 +483,11 @@ void command_rpcloop(void *ctx) command_rpcloop_stats.threshold = 2500.; while ( LP_STOP_RECEIVED == 0 ) { + if ( G.initializing != 0 ) + { + sleep(1); + continue; + } LP_millistats_update(&command_rpcloop_stats); nonz = LP_nanomsg_recvs(ctx); //if ( LP_mybussock >= 0 ) @@ -518,6 +523,11 @@ void LP_coinsloop(void *_coins) } while ( LP_STOP_RECEIVED == 0 ) { + if ( G.initializing != 0 ) + { + sleep(1); + continue; + } if ( strcmp(G.USERPASS,"1d8b27b21efabcd96571cd56f91a40fb9aa4cc623d273c63bf9223dc6f8cd81f") == 0 ) { sleep(10); @@ -914,6 +924,11 @@ void LP_pubkeysloop(void *ctx) sleep(10); while ( LP_STOP_RECEIVED == 0 ) { + if ( G.initializing != 0 ) + { + sleep(1); + continue; + } if ( strcmp(G.USERPASS,"1d8b27b21efabcd96571cd56f91a40fb9aa4cc623d273c63bf9223dc6f8cd81f") != 0 ) { LP_millistats_update(&LP_pubkeysloop_stats); @@ -936,6 +951,11 @@ void LP_swapsloop(void *ctx) sleep(50); while ( LP_STOP_RECEIVED == 0 ) { + if ( G.initializing != 0 ) + { + sleep(1); + continue; + } if ( strcmp(G.USERPASS,"1d8b27b21efabcd96571cd56f91a40fb9aa4cc623d273c63bf9223dc6f8cd81f") != 0 ) { LP_millistats_update(&LP_swapsloop_stats); @@ -953,6 +973,11 @@ void gc_loop(void *ctx) LP_gcloop_stats.threshold = 11000.; while ( LP_STOP_RECEIVED == 0 ) { + if ( G.initializing != 0 ) + { + sleep(1); + continue; + } flag = 0; LP_millistats_update(&LP_gcloop_stats); portable_mutex_lock(&LP_gcmutex); @@ -988,6 +1013,11 @@ void queue_loop(void *ctx) queue_loop_stats.threshold = 1000.; while ( LP_STOP_RECEIVED == 0 ) { + if ( G.initializing != 0 ) + { + sleep(1); + continue; + } LP_millistats_update(&queue_loop_stats); //printf("LP_Q.%p next.%p prev.%p\n",LP_Q,LP_Q!=0?LP_Q->next:0,LP_Q!=0?LP_Q->prev:0); n = nonz = flag = 0; @@ -1097,6 +1127,11 @@ void LP_reserved_msgs(void *ignore) LP_reserved_msgs_stats.threshold = 1000.; while ( LP_STOP_RECEIVED == 0 ) { + if ( G.initializing != 0 ) + { + sleep(1); + continue; + } nonz = 0; LP_millistats_update(&LP_reserved_msgs_stats); if ( num_Reserved_msgs[0] > 0 || num_Reserved_msgs[1] > 0 ) @@ -1390,6 +1425,11 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybu //fprintf(stderr,"."); sleep(3); } + if ( G.initializing != 0 ) + { + sleep(1); + continue; + } if ( LP_mainloop_iter(ctx,myipaddr,mypeer,LP_mypubsock) != 0 ) nonz++; if ( didremote == 0 && LP_cmdcount > 0 ) diff --git a/iguana/exchanges/LP_portfolio.c b/iguana/exchanges/LP_portfolio.c index ead40b27c..95e6d2c03 100644 --- a/iguana/exchanges/LP_portfolio.c +++ b/iguana/exchanges/LP_portfolio.c @@ -840,9 +840,14 @@ void prices_loop(void *ctx) { char *retstr; cJSON *retjson,*array; char *buycoin,*sellcoin; struct iguana_info *buy,*sell; uint32_t requestid,quoteid; int32_t i,n,m; struct LP_portfoliotrade trades[256]; struct LP_priceinfo *btcpp; strcpy(prices_loop_stats.name,"prices_loop"); - prices_loop_stats.threshold = 191000.; + prices_loop_stats.threshold = 600000.; while ( LP_STOP_RECEIVED == 0 ) { + if ( G.initializing != 0 ) + { + sleep(1); + continue; + } //printf("prices loop autoprices.%d autorefs.%d\n",LP_autoprices,num_LP_autorefs); LP_millistats_update(&prices_loop_stats); LP_tradebots_timeslice(ctx); diff --git a/iguana/exchanges/coins b/iguana/exchanges/coins index 0725602b8..988b79784 100644 --- a/iguana/exchanges/coins +++ b/iguana/exchanges/coins @@ -1,3 +1,3 @@ -export coins="[{\"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\":\"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/prices/autoprice b/iguana/exchanges/prices/autoprice index eb3b53851..c3750a157 100755 --- a/iguana/exchanges/prices/autoprice +++ b/iguana/exchanges/prices/autoprice @@ -10,7 +10,7 @@ curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\ curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"HUSH\",\"rel\":\"KMD\",\"margin\":$margin,\"refbase\":\"hush\",\"refrel\":\"coinmarketcap\"}" curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"KMD\",\"rel\":\"BTCH\",\"offset\":0.0,\"refbase\":\"KMD\",\"refrel\":\"HUSH\",\"factor\":1.44,\"buymargin\":0.05,\"sellmargin\":0.05}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"BTCH\",\"rel\":\"KMD\",\"offset\":0.0,\"refbase\":\"HUSH\",\"refrel\":\"KMD\",\"factor\":0.7,\"buymargin\":0.05,\"sellmargin\":0.05}" +#curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"BTCH\",\"rel\":\"KMD\",\"offset\":0.0,\"refbase\":\"HUSH\",\"refrel\":\"KMD\",\"factor\":0.7,\"buymargin\":0.05,\"sellmargin\":0.05}" curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"BEER\",\"rel\":\"PIZZA\",\"fixed\":0.0001,\"margin\":0.00001}" From 7238d556bc060b87787a6da6aac9f3db61f7c063 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 2 Feb 2018 11:59:16 +0200 Subject: [PATCH 004/197] Test --- iguana/exchanges/LP_etomic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index 3485abfc3..f9ae0fb7b 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -141,8 +141,8 @@ extern "C" { char *aliceInitsEthDeal(AliceInitEthInput input,BasicTxData txData); char *aliceInitsErc20Deal(AliceInitErc20Input input,BasicTxData txData); -char *aliceMakesEthPayment(AliceMakesEthPaymentInput input,BasicTxData txData); -char *aliceMakesErc20Payment(AliceMakesErc20PaymentInput input,BasicTxData txData); +//char *aliceMakesEthPayment(AliceMakesEthPaymentInput input,BasicTxData txData); +//char *aliceMakesErc20Payment(AliceMakesErc20PaymentInput input,BasicTxData txData); char *aliceSpendsBobPayment(AliceSpendsBobPaymentInput input,BasicTxData txData); char *aliceReclaimsAlicePayment(AliceReclaimsAlicePaymentInput input,BasicTxData txData); char *aliceClaimsBobDeposit(AliceClaimsBobDepositInput input,BasicTxData txData); From 3dfbc3e01c7d2bf2aa8f42b9c4aa855d281ea7c7 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Fri, 2 Feb 2018 18:24:24 +0700 Subject: [PATCH 005/197] Build marketmaker using Cmake. Link etomic lib. --- .gitignore | 2 + .gitmodules | 3 + CMakeLists.txt | 14 + cmake/Hunter/config.cmake | 18 + cmake/HunterGate.cmake | 529 ++++++++++++++++++ cmake/toolchain.cmake | 4 + cpp-ethereum | 1 + crypto777/CMakeLists.txt | 4 + crypto777/jpeg/CMakeLists.txt | 4 + iguana/exchanges/CMakeLists.txt | 5 + iguana/exchanges/mm.c | 19 + iguana/m_unix | 2 +- iguana/secp256k1/CMakeLists.txt | 5 + iguana/secp256k1/include/secp256k1_recovery.h | 1 + 14 files changed, 610 insertions(+), 1 deletion(-) create mode 100644 .gitmodules create mode 100644 CMakeLists.txt create mode 100644 cmake/Hunter/config.cmake create mode 100644 cmake/HunterGate.cmake create mode 100644 cmake/toolchain.cmake create mode 160000 cpp-ethereum create mode 100644 crypto777/CMakeLists.txt create mode 100644 crypto777/jpeg/CMakeLists.txt create mode 100644 iguana/exchanges/CMakeLists.txt create mode 100644 iguana/secp256k1/CMakeLists.txt diff --git a/.gitignore b/.gitignore index 14b005133..4b701008b 100755 --- a/.gitignore +++ b/.gitignore @@ -499,3 +499,5 @@ iguana/DB/UNSPENTS/.tmpmarker iguana/DB/instantdex_RQ4z6KrMZeEnCSCsChv1ZoR9ExQitHjbpg_append.json iguana/DB/instantdex_RQ4z6KrMZeEnCSCsChv1ZoR9ExQitHjbpg.json + +build \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..f3eeef5d3 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "cpp-ethereum"] + path = cpp-ethereum + url = git@github.com:artemii235/cpp-ethereum.git diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..ef437913e --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.9) +include("cmake/HunterGate.cmake") +HunterGate( + URL "https://github.com/ruslo/hunter/archive/v0.19.173.tar.gz" + SHA1 "750fb1d621af971fad6f303356b13017ad9f5e15" + LOCAL +) +project(SuperNET) +include_directories("${CMAKE_SOURCE_DIR}") +add_subdirectory(cpp-ethereum) +add_subdirectory(iguana/exchanges) +add_subdirectory(iguana/secp256k1) +add_subdirectory(crypto777) +add_subdirectory(crypto777/jpeg) \ No newline at end of file diff --git a/cmake/Hunter/config.cmake b/cmake/Hunter/config.cmake new file mode 100644 index 000000000..ad5e23194 --- /dev/null +++ b/cmake/Hunter/config.cmake @@ -0,0 +1,18 @@ +# cryptopp has very bad CMakeLists.txt config. +# We have to enforce "cross compiling mode" there by setting CMAKE_SYSTEM_VERSION=NO +# to any "false" value. +hunter_config(cryptopp VERSION ${HUNTER_cryptopp_VERSION} CMAKE_ARGS CMAKE_SYSTEM_VERSION=NO) + +hunter_config( + libjson-rpc-cpp + VERSION ${HUNTER_libjson-rpc-cpp_VERSION} + CMAKE_ARGS + UNIX_DOMAIN_SOCKET_SERVER=NO + UNIX_DOMAIN_SOCKET_CLIENT=NO + FILE_DESCRIPTOR_SERVER=NO + FILE_DESCRIPTOR_CLIENT=NO + TCP_SOCKET_SERVER=NO + TCP_SOCKET_CLIENT=NO + HTTP_SERVER=NO + HTTP_CLIENT=NO +) \ No newline at end of file diff --git a/cmake/HunterGate.cmake b/cmake/HunterGate.cmake new file mode 100644 index 000000000..cdc37afe6 --- /dev/null +++ b/cmake/HunterGate.cmake @@ -0,0 +1,529 @@ +# Copyright (c) 2013-2017, Ruslan Baratov +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# This is a gate file to Hunter package manager. +# Include this file using `include` command and add package you need, example: +# +# cmake_minimum_required(VERSION 3.0) +# +# include("cmake/HunterGate.cmake") +# HunterGate( +# URL "https://github.com/path/to/hunter/archive.tar.gz" +# SHA1 "798501e983f14b28b10cda16afa4de69eee1da1d" +# ) +# +# project(MyProject) +# +# hunter_add_package(Foo) +# hunter_add_package(Boo COMPONENTS Bar Baz) +# +# Projects: +# * https://github.com/hunter-packages/gate/ +# * https://github.com/ruslo/hunter + +option(HUNTER_ENABLED "Enable Hunter package manager support" ON) +if(HUNTER_ENABLED) + if(CMAKE_VERSION VERSION_LESS "3.0") + message(FATAL_ERROR "At least CMake version 3.0 required for hunter dependency management." + " Update CMake or set HUNTER_ENABLED to OFF.") + endif() +endif() + +include(CMakeParseArguments) # cmake_parse_arguments + +option(HUNTER_STATUS_PRINT "Print working status" ON) +option(HUNTER_STATUS_DEBUG "Print a lot info" OFF) + +set(HUNTER_WIKI "https://github.com/ruslo/hunter/wiki") + +function(hunter_gate_status_print) + foreach(print_message ${ARGV}) + if(HUNTER_STATUS_PRINT OR HUNTER_STATUS_DEBUG) + message(STATUS "[hunter] ${print_message}") + endif() + endforeach() +endfunction() + +function(hunter_gate_status_debug) + foreach(print_message ${ARGV}) + if(HUNTER_STATUS_DEBUG) + string(TIMESTAMP timestamp) + message(STATUS "[hunter *** DEBUG *** ${timestamp}] ${print_message}") + endif() + endforeach() +endfunction() + +function(hunter_gate_wiki wiki_page) + message("------------------------------ WIKI -------------------------------") + message(" ${HUNTER_WIKI}/${wiki_page}") + message("-------------------------------------------------------------------") + message("") + message(FATAL_ERROR "") +endfunction() + +function(hunter_gate_internal_error) + message("") + foreach(print_message ${ARGV}) + message("[hunter ** INTERNAL **] ${print_message}") + endforeach() + message("[hunter ** INTERNAL **] [Directory:${CMAKE_CURRENT_LIST_DIR}]") + message("") + hunter_gate_wiki("error.internal") +endfunction() + +function(hunter_gate_fatal_error) + cmake_parse_arguments(hunter "" "WIKI" "" "${ARGV}") + string(COMPARE EQUAL "${hunter_WIKI}" "" have_no_wiki) + if(have_no_wiki) + hunter_gate_internal_error("Expected wiki") + endif() + message("") + foreach(x ${hunter_UNPARSED_ARGUMENTS}) + message("[hunter ** FATAL ERROR **] ${x}") + endforeach() + message("[hunter ** FATAL ERROR **] [Directory:${CMAKE_CURRENT_LIST_DIR}]") + message("") + hunter_gate_wiki("${hunter_WIKI}") +endfunction() + +function(hunter_gate_user_error) + hunter_gate_fatal_error(${ARGV} WIKI "error.incorrect.input.data") +endfunction() + +function(hunter_gate_self root version sha1 result) + string(COMPARE EQUAL "${root}" "" is_bad) + if(is_bad) + hunter_gate_internal_error("root is empty") + endif() + + string(COMPARE EQUAL "${version}" "" is_bad) + if(is_bad) + hunter_gate_internal_error("version is empty") + endif() + + string(COMPARE EQUAL "${sha1}" "" is_bad) + if(is_bad) + hunter_gate_internal_error("sha1 is empty") + endif() + + string(SUBSTRING "${sha1}" 0 7 archive_id) + + if(EXISTS "${root}/cmake/Hunter") + set(hunter_self "${root}") + else() + set( + hunter_self + "${root}/_Base/Download/Hunter/${version}/${archive_id}/Unpacked" + ) + endif() + + set("${result}" "${hunter_self}" PARENT_SCOPE) +endfunction() + +# Set HUNTER_GATE_ROOT cmake variable to suitable value. +function(hunter_gate_detect_root) + # Check CMake variable + string(COMPARE NOTEQUAL "${HUNTER_ROOT}" "" not_empty) + if(not_empty) + set(HUNTER_GATE_ROOT "${HUNTER_ROOT}" PARENT_SCOPE) + hunter_gate_status_debug("HUNTER_ROOT detected by cmake variable") + return() + endif() + + # Check environment variable + string(COMPARE NOTEQUAL "$ENV{HUNTER_ROOT}" "" not_empty) + if(not_empty) + set(HUNTER_GATE_ROOT "$ENV{HUNTER_ROOT}" PARENT_SCOPE) + hunter_gate_status_debug("HUNTER_ROOT detected by environment variable") + return() + endif() + + # Check HOME environment variable + string(COMPARE NOTEQUAL "$ENV{HOME}" "" result) + if(result) + set(HUNTER_GATE_ROOT "$ENV{HOME}/.hunter" PARENT_SCOPE) + hunter_gate_status_debug("HUNTER_ROOT set using HOME environment variable") + return() + endif() + + # Check SYSTEMDRIVE and USERPROFILE environment variable (windows only) + if(WIN32) + string(COMPARE NOTEQUAL "$ENV{SYSTEMDRIVE}" "" result) + if(result) + set(HUNTER_GATE_ROOT "$ENV{SYSTEMDRIVE}/.hunter" PARENT_SCOPE) + hunter_gate_status_debug( + "HUNTER_ROOT set using SYSTEMDRIVE environment variable" + ) + return() + endif() + + string(COMPARE NOTEQUAL "$ENV{USERPROFILE}" "" result) + if(result) + set(HUNTER_GATE_ROOT "$ENV{USERPROFILE}/.hunter" PARENT_SCOPE) + hunter_gate_status_debug( + "HUNTER_ROOT set using USERPROFILE environment variable" + ) + return() + endif() + endif() + + hunter_gate_fatal_error( + "Can't detect HUNTER_ROOT" + WIKI "error.detect.hunter.root" + ) +endfunction() + +macro(hunter_gate_lock dir) + if(NOT HUNTER_SKIP_LOCK) + if("${CMAKE_VERSION}" VERSION_LESS "3.2") + hunter_gate_fatal_error( + "Can't lock, upgrade to CMake 3.2 or use HUNTER_SKIP_LOCK" + WIKI "error.can.not.lock" + ) + endif() + hunter_gate_status_debug("Locking directory: ${dir}") + file(LOCK "${dir}" DIRECTORY GUARD FUNCTION) + hunter_gate_status_debug("Lock done") + endif() +endmacro() + +function(hunter_gate_download dir) + string( + COMPARE + NOTEQUAL + "$ENV{HUNTER_DISABLE_AUTOINSTALL}" + "" + disable_autoinstall + ) + if(disable_autoinstall AND NOT HUNTER_RUN_INSTALL) + hunter_gate_fatal_error( + "Hunter not found in '${dir}'" + "Set HUNTER_RUN_INSTALL=ON to auto-install it from '${HUNTER_GATE_URL}'" + "Settings:" + " HUNTER_ROOT: ${HUNTER_GATE_ROOT}" + " HUNTER_SHA1: ${HUNTER_GATE_SHA1}" + WIKI "error.run.install" + ) + endif() + string(COMPARE EQUAL "${dir}" "" is_bad) + if(is_bad) + hunter_gate_internal_error("Empty 'dir' argument") + endif() + + string(COMPARE EQUAL "${HUNTER_GATE_SHA1}" "" is_bad) + if(is_bad) + hunter_gate_internal_error("HUNTER_GATE_SHA1 empty") + endif() + + string(COMPARE EQUAL "${HUNTER_GATE_URL}" "" is_bad) + if(is_bad) + hunter_gate_internal_error("HUNTER_GATE_URL empty") + endif() + + set(done_location "${dir}/DONE") + set(sha1_location "${dir}/SHA1") + + set(build_dir "${dir}/Build") + set(cmakelists "${dir}/CMakeLists.txt") + + hunter_gate_lock("${dir}") + if(EXISTS "${done_location}") + # while waiting for lock other instance can do all the job + hunter_gate_status_debug("File '${done_location}' found, skip install") + return() + endif() + + file(REMOVE_RECURSE "${build_dir}") + file(REMOVE_RECURSE "${cmakelists}") + + file(MAKE_DIRECTORY "${build_dir}") # check directory permissions + + # Disabling languages speeds up a little bit, reduces noise in the output + # and avoids path too long windows error + file( + WRITE + "${cmakelists}" + "cmake_minimum_required(VERSION 3.0)\n" + "project(HunterDownload LANGUAGES NONE)\n" + "include(ExternalProject)\n" + "ExternalProject_Add(\n" + " Hunter\n" + " URL\n" + " \"${HUNTER_GATE_URL}\"\n" + " URL_HASH\n" + " SHA1=${HUNTER_GATE_SHA1}\n" + " DOWNLOAD_DIR\n" + " \"${dir}\"\n" + " SOURCE_DIR\n" + " \"${dir}/Unpacked\"\n" + " CONFIGURE_COMMAND\n" + " \"\"\n" + " BUILD_COMMAND\n" + " \"\"\n" + " INSTALL_COMMAND\n" + " \"\"\n" + ")\n" + ) + + if(HUNTER_STATUS_DEBUG) + set(logging_params "") + else() + set(logging_params OUTPUT_QUIET) + endif() + + hunter_gate_status_debug("Run generate") + + # Need to add toolchain file too. + # Otherwise on Visual Studio + MDD this will fail with error: + # "Could not find an appropriate version of the Windows 10 SDK installed on this machine" + if(EXISTS "${CMAKE_TOOLCHAIN_FILE}") + get_filename_component(absolute_CMAKE_TOOLCHAIN_FILE "${CMAKE_TOOLCHAIN_FILE}" ABSOLUTE) + set(toolchain_arg "-DCMAKE_TOOLCHAIN_FILE=${absolute_CMAKE_TOOLCHAIN_FILE}") + else() + # 'toolchain_arg' can't be empty + set(toolchain_arg "-DCMAKE_TOOLCHAIN_FILE=") + endif() + + string(COMPARE EQUAL "${CMAKE_MAKE_PROGRAM}" "" no_make) + if(no_make) + set(make_arg "") + else() + # Test case: remove Ninja from PATH but set it via CMAKE_MAKE_PROGRAM + set(make_arg "-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}") + endif() + + execute_process( + COMMAND + "${CMAKE_COMMAND}" + "-H${dir}" + "-B${build_dir}" + "-G${CMAKE_GENERATOR}" + "${toolchain_arg}" + ${make_arg} + WORKING_DIRECTORY "${dir}" + RESULT_VARIABLE download_result + ${logging_params} + ) + + if(NOT download_result EQUAL 0) + hunter_gate_internal_error("Configure project failed") + endif() + + hunter_gate_status_print( + "Initializing Hunter workspace (${HUNTER_GATE_SHA1})" + " ${HUNTER_GATE_URL}" + " -> ${dir}" + ) + execute_process( + COMMAND "${CMAKE_COMMAND}" --build "${build_dir}" + WORKING_DIRECTORY "${dir}" + RESULT_VARIABLE download_result + ${logging_params} + ) + + if(NOT download_result EQUAL 0) + hunter_gate_internal_error("Build project failed") + endif() + + file(REMOVE_RECURSE "${build_dir}") + file(REMOVE_RECURSE "${cmakelists}") + + file(WRITE "${sha1_location}" "${HUNTER_GATE_SHA1}") + file(WRITE "${done_location}" "DONE") + + hunter_gate_status_debug("Finished") +endfunction() + +# Must be a macro so master file 'cmake/Hunter' can +# apply all variables easily just by 'include' command +# (otherwise PARENT_SCOPE magic needed) +macro(HunterGate) + if(HUNTER_GATE_DONE) + # variable HUNTER_GATE_DONE set explicitly for external project + # (see `hunter_download`) + set_property(GLOBAL PROPERTY HUNTER_GATE_DONE YES) + endif() + + # First HunterGate command will init Hunter, others will be ignored + get_property(_hunter_gate_done GLOBAL PROPERTY HUNTER_GATE_DONE SET) + + if(NOT HUNTER_ENABLED) + # Empty function to avoid error "unknown function" + function(hunter_add_package) + endfunction() + elseif(_hunter_gate_done) + hunter_gate_status_debug("Secondary HunterGate (use old settings)") + hunter_gate_self( + "${HUNTER_CACHED_ROOT}" + "${HUNTER_VERSION}" + "${HUNTER_SHA1}" + _hunter_self + ) + include("${_hunter_self}/cmake/Hunter") + else() + set(HUNTER_GATE_LOCATION "${CMAKE_CURRENT_LIST_DIR}") + + string(COMPARE NOTEQUAL "${PROJECT_NAME}" "" _have_project_name) + if(_have_project_name) + hunter_gate_fatal_error( + "Please set HunterGate *before* 'project' command. " + "Detected project: ${PROJECT_NAME}" + WIKI "error.huntergate.before.project" + ) + endif() + + cmake_parse_arguments( + HUNTER_GATE "LOCAL" "URL;SHA1;GLOBAL;FILEPATH" "" ${ARGV} + ) + + string(COMPARE EQUAL "${HUNTER_GATE_SHA1}" "" _empty_sha1) + string(COMPARE EQUAL "${HUNTER_GATE_URL}" "" _empty_url) + string( + COMPARE + NOTEQUAL + "${HUNTER_GATE_UNPARSED_ARGUMENTS}" + "" + _have_unparsed + ) + string(COMPARE NOTEQUAL "${HUNTER_GATE_GLOBAL}" "" _have_global) + string(COMPARE NOTEQUAL "${HUNTER_GATE_FILEPATH}" "" _have_filepath) + + if(_have_unparsed) + hunter_gate_user_error( + "HunterGate unparsed arguments: ${HUNTER_GATE_UNPARSED_ARGUMENTS}" + ) + endif() + if(_empty_sha1) + hunter_gate_user_error("SHA1 suboption of HunterGate is mandatory") + endif() + if(_empty_url) + hunter_gate_user_error("URL suboption of HunterGate is mandatory") + endif() + if(_have_global) + if(HUNTER_GATE_LOCAL) + hunter_gate_user_error("Unexpected LOCAL (already has GLOBAL)") + endif() + if(_have_filepath) + hunter_gate_user_error("Unexpected FILEPATH (already has GLOBAL)") + endif() + endif() + if(HUNTER_GATE_LOCAL) + if(_have_global) + hunter_gate_user_error("Unexpected GLOBAL (already has LOCAL)") + endif() + if(_have_filepath) + hunter_gate_user_error("Unexpected FILEPATH (already has LOCAL)") + endif() + endif() + if(_have_filepath) + if(_have_global) + hunter_gate_user_error("Unexpected GLOBAL (already has FILEPATH)") + endif() + if(HUNTER_GATE_LOCAL) + hunter_gate_user_error("Unexpected LOCAL (already has FILEPATH)") + endif() + endif() + + hunter_gate_detect_root() # set HUNTER_GATE_ROOT + + # Beautify path, fix probable problems with windows path slashes + get_filename_component( + HUNTER_GATE_ROOT "${HUNTER_GATE_ROOT}" ABSOLUTE + ) + hunter_gate_status_debug("HUNTER_ROOT: ${HUNTER_GATE_ROOT}") + if(NOT HUNTER_ALLOW_SPACES_IN_PATH) + string(FIND "${HUNTER_GATE_ROOT}" " " _contain_spaces) + if(NOT _contain_spaces EQUAL -1) + hunter_gate_fatal_error( + "HUNTER_ROOT (${HUNTER_GATE_ROOT}) contains spaces." + "Set HUNTER_ALLOW_SPACES_IN_PATH=ON to skip this error" + "(Use at your own risk!)" + WIKI "error.spaces.in.hunter.root" + ) + endif() + endif() + + string( + REGEX + MATCH + "[0-9]+\\.[0-9]+\\.[0-9]+[-_a-z0-9]*" + HUNTER_GATE_VERSION + "${HUNTER_GATE_URL}" + ) + string(COMPARE EQUAL "${HUNTER_GATE_VERSION}" "" _is_empty) + if(_is_empty) + set(HUNTER_GATE_VERSION "unknown") + endif() + + hunter_gate_self( + "${HUNTER_GATE_ROOT}" + "${HUNTER_GATE_VERSION}" + "${HUNTER_GATE_SHA1}" + _hunter_self + ) + + set(_master_location "${_hunter_self}/cmake/Hunter") + if(EXISTS "${HUNTER_GATE_ROOT}/cmake/Hunter") + # Hunter downloaded manually (e.g. by 'git clone') + set(_unused "xxxxxxxxxx") + set(HUNTER_GATE_SHA1 "${_unused}") + set(HUNTER_GATE_VERSION "${_unused}") + else() + get_filename_component(_archive_id_location "${_hunter_self}/.." ABSOLUTE) + set(_done_location "${_archive_id_location}/DONE") + set(_sha1_location "${_archive_id_location}/SHA1") + + # Check Hunter already downloaded by HunterGate + if(NOT EXISTS "${_done_location}") + hunter_gate_download("${_archive_id_location}") + endif() + + if(NOT EXISTS "${_done_location}") + hunter_gate_internal_error("hunter_gate_download failed") + endif() + + if(NOT EXISTS "${_sha1_location}") + hunter_gate_internal_error("${_sha1_location} not found") + endif() + file(READ "${_sha1_location}" _sha1_value) + string(COMPARE EQUAL "${_sha1_value}" "${HUNTER_GATE_SHA1}" _is_equal) + if(NOT _is_equal) + hunter_gate_internal_error( + "Short SHA1 collision:" + " ${_sha1_value} (from ${_sha1_location})" + " ${HUNTER_GATE_SHA1} (HunterGate)" + ) + endif() + if(NOT EXISTS "${_master_location}") + hunter_gate_user_error( + "Master file not found:" + " ${_master_location}" + "try to update Hunter/HunterGate" + ) + endif() + endif() + include("${_master_location}") + set_property(GLOBAL PROPERTY HUNTER_GATE_DONE YES) + endif() +endmacro() \ No newline at end of file diff --git a/cmake/toolchain.cmake b/cmake/toolchain.cmake new file mode 100644 index 000000000..0ac730b5f --- /dev/null +++ b/cmake/toolchain.cmake @@ -0,0 +1,4 @@ +# Require C++11. +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED True) +set(CMAKE_CXX_EXTENSIONS Off) \ No newline at end of file diff --git a/cpp-ethereum b/cpp-ethereum new file mode 160000 index 000000000..994c1d812 --- /dev/null +++ b/cpp-ethereum @@ -0,0 +1 @@ +Subproject commit 994c1d812380436d980d27b0289ba5f84237ee83 diff --git a/crypto777/CMakeLists.txt b/crypto777/CMakeLists.txt new file mode 100644 index 000000000..8a5b77522 --- /dev/null +++ b/crypto777/CMakeLists.txt @@ -0,0 +1,4 @@ +file(GLOB sources "*.c") +file(GLOB headers "*.h") +add_library(libcrypto777 ${sources} ${headers}) +target_link_libraries(libcrypto777 PUBLIC curl) \ No newline at end of file diff --git a/crypto777/jpeg/CMakeLists.txt b/crypto777/jpeg/CMakeLists.txt new file mode 100644 index 000000000..aec626b74 --- /dev/null +++ b/crypto777/jpeg/CMakeLists.txt @@ -0,0 +1,4 @@ +file(GLOB sources "*.c") +file(GLOB headers "*.h") +add_library(libjpeg ${sources} ${headers}) +target_sources(libjpeg PRIVATE "unix/jmemname.c") diff --git a/iguana/exchanges/CMakeLists.txt b/iguana/exchanges/CMakeLists.txt new file mode 100644 index 000000000..0d4adfd61 --- /dev/null +++ b/iguana/exchanges/CMakeLists.txt @@ -0,0 +1,5 @@ +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +add_executable(marketmaker mm.c) +include_directories(../../crypto777) +target_sources(marketmaker PRIVATE ../mini-gmp.c) +target_link_libraries(marketmaker PRIVATE nanomsg curl pthread m libcrypto777 libjpeg libsecp256k1 "-Wl,--allow-multiple-definition" etomiclib) \ No newline at end of file diff --git a/iguana/exchanges/mm.c b/iguana/exchanges/mm.c index faa8804a9..6f0084fbb 100644 --- a/iguana/exchanges/mm.c +++ b/iguana/exchanges/mm.c @@ -28,6 +28,7 @@ void PNACL_message(char *arg,...) #include #include +// #include "lib.h" #ifndef NATIVE_WINDOWS #include "OS_portable.h" #else @@ -70,6 +71,7 @@ void LP_priceupdate(char *base,char *rel,double price,double avebid,double aveas #endif #include "LP_nativeDEX.c" +#include void LP_main(void *ptr) { @@ -86,6 +88,23 @@ void LP_main(void *ptr) int main(int argc, const char * argv[]) { + BasicTxData txData; + txData.amount = "1000000000000000000"; + txData.from = "0xA7EF3f65714AE266414C9E58bB4bAa4E6FB82B41"; + txData.to = "0x9387Fd3a016bB0205e4e131Dde886B9d2BC000A2"; + txData.secretKey = getenv("BOB_PK"); + txData.nonce = 1; + + BobSendsEthDepositInput input = { + .aliceAddress = "0x485d2cc2d13a9e12E4b53D606DB1c8adc884fB8a", + .depositId = "0x28c5a7c25911ef59a577ddf811d0e58edb827efb0646a8a38df6e921ba53f431", + .bobHash = "0xd66ca5295806fb95ead3f2be1d193a206a376371" + }; + + char* ethSignedTx; + ethSignedTx = bobSendsEthDeposit(input, txData); + printf("%s", ethSignedTx); + free(ethSignedTx); char dirname[512],*passphrase; double incr; cJSON *retjson; OS_init(); if ( strstr(argv[0],"btc2kmd") != 0 && argv[1] != 0 ) diff --git a/iguana/m_unix b/iguana/m_unix index 8517b1135..762bcbd58 100755 --- a/iguana/m_unix +++ b/iguana/m_unix @@ -9,4 +9,4 @@ cd secp256k1; ./m_unix; cd .. cd ../crypto777; ./m_unix; cd ../iguana gcc -g -fno-aggressive-loop-optimizations -Wno-deprecated -c *.c ../basilisk/basilisk.c ../gecko/gecko.c ../datachain/datachain.c gcc -g -fno-aggressive-loop-optimizations -Wno-deprecated -c main.c iguana777.c iguana_bundles.c ../basilisk/basilisk.c -gcc -g -o ../agents/iguana *.o ../agents/libcrypto777.a -lpthread -lm -lnanomsg +gcc -g -o ../agents/iguana *.o ../agents/libcrypto777.a -lpthread -lm -lnanomsg -lcurl diff --git a/iguana/secp256k1/CMakeLists.txt b/iguana/secp256k1/CMakeLists.txt new file mode 100644 index 000000000..ae62f1f16 --- /dev/null +++ b/iguana/secp256k1/CMakeLists.txt @@ -0,0 +1,5 @@ +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +file(GLOB sources "src/secp256k1.c") +file(GLOB headers "src/*.h") +add_definitions(-DHAVE_CONFIG_H) +add_library(libsecp256k1 ${sources} ${headers}) \ No newline at end of file diff --git a/iguana/secp256k1/include/secp256k1_recovery.h b/iguana/secp256k1/include/secp256k1_recovery.h index 5e4d89b81..8f3082698 100644 --- a/iguana/secp256k1/include/secp256k1_recovery.h +++ b/iguana/secp256k1/include/secp256k1_recovery.h @@ -2,6 +2,7 @@ # define _SECP256K1_RECOVERY_ # include "secp256k1.h" +# include "stdint.h" # ifdef __cplusplus extern "C" { From 7053d4fd5420665d848cb48715e435c2dad74d8a Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Fri, 2 Feb 2018 18:53:52 +0700 Subject: [PATCH 006/197] Fix build after pull. --- iguana/exchanges/CMakeLists.txt | 2 + iguana/exchanges/LP_etomic.c | 138 +------------------------------- iguana/exchanges/mm.c | 3 +- 3 files changed, 7 insertions(+), 136 deletions(-) diff --git a/iguana/exchanges/CMakeLists.txt b/iguana/exchanges/CMakeLists.txt index 0d4adfd61..696d2557c 100644 --- a/iguana/exchanges/CMakeLists.txt +++ b/iguana/exchanges/CMakeLists.txt @@ -2,4 +2,6 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}) add_executable(marketmaker mm.c) include_directories(../../crypto777) target_sources(marketmaker PRIVATE ../mini-gmp.c) +target_sources(marketmaker PRIVATE ../groestl.c) +target_sources(marketmaker PRIVATE ../segwit_addr.c) target_link_libraries(marketmaker PRIVATE nanomsg curl pthread m libcrypto777 libjpeg libsecp256k1 "-Wl,--allow-multiple-definition" etomiclib) \ No newline at end of file diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index f9ae0fb7b..5c16e4cfe 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -21,142 +21,12 @@ // // Created by artem on 24.01.18. // -#ifdef __cplusplus -extern "C" { -#endif - typedef struct { - char* from; - char* to; - char* amount; - int nonce; - char* secretKey; - } BasicTxData; - - typedef struct { - char* dealId; - char* bobAddress; - char* aliceHash; - char* bobHash; - } AliceInitEthInput; - - typedef struct { - char* dealId; - char* amount; - char* tokenAddress; - char* bobAddress; - char* aliceHash; - char* bobHash; - } AliceInitErc20Input; - - typedef struct { - char* dealId; - char* amount; - char* tokenAddress; - char* bobAddress; - char* aliceHash; - char* bobSecret; - } AliceReclaimsAlicePaymentInput; - - typedef struct { - char* dealId; - char* amount; - char* tokenAddress; - char* aliceAddress; - char* aliceSecret; - char* bobHash; - } BobSpendsAlicePaymentInput; - - typedef struct { - char* depositId; - char* aliceAddress; - char* bobHash; - } BobMakesEthDepositInput; - - typedef struct { - char* depositId; - char* amount; - char* tokenAddress; - char* aliceAddress; - char* bobHash; - } BobMakesErc20DepositInput; - - typedef struct { - char* depositId; - char* amount; - char* tokenAddress; - char* aliceAddress; - char* bobSecret; - char* aliceCanClaimAfter; - } BobRefundsDepositInput; - - typedef struct { - char* depositId; - char* amount; - char* tokenAddress; - char* bobAddress; - char* bobHash; - char* aliceCanClaimAfter; - } AliceClaimsBobDepositInput; - - typedef struct { - char* paymentId; - char* aliceAddress; - char* aliceHash; - } BobMakesEthPaymentInput; - - typedef struct { - char* paymentId; - char* amount; - char* tokenAddress; - char* aliceAddress; - char* aliceHash; - } BobMakesErc20PaymentInput; - - typedef struct { - char* paymentId; - char* amount; - char* tokenAddress; - char* aliceAddress; - char* aliceHash; - char* bobCanClaimAfter; - } BobReclaimsBobPaymentInput; - - typedef struct { - char* paymentId; - char* amount; - char* tokenAddress; - char* aliceSecret; - char* bobAddress; - char* bobCanClaimAfter; - } AliceSpendsBobPaymentInput; - - // Your prototype or Definition -#ifdef __cplusplus -} -#endif +#include #define ETOMIC_ALICECONTRACT "0xe1D4236C5774D35Dc47dcc2E5E0CcFc463A3289c" #define ETOMIC_BOBCONTRACT "0x9387Fd3a016bB0205e4e131Dde886B9d2BC000A2" #define ETOMIC_SATOSHICAT "0000000000" -char *aliceInitsEthDeal(AliceInitEthInput input,BasicTxData txData); -char *aliceInitsErc20Deal(AliceInitErc20Input input,BasicTxData txData); -//char *aliceMakesEthPayment(AliceMakesEthPaymentInput input,BasicTxData txData); -//char *aliceMakesErc20Payment(AliceMakesErc20PaymentInput input,BasicTxData txData); -char *aliceSpendsBobPayment(AliceSpendsBobPaymentInput input,BasicTxData txData); -char *aliceReclaimsAlicePayment(AliceReclaimsAlicePaymentInput input,BasicTxData txData); -char *aliceClaimsBobDeposit(AliceClaimsBobDepositInput input,BasicTxData txData); - -char *bobMakesEthDeposit(BobMakesEthDepositInput input,BasicTxData txData); -char *bobMakesErc20Deposit(BobMakesErc20DepositInput input,BasicTxData txData); -char *bobMakesEthPayment(BobMakesEthPaymentInput input,BasicTxData txData); -char *bobMakesErc20Payment(BobMakesErc20PaymentInput input,BasicTxData txData); -char *bobSpendsAlicePayment(BobSpendsAlicePaymentInput input,BasicTxData txData); -char *bobReclaimsBobPayment(BobReclaimsBobPaymentInput input,BasicTxData txData); -char *bobRefundsDeposit(BobRefundsDepositInput input,BasicTxData txData); - -char *approveErc20(char *amount,char *from,char *secret,char *buffer,int32_t nonce); - int32_t LP_etomicsymbol(char *etomic,char *symbol) { struct iguana_info *coin; @@ -168,17 +38,17 @@ int32_t LP_etomicsymbol(char *etomic,char *symbol) char *LP_etomicalice_start(struct basilisk_swap *swap) { - AliceInitEthInput input; AliceInitErc20Input input20; BasicTxData txData; + AliceSendsEthPaymentInput input; AliceSendsErc20PaymentInput input20; BasicTxData txData; // set input and txData fields from the swap data structure memset(&txData,0,sizeof(txData)); if ( strcmp(swap->I.alicestr,"ETH") == 0 ) { memset(&input,0,sizeof(input)); - return(aliceInitsEthDeal(input,txData)); + return(aliceSendsEthPayment(input,txData)); } else { memset(&input20,0,sizeof(input20)); - return(aliceInitsErc20Deal(input20,txData)); + return(aliceSendsErc20Payment(input20,txData)); } } diff --git a/iguana/exchanges/mm.c b/iguana/exchanges/mm.c index 4258d2d51..5db1567ca 100644 --- a/iguana/exchanges/mm.c +++ b/iguana/exchanges/mm.c @@ -72,7 +72,6 @@ void LP_priceupdate(char *base,char *rel,double price,double avebid,double aveas #include "LP_nativeDEX.c" -#include void LP_ports(uint16_t *pullportp,uint16_t *pubportp,uint16_t *busportp,uint16_t netid) { @@ -130,7 +129,7 @@ int main(int argc, const char * argv[]) char* ethSignedTx; ethSignedTx = bobSendsEthDeposit(input, txData); - printf("%s", ethSignedTx); + printf("%s\n", ethSignedTx); free(ethSignedTx); char dirname[512],*passphrase; double incr; cJSON *retjson; OS_init(); From 13c607602bf1c92b8816b39de59c9c5f4f3cfcb4 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Fri, 2 Feb 2018 19:08:47 +0700 Subject: [PATCH 007/197] Add instruction how to build marketmaker using cmake. --- iguana/Readme.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/iguana/Readme.md b/iguana/Readme.md index 596952081..db6a82af2 100755 --- a/iguana/Readme.md +++ b/iguana/Readme.md @@ -191,3 +191,14 @@ struct iguana_account // 12 bytes uint64_t balance; uint32_t lastunspentind; } __attribute__((packed)); // pkind +# Cmake build of marketmaker with linked etomic lib for ETH/ERC20 atomic swaps: +1. Clone this repository. +1. `git checkout etomic` +1. `git submodule update --init --recursive` +1. `mkdir build` +1. `cd build` +1. `cmake ..` +1. `cmake --build . --target marketmaker` +1. `cd exchanges/iguana` +1. `export BOB_PK=YOUR_PRIVATE_KEY` +1. `./marketmaker` \ No newline at end of file From c6d24280b40993d4da1ab1e0eb68e1a6d582491a Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Fri, 2 Feb 2018 19:37:38 +0700 Subject: [PATCH 008/197] Set develop branch for cpp-ethereum submodule. --- .gitmodules | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitmodules b/.gitmodules index f3eeef5d3..30c42111f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,4 @@ [submodule "cpp-ethereum"] path = cpp-ethereum url = git@github.com:artemii235/cpp-ethereum.git + branch = develop From e9e83b6158ec9ab22944f54d9d94bf00b8076e54 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 2 Feb 2018 14:46:39 +0200 Subject: [PATCH 009/197] airdropH --- iguana/exchanges/beertest | 3 +++ iguana/exchanges/mm.c | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100755 iguana/exchanges/beertest diff --git a/iguana/exchanges/beertest b/iguana/exchanges/beertest new file mode 100755 index 000000000..f0b08a985 --- /dev/null +++ b/iguana/exchanges/beertest @@ -0,0 +1,3 @@ +source userpass +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"BEER\",\"rel\":\"KMD\",\"fixed\":0.777,\"margin\":0.00001}" + diff --git a/iguana/exchanges/mm.c b/iguana/exchanges/mm.c index db8bc57b7..9d401a453 100644 --- a/iguana/exchanges/mm.c +++ b/iguana/exchanges/mm.c @@ -190,6 +190,32 @@ int main(int argc, const char * argv[]) printf("done vanitygen.(%s) done %u elapsed %d\n",argv[2],(uint32_t)time(NULL),(uint32_t)time(NULL) - timestamp); exit(0); } + else if ( argv[1] != 0 && strcmp(argv[1],"airdropH") == 0 && argv[2] != 0 ) + { + FILE *fp; uint8_t addrtype,rmd160[20]; char buf[256],coinaddr[64]; int32_t n,i; char *flag; + if ( (fp= fopen(argv[2],"rb")) != 0 ) + { + while ( fgets(buf,sizeof(buf),fp) > 0 ) + { + if ( (n= (int32_t)strlen(buf)) > 0 ) + buf[--n] = 0; + flag = 0; + for (i=0; i Date: Fri, 2 Feb 2018 14:54:28 +0200 Subject: [PATCH 010/197] Test --- iguana/exchanges/mm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/mm.c b/iguana/exchanges/mm.c index 9d401a453..ee0e4433f 100644 --- a/iguana/exchanges/mm.c +++ b/iguana/exchanges/mm.c @@ -213,7 +213,7 @@ int main(int argc, const char * argv[]) printf("(%s) (%s) <- %s\n",buf,coinaddr,flag); } fclose(fp); - } + } else printf("couldnt open (%s)\n",argv[2]); exit(0); } sprintf(dirname,"%s",GLOBAL_DBDIR), OS_ensure_directory(dirname); From d807d02659a373a096ba86f9caad75d0d98459b2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 2 Feb 2018 14:57:43 +0200 Subject: [PATCH 011/197] Test --- iguana/exchanges/mm.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/mm.c b/iguana/exchanges/mm.c index ee0e4433f..b0cb50465 100644 --- a/iguana/exchanges/mm.c +++ b/iguana/exchanges/mm.c @@ -206,12 +206,17 @@ int main(int argc, const char * argv[]) { buf[i] = 0; flag = &buf[i+1]; + break; } } - bitcoin_addr2rmd160("HUSH",28,&addrtype,rmd160,buf); - bitcoin_address("KMD",coinaddr,0,60,rmd160,20); - printf("(%s) (%s) <- %s\n",buf,coinaddr,flag); + if ( flag != 0 ) + { + bitcoin_addr2rmd160("HUSH",28,&addrtype,rmd160,buf); + bitcoin_address("KMD",coinaddr,0,60,rmd160,20); + printf("(%s) (%s) <- %s\n",buf,coinaddr,flag); + } else printf("parse error for (%s)\n",buf); } + printf("close (%s)\n",argv[2]); fclose(fp); } else printf("couldnt open (%s)\n",argv[2]); exit(0); From 1659fb933d6e0a267a57a5847982b3afc981dbdc Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Fri, 2 Feb 2018 20:01:09 +0700 Subject: [PATCH 012/197] Update cpp-ethereum submodule. --- cpp-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp-ethereum b/cpp-ethereum index 994c1d812..5fcf233e7 160000 --- a/cpp-ethereum +++ b/cpp-ethereum @@ -1 +1 @@ -Subproject commit 994c1d812380436d980d27b0289ba5f84237ee83 +Subproject commit 5fcf233e78783318d5c5ed6cd34d2c5ea5da1dca From cb9f6322359c1c840da8ecc194eaba0fc70d4b3a Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 2 Feb 2018 15:01:18 +0200 Subject: [PATCH 013/197] Test --- iguana/exchanges/LP_etomic.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index f9ae0fb7b..a23cfff72 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -174,11 +174,12 @@ char *LP_etomicalice_start(struct basilisk_swap *swap) if ( strcmp(swap->I.alicestr,"ETH") == 0 ) { memset(&input,0,sizeof(input)); - return(aliceInitsEthDeal(input,txData)); + //return(aliceInitsEthDeal(input,txData)); } else { memset(&input20,0,sizeof(input20)); - return(aliceInitsErc20Deal(input20,txData)); + //return(aliceInitsErc20Deal(input20,txData)); } + return(0); } From 8e882efbefd714255b07098b92c743ea04d9479e Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 2 Feb 2018 15:05:38 +0200 Subject: [PATCH 014/197] Test --- iguana/exchanges/mm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/mm.c b/iguana/exchanges/mm.c index b0cb50465..91ed65141 100644 --- a/iguana/exchanges/mm.c +++ b/iguana/exchanges/mm.c @@ -192,7 +192,7 @@ int main(int argc, const char * argv[]) } else if ( argv[1] != 0 && strcmp(argv[1],"airdropH") == 0 && argv[2] != 0 ) { - FILE *fp; uint8_t addrtype,rmd160[20]; char buf[256],coinaddr[64]; int32_t n,i; char *flag; + FILE *fp; double val,total = 0.; uint8_t addrtype,rmd160[20]; char buf[256],coinaddr[64]; int32_t n,i; char *flag; if ( (fp= fopen(argv[2],"rb")) != 0 ) { while ( fgets(buf,sizeof(buf),fp) > 0 ) @@ -213,7 +213,9 @@ int main(int argc, const char * argv[]) { bitcoin_addr2rmd160("HUSH",28,&addrtype,rmd160,buf); bitcoin_address("KMD",coinaddr,0,60,rmd160,20); - printf("(%s) (%s) <- %s\n",buf,coinaddr,flag); + val = atof(flag); + total += val; + printf("(%s) (%s) <- %.8f total %.8f\n",buf,coinaddr,val,total); } else printf("parse error for (%s)\n",buf); } printf("close (%s)\n",argv[2]); From d7acb803ee63d06c048a8f46626a521042dd665f Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Fri, 2 Feb 2018 20:45:35 +0700 Subject: [PATCH 015/197] Use https for cpp-ethereum submodule. --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 30c42111f..432d28c90 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ [submodule "cpp-ethereum"] path = cpp-ethereum - url = git@github.com:artemii235/cpp-ethereum.git + url = https://github.com/artemii235/cpp-ethereum.git branch = develop From d28ace80b62485bbc62b1274ad1b06219306c074 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Fri, 2 Feb 2018 21:05:01 +0700 Subject: [PATCH 016/197] Set same Cmake version as of cpp-ethereum. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ef437913e..43bac6ac0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.9) +cmake_minimum_required(VERSION 3.5.1) include("cmake/HunterGate.cmake") HunterGate( URL "https://github.com/ruslo/hunter/archive/v0.19.173.tar.gz" From ea6a8bc890d64fd9010bb48efc5ec3bf19cc59f7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 2 Feb 2018 16:18:01 +0200 Subject: [PATCH 017/197] Cli mmjson --- cpp-ethereum | 1 - iguana/exchanges/LP_mmjson.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 160000 cpp-ethereum diff --git a/cpp-ethereum b/cpp-ethereum deleted file mode 160000 index 5fcf233e7..000000000 --- a/cpp-ethereum +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 5fcf233e78783318d5c5ed6cd34d2c5ea5da1dca diff --git a/iguana/exchanges/LP_mmjson.c b/iguana/exchanges/LP_mmjson.c index 5663e6f67..6a3d130d9 100644 --- a/iguana/exchanges/LP_mmjson.c +++ b/iguana/exchanges/LP_mmjson.c @@ -51,7 +51,7 @@ int32_t MM_numfields; char *MM_fields[256] = { - "timestamp", "getdPoW", "dPoW", "aliceid", "src", "base", "basevol", "dest", "rel", "relvol", "price", "requestid", "quoteid", "finished", "expired", "bobdeposit", "alicepayment", "bobpayment", "paymentspent", "Apaymentspent", "depositspent", "ind", "method", "swapstatus", "method2", "gettradestatus", "coin", "rmd160", "pub", "pubsecp", "sig", "session", "notify", "pubkey", "price64", "credits", "utxocoin", "n", "bal", "min", "max", "postprice", "notarized", "notarizedhash", "notarizationtxid", "wantnotify", "isLP", "gui", "nogui", "tradeid", "address", "txid", "vout", "srchash", "txfee", "quotetime", "satoshis", "desthash", "txid2", "vout2", "destaddr", "desttxid", "destvout", "feetxid", "feevout", "desttxfee", "destsatoshis", "pending", "reserved", "broadcast", "ismine", "simplegui", "request", "proof", "connect", "expiration", "iambob", "Bgui", "", "Agui", "bob", "srcamount", "bobtxfee", "alice", "destamount", "alicetxfee", "sentflags", "values", "result", "success", "status", "finishtime", "tradestatus", "pair", "connected", "warning", "critical", "endcritical", "etomic", "esrc", "edest" + "timestamp", "getdPoW", "dPoW", "aliceid", "src", "base", "basevol", "dest", "rel", "relvol", "price", "requestid", "quoteid", "finished", "expired", "bobdeposit", "alicepayment", "bobpayment", "paymentspent", "Apaymentspent", "depositspent", "ind", "method", "swapstatus", "method2", "gettradestatus", "coin", "rmd160", "pub", "pubsecp", "sig", "session", "notify", "pubkey", "price64", "credits", "utxocoin", "n", "bal", "min", "max", "postprice", "notarized", "notarizedhash", "notarizationtxid", "wantnotify", "isLP", "gui", "nogui", "tradeid", "address", "txid", "vout", "srchash", "txfee", "quotetime", "satoshis", "desthash", "txid2", "vout2", "destaddr", "desttxid", "destvout", "feetxid", "feevout", "desttxfee", "destsatoshis", "pending", "reserved", "broadcast", "ismine", "simplegui", "request", "proof", "connect", "expiration", "iambob", "Bgui", "", "Agui", "bob", "srcamount", "bobtxfee", "alice", "destamount", "alicetxfee", "sentflags", "values", "result", "success", "status", "finishtime", "tradestatus", "pair", "connected", "warning", "critical", "endcritical", "etomic", "esrc", "edest", "cli" }; char *MM_coins[256] = From ef62a0c8af9545741797da82ee89393bfd5910d7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 2 Feb 2018 16:54:09 +0200 Subject: [PATCH 018/197] Test --- README.md | 20 ++++++++++++++++++++ crypto777/OS_portable.h | 1 + 2 files changed, 21 insertions(+) diff --git a/README.md b/README.md index 57e2376e8..6ad551b6e 100755 --- a/README.md +++ b/README.md @@ -255,3 +255,23 @@ Execute the OSX deploy script: ./osx_deploy.sh ``` The iguana binary and its linked libraries are in ```$HOME/tmp/iguana```. + +# Cmake build of marketmaker with linked etomic lib for ETH/ERC20 atomic swaps: +1. `git checkout etomic` +2. `cd ~/SuperNET/iguana/exchanges` +3. `git clone https://github.com/artemii235/cpp-ethereum` +4. `cd cpp-ethereum` +5. `git submodule update --init --recursive` +6. `mkdir build` +7. `cd build` +8. `cmake ..` +9. `make` +# now the ethereum libs are there +10. `cd ~/SuperNET/iguana/exchanges` +11. `mkdir build` +12. `cd build` +13. `cmake ..` +14. `make` +15. `cd ../..` +16. `export BOB_PK=YOUR_PRIVATE_KEY` +17. `./marketmaker` diff --git a/crypto777/OS_portable.h b/crypto777/OS_portable.h index 8c109e5d0..491a50454 100755 --- a/crypto777/OS_portable.h +++ b/crypto777/OS_portable.h @@ -31,6 +31,7 @@ #include #include #include +#include #define HAVE_STRUCT_TIMESPEC #include #include From 87047dd824a27e8db9050773690003153dbc52aa Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 2 Feb 2018 17:27:55 +0200 Subject: [PATCH 019/197] stop BTCH autoprice --- iguana/exchanges/prices/autoprice | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/prices/autoprice b/iguana/exchanges/prices/autoprice index c3750a157..e4e261d86 100755 --- a/iguana/exchanges/prices/autoprice +++ b/iguana/exchanges/prices/autoprice @@ -9,7 +9,7 @@ curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\ #curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"KMD\",\"rel\":\"MNZ\",\"offset\":0.0,\"refbase\":\"KMD\",\"refrel\":\"BTC\",\"factor\":15000,\"margin\":-0.2}" curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"HUSH\",\"rel\":\"KMD\",\"margin\":$margin,\"refbase\":\"hush\",\"refrel\":\"coinmarketcap\"}" -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"KMD\",\"rel\":\"BTCH\",\"offset\":0.0,\"refbase\":\"KMD\",\"refrel\":\"HUSH\",\"factor\":1.44,\"buymargin\":0.05,\"sellmargin\":0.05}" +#curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"KMD\",\"rel\":\"BTCH\",\"offset\":0.0,\"refbase\":\"KMD\",\"refrel\":\"HUSH\",\"factor\":1.44,\"buymargin\":0.05,\"sellmargin\":0.05}" #curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"BTCH\",\"rel\":\"KMD\",\"offset\":0.0,\"refbase\":\"HUSH\",\"refrel\":\"KMD\",\"factor\":0.7,\"buymargin\":0.05,\"sellmargin\":0.05}" curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"BEER\",\"rel\":\"PIZZA\",\"fixed\":0.0001,\"margin\":0.00001}" From eb6de5cc379b57d46643d2d11f677732c02c6b51 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 6 Feb 2018 13:51:52 +0200 Subject: [PATCH 020/197] Test --- README.md | 28 ++++++++++--------------- iguana/exchanges/mm.c | 48 +++++++++++++++++++++++++++++++++++++------ 2 files changed, 53 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 6ad551b6e..304ca77fc 100755 --- a/README.md +++ b/README.md @@ -257,21 +257,15 @@ Execute the OSX deploy script: The iguana binary and its linked libraries are in ```$HOME/tmp/iguana```. # Cmake build of marketmaker with linked etomic lib for ETH/ERC20 atomic swaps: -1. `git checkout etomic` -2. `cd ~/SuperNET/iguana/exchanges` -3. `git clone https://github.com/artemii235/cpp-ethereum` -4. `cd cpp-ethereum` -5. `git submodule update --init --recursive` -6. `mkdir build` -7. `cd build` +1. `cd ~/SuperNET` +2. `mkdir build` +3. `git checkout etomic` +4. `git clone https://github.com/artemii235/cpp-ethereum` +5. `cd cpp-ethereum` +6. `git submodule update --init --recursive` +7. `cd ~/SuperNET/build` 8. `cmake ..` -9. `make` -# now the ethereum libs are there -10. `cd ~/SuperNET/iguana/exchanges` -11. `mkdir build` -12. `cd build` -13. `cmake ..` -14. `make` -15. `cd ../..` -16. `export BOB_PK=YOUR_PRIVATE_KEY` -17. `./marketmaker` +9. `cmake --build . --target marketmaker` +10. `cd build/iguana/exchanges` +11. `export BOB_PK=YOUR_PRIVATE_KEY` #export BOB_PK=59a03784447e3b24d2deb7231236d549502e4e806550aca4ab6a5532b003da25 +12. `./marketmaker` diff --git a/iguana/exchanges/mm.c b/iguana/exchanges/mm.c index e641b7fc5..ad744f00d 100644 --- a/iguana/exchanges/mm.c +++ b/iguana/exchanges/mm.c @@ -210,9 +210,10 @@ int main(int argc, const char * argv[]) } else if ( argv[1] != 0 && strcmp(argv[1],"airdropH") == 0 && argv[2] != 0 ) { - FILE *fp; double val,total = 0.; uint8_t addrtype,rmd160[20]; char buf[256],coinaddr[64]; int32_t n,i; char *flag; + FILE *fp; double val,total = 0.; uint8_t checktype,addrtype,rmd160[21],checkrmd160[21]; char buf[256],checkaddr[64],coinaddr[64],manystrs[64][128],cmd[64*128]; int32_t n,i,num; char *flag; if ( (fp= fopen(argv[2],"rb")) != 0 ) { + num = 0; while ( fgets(buf,sizeof(buf),fp) > 0 ) { if ( (n= (int32_t)strlen(buf)) > 0 ) @@ -230,13 +231,48 @@ int main(int argc, const char * argv[]) if ( flag != 0 ) { bitcoin_addr2rmd160("HUSH",28,&addrtype,rmd160,buf); - bitcoin_address("KMD",coinaddr,0,60,rmd160,20); - val = atof(flag); - total += val; - printf("(%s) (%s) <- %.8f total %.8f\n",buf,coinaddr,val,total); + bitcoin_address("KMD",coinaddr,0,addrtype == 184 ? 60 : 85,rmd160,20); + bitcoin_addr2rmd160("KMD",0,&checktype,checkrmd160,coinaddr); + bitcoin_address("HUSH",checkaddr,28,checktype == 60 ? 184 : 189,checkrmd160,20); + if ( memcmp(rmd160,checkrmd160,20) != 0 || strcmp(buf,checkaddr) != 0 ) + { + for (i=0; i<20; i++) + printf("%02x",rmd160[i]); + printf(" vs. "); + for (i=0; i<20; i++) + printf("%02x",checkrmd160[i]); + printf(" address calc error (%s).%d -> (%s).%d -> (%s) %.8f?\n",buf,addrtype,coinaddr,checktype,checkaddr,atof(flag)); + } + else + { + val = atof(flag); + sprintf(manystrs[num++],"\\\"%s\\\":%0.8f",coinaddr,val); + if ( num >= sizeof(manystrs)/sizeof(*manystrs) ) + { + sprintf(cmd,"fiat/btch sendmany \"\" \"{ "); + for (i=0; i 0 ) + { + sprintf(cmd,"fiat/btch sendmany \"\" \"{ "); + for (i=0; i Date: Tue, 6 Feb 2018 13:58:45 +0200 Subject: [PATCH 021/197] Resolve conflicts --- iguana/exchanges/beertest | 5 ----- iguana/exchanges/coins | 4 ---- iguana/exchanges/mm.c | 14 -------------- 3 files changed, 23 deletions(-) diff --git a/iguana/exchanges/beertest b/iguana/exchanges/beertest index 3668a64b8..61b600820 100755 --- a/iguana/exchanges/beertest +++ b/iguana/exchanges/beertest @@ -1,7 +1,2 @@ source userpass -<<<<<<< HEAD -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"BEER\",\"rel\":\"KMD\",\"fixed\":0.777,\"margin\":0.00001}" - -======= curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"BEER\",\"rel\":\"KMD\",\"fixed\":1.28700,\"margin\":0.00001}" ->>>>>>> master diff --git a/iguana/exchanges/coins b/iguana/exchanges/coins index 6f768c3db..988b79784 100644 --- a/iguana/exchanges/coins +++ b/iguana/exchanges/coins @@ -1,7 +1,3 @@ -<<<<<<< HEAD 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\":\"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}]" ->>>>>>> master #, {\"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/mm.c b/iguana/exchanges/mm.c index 344f8ad91..f77131e4a 100644 --- a/iguana/exchanges/mm.c +++ b/iguana/exchanges/mm.c @@ -249,17 +249,10 @@ int main(int argc, const char * argv[]) sprintf(manystrs[num++],"\\\"%s\\\":%0.8f",coinaddr,val); if ( num >= sizeof(manystrs)/sizeof(*manystrs) ) { -<<<<<<< HEAD - sprintf(cmd,"fiat/btch sendmany \"\" \"{ "); - for (i=0; i>>>>>> master printf("%s\n",cmd); num = 0; memset(manystrs,0,sizeof(manystrs)); @@ -271,17 +264,10 @@ int main(int argc, const char * argv[]) } if ( num > 0 ) { -<<<<<<< HEAD - sprintf(cmd,"fiat/btch sendmany \"\" \"{ "); - for (i=0; i>>>>>> master printf("%s\n",cmd); num = 0; memset(manystrs,0,sizeof(manystrs)); From b0793b9607d61ceccf2089555e268c901e9ba901 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 6 Feb 2018 15:40:34 +0200 Subject: [PATCH 022/197] sync --- iguana/exchanges/LP_network.c | 124 +++++++++++++++++----------------- 1 file changed, 63 insertions(+), 61 deletions(-) diff --git a/iguana/exchanges/LP_network.c b/iguana/exchanges/LP_network.c index b632e470d..87c25fd29 100644 --- a/iguana/exchanges/LP_network.c +++ b/iguana/exchanges/LP_network.c @@ -103,28 +103,28 @@ char *nanomsg_transportname(int32_t bindflag,char *str,char *ipaddr,uint16_t por } /*char *nanomsg_transportname2(int32_t bindflag,char *str,char *ipaddr,uint16_t port) -{ - sprintf(str,"ws://%s:%u",bindflag == 0 ? ipaddr : "*",port+10); - return(str); -} - -int32_t _LP_send(int32_t sock,void *msg,int32_t sendlen,int32_t freeflag) -{ - int32_t sentbytes; - if ( sock < 0 ) - { - printf("LP_send.(%s) to illegal socket\n",(char *)msg); - if ( freeflag != 0 ) - free(msg); - return(-1); - } - if ( (sentbytes= nn_send(sock,msg,sendlen,0)) != sendlen ) - printf("LP_send sent %d instead of %d\n",sentbytes,sendlen); - else printf("SENT.(%s)\n",(char *)msg); - if ( freeflag != 0 ) - free(msg); - return(sentbytes); -}*/ + { + sprintf(str,"ws://%s:%u",bindflag == 0 ? ipaddr : "*",port+10); + return(str); + } + + int32_t _LP_send(int32_t sock,void *msg,int32_t sendlen,int32_t freeflag) + { + int32_t sentbytes; + if ( sock < 0 ) + { + printf("LP_send.(%s) to illegal socket\n",(char *)msg); + if ( freeflag != 0 ) + free(msg); + return(-1); + } + if ( (sentbytes= nn_send(sock,msg,sendlen,0)) != sendlen ) + printf("LP_send sent %d instead of %d\n",sentbytes,sendlen); + else printf("SENT.(%s)\n",(char *)msg); + if ( freeflag != 0 ) + free(msg); + return(sentbytes); + }*/ int32_t LP_sockcheck(int32_t sock) { @@ -314,7 +314,7 @@ void LP_broadcast_finish(int32_t pubsock,char *base,char *rel,uint8_t *msg,cJSON #endif { free(msg); -//printf("broadcast %s\n",jstr(argjson,"method")); + //printf("broadcast %s\n",jstr(argjson,"method")); jdelete(argjson,"method"); jaddstr(argjson,"method","broadcast"); if ( jobj(argjson,"timestamp") == 0 ) @@ -332,7 +332,7 @@ void LP_broadcast_finish(int32_t pubsock,char *base,char *rel,uint8_t *msg,cJSON } free(msg); } - + void LP_broadcast_message(int32_t pubsock,char *base,char *rel,bits256 destpub25519,char *msgstr) { uint8_t encoded[LP_ENCRYPTED_MAXSIZE],space[sizeof(encoded)],*msg,*nonce,*cipher; int32_t encrypted=0,msglen; uint32_t crc32=0; cJSON *argjson; char *methodstr,method[64],cipherstr[LP_ENCRYPTED_MAXSIZE*2+1]; @@ -388,7 +388,7 @@ void LP_broadcast_message(int32_t pubsock,char *base,char *rel,bits256 destpub25 if ( msgstr != 0 ) free(msgstr); } - + uint32_t LP_swapsend(int32_t pairsock,struct basilisk_swap *swap,uint32_t msgbits,uint8_t *data,int32_t datalen,uint32_t nextbits,uint32_t crcs[2]) { uint8_t *buf; int32_t sentbytes,offset=0,i; @@ -413,7 +413,7 @@ uint32_t LP_swapsend(int32_t pairsock,struct basilisk_swap *swap,uint32_t msgbit free(buf); return(nextbits); } - + struct LP_queuedcommand { struct LP_queuedcommand *next,*prev; @@ -471,7 +471,7 @@ void LP_queuecommand(char **retstrp,char *buf,int32_t responsesock,int32_t stats DL_APPEND(LP_commandQ,ptr); portable_mutex_unlock(&LP_commandQmutex); } - + void mynn_close(int32_t sock) { struct nn_pollfd pfd; int32_t n; void *buf; @@ -490,7 +490,7 @@ void mynn_close(int32_t sock) nn_close(sock); } } - + void LP_psockloop(void *_ptr) { static struct nn_pollfd *pfds; @@ -522,6 +522,7 @@ void LP_psockloop(void *_ptr) { if ( pfds == 0 ) pfds = calloc(MAX_PSOCK_PORT,sizeof(*pfds)); + nexti = (rand() % Numpsocks); portable_mutex_lock(&LP_psockmutex); memset(pfds,0,sizeof(*pfds) * ((Numpsocks*2 <= MAX_PSOCK_PORT) ? Numpsocks*2 : MAX_PSOCK_PORT)); for (iter=j=0; iter<2; iter++) @@ -541,7 +542,6 @@ void LP_psockloop(void *_ptr) if ( pfds[n].fd != ptr->publicsock ) { printf("unexpected fd.%d mismatched publicsock.%d\n",pfds[n].fd,ptr->publicsock); - nexti = i+1; break; } else if ( (pfds[n].revents & POLLIN) != 0 ) @@ -552,12 +552,12 @@ void LP_psockloop(void *_ptr) { ptr->lasttime = now; if ( ptr->cmdchannel == 0 ) + { sendsock = ptr->sendsock; - else LP_queuecommand(0,(char *)buf,ptr->publicsock,0); - nexti = i+1; - break; + break; + } else LP_queuecommand(0,(char *)buf,ptr->publicsock,0); } - else if ( buf != 0 ) + if ( buf != 0 ) { nn_freemsg(buf); buf = 0; @@ -578,7 +578,6 @@ void LP_psockloop(void *_ptr) if ( pfds[n].fd != ptr->sendsock ) { printf("unexpected fd.%d mismatched sendsock.%d\n",pfds[n].fd,ptr->sendsock); - nexti = i+1; break; } else if ( (pfds[n].revents & POLLIN) != 0 ) @@ -590,7 +589,6 @@ void LP_psockloop(void *_ptr) if ( ptr->ispaired != 0 ) { sendsock = ptr->publicsock; - nexti = i+1; break; } } @@ -615,23 +613,20 @@ void LP_psockloop(void *_ptr) } // else printf("num pfds.%d retval.%d\n",n,retval); } } - if ( sendsock < 0 ) + if ( IAMLP != 0 && sendsock < 0 ) { usleep(30000); for (i=nonz=0; icmdchannel == 0 && now > ptr->lasttime+PSOCK_KEEPALIVE ) { - ptr = &PSOCKS[i]; - if ( ptr->cmdchannel == 0 && now > ptr->lasttime+PSOCK_KEEPALIVE ) - { - printf("PSOCKS[%d] of %d (%u %u) lag.%d IDLETIMEOUT\n",i,Numpsocks,ptr->publicport,ptr->sendport,now - ptr->lasttime); - if ( ptr->sendsock != ptr->publicsock && ptr->sendsock >= 0 ) - mynn_close(ptr->sendsock), ptr->sendsock = -1; - if ( ptr->publicsock >= 0 ) - mynn_close(ptr->publicsock), ptr->publicsock = -1; - nonz++; - } + printf("PSOCKS[%d] of %d (%u %u) lag.%d IDLETIMEOUT\n",i,Numpsocks,ptr->publicport,ptr->sendport,now - ptr->lasttime); + if ( ptr->sendsock != ptr->publicsock && ptr->sendsock >= 0 ) + nn_close(ptr->sendsock), ptr->sendsock = -1; + if ( ptr->publicsock >= 0 ) + nn_close(ptr->publicsock), ptr->publicsock = -1; + nonz++; } } if ( nonz > 0 ) @@ -655,13 +650,14 @@ void LP_psockloop(void *_ptr) } else usleep(100000); } } - + void LP_psockadd(int32_t ispaired,int32_t publicsock,uint16_t recvport,int32_t sendsock,uint16_t sendport,char *subaddr,char *publicaddr,int32_t cmdchannel) { struct psock *ptr; portable_mutex_lock(&LP_psockmutex); PSOCKS = realloc(PSOCKS,sizeof(*PSOCKS) * (Numpsocks + 1)); ptr = &PSOCKS[Numpsocks++]; + memset(ptr,0,sizeof(*ptr)); ptr->ispaired = ispaired; ptr->cmdchannel = cmdchannel; ptr->publicsock = publicsock; @@ -673,7 +669,7 @@ void LP_psockadd(int32_t ispaired,int32_t publicsock,uint16_t recvport,int32_t s ptr->lasttime = (uint32_t)time(NULL); portable_mutex_unlock(&LP_psockmutex); } - + int32_t LP_psockmark(char *publicaddr) { int32_t i,retval = -1; struct psock *ptr; @@ -692,20 +688,24 @@ int32_t LP_psockmark(char *publicaddr) portable_mutex_unlock(&LP_psockmutex); return(retval); } - + char *_LP_psock_create(int32_t *pullsockp,int32_t *pubsockp,char *ipaddr,uint16_t publicport,uint16_t subport,int32_t ispaired,int32_t cmdchannel,bits256 pubkey) { int32_t i,pullsock,bindflag=(IAMLP != 0),pubsock,arg; struct LP_pubkey_info *pubp; char pushaddr[128],subaddr[128]; cJSON *retjson = 0; pullsock = pubsock = -1; *pullsockp = *pubsockp = -1; + if ( cmdchannel != 0 && bits256_nonz(pubkey) == 0 ) + { + printf("ignore cmdchannel request without pubkey\n"); + return(clonestr("{\"error\":\"cmdchannel needs pubkey\"}")); + } if ( IAMLP != 0 && bits256_nonz(pubkey) != 0 ) { - char str[65]; if ( (pubp= LP_pubkeyadd(pubkey)) != 0 ) { if ( pubp->pairsock >= 0 ) { - printf("%s already has pairsock.%d\n",bits256_str(str,pubkey),pubp->pairsock); + //printf("%s already has pairsock.%d\n",bits256_str(str,pubkey),pubp->pairsock); portable_mutex_lock(&LP_psockmutex); for (i=0; ipairsock ) @@ -762,7 +762,9 @@ char *_LP_psock_create(int32_t *pullsockp,int32_t *pubsockp,char *ipaddr,uint16_ jaddnum(retjson,"cmdchannel",cmdchannel); jaddstr(retjson,"publicaddr",pushaddr); jaddnum(retjson,"publicport",publicport); - //printf("cmd.%d publicaddr.(%s) for subaddr.(%s), pullsock.%d pubsock.%d\n",cmdchannel,pushaddr,subaddr,pullsock,pubsock); + if ( bits256_nonz(pubkey) != 0 && (pubp= LP_pubkeyadd(pubkey)) != 0 ) + pubp->pairsock = pullsock; + char str[65]; printf("PSOCK %s cmd.%d publicaddr.(%s) for subaddr.(%s), pullsock.%d pubsock.%d\n",bits256_str(str,pubkey),cmdchannel,pushaddr,subaddr,pullsock,pubsock); *pullsockp = pullsock; *pubsockp = pubsock; return(jprint(retjson,1)); @@ -774,7 +776,7 @@ char *_LP_psock_create(int32_t *pullsockp,int32_t *pubsockp,char *ipaddr,uint16_ } return(0); } - + char *LP_psock(int32_t *pullsockp,char *ipaddr,int32_t ispaired,int32_t cmdchannel,bits256 pubkey) { char *retstr=0; uint16_t i,publicport,subport,maxport; int32_t pubsock=-1; @@ -814,18 +816,18 @@ char *LP_psock(int32_t *pullsockp,char *ipaddr,int32_t ispaired,int32_t cmdchann Pcmdport = MAX_PSOCK_PORT; return(clonestr("{\"error\",\"cant find psock ports\"}")); } - + /* LP_pushaddr_get makes transparent the fact that most nodes cannot bind()! The idea is to create an LP node NN_PAIR sock that the LP node binds to and client node connects to. Additionally, the LP node creates an NN_PULL that other nodes can NN_PUSH to and returns this address in pushaddr/retval for the client node to register with. The desired result is that other than the initial LP node, all the other nodes do a normal NN_PUSH, requiring no change to the NN_PUSH/NN_PULL logic. Of course, the initial LP node needs to autoforward all packets from the public NN_PULL to the NN_PUB - similar to LP_pushaddr_get, create an NN_PAIR for DEX atomic data, can be assumed to have a max lifetime of 2*INSTANTDEX_LOCKTIME + similar to LP_pushaddr_get, create an NN_PAIR for DEX atomic data, can be assumed to have a max lifetime of 2*INSTANTDEX_LOCKTIME both are combined in LP_psock_get - -*/ - + + */ + char *issue_LP_psock(char *destip,uint16_t destport,int32_t ispaired,int32_t cmdchannel) { char str[65],url[512],*retstr; @@ -835,7 +837,7 @@ char *issue_LP_psock(char *destip,uint16_t destport,int32_t ispaired,int32_t cmd printf("issue_LP_psock got (%s) from %s\n",retstr,url); // this is needed?! return(retstr); } - + uint16_t LP_psock_get(char *connectaddr,char *publicaddr,int32_t ispaired,int32_t cmdchannel,char *ipaddr) { uint16_t publicport = 0; char *retstr,*addr; cJSON *retjson; struct LP_peerinfo *peer,*tmp; @@ -865,7 +867,7 @@ uint16_t LP_psock_get(char *connectaddr,char *publicaddr,int32_t ispaired,int32_ } return(0); } - + int32_t LP_initpublicaddr(void *ctx,uint16_t *mypullportp,char *publicaddr,char *myipaddr,uint16_t mypullport,int32_t ispaired) { int32_t nntype,pullsock,timeout; char bindaddr[128],connectaddr[128]; From 74b0c30ba656d70d9d0f2d6348a93656bbd27751 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 6 Feb 2018 17:32:10 +0200 Subject: [PATCH 023/197] Test --- README.md | 21 +++++------ iguana/exchanges/LP_etomic.c | 9 ++++- iguana/exchanges/LP_instantdex.c | 6 ++- iguana/exchanges/LP_swap.c | 65 ++++++++++++++++++-------------- iguana/exchanges/mm.c | 13 ++++--- 5 files changed, 65 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index 304ca77fc..513f9af49 100755 --- a/README.md +++ b/README.md @@ -258,14 +258,13 @@ The iguana binary and its linked libraries are in ```$HOME/tmp/iguana```. # Cmake build of marketmaker with linked etomic lib for ETH/ERC20 atomic swaps: 1. `cd ~/SuperNET` -2. `mkdir build` -3. `git checkout etomic` -4. `git clone https://github.com/artemii235/cpp-ethereum` -5. `cd cpp-ethereum` -6. `git submodule update --init --recursive` -7. `cd ~/SuperNET/build` -8. `cmake ..` -9. `cmake --build . --target marketmaker` -10. `cd build/iguana/exchanges` -11. `export BOB_PK=YOUR_PRIVATE_KEY` #export BOB_PK=59a03784447e3b24d2deb7231236d549502e4e806550aca4ab6a5532b003da25 -12. `./marketmaker` +2. `git checkout etomic` +3. `git submodule add https://github.com/artemii235/cpp-ethereum` +4. `git submodule update --init --recursive` +5. `mkdir build` +6. `cd build` +7. `cmake ..` +8. `cmake --build . --target marketmaker` +9. `cd build/iguana/exchanges` +10. `export BOB_PK=YOUR_PRIVATE_KEY` #export BOB_PK=59a03784447e3b24d2deb7231236d549502e4e806550aca4ab6a5532b003da25 +11. `./marketmaker` diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index b1a0ddfb5..56d8dbbe0 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -27,12 +27,17 @@ #define ETOMIC_BOBCONTRACT "0x9387Fd3a016bB0205e4e131Dde886B9d2BC000A2" #define ETOMIC_SATOSHICAT "0000000000" -int32_t LP_etomicsymbol(char *etomic,char *symbol) +int32_t LP_etomicsymbol(char *activesymbol,char *etomic,char *symbol) { struct iguana_info *coin; - etomic[0] = 0; + etomic[0] = activesymbol[0] = 0; if ( (coin= LP_coinfind(symbol)) != 0 ) + { strcpy(etomic,coin->etomic); + if ( etomic[0] != 0 ) + strcpy(activesymbol,"ETOMIC"); + else strcpy(activesymbol,symbol); + } return(etomic[0] != 0); } diff --git a/iguana/exchanges/LP_instantdex.c b/iguana/exchanges/LP_instantdex.c index 4dd519de7..a54441742 100644 --- a/iguana/exchanges/LP_instantdex.c +++ b/iguana/exchanges/LP_instantdex.c @@ -65,7 +65,8 @@ void LP_instantdex_deposituniq(FILE *fp,bits256 txid) for (i=0; isymbol,swap->I.bobstr) == 0 ) + if ( strcmp(coin->symbol,bobstr) == 0 ) txfee = swap->I.Btxfee; - else if ( strcmp(coin->symbol,swap->I.alicestr) == 0 ) + else if ( strcmp(coin->symbol,alicestr) == 0 ) txfee = swap->I.Atxfee; else txfee = LP_MIN_TXFEE; } @@ -806,13 +806,11 @@ void LP_bobloop(void *_swap) printf("error bobscripts payment\n"); else { - /*if ( strcmp(swap->I.alicestr,"BTC") == 0 ) - m = 0; - else*/ m = swap->I.aliceconfirms; - while ( (n= LP_numconfirms(swap->I.alicestr,swap->alicepayment.I.destaddr,swap->alicepayment.I.signedtxid,0,1)) < m ) // sync with alice + m = swap->I.aliceconfirms; + while ( (n= LP_numconfirms(alicestr,swap->alicepayment.I.destaddr,swap->alicepayment.I.signedtxid,0,1)) < m ) // sync with alice { LP_swap_critical = (uint32_t)time(NULL); - char str[65];printf("%d wait for alicepayment %s numconfs.%d %s %s\n",n,swap->alicepayment.I.destaddr,m,swap->I.alicestr,bits256_str(str,swap->alicepayment.I.signedtxid)); + char str[65];printf("%d wait for alicepayment %s numconfs.%d %s %s\n",n,swap->alicepayment.I.destaddr,m,alicestr,bits256_str(str,swap->alicepayment.I.signedtxid)); sleep(10); } LP_swap_critical = (uint32_t)time(NULL); @@ -827,7 +825,7 @@ void LP_bobloop(void *_swap) if ( swap->N.pair >= 0 ) nn_close(swap->N.pair), swap->N.pair = -1; LP_swap_endcritical = (uint32_t)time(NULL); - LP_swapwait(swap,swap->I.req.requestid,swap->I.req.quoteid,LP_atomic_locktime(swap->I.bobstr,swap->I.alicestr)*2,swap->I.aliceconfirms == 0 ? 3 : 30); + LP_swapwait(swap,swap->I.req.requestid,swap->I.req.quoteid,LP_atomic_locktime(bobstr,alicestr)*2,swap->I.aliceconfirms == 0 ? 3 : 30); } } } @@ -875,10 +873,10 @@ void LP_aliceloop(void *_swap) // artem: do stuff alice needs to do after bobdeposit comes in } m = swap->I.bobconfirms; - while ( (n= LP_numconfirms(swap->I.bobstr,swap->bobdeposit.I.destaddr,swap->bobdeposit.I.signedtxid,0,1)) < m ) + while ( (n= LP_numconfirms(bobstr,swap->bobdeposit.I.destaddr,swap->bobdeposit.I.signedtxid,0,1)) < m ) { LP_swap_critical = (uint32_t)time(NULL); - char str[65];printf("%d wait for bobdeposit %s numconfs.%d %s %s\n",n,swap->bobdeposit.I.destaddr,m,swap->I.bobstr,bits256_str(str,swap->bobdeposit.I.signedtxid)); + char str[65];printf("%d wait for bobdeposit %s numconfs.%d %s %s\n",n,swap->bobdeposit.I.destaddr,m,bobstr,bits256_str(str,swap->bobdeposit.I.signedtxid)); sleep(10); } if ( LP_swapdata_rawtxsend(swap->N.pair,swap,0x1000,data,maxlen,&swap->alicepayment,0x800,0) == 0 ) @@ -890,10 +888,10 @@ void LP_aliceloop(void *_swap) // artem: do stuff alice needs to do right before alicepayment goes out } m = swap->I.aliceconfirms; - while ( (n= LP_numconfirms(swap->I.alicestr,swap->alicepayment.I.destaddr,swap->alicepayment.I.signedtxid,0,1)) < m ) + while ( (n= LP_numconfirms(alicestr,swap->alicepayment.I.destaddr,swap->alicepayment.I.signedtxid,0,1)) < m ) { LP_swap_critical = (uint32_t)time(NULL); - char str[65];printf("%d wait for alicepayment %s numconfs.%d %s %s\n",n,swap->alicepayment.I.destaddr,m,swap->I.alicestr,bits256_str(str,swap->alicepayment.I.signedtxid)); + char str[65];printf("%d wait for alicepayment %s numconfs.%d %s %s\n",n,swap->alicepayment.I.destaddr,m,alicestr,bits256_str(str,swap->alicepayment.I.signedtxid)); sleep(10); } //swap->sentflag = 1; @@ -907,16 +905,16 @@ void LP_aliceloop(void *_swap) // artem: do stuff alice needs to do after bobpayment comes in } LP_swap_endcritical = (uint32_t)time(NULL); - while ( (n= LP_numconfirms(swap->I.bobstr,swap->bobpayment.I.destaddr,swap->bobpayment.I.signedtxid,0,1)) < swap->I.bobconfirms ) + while ( (n= LP_numconfirms(bobstr,swap->bobpayment.I.destaddr,swap->bobpayment.I.signedtxid,0,1)) < swap->I.bobconfirms ) { - char str[65];printf("%d wait for bobpayment %s numconfs.%d %s %s\n",n,swap->bobpayment.I.destaddr,swap->I.bobconfirms,swap->I.bobstr,bits256_str(str,swap->bobpayment.I.signedtxid)); + char str[65];printf("%d wait for bobpayment %s numconfs.%d %s %s\n",n,swap->bobpayment.I.destaddr,swap->I.bobconfirms,bobstr,bits256_str(str,swap->bobpayment.I.signedtxid)); sleep(10); } if ( swap->N.pair >= 0 ) nn_close(swap->N.pair), swap->N.pair = -1; LP_swap_endcritical = (uint32_t)time(NULL); // spending is done in LP_remember.c - LP_swapwait(swap,swap->I.req.requestid,swap->I.req.quoteid,LP_atomic_locktime(swap->I.bobstr,swap->I.alicestr)*2,swap->I.aliceconfirms == 0 ? 3 : 30); + LP_swapwait(swap,swap->I.req.requestid,swap->I.req.quoteid,LP_atomic_locktime(bobstr,alicestr)*2,swap->I.aliceconfirms == 0 ? 3 : 30); } } } @@ -1042,34 +1040,42 @@ void basilisk_rawtx_setparms(char *name,uint32_t quoteid,struct basilisk_rawtx * struct basilisk_swap *bitcoin_swapinit(bits256 privkey,uint8_t *pubkey33,bits256 pubkey25519,struct basilisk_swap *swap,int32_t optionduration,uint32_t statebits,struct LP_quoteinfo *qp,int32_t dynamictrust) { //FILE *fp; char fname[512]; - uint8_t *alicepub33=0,*bobpub33=0; int32_t jumblrflag=-2,x = -1; struct iguana_info *bobcoin,*alicecoin; + uint8_t *alicepub33=0,*bobpub33=0; int32_t jumblrflag=-2,x = -1; struct iguana_info *bobcoin,*alicecoin; char bobstr[65],alicestr[65]; strcpy(swap->I.bobstr,swap->I.req.src); strcpy(swap->I.alicestr,swap->I.req.dest); - LP_etomicsymbol(swap->I.bobtomic,swap->I.bobstr); - LP_etomicsymbol(swap->I.alicetomic,swap->I.bobstr); - if ( (alicecoin= LP_coinfind(swap->I.alicestr)) == 0 ) + LP_etomicsymbol(bobstr,swap->I.bobtomic,swap->I.bobstr); + LP_etomicsymbol(alicestr,swap->I.alicetomic,swap->I.alicestr); + if ( (alicecoin= LP_coinfind(alicestr)) == 0 ) { - printf("missing alicecoin src.%p dest.%p\n",LP_coinfind(swap->I.req.src),LP_coinfind(swap->I.req.dest)); + printf("missing alicecoin src.%p dest.%p\n",LP_coinfind(alicestr),LP_coinfind(bobstr)); free(swap); return(0); } - if ( (bobcoin= LP_coinfind(swap->I.bobstr)) == 0 ) + if ( (bobcoin= LP_coinfind(bobstr)) == 0 ) { printf("missing bobcoin src.%p dest.%p\n",LP_coinfind(swap->I.req.src),LP_coinfind(swap->I.req.dest)); free(swap); return(0); } + if ( alicecoin == 0 || bobcoin == 0 ) + { + printf("couldnt find ETOMIC\n"); + free(swap); + return(0); + } if ( (swap->I.Atxfee= qp->desttxfee) < 0 ) { printf("bitcoin_swapinit %s Atxfee %.8f rejected\n",swap->I.req.dest,dstr(swap->I.Atxfee)); + free(swap); return(0); } if ( (swap->I.Btxfee= qp->txfee) < 0 ) { printf("bitcoin_swapinit %s Btxfee %.8f rejected\n",swap->I.req.src,dstr(swap->I.Btxfee)); + free(swap); return(0); } - swap->I.putduration = swap->I.callduration = LP_atomic_locktime(swap->I.bobstr,swap->I.alicestr); + swap->I.putduration = swap->I.callduration = LP_atomic_locktime(bobstr,alicestr); if ( optionduration < 0 ) swap->I.putduration -= optionduration; else if ( optionduration > 0 ) @@ -1077,11 +1083,13 @@ struct basilisk_swap *bitcoin_swapinit(bits256 privkey,uint8_t *pubkey33,bits256 if ( (swap->I.bobsatoshis= swap->I.req.srcamount) <= 0 ) { printf("bitcoin_swapinit %s bobsatoshis %.8f rejected\n",swap->I.req.src,dstr(swap->I.bobsatoshis)); + free(swap); return(0); } if ( (swap->I.alicesatoshis= swap->I.req.destamount) <= 0 ) { printf("bitcoin_swapinit %s alicesatoshis %.8f rejected\n",swap->I.req.dest,dstr(swap->I.alicesatoshis)); + free(swap); return(0); } if ( (swap->I.bobinsurance= (swap->I.bobsatoshis / INSTANTDEX_INSURANCEDIV)) < LP_MIN_TXFEE ) @@ -1117,14 +1125,15 @@ struct basilisk_swap *bitcoin_swapinit(bits256 privkey,uint8_t *pubkey33,bits256 if ( bits256_nonz(privkey) == 0 || (x= instantdex_pubkeyargs(swap,2 + INSTANTDEX_DECKSIZE,privkey,swap->I.orderhash,0x02+swap->I.iambob)) != 2 + INSTANTDEX_DECKSIZE ) { char str[65]; printf("couldnt generate privkeys %d %s\n",x,bits256_str(str,privkey)); + free(swap); return(0); } - if ( strcmp("BTC",swap->I.bobstr) == 0 ) + if ( strcmp("BTC",bobstr) == 0 ) { swap->I.bobconfirms = 1;//(1 + sqrt(dstr(swap->I.bobsatoshis) * .1)); swap->I.aliceconfirms = BASILISK_DEFAULT_NUMCONFIRMS; } - else if ( strcmp("BTC",swap->I.alicestr) == 0 ) + else if ( strcmp("BTC",alicestr) == 0 ) { swap->I.aliceconfirms = 1;//(1 + sqrt(dstr(swap->I.alicesatoshis) * .1)); swap->I.bobconfirms = BASILISK_DEFAULT_NUMCONFIRMS; @@ -1188,9 +1197,9 @@ struct basilisk_swap *bitcoin_swapinit(bits256 privkey,uint8_t *pubkey33,bits256 swap->bobpayment.utxotxid = qp->txid, swap->bobpayment.utxovout = qp->vout; swap->bobdeposit.utxotxid = qp->txid2, swap->bobdeposit.utxovout = qp->vout2; swap->alicepayment.utxotxid = qp->desttxid, swap->alicepayment.utxovout = qp->destvout; - LP_mark_spent(swap->I.bobstr,qp->txid,qp->vout); - LP_mark_spent(swap->I.bobstr,qp->txid2,qp->vout2); - LP_mark_spent(swap->I.alicestr,qp->desttxid,qp->destvout); + LP_mark_spent(bobstr,qp->txid,qp->vout); + LP_mark_spent(bobstr,qp->txid2,qp->vout2); + LP_mark_spent(alicestr,qp->desttxid,qp->destvout); if ( swap->I.iambob != 0 ) swap->otherfee.utxotxid = qp->feetxid, swap->otherfee.utxovout = qp->feevout; else @@ -1198,7 +1207,7 @@ struct basilisk_swap *bitcoin_swapinit(bits256 privkey,uint8_t *pubkey33,bits256 swap->myfee.utxotxid = qp->feetxid, swap->myfee.utxovout = qp->feevout; LP_mark_spent(swap->I.alicestr,qp->feetxid,qp->feevout); } - //char str[65],str2[65],str3[65]; printf("IAMBOB.%d %s %s %s [%s %s]\n",swap->I.iambob,bits256_str(str,qp->txid),bits256_str(str2,qp->txid2),bits256_str(str3,qp->feetxid),swap->I.bobstr,swap->I.alicestr); + //char str[65],str2[65],str3[65]; printf("IAMBOB.%d %s %s %s [%s %s]\n",swap->I.iambob,bits256_str(str,qp->txid),bits256_str(str2,qp->txid2),bits256_str(str3,qp->feetxid),bobstr,alicestr); return(swap); } diff --git a/iguana/exchanges/mm.c b/iguana/exchanges/mm.c index f77131e4a..2505f6f28 100644 --- a/iguana/exchanges/mm.c +++ b/iguana/exchanges/mm.c @@ -112,27 +112,28 @@ void LP_main(void *ptr) } } -int main(int argc, const char * argv[]) +void ETH_test() { - BasicTxData txData; + BasicTxData txData; char* ethSignedTx; txData.amount = "1000000000000000000"; txData.from = "0xA7EF3f65714AE266414C9E58bB4bAa4E6FB82B41"; txData.to = "0x9387Fd3a016bB0205e4e131Dde886B9d2BC000A2"; txData.secretKey = getenv("BOB_PK"); - txData.nonce = 1; - BobSendsEthDepositInput input = { .aliceAddress = "0x485d2cc2d13a9e12E4b53D606DB1c8adc884fB8a", .depositId = "0x28c5a7c25911ef59a577ddf811d0e58edb827efb0646a8a38df6e921ba53f431", .bobHash = "0xd66ca5295806fb95ead3f2be1d193a206a376371" }; - - char* ethSignedTx; ethSignedTx = bobSendsEthDeposit(input, txData); printf("%s\n", ethSignedTx); free(ethSignedTx); +} + +int main(int argc, const char * argv[]) +{ char dirname[512],*passphrase; double incr; cJSON *retjson; OS_init(); + ETH_test(); if ( strstr(argv[0],"btc2kmd") != 0 && argv[1] != 0 ) { uint8_t addrtype,rmd160[20],rmd160b[20]; char coinaddr[64],coinaddr2[64]; From b536b67d0c30d08c9a1a1a831f0f31ff33777c69 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 6 Feb 2018 17:34:06 +0200 Subject: [PATCH 024/197] Test --- iguana/exchanges/LP_signatures.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/iguana/exchanges/LP_signatures.c b/iguana/exchanges/LP_signatures.c index fb393564a..19f8a9622 100644 --- a/iguana/exchanges/LP_signatures.c +++ b/iguana/exchanges/LP_signatures.c @@ -41,16 +41,16 @@ struct basilisk_request *LP_requestinit(struct basilisk_request *rp,bits256 srch cJSON *LP_quotejson(struct LP_quoteinfo *qp) { - double price; char etomic[64]; cJSON *retjson = cJSON_CreateObject(); + double price; char etomic[64],activesymbol[65]; cJSON *retjson = cJSON_CreateObject(); if ( jobj(retjson,"gui") == 0 ) jaddstr(retjson,"gui",qp->gui[0] != 0 ? qp->gui : LP_gui); jadd64bits(retjson,"aliceid",qp->aliceid); jaddnum(retjson,"tradeid",qp->tradeid); jaddstr(retjson,"base",qp->srccoin); - if ( LP_etomicsymbol(etomic,qp->srccoin) != 0 ) + if ( LP_etomicsymbol(activesymbol,etomic,qp->srccoin) != 0 ) jaddstr(retjson,"esrc",etomic); jaddstr(retjson,"rel",qp->destcoin); - if ( LP_etomicsymbol(etomic,qp->destcoin) != 0 ) + if ( LP_etomicsymbol(activesymbol,etomic,qp->destcoin) != 0 ) jaddstr(retjson,"edest",etomic); if ( qp->coinaddr[0] != 0 ) jaddstr(retjson,"address",qp->coinaddr); @@ -108,11 +108,11 @@ cJSON *LP_quotejson(struct LP_quoteinfo *qp) int32_t LP_quoteparse(struct LP_quoteinfo *qp,cJSON *argjson) { - uint32_t rid,qid; char etomic[64],*etomicstr; + uint32_t rid,qid; char etomic[64],activesymbol[65],*etomicstr; memset(qp,0,sizeof(*qp)); safecopy(qp->gui,LP_gui,sizeof(qp->gui)); safecopy(qp->srccoin,jstr(argjson,"base"),sizeof(qp->srccoin)); - if ( LP_etomicsymbol(etomic,qp->srccoin) != 0 ) + if ( LP_etomicsymbol(activesymbol,etomic,qp->srccoin) != 0 ) { if ( (etomicstr= jstr(argjson,"esrc")) == 0 || strcmp(etomicstr,etomic) != 0 ) { @@ -122,7 +122,7 @@ int32_t LP_quoteparse(struct LP_quoteinfo *qp,cJSON *argjson) } safecopy(qp->coinaddr,jstr(argjson,"address"),sizeof(qp->coinaddr)); safecopy(qp->destcoin,jstr(argjson,"rel"),sizeof(qp->destcoin)); - if ( LP_etomicsymbol(etomic,qp->destcoin) != 0 ) + if ( LP_etomicsymbol(activesymbol,etomic,qp->destcoin) != 0 ) { if ( (etomicstr= jstr(argjson,"edest")) == 0 || strcmp(etomicstr,etomic) != 0 ) { From 06467c93374eaa4b559b8f8a9c94cbb72f2034c3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 6 Feb 2018 17:38:58 +0200 Subject: [PATCH 025/197] Test --- iguana/exchanges/LP_swap.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index 68341c001..30f2ce5b8 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -570,7 +570,9 @@ struct basilisk_rawtx *LP_swapdata_rawtx(struct basilisk_swap *swap,uint8_t *dat int32_t LP_rawtx_spendscript(struct basilisk_swap *swap,int32_t height,struct basilisk_rawtx *rawtx,int32_t v,uint8_t *recvbuf,int32_t recvlen,int32_t suppress_pubkeys) { - bits256 otherhash,myhash,txid; int64_t txfee,val; int32_t i,offset=0,datalen=0,retval=-1,hexlen,n; uint8_t *data; cJSON *txobj,*skey,*vouts,*vout; char *hexstr,redeemaddr[64],checkaddr[64]; uint32_t quoteid,msgbits; struct iguana_info *coin; + bits256 otherhash,myhash,txid; int64_t txfee,val; int32_t i,offset=0,datalen=0,retval=-1,hexlen,n; uint8_t *data; cJSON *txobj,*skey,*vouts,*vout; char *hexstr,bobstr[65],alicestr[65],redeemaddr[64],checkaddr[64]; uint32_t quoteid,msgbits; struct iguana_info *coin; + LP_etomicsymbol(bobstr,swap->I.bobtomic,swap->I.bobstr); + LP_etomicsymbol(alicestr,swap->I.alicetomic,swap->I.alicestr); if ( (coin= LP_coinfind(rawtx->symbol)) == 0 ) { printf("LP_rawtx_spendscript couldnt find coin.(%s)\n",rawtx->symbol); @@ -769,9 +771,11 @@ int32_t LP_swapwait(struct basilisk_swap *swap,uint32_t requestid,uint32_t quote void LP_bobloop(void *_swap) { - uint8_t *data; int32_t maxlen,m,n; uint32_t expiration; struct basilisk_swap *swap = _swap; + uint8_t *data; char bobstr[65],alicestr[65]; int32_t maxlen,m,n; uint32_t expiration; struct basilisk_swap *swap = _swap; G.LP_pendingswaps++; printf("start swap iambob\n"); + LP_etomicsymbol(bobstr,swap->I.bobtomic,swap->I.bobstr); + LP_etomicsymbol(alicestr,swap->I.alicetomic,swap->I.alicestr); maxlen = 1024*1024 + sizeof(*swap); data = malloc(maxlen); expiration = (uint32_t)time(NULL) + LP_SWAPSTEP_TIMEOUT; @@ -838,8 +842,10 @@ void LP_bobloop(void *_swap) void LP_aliceloop(void *_swap) { - uint8_t *data; int32_t maxlen,n,m; uint32_t expiration; struct basilisk_swap *swap = _swap; + uint8_t *data; char bobstr[65],alicestr[65]; int32_t maxlen,n,m; uint32_t expiration; struct basilisk_swap *swap = _swap; G.LP_pendingswaps++; + LP_etomicsymbol(bobstr,swap->I.bobtomic,swap->I.bobstr); + LP_etomicsymbol(alicestr,swap->I.alicetomic,swap->I.alicestr); maxlen = 1024*1024 + sizeof(*swap); data = malloc(maxlen); expiration = (uint32_t)time(NULL) + LP_SWAPSTEP_TIMEOUT; From c956adc199e6a1dc9f9353f3b482e49e44eed116 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 6 Feb 2018 17:41:53 +0200 Subject: [PATCH 026/197] Test --- iguana/exchanges/LP_peers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_peers.c b/iguana/exchanges/LP_peers.c index ced058f37..68c13392e 100644 --- a/iguana/exchanges/LP_peers.c +++ b/iguana/exchanges/LP_peers.c @@ -113,7 +113,7 @@ void LP_peer_pairsock(bits256 pubkey) struct LP_peerinfo *LP_addpeer(struct LP_peerinfo *mypeer,int32_t mypubsock,char *ipaddr,uint16_t port,uint16_t pushport,uint16_t subport,int32_t isLP,uint32_t sessionid,uint16_t netid) { - uint32_t ipbits; int32_t valid,pushsock,subsock,timeout; char checkip[64],pushaddr[64],subaddr[64]; struct LP_peerinfo *peer = 0; + uint32_t ipbits; int32_t valid,pushsock,subsock,timeout; char checkip[64],pushaddr[128],subaddr[128]; struct LP_peerinfo *peer = 0; #ifdef LP_STRICTPEERS if ( strncmp("5.9.253",ipaddr,strlen("5.9.253")) != 0 ) return(0); From aeb1dd800a065cb2299ce14052b1afad5af43f2f Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 6 Feb 2018 17:43:46 +0200 Subject: [PATCH 027/197] Test --- iguana/exchanges/mm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/mm.c b/iguana/exchanges/mm.c index 2505f6f28..5544523f1 100644 --- a/iguana/exchanges/mm.c +++ b/iguana/exchanges/mm.c @@ -125,7 +125,7 @@ void ETH_test() .bobHash = "0xd66ca5295806fb95ead3f2be1d193a206a376371" }; ethSignedTx = bobSendsEthDeposit(input, txData); - printf("%s\n", ethSignedTx); + printf("ETH_test (%s)\n", ethSignedTx); free(ethSignedTx); } From 1c28a2bc8fa4c5db3c1cbc7be17e2437c57c1675 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 6 Feb 2018 18:39:58 +0200 Subject: [PATCH 028/197] Init atomic coins --- README.md | 1 + iguana/exchanges/LP_commands.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 513f9af49..291e5f720 100755 --- a/README.md +++ b/README.md @@ -257,6 +257,7 @@ Execute the OSX deploy script: The iguana binary and its linked libraries are in ```$HOME/tmp/iguana```. # Cmake build of marketmaker with linked etomic lib for ETH/ERC20 atomic swaps: +0. `make sure g++-7 ln to /usr/bin/g++` 1. `cd ~/SuperNET` 2. `git checkout etomic` 3. `git submodule add https://github.com/artemii235/cpp-ethereum` diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index 6f79b5c9d..09fe4ca7d 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -428,7 +428,7 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\ //* if ( (ptr= LP_coinsearch(coin)) != 0 ) { - if ( ptr->userpass[0] == 0 ) + if ( ptr->userpass[0] == 0 && ptr->etomic[0] == 0 ) { cJSON *retjson = cJSON_CreateObject(); jaddstr(retjson,"error",LP_DONTCHANGE_ERRMSG0); @@ -439,7 +439,7 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\ { ptr->inactive = 0; cJSON *array; int32_t notarized; - if ( LP_getheight(¬arized,ptr) <= 0 ) + if ( ptr->etomic[0] == 0 && LP_getheight(¬arized,ptr) <= 0 ) { ptr->inactive = (uint32_t)time(NULL); return(clonestr("{\"error\":\"coin cant be activated till synced\"}")); From d28159d94b29bc1769f1dbb165004a623adf4264 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 6 Feb 2018 18:49:36 +0200 Subject: [PATCH 029/197] Atomic build scripts --- etomic_build/client | 5 +++++ etomic_build/coins | 3 +++ etomic_build/enable | 4 ++++ etomic_build/orderbook | 3 +++ etomic_build/passphrase | 1 + etomic_build/run | 4 ++++ etomic_build/setpassphrase | 4 ++++ etomic_build/stop | 3 +++ etomic_build/userpass | 2 ++ 9 files changed, 29 insertions(+) create mode 100755 etomic_build/client create mode 100755 etomic_build/coins create mode 100755 etomic_build/enable create mode 100755 etomic_build/orderbook create mode 100644 etomic_build/passphrase create mode 100755 etomic_build/run create mode 100755 etomic_build/setpassphrase create mode 100755 etomic_build/stop create mode 100644 etomic_build/userpass diff --git a/etomic_build/client b/etomic_build/client new file mode 100755 index 000000000..fb4f0c935 --- /dev/null +++ b/etomic_build/client @@ -0,0 +1,5 @@ +#!/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/coins b/etomic_build/coins new file mode 100755 index 000000000..988b79784 --- /dev/null +++ b/etomic_build/coins @@ -0,0 +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}]" +#, {\"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/enable b/etomic_build/enable new file mode 100755 index 000000000..c51c0810d --- /dev/null +++ b/etomic_build/enable @@ -0,0 +1,4 @@ +#!/bin/bash +source userpass +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"ETH\"}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"KMD\"}" diff --git a/etomic_build/orderbook b/etomic_build/orderbook new file mode 100755 index 000000000..dba91c284 --- /dev/null +++ b/etomic_build/orderbook @@ -0,0 +1,3 @@ +#!/bin/bash +source userpass +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"orderbook\",\"base\":\"ETH\",\"rel\":\"KMD\"}" diff --git a/etomic_build/passphrase b/etomic_build/passphrase new file mode 100644 index 000000000..eb00095d6 --- /dev/null +++ b/etomic_build/passphrase @@ -0,0 +1 @@ +export passphrase="" diff --git a/etomic_build/run b/etomic_build/run new file mode 100755 index 000000000..346795148 --- /dev/null +++ b/etomic_build/run @@ -0,0 +1,4 @@ +#!/bin/bash +source passphrase +source coins + $1 iguana/exchanges/marketmaker "{\"netid\":9999,\"gui\":\"nogui\", \"profitmargin\":0.01, \"userhome\":\"/${HOME#"/"}\", \"passphrase\":\"$passphrase\", \"coins\":$coins}" & diff --git a/etomic_build/setpassphrase b/etomic_build/setpassphrase new file mode 100755 index 000000000..b3df81427 --- /dev/null +++ b/etomic_build/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/stop b/etomic_build/stop new file mode 100755 index 000000000..d13a70243 --- /dev/null +++ b/etomic_build/stop @@ -0,0 +1,3 @@ +#!/bin/bash +source userpass +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"stop\"}" diff --git a/etomic_build/userpass b/etomic_build/userpass new file mode 100644 index 000000000..d097e0445 --- /dev/null +++ b/etomic_build/userpass @@ -0,0 +1,2 @@ +#export userpass="" +export userpass="c3d8c2a364b7d18c1f9d7321d017b92e9f9c791e4f5c741214fefdea8a071256" From 0c240fed4e3c19dbaea28ea4bf99624577189c65 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 6 Feb 2018 19:09:38 +0200 Subject: [PATCH 030/197] price --- etomic_build/autoprice | 3 +++ etomic_build/buy | 3 +++ 2 files changed, 6 insertions(+) create mode 100755 etomic_build/autoprice create mode 100755 etomic_build/buy diff --git a/etomic_build/autoprice b/etomic_build/autoprice new file mode 100755 index 000000000..4ef086a75 --- /dev/null +++ b/etomic_build/autoprice @@ -0,0 +1,3 @@ +#!/bin/bash +source userpass +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"ETH\",\"rel\":\"KMD\",\"margin\":0.05,\"refbase\":\"ethereum\",\"refrel\":\"coinmarketcap\"}" diff --git a/etomic_build/buy b/etomic_build/buy new file mode 100755 index 000000000..379d03813 --- /dev/null +++ b/etomic_build/buy @@ -0,0 +1,3 @@ +#!/bin/bash +source userpass +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"buy\",\"base\":\"ETH\",\"rel\":\"KMD\",\"relvolume\":1,\"price\":300}" From f3baa496a267871918eefe94cd24fd890a08ca66 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 6 Feb 2018 19:13:09 +0200 Subject: [PATCH 031/197] Test --- iguana/exchanges/LP_mmjson.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_mmjson.c b/iguana/exchanges/LP_mmjson.c index 249988117..a7f8860f6 100644 --- a/iguana/exchanges/LP_mmjson.c +++ b/iguana/exchanges/LP_mmjson.c @@ -46,15 +46,15 @@ #define MMJSON_ARRAY8 228 #define MMJSON_ARRAY16 227 #define MMJSON_ARRAY32 226 -#define MMJSON_BOUNDARY 98 int32_t MM_numfields; -char *MM_fields[256] = +char *MM_fields[] = { "timestamp", "getdPoW", "dPoW", "aliceid", "src", "base", "basevol", "dest", "rel", "relvol", "price", "requestid", "quoteid", "finished", "expired", "bobdeposit", "alicepayment", "bobpayment", "paymentspent", "Apaymentspent", "depositspent", "ind", "method", "swapstatus", "method2", "gettradestatus", "coin", "rmd160", "pub", "pubsecp", "sig", "session", "notify", "pubkey", "price64", "credits", "utxocoin", "n", "bal", "min", "max", "postprice", "notarized", "notarizedhash", "notarizationtxid", "wantnotify", "isLP", "gui", "nogui", "tradeid", "address", "txid", "vout", "srchash", "txfee", "quotetime", "satoshis", "desthash", "txid2", "vout2", "destaddr", "desttxid", "destvout", "feetxid", "feevout", "desttxfee", "destsatoshis", "pending", "reserved", "broadcast", "ismine", "simplegui", "request", "proof", "connect", "expiration", "iambob", "Bgui", "", "Agui", "bob", "srcamount", "bobtxfee", "alice", "destamount", "alicetxfee", "sentflags", "values", "result", "success", "status", "finishtime", "tradestatus", "pair", "connected", "warning", "critical", "endcritical", "etomic", "esrc", "edest", "cli" }; +#define MMJSON_BOUNDARY ((int32_t)(sizeof(MM_fields)/sizeof(*MM_fields))) -char *MM_coins[256] = +char *MM_coins[] = { "KMD", "BTC", "CRC", "VOT", "INN", "MOON", "CRW", "EFL", "GBX", "BCO", "BLK", "BTG", "BCH", "ABY", "STAK", "XZC", "QTUM", "PURA", "DSR", "MNZ", "BTCZ", "MAGA", "BSD", "IOP", "BLOCK", "CHIPS", "888", "ARG", "GLT", "ZER", "HODLC", "UIS", "HUC", "PIVX", "BDL", "ARC", "ZCL", "VIA", "ERC", "FAIR", "FLO", "SXC", "CREA", "TRC", "BTA", "SMC", "NMC", "NAV", "EMC2", "SYS", "I0C", "DASH", "STRAT", "MUE", "MONA", "XMY", "MAC", "BTX", "XRE", "LBC", "SIB", "VTC", "REVS", "JUMBLR", "DOGE", "HUSH", "ZEC", "DGB", "ZET", "GAME", "LTC", "SUPERNET", "WLC", "PANGEA", "DEX", "BET", "CRYPTO", "HODL", "MSHARK", "BOTS", "MGW", "COQUI", "KV", "CEAL", "MESH", }; From f1518ac7514a73895dd52df24623813f453d7f03 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 6 Feb 2018 19:53:08 +0200 Subject: [PATCH 032/197] Test --- iguana/exchanges/LP_ordermatch.c | 1 + 1 file changed, 1 insertion(+) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index 36bebb779..447a1f43f 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -1205,6 +1205,7 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson, printf("aliceid.%llu is expired by %d\n",(long long)Q.aliceid,(uint32_t)time(NULL) - (Q.timestamp + LP_AUTOTRADE_TIMEOUT*20)); return(1); } + printf("%s\n",jprint(argjson,0)); printf("%-4d (%-10u %10u) %12s id.%-20llu %5s/%-5s %12.8f -> %12.8f (%11.8f) | RT.%d %d n%d\n",(uint32_t)time(NULL) % 3600,Q.R.requestid,Q.R.quoteid,method,(long long)Q.aliceid,Q.srccoin,Q.destcoin,dstr(Q.satoshis),dstr(Q.destsatoshis),(double)Q.destsatoshis/Q.satoshis,LP_RTcount,LP_swapscount,G.netid); retval = 1; aliceid = j64bits(argjson,"aliceid"); From f08b7700ed1f6ec7b8804fb52d12140e5e2d6abd Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 6 Feb 2018 20:43:31 +0200 Subject: [PATCH 033/197] Test --- etomic_build/run | 1 + iguana/exchanges/LP_etomic.c | 43 +++++++++++++++++++++++++++++++++++ iguana/exchanges/LP_privkey.c | 12 ++++++++++ 3 files changed, 56 insertions(+) diff --git a/etomic_build/run b/etomic_build/run index 346795148..b757bb993 100755 --- a/etomic_build/run +++ b/etomic_build/run @@ -1,4 +1,5 @@ #!/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/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index 56d8dbbe0..fbdc99fb8 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -58,3 +58,46 @@ char *LP_etomicalice_start(struct basilisk_swap *swap) } return(0); } + +int32_t LP_etomic_priv2addr(char *coinaddr,bits256 privkey) +{ + char str[65],*addrstr; + bits256_str(str,privkey); + if ( (addrstr= privKey2Addr(str)) != 0 ) + { + strcpy(coinaddr,addrstr); + free(addrstr); + return(0); + } + return(-1); +} + +int32_t LP_etomic_priv2pub(uint8_t *pub33,bits256 privkey) +{ + char *pubstr,str[65]; int32_t retval = -1; + bits256_str(str,privkey); + if ( (pubstr= getPubKeyFromPriv(str)) != 0 ) + { + if ( strlen(pubstr) == 35 && pubstr[0] == '0' && pubstr[1] == 'x' ) + { + decode_hex(pub33,33,pubstr+2); + retval = 33; + } + free(pubstr); + } + return(retval); +} + +int32_t LP_etomic_pub2addr(char *coinaddr,uint8_t pub33[33]) +{ + char pubkeystr[72],*addrstr; + strcpy(pubkeystr,"0x"); + init_hexbytes_noT(pubkeystr+2,pub33,33); + if ( (addrstr= pubKey2Addr(pubkeystr+2)) != 0 ) + { + strcpy(coinaddr,addrstr); + free(addrstr); + return((int32_t)strlen(coinaddr)); + } + return(-1); +} diff --git a/iguana/exchanges/LP_privkey.c b/iguana/exchanges/LP_privkey.c index a2b9494a5..17cd22723 100644 --- a/iguana/exchanges/LP_privkey.c +++ b/iguana/exchanges/LP_privkey.c @@ -294,6 +294,18 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan RS_encode(G.LP_NXTaddr,nxtaddr); } bitcoin_priv2pub(ctx,coin->symbol,coin->pubkey33,coin->smartaddr,privkey,coin->taddr,coin->pubtype); + { + uint8_t check33[33]; char checkaddr[64]; + if ( LP_etomic_priv2pub(check33,privkey) > 0 ) + { + if ( memcmp(check33,coin->pubkey33) == 0 ) + { + printf("pubkey33 matches!\n"); + if ( LP_etomic_pub2addr(checkaddr,check33) > 0 ) + printf("addr is (%s)\n",checkaddr); + } else printf("pubkey 33 mismatch\n"); + } + } if ( coin->counter == 0 ) { coin->counter++; From a8541fc70756d886ab60d00bcff8ba0dd741112e Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 6 Feb 2018 20:44:31 +0200 Subject: [PATCH 034/197] Test --- iguana/exchanges/LP_privkey.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_privkey.c b/iguana/exchanges/LP_privkey.c index 17cd22723..f51024a60 100644 --- a/iguana/exchanges/LP_privkey.c +++ b/iguana/exchanges/LP_privkey.c @@ -298,7 +298,7 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan uint8_t check33[33]; char checkaddr[64]; if ( LP_etomic_priv2pub(check33,privkey) > 0 ) { - if ( memcmp(check33,coin->pubkey33) == 0 ) + if ( memcmp(check33,coin->pubkey33,33) == 0 ) { printf("pubkey33 matches!\n"); if ( LP_etomic_pub2addr(checkaddr,check33) > 0 ) From e4319f3f8683ef6d185f7e3a7daf6b69319c745c Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 6 Feb 2018 20:47:02 +0200 Subject: [PATCH 035/197] Test --- iguana/exchanges/LP_privkey.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_privkey.c b/iguana/exchanges/LP_privkey.c index f51024a60..0bf88e704 100644 --- a/iguana/exchanges/LP_privkey.c +++ b/iguana/exchanges/LP_privkey.c @@ -303,8 +303,9 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan printf("pubkey33 matches!\n"); if ( LP_etomic_pub2addr(checkaddr,check33) > 0 ) printf("addr is (%s)\n",checkaddr); + else printf("error getting addr\n"); } else printf("pubkey 33 mismatch\n"); - } + } else print("error creating pubkey\n"); } if ( coin->counter == 0 ) { From 686d6a0567e99dcf3d2d9af4102f628eb20dfb98 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 6 Feb 2018 20:47:24 +0200 Subject: [PATCH 036/197] Test --- iguana/exchanges/LP_privkey.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_privkey.c b/iguana/exchanges/LP_privkey.c index 0bf88e704..95d9eb079 100644 --- a/iguana/exchanges/LP_privkey.c +++ b/iguana/exchanges/LP_privkey.c @@ -305,7 +305,7 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan printf("addr is (%s)\n",checkaddr); else printf("error getting addr\n"); } else printf("pubkey 33 mismatch\n"); - } else print("error creating pubkey\n"); + } else printf("error creating pubkey\n"); } if ( coin->counter == 0 ) { From f0fc9378353101193ec945542bc041c94dff746d Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 6 Feb 2018 20:48:47 +0200 Subject: [PATCH 037/197] Test --- iguana/exchanges/LP_etomic.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index fbdc99fb8..5dc33a8b1 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -74,8 +74,9 @@ int32_t LP_etomic_priv2addr(char *coinaddr,bits256 privkey) int32_t LP_etomic_priv2pub(uint8_t *pub33,bits256 privkey) { - char *pubstr,str[65]; int32_t retval = -1; - bits256_str(str,privkey); + char *pubstr,str[72]; int32_t retval = -1; + strcpy(str,"0x"); + bits256_str(str+2,privkey); if ( (pubstr= getPubKeyFromPriv(str)) != 0 ) { if ( strlen(pubstr) == 35 && pubstr[0] == '0' && pubstr[1] == 'x' ) From d7c8daff1a2e1418a69674e1d38c9941d652e49f Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 6 Feb 2018 20:49:59 +0200 Subject: [PATCH 038/197] Test --- iguana/exchanges/LP_etomic.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index 5dc33a8b1..86e746edc 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -75,8 +75,7 @@ int32_t LP_etomic_priv2addr(char *coinaddr,bits256 privkey) int32_t LP_etomic_priv2pub(uint8_t *pub33,bits256 privkey) { char *pubstr,str[72]; int32_t retval = -1; - strcpy(str,"0x"); - bits256_str(str+2,privkey); + bits256_str(str,privkey); if ( (pubstr= getPubKeyFromPriv(str)) != 0 ) { if ( strlen(pubstr) == 35 && pubstr[0] == '0' && pubstr[1] == 'x' ) From 0645713a730383c7f15dc2a2e77b73f6b5105f1f Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 03:09:06 +0200 Subject: [PATCH 039/197] fundLP --- iguana/exchanges/coins | 2 +- iguana/exchanges/fundLP | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100755 iguana/exchanges/fundLP diff --git a/iguana/exchanges/coins b/iguana/exchanges/coins index 988b79784..eb8939cc9 100644 --- a/iguana/exchanges/coins +++ b/iguana/exchanges/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\":\"BAY\",\"name\":\"bitbay\",\"isPoS\":1,\"rpcport\":19915,\"pubtype\":25,\"p2shtype\":85,\"wiftype\":153,\"txfee\":10000}, {\"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}]" #, {\"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/fundLP b/iguana/exchanges/fundLP new file mode 100755 index 000000000..d1cbd66c1 --- /dev/null +++ b/iguana/exchanges/fundLP @@ -0,0 +1,2 @@ +fiat/$1 sendmany \"\" "{\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\":$2, \"RQzkkncY8ehpRg8M4kvKmDMcbFxcJvohgk\":$2, \"RXUF132uyPVTVUdLn16zCgvYoFXya3pyVb\":$2, \"RNyBS6ryQtPPQnJhavKn9o94U2RNExLZon\":$2, \"RPMpwKpzWyg5KoMcsuy3mZucUWNdcP2ndD\":$2, \"RVPcbafNSi6uMaKDyss9epGpHCHbbzUFMd\":$2, \"RAzheh3L7QtBL7oNKByVa43CtgALht6bbT\":$2, \"RMdjuxKBhyr87yhKp6BLUg2p9673NMcPAu\":$2, \"RUPX5RWQL1qurMLmF4fFB4JAgRfwcNww4b\":$2, \"RQLn2QYwXDemFN3DNigU5qv3wUrA3WqquA\":$2,\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\":$2, \"RQzkkncY8ehpRg8M4kvKmDMcbFxcJvohgk\":$2, \"RXUF132uyPVTVUdLn16zCgvYoFXya3pyVb\":$2, \"RNyBS6ryQtPPQnJhavKn9o94U2RNExLZon\":$2, \"RPMpwKpzWyg5KoMcsuy3mZucUWNdcP2ndD\":$2, \"RVPcbafNSi6uMaKDyss9epGpHCHbbzUFMd\":$2, \"RAzheh3L7QtBL7oNKByVa43CtgALht6bbT\":$2, \"RMdjuxKBhyr87yhKp6BLUg2p9673NMcPAu\":$2, \"RUPX5RWQL1qurMLmF4fFB4JAgRfwcNww4b\":$2, \"RQLn2QYwXDemFN3DNigU5qv3wUrA3WqquA\":$2,\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\":$2, \"RQzkkncY8ehpRg8M4kvKmDMcbFxcJvohgk\":$2, \"RXUF132uyPVTVUdLn16zCgvYoFXya3pyVb\":$2, \"RNyBS6ryQtPPQnJhavKn9o94U2RNExLZon\":$2, \"RPMpwKpzWyg5KoMcsuy3mZucUWNdcP2ndD\":$2, \"RVPcbafNSi6uMaKDyss9epGpHCHbbzUFMd\":$2, \"RAzheh3L7QtBL7oNKByVa43CtgALht6bbT\":$2, \"RMdjuxKBhyr87yhKp6BLUg2p9673NMcPAu\":$2, \"RUPX5RWQL1qurMLmF4fFB4JAgRfwcNww4b\":$2, \"RQLn2QYwXDemFN3DNigU5qv3wUrA3WqquA\":$2,\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\":$2, \"RQzkkncY8ehpRg8M4kvKmDMcbFxcJvohgk\":$2, \"RXUF132uyPVTVUdLn16zCgvYoFXya3pyVb\":$2, \"RNyBS6ryQtPPQnJhavKn9o94U2RNExLZon\":$2, \"RPMpwKpzWyg5KoMcsuy3mZucUWNdcP2ndD\":$2, \"RVPcbafNSi6uMaKDyss9epGpHCHbbzUFMd\":$2, \"RAzheh3L7QtBL7oNKByVa43CtgALht6bbT\":$2, \"RMdjuxKBhyr87yhKp6BLUg2p9673NMcPAu\":$2, \"RUPX5RWQL1qurMLmF4fFB4JAgRfwcNww4b\":$2, \"RQLn2QYwXDemFN3DNigU5qv3wUrA3WqquA\":$2,\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\":$2, \"RQzkkncY8ehpRg8M4kvKmDMcbFxcJvohgk\":$2, \"RXUF132uyPVTVUdLn16zCgvYoFXya3pyVb\":$2, \"RNyBS6ryQtPPQnJhavKn9o94U2RNExLZon\":$2, \"RPMpwKpzWyg5KoMcsuy3mZucUWNdcP2ndD\":$2, \"RVPcbafNSi6uMaKDyss9epGpHCHbbzUFMd\":$2, \"RAzheh3L7QtBL7oNKByVa43CtgALht6bbT\":$2, \"RMdjuxKBhyr87yhKp6BLUg2p9673NMcPAu\":$2, \"RUPX5RWQL1qurMLmF4fFB4JAgRfwcNww4b\":$2, \"RQLn2QYwXDemFN3DNigU5qv3wUrA3WqquA\":$2,\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\":$2, \"RQzkkncY8ehpRg8M4kvKmDMcbFxcJvohgk\":$2, \"RXUF132uyPVTVUdLn16zCgvYoFXya3pyVb\":$2, \"RNyBS6ryQtPPQnJhavKn9o94U2RNExLZon\":$2, \"RPMpwKpzWyg5KoMcsuy3mZucUWNdcP2ndD\":$2, \"RVPcbafNSi6uMaKDyss9epGpHCHbbzUFMd\":$2, \"RAzheh3L7QtBL7oNKByVa43CtgALht6bbT\":$2, \"RMdjuxKBhyr87yhKp6BLUg2p9673NMcPAu\":$2, \"RUPX5RWQL1qurMLmF4fFB4JAgRfwcNww4b\":$2, \"RQLn2QYwXDemFN3DNigU5qv3wUrA3WqquA\":$2,\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\":$2, \"RQzkkncY8ehpRg8M4kvKmDMcbFxcJvohgk\":$2, \"RXUF132uyPVTVUdLn16zCgvYoFXya3pyVb\":$2, \"RNyBS6ryQtPPQnJhavKn9o94U2RNExLZon\":$2, \"RPMpwKpzWyg5KoMcsuy3mZucUWNdcP2ndD\":$2, \"RVPcbafNSi6uMaKDyss9epGpHCHbbzUFMd\":$2, \"RAzheh3L7QtBL7oNKByVa43CtgALht6bbT\":$2, \"RMdjuxKBhyr87yhKp6BLUg2p9673NMcPAu\":$2, \"RUPX5RWQL1qurMLmF4fFB4JAgRfwcNww4b\":$2, \"RQLn2QYwXDemFN3DNigU5qv3wUrA3WqquA\":$2,\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\":$2, \"RQzkkncY8ehpRg8M4kvKmDMcbFxcJvohgk\":$2, \"RXUF132uyPVTVUdLn16zCgvYoFXya3pyVb\":$2, \"RNyBS6ryQtPPQnJhavKn9o94U2RNExLZon\":$2, \"RPMpwKpzWyg5KoMcsuy3mZucUWNdcP2ndD\":$2, \"RVPcbafNSi6uMaKDyss9epGpHCHbbzUFMd\":$2, \"RAzheh3L7QtBL7oNKByVa43CtgALht6bbT\":$2, \"RMdjuxKBhyr87yhKp6BLUg2p9673NMcPAu\":$2, \"RUPX5RWQL1qurMLmF4fFB4JAgRfwcNww4b\":$2, \"RQLn2QYwXDemFN3DNigU5qv3wUrA3WqquA\":$2,\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\":$2, \"RQzkkncY8ehpRg8M4kvKmDMcbFxcJvohgk\":$2, \"RXUF132uyPVTVUdLn16zCgvYoFXya3pyVb\":$2, \"RNyBS6ryQtPPQnJhavKn9o94U2RNExLZon\":$2, \"RPMpwKpzWyg5KoMcsuy3mZucUWNdcP2ndD\":$2, \"RVPcbafNSi6uMaKDyss9epGpHCHbbzUFMd\":$2, \"RAzheh3L7QtBL7oNKByVa43CtgALht6bbT\":$2, \"RMdjuxKBhyr87yhKp6BLUg2p9673NMcPAu\":$2, \"RUPX5RWQL1qurMLmF4fFB4JAgRfwcNww4b\":$2, \"RQLn2QYwXDemFN3DNigU5qv3wUrA3WqquA\":$2,\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\":$2, \"RQzkkncY8ehpRg8M4kvKmDMcbFxcJvohgk\":$2, \"RXUF132uyPVTVUdLn16zCgvYoFXya3pyVb\":$2, \"RNyBS6ryQtPPQnJhavKn9o94U2RNExLZon\":$2, \"RPMpwKpzWyg5KoMcsuy3mZucUWNdcP2ndD\":$2, \"RVPcbafNSi6uMaKDyss9epGpHCHbbzUFMd\":$2, \"RAzheh3L7QtBL7oNKByVa43CtgALht6bbT\":$2, \"RMdjuxKBhyr87yhKp6BLUg2p9673NMcPAu\":$2, \"RUPX5RWQL1qurMLmF4fFB4JAgRfwcNww4b\":$2, \"RQLn2QYwXDemFN3DNigU5qv3wUrA3WqquA\":$2,\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\":$2, \"RQzkkncY8ehpRg8M4kvKmDMcbFxcJvohgk\":$2, \"RXUF132uyPVTVUdLn16zCgvYoFXya3pyVb\":$2, \"RNyBS6ryQtPPQnJhavKn9o94U2RNExLZon\":$2, \"RPMpwKpzWyg5KoMcsuy3mZucUWNdcP2ndD\":$2, \"RVPcbafNSi6uMaKDyss9epGpHCHbbzUFMd\":$2, \"RAzheh3L7QtBL7oNKByVa43CtgALht6bbT\":$2, \"RMdjuxKBhyr87yhKp6BLUg2p9673NMcPAu\":$2, \"RUPX5RWQL1qurMLmF4fFB4JAgRfwcNww4b\":$2, \"RQLn2QYwXDemFN3DNigU5qv3wUrA3WqquA\":$2}" 0 + From 3cb4df71cbf41423841b6d75d6e9899127a05a11 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 03:17:16 +0200 Subject: [PATCH 040/197] fundLP --- iguana/exchanges/fundLP | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/fundLP b/iguana/exchanges/fundLP index d1cbd66c1..9dcf3eab8 100755 --- a/iguana/exchanges/fundLP +++ b/iguana/exchanges/fundLP @@ -1,2 +1,2 @@ -fiat/$1 sendmany \"\" "{\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\":$2, \"RQzkkncY8ehpRg8M4kvKmDMcbFxcJvohgk\":$2, \"RXUF132uyPVTVUdLn16zCgvYoFXya3pyVb\":$2, \"RNyBS6ryQtPPQnJhavKn9o94U2RNExLZon\":$2, \"RPMpwKpzWyg5KoMcsuy3mZucUWNdcP2ndD\":$2, \"RVPcbafNSi6uMaKDyss9epGpHCHbbzUFMd\":$2, \"RAzheh3L7QtBL7oNKByVa43CtgALht6bbT\":$2, \"RMdjuxKBhyr87yhKp6BLUg2p9673NMcPAu\":$2, \"RUPX5RWQL1qurMLmF4fFB4JAgRfwcNww4b\":$2, \"RQLn2QYwXDemFN3DNigU5qv3wUrA3WqquA\":$2,\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\":$2, \"RQzkkncY8ehpRg8M4kvKmDMcbFxcJvohgk\":$2, \"RXUF132uyPVTVUdLn16zCgvYoFXya3pyVb\":$2, \"RNyBS6ryQtPPQnJhavKn9o94U2RNExLZon\":$2, \"RPMpwKpzWyg5KoMcsuy3mZucUWNdcP2ndD\":$2, \"RVPcbafNSi6uMaKDyss9epGpHCHbbzUFMd\":$2, \"RAzheh3L7QtBL7oNKByVa43CtgALht6bbT\":$2, \"RMdjuxKBhyr87yhKp6BLUg2p9673NMcPAu\":$2, \"RUPX5RWQL1qurMLmF4fFB4JAgRfwcNww4b\":$2, \"RQLn2QYwXDemFN3DNigU5qv3wUrA3WqquA\":$2,\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\":$2, \"RQzkkncY8ehpRg8M4kvKmDMcbFxcJvohgk\":$2, \"RXUF132uyPVTVUdLn16zCgvYoFXya3pyVb\":$2, \"RNyBS6ryQtPPQnJhavKn9o94U2RNExLZon\":$2, \"RPMpwKpzWyg5KoMcsuy3mZucUWNdcP2ndD\":$2, \"RVPcbafNSi6uMaKDyss9epGpHCHbbzUFMd\":$2, \"RAzheh3L7QtBL7oNKByVa43CtgALht6bbT\":$2, \"RMdjuxKBhyr87yhKp6BLUg2p9673NMcPAu\":$2, \"RUPX5RWQL1qurMLmF4fFB4JAgRfwcNww4b\":$2, \"RQLn2QYwXDemFN3DNigU5qv3wUrA3WqquA\":$2,\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\":$2, \"RQzkkncY8ehpRg8M4kvKmDMcbFxcJvohgk\":$2, \"RXUF132uyPVTVUdLn16zCgvYoFXya3pyVb\":$2, \"RNyBS6ryQtPPQnJhavKn9o94U2RNExLZon\":$2, \"RPMpwKpzWyg5KoMcsuy3mZucUWNdcP2ndD\":$2, \"RVPcbafNSi6uMaKDyss9epGpHCHbbzUFMd\":$2, \"RAzheh3L7QtBL7oNKByVa43CtgALht6bbT\":$2, \"RMdjuxKBhyr87yhKp6BLUg2p9673NMcPAu\":$2, \"RUPX5RWQL1qurMLmF4fFB4JAgRfwcNww4b\":$2, \"RQLn2QYwXDemFN3DNigU5qv3wUrA3WqquA\":$2,\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\":$2, \"RQzkkncY8ehpRg8M4kvKmDMcbFxcJvohgk\":$2, \"RXUF132uyPVTVUdLn16zCgvYoFXya3pyVb\":$2, \"RNyBS6ryQtPPQnJhavKn9o94U2RNExLZon\":$2, \"RPMpwKpzWyg5KoMcsuy3mZucUWNdcP2ndD\":$2, \"RVPcbafNSi6uMaKDyss9epGpHCHbbzUFMd\":$2, \"RAzheh3L7QtBL7oNKByVa43CtgALht6bbT\":$2, \"RMdjuxKBhyr87yhKp6BLUg2p9673NMcPAu\":$2, \"RUPX5RWQL1qurMLmF4fFB4JAgRfwcNww4b\":$2, \"RQLn2QYwXDemFN3DNigU5qv3wUrA3WqquA\":$2,\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\":$2, \"RQzkkncY8ehpRg8M4kvKmDMcbFxcJvohgk\":$2, \"RXUF132uyPVTVUdLn16zCgvYoFXya3pyVb\":$2, \"RNyBS6ryQtPPQnJhavKn9o94U2RNExLZon\":$2, \"RPMpwKpzWyg5KoMcsuy3mZucUWNdcP2ndD\":$2, \"RVPcbafNSi6uMaKDyss9epGpHCHbbzUFMd\":$2, \"RAzheh3L7QtBL7oNKByVa43CtgALht6bbT\":$2, \"RMdjuxKBhyr87yhKp6BLUg2p9673NMcPAu\":$2, \"RUPX5RWQL1qurMLmF4fFB4JAgRfwcNww4b\":$2, \"RQLn2QYwXDemFN3DNigU5qv3wUrA3WqquA\":$2,\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\":$2, \"RQzkkncY8ehpRg8M4kvKmDMcbFxcJvohgk\":$2, \"RXUF132uyPVTVUdLn16zCgvYoFXya3pyVb\":$2, \"RNyBS6ryQtPPQnJhavKn9o94U2RNExLZon\":$2, \"RPMpwKpzWyg5KoMcsuy3mZucUWNdcP2ndD\":$2, \"RVPcbafNSi6uMaKDyss9epGpHCHbbzUFMd\":$2, \"RAzheh3L7QtBL7oNKByVa43CtgALht6bbT\":$2, \"RMdjuxKBhyr87yhKp6BLUg2p9673NMcPAu\":$2, \"RUPX5RWQL1qurMLmF4fFB4JAgRfwcNww4b\":$2, \"RQLn2QYwXDemFN3DNigU5qv3wUrA3WqquA\":$2,\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\":$2, \"RQzkkncY8ehpRg8M4kvKmDMcbFxcJvohgk\":$2, \"RXUF132uyPVTVUdLn16zCgvYoFXya3pyVb\":$2, \"RNyBS6ryQtPPQnJhavKn9o94U2RNExLZon\":$2, \"RPMpwKpzWyg5KoMcsuy3mZucUWNdcP2ndD\":$2, \"RVPcbafNSi6uMaKDyss9epGpHCHbbzUFMd\":$2, \"RAzheh3L7QtBL7oNKByVa43CtgALht6bbT\":$2, \"RMdjuxKBhyr87yhKp6BLUg2p9673NMcPAu\":$2, \"RUPX5RWQL1qurMLmF4fFB4JAgRfwcNww4b\":$2, \"RQLn2QYwXDemFN3DNigU5qv3wUrA3WqquA\":$2,\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\":$2, \"RQzkkncY8ehpRg8M4kvKmDMcbFxcJvohgk\":$2, \"RXUF132uyPVTVUdLn16zCgvYoFXya3pyVb\":$2, \"RNyBS6ryQtPPQnJhavKn9o94U2RNExLZon\":$2, \"RPMpwKpzWyg5KoMcsuy3mZucUWNdcP2ndD\":$2, \"RVPcbafNSi6uMaKDyss9epGpHCHbbzUFMd\":$2, \"RAzheh3L7QtBL7oNKByVa43CtgALht6bbT\":$2, \"RMdjuxKBhyr87yhKp6BLUg2p9673NMcPAu\":$2, \"RUPX5RWQL1qurMLmF4fFB4JAgRfwcNww4b\":$2, \"RQLn2QYwXDemFN3DNigU5qv3wUrA3WqquA\":$2,\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\":$2, \"RQzkkncY8ehpRg8M4kvKmDMcbFxcJvohgk\":$2, \"RXUF132uyPVTVUdLn16zCgvYoFXya3pyVb\":$2, \"RNyBS6ryQtPPQnJhavKn9o94U2RNExLZon\":$2, \"RPMpwKpzWyg5KoMcsuy3mZucUWNdcP2ndD\":$2, \"RVPcbafNSi6uMaKDyss9epGpHCHbbzUFMd\":$2, \"RAzheh3L7QtBL7oNKByVa43CtgALht6bbT\":$2, \"RMdjuxKBhyr87yhKp6BLUg2p9673NMcPAu\":$2, \"RUPX5RWQL1qurMLmF4fFB4JAgRfwcNww4b\":$2, \"RQLn2QYwXDemFN3DNigU5qv3wUrA3WqquA\":$2,\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\":$2, \"RQzkkncY8ehpRg8M4kvKmDMcbFxcJvohgk\":$2, \"RXUF132uyPVTVUdLn16zCgvYoFXya3pyVb\":$2, \"RNyBS6ryQtPPQnJhavKn9o94U2RNExLZon\":$2, \"RPMpwKpzWyg5KoMcsuy3mZucUWNdcP2ndD\":$2, \"RVPcbafNSi6uMaKDyss9epGpHCHbbzUFMd\":$2, \"RAzheh3L7QtBL7oNKByVa43CtgALht6bbT\":$2, \"RMdjuxKBhyr87yhKp6BLUg2p9673NMcPAu\":$2, \"RUPX5RWQL1qurMLmF4fFB4JAgRfwcNww4b\":$2, \"RQLn2QYwXDemFN3DNigU5qv3wUrA3WqquA\":$2}" 0 +fiat/$1 sendmany \"\" "{\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\":$2,\"RQzkkncY8ehpRg8M4kvKmDMcbFxcJvohgk\":$2,\"RXUF132uyPVTVUdLn16zCgvYoFXya3pyVb\":$2,\"RNyBS6ryQtPPQnJhavKn9o94U2RNExLZon\":$2,\"RPMpwKpzWyg5KoMcsuy3mZucUWNdcP2ndD\":$2,\"RVPcbafNSi6uMaKDyss9epGpHCHbbzUFMd\":$2,\"RAzheh3L7QtBL7oNKByVa43CtgALht6bbT\":$2,\"RMdjuxKBhyr87yhKp6BLUg2p9673NMcPAu\":$2,\"RUPX5RWQL1qurMLmF4fFB4JAgRfwcNww4b\":$2,\"RQLn2QYwXDemFN3DNigU5qv3wUrA3WqquA\":$2,\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\":$2,\"RQzkkncY8ehpRg8M4kvKmDMcbFxcJvohgk\":$2,\"RXUF132uyPVTVUdLn16zCgvYoFXya3pyVb\":$2,\"RNyBS6ryQtPPQnJhavKn9o94U2RNExLZon\":$2,\"RPMpwKpzWyg5KoMcsuy3mZucUWNdcP2ndD\":$2,\"RVPcbafNSi6uMaKDyss9epGpHCHbbzUFMd\":$2,\"RAzheh3L7QtBL7oNKByVa43CtgALht6bbT\":$2,\"RMdjuxKBhyr87yhKp6BLUg2p9673NMcPAu\":$2,\"RUPX5RWQL1qurMLmF4fFB4JAgRfwcNww4b\":$2,\"RQLn2QYwXDemFN3DNigU5qv3wUrA3WqquA\":$2,\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\":$2,\"RQzkkncY8ehpRg8M4kvKmDMcbFxcJvohgk\":$2,\"RXUF132uyPVTVUdLn16zCgvYoFXya3pyVb\":$2,\"RNyBS6ryQtPPQnJhavKn9o94U2RNExLZon\":$2,\"RPMpwKpzWyg5KoMcsuy3mZucUWNdcP2ndD\":$2,\"RVPcbafNSi6uMaKDyss9epGpHCHbbzUFMd\":$2,\"RAzheh3L7QtBL7oNKByVa43CtgALht6bbT\":$2,\"RMdjuxKBhyr87yhKp6BLUg2p9673NMcPAu\":$2,\"RUPX5RWQL1qurMLmF4fFB4JAgRfwcNww4b\":$2,\"RQLn2QYwXDemFN3DNigU5qv3wUrA3WqquA\":$2,\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\":$2,\"RQzkkncY8ehpRg8M4kvKmDMcbFxcJvohgk\":$2,\"RXUF132uyPVTVUdLn16zCgvYoFXya3pyVb\":$2,\"RNyBS6ryQtPPQnJhavKn9o94U2RNExLZon\":$2,\"RPMpwKpzWyg5KoMcsuy3mZucUWNdcP2ndD\":$2,\"RVPcbafNSi6uMaKDyss9epGpHCHbbzUFMd\":$2,\"RAzheh3L7QtBL7oNKByVa43CtgALht6bbT\":$2,\"RMdjuxKBhyr87yhKp6BLUg2p9673NMcPAu\":$2,\"RUPX5RWQL1qurMLmF4fFB4JAgRfwcNww4b\":$2,\"RQLn2QYwXDemFN3DNigU5qv3wUrA3WqquA\":$2,\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\":$2,\"RQzkkncY8ehpRg8M4kvKmDMcbFxcJvohgk\":$2,\"RXUF132uyPVTVUdLn16zCgvYoFXya3pyVb\":$2,\"RNyBS6ryQtPPQnJhavKn9o94U2RNExLZon\":$2,\"RPMpwKpzWyg5KoMcsuy3mZucUWNdcP2ndD\":$2,\"RVPcbafNSi6uMaKDyss9epGpHCHbbzUFMd\":$2,\"RAzheh3L7QtBL7oNKByVa43CtgALht6bbT\":$2,\"RMdjuxKBhyr87yhKp6BLUg2p9673NMcPAu\":$2,\"RUPX5RWQL1qurMLmF4fFB4JAgRfwcNww4b\":$2,\"RQLn2QYwXDemFN3DNigU5qv3wUrA3WqquA\":$2,\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\":$2,\"RQzkkncY8ehpRg8M4kvKmDMcbFxcJvohgk\":$2,\"RXUF132uyPVTVUdLn16zCgvYoFXya3pyVb\":$2,\"RNyBS6ryQtPPQnJhavKn9o94U2RNExLZon\":$2,\"RPMpwKpzWyg5KoMcsuy3mZucUWNdcP2ndD\":$2,\"RVPcbafNSi6uMaKDyss9epGpHCHbbzUFMd\":$2,\"RAzheh3L7QtBL7oNKByVa43CtgALht6bbT\":$2,\"RMdjuxKBhyr87yhKp6BLUg2p9673NMcPAu\":$2,\"RUPX5RWQL1qurMLmF4fFB4JAgRfwcNww4b\":$2,\"RQLn2QYwXDemFN3DNigU5qv3wUrA3WqquA\":$2,\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\":$2,\"RQzkkncY8ehpRg8M4kvKmDMcbFxcJvohgk\":$2,\"RXUF132uyPVTVUdLn16zCgvYoFXya3pyVb\":$2,\"RNyBS6ryQtPPQnJhavKn9o94U2RNExLZon\":$2,\"RPMpwKpzWyg5KoMcsuy3mZucUWNdcP2ndD\":$2,\"RVPcbafNSi6uMaKDyss9epGpHCHbbzUFMd\":$2,\"RAzheh3L7QtBL7oNKByVa43CtgALht6bbT\":$2,\"RMdjuxKBhyr87yhKp6BLUg2p9673NMcPAu\":$2,\"RUPX5RWQL1qurMLmF4fFB4JAgRfwcNww4b\":$2,\"RQLn2QYwXDemFN3DNigU5qv3wUrA3WqquA\":$2,\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\":$2,\"RQzkkncY8ehpRg8M4kvKmDMcbFxcJvohgk\":$2,\"RXUF132uyPVTVUdLn16zCgvYoFXya3pyVb\":$2,\"RNyBS6ryQtPPQnJhavKn9o94U2RNExLZon\":$2,\"RPMpwKpzWyg5KoMcsuy3mZucUWNdcP2ndD\":$2,\"RVPcbafNSi6uMaKDyss9epGpHCHbbzUFMd\":$2,\"RAzheh3L7QtBL7oNKByVa43CtgALht6bbT\":$2,\"RMdjuxKBhyr87yhKp6BLUg2p9673NMcPAu\":$2,\"RUPX5RWQL1qurMLmF4fFB4JAgRfwcNww4b\":$2,\"RQLn2QYwXDemFN3DNigU5qv3wUrA3WqquA\":$2,\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\":$2,\"RQzkkncY8ehpRg8M4kvKmDMcbFxcJvohgk\":$2,\"RXUF132uyPVTVUdLn16zCgvYoFXya3pyVb\":$2,\"RNyBS6ryQtPPQnJhavKn9o94U2RNExLZon\":$2,\"RPMpwKpzWyg5KoMcsuy3mZucUWNdcP2ndD\":$2,\"RVPcbafNSi6uMaKDyss9epGpHCHbbzUFMd\":$2,\"RAzheh3L7QtBL7oNKByVa43CtgALht6bbT\":$2,\"RMdjuxKBhyr87yhKp6BLUg2p9673NMcPAu\":$2,\"RUPX5RWQL1qurMLmF4fFB4JAgRfwcNww4b\":$2,\"RQLn2QYwXDemFN3DNigU5qv3wUrA3WqquA\":$2,\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\":$2,\"RQzkkncY8ehpRg8M4kvKmDMcbFxcJvohgk\":$2,\"RXUF132uyPVTVUdLn16zCgvYoFXya3pyVb\":$2,\"RNyBS6ryQtPPQnJhavKn9o94U2RNExLZon\":$2,\"RPMpwKpzWyg5KoMcsuy3mZucUWNdcP2ndD\":$2,\"RVPcbafNSi6uMaKDyss9epGpHCHbbzUFMd\":$2,\"RAzheh3L7QtBL7oNKByVa43CtgALht6bbT\":$2,\"RMdjuxKBhyr87yhKp6BLUg2p9673NMcPAu\":$2,\"RUPX5RWQL1qurMLmF4fFB4JAgRfwcNww4b\":$2,\"RQLn2QYwXDemFN3DNigU5qv3wUrA3WqquA\":$2,\"RMfQwu5ey23eWJ4as2ckd8dqsQJwo836ny\":$2,\"RQzkkncY8ehpRg8M4kvKmDMcbFxcJvohgk\":$2,\"RXUF132uyPVTVUdLn16zCgvYoFXya3pyVb\":$2,\"RNyBS6ryQtPPQnJhavKn9o94U2RNExLZon\":$2,\"RPMpwKpzWyg5KoMcsuy3mZucUWNdcP2ndD\":$2,\"RVPcbafNSi6uMaKDyss9epGpHCHbbzUFMd\":$2,\"RAzheh3L7QtBL7oNKByVa43CtgALht6bbT\":$2,\"RMdjuxKBhyr87yhKp6BLUg2p9673NMcPAu\":$2,\"RUPX5RWQL1qurMLmF4fFB4JAgRfwcNww4b\":$2,\"RQLn2QYwXDemFN3DNigU5qv3wUrA3WqquA\":$2}" 0 From ba5aafd5cae6d966ee14dcd5713f78aaff9400c7 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Wed, 7 Feb 2018 13:45:38 +0700 Subject: [PATCH 041/197] Move etomic lib to SuperNet. --- .gitignore | 4 +- CMakeLists.txt | 1 + cpp-ethereum | 1 + iguana/exchanges/LP_etomic.c | 2 +- iguana/exchanges/etomicswap/CMakeLists.txt | 10 + iguana/exchanges/etomicswap/alice.c | 106 +++++++ iguana/exchanges/etomicswap/bob.c | 177 +++++++++++ iguana/exchanges/etomicswap/etomiccurl.c | 112 +++++++ iguana/exchanges/etomicswap/etomiccurl.h | 10 + iguana/exchanges/etomicswap/etomiclib.cpp | 334 +++++++++++++++++++++ iguana/exchanges/etomicswap/etomiclib.h | 131 ++++++++ 11 files changed, 886 insertions(+), 2 deletions(-) create mode 160000 cpp-ethereum create mode 100644 iguana/exchanges/etomicswap/CMakeLists.txt create mode 100644 iguana/exchanges/etomicswap/alice.c create mode 100644 iguana/exchanges/etomicswap/bob.c create mode 100644 iguana/exchanges/etomicswap/etomiccurl.c create mode 100644 iguana/exchanges/etomicswap/etomiccurl.h create mode 100644 iguana/exchanges/etomicswap/etomiclib.cpp create mode 100644 iguana/exchanges/etomicswap/etomiclib.h diff --git a/.gitignore b/.gitignore index 362b0b8e6..633253ec9 100755 --- a/.gitignore +++ b/.gitignore @@ -251,4 +251,6 @@ iguana/DB/instantdex_RQ4z6KrMZeEnCSCsChv1ZoR9ExQitHjbpg_append.json iguana/DB/instantdex_RQ4z6KrMZeEnCSCsChv1ZoR9ExQitHjbpg.json -build \ No newline at end of file +build + +.idea \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 43bac6ac0..e833ab65f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ project(SuperNET) include_directories("${CMAKE_SOURCE_DIR}") add_subdirectory(cpp-ethereum) add_subdirectory(iguana/exchanges) +add_subdirectory(iguana/exchanges/etomicswap) add_subdirectory(iguana/secp256k1) add_subdirectory(crypto777) add_subdirectory(crypto777/jpeg) \ No newline at end of file diff --git a/cpp-ethereum b/cpp-ethereum new file mode 160000 index 000000000..633c62c08 --- /dev/null +++ b/cpp-ethereum @@ -0,0 +1 @@ +Subproject commit 633c62c08bc73c7c3935c948a8d6c656a3659976 diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index 86e746edc..92641557f 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -21,7 +21,7 @@ // // Created by artem on 24.01.18. // -#include +#include "etomicswap/etomiclib.h" #define ETOMIC_ALICECONTRACT "0xe1D4236C5774D35Dc47dcc2E5E0CcFc463A3289c" #define ETOMIC_BOBCONTRACT "0x9387Fd3a016bB0205e4e131Dde886B9d2BC000A2" diff --git a/iguana/exchanges/etomicswap/CMakeLists.txt b/iguana/exchanges/etomicswap/CMakeLists.txt new file mode 100644 index 000000000..0df98500a --- /dev/null +++ b/iguana/exchanges/etomicswap/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 2.8.9) +add_library(etomiclib etomiclib.cpp) +add_library(etomiccurl etomiccurl.c) +add_executable(alice alice.c) +add_executable(bob bob.c) +include_directories("${CMAKE_SOURCE_DIR}/cpp-ethereum") +target_link_libraries(etomiccurl PUBLIC curl libcrypto777) +target_link_libraries(etomiclib PUBLIC ethcore devcrypto devcore etomiccurl) +target_link_libraries(alice PUBLIC etomiclib) +target_link_libraries(bob PUBLIC etomiclib etomiccurl) \ No newline at end of file diff --git a/iguana/exchanges/etomicswap/alice.c b/iguana/exchanges/etomicswap/alice.c new file mode 100644 index 000000000..0b2508aac --- /dev/null +++ b/iguana/exchanges/etomicswap/alice.c @@ -0,0 +1,106 @@ +// +// Created by artem on 24.01.18. +// +#include +#include +#include +#include "etomiclib.h" +#include + +char* aliceContractAddress = "0xe1D4236C5774D35Dc47dcc2E5E0CcFc463A3289c"; +char* aliceAddress = "0x485d2cc2d13a9e12E4b53D606DB1c8adc884fB8a"; +char* bobAddress = "0xA7EF3f65714AE266414C9E58bB4bAa4E6FB82B41"; +char* tokenAddress = "0xc0eb7AeD740E1796992A08962c15661bDEB58003"; + +int main(int argc, char** argv) { + enum { INIT_ETH, INIT_ERC20, ALICE_CLAIMS, BOB_CLAIMS, ALICE_APPROVES_ERC20 }; + + if (argc < 2) { + return 1; + } + + int action = atoi(argv[1]); + char* result; + BasicTxData txData; + switch (action) + { + case INIT_ETH: + txData.amount = "1000000000000000000"; + txData.from = aliceAddress; + txData.to = aliceContractAddress; + txData.secretKey = getenv("ALICE_PK"); + + AliceSendsEthPaymentInput input = { + .dealId = argv[2], + .bobAddress = bobAddress, + .aliceHash = argv[3], + .bobHash = argv[4] + }; + + result = aliceSendsEthPayment(input, txData); + break; + case INIT_ERC20: + txData.amount = "0"; + txData.from = aliceAddress; + txData.to = aliceContractAddress; + txData.secretKey = getenv("ALICE_PK"); + + AliceSendsErc20PaymentInput input1 = { + .dealId = argv[2], + .bobAddress = bobAddress, + .aliceHash = argv[3], + .bobHash = argv[4], + .amount = "1000000000000000000", + .tokenAddress = tokenAddress + }; + + result = aliceSendsErc20Payment(input1, txData); + break; + case ALICE_CLAIMS: + txData.amount = "0"; + txData.from = aliceAddress; + txData.to = aliceContractAddress; + txData.secretKey = getenv("ALICE_PK"); + + AliceReclaimsAlicePaymentInput input2 = { + .dealId = argv[2], + .bobAddress = bobAddress, + .aliceHash = argv[3], + .bobSecret = argv[4], + .tokenAddress = argv[5], + .amount = "1000000000000000000" + }; + + result = aliceReclaimsAlicePayment(input2, txData); + break; + case BOB_CLAIMS: + txData.amount = "0"; + txData.from = bobAddress; + txData.to = aliceContractAddress; + txData.secretKey = getenv("BOB_PK"); + + BobSpendsAlicePaymentInput input3 = { + .dealId = argv[2], + .aliceAddress = aliceAddress, + .aliceSecret = argv[3], + .bobHash = argv[4], + .tokenAddress = argv[5], + .amount = "1000000000000000000" + }; + + result = bobSpendsAlicePayment(input3, txData); + break; + case ALICE_APPROVES_ERC20: + result = approveErc20( + "1000000000000000000", + "0x485d2cc2d13a9e12E4b53D606DB1c8adc884fB8a", + getenv("ALICE_PK") + ); + break; + default: + return 1; + } + printf("%s\n", result); + free(result); + return 0; +} diff --git a/iguana/exchanges/etomicswap/bob.c b/iguana/exchanges/etomicswap/bob.c new file mode 100644 index 000000000..a4d18d6df --- /dev/null +++ b/iguana/exchanges/etomicswap/bob.c @@ -0,0 +1,177 @@ +// +// Created by artem on 24.01.18. +// +#include +#include +#include +#include "etomiclib.h" +#include + +char* bobContractAddress = "0x9387Fd3a016bB0205e4e131Dde886B9d2BC000A2"; +char* aliceAddress = "0x485d2cc2d13a9e12E4b53D606DB1c8adc884fB8a"; +char* bobAddress = "0xA7EF3f65714AE266414C9E58bB4bAa4E6FB82B41"; +char* tokenAddress = "0xc0eb7AeD740E1796992A08962c15661bDEB58003"; + +int main(int argc, char** argv) +{ + enum { + BOB_ETH_DEPOSIT, + BOB_ERC20_DEPOSIT, + BOB_CLAIMS_DEPOSIT, + ALICE_CLAIMS_DEPOSIT, + BOB_ETH_PAYMENT, + BOB_ERC20_PAYMENT, + BOB_CLAIMS_PAYMENT, + ALICE_CLAIMS_PAYMENT, + BOB_APPROVES_ERC20 + }; + if (argc < 3) { + return 1; + } + int action = atoi(argv[1]); + BasicTxData txData; + char* result; + switch (action) + { + case BOB_ETH_DEPOSIT: + txData.amount = "1000000000000000000"; + txData.from = bobAddress; + txData.to = bobContractAddress; + txData.secretKey = getenv("BOB_PK"); + + BobSendsEthDepositInput input = { + .aliceAddress = aliceAddress, + .depositId = argv[2], + .bobHash = argv[3] + }; + + result = bobSendsEthDeposit(input, txData); + break; + case BOB_ERC20_DEPOSIT: + txData.amount = "0"; + txData.from = bobAddress; + txData.to = bobContractAddress; + txData.secretKey = getenv("BOB_PK"); + + BobSendsErc20DepositInput input1 = { + .depositId = argv[2], + .amount = "1000000000000000000", + .aliceAddress = aliceAddress, + .bobHash = argv[3], + .tokenAddress = tokenAddress + }; + + result = bobSendsErc20Deposit(input1, txData); + break; + case BOB_CLAIMS_DEPOSIT: + txData.amount = "0"; + txData.from = bobAddress; + txData.to = bobContractAddress; + txData.secretKey = getenv("BOB_PK"); + + BobRefundsDepositInput input2 = { + .depositId = argv[2], + .amount = "1000000000000000000", + .aliceAddress = aliceAddress, + .tokenAddress = argv[3], + .aliceCanClaimAfter = argv[4], + .bobSecret = argv[5] + }; + + result = bobRefundsDeposit(input2, txData); + break; + case ALICE_CLAIMS_DEPOSIT: + txData.amount = "0"; + txData.from = aliceAddress; + txData.to = bobContractAddress; + txData.secretKey = getenv("ALICE_PK"); + + AliceClaimsBobDepositInput input3 = { + .depositId = argv[2], + .amount = "1000000000000000000", + .bobAddress = bobAddress, + .tokenAddress = argv[3], + .aliceCanClaimAfter = argv[4], + .bobHash = argv[5] + }; + + result = aliceClaimsBobDeposit(input3, txData); + break; + case BOB_ETH_PAYMENT: + txData.amount = "1000000000000000000"; + txData.from = bobAddress; + txData.to = bobContractAddress; + txData.secretKey = getenv("BOB_PK"); + + BobSendsEthPaymentInput input4 = { + .paymentId = argv[2], + .aliceHash = argv[3], + .aliceAddress = aliceAddress + }; + + result = bobSendsEthPayment(input4, txData); + break; + case BOB_ERC20_PAYMENT: + txData.amount = "0"; + txData.from = bobAddress; + txData.to = bobContractAddress; + txData.secretKey = getenv("BOB_PK"); + + BobSendsErc20PaymentInput input5 = { + .paymentId = argv[2], + .amount = "1000000000000000000", + .tokenAddress = tokenAddress, + .aliceAddress = aliceAddress, + .aliceHash = argv[3] + }; + + result = bobSendsErc20Payment(input5, txData); + break; + case BOB_CLAIMS_PAYMENT: + txData.amount = "0"; + txData.from = bobAddress; + txData.to = bobContractAddress; + txData.secretKey = getenv("BOB_PK"); + + BobReclaimsBobPaymentInput input6 = { + .paymentId = argv[2], + .aliceAddress = aliceAddress, + .amount = "1000000000000000000", + .tokenAddress = argv[3], + .bobCanClaimAfter = argv[4], + .aliceHash = argv[5] + }; + + result = bobReclaimsBobPayment(input6, txData); + break; + case ALICE_CLAIMS_PAYMENT: + txData.amount = "0"; + txData.from = aliceAddress; + txData.to = bobContractAddress; + txData.secretKey = getenv("ALICE_PK"); + + AliceSpendsBobPaymentInput input7 = { + .paymentId = argv[2], + .bobAddress = bobAddress, + .amount = "1000000000000000000", + .tokenAddress = argv[3], + .bobCanClaimAfter = argv[4], + .aliceSecret = argv[5] + }; + + result = aliceSpendsBobPayment(input7, txData); + break; + case BOB_APPROVES_ERC20: + result = approveErc20( + "10000000000000000000", + "0xA7EF3f65714AE266414C9E58bB4bAa4E6FB82B41", + getenv("BOB_PK") + ); + break; + default: + return 1; + } + printf("%s\n", result); + free(result); + return 0; +} diff --git a/iguana/exchanges/etomicswap/etomiccurl.c b/iguana/exchanges/etomicswap/etomiccurl.c new file mode 100644 index 000000000..9bb98ec31 --- /dev/null +++ b/iguana/exchanges/etomicswap/etomiccurl.c @@ -0,0 +1,112 @@ +#include "etomiccurl.h" +#include +#include +#include +#include "../../../includes/cJSON.h" + +static char* ethRpcUrl = "https://ropsten.infura.io/y07GHxUyTgeN2mdfOonu"; + +struct string { + char *ptr; + size_t len; +}; + +void init_eth_string(struct string *s) { + s->len = 0; + s->ptr = malloc(s->len+1); + if (s->ptr == NULL) { + fprintf(stderr, "malloc() failed\n"); + exit(EXIT_FAILURE); + } + s->ptr[0] = '\0'; +} + +size_t writefunc(void *ptr, size_t size, size_t nmemb, struct string *s) +{ + size_t new_len = s->len + size*nmemb; + s->ptr = realloc(s->ptr, new_len+1); + if (s->ptr == NULL) { + fprintf(stderr, "realloc() failed\n"); + exit(EXIT_FAILURE); + } + memcpy(s->ptr+s->len, ptr, size*nmemb); + s->ptr[new_len] = '\0'; + s->len = new_len; + + return size*nmemb; +} + +char* sendRequest(char* request) +{ + CURL *curl; + CURLcode res; + struct curl_slist *headers = NULL; + curl = curl_easy_init(); + if (curl) { + struct string s; + init_eth_string(&s); + + headers = curl_slist_append(headers, "Accept: application/json"); + headers = curl_slist_append(headers, "Content-Type: application/json"); + curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); + 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_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)); + } + + /* always cleanup */ + curl_easy_cleanup(curl); + return s.ptr; + } else { + return NULL; + } +} + +char* sendRawTx(char* rawTx) +{ + char* string; + cJSON *request = cJSON_CreateObject(); + cJSON *params = cJSON_CreateArray(); + cJSON_AddItemToObject(request, "jsonrpc", cJSON_CreateString("2.0")); + cJSON_AddItemToObject(request, "method", cJSON_CreateString("eth_sendRawTransaction")); + cJSON_AddItemToArray(params, cJSON_CreateString(rawTx)); + cJSON_AddItemToObject(request, "params", params); + cJSON_AddItemToObject(request, "id", cJSON_CreateNumber(2)); + string = cJSON_PrintUnformatted(request); + char* requestResult = sendRequest(string); + cJSON *json = cJSON_Parse(requestResult); + cJSON_Delete(request); + char* tmp = cJSON_GetObjectItem(json, "result")->valuestring; + char* txId = (char*)malloc(strlen(tmp) + 1); + strcpy(txId, tmp); + free(requestResult); + return txId; +} + +int getNonce(char* address) +{ + char* string; + cJSON *request = cJSON_CreateObject(); + cJSON *params = cJSON_CreateArray(); + cJSON_AddItemToObject(request, "jsonrpc", cJSON_CreateString("2.0")); + cJSON_AddItemToObject(request, "method", cJSON_CreateString("eth_getTransactionCount")); + cJSON_AddItemToArray(params, cJSON_CreateString(address)); + cJSON_AddItemToArray(params, cJSON_CreateString("pending")); + cJSON_AddItemToObject(request, "params", params); + cJSON_AddItemToObject(request, "id", cJSON_CreateNumber(2)); + string = cJSON_PrintUnformatted(request); + char* requestResult = sendRequest(string); + cJSON_Delete(request); + cJSON *json = cJSON_Parse(requestResult); + int nonce = (int)strtol(cJSON_GetObjectItem(json, "result")->valuestring, NULL, 0); + cJSON_Delete(json); + free(requestResult); + return nonce; +} diff --git a/iguana/exchanges/etomicswap/etomiccurl.h b/iguana/exchanges/etomicswap/etomiccurl.h new file mode 100644 index 000000000..339f8bf19 --- /dev/null +++ b/iguana/exchanges/etomicswap/etomiccurl.h @@ -0,0 +1,10 @@ +#ifdef __cplusplus +extern "C"{ +#endif + +char* sendRawTx(char* rawTx); +int getNonce(char* address); + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/iguana/exchanges/etomicswap/etomiclib.cpp b/iguana/exchanges/etomicswap/etomiclib.cpp new file mode 100644 index 000000000..cd8432e29 --- /dev/null +++ b/iguana/exchanges/etomicswap/etomiclib.cpp @@ -0,0 +1,334 @@ +// +// Created by artem on 24.01.18. +// +#include "etomiclib.h" +#include "etomiccurl.h" +#include +#include +#include +#include +using namespace dev; +using namespace dev::eth; + +char* stringStreamToChar(std::stringstream& ss) +{ + const std::string tmp = ss.str(); + auto result = (char*)malloc(strlen(tmp.c_str()) + 1); + strcpy(result, tmp.c_str()); + return result; +} + +TransactionSkeleton txDataToSkeleton(BasicTxData txData) +{ + TransactionSkeleton tx; + tx.from = jsToAddress(txData.from); + tx.to = jsToAddress(txData.to); + tx.value = jsToU256(txData.amount); + tx.gas = 300000; + tx.gasPrice = 100 * exp10<9>(); + tx.nonce = getNonce(txData.from); + return tx; +} + +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); + ss << rlpStream.out(); + return stringStreamToChar(ss); +} + +char* approveErc20(char* amount, char* from, char* secret) +{ + TransactionSkeleton tx; + tx.from = jsToAddress(from); + tx.to = jsToAddress("0xc0eb7AeD740E1796992A08962c15661bDEB58003"); + tx.value = 0; // exp10<18>(); + tx.gas = 300000; + tx.gasPrice = 100 * exp10<9>(); + tx.nonce = getNonce(from); + std::stringstream ss; + ss << "0x095ea7b3" + << "000000000000000000000000" + << toHex(jsToAddress("0xe1D4236C5774D35Dc47dcc2E5E0CcFc463A3289c")) + << toHex(toBigEndian(jsToU256(amount))); + tx.data = jsToBytes(ss.str()); + char* rawTx = signTx(tx, secret); + char* result = sendRawTx(rawTx); + free(rawTx); + return result; +} + +char* aliceSendsEthPayment(AliceSendsEthPaymentInput input, BasicTxData txData) +{ + TransactionSkeleton tx = txDataToSkeleton(txData); + std::stringstream ss; + ss << "0x47c7b6e2" + << toHex(jsToBytes(input.dealId)) + << "000000000000000000000000" + << toHex(jsToAddress(input.bobAddress)) + << toHex(jsToBytes(input.aliceHash)) + << "000000000000000000000000" + << toHex(jsToBytes(input.bobHash)) + << "000000000000000000000000"; + tx.data = jsToBytes(ss.str()); + char* rawTx = signTx(tx, txData.secretKey); + char* result = sendRawTx(rawTx); + free(rawTx); + return result; +} + +char* aliceSendsErc20Payment(AliceSendsErc20PaymentInput input, BasicTxData txData) +{ + TransactionSkeleton tx = txDataToSkeleton(txData); + std::stringstream ss; + ss << "0x184db3bf" + << toHex(jsToBytes(input.dealId)) + << toHex(toBigEndian(jsToU256(input.amount))) + << "000000000000000000000000" + << toHex(jsToAddress(input.bobAddress)) + << toHex(jsToBytes(input.aliceHash)) + << "000000000000000000000000" + << toHex(jsToBytes(input.bobHash)) + << "000000000000000000000000" + << "000000000000000000000000" + << toHex(jsToAddress(input.tokenAddress)); + tx.data = jsToBytes(ss.str()); + char* rawTx = signTx(tx, txData.secretKey); + char* result = sendRawTx(rawTx); + free(rawTx); + return result; +} + +char* aliceReclaimsAlicePayment(AliceReclaimsAlicePaymentInput input, BasicTxData txData) +{ + TransactionSkeleton tx = txDataToSkeleton(txData); + std::stringstream ss; + ss << "0x8b9a167a" + << toHex(jsToBytes(input.dealId)) + << toHex(toBigEndian(jsToU256(input.amount))) + << "000000000000000000000000" + << toHex(jsToAddress(input.tokenAddress)) + << "000000000000000000000000" + << toHex(jsToAddress(input.bobAddress)) + << toHex(jsToBytes(input.aliceHash)) + << "000000000000000000000000" + << "00000000000000000000000000000000000000000000000000000000000000c0" + << "0000000000000000000000000000000000000000000000000000000000000020" + << toHex(jsToBytes(input.bobSecret)); + tx.data = jsToBytes(ss.str()); + char* rawTx = signTx(tx, txData.secretKey); + char* result = sendRawTx(rawTx); + free(rawTx); + return result; +} + +char* bobSpendsAlicePayment(BobSpendsAlicePaymentInput input, BasicTxData txData) +{ + TransactionSkeleton tx = txDataToSkeleton(txData); + std::stringstream ss; + ss << "0x392ec66b" + << toHex(jsToBytes(input.dealId)) + << toHex(toBigEndian(jsToU256(input.amount))) + << "000000000000000000000000" + << toHex(jsToAddress(input.tokenAddress)) + << "000000000000000000000000" + << toHex(jsToAddress(input.aliceAddress)) + << toHex(jsToBytes(input.bobHash)) + << "000000000000000000000000" + << "00000000000000000000000000000000000000000000000000000000000000c0" + << "0000000000000000000000000000000000000000000000000000000000000020" + << toHex(jsToBytes(input.aliceSecret)); + tx.data = jsToBytes(ss.str()); + char* rawTx = signTx(tx, txData.secretKey); + char* result = sendRawTx(rawTx); + free(rawTx); + return result; +} + +char* bobSendsEthDeposit(BobSendsEthDepositInput input, BasicTxData txData) +{ + TransactionSkeleton tx = txDataToSkeleton(txData); + std::stringstream ss; + ss << "0xc2c5143f" + << toHex(jsToBytes(input.depositId)) + << "000000000000000000000000" + << toHex(jsToAddress(input.aliceAddress)) + << toHex(jsToBytes(input.bobHash)) + << "000000000000000000000000"; + tx.data = jsToBytes(ss.str()); + char* rawTx = signTx(tx, txData.secretKey); + char* result = sendRawTx(rawTx); + free(rawTx); + return result; +} + +char* bobSendsErc20Deposit(BobSendsErc20DepositInput input, BasicTxData txData) +{ + TransactionSkeleton tx = txDataToSkeleton(txData); + std::stringstream ss; + ss << "0xce8bbe4b" + << toHex(jsToBytes(input.depositId)) + << toHex(toBigEndian(jsToU256(input.amount))) + << "000000000000000000000000" + << toHex(jsToAddress(input.aliceAddress)) + << toHex(jsToBytes(input.bobHash)) + << "000000000000000000000000" + << "000000000000000000000000" + << toHex(jsToAddress(input.tokenAddress)); + tx.data = jsToBytes(ss.str()); + char* rawTx = signTx(tx, txData.secretKey); + char* result = sendRawTx(rawTx); + free(rawTx); + return result; +} + +char* bobRefundsDeposit(BobRefundsDepositInput input, BasicTxData txData) +{ + TransactionSkeleton tx = txDataToSkeleton(txData); + std::stringstream ss; + ss << "0x1dbe6508" + << toHex(jsToBytes(input.depositId)) + << toHex(toBigEndian(jsToU256(input.amount))) + << toHex(toBigEndian(jsToU256(input.aliceCanClaimAfter))) + << "000000000000000000000000" + << toHex(jsToAddress(input.aliceAddress)) + << "000000000000000000000000" + << toHex(jsToAddress(input.tokenAddress)) + << "00000000000000000000000000000000000000000000000000000000000000c0" + << "0000000000000000000000000000000000000000000000000000000000000020" + << toHex(jsToBytes(input.bobSecret)); + tx.data = jsToBytes(ss.str()); + char* rawTx = signTx(tx, txData.secretKey); + char* result = sendRawTx(rawTx); + free(rawTx); + return result; +} + +char* aliceClaimsBobDeposit(AliceClaimsBobDepositInput input, BasicTxData txData) +{ + TransactionSkeleton tx = txDataToSkeleton(txData); + std::stringstream ss; + ss << "0x960173b5" + << toHex(jsToBytes(input.depositId)) + << toHex(toBigEndian(jsToU256(input.amount))) + << toHex(toBigEndian(jsToU256(input.aliceCanClaimAfter))) + << "000000000000000000000000" + << toHex(jsToAddress(input.bobAddress)) + << "000000000000000000000000" + << toHex(jsToAddress(input.tokenAddress)) + << toHex(jsToBytes(input.bobHash)) + << "000000000000000000000000"; + tx.data = jsToBytes(ss.str()); + char* rawTx = signTx(tx, txData.secretKey); + char* result = sendRawTx(rawTx); + free(rawTx); + return result; +} + +char* bobSendsEthPayment(BobSendsEthPaymentInput input, BasicTxData txData) +{ + TransactionSkeleton tx = txDataToSkeleton(txData); + std::stringstream ss; + ss << "0xcf36fe8e" + << toHex(jsToBytes(input.paymentId)) + << "000000000000000000000000" + << toHex(jsToAddress(input.aliceAddress)) + << toHex(jsToBytes(input.aliceHash)) + << "000000000000000000000000"; + tx.data = jsToBytes(ss.str()); + char* rawTx = signTx(tx, txData.secretKey); + char* result = sendRawTx(rawTx); + free(rawTx); + return result; +} + +char* bobSendsErc20Payment(BobSendsErc20PaymentInput input, BasicTxData txData) +{ + TransactionSkeleton tx = txDataToSkeleton(txData); + std::stringstream ss; + ss << "0x34f64dfd" + << toHex(jsToBytes(input.paymentId)) + << toHex(toBigEndian(jsToU256(input.amount))) + << "000000000000000000000000" + << toHex(jsToAddress(input.aliceAddress)) + << toHex(jsToBytes(input.aliceHash)) + << "000000000000000000000000" + << "000000000000000000000000" + << toHex(jsToAddress(input.tokenAddress)); + tx.data = jsToBytes(ss.str()); + char* rawTx = signTx(tx, txData.secretKey); + char* result = sendRawTx(rawTx); + free(rawTx); + return result; +} + +char* bobReclaimsBobPayment(BobReclaimsBobPaymentInput input, BasicTxData txData) +{ + TransactionSkeleton tx = txDataToSkeleton(txData); + std::stringstream ss; + ss << "0xb7cc2312" + << toHex(jsToBytes(input.paymentId)) + << toHex(toBigEndian(jsToU256(input.amount))) + << toHex(toBigEndian(jsToU256(input.bobCanClaimAfter))) + << "000000000000000000000000" + << toHex(jsToAddress(input.aliceAddress)) + << "000000000000000000000000" + << toHex(jsToAddress(input.tokenAddress)) + << toHex(jsToBytes(input.aliceHash)) + << "000000000000000000000000"; + tx.data = jsToBytes(ss.str()); + char* rawTx = signTx(tx, txData.secretKey); + char* result = sendRawTx(rawTx); + free(rawTx); + return result; +} + +char* aliceSpendsBobPayment(AliceSpendsBobPaymentInput input, BasicTxData txData) +{ + TransactionSkeleton tx = txDataToSkeleton(txData); + std::stringstream ss; + ss << "0x97004255" + << toHex(jsToBytes(input.paymentId)) + << toHex(toBigEndian(jsToU256(input.amount))) + << toHex(toBigEndian(jsToU256(input.bobCanClaimAfter))) + << "000000000000000000000000" + << toHex(jsToAddress(input.bobAddress)) + << "000000000000000000000000" + << toHex(jsToAddress(input.tokenAddress)) + << "00000000000000000000000000000000000000000000000000000000000000c0" + << "0000000000000000000000000000000000000000000000000000000000000020" + << toHex(jsToBytes(input.aliceSecret)); + tx.data = jsToBytes(ss.str()); + char* rawTx = signTx(tx, txData.secretKey); + char* result = sendRawTx(rawTx); + free(rawTx); + return result; +} + +char* privKey2Addr(char* privKey) +{ + Secret& secretKey = *(new Secret(privKey)); + std::stringstream& ss = *(new std::stringstream); + ss << "0x" << toAddress(secretKey); + return stringStreamToChar(ss); +}; + +char* pubKey2Addr(char* pubKey) +{ + Public& publicKey = *(new Public(pubKey)); + std::stringstream& ss = *(new std::stringstream); + ss << "0x" << toAddress(publicKey); + return stringStreamToChar(ss); +}; + +char* getPubKeyFromPriv(char* privKey) +{ + Public publicKey = toPublic(*(new Secret(privKey))); + std::stringstream& ss = *(new std::stringstream); + ss << "0x" << publicKey; + return stringStreamToChar(ss); +} diff --git a/iguana/exchanges/etomicswap/etomiclib.h b/iguana/exchanges/etomicswap/etomiclib.h new file mode 100644 index 000000000..851a7ee11 --- /dev/null +++ b/iguana/exchanges/etomicswap/etomiclib.h @@ -0,0 +1,131 @@ +// +// Created by artem on 24.01.18. +// +#ifdef __cplusplus +extern "C" { +#endif +typedef struct { + char* from; + char* to; + char* amount; + char* secretKey; +} BasicTxData; + +typedef struct { + char* dealId; + char* bobAddress; + char* aliceHash; + char* bobHash; +} AliceSendsEthPaymentInput; + +typedef struct { + char* dealId; + char* amount; + char* tokenAddress; + char* bobAddress; + char* aliceHash; + char* bobHash; +} AliceSendsErc20PaymentInput; + +typedef struct { + char* dealId; + char* amount; + char* tokenAddress; + char* bobAddress; + char* aliceHash; + char* bobSecret; +} AliceReclaimsAlicePaymentInput; + +typedef struct { + char* dealId; + char* amount; + char* tokenAddress; + char* aliceAddress; + char* aliceSecret; + char* bobHash; +} BobSpendsAlicePaymentInput; + +typedef struct { + char* depositId; + char* aliceAddress; + char* bobHash; +} BobSendsEthDepositInput; + +typedef struct { + char* depositId; + char* amount; + char* tokenAddress; + char* aliceAddress; + char* bobHash; +} BobSendsErc20DepositInput; + +typedef struct { + char* depositId; + char* amount; + char* tokenAddress; + char* aliceAddress; + char* bobSecret; + char* aliceCanClaimAfter; +} BobRefundsDepositInput; + +typedef struct { + char* depositId; + char* amount; + char* tokenAddress; + char* bobAddress; + char* bobHash; + char* aliceCanClaimAfter; +} AliceClaimsBobDepositInput; + +typedef struct { + char* paymentId; + char* aliceAddress; + char* aliceHash; +} BobSendsEthPaymentInput; + +typedef struct { + char* paymentId; + char* amount; + char* tokenAddress; + char* aliceAddress; + char* aliceHash; +} BobSendsErc20PaymentInput; + +typedef struct { + char* paymentId; + char* amount; + char* tokenAddress; + char* aliceAddress; + char* aliceHash; + char* bobCanClaimAfter; +} BobReclaimsBobPaymentInput; + +typedef struct { + char* paymentId; + char* amount; + char* tokenAddress; + char* aliceSecret; + char* bobAddress; + char* bobCanClaimAfter; +} AliceSpendsBobPaymentInput; + +char* approveErc20(char* amount, char* from, char* secret); +char* aliceSendsEthPayment(AliceSendsEthPaymentInput input, BasicTxData txData); +char* aliceSendsErc20Payment(AliceSendsErc20PaymentInput input, BasicTxData txData); +char* aliceReclaimsAlicePayment(AliceReclaimsAlicePaymentInput input, BasicTxData txData); +char* bobSpendsAlicePayment(BobSpendsAlicePaymentInput input, BasicTxData txData); +char* bobSendsEthDeposit(BobSendsEthDepositInput input, BasicTxData txData); +char* bobSendsErc20Deposit(BobSendsErc20DepositInput input, BasicTxData txData); +char* bobRefundsDeposit(BobRefundsDepositInput input, BasicTxData txData); +char* aliceClaimsBobDeposit(AliceClaimsBobDepositInput input, BasicTxData txData); +char* bobSendsEthPayment(BobSendsEthPaymentInput input, BasicTxData txData); +char* bobSendsErc20Payment(BobSendsErc20PaymentInput input, BasicTxData txData); +char* bobReclaimsBobPayment(BobReclaimsBobPaymentInput input, BasicTxData txData); +char* aliceSpendsBobPayment(AliceSpendsBobPaymentInput input, BasicTxData txData); +char* privKey2Addr(char* privKey); +char* pubKey2Addr(char* pubKey); +char* getPubKeyFromPriv(char* privKey); +// Your prototype or Definition +#ifdef __cplusplus +} +#endif From 84329750a1c07c8451b8ad4cc8bd7f24e9418e17 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 10:59:49 +0200 Subject: [PATCH 042/197] Pub33-> pub64 --- iguana/exchanges/LP_etomic.c | 12 ++++++------ iguana/exchanges/LP_swap.c | 7 +++++-- iguana/exchanges/enable | 1 + 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index 86e746edc..8ecb5cc35 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -72,27 +72,27 @@ int32_t LP_etomic_priv2addr(char *coinaddr,bits256 privkey) return(-1); } -int32_t LP_etomic_priv2pub(uint8_t *pub33,bits256 privkey) +int32_t LP_etomic_priv2pub(uint8_t *pub64,bits256 privkey) { char *pubstr,str[72]; int32_t retval = -1; bits256_str(str,privkey); if ( (pubstr= getPubKeyFromPriv(str)) != 0 ) { - if ( strlen(pubstr) == 35 && pubstr[0] == '0' && pubstr[1] == 'x' ) + if ( strlen(pubstr) == 128 && pubstr[0] == '0' && pubstr[1] == 'x' ) { - decode_hex(pub33,33,pubstr+2); - retval = 33; + decode_hex(pub33,64,pubstr+2); + retval = 64; } free(pubstr); } return(retval); } -int32_t LP_etomic_pub2addr(char *coinaddr,uint8_t pub33[33]) +int32_t LP_etomic_pub2addr(char *coinaddr,uint8_t pub64[64]) { char pubkeystr[72],*addrstr; strcpy(pubkeystr,"0x"); - init_hexbytes_noT(pubkeystr+2,pub33,33); + init_hexbytes_noT(pubkeystr+2,pub64,64); if ( (addrstr= pubKey2Addr(pubkeystr+2)) != 0 ) { strcpy(coinaddr,addrstr); diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index 30f2ce5b8..290158ace 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -1165,8 +1165,11 @@ struct basilisk_swap *bitcoin_swapinit(bits256 privkey,uint8_t *pubkey33,bits256 swap->I.bobconfirms = swap->I.bobmaxconfirms; if ( swap->I.aliceconfirms > swap->I.alicemaxconfirms ) swap->I.aliceconfirms = swap->I.alicemaxconfirms; - swap->I.bobconfirms *= !swap->I.bobistrusted; - swap->I.aliceconfirms *= !swap->I.aliceistrusted; + if ( strcmp("BAY",swap->I.req.src) != 0 && strcmp("BAY",swap->I.req.dest) != 0 ) + { + swap->I.bobconfirms *= !swap->I.bobistrusted; + swap->I.aliceconfirms *= !swap->I.aliceistrusted; + } printf(">>>>>>>>>> jumblrflag.%d <<<<<<<<< r.%u q.%u, %.8f bobconfs.%d, %.8f aliceconfs.%d taddr.%d %d\n",jumblrflag,swap->I.req.requestid,swap->I.req.quoteid,dstr(swap->I.bobsatoshis),swap->I.bobconfirms,dstr(swap->I.alicesatoshis),swap->I.aliceconfirms,bobcoin->taddr,alicecoin->taddr); if ( swap->I.iambob != 0 ) { diff --git a/iguana/exchanges/enable b/iguana/exchanges/enable index e5121918a..f682b9343 100755 --- a/iguana/exchanges/enable +++ b/iguana/exchanges/enable @@ -1,6 +1,7 @@ #!/bin/bash source userpass curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"BEER\"}" +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\":\"PIZZA\"}" curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"REVS\"}" curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"KMD\"}" From 913d75219b702a757448c1239593cf13db6c7dea Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 11:03:03 +0200 Subject: [PATCH 043/197] Test --- iguana/exchanges/LP_etomic.c | 1 + iguana/exchanges/LP_privkey.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index 8ecb5cc35..3d16b19eb 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -78,6 +78,7 @@ int32_t LP_etomic_priv2pub(uint8_t *pub64,bits256 privkey) bits256_str(str,privkey); if ( (pubstr= getPubKeyFromPriv(str)) != 0 ) { + printf("priv2pub got %s\n",pubstr); if ( strlen(pubstr) == 128 && pubstr[0] == '0' && pubstr[1] == 'x' ) { decode_hex(pub33,64,pubstr+2); diff --git a/iguana/exchanges/LP_privkey.c b/iguana/exchanges/LP_privkey.c index 95d9eb079..eb1668f10 100644 --- a/iguana/exchanges/LP_privkey.c +++ b/iguana/exchanges/LP_privkey.c @@ -295,16 +295,16 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan } bitcoin_priv2pub(ctx,coin->symbol,coin->pubkey33,coin->smartaddr,privkey,coin->taddr,coin->pubtype); { - uint8_t check33[33]; char checkaddr[64]; + uint8_t check64[64]; char checkaddr[64]; if ( LP_etomic_priv2pub(check33,privkey) > 0 ) { - if ( memcmp(check33,coin->pubkey33,33) == 0 ) + if ( memcmp(check64,coin->pubkey33+1,32) == 0 ) { printf("pubkey33 matches!\n"); if ( LP_etomic_pub2addr(checkaddr,check33) > 0 ) printf("addr is (%s)\n",checkaddr); else printf("error getting addr\n"); - } else printf("pubkey 33 mismatch\n"); + } else printf("pubkey 64 mismatch\n"); } else printf("error creating pubkey\n"); } if ( coin->counter == 0 ) From 014b1b3dd71736861a4ed10e2d8f466f67230825 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 11:07:45 +0200 Subject: [PATCH 044/197] Test --- iguana/exchanges/LP_etomic.c | 2 +- iguana/exchanges/LP_privkey.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index 3d16b19eb..0451509bf 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -81,7 +81,7 @@ int32_t LP_etomic_priv2pub(uint8_t *pub64,bits256 privkey) printf("priv2pub got %s\n",pubstr); if ( strlen(pubstr) == 128 && pubstr[0] == '0' && pubstr[1] == 'x' ) { - decode_hex(pub33,64,pubstr+2); + decode_hex(pub64,64,pubstr+2); retval = 64; } free(pubstr); diff --git a/iguana/exchanges/LP_privkey.c b/iguana/exchanges/LP_privkey.c index eb1668f10..5dad47e56 100644 --- a/iguana/exchanges/LP_privkey.c +++ b/iguana/exchanges/LP_privkey.c @@ -301,7 +301,7 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan if ( memcmp(check64,coin->pubkey33+1,32) == 0 ) { printf("pubkey33 matches!\n"); - if ( LP_etomic_pub2addr(checkaddr,check33) > 0 ) + if ( LP_etomic_pub2addr(checkaddr,check64) > 0 ) printf("addr is (%s)\n",checkaddr); else printf("error getting addr\n"); } else printf("pubkey 64 mismatch\n"); From 794c9849e0b7900577258724eb07ecfb54cfd36e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 11:08:16 +0200 Subject: [PATCH 045/197] Test --- iguana/exchanges/LP_privkey.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_privkey.c b/iguana/exchanges/LP_privkey.c index 5dad47e56..adcfa4f78 100644 --- a/iguana/exchanges/LP_privkey.c +++ b/iguana/exchanges/LP_privkey.c @@ -296,7 +296,7 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan bitcoin_priv2pub(ctx,coin->symbol,coin->pubkey33,coin->smartaddr,privkey,coin->taddr,coin->pubtype); { uint8_t check64[64]; char checkaddr[64]; - if ( LP_etomic_priv2pub(check33,privkey) > 0 ) + if ( LP_etomic_priv2pub(check64,privkey) > 0 ) { if ( memcmp(check64,coin->pubkey33+1,32) == 0 ) { From 8c569350a5c576a1a9ca6420174f95c28963f65d Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 11:09:21 +0200 Subject: [PATCH 046/197] Test --- iguana/exchanges/LP_etomic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index 0451509bf..da0d16b77 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -79,7 +79,7 @@ int32_t LP_etomic_priv2pub(uint8_t *pub64,bits256 privkey) if ( (pubstr= getPubKeyFromPriv(str)) != 0 ) { printf("priv2pub got %s\n",pubstr); - if ( strlen(pubstr) == 128 && pubstr[0] == '0' && pubstr[1] == 'x' ) + if ( strlen(pubstr) == 130 && pubstr[0] == '0' && pubstr[1] == 'x' ) { decode_hex(pub64,64,pubstr+2); retval = 64; From b41230f4b9286f12f99cc554edc5aead3c34cba4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 11:11:30 +0200 Subject: [PATCH 047/197] Test --- iguana/exchanges/LP_etomic.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index da0d16b77..48f3a12cc 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -65,6 +65,7 @@ int32_t LP_etomic_priv2addr(char *coinaddr,bits256 privkey) bits256_str(str,privkey); if ( (addrstr= privKey2Addr(str)) != 0 ) { + printf("priv2addr got %s\n",addrstr); strcpy(coinaddr,addrstr); free(addrstr); return(0); @@ -78,7 +79,6 @@ int32_t LP_etomic_priv2pub(uint8_t *pub64,bits256 privkey) bits256_str(str,privkey); if ( (pubstr= getPubKeyFromPriv(str)) != 0 ) { - printf("priv2pub got %s\n",pubstr); if ( strlen(pubstr) == 130 && pubstr[0] == '0' && pubstr[1] == 'x' ) { decode_hex(pub64,64,pubstr+2); @@ -91,10 +91,10 @@ int32_t LP_etomic_priv2pub(uint8_t *pub64,bits256 privkey) int32_t LP_etomic_pub2addr(char *coinaddr,uint8_t pub64[64]) { - char pubkeystr[72],*addrstr; + char pubkeystr[131],*addrstr; strcpy(pubkeystr,"0x"); init_hexbytes_noT(pubkeystr+2,pub64,64); - if ( (addrstr= pubKey2Addr(pubkeystr+2)) != 0 ) + if ( (addrstr= pubKey2Addr(pubkeystr)) != 0 ) { strcpy(coinaddr,addrstr); free(addrstr); From 16919abe4dc73e24bcead136024ccb04a14fe18c Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 11:21:13 +0200 Subject: [PATCH 048/197] Test --- iguana/exchanges/LP_privkey.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_privkey.c b/iguana/exchanges/LP_privkey.c index adcfa4f78..c9c08f1e8 100644 --- a/iguana/exchanges/LP_privkey.c +++ b/iguana/exchanges/LP_privkey.c @@ -295,14 +295,15 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan } bitcoin_priv2pub(ctx,coin->symbol,coin->pubkey33,coin->smartaddr,privkey,coin->taddr,coin->pubtype); { - uint8_t check64[64]; char checkaddr[64]; + uint8_t check64[64]; char checkaddr[64],checkaddr2[64]; if ( LP_etomic_priv2pub(check64,privkey) > 0 ) { if ( memcmp(check64,coin->pubkey33+1,32) == 0 ) { - printf("pubkey33 matches!\n"); - if ( LP_etomic_pub2addr(checkaddr,check64) > 0 ) + if ( LP_etomic_priv2addr(checkaddr2,privkey) > 0 && LP_etomic_pub2addr(checkaddr,check64) > 0 && strcmp(checkaddr2,checkaddr) == 0 ) + { printf("addr is (%s)\n",checkaddr); + } else printf("error getting addr\n"); } else printf("pubkey 64 mismatch\n"); } else printf("error creating pubkey\n"); From 4a89d15097c9ef2372fe311ff66dc8e8c9199e34 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 11:23:32 +0200 Subject: [PATCH 049/197] Test --- iguana/exchanges/LP_etomic.c | 5 ++--- iguana/exchanges/LP_privkey.c | 7 +++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index 48f3a12cc..5a0a87821 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -65,7 +65,6 @@ int32_t LP_etomic_priv2addr(char *coinaddr,bits256 privkey) bits256_str(str,privkey); if ( (addrstr= privKey2Addr(str)) != 0 ) { - printf("priv2addr got %s\n",addrstr); strcpy(coinaddr,addrstr); free(addrstr); return(0); @@ -82,7 +81,7 @@ int32_t LP_etomic_priv2pub(uint8_t *pub64,bits256 privkey) if ( strlen(pubstr) == 130 && pubstr[0] == '0' && pubstr[1] == 'x' ) { decode_hex(pub64,64,pubstr+2); - retval = 64; + retval = 0; } free(pubstr); } @@ -98,7 +97,7 @@ int32_t LP_etomic_pub2addr(char *coinaddr,uint8_t pub64[64]) { strcpy(coinaddr,addrstr); free(addrstr); - return((int32_t)strlen(coinaddr)); + return(0); } return(-1); } diff --git a/iguana/exchanges/LP_privkey.c b/iguana/exchanges/LP_privkey.c index c9c08f1e8..35aa506ac 100644 --- a/iguana/exchanges/LP_privkey.c +++ b/iguana/exchanges/LP_privkey.c @@ -296,15 +296,14 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan bitcoin_priv2pub(ctx,coin->symbol,coin->pubkey33,coin->smartaddr,privkey,coin->taddr,coin->pubtype); { uint8_t check64[64]; char checkaddr[64],checkaddr2[64]; - if ( LP_etomic_priv2pub(check64,privkey) > 0 ) + if ( LP_etomic_priv2pub(check64,privkey) == 0 ) { if ( memcmp(check64,coin->pubkey33+1,32) == 0 ) { - if ( LP_etomic_priv2addr(checkaddr2,privkey) > 0 && LP_etomic_pub2addr(checkaddr,check64) > 0 && strcmp(checkaddr2,checkaddr) == 0 ) + if ( LP_etomic_priv2addr(checkaddr,privkey) == 0 && LP_etomic_pub2addr(checkaddr2,check64) == 0 && strcmp(checkaddr,checkaddr2) == 0 ) { printf("addr is (%s)\n",checkaddr); - } - else printf("error getting addr\n"); + } else printf("error getting addr (%s) != (%s)\n",checkaddr,checkaddr2); } else printf("pubkey 64 mismatch\n"); } else printf("error creating pubkey\n"); } From f276f0f09ac8e1fdb0df6bf33d761245835ed714 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 12:07:07 +0200 Subject: [PATCH 050/197] Test --- iguana/exchanges/LP_privkey.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/iguana/exchanges/LP_privkey.c b/iguana/exchanges/LP_privkey.c index 35aa506ac..a6aaba44f 100644 --- a/iguana/exchanges/LP_privkey.c +++ b/iguana/exchanges/LP_privkey.c @@ -262,12 +262,17 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan } if ( passphrase != 0 && passphrase[0] != 0 ) { - calc_NXTaddr(G.LP_NXTaddr,userpub.bytes,(uint8_t *)passphrase,(int32_t)strlen(passphrase)); - conv_NXTpassword(privkey.bytes,pubkeyp->bytes,(uint8_t *)passphrase,(int32_t)strlen(passphrase)); - privkey.bytes[0] &= 248, privkey.bytes[31] &= 127, privkey.bytes[31] |= 64; - //vcalc_sha256(0,checkkey.bytes,(uint8_t *)passphrase,(int32_t)strlen(passphrase)); - //printf("SHA256.(%s) ",bits256_str(pstr,checkkey)); - //printf("privkey.(%s)\n",bits256_str(pstr,privkey)); + if ( strlen(passphrase) == 130 && passphrase[0] == '0' && passphrase[1] == 'x' && is_hexstr(passhrase+2,0) == 128 ) + { + decode_hex(privkey.bytes,64,passphrase+2); + printf("ETH style privkey.(%s)\n",passphrase); + } + else + { + calc_NXTaddr(G.LP_NXTaddr,userpub.bytes,(uint8_t *)passphrase,(int32_t)strlen(passphrase)); + conv_NXTpassword(privkey.bytes,pubkeyp->bytes,(uint8_t *)passphrase,(int32_t)strlen(passphrase)); + privkey.bytes[0] &= 248, privkey.bytes[31] &= 127, privkey.bytes[31] |= 64; + } bitcoin_priv2wif(coin->symbol,coin->wiftaddr,tmpstr,privkey,coin->wiftype); bitcoin_wif2priv(coin->symbol,coin->wiftaddr,&tmptype,&checkkey,tmpstr); if ( bits256_cmp(privkey,checkkey) != 0 ) From fb7cd5e305a9f9d90eff28538fdb890e8343d577 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 12:11:31 +0200 Subject: [PATCH 051/197] Test --- iguana/exchanges/LP_privkey.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_privkey.c b/iguana/exchanges/LP_privkey.c index a6aaba44f..ad94eba89 100644 --- a/iguana/exchanges/LP_privkey.c +++ b/iguana/exchanges/LP_privkey.c @@ -262,7 +262,7 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan } if ( passphrase != 0 && passphrase[0] != 0 ) { - if ( strlen(passphrase) == 130 && passphrase[0] == '0' && passphrase[1] == 'x' && is_hexstr(passhrase+2,0) == 128 ) + if ( strlen(passphrase) == 130 && passphrase[0] == '0' && passphrase[1] == 'x' && is_hexstr(passphrase+2,0) == 128 ) { decode_hex(privkey.bytes,64,passphrase+2); printf("ETH style privkey.(%s)\n",passphrase); From 029857a3a2a752ea0dde6d9e98845133761e373c Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 12:15:05 +0200 Subject: [PATCH 052/197] Test --- iguana/exchanges/LP_privkey.c | 1 + 1 file changed, 1 insertion(+) diff --git a/iguana/exchanges/LP_privkey.c b/iguana/exchanges/LP_privkey.c index ad94eba89..58e81a861 100644 --- a/iguana/exchanges/LP_privkey.c +++ b/iguana/exchanges/LP_privkey.c @@ -269,6 +269,7 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan } else { + printf("strlen %ld (%s)\n",strlen(passphrase),passphrase); calc_NXTaddr(G.LP_NXTaddr,userpub.bytes,(uint8_t *)passphrase,(int32_t)strlen(passphrase)); conv_NXTpassword(privkey.bytes,pubkeyp->bytes,(uint8_t *)passphrase,(int32_t)strlen(passphrase)); privkey.bytes[0] &= 248, privkey.bytes[31] &= 127, privkey.bytes[31] |= 64; From d46a75cc7782b751be0932c77b9b5af41b9ace6e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 12:16:03 +0200 Subject: [PATCH 053/197] Test --- iguana/exchanges/LP_privkey.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_privkey.c b/iguana/exchanges/LP_privkey.c index 58e81a861..aff0ff799 100644 --- a/iguana/exchanges/LP_privkey.c +++ b/iguana/exchanges/LP_privkey.c @@ -262,14 +262,13 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan } if ( passphrase != 0 && passphrase[0] != 0 ) { - if ( strlen(passphrase) == 130 && passphrase[0] == '0' && passphrase[1] == 'x' && is_hexstr(passphrase+2,0) == 128 ) + if ( strlen(passphrase) == 66 && passphrase[0] == '0' && passphrase[1] == 'x' && is_hexstr(passphrase+2,0) == 64 ) { - decode_hex(privkey.bytes,64,passphrase+2); + decode_hex(privkey.bytes,32,passphrase+2); printf("ETH style privkey.(%s)\n",passphrase); } else { - printf("strlen %ld (%s)\n",strlen(passphrase),passphrase); calc_NXTaddr(G.LP_NXTaddr,userpub.bytes,(uint8_t *)passphrase,(int32_t)strlen(passphrase)); conv_NXTpassword(privkey.bytes,pubkeyp->bytes,(uint8_t *)passphrase,(int32_t)strlen(passphrase)); privkey.bytes[0] &= 248, privkey.bytes[31] &= 127, privkey.bytes[31] |= 64; From b9f3248456553e2e1ea04979cdaed9bb9e76955e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 12:22:05 +0200 Subject: [PATCH 054/197] Test --- iguana/exchanges/LP_privkey.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_privkey.c b/iguana/exchanges/LP_privkey.c index aff0ff799..1915c0356 100644 --- a/iguana/exchanges/LP_privkey.c +++ b/iguana/exchanges/LP_privkey.c @@ -265,7 +265,7 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan if ( strlen(passphrase) == 66 && passphrase[0] == '0' && passphrase[1] == 'x' && is_hexstr(passphrase+2,0) == 64 ) { decode_hex(privkey.bytes,32,passphrase+2); - printf("ETH style privkey.(%s)\n",passphrase); + //printf("ETH style privkey.(%s)\n",passphrase); } else { @@ -299,6 +299,7 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan RS_encode(G.LP_NXTaddr,nxtaddr); } bitcoin_priv2pub(ctx,coin->symbol,coin->pubkey33,coin->smartaddr,privkey,coin->taddr,coin->pubtype); + if ( coin->etomic[0] != 0 ) { uint8_t check64[64]; char checkaddr[64],checkaddr2[64]; if ( LP_etomic_priv2pub(check64,privkey) == 0 ) @@ -307,7 +308,8 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan { if ( LP_etomic_priv2addr(checkaddr,privkey) == 0 && LP_etomic_pub2addr(checkaddr2,check64) == 0 && strcmp(checkaddr,checkaddr2) == 0 ) { - printf("addr is (%s)\n",checkaddr); + //printf("addr is (%s)\n",checkaddr); + strcpy(coin->smartaddr,checkaddr); } else printf("error getting addr (%s) != (%s)\n",checkaddr,checkaddr2); } else printf("pubkey 64 mismatch\n"); } else printf("error creating pubkey\n"); From e3e6c6d0f61159b91741fde508ed812c167e3ada Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 12:27:12 +0200 Subject: [PATCH 055/197] Test --- iguana/mini-gmp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/iguana/mini-gmp.c b/iguana/mini-gmp.c index f39c66f69..be2dfdb73 100644 --- a/iguana/mini-gmp.c +++ b/iguana/mini-gmp.c @@ -4402,7 +4402,9 @@ int32_t bitcoin_base58decode(uint8_t *data,char *coinaddr) p++; if ( *p != '\0' ) { + int32_t zeroval(); printf("bitcoin_base58decode error: p %02x != 0x00\n",*p); + printf("div0 %d\n",1/zeroval()); mpz_clear(bn), mpz_clear(bn58); return(-1); } From 4d8d6f397a68f0a33174a0143988c0d6ae93bf5e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 12:37:42 +0200 Subject: [PATCH 056/197] Addr2rmd160 for 0x --- iguana/exchanges/LP_bitcoin.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_bitcoin.c b/iguana/exchanges/LP_bitcoin.c index 0343acc0b..4e6302efd 100644 --- a/iguana/exchanges/LP_bitcoin.c +++ b/iguana/exchanges/LP_bitcoin.c @@ -2052,11 +2052,14 @@ bits256 bits256_calcaddrhash(char *symbol,uint8_t *serialized,int32_t len) int32_t bitcoin_addr2rmd160(char *symbol,uint8_t taddr,uint8_t *addrtypep,uint8_t rmd160[20],char *coinaddr) { bits256 hash; uint8_t *buf,_buf[26],data5[128],rmd21[21]; char prefixaddr[64],hrp[64]; int32_t len,len5,offset; + *addrtypep = 0; + memset(rmd160,0,20); if ( coinaddr == 0 || coinaddr[0] == 0 ) - { - *addrtypep = 0; - memset(rmd160,0,20); return(0); + if ( coinaddr[0] == '0' && coinaddr[1] == 'x' && is_hexstr(coinaddr+2,0) == 40 ) + { + decode_hex(rmd160,20,coinaddr+2); // not rmd160 hash but hopefully close enough; + return(20); } if ( strcmp(symbol,"BCH") == 0 )//&& strlen(coinaddr) == 42 ) { From b1ea433d0f75401793cb9c3b96f7ec8a3164ca65 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Wed, 7 Feb 2018 17:43:09 +0700 Subject: [PATCH 057/197] Add methods to get ETH and ERC20 balance. --- iguana/exchanges/etomicswap/bob.c | 35 +++++++++++++--- iguana/exchanges/etomicswap/etomiccurl.c | 50 +++++++++++++++++++++++ iguana/exchanges/etomicswap/etomiccurl.h | 2 + iguana/exchanges/etomicswap/etomiclib.cpp | 23 +++++++++++ iguana/exchanges/etomicswap/etomiclib.h | 4 ++ 5 files changed, 109 insertions(+), 5 deletions(-) diff --git a/iguana/exchanges/etomicswap/bob.c b/iguana/exchanges/etomicswap/bob.c index a4d18d6df..ede02320d 100644 --- a/iguana/exchanges/etomicswap/bob.c +++ b/iguana/exchanges/etomicswap/bob.c @@ -4,8 +4,8 @@ #include #include #include +#include #include "etomiclib.h" -#include char* bobContractAddress = "0x9387Fd3a016bB0205e4e131Dde886B9d2BC000A2"; char* aliceAddress = "0x485d2cc2d13a9e12E4b53D606DB1c8adc884fB8a"; @@ -23,9 +23,11 @@ int main(int argc, char** argv) BOB_ERC20_PAYMENT, BOB_CLAIMS_PAYMENT, ALICE_CLAIMS_PAYMENT, - BOB_APPROVES_ERC20 + BOB_APPROVES_ERC20, + BOB_ETH_BALANCE, + BOB_ERC20_BALANCE, }; - if (argc < 3) { + if (argc < 2) { return 1; } int action = atoi(argv[1]); @@ -46,6 +48,8 @@ int main(int argc, char** argv) }; result = bobSendsEthDeposit(input, txData); + printf("%s\n", result); + free(result); break; case BOB_ERC20_DEPOSIT: txData.amount = "0"; @@ -62,6 +66,8 @@ int main(int argc, char** argv) }; result = bobSendsErc20Deposit(input1, txData); + printf("%s\n", result); + free(result); break; case BOB_CLAIMS_DEPOSIT: txData.amount = "0"; @@ -79,6 +85,8 @@ int main(int argc, char** argv) }; result = bobRefundsDeposit(input2, txData); + printf("%s\n", result); + free(result); break; case ALICE_CLAIMS_DEPOSIT: txData.amount = "0"; @@ -96,6 +104,8 @@ int main(int argc, char** argv) }; result = aliceClaimsBobDeposit(input3, txData); + printf("%s\n", result); + free(result); break; case BOB_ETH_PAYMENT: txData.amount = "1000000000000000000"; @@ -110,6 +120,8 @@ int main(int argc, char** argv) }; result = bobSendsEthPayment(input4, txData); + printf("%s\n", result); + free(result); break; case BOB_ERC20_PAYMENT: txData.amount = "0"; @@ -126,6 +138,8 @@ int main(int argc, char** argv) }; result = bobSendsErc20Payment(input5, txData); + printf("%s\n", result); + free(result); break; case BOB_CLAIMS_PAYMENT: txData.amount = "0"; @@ -143,6 +157,8 @@ int main(int argc, char** argv) }; result = bobReclaimsBobPayment(input6, txData); + printf("%s\n", result); + free(result); break; case ALICE_CLAIMS_PAYMENT: txData.amount = "0"; @@ -160,18 +176,27 @@ int main(int argc, char** argv) }; result = aliceSpendsBobPayment(input7, txData); + printf("%s\n", result); + free(result); break; case BOB_APPROVES_ERC20: result = approveErc20( "10000000000000000000", "0xA7EF3f65714AE266414C9E58bB4bAa4E6FB82B41", getenv("BOB_PK") + ); + printf("%s\n", result); + free(result); + break; + case BOB_ETH_BALANCE: + printf("%" PRIu64 "\n", getEthBalance(bobAddress)); + break; + case BOB_ERC20_BALANCE: + printf("%" PRIu64 "\n", getErc20Balance(bobAddress, tokenAddress)); break; default: return 1; } - printf("%s\n", result); - free(result); return 0; } diff --git a/iguana/exchanges/etomicswap/etomiccurl.c b/iguana/exchanges/etomicswap/etomiccurl.c index 9bb98ec31..f8e3958be 100644 --- a/iguana/exchanges/etomicswap/etomiccurl.c +++ b/iguana/exchanges/etomicswap/etomiccurl.c @@ -86,6 +86,7 @@ char* sendRawTx(char* rawTx) char* tmp = cJSON_GetObjectItem(json, "result")->valuestring; char* txId = (char*)malloc(strlen(tmp) + 1); strcpy(txId, tmp); + cJSON_Delete(json); free(requestResult); return txId; } @@ -110,3 +111,52 @@ int getNonce(char* address) free(requestResult); return nonce; } + +char* getEthBalanceRequest(char* address) +{ + char* string; + cJSON *request = cJSON_CreateObject(); + cJSON *params = cJSON_CreateArray(); + cJSON_AddItemToObject(request, "jsonrpc", cJSON_CreateString("2.0")); + cJSON_AddItemToObject(request, "method", cJSON_CreateString("eth_getBalance")); + cJSON_AddItemToArray(params, cJSON_CreateString(address)); + cJSON_AddItemToArray(params, cJSON_CreateString("latest")); + cJSON_AddItemToObject(request, "params", params); + cJSON_AddItemToObject(request, "id", cJSON_CreateNumber(2)); + string = cJSON_PrintUnformatted(request); + char* requestResult = sendRequest(string); + cJSON_Delete(request); + cJSON *json = cJSON_Parse(requestResult); + char* tmp = cJSON_GetObjectItem(json, "result")->valuestring; + char* balance = (char*)malloc(strlen(tmp) + 1); + strcpy(balance, tmp); + cJSON_Delete(json); + free(requestResult); + return balance; +} + +char* ethCall(char* to, const char* data) +{ + char* string; + cJSON *request = cJSON_CreateObject(); + cJSON *params = cJSON_CreateArray(); + cJSON *txObject = cJSON_CreateObject(); + cJSON_AddItemToObject(request, "jsonrpc", cJSON_CreateString("2.0")); + cJSON_AddItemToObject(request, "method", cJSON_CreateString("eth_call")); + cJSON_AddStringToObject(txObject, "to", to); + cJSON_AddStringToObject(txObject, "data", data); + cJSON_AddItemToArray(params, txObject); + cJSON_AddItemToArray(params, cJSON_CreateString("latest")); + cJSON_AddItemToObject(request, "params", params); + cJSON_AddItemToObject(request, "id", cJSON_CreateNumber(2)); + string = cJSON_PrintUnformatted(request); + char* requestResult = sendRequest(string); + cJSON_Delete(request); + cJSON *json = cJSON_Parse(requestResult); + char* tmp = cJSON_GetObjectItem(json, "result")->valuestring; + char* balance = (char*)malloc(strlen(tmp) + 1); + strcpy(balance, tmp); + cJSON_Delete(json); + free(requestResult); + return balance; +} diff --git a/iguana/exchanges/etomicswap/etomiccurl.h b/iguana/exchanges/etomicswap/etomiccurl.h index 339f8bf19..54e71d4d5 100644 --- a/iguana/exchanges/etomicswap/etomiccurl.h +++ b/iguana/exchanges/etomicswap/etomiccurl.h @@ -3,7 +3,9 @@ extern "C"{ #endif char* sendRawTx(char* rawTx); +char* ethCall(char* to, const char* data); int getNonce(char* address); +char* getEthBalanceRequest(char* address); #ifdef __cplusplus } diff --git a/iguana/exchanges/etomicswap/etomiclib.cpp b/iguana/exchanges/etomicswap/etomiclib.cpp index cd8432e29..5e3fe6e2b 100644 --- a/iguana/exchanges/etomicswap/etomiclib.cpp +++ b/iguana/exchanges/etomicswap/etomiclib.cpp @@ -332,3 +332,26 @@ char* getPubKeyFromPriv(char* privKey) ss << "0x" << publicKey; return stringStreamToChar(ss); } + +uint64_t getEthBalance(char* address) +{ + char* hexBalance = getEthBalanceRequest(address); + // convert wei to satoshi + u256 balance = jsToU256(hexBalance) / exp10<10>(); + free(hexBalance); + return static_cast(balance); +} + +uint64_t getErc20Balance(char* address, char* tokenAddress) +{ + 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 + u256 balance = jsToU256(hexBalance) / exp10<10>(); + free(hexBalance); + return static_cast(balance); +} diff --git a/iguana/exchanges/etomicswap/etomiclib.h b/iguana/exchanges/etomicswap/etomiclib.h index 851a7ee11..a5267eb4a 100644 --- a/iguana/exchanges/etomicswap/etomiclib.h +++ b/iguana/exchanges/etomicswap/etomiclib.h @@ -1,6 +1,8 @@ // // Created by artem on 24.01.18. // +#include + #ifdef __cplusplus extern "C" { #endif @@ -125,6 +127,8 @@ char* aliceSpendsBobPayment(AliceSpendsBobPaymentInput input, BasicTxData txData char* privKey2Addr(char* privKey); char* pubKey2Addr(char* pubKey); char* getPubKeyFromPriv(char* privKey); +uint64_t getEthBalance(char* address); +uint64_t getErc20Balance(char* address, char* tokenAddress); // Your prototype or Definition #ifdef __cplusplus } From ca44b554c511f65f36547df9360f25bac04b99a8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 12:57:00 +0200 Subject: [PATCH 058/197] Test --- iguana/exchanges/LP_bitcoin.c | 31 ++++++++++++++++++++++++++++++- iguana/exchanges/LP_include.h | 1 + iguana/exchanges/LP_secp.c | 17 +++++++++++++++++ iguana/mini-gmp.c | 1 - 4 files changed, 48 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_bitcoin.c b/iguana/exchanges/LP_bitcoin.c index 4e6302efd..b0c7fd14c 100644 --- a/iguana/exchanges/LP_bitcoin.c +++ b/iguana/exchanges/LP_bitcoin.c @@ -2113,7 +2113,36 @@ int32_t bitcoin_addr2rmd160(char *symbol,uint8_t taddr,uint8_t *addrtypep,uint8_ char *bitcoin_address(char *symbol,char *coinaddr,uint8_t taddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160,int32_t len) { - int32_t offset,i,len5; char prefixed[64]; uint8_t data[64],data5[64]; bits256 hash; + static void *ctx; + int32_t offset,i,len5; char prefixed[64]; uint8_t data[64],data5[64],bigpubkey[65]; bits256 hash; struct iguana_info *coin; + if ( (coin= LP_coinfind(symbol)) != 0 && coin->etomic[0] != 0 ) + { + if ( len == 20 ) + { + strcpy(coinaddr,"0x"); + init_hexbytes_noT(coinaddr+2,pubkey_or_rmd160,20); + return(coinaddr); + } + else if ( len == 33 || len == 65 ) + { + strcpy(coinaddr,"0x"); + if ( len == 33 ) + { + if ( ctx == 0 ) + ctx = bitcoin_ctx(); + bitcoin_expandcompressed(ctx,bigpubkey,pubkey_or_rmd160); + LP_etomic_pub2addr(coinaddr+2,bigpubkey+1); + for (i=0; i<33; i++) + printf("%02x",pubkey_or_rmd160[i]); + printf(" compressed -> "); + for (i=0; i<65; i++) + printf("%02x",bigpubkey[i]); + printf(" -> %s\n",coinaddr); + } + else LP_etomic_pub2addr(coinaddr+2,pubkey_or_rmd160+1); + return(coinaddr); + } + } coinaddr[0] = 0; offset = 1 + (taddr != 0); if ( len != 20 ) diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index 3fcd09051..6d75f7390 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -546,6 +546,7 @@ void LP_postutxos(char *symbol,char *coinaddr); int32_t LP_listunspent_both(char *symbol,char *coinaddr,int32_t fullflag); uint16_t LP_randpeer(char *destip); void LP_tradebot_pauseall(); +int32_t LP_etomic_pub2addr(char *coinaddr,uint8_t pub64[64]); void LP_portfolio_reset(); struct LP_pubkey_info *LP_pubkeyadd(bits256 pubkey); uint32_t LP_atomic_locktime(char *base,char *rel); diff --git a/iguana/exchanges/LP_secp.c b/iguana/exchanges/LP_secp.c index 516e2be75..19452337b 100644 --- a/iguana/exchanges/LP_secp.c +++ b/iguana/exchanges/LP_secp.c @@ -191,3 +191,20 @@ int32_t bitcoin_verify(void *ctx,uint8_t *sig,int32_t siglen,bits256 txhash2,uin } return(retval); } + +int32_t bitcoin_expandcompressed(void *ctx,uint8_t *bigpubkey,uint8_t *pub33) +{ + int32_t retval = -1; secp256k1_pubkey PUB; size_t plen = 65; + SECP_ENSURE_CTX + { + if ( secp256k1_ec_pubkey_parse(ctx,&PUB,pub33,33) != 0 ) + { + secp256k1_ec_pubkey_serialize(ctx,bigpubkey,&plen,&PUB,SECP256K1_EC_UNCOMPRESSED); + retval = 0; + } + ENDSECP_ENSURE_CTX + } + return(retval); +} + + diff --git a/iguana/mini-gmp.c b/iguana/mini-gmp.c index be2dfdb73..99cb68222 100644 --- a/iguana/mini-gmp.c +++ b/iguana/mini-gmp.c @@ -4404,7 +4404,6 @@ int32_t bitcoin_base58decode(uint8_t *data,char *coinaddr) { int32_t zeroval(); printf("bitcoin_base58decode error: p %02x != 0x00\n",*p); - printf("div0 %d\n",1/zeroval()); mpz_clear(bn), mpz_clear(bn58); return(-1); } From 2f3fbe5add63f22cb57af680e0417e75f4d92c1f Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 13:00:50 +0200 Subject: [PATCH 059/197] Test --- iguana/exchanges/LP_privkey.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_privkey.c b/iguana/exchanges/LP_privkey.c index 1915c0356..a5b356f3e 100644 --- a/iguana/exchanges/LP_privkey.c +++ b/iguana/exchanges/LP_privkey.c @@ -301,7 +301,7 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan bitcoin_priv2pub(ctx,coin->symbol,coin->pubkey33,coin->smartaddr,privkey,coin->taddr,coin->pubtype); if ( coin->etomic[0] != 0 ) { - uint8_t check64[64]; char checkaddr[64],checkaddr2[64]; + uint8_t check64[64],checktype,checkrmd160[20]; char checkaddr[64],checkaddr2[64]; if ( LP_etomic_priv2pub(check64,privkey) == 0 ) { if ( memcmp(check64,coin->pubkey33+1,32) == 0 ) @@ -310,6 +310,8 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan { //printf("addr is (%s)\n",checkaddr); strcpy(coin->smartaddr,checkaddr); + decode_hex(checkrmd160,20,checkaddr+2); + bitcoin_addr2rmd160(coin->symbol,coin->taddr,&checktype,checkrmd160,checkaddr); } else printf("error getting addr (%s) != (%s)\n",checkaddr,checkaddr2); } else printf("pubkey 64 mismatch\n"); } else printf("error creating pubkey\n"); From 3f19dc7c19618e2e5f87105b0e87d66c0cbfdc6e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 13:03:16 +0200 Subject: [PATCH 060/197] Test --- iguana/exchanges/LP_privkey.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_privkey.c b/iguana/exchanges/LP_privkey.c index a5b356f3e..1add9c335 100644 --- a/iguana/exchanges/LP_privkey.c +++ b/iguana/exchanges/LP_privkey.c @@ -301,7 +301,7 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan bitcoin_priv2pub(ctx,coin->symbol,coin->pubkey33,coin->smartaddr,privkey,coin->taddr,coin->pubtype); if ( coin->etomic[0] != 0 ) { - uint8_t check64[64],checktype,checkrmd160[20]; char checkaddr[64],checkaddr2[64]; + uint8_t check64[64],checktype,checkrmd160[20],rmd160[20]; char checkaddr[64],checkaddr2[64]; if ( LP_etomic_priv2pub(check64,privkey) == 0 ) { if ( memcmp(check64,coin->pubkey33+1,32) == 0 ) @@ -311,7 +311,9 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan //printf("addr is (%s)\n",checkaddr); strcpy(coin->smartaddr,checkaddr); decode_hex(checkrmd160,20,checkaddr+2); - bitcoin_addr2rmd160(coin->symbol,coin->taddr,&checktype,checkrmd160,checkaddr); + bitcoin_addr2rmd160(coin->symbol,coin->taddr,&checktype,rmd160,checkaddr); + if ( memcmp(rmd160,checkrmd160,20) == 0 ) + printf("rmd160 matches\n"); } else printf("error getting addr (%s) != (%s)\n",checkaddr,checkaddr2); } else printf("pubkey 64 mismatch\n"); } else printf("error creating pubkey\n"); From 484392ed326726b3dfdabea30df941a4f996b7dd Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 13:07:53 +0200 Subject: [PATCH 061/197] Test --- iguana/exchanges/LP_bitcoin.c | 8 +++----- iguana/exchanges/LP_privkey.c | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/iguana/exchanges/LP_bitcoin.c b/iguana/exchanges/LP_bitcoin.c index b0c7fd14c..c55bdefc1 100644 --- a/iguana/exchanges/LP_bitcoin.c +++ b/iguana/exchanges/LP_bitcoin.c @@ -2125,21 +2125,19 @@ char *bitcoin_address(char *symbol,char *coinaddr,uint8_t taddr,uint8_t addrtype } else if ( len == 33 || len == 65 ) { - strcpy(coinaddr,"0x"); if ( len == 33 ) { if ( ctx == 0 ) ctx = bitcoin_ctx(); bitcoin_expandcompressed(ctx,bigpubkey,pubkey_or_rmd160); LP_etomic_pub2addr(coinaddr+2,bigpubkey+1); - for (i=0; i<33; i++) + /*for (i=0; i<33; i++) printf("%02x",pubkey_or_rmd160[i]); printf(" compressed -> "); for (i=0; i<65; i++) printf("%02x",bigpubkey[i]); - printf(" -> %s\n",coinaddr); - } - else LP_etomic_pub2addr(coinaddr+2,pubkey_or_rmd160+1); + printf(" -> %s\n",coinaddr);*/ + } else LP_etomic_pub2addr(coinaddr,pubkey_or_rmd160+1); return(coinaddr); } } diff --git a/iguana/exchanges/LP_privkey.c b/iguana/exchanges/LP_privkey.c index 1add9c335..e6321820d 100644 --- a/iguana/exchanges/LP_privkey.c +++ b/iguana/exchanges/LP_privkey.c @@ -312,8 +312,8 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan strcpy(coin->smartaddr,checkaddr); decode_hex(checkrmd160,20,checkaddr+2); bitcoin_addr2rmd160(coin->symbol,coin->taddr,&checktype,rmd160,checkaddr); - if ( memcmp(rmd160,checkrmd160,20) == 0 ) - printf("rmd160 matches\n"); + if ( memcmp(rmd160,checkrmd160,20) != 0 ) + printf("rmd160 doesnt match\n"); } else printf("error getting addr (%s) != (%s)\n",checkaddr,checkaddr2); } else printf("pubkey 64 mismatch\n"); } else printf("error creating pubkey\n"); From a9b4f6664b8be7e1c6eb4cbe81c4c64fbf0b666b Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 13:38:50 +0200 Subject: [PATCH 062/197] Test --- README.md | 16 +++++++--------- iguana/exchanges/LP_signatures.c | 1 + iguana/exchanges/mm.c | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 291e5f720..4a5d94898 100755 --- a/README.md +++ b/README.md @@ -260,12 +260,10 @@ The iguana binary and its linked libraries are in ```$HOME/tmp/iguana```. 0. `make sure g++-7 ln to /usr/bin/g++` 1. `cd ~/SuperNET` 2. `git checkout etomic` -3. `git submodule add https://github.com/artemii235/cpp-ethereum` -4. `git submodule update --init --recursive` -5. `mkdir build` -6. `cd build` -7. `cmake ..` -8. `cmake --build . --target marketmaker` -9. `cd build/iguana/exchanges` -10. `export BOB_PK=YOUR_PRIVATE_KEY` #export BOB_PK=59a03784447e3b24d2deb7231236d549502e4e806550aca4ab6a5532b003da25 -11. `./marketmaker` +3. `git submodule update --init --recursive` +4. `mkdir build` +5. `cd build` +6. `cmake ..` +7. `cmake --build . --target marketmaker` +8. `cd build/iguana/exchanges` +9. `./marketmaker` diff --git a/iguana/exchanges/LP_signatures.c b/iguana/exchanges/LP_signatures.c index 19f8a9622..e71f02131 100644 --- a/iguana/exchanges/LP_signatures.c +++ b/iguana/exchanges/LP_signatures.c @@ -444,6 +444,7 @@ char *LP_pricepings(void *ctx,char *myipaddr,int32_t pubsock,char *base,char *re jaddnum(reqjson,"max",dstr(maxsize)); } LP_price_sigadd(reqjson,timestamp,G.LP_privkey,G.LP_pubsecp,G.LP_mypub25519,base,rel,price64); + printf("priceping.(%s)\n",jprint(reqjson,0)); LP_reserved_msg(0,base,rel,zero,jprint(reqjson,1)); return(clonestr("{\"result\":\"success\"}")); } else return(clonestr("{\"error\":\"electrum node cant post bob asks\"}")); diff --git a/iguana/exchanges/mm.c b/iguana/exchanges/mm.c index 5544523f1..e25c729de 100644 --- a/iguana/exchanges/mm.c +++ b/iguana/exchanges/mm.c @@ -133,7 +133,7 @@ int main(int argc, const char * argv[]) { char dirname[512],*passphrase; double incr; cJSON *retjson; OS_init(); - ETH_test(); + //ETH_test(); if ( strstr(argv[0],"btc2kmd") != 0 && argv[1] != 0 ) { uint8_t addrtype,rmd160[20],rmd160b[20]; char coinaddr[64],coinaddr2[64]; From 2df5ae67c30fc05b706e798495ebe6bbd2d85680 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 13:47:38 +0200 Subject: [PATCH 063/197] Test --- iguana/exchanges/LP_signatures.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_signatures.c b/iguana/exchanges/LP_signatures.c index e71f02131..afd346bc7 100644 --- a/iguana/exchanges/LP_signatures.c +++ b/iguana/exchanges/LP_signatures.c @@ -453,7 +453,7 @@ char *LP_pricepings(void *ctx,char *myipaddr,int32_t pubsock,char *base,char *re char *LP_postprice_recv(cJSON *argjson) { bits256 pubkey; double price; char *base,*rel; - //printf("PRICE POSTED.(%s)\n",jprint(argjson,0)); + printf("PRICE POSTED.(%s)\n",jprint(argjson,0)); if ( (base= jstr(argjson,"base")) != 0 && (rel= jstr(argjson,"rel")) != 0 && (price= jdouble(argjson,"price")) > SMALLVAL ) { pubkey = jbits256(argjson,"pubkey"); From 5954837479d7a01d53d4ab38621d55a05865f67e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 14:46:03 +0200 Subject: [PATCH 064/197] test --- iguana/exchanges/LP_prices.c | 2 +- iguana/exchanges/LP_rpc.c | 2 +- iguana/exchanges/LP_signatures.c | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_prices.c b/iguana/exchanges/LP_prices.c index a887331da..5967db7a5 100644 --- a/iguana/exchanges/LP_prices.c +++ b/iguana/exchanges/LP_prices.c @@ -811,7 +811,7 @@ int32_t LP_orderbook_utxoentries(uint32_t now,int32_t polarity,char *base,char * } if ( pubp->timestamp < oldest ) continue; - bitcoin_address(base,coinaddr,basecoin->taddr,basecoin->pubtype,pubp->rmd160,sizeof(pubp->rmd160)); + bitcoin_address(base,coinaddr,basecoin->taddr,basecoin->pubtype,pubp->pubsecp,33); avesatoshis = maxsatoshis = n = 0; ap = 0; if ( (price= LP_pubkey_price(&n,&avesatoshis,&maxsatoshis,pubp,baseid,relid)) > SMALLVAL ) //pubp->matrix[baseid][relid]) > SMALLVAL )//&& pubp->timestamps[baseid][relid] >= oldest ) diff --git a/iguana/exchanges/LP_rpc.c b/iguana/exchanges/LP_rpc.c index 21e226cc0..dae5be58e 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -316,7 +316,7 @@ cJSON *LP_validateaddress(char *symbol,char *address) strcat(script,"88ac"); jaddstr(retjson,"scriptPubKey",script); } - bitcoin_address(symbol,coinaddr,coin->taddr,coin->pubtype,G.LP_myrmd160,20); + bitcoin_address(symbol,coinaddr,coin->taddr,coin->pubtype,G.LP_pubsecp,33); jadd(retjson,"ismine",strcmp(coinaddr,coin->smartaddr) == 0 ? cJSON_CreateTrue() : cJSON_CreateFalse()); jadd(retjson,"iswatchonly",cJSON_CreateTrue()); jadd(retjson,"isscript",addrtype == coin->p2shtype ? cJSON_CreateTrue() : cJSON_CreateFalse()); diff --git a/iguana/exchanges/LP_signatures.c b/iguana/exchanges/LP_signatures.c index afd346bc7..3d0f35139 100644 --- a/iguana/exchanges/LP_signatures.c +++ b/iguana/exchanges/LP_signatures.c @@ -444,7 +444,6 @@ char *LP_pricepings(void *ctx,char *myipaddr,int32_t pubsock,char *base,char *re jaddnum(reqjson,"max",dstr(maxsize)); } LP_price_sigadd(reqjson,timestamp,G.LP_privkey,G.LP_pubsecp,G.LP_mypub25519,base,rel,price64); - printf("priceping.(%s)\n",jprint(reqjson,0)); LP_reserved_msg(0,base,rel,zero,jprint(reqjson,1)); return(clonestr("{\"result\":\"success\"}")); } else return(clonestr("{\"error\":\"electrum node cant post bob asks\"}")); From d7a5da05ae8b0d77c091d04cd3ba08648a04b79f Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 14:57:18 +0200 Subject: [PATCH 065/197] Test --- iguana/exchanges/LP_bitcoin.c | 2 +- iguana/exchanges/LP_privkey.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_bitcoin.c b/iguana/exchanges/LP_bitcoin.c index c55bdefc1..02941c337 100644 --- a/iguana/exchanges/LP_bitcoin.c +++ b/iguana/exchanges/LP_bitcoin.c @@ -2130,7 +2130,7 @@ char *bitcoin_address(char *symbol,char *coinaddr,uint8_t taddr,uint8_t addrtype if ( ctx == 0 ) ctx = bitcoin_ctx(); bitcoin_expandcompressed(ctx,bigpubkey,pubkey_or_rmd160); - LP_etomic_pub2addr(coinaddr+2,bigpubkey+1); + LP_etomic_pub2addr(coinaddr,bigpubkey+1); /*for (i=0; i<33; i++) printf("%02x",pubkey_or_rmd160[i]); printf(" compressed -> "); diff --git a/iguana/exchanges/LP_privkey.c b/iguana/exchanges/LP_privkey.c index e6321820d..7f78ce73d 100644 --- a/iguana/exchanges/LP_privkey.c +++ b/iguana/exchanges/LP_privkey.c @@ -318,7 +318,7 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan } else printf("pubkey 64 mismatch\n"); } else printf("error creating pubkey\n"); } - if ( coin->counter == 0 ) + if ( coin->counter == 0 && coin->etomic[0] == 0 ) { coin->counter++; memcpy(G.LP_pubsecp,coin->pubkey33,33); From 3d9a5b51a6f3cd8967bcfaee8207cda2252752f4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 15:45:22 +0200 Subject: [PATCH 066/197] Test --- etomic_build/enable | 1 + iguana/exchanges/LP_ordermatch.c | 4 ++++ iguana/exchanges/LP_signatures.c | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/etomic_build/enable b/etomic_build/enable index c51c0810d..0bcf62166 100755 --- a/etomic_build/enable +++ b/etomic_build/enable @@ -2,3 +2,4 @@ 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\"}" diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index 447a1f43f..e58294ca3 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -380,6 +380,10 @@ uint64_t LP_basesatoshis(double relvolume,double price,uint64_t txfee,uint64_t d struct LP_utxoinfo *LP_address_myutxopair(struct LP_utxoinfo *butxo,int32_t iambob,struct LP_address_utxo **utxos,int32_t max,struct iguana_info *coin,char *coinaddr,uint64_t txfee,double relvolume,double price,uint64_t desttxfee) { struct LP_address *ap; uint64_t fee,targetval,targetval2; int32_t m,mini; struct LP_address_utxo *up,*up2; double ratio; + if ( coin->etomic[0] != 0 ) + coin = LP_coinfind("ETOMIC"); + if ( coin == 0 ) + return(0); memset(butxo,0,sizeof(*butxo)); if ( iambob != 0 ) { diff --git a/iguana/exchanges/LP_signatures.c b/iguana/exchanges/LP_signatures.c index 3d0f35139..19f8a9622 100644 --- a/iguana/exchanges/LP_signatures.c +++ b/iguana/exchanges/LP_signatures.c @@ -452,7 +452,7 @@ char *LP_pricepings(void *ctx,char *myipaddr,int32_t pubsock,char *base,char *re char *LP_postprice_recv(cJSON *argjson) { bits256 pubkey; double price; char *base,*rel; - printf("PRICE POSTED.(%s)\n",jprint(argjson,0)); + //printf("PRICE POSTED.(%s)\n",jprint(argjson,0)); if ( (base= jstr(argjson,"base")) != 0 && (rel= jstr(argjson,"rel")) != 0 && (price= jdouble(argjson,"price")) > SMALLVAL ) { pubkey = jbits256(argjson,"pubkey"); From f6b7b32926f6b2bdce4204686f94d2702d8bc5c3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 15:57:20 +0200 Subject: [PATCH 067/197] Test --- iguana/exchanges/LP_ordermatch.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index e58294ca3..c8b6b83fd 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -403,7 +403,7 @@ struct LP_utxoinfo *LP_address_myutxopair(struct LP_utxoinfo *butxo,int32_t iamb { if ( (m= LP_address_utxo_ptrs(coin,iambob,utxos,max,ap,coinaddr)) > 1 ) { - if ( 0 ) + if ( 1 ) { int32_t i; for (i=0; i targetval2 %.8f, ratio %.2f\n",mini,dstr(up->U.value),dstr(targetval),dstr(targetval2),(double)up->U.value/targetval); + printf("found mini.%d %.8f for targetval %.8f -> targetval2 %.8f, ratio %.2f\n",mini,dstr(up->U.value),dstr(targetval),dstr(targetval2),(double)up->U.value/targetval); if ( (double)up->U.value/targetval < ratio-1 ) { - if ( 0 ) + if ( 1 ) { int32_t i; for (i=0; isymbol,coinaddr); return(0); } From 42e943150d7c096d53bafed4e5efb7085306c7e6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 15:58:34 +0200 Subject: [PATCH 068/197] Test --- iguana/exchanges/LP_ordermatch.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index c8b6b83fd..318fa66d4 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -381,7 +381,10 @@ struct LP_utxoinfo *LP_address_myutxopair(struct LP_utxoinfo *butxo,int32_t iamb { struct LP_address *ap; uint64_t fee,targetval,targetval2; int32_t m,mini; struct LP_address_utxo *up,*up2; double ratio; if ( coin->etomic[0] != 0 ) - coin = LP_coinfind("ETOMIC"); + { + if ( (coin= LP_coinfind("ETOMIC")) != 0 ) + coinaddr = coin->smartaddr; + } if ( coin == 0 ) return(0); memset(butxo,0,sizeof(*butxo)); @@ -403,7 +406,7 @@ struct LP_utxoinfo *LP_address_myutxopair(struct LP_utxoinfo *butxo,int32_t iamb { if ( (m= LP_address_utxo_ptrs(coin,iambob,utxos,max,ap,coinaddr)) > 1 ) { - if ( 1 ) + if ( 0 ) { int32_t i; for (i=0; iU.value/targetval < ratio-1 ) { - if ( 1 ) + if ( 0 ) { int32_t i; for (i=0; isymbol,coinaddr,dstr(targetval),dstr(targetval2)); } else printf("address_myutxopair couldnt find %s %s\n",coin->symbol,coinaddr); return(0); } From 636faafcb959f5f065ff4ec1567c74527cd233bc Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 16:21:07 +0200 Subject: [PATCH 069/197] Test --- iguana/exchanges/LP_include.h | 2 +- iguana/exchanges/LP_ordermatch.c | 51 +++++++++++++++++++++++--------- 2 files changed, 38 insertions(+), 15 deletions(-) diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index 6d75f7390..b94860c5a 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -58,7 +58,7 @@ void emscripten_usleep(int32_t x); // returns immediate, no sense for sleeping #define LP_MAXVINS 64 #define LP_HTTP_TIMEOUT 3 // 1 is too small due to edge cases of time(NULL) -#define LP_AUTOTRADE_TIMEOUT 180 +#define LP_AUTOTRADE_TIMEOUT 30 #define LP_RESERVETIME 600 //(LP_AUTOTRADE_TIMEOUT * 2) #define ELECTRUM_TIMEOUT 13 #define LP_ELECTRUM_KEEPALIVE 60 diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index 318fa66d4..e9fa25fdf 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -103,27 +103,29 @@ int32_t LP_quote_checkmempool(struct LP_quoteinfo *qp,struct LP_utxoinfo *autxo, double LP_quote_validate(struct LP_utxoinfo *autxo,struct LP_utxoinfo *butxo,struct LP_quoteinfo *qp,int32_t iambob) { - double qprice=0.; char str[65]; cJSON *txout; uint64_t txfee,desttxfee,srcvalue=0,srcvalue2=0,destvalue=0,destvalue2=0; - //printf(">>>>>>> quote satoshis.(%.8f %.8f) %s %.8f -> %s %.8f\n",dstr(qp->satoshis),dstr(qp->destsatoshis),qp->srccoin,dstr(qp->satoshis),qp->destcoin,dstr(qp->destsatoshis)); + double qprice=0.; char str[65],srccoin[65],destcoin[65],bobtomic[64],alicetomic[64]; cJSON *txout; uint64_t txfee,desttxfee,srcvalue=0,srcvalue2=0,destvalue=0,destvalue2=0; + LP_etomicsymbol(srccoin,bobtomic,qp->srccoin); + LP_etomicsymbol(destcoin,alicetomic,qp->destcoin); + //printf(">>>>>>> quote satoshis.(%.8f %.8f) %s %.8f -> %s %.8f\n",dstr(qp->satoshis),dstr(qp->destsatoshis),qp->srccoin,dstr(qp->satoshis),qp->destcoin,dstr(qp->destsatoshis)); if ( butxo != 0 ) { - if ( LP_iseligible(&srcvalue,&srcvalue2,1,qp->srccoin,qp->txid,qp->vout,qp->satoshis,qp->txid2,qp->vout2) == 0 ) + if ( LP_iseligible(&srcvalue,&srcvalue2,1,srccoin,qp->txid,qp->vout,qp->satoshis,qp->txid2,qp->vout2) == 0 ) { //printf("bob not eligible %s (%.8f %.8f)\n",jprint(LP_quotejson(qp),1),dstr(srcvalue),dstr(srcvalue2)); return(-2); } - if ( (txout= LP_gettxout(qp->srccoin,qp->coinaddr,qp->txid,qp->vout)) != 0 ) + if ( (txout= LP_gettxout(srccoin,qp->coinaddr,qp->txid,qp->vout)) != 0 ) free_json(txout); else { - printf("%s %s payment %s/v%d is spent\n",qp->srccoin,qp->coinaddr,bits256_str(str,qp->txid),qp->vout); + printf("%s %s payment %s/v%d is spent\n",srccoin,qp->coinaddr,bits256_str(str,qp->txid),qp->vout); return(-21); } - if ( (txout= LP_gettxout(qp->srccoin,qp->coinaddr,qp->txid2,qp->vout2)) != 0 ) + if ( (txout= LP_gettxout(srccoin,qp->coinaddr,qp->txid2,qp->vout2)) != 0 ) free_json(txout); else { - printf("%s %s deposit %s/v%d is spent\n",qp->srccoin,qp->coinaddr,bits256_str(str,qp->txid2),qp->vout2); + printf("%s %s deposit %s/v%d is spent\n",srccoin,qp->coinaddr,bits256_str(str,qp->txid2),qp->vout2); return(-22); } if ( bits256_cmp(butxo->deposit.txid,qp->txid2) != 0 || butxo->deposit.vout != qp->vout2 ) @@ -139,24 +141,24 @@ double LP_quote_validate(struct LP_utxoinfo *autxo,struct LP_utxoinfo *butxo,str } if ( autxo != 0 ) { - if ( LP_iseligible(&destvalue,&destvalue2,0,qp->destcoin,qp->desttxid,qp->destvout,qp->destsatoshis,qp->feetxid,qp->feevout) == 0 ) + if ( LP_iseligible(&destvalue,&destvalue2,0,destcoin,qp->desttxid,qp->destvout,qp->destsatoshis,qp->feetxid,qp->feevout) == 0 ) { //alice not eligible 0.36893923 -> dest 0.55020000 1.49130251 (0.61732249 0.00104324) 14b8b74808d2d34a70e5eddd1cad47d855858f8b23cac802576d4d37b5f8af8f/v1 abec6e76169bcb738235ca67fab02cc55390f39e422aa71f1badf8747c290cc4/v1 //char str[65],str2[65]; printf("alice not eligible %.8f -> dest %.8f %.8f (%.8f %.8f) %s/v%d %s/v%d\n",dstr(qp->satoshis),dstr(qp->destsatoshis),(double)qp->destsatoshis/qp->satoshis,dstr(destvalue),dstr(destvalue2),bits256_str(str,qp->desttxid),qp->destvout,bits256_str(str2,qp->feetxid),qp->feevout); return(-3); } - if ( (txout= LP_gettxout(qp->destcoin,qp->destaddr,qp->desttxid,qp->destvout)) != 0 ) + if ( (txout= LP_gettxout(destcoin,qp->destaddr,qp->desttxid,qp->destvout)) != 0 ) free_json(txout); else { - printf("%s %s Apayment %s/v%d is spent\n",qp->destcoin,qp->destaddr,bits256_str(str,qp->desttxid),qp->destvout); + printf("%s %s Apayment %s/v%d is spent\n",destcoin,qp->destaddr,bits256_str(str,qp->desttxid),qp->destvout); return(-23); } - if ( (txout= LP_gettxout(qp->destcoin,qp->destaddr,qp->feetxid,qp->feevout)) != 0 ) + if ( (txout= LP_gettxout(destcoin,qp->destaddr,qp->feetxid,qp->feevout)) != 0 ) free_json(txout); else { - printf("%s %s dexfee %s/v%d is spent\n",qp->destcoin,qp->destaddr,bits256_str(str,qp->feetxid),qp->feevout); + printf("%s %s dexfee %s/v%d is spent\n",destcoin,qp->destaddr,bits256_str(str,qp->feetxid),qp->feevout); return(-24); } } @@ -859,8 +861,15 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru { qprice = (double)qp->destsatoshis / (qp->satoshis - qp->txfee); strcpy(qp->gui,G.gui); + if ( coin->etomic[0] != 0 ) + { + struct iguana_info *ecoin; + if ( (ecoin= LP_coinfind("ETOMIC")) != 0 ) + strcpy(qp->coinaddr,ecoin->smartaddr); + else return(0); + } strcpy(qp->coinaddr,coin->smartaddr); - strcpy(butxo->coinaddr,coin->smartaddr); + strcpy(butxo->coinaddr,qp->coinaddr); qp->srchash = G.LP_mypub25519; memset(&qp->txid,0,sizeof(qp->txid)); memset(&qp->txid2,0,sizeof(qp->txid2)); @@ -885,10 +894,17 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru //printf("LP_address_utxo_reset.%s\n",coin->symbol); //LP_address_utxo_reset(coin); //printf("done LP_address_utxo_reset.%s\n",coin->symbol); + if ( coin->etomic[0] != 0 ) + { + struct iguana_info *ecoin; + if ( (ecoin= LP_coinfind("ETOMIC")) != 0 ) + strcpy(qp->coinaddr,ecoin->smartaddr); + else return(0); + } if ( (butxo= LP_address_myutxopair(butxo,1,utxos,max,LP_coinfind(qp->srccoin),qp->coinaddr,qp->txfee,dstr(qp->destsatoshis),price,qp->desttxfee)) != 0 ) { strcpy(qp->gui,G.gui); - strcpy(qp->coinaddr,coin->smartaddr); + //strcpy(qp->coinaddr,coin->smartaddr); qp->srchash = G.LP_mypub25519; qp->txid = butxo->payment.txid; qp->vout = butxo->payment.vout; @@ -1397,6 +1413,13 @@ char *LP_autobuy(void *ctx,char *myipaddr,int32_t mypubsock,char *base,char *rel return(clonestr("{\"error\":\"cant set ordermatch quote\"}")); if ( LP_quotedestinfo(&Q,autxo->payment.txid,autxo->payment.vout,autxo->fee.txid,autxo->fee.vout,G.LP_mypub25519,autxo->coinaddr) < 0 ) return(clonestr("{\"error\":\"cant set ordermatch quote info\"}")); + if ( relcoin->etomic[0] != 0 ) + { + struct iguana_info *coin; + if ( (coin= LP_coinfind("ETOMIC")) != 0 ) + strcpy(Q.destaddr,coin->smartaddr); + else return(clonestr("{\"error\":\"cant find ETOMIC\"}")); + } int32_t changed; LP_mypriceset(&changed,autxo->coin,base,1. / maxprice); LP_mypriceset(&changed,base,autxo->coin,0.); From fad72773fb5369cd640534858de162d5dfb99854 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 16:27:52 +0200 Subject: [PATCH 070/197] Test --- iguana/exchanges/LP_commands.c | 2 +- iguana/exchanges/LP_network.c | 2 +- iguana/exchanges/LP_ordermatch.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index 09fe4ca7d..121238bd0 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -761,7 +761,7 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\ myipaddr = LP_mypeer->ipaddr; else printf("LP_psock dont have actual ipaddr?\n"); } - if ( jint(argjson,"ispaired") != 0 ) + if ( jint(argjson,"ispaired") != 0 && jobj(argjson,"netid") != 0 && juint(argjson,"netid") == G.netid ) { retstr = LP_psock(&psock,myipaddr,1,jint(argjson,"cmdchannel"),jbits256(argjson,"pubkey")); //printf("LP_commands.(%s)\n",retstr); diff --git a/iguana/exchanges/LP_network.c b/iguana/exchanges/LP_network.c index 87c25fd29..a2d754b4b 100644 --- a/iguana/exchanges/LP_network.c +++ b/iguana/exchanges/LP_network.c @@ -831,7 +831,7 @@ char *LP_psock(int32_t *pullsockp,char *ipaddr,int32_t ispaired,int32_t cmdchann char *issue_LP_psock(char *destip,uint16_t destport,int32_t ispaired,int32_t cmdchannel) { char str[65],url[512],*retstr; - sprintf(url,"http://%s:%u/api/stats/psock?ispaired=%d&cmdchannel=%d&pubkey=%s",destip,destport-1,ispaired,cmdchannel,bits256_str(str,G.LP_mypub25519)); + sprintf(url,"http://%s:%u/api/stats/psock?ispaired=%d&cmdchannel=%d&pubkey=%s&netid=%d",destip,destport-1,ispaired,cmdchannel,bits256_str(str,G.LP_mypub25519),G.netid); //return(LP_issue_curl("psock",destip,destport,url)); retstr = issue_curlt(url,LP_HTTP_TIMEOUT*10); printf("issue_LP_psock got (%s) from %s\n",retstr,url); // this is needed?! diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index e9fa25fdf..cc8ce67a0 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -819,7 +819,7 @@ double LP_trades_pricevalidate(struct LP_quoteinfo *qp,struct iguana_info *coin, memset(autxo,0,sizeof(*autxo)); memset(butxo,0,sizeof(*butxo)); LP_abutxo_set(autxo,butxo,qp); - if ( strcmp(qp->coinaddr,coin->smartaddr) != 0 ) + if ( coin->etomic[0] == 0 && strcmp(qp->coinaddr,coin->smartaddr) != 0 ) { printf("bob is patching qp->coinaddr %s mismatch != %s\n",qp->coinaddr,coin->smartaddr); strcpy(qp->coinaddr,coin->smartaddr); From 4e970a1645e676f4c0ed67f2bde3d68f9c8f698a Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 16:34:13 +0200 Subject: [PATCH 071/197] Test --- iguana/exchanges/LP_ordermatch.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index cc8ce67a0..853854656 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -965,10 +965,13 @@ struct LP_quoteinfo *LP_trades_gotconnect(void *ctx,struct LP_quoteinfo *qp,stru qp = newqp; if ( (coin= LP_coinfind(qp->srccoin)) == 0 ) return(0); + printf("check myprice\n"); if ( (myprice= LP_trades_bobprice(&bid,&ask,qp)) == 0. ) return(0); + printf("validate myprice\n"); if ( (qprice= LP_trades_pricevalidate(qp,coin,myprice)) < 0. ) return(0); + printf("check reservation\n"); if ( LP_reservation_check(qp->txid,qp->vout,qp->desthash) == 0 && LP_reservation_check(qp->txid2,qp->vout2,qp->desthash) == 0 ) { LP_connectstartbob(ctx,LP_mypubsock,qp->srccoin,qp->destcoin,qprice,qp); From cb0e3e494af87e709a57ff90558b9f3eb9206c18 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 16:51:14 +0200 Subject: [PATCH 072/197] Test --- iguana/exchanges/LP_utxo.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index f33d8b32f..1c43a5ad4 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -117,8 +117,10 @@ int32_t LP_reservation_check(bits256 txid,int32_t vout,bits256 pubkey) portable_mutex_lock(&LP_inusemutex); if ( (lp= _LP_inuse_find(txid,vout)) != 0 ) { + char str[65],str2[65]; if ( bits256_cmp(lp->otherpub,pubkey) == 0 ) retval = 0; + else printf("otherpub.%s != %s\n",bits256_str(str,lp->otherpub),bits256_str(str2,pubkey)); } portable_mutex_unlock(&LP_inusemutex); } From 9f93e49ec3843110d80cdc324a9c4e7af5367b88 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 16:54:09 +0200 Subject: [PATCH 073/197] Test --- iguana/exchanges/LP_utxo.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index 1c43a5ad4..7cb916861 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -114,16 +114,16 @@ int32_t LP_reservation_check(bits256 txid,int32_t vout,bits256 pubkey) struct LP_inuse_info *lp; int32_t retval = -1; if ( bits256_nonz(pubkey) != 0 ) { + char str[65],str2[65]; portable_mutex_lock(&LP_inusemutex); if ( (lp= _LP_inuse_find(txid,vout)) != 0 ) { - char str[65],str2[65]; if ( bits256_cmp(lp->otherpub,pubkey) == 0 ) retval = 0; else printf("otherpub.%s != %s\n",bits256_str(str,lp->otherpub),bits256_str(str2,pubkey)); - } + } else printf("couldnt find %s/v%d\n",bits256_str(str,txid),vout); portable_mutex_unlock(&LP_inusemutex); - } + } else printf("null pubkey\n"); return(retval); } From 7b1d586cf950e85fbec5704e221768df2d0bb3ca Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 17:01:57 +0200 Subject: [PATCH 074/197] Test --- iguana/exchanges/LP_ordermatch.c | 1 + iguana/exchanges/LP_utxo.c | 1 + 2 files changed, 2 insertions(+) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index 853854656..b8eb2458f 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -974,6 +974,7 @@ struct LP_quoteinfo *LP_trades_gotconnect(void *ctx,struct LP_quoteinfo *qp,stru printf("check reservation\n"); if ( LP_reservation_check(qp->txid,qp->vout,qp->desthash) == 0 && LP_reservation_check(qp->txid2,qp->vout2,qp->desthash) == 0 ) { + printf("CONNECT STARTBOB!\n"); LP_connectstartbob(ctx,LP_mypubsock,qp->srccoin,qp->destcoin,qprice,qp); return(qp); } else printf("connect message from non-reserved (%llu)\n",(long long)qp->aliceid); diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index 7cb916861..2ad25ecf9 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -112,6 +112,7 @@ struct LP_inuse_info *_LP_inuse_add(uint32_t expiration,bits256 otherpub,bits256 int32_t LP_reservation_check(bits256 txid,int32_t vout,bits256 pubkey) { struct LP_inuse_info *lp; int32_t retval = -1; + printf("LP_reservation check\n"); if ( bits256_nonz(pubkey) != 0 ) { char str[65],str2[65]; From 26a24a079f848bd7ac8df7c5f153b4d6404be22d Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 17:06:15 +0200 Subject: [PATCH 075/197] Test --- iguana/exchanges/LP_ordermatch.c | 7 ++----- iguana/exchanges/LP_utxo.c | 3 +-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index b8eb2458f..cfeca9637 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -965,13 +965,10 @@ struct LP_quoteinfo *LP_trades_gotconnect(void *ctx,struct LP_quoteinfo *qp,stru qp = newqp; if ( (coin= LP_coinfind(qp->srccoin)) == 0 ) return(0); - printf("check myprice\n"); if ( (myprice= LP_trades_bobprice(&bid,&ask,qp)) == 0. ) return(0); - printf("validate myprice\n"); if ( (qprice= LP_trades_pricevalidate(qp,coin,myprice)) < 0. ) return(0); - printf("check reservation\n"); if ( LP_reservation_check(qp->txid,qp->vout,qp->desthash) == 0 && LP_reservation_check(qp->txid2,qp->vout2,qp->desthash) == 0 ) { printf("CONNECT STARTBOB!\n"); @@ -984,12 +981,12 @@ struct LP_quoteinfo *LP_trades_gotconnect(void *ctx,struct LP_quoteinfo *qp,stru struct LP_quoteinfo *LP_trades_gotconnected(void *ctx,struct LP_quoteinfo *qp,struct LP_quoteinfo *newqp,char *pairstr) { char *retstr; - //char str[65]; printf("alice %s received CONNECTED.(%llu)\n",bits256_str(str,G.LP_mypub25519),(long long)qp->aliceid); + char str[65]; printf("alice %s received CONNECTED.(%llu)\n",bits256_str(str,G.LP_mypub25519),(long long)qp->aliceid); *newqp = *qp; qp = newqp; if ( LP_trades_alicevalidate(ctx,qp) > 0. ) { - //printf("LP_trades_alicevalidate fine\n"); + printf("CONNECTED ALICE\n"); LP_aliceid(qp->tradeid,qp->aliceid,"connected",0,0); if ( (retstr= LP_connectedalice(qp,pairstr)) != 0 ) free(retstr); diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index 2ad25ecf9..e86bffe26 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -112,7 +112,6 @@ struct LP_inuse_info *_LP_inuse_add(uint32_t expiration,bits256 otherpub,bits256 int32_t LP_reservation_check(bits256 txid,int32_t vout,bits256 pubkey) { struct LP_inuse_info *lp; int32_t retval = -1; - printf("LP_reservation check\n"); if ( bits256_nonz(pubkey) != 0 ) { char str[65],str2[65]; @@ -124,7 +123,7 @@ int32_t LP_reservation_check(bits256 txid,int32_t vout,bits256 pubkey) else printf("otherpub.%s != %s\n",bits256_str(str,lp->otherpub),bits256_str(str2,pubkey)); } else printf("couldnt find %s/v%d\n",bits256_str(str,txid),vout); portable_mutex_unlock(&LP_inusemutex); - } else printf("null pubkey\n"); + } else printf("LP_reservation_check null pubkey\n"); return(retval); } From dbaa830e61bb0b092f172da8b1603307023b8ad7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 17:09:54 +0200 Subject: [PATCH 076/197] Test --- iguana/exchanges/LP_ordermatch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index cfeca9637..5ef9089fd 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -505,7 +505,7 @@ int32_t LP_connectstartbob(void *ctx,int32_t pubsock,char *base,char *rel,double retval = 0; } else printf("error launching swaploop\n"); } else printf("couldnt bind to any port %s\n",pairstr); - } + } else printf("cant find privkey for %s\n",coin->smartaddr); if ( retval < 0 ) { if ( pair >= 0 ) From 04ea00cc0bad966b816b093b1e4b772cb9b9a72f Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 17:15:13 +0200 Subject: [PATCH 077/197] Test --- iguana/exchanges/LP_ordermatch.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index 5ef9089fd..e2392954b 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -456,7 +456,7 @@ struct LP_utxoinfo *LP_address_myutxopair(struct LP_utxoinfo *butxo,int32_t iamb int32_t LP_connectstartbob(void *ctx,int32_t pubsock,char *base,char *rel,double price,struct LP_quoteinfo *qp) { - char pairstr[512],otheraddr[64]; cJSON *reqjson; bits256 privkey; int32_t pair=-1,retval = -1,DEXselector = 0; int64_t dtrust; struct basilisk_swap *swap; struct iguana_info *coin,*kmdcoin; + char pairstr[512],otheraddr[64]; cJSON *reqjson; bits256 privkey; int32_t pair=-1,retval = -1,DEXselector = 0; int64_t dtrust; struct basilisk_swap *swap; struct iguana_info *ecoin,*coin,*kmdcoin; qp->quotetime = (uint32_t)time(NULL); if ( (coin= LP_coinfind(qp->srccoin)) == 0 ) { @@ -464,6 +464,11 @@ int32_t LP_connectstartbob(void *ctx,int32_t pubsock,char *base,char *rel,double return(-1); } privkey = LP_privkey(coin->symbol,coin->smartaddr,coin->taddr); + if ( coin->etomic[0] != 0 ) + { + if ( (ecoin= LP_coinfind("ETOMIC")) != 0 ) + privkey = LP_privkey(ecoin->symbol,ecoin->smartaddr,ecoin->taddr); + } if ( bits256_nonz(privkey) != 0 && bits256_cmp(G.LP_mypub25519,qp->srchash) == 0 ) { LP_requestinit(&qp->R,qp->srchash,qp->desthash,base,qp->satoshis-qp->txfee,rel,qp->destsatoshis-qp->desttxfee,qp->timestamp,qp->quotetime,DEXselector); From a2a88fb5b986c7414cb64da1defd0a67abb1ffa1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 17:21:55 +0200 Subject: [PATCH 078/197] Test --- iguana/exchanges/LP_transaction.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index 68568345b..1c8e139c7 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -756,6 +756,12 @@ char *basilisk_swap_bobtxspend(bits256 *signedtxidp,uint64_t txfee,char *name,ch value = 0; if ( (coin= LP_coinfind(symbol)) != 0 ) { + if ( coin->etomic[0] != 0 ) + { + if ( (coin= LP_coinfind("ETOMIC")) == 0 ) + return(0); + symbol = coin->symbol; + } if ( txfee > 0 && txfee < coin->txfee ) txfee = coin->txfee; #ifndef BASILISK_DISABLESENDTX @@ -1330,6 +1336,11 @@ char *LP_withdraw(struct iguana_info *coin,cJSON *argjson) { static void *ctx; int32_t iter,i,utxovout,autofee,completed=0,maxV,numvins,numvouts,datalen,suppress_pubkeys; bits256 privkey; struct LP_address *ap; char changeaddr[64],vinaddr[64],str[65],*signedtx=0,*rawtx=0; struct vin_info *V; uint32_t locktime; cJSON *retjson,*item,*outputs,*vins=0,*txobj=0,*privkeys=0; struct iguana_msgtx msgtx; bits256 utxotxid,signedtxid; uint64_t txfee,newtxfee=10000; + if ( coin->etomic[0] != 0 ) + { + if ( (coin= LP_coinfind("ETOMIC")) == 0 ) + return(0); + } if ( ctx == 0 ) ctx = bitcoin_ctx(); if ( (outputs= jarray(&numvouts,argjson,"outputs")) == 0 ) From 2b0c1ba3effed5864a8d6ab673c0f53e252d32e0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 17:24:32 +0200 Subject: [PATCH 079/197] Test --- iguana/exchanges/LP_transaction.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index 1c8e139c7..6de0d25fb 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -1448,6 +1448,11 @@ int32_t basilisk_rawtx_gen(void *ctx,char *str,uint32_t swapstarted,uint8_t *pub struct iguana_info *coin; int32_t len,retval=-1; char *retstr,*hexstr; cJSON *argjson,*outputs,*item,*retjson,*obj; if ( (coin= LP_coinfind(rawtx->symbol)) == 0 ) return(-1); + if ( coin->etomic[0] != 0 ) + { + if ( (coin= LP_coinfind("ETOMIC")) == 0 ) + return(-1); + } if ( strcmp(coin->smartaddr,vinaddr) != 0 ) { printf("???????????????????????? basilisk_rawtx_gen mismatched %s %s vinaddr.%s != (%s)\n",rawtx->symbol,coin->symbol,vinaddr,coin->smartaddr); From c0f72c6d0151fc630820e99c13f63e5b94db06df Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 17:38:32 +0200 Subject: [PATCH 080/197] Test --- iguana/exchanges/LP_include.h | 2 +- iguana/exchanges/LP_remember.c | 10 +++++ iguana/exchanges/LP_transaction.c | 62 ++++++++++++++++++------------- 3 files changed, 47 insertions(+), 27 deletions(-) diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index b94860c5a..3a3549454 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -276,7 +276,7 @@ struct LP_swap_remember uint32_t finishtime,tradeid,requestid,quoteid,plocktime,dlocktime,expiration,state,otherstate; int32_t iambob,finishedflag,origfinishedflag,Predeemlen,Dredeemlen,sentflags[sizeof(txnames)/sizeof(*txnames)]; uint8_t secretAm[20],secretAm256[32],secretBn[20],secretBn256[32],Predeemscript[1024],Dredeemscript[1024],pubkey33[33],other33[33]; - char Agui[65],Bgui[65],gui[65],src[65],dest[65],destaddr[64],Adestaddr[64],Sdestaddr[64],alicepaymentaddr[64],bobpaymentaddr[64],bobdepositaddr[64],alicecoin[65],bobcoin[65],*txbytes[sizeof(txnames)/sizeof(*txnames)]; + char Agui[65],Bgui[65],gui[65],src[65],dest[65],bobtomic[128],alicetomic[128],destaddr[64],Adestaddr[64],Sdestaddr[64],alicepaymentaddr[64],bobpaymentaddr[64],bobdepositaddr[64],alicecoin[65],bobcoin[65],*txbytes[sizeof(txnames)/sizeof(*txnames)]; }; struct LP_outpoint diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 2aad1afb5..e9bb05870 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -66,7 +66,11 @@ void basilisk_dontforget(struct basilisk_swap *swap,struct basilisk_rawtx *rawtx fprintf(fp,",\"expiration\":%u",swap->I.expiration); fprintf(fp,",\"iambob\":%d",swap->I.iambob); fprintf(fp,",\"bobcoin\":\"%s\"",swap->I.bobstr); + if ( swap->I.bobtomic[0] != 0 ) + fprintf(fp,",\"bobtomic\":\"%s\"",swap->I.bobtomic); fprintf(fp,",\"alicecoin\":\"%s\"",swap->I.alicestr); + if ( swap->I.alicetomic[0] != 0 ) + fprintf(fp,",\"alicetomic\":\"%s\"",swap->I.alicetomic); fprintf(fp,",\"lock\":%u",locktime); fprintf(fp,",\"amount\":%.8f",dstr(rawtx->I.amount)); if ( bits256_nonz(triggertxid) != 0 ) @@ -502,9 +506,13 @@ cJSON *LP_swap_json(struct LP_swap_remember *rswap) jaddstr(item,"Agui",rswap->Agui); jaddstr(item,"gui",rswap->gui); jaddstr(item,"bob",rswap->src); + if ( rswap->bobtomic[0] != 0 ) + jaddstr(item,"bobtomic",rswap->bobtomic); jaddnum(item,"srcamount",dstr(rswap->srcamount)); jaddnum(item,"bobtxfee",dstr(rswap->Btxfee)); jaddstr(item,"alice",rswap->dest); + if ( rswap->alicetomic[0] != 0 ) + jaddstr(item,"alicetomic",rswap->alicetomic); jaddnum(item,"destamount",dstr(rswap->destamount)); jaddnum(item,"alicetxfee",dstr(rswap->Atxfee)); jadd64bits(item,"aliceid",rswap->aliceid); @@ -552,6 +560,8 @@ int32_t LP_rswap_init(struct LP_swap_remember *rswap,uint32_t requestid,uint32_t safecopy(rswap->Bgui,jstr(item,"Bgui"),sizeof(rswap->Bgui)); safecopy(rswap->Agui,jstr(item,"Agui"),sizeof(rswap->Agui)); safecopy(rswap->gui,jstr(item,"gui"),sizeof(rswap->gui)); + safecopy(rswap->bobtomic,jstr(item,"bobtomic"),sizeof(rswap->bobtomic)); + safecopy(rswap->alicetomic,jstr(item,"alicetomic"),sizeof(rswap->alicetomic)); rswap->tradeid = juint(item,"tradeid"); rswap->aliceid = j64bits(item,"aliceid"); if ( (secretstr= jstr(item,"secretAm")) != 0 && strlen(secretstr) == 40 ) diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index 6de0d25fb..f687ca893 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -1867,8 +1867,9 @@ int32_t basilisk_swapuserdata(uint8_t *userdata,bits256 privkey,int32_t ifpath,b int32_t basilisk_bobpayment_reclaim(struct basilisk_swap *swap,int32_t delay) { static bits256 zero; - uint8_t userdata[512]; int32_t retval,len = 0; struct iguana_info *coin; - if ( (coin= LP_coinfind(swap->I.bobstr)) != 0 ) + uint8_t userdata[512]; char bobstr[65],bobtomic[128]; int32_t retval,len = 0; struct iguana_info *coin; + LP_etomicsymbol(bobstr,bobtomic,bobstr); + if ( (coin= LP_coinfind(bobstr)) != 0 ) { //printf("basilisk_bobpayment_reclaim\n"); len = basilisk_swapuserdata(userdata,zero,1,swap->I.myprivs[1],swap->bobpayment.redeemscript,swap->bobpayment.I.redeemlen); @@ -1882,14 +1883,15 @@ int32_t basilisk_bobpayment_reclaim(struct basilisk_swap *swap,int32_t delay) //basilisk_txlog(swap,&swap->bobreclaim,delay); return(retval); } - } else printf("basilisk_bobpayment_reclaim cant find (%s)\n",swap->I.bobstr); + } else printf("basilisk_bobpayment_reclaim cant find (%s)\n",bobstr); return(-1); } int32_t basilisk_bobdeposit_refund(struct basilisk_swap *swap,int32_t delay) { - uint8_t userdata[512]; int32_t i,retval,len = 0; char str[65]; struct iguana_info *coin; - if ( (coin= LP_coinfind(swap->I.bobstr)) != 0 ) + uint8_t userdata[512]; int32_t i,retval,len = 0; char str[65],bobstr[65],bobtomic[128]; struct iguana_info *coin; + LP_etomicsymbol(bobstr,bobtomic,swap->I.bobstr); + if ( (coin= LP_coinfind(bobstr)) != 0 ) { len = basilisk_swapuserdata(userdata,swap->I.privBn,0,swap->I.myprivs[0],swap->bobdeposit.redeemscript,swap->bobdeposit.I.redeemlen); memcpy(swap->I.userdata_bobrefund,userdata,len); @@ -1902,7 +1904,7 @@ int32_t basilisk_bobdeposit_refund(struct basilisk_swap *swap,int32_t delay) //basilisk_txlog(swap,&swap->bobrefund,delay); return(retval); } - } else printf("basilisk_bobdeposit_refund cant find (%s)\n",swap->I.bobstr); + } else printf("basilisk_bobdeposit_refund cant find (%s)\n",bobstr); return(-1); } @@ -1928,8 +1930,9 @@ void LP_swap_coinaddr(struct iguana_info *coin,char *coinaddr,uint64_t *valuep,u int32_t basilisk_bobscripts_set(struct basilisk_swap *swap,int32_t depositflag,int32_t genflag) { - char coinaddr[64],checkaddr[64]; struct iguana_info *coin; - if ( (coin= LP_coinfind(swap->I.bobstr)) != 0 ) + char coinaddr[64],checkaddr[64],bobstr[65],bobtomic[128]; struct iguana_info *coin; + LP_etomicsymbol(bobstr,bobtomic,swap->I.bobstr); + if ( (coin= LP_coinfind(bobstr)) != 0 ) { bitcoin_address(coin->symbol,coinaddr,coin->taddr,coin->pubtype,swap->changermd160,20); if ( genflag != 0 && swap->I.iambob == 0 ) @@ -2005,7 +2008,7 @@ int32_t basilisk_bobscripts_set(struct basilisk_swap *swap,int32_t depositflag,i } } } - } else printf("bobscripts set cant find (%s)\n",swap->I.bobstr); + } else printf("bobscripts set cant find (%s)\n",bobstr); return(0); } @@ -2053,8 +2056,9 @@ void basilisk_alicepayment(struct basilisk_swap *swap,struct iguana_info *coin,s int32_t basilisk_alicetxs(int32_t pairsock,struct basilisk_swap *swap,uint8_t *data,int32_t maxlen) { - char coinaddr[64]; int32_t retval = -1; struct iguana_info *coin; - if ( (coin= LP_coinfind(swap->I.alicestr)) != 0 ) + char coinaddr[64],alicestr[65],alicetomic[128]; int32_t retval = -1; struct iguana_info *coin; + LP_etomicsymbol(alicestr,alicetomic,swap->I.alicestr); + if ( (coin= LP_coinfind(alicestr)) != 0 ) { if ( swap->alicepayment.I.datalen == 0 ) basilisk_alicepayment(swap,coin,&swap->alicepayment,swap->I.pubAm,swap->I.pubBn); @@ -2099,14 +2103,16 @@ int32_t basilisk_alicetxs(int32_t pairsock,struct basilisk_swap *swap,uint8_t *d //printf("fee sent\n"); return(0); } - } else printf("basilisk alicetx cant find (%s)\n",swap->I.alicestr); + } else printf("basilisk alicetx cant find (%s)\n",alicestr); return(-1); } int32_t LP_verify_otherfee(struct basilisk_swap *swap,uint8_t *data,int32_t datalen) { - int32_t diff; struct iguana_info *coin; - if ( (coin= LP_coinfind(swap->I.iambob != 0 ? swap->I.alicestr : swap->I.bobstr)) != 0 ) + int32_t diff; char bobstr[65],bobtomic[128],alicestr[65],alicetomic[128]; struct iguana_info *coin; + LP_etomicsymbol(bobstr,bobtomic,swap->I.bobstr); + LP_etomicsymbol(alicestr,alicetomic,swap->I.alicestr); + if ( (coin= LP_coinfind(swap->I.iambob != 0 ? alicestr : bobstr)) != 0 ) { if ( LP_rawtx_spendscript(swap,coin->longestchain,&swap->otherfee,0,data,datalen,0) == 0 ) { @@ -2130,8 +2136,9 @@ int32_t LP_verify_otherfee(struct basilisk_swap *swap,uint8_t *data,int32_t data int32_t LP_verify_alicespend(struct basilisk_swap *swap,uint8_t *data,int32_t datalen) { - struct iguana_info *coin; - if ( (coin= LP_coinfind(swap->I.alicestr)) != 0 ) + struct iguana_info *coin; char alicestr[65],alicetomic[128]; + LP_etomicsymbol(alicestr,alicetomic,swap->I.alicestr); + if ( (coin= LP_coinfind(alicestr)) != 0 ) { if ( LP_rawtx_spendscript(swap,coin->longestchain,&swap->alicespend,0,data,datalen,0) == 0 ) { @@ -2142,7 +2149,7 @@ int32_t LP_verify_alicespend(struct basilisk_swap *swap,uint8_t *data,int32_t da return(0); } } - } else printf("verify alicespend cant find (%s)\n",swap->I.alicestr); + } else printf("verify alicespend cant find (%s)\n",alicestr); return(-1); } @@ -2156,8 +2163,9 @@ int32_t LP_verify_alicespend(struct basilisk_swap *swap,uint8_t *data,int32_t da int32_t LP_verify_bobdeposit(struct basilisk_swap *swap,uint8_t *data,int32_t datalen) { static bits256 zero; - uint8_t userdata[512]; int32_t retval=-1,len = 0; struct iguana_info *coin; - if ( (coin= LP_coinfind(swap->I.bobstr)) != 0 ) + uint8_t userdata[512]; char bobstr[65],bobtomic[128]; int32_t retval=-1,len = 0; struct iguana_info *coin; + LP_etomicsymbol(bobstr,bobtomic,swap->I.bobstr); + if ( (coin= LP_coinfind(bobstr)) != 0 ) { if ( LP_rawtx_spendscript(swap,coin->longestchain,&swap->bobdeposit,0,data,datalen,0) == 0 ) { @@ -2196,15 +2204,16 @@ int32_t LP_verify_bobdeposit(struct basilisk_swap *swap,uint8_t *data,int32_t da return(LP_waitmempool(coin->symbol,swap->bobdeposit.I.destaddr,swap->bobdeposit.I.signedtxid,0,60)); } else printf("error signing aliceclaim suppress.%d vin.(%s)\n",swap->aliceclaim.I.suppress_pubkeys,swap->bobdeposit.I.destaddr); } - } else printf("verify bob depositcant find bob coin (%s)\n",swap->I.bobstr); + } else printf("verify bob depositcant find bob coin (%s)\n",bobstr); printf("error with bobdeposit\n"); return(retval); } int32_t LP_verify_alicepayment(struct basilisk_swap *swap,uint8_t *data,int32_t datalen) { - struct iguana_info *coin; - if ( (coin= LP_coinfind(swap->I.alicestr)) != 0 ) + struct iguana_info *coin; char alicestr[65],alicetomic[128]; + LP_etomicsymbol(alicestr,alicetomic,swap->I.alicestr); + if ( (coin= LP_coinfind(alicestr)) != 0 ) { if ( LP_rawtx_spendscript(swap,coin->longestchain,&swap->alicepayment,0,data,datalen,0) == 0 ) { @@ -2220,15 +2229,16 @@ int32_t LP_verify_alicepayment(struct basilisk_swap *swap,uint8_t *data,int32_t //LP_importaddress(coin->symbol,swap->alicepayment.p2shaddr); return(0); } - } else printf("verify alicepayment couldnt find coin.(%s)\n",swap->I.alicestr); + } else printf("verify alicepayment couldnt find coin.(%s)\n",alicestr); printf("error validating alicepayment\n"); return(-1); } int32_t LP_verify_bobpayment(struct basilisk_swap *swap,uint8_t *data,int32_t datalen) { - uint8_t userdata[512]; int32_t i,retval=-1,len = 0; bits256 revAm; struct iguana_info *coin; - if ( (coin= LP_coinfind(swap->I.bobstr)) != 0 ) + uint8_t userdata[512]; char bobstr[65],bobtomic[128]; int32_t i,retval=-1,len = 0; bits256 revAm; struct iguana_info *coin; + LP_etomicsymbol(bobstr,bobtomic,swap->I.bobstr); + if ( (coin= LP_coinfind(bobstr)) != 0 ) { memset(revAm.bytes,0,sizeof(revAm)); if ( LP_rawtx_spendscript(swap,coin->longestchain,&swap->bobpayment,0,data,datalen,0) == 0 ) @@ -2268,7 +2278,7 @@ int32_t LP_verify_bobpayment(struct basilisk_swap *swap,uint8_t *data,int32_t da return(LP_waitmempool(coin->symbol,swap->bobpayment.I.destaddr,swap->bobpayment.I.signedtxid,0,60)); } else printf("error signing aliceclaim suppress.%d vin.(%s)\n",swap->alicespend.I.suppress_pubkeys,swap->bobpayment.I.destaddr); } - } else printf("verify bobpayment cant find (%s)\n",swap->I.bobstr); + } else printf("verify bobpayment cant find (%s)\n",bobstr); printf("error validating bobpayment\n"); return(-1); } From 6b702340ddc23c76d147c0357ec70db2cc822afd Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 17:53:11 +0200 Subject: [PATCH 081/197] Test --- iguana/exchanges/LP_remember.c | 6 ++++-- iguana/exchanges/LP_transaction.c | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index e9bb05870..ca2265341 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -900,7 +900,7 @@ int32_t LP_spends_set(struct LP_swap_remember *rswap) cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requestid,uint32_t quoteid,int32_t forceflag,int32_t pendingonly) { static void *ctx; - struct LP_swap_remember rswap; int32_t i,j,flag,numspent,len,secretstart,redeemlen; char str[65],*srcAdest,*srcBdest,*destAdest,*destBdest,otheraddr[64]; cJSON *item,*txoutobj; bits256 rev,signedtxid,zero,deadtxid; uint32_t claimtime; struct iguana_info *bob=0,*alice=0; uint8_t redeemscript[1024],userdata[1024]; + struct LP_swap_remember rswap; int32_t i,j,flag,numspent,len,secretstart,redeemlen; char str[65],*srcAdest,*srcBdest,*destAdest,*destBdest,otheraddr[64],bobstr[65],bobtomic[128],alicestr[65],alicetomic[128]; cJSON *item,*txoutobj; bits256 rev,signedtxid,zero,deadtxid; uint32_t claimtime; struct iguana_info *bob=0,*alice=0; uint8_t redeemscript[1024],userdata[1024]; if ( ctx == 0 ) ctx = bitcoin_ctx(); if ( requestid == 0 || quoteid == 0 ) @@ -913,9 +913,11 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti otheraddr[0] = 0; claimtime = (uint32_t)time(NULL) - 777; srcAdest = srcBdest = destAdest = destBdest = 0; + LP_etomicsymbol(bobstr,bobtomic,rswap.src); + LP_etomicsymbol(alicestr,alicetomic,rswap.dest); if ( rswap.bobcoin[0] == 0 || rswap.alicecoin[0] == 0 || strcmp(rswap.bobcoin,rswap.src) != 0 || strcmp(rswap.alicecoin,rswap.dest) != 0 ) { - //printf("legacy r%u-q%u DB SWAPS.(%u %u) %llu files BOB.(%s) Alice.(%s) src.(%s) dest.(%s)\n",requestid,quoteid,rswap.requestid,rswap.quoteid,(long long)rswap.aliceid,rswap.bobcoin,rswap.alicecoin,rswap.src,rswap.dest); + printf("legacy r%u-q%u DB SWAPS.(%u %u) %llu files BOB.(%s) Alice.(%s) src.(%s) dest.(%s)\n",requestid,quoteid,rswap.requestid,rswap.quoteid,(long long)rswap.aliceid,rswap.bobcoin,rswap.alicecoin,rswap.src,rswap.dest); cJSON *retjson = cJSON_CreateObject(); jaddstr(retjson,"error","swap never started"); jaddnum(retjson,"requestid",requestid); diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index f687ca893..2fabf7fb8 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -1868,7 +1868,7 @@ int32_t basilisk_bobpayment_reclaim(struct basilisk_swap *swap,int32_t delay) { static bits256 zero; uint8_t userdata[512]; char bobstr[65],bobtomic[128]; int32_t retval,len = 0; struct iguana_info *coin; - LP_etomicsymbol(bobstr,bobtomic,bobstr); + LP_etomicsymbol(bobstr,bobtomic,swap->I.bobstr); if ( (coin= LP_coinfind(bobstr)) != 0 ) { //printf("basilisk_bobpayment_reclaim\n"); From 1771d1e390c80a84c05d8f554e447fb13b0c60b4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 17:55:19 +0200 Subject: [PATCH 082/197] Test --- iguana/exchanges/LP_remember.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index ca2265341..f32780e73 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -920,6 +920,10 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti printf("legacy r%u-q%u DB SWAPS.(%u %u) %llu files BOB.(%s) Alice.(%s) src.(%s) dest.(%s)\n",requestid,quoteid,rswap.requestid,rswap.quoteid,(long long)rswap.aliceid,rswap.bobcoin,rswap.alicecoin,rswap.src,rswap.dest); cJSON *retjson = cJSON_CreateObject(); jaddstr(retjson,"error","swap never started"); + jaddstr(retjson,"bob",rswap.bobcoin); + jaddstr(retjson,"src",rswap.src); + jaddstr(retjson,"alice",rswap.alicecoin); + jaddstr(retjson,"dest",rswap.dest); jaddnum(retjson,"requestid",requestid); jaddnum(retjson,"quoteid",quoteid); return(retjson); From 19470850cee2ee6fa8912c0791581c1c1e7c1bdb Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 17:56:23 +0200 Subject: [PATCH 083/197] Test --- iguana/exchanges/LP_remember.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index f32780e73..2b2866d02 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -915,9 +915,9 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti srcAdest = srcBdest = destAdest = destBdest = 0; LP_etomicsymbol(bobstr,bobtomic,rswap.src); LP_etomicsymbol(alicestr,alicetomic,rswap.dest); - if ( rswap.bobcoin[0] == 0 || rswap.alicecoin[0] == 0 || strcmp(rswap.bobcoin,rswap.src) != 0 || strcmp(rswap.alicecoin,rswap.dest) != 0 ) + if ( rswap.bobcoin[0] == 0 || rswap.alicecoin[0] == 0 || strcmp(rswap.bobcoin,bobstr) != 0 || strcmp(rswap.alicecoin,alicestr) != 0 ) { - printf("legacy r%u-q%u DB SWAPS.(%u %u) %llu files BOB.(%s) Alice.(%s) src.(%s) dest.(%s)\n",requestid,quoteid,rswap.requestid,rswap.quoteid,(long long)rswap.aliceid,rswap.bobcoin,rswap.alicecoin,rswap.src,rswap.dest); + //printf("legacy r%u-q%u DB SWAPS.(%u %u) %llu files BOB.(%s) Alice.(%s) src.(%s) dest.(%s)\n",requestid,quoteid,rswap.requestid,rswap.quoteid,(long long)rswap.aliceid,rswap.bobcoin,rswap.alicecoin,rswap.src,rswap.dest); cJSON *retjson = cJSON_CreateObject(); jaddstr(retjson,"error","swap never started"); jaddstr(retjson,"bob",rswap.bobcoin); From 10e93f5fc98186328298e7ff2e0b64c38262e952 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 18:02:10 +0200 Subject: [PATCH 084/197] Test --- iguana/exchanges/LP_remember.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 2b2866d02..b5b7cff29 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -930,7 +930,11 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti //return(cJSON_Parse("{\"error\":\"mismatched bob/alice vs src/dest coins??\"}")); } alice = LP_coinfind(rswap.alicecoin); + if ( alice->etomic[0] != 0 ) + alice = LP_coinfind("ETOMIC"); bob = LP_coinfind(rswap.bobcoin); + if ( bob->etomic[0] != 0 ) + bob = LP_coinfind("ETOMIC"); rswap.Atxfee = LP_txfeecalc(alice,rswap.Atxfee,0); rswap.Btxfee = LP_txfeecalc(bob,rswap.Btxfee,0); if ( rswap.iambob == 0 ) From 09ec08d09cda13cc2f6fd9f96eca767ed1ccf20d Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 18:04:42 +0200 Subject: [PATCH 085/197] Test --- iguana/exchanges/LP_remember.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index b5b7cff29..95bc88546 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -930,11 +930,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti //return(cJSON_Parse("{\"error\":\"mismatched bob/alice vs src/dest coins??\"}")); } alice = LP_coinfind(rswap.alicecoin); - if ( alice->etomic[0] != 0 ) - alice = LP_coinfind("ETOMIC"); bob = LP_coinfind(rswap.bobcoin); - if ( bob->etomic[0] != 0 ) - bob = LP_coinfind("ETOMIC"); rswap.Atxfee = LP_txfeecalc(alice,rswap.Atxfee,0); rswap.Btxfee = LP_txfeecalc(bob,rswap.Btxfee,0); if ( rswap.iambob == 0 ) @@ -944,7 +940,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti bitcoin_address(alice->symbol,otheraddr,alice->taddr,alice->pubtype,rswap.other33,33); destBdest = otheraddr; destAdest = rswap.Adestaddr; - if ( LP_TECHSUPPORT == 0 && strcmp(alice->smartaddr,rswap.Adestaddr) != 0 ) + if ( LP_TECHSUPPORT == 0 && alice->etomic[0] == 0 && strcmp(alice->smartaddr,rswap.Adestaddr) != 0 ) { printf("this isnt my swap! alice.(%s vs %s)\n",alice->smartaddr,rswap.Adestaddr); cJSON *retjson = cJSON_CreateObject(); @@ -968,7 +964,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti bitcoin_address(bob->symbol,otheraddr,bob->taddr,bob->pubtype,rswap.other33,33); srcAdest = otheraddr; srcBdest = rswap.destaddr; - if ( LP_TECHSUPPORT == 0 && strcmp(bob->smartaddr,rswap.destaddr) != 0 ) + if ( LP_TECHSUPPORT == 0 && bob->etomic[0] == 0 && strcmp(bob->smartaddr,rswap.destaddr) != 0 ) { printf("this isnt my swap! bob.(%s vs %s)\n",bob->smartaddr,rswap.destaddr); cJSON *retjson = cJSON_CreateObject(); From e57f599387e980d68792564a48abf68a86d24e33 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 18:31:31 +0200 Subject: [PATCH 086/197] Test --- iguana/exchanges/LP_include.h | 6 +++--- iguana/exchanges/LP_mmjson.c | 4 ++-- iguana/exchanges/LP_ordermatch.c | 9 +++++++++ iguana/exchanges/LP_remember.c | 10 ++++++++++ iguana/exchanges/LP_signatures.c | 16 ++++++++++++---- 5 files changed, 36 insertions(+), 9 deletions(-) diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index 3a3549454..a8d4dc211 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -235,7 +235,7 @@ struct basilisk_rawtx struct basilisk_swapinfo { struct basilisk_request req; - char bobstr[128],alicestr[128],bobtomic[64],alicetomic[64]; + char bobstr[128],alicestr[128],bobtomic[64],alicetomic[64],etomicsrc[65],etomicdest[65]; 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; @@ -276,7 +276,7 @@ struct LP_swap_remember uint32_t finishtime,tradeid,requestid,quoteid,plocktime,dlocktime,expiration,state,otherstate; int32_t iambob,finishedflag,origfinishedflag,Predeemlen,Dredeemlen,sentflags[sizeof(txnames)/sizeof(*txnames)]; uint8_t secretAm[20],secretAm256[32],secretBn[20],secretBn256[32],Predeemscript[1024],Dredeemscript[1024],pubkey33[33],other33[33]; - char Agui[65],Bgui[65],gui[65],src[65],dest[65],bobtomic[128],alicetomic[128],destaddr[64],Adestaddr[64],Sdestaddr[64],alicepaymentaddr[64],bobpaymentaddr[64],bobdepositaddr[64],alicecoin[65],bobcoin[65],*txbytes[sizeof(txnames)/sizeof(*txnames)]; + char Agui[65],Bgui[65],gui[65],src[65],dest[65],bobtomic[128],alicetomic[128],etomicsrc[65],etomicdest[65],destaddr[64],Adestaddr[64],Sdestaddr[64],alicepaymentaddr[64],bobpaymentaddr[64],bobdepositaddr[64],alicecoin[65],bobcoin[65],*txbytes[sizeof(txnames)/sizeof(*txnames)]; }; struct LP_outpoint @@ -379,7 +379,7 @@ struct LP_quoteinfo uint64_t satoshis,txfee,destsatoshis,desttxfee,aliceid; uint32_t timestamp,quotetime,tradeid; int32_t vout,vout2,destvout,feevout,pair; - char srccoin[65],coinaddr[64],destcoin[65],destaddr[64],gui[64]; + char srccoin[65],coinaddr[64],destcoin[65],destaddr[64],gui[64],etomicsrc[65],etomicdest[65]; }; struct LP_endpoint { int32_t pair; char ipaddr[64]; uint16_t port; }; diff --git a/iguana/exchanges/LP_mmjson.c b/iguana/exchanges/LP_mmjson.c index a7f8860f6..0438c99cc 100644 --- a/iguana/exchanges/LP_mmjson.c +++ b/iguana/exchanges/LP_mmjson.c @@ -50,13 +50,13 @@ int32_t MM_numfields; char *MM_fields[] = { - "timestamp", "getdPoW", "dPoW", "aliceid", "src", "base", "basevol", "dest", "rel", "relvol", "price", "requestid", "quoteid", "finished", "expired", "bobdeposit", "alicepayment", "bobpayment", "paymentspent", "Apaymentspent", "depositspent", "ind", "method", "swapstatus", "method2", "gettradestatus", "coin", "rmd160", "pub", "pubsecp", "sig", "session", "notify", "pubkey", "price64", "credits", "utxocoin", "n", "bal", "min", "max", "postprice", "notarized", "notarizedhash", "notarizationtxid", "wantnotify", "isLP", "gui", "nogui", "tradeid", "address", "txid", "vout", "srchash", "txfee", "quotetime", "satoshis", "desthash", "txid2", "vout2", "destaddr", "desttxid", "destvout", "feetxid", "feevout", "desttxfee", "destsatoshis", "pending", "reserved", "broadcast", "ismine", "simplegui", "request", "proof", "connect", "expiration", "iambob", "Bgui", "", "Agui", "bob", "srcamount", "bobtxfee", "alice", "destamount", "alicetxfee", "sentflags", "values", "result", "success", "status", "finishtime", "tradestatus", "pair", "connected", "warning", "critical", "endcritical", "etomic", "esrc", "edest", "cli" + "timestamp", "getdPoW", "dPoW", "aliceid", "src", "base", "basevol", "dest", "rel", "relvol", "price", "requestid", "quoteid", "finished", "expired", "bobdeposit", "alicepayment", "bobpayment", "paymentspent", "Apaymentspent", "depositspent", "ind", "method", "swapstatus", "method2", "gettradestatus", "coin", "rmd160", "pub", "pubsecp", "sig", "session", "notify", "pubkey", "price64", "credits", "utxocoin", "n", "bal", "min", "max", "postprice", "notarized", "notarizedhash", "notarizationtxid", "wantnotify", "isLP", "gui", "nogui", "tradeid", "address", "txid", "vout", "srchash", "txfee", "quotetime", "satoshis", "desthash", "txid2", "vout2", "destaddr", "desttxid", "destvout", "feetxid", "feevout", "desttxfee", "destsatoshis", "pending", "reserved", "broadcast", "ismine", "simplegui", "request", "proof", "connect", "expiration", "iambob", "Bgui", "", "Agui", "bob", "srcamount", "bobtxfee", "alice", "destamount", "alicetxfee", "sentflags", "values", "result", "success", "status", "finishtime", "tradestatus", "pair", "connected", "warning", "critical", "endcritical", "cli", "etomic", "bobetomic", "alicetomic", "etomicsrc", "etomicdest" }; #define MMJSON_BOUNDARY ((int32_t)(sizeof(MM_fields)/sizeof(*MM_fields))) char *MM_coins[] = { - "KMD", "BTC", "CRC", "VOT", "INN", "MOON", "CRW", "EFL", "GBX", "BCO", "BLK", "BTG", "BCH", "ABY", "STAK", "XZC", "QTUM", "PURA", "DSR", "MNZ", "BTCZ", "MAGA", "BSD", "IOP", "BLOCK", "CHIPS", "888", "ARG", "GLT", "ZER", "HODLC", "UIS", "HUC", "PIVX", "BDL", "ARC", "ZCL", "VIA", "ERC", "FAIR", "FLO", "SXC", "CREA", "TRC", "BTA", "SMC", "NMC", "NAV", "EMC2", "SYS", "I0C", "DASH", "STRAT", "MUE", "MONA", "XMY", "MAC", "BTX", "XRE", "LBC", "SIB", "VTC", "REVS", "JUMBLR", "DOGE", "HUSH", "ZEC", "DGB", "ZET", "GAME", "LTC", "SUPERNET", "WLC", "PANGEA", "DEX", "BET", "CRYPTO", "HODL", "MSHARK", "BOTS", "MGW", "COQUI", "KV", "CEAL", "MESH", + "KMD", "BTC", "CRC", "VOT", "INN", "MOON", "CRW", "EFL", "GBX", "BCO", "BLK", "BTG", "BCH", "ABY", "STAK", "XZC", "QTUM", "PURA", "DSR", "MNZ", "BTCZ", "MAGA", "BSD", "IOP", "BLOCK", "CHIPS", "888", "ARG", "GLT", "ZER", "HODLC", "UIS", "HUC", "PIVX", "BDL", "ARC", "ZCL", "VIA", "ERC", "FAIR", "FLO", "SXC", "CREA", "TRC", "BTA", "SMC", "NMC", "NAV", "EMC2", "SYS", "I0C", "DASH", "STRAT", "MUE", "MONA", "XMY", "MAC", "BTX", "XRE", "LBC", "SIB", "VTC", "REVS", "JUMBLR", "DOGE", "HUSH", "ZEC", "DGB", "ZET", "GAME", "LTC", "SUPERNET", "WLC", "PANGEA", "DEX", "BET", "CRYPTO", "HODL", "MSHARK", "BOTS", "MGW", "COQUI", "KV", "CEAL", "MESH", "ETOMIC", "BTCH", "ETH" }; int32_t mmjson_coinfind(char *symbol) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index e2392954b..e88dc37b6 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -870,7 +870,10 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru { struct iguana_info *ecoin; if ( (ecoin= LP_coinfind("ETOMIC")) != 0 ) + { + strcpy(qp->etomicsrc,qp->coinaddr); strcpy(qp->coinaddr,ecoin->smartaddr); + } else return(0); } strcpy(qp->coinaddr,coin->smartaddr); @@ -903,7 +906,10 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru { struct iguana_info *ecoin; if ( (ecoin= LP_coinfind("ETOMIC")) != 0 ) + { + strcpy(qp->etomicsrc,qp->coinaddr); strcpy(qp->coinaddr,ecoin->smartaddr); + } else return(0); } if ( (butxo= LP_address_myutxopair(butxo,1,utxos,max,LP_coinfind(qp->srccoin),qp->coinaddr,qp->txfee,dstr(qp->destsatoshis),price,qp->desttxfee)) != 0 ) @@ -1423,7 +1429,10 @@ char *LP_autobuy(void *ctx,char *myipaddr,int32_t mypubsock,char *base,char *rel { struct iguana_info *coin; if ( (coin= LP_coinfind("ETOMIC")) != 0 ) + { + strcpy(Q.etomicdest,Q.destaddr); strcpy(Q.destaddr,coin->smartaddr); + } else return(clonestr("{\"error\":\"cant find ETOMIC\"}")); } int32_t changed; diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 95bc88546..67610f37e 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -68,9 +68,13 @@ void basilisk_dontforget(struct basilisk_swap *swap,struct basilisk_rawtx *rawtx fprintf(fp,",\"bobcoin\":\"%s\"",swap->I.bobstr); if ( swap->I.bobtomic[0] != 0 ) fprintf(fp,",\"bobtomic\":\"%s\"",swap->I.bobtomic); + if ( swap->I.etomicsrc[0] != 0 ) + fprintf(fp,",\"etomicsrc\":\"%s\"",swap->I.etomicsrc); fprintf(fp,",\"alicecoin\":\"%s\"",swap->I.alicestr); if ( swap->I.alicetomic[0] != 0 ) fprintf(fp,",\"alicetomic\":\"%s\"",swap->I.alicetomic); + if ( swap->I.etomicdest[0] != 0 ) + fprintf(fp,",\"etomicdest\":\"%s\"",swap->I.etomicdest); fprintf(fp,",\"lock\":%u",locktime); fprintf(fp,",\"amount\":%.8f",dstr(rawtx->I.amount)); if ( bits256_nonz(triggertxid) != 0 ) @@ -945,6 +949,9 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti printf("this isnt my swap! alice.(%s vs %s)\n",alice->smartaddr,rswap.Adestaddr); cJSON *retjson = cJSON_CreateObject(); jaddstr(retjson,"error","swap for different account"); + jaddstr(retjson,"alice",alice->symbol); + jaddstr(retjson,"aliceaddr",alice->smartaddr); + jaddstr(retjson,"dest",rswap.dest); jaddnum(retjson,"requestid",requestid); jaddnum(retjson,"quoteid",quoteid); return(retjson); @@ -969,6 +976,9 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti printf("this isnt my swap! bob.(%s vs %s)\n",bob->smartaddr,rswap.destaddr); cJSON *retjson = cJSON_CreateObject(); jaddstr(retjson,"error","swap for different account"); + jaddstr(retjson,"bob",bob->symbol); + jaddstr(retjson,"bobaddr",bob->smartaddr); + jaddstr(retjson,"src",rswap.src); jaddnum(retjson,"requestid",requestid); jaddnum(retjson,"quoteid",quoteid); return(retjson); diff --git a/iguana/exchanges/LP_signatures.c b/iguana/exchanges/LP_signatures.c index 19f8a9622..3854cb237 100644 --- a/iguana/exchanges/LP_signatures.c +++ b/iguana/exchanges/LP_signatures.c @@ -48,10 +48,16 @@ cJSON *LP_quotejson(struct LP_quoteinfo *qp) jaddnum(retjson,"tradeid",qp->tradeid); jaddstr(retjson,"base",qp->srccoin); if ( LP_etomicsymbol(activesymbol,etomic,qp->srccoin) != 0 ) - jaddstr(retjson,"esrc",etomic); + { + jaddstr(retjson,"bobetomic",etomic); + jaddstr(retjson,"etomicsrc",qp->etomicsrc); + } jaddstr(retjson,"rel",qp->destcoin); if ( LP_etomicsymbol(activesymbol,etomic,qp->destcoin) != 0 ) - jaddstr(retjson,"edest",etomic); + { + jaddstr(retjson,"alicetomic",etomic); + jaddstr(retjson,"etomicdest",qp->etomicdest); + } if ( qp->coinaddr[0] != 0 ) jaddstr(retjson,"address",qp->coinaddr); if ( qp->timestamp != 0 ) @@ -114,23 +120,25 @@ int32_t LP_quoteparse(struct LP_quoteinfo *qp,cJSON *argjson) safecopy(qp->srccoin,jstr(argjson,"base"),sizeof(qp->srccoin)); if ( LP_etomicsymbol(activesymbol,etomic,qp->srccoin) != 0 ) { - if ( (etomicstr= jstr(argjson,"esrc")) == 0 || strcmp(etomicstr,etomic) != 0 ) + if ( (etomicstr= jstr(argjson,"bobetomic")) == 0 || strcmp(etomicstr,etomic) != 0 ) { printf("etomic src mismatch (%s) vs (%s)\n",etomicstr!=0?etomicstr:"",etomic); return(-1); } } safecopy(qp->coinaddr,jstr(argjson,"address"),sizeof(qp->coinaddr)); + safecopy(qp->etomicsrc,jstr(argjson,"etomicsrc"),sizeof(qp->etomicsrc)); safecopy(qp->destcoin,jstr(argjson,"rel"),sizeof(qp->destcoin)); if ( LP_etomicsymbol(activesymbol,etomic,qp->destcoin) != 0 ) { - if ( (etomicstr= jstr(argjson,"edest")) == 0 || strcmp(etomicstr,etomic) != 0 ) + if ( (etomicstr= jstr(argjson,"alicetomic")) == 0 || strcmp(etomicstr,etomic) != 0 ) { printf("etomic dest mismatch (%s) vs (%s)\n",etomicstr!=0?etomicstr:"",etomic); return(-1); } } safecopy(qp->destaddr,jstr(argjson,"destaddr"),sizeof(qp->destaddr)); + safecopy(qp->etomicdest,jstr(argjson,"etomicdest"),sizeof(qp->etomicdest)); qp->aliceid = j64bits(argjson,"aliceid"); qp->tradeid = juint(argjson,"tradeid"); qp->timestamp = juint(argjson,"timestamp"); From 2a8afe7b95a821053fb4bdb188dedb5afda70a39 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Feb 2018 18:46:25 +0200 Subject: [PATCH 087/197] Test --- iguana/exchanges/LP_remember.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 67610f37e..85ed4061d 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -904,7 +904,7 @@ int32_t LP_spends_set(struct LP_swap_remember *rswap) cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requestid,uint32_t quoteid,int32_t forceflag,int32_t pendingonly) { static void *ctx; - struct LP_swap_remember rswap; int32_t i,j,flag,numspent,len,secretstart,redeemlen; char str[65],*srcAdest,*srcBdest,*destAdest,*destBdest,otheraddr[64],bobstr[65],bobtomic[128],alicestr[65],alicetomic[128]; cJSON *item,*txoutobj; bits256 rev,signedtxid,zero,deadtxid; uint32_t claimtime; struct iguana_info *bob=0,*alice=0; uint8_t redeemscript[1024],userdata[1024]; + struct LP_swap_remember rswap; int32_t i,j,flag,numspent,len,secretstart,redeemlen; char str[65],*srcAdest,*srcBdest,*destAdest,*destBdest,otheraddr[64],etomicsrc[65],etomicdest[65],bobstr[65],bobtomic[128],alicestr[65],alicetomic[128]; cJSON *item,*txoutobj; bits256 rev,signedtxid,zero,deadtxid; uint32_t claimtime; struct iguana_info *coin,*bob=0,*alice=0; uint8_t redeemscript[1024],userdata[1024]; if ( ctx == 0 ) ctx = bitcoin_ctx(); if ( requestid == 0 || quoteid == 0 ) @@ -917,8 +917,26 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti otheraddr[0] = 0; claimtime = (uint32_t)time(NULL) - 777; srcAdest = srcBdest = destAdest = destBdest = 0; + alice = LP_coinfind(rswap.alicecoin); + bob = LP_coinfind(rswap.bobcoin); + if ( alice != 0 ) + strcpy(etomicdest,alice->smartaddr); + else etomicdest[0] = 0; + if ( bob != 0 ) + strcpy(etomicsrc,bob->smartaddr); + else etomicsrc[0] = 0; LP_etomicsymbol(bobstr,bobtomic,rswap.src); + if ( bobtomic[0] != 0 ) + { + if ( (coin= LP_coinfind(rswap.src)) != 0 ) + strcpy(etomicsrc,coin->smartaddr); + } LP_etomicsymbol(alicestr,alicetomic,rswap.dest); + if ( alicetomic[0] != 0 ) + { + if ( (coin= LP_coinfind(rswap.dest)) != 0 ) + strcpy(etomicdest,coin->smartaddr); + } if ( rswap.bobcoin[0] == 0 || rswap.alicecoin[0] == 0 || strcmp(rswap.bobcoin,bobstr) != 0 || strcmp(rswap.alicecoin,alicestr) != 0 ) { //printf("legacy r%u-q%u DB SWAPS.(%u %u) %llu files BOB.(%s) Alice.(%s) src.(%s) dest.(%s)\n",requestid,quoteid,rswap.requestid,rswap.quoteid,(long long)rswap.aliceid,rswap.bobcoin,rswap.alicecoin,rswap.src,rswap.dest); @@ -933,8 +951,6 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti return(retjson); //return(cJSON_Parse("{\"error\":\"mismatched bob/alice vs src/dest coins??\"}")); } - alice = LP_coinfind(rswap.alicecoin); - bob = LP_coinfind(rswap.bobcoin); rswap.Atxfee = LP_txfeecalc(alice,rswap.Atxfee,0); rswap.Btxfee = LP_txfeecalc(bob,rswap.Btxfee,0); if ( rswap.iambob == 0 ) @@ -944,7 +960,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti bitcoin_address(alice->symbol,otheraddr,alice->taddr,alice->pubtype,rswap.other33,33); destBdest = otheraddr; destAdest = rswap.Adestaddr; - if ( LP_TECHSUPPORT == 0 && alice->etomic[0] == 0 && strcmp(alice->smartaddr,rswap.Adestaddr) != 0 ) + if ( LP_TECHSUPPORT == 0 && strcmp(etomicdest,rswap.Adestaddr) != 0 ) { printf("this isnt my swap! alice.(%s vs %s)\n",alice->smartaddr,rswap.Adestaddr); cJSON *retjson = cJSON_CreateObject(); @@ -971,7 +987,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti bitcoin_address(bob->symbol,otheraddr,bob->taddr,bob->pubtype,rswap.other33,33); srcAdest = otheraddr; srcBdest = rswap.destaddr; - if ( LP_TECHSUPPORT == 0 && bob->etomic[0] == 0 && strcmp(bob->smartaddr,rswap.destaddr) != 0 ) + if ( LP_TECHSUPPORT == 0 && strcmp(etomicsrc,rswap.destaddr) != 0 ) { printf("this isnt my swap! bob.(%s vs %s)\n",bob->smartaddr,rswap.destaddr); cJSON *retjson = cJSON_CreateObject(); From d8e2c3a3579576f7ea10bfa36d99c9c4d544118a Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 9 Feb 2018 16:06:12 +0200 Subject: [PATCH 088/197] Fix etomicsrc --- iguana/exchanges/LP_nativeDEX.c | 2 +- iguana/exchanges/LP_ordermatch.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 105d84ecd..9992ae144 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -1485,7 +1485,7 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybu } if ( LP_mainloop_iter(ctx,myipaddr,mypeer,LP_mypubsock) != 0 ) nonz++; - if ( didremote == 0 && LP_cmdcount > 0 ) + if ( IAMLP != 0 && didremote == 0 && LP_cmdcount > 0 ) { didremote = 1; uint16_t myport2 = RPC_port-1; diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index e88dc37b6..c54cec9d2 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -866,17 +866,17 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru { qprice = (double)qp->destsatoshis / (qp->satoshis - qp->txfee); strcpy(qp->gui,G.gui); + strcpy(qp->coinaddr,coin->smartaddr); if ( coin->etomic[0] != 0 ) { struct iguana_info *ecoin; if ( (ecoin= LP_coinfind("ETOMIC")) != 0 ) { - strcpy(qp->etomicsrc,qp->coinaddr); + strcpy(qp->etomicsrc,coin->smartaddr); strcpy(qp->coinaddr,ecoin->smartaddr); } else return(0); } - strcpy(qp->coinaddr,coin->smartaddr); strcpy(butxo->coinaddr,qp->coinaddr); qp->srchash = G.LP_mypub25519; memset(&qp->txid,0,sizeof(qp->txid)); @@ -907,7 +907,7 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru struct iguana_info *ecoin; if ( (ecoin= LP_coinfind("ETOMIC")) != 0 ) { - strcpy(qp->etomicsrc,qp->coinaddr); + strcpy(qp->etomicsrc,coin->smartaddr); strcpy(qp->coinaddr,ecoin->smartaddr); } else return(0); From 4194554ae93a60f687f585080a1168c7f0c7b8ba Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 9 Feb 2018 17:39:13 +0200 Subject: [PATCH 089/197] Need to update Alice claim script path to prevent unspendable alicepayment --- iguana/exchanges/LP_swap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index 290158ace..9e7028b8d 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -43,7 +43,8 @@ Bob deposit: OP_IF - OP_CLTV OP_DROP OP_CHECKSIG + // OP_CLTV OP_DROP OP_CHECKSIG + OP_CLTV OP_DROP OP_HASH160 OP_EQUALVERIFY OP_CHECKSIG OP_ELSE OP_HASH160 OP_EQUALVERIFY OP_CHECKSIG OP_ENDIF From 1eb05317975384feb7cca873209a5dea9daf39b3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 9 Feb 2018 17:51:31 +0200 Subject: [PATCH 090/197] Add etomicsrc/dest to swap --- iguana/exchanges/LP_remember.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 85ed4061d..66401e909 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -512,11 +512,15 @@ cJSON *LP_swap_json(struct LP_swap_remember *rswap) jaddstr(item,"bob",rswap->src); if ( rswap->bobtomic[0] != 0 ) jaddstr(item,"bobtomic",rswap->bobtomic); + if ( rswap->etomicsrc[0] != 0 ) + jaddstr(item,"etomicsrc",rswap->etomicsrc); jaddnum(item,"srcamount",dstr(rswap->srcamount)); jaddnum(item,"bobtxfee",dstr(rswap->Btxfee)); jaddstr(item,"alice",rswap->dest); if ( rswap->alicetomic[0] != 0 ) jaddstr(item,"alicetomic",rswap->alicetomic); + if ( rswap->etomicdest[0] != 0 ) + jaddstr(item,"etomicdest",rswap->etomicdest); jaddnum(item,"destamount",dstr(rswap->destamount)); jaddnum(item,"alicetxfee",dstr(rswap->Atxfee)); jadd64bits(item,"aliceid",rswap->aliceid); From e9c427d194bc550c222e2afc2b628aafd2fdbdfb Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 9 Feb 2018 18:01:05 +0200 Subject: [PATCH 091/197] Bob needs to put etomicsrc even if bob coin is not ETH --- iguana/exchanges/LP_ordermatch.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index c54cec9d2..8bda2d117 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -849,11 +849,11 @@ double LP_trades_pricevalidate(struct LP_quoteinfo *qp,struct iguana_info *coin, struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,struct LP_quoteinfo *newqp,char *pairstr) { - double price,qprice,myprice,bestprice,range,bid,ask; struct iguana_info *coin; struct LP_utxoinfo A,B,*autxo,*butxo; cJSON *reqjson; char str[65]; struct LP_address_utxo *utxos[1000]; int32_t r,counter,max = (int32_t)(sizeof(utxos)/sizeof(*utxos)); + double price,qprice,myprice,bestprice,range,bid,ask; struct iguana_info *coin,*othercoin; struct LP_utxoinfo A,B,*autxo,*butxo; cJSON *reqjson; char str[65]; struct LP_address_utxo *utxos[1000]; int32_t r,counter,max = (int32_t)(sizeof(utxos)/sizeof(*utxos)); *newqp = *qp; qp = newqp; //printf("bob %s received REQUEST.(%llu)\n",bits256_str(str,G.LP_mypub25519),(long long)qp->aliceid); - if ( (coin= LP_coinfind(qp->srccoin)) == 0 ) + if ( (coin= LP_coinfind(qp->srccoin)) == 0 || (othercoin= LP_coinfind(qp->destcoin)) != 0 ) return(0); if ( (myprice= LP_trades_bobprice(&bid,&ask,qp)) == 0. ) return(0); @@ -866,13 +866,16 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru { qprice = (double)qp->destsatoshis / (qp->satoshis - qp->txfee); strcpy(qp->gui,G.gui); - strcpy(qp->coinaddr,coin->smartaddr); if ( coin->etomic[0] != 0 ) + strcpy(qp->coinaddr,coin->smartaddr); + else if ( othercoin->etomic[0] != 0 ) + strcpy(qp->coinaddr,othercoin->smartaddr); + if ( coin->etomic[0] != 0 || othercoin->etomic[0] != 0 ) { struct iguana_info *ecoin; if ( (ecoin= LP_coinfind("ETOMIC")) != 0 ) { - strcpy(qp->etomicsrc,coin->smartaddr); + strcpy(qp->etomicsrc,qp->coinaddr); strcpy(qp->coinaddr,ecoin->smartaddr); } else return(0); @@ -903,11 +906,15 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru //LP_address_utxo_reset(coin); //printf("done LP_address_utxo_reset.%s\n",coin->symbol); if ( coin->etomic[0] != 0 ) + strcpy(qp->coinaddr,coin->smartaddr); + else if ( othercoin->etomic[0] != 0 ) + strcpy(qp->coinaddr,othercoin->smartaddr); + if ( coin->etomic[0] != 0 || othercoin->etomic[0] != 0 ) { struct iguana_info *ecoin; if ( (ecoin= LP_coinfind("ETOMIC")) != 0 ) { - strcpy(qp->etomicsrc,coin->smartaddr); + strcpy(qp->etomicsrc,qp->coinaddr); strcpy(qp->coinaddr,ecoin->smartaddr); } else return(0); From f011ca26b567ac6d35515f00462c3ee5332e01d4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 9 Feb 2018 19:29:30 +0200 Subject: [PATCH 092/197] Always set qp->coinaddr --- iguana/exchanges/LP_ordermatch.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index 8bda2d117..df666981b 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -862,22 +862,20 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru memset(autxo,0,sizeof(*autxo)); memset(butxo,0,sizeof(*butxo)); LP_abutxo_set(autxo,butxo,qp); + strcpy(qp->coinaddr,coin->smartaddr); if ( bits256_nonz(qp->srchash) == 0 || bits256_cmp(qp->srchash,G.LP_mypub25519) == 0 ) { qprice = (double)qp->destsatoshis / (qp->satoshis - qp->txfee); strcpy(qp->gui,G.gui); if ( coin->etomic[0] != 0 ) - strcpy(qp->coinaddr,coin->smartaddr); + strcpy(qp->etomicsrc,coin->smartaddr); else if ( othercoin->etomic[0] != 0 ) - strcpy(qp->coinaddr,othercoin->smartaddr); + strcpy(qp->etomicsrc,othercoin->smartaddr); if ( coin->etomic[0] != 0 || othercoin->etomic[0] != 0 ) { struct iguana_info *ecoin; if ( (ecoin= LP_coinfind("ETOMIC")) != 0 ) - { - strcpy(qp->etomicsrc,qp->coinaddr); strcpy(qp->coinaddr,ecoin->smartaddr); - } else return(0); } strcpy(butxo->coinaddr,qp->coinaddr); @@ -906,17 +904,14 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru //LP_address_utxo_reset(coin); //printf("done LP_address_utxo_reset.%s\n",coin->symbol); if ( coin->etomic[0] != 0 ) - strcpy(qp->coinaddr,coin->smartaddr); + strcpy(qp->etomicsrc,coin->smartaddr); else if ( othercoin->etomic[0] != 0 ) - strcpy(qp->coinaddr,othercoin->smartaddr); + strcpy(qp->etomicsrc,othercoin->smartaddr); if ( coin->etomic[0] != 0 || othercoin->etomic[0] != 0 ) { struct iguana_info *ecoin; if ( (ecoin= LP_coinfind("ETOMIC")) != 0 ) - { - strcpy(qp->etomicsrc,qp->coinaddr); strcpy(qp->coinaddr,ecoin->smartaddr); - } else return(0); } if ( (butxo= LP_address_myutxopair(butxo,1,utxos,max,LP_coinfind(qp->srccoin),qp->coinaddr,qp->txfee,dstr(qp->destsatoshis),price,qp->desttxfee)) != 0 ) @@ -1432,14 +1427,15 @@ char *LP_autobuy(void *ctx,char *myipaddr,int32_t mypubsock,char *base,char *rel return(clonestr("{\"error\":\"cant set ordermatch quote\"}")); if ( LP_quotedestinfo(&Q,autxo->payment.txid,autxo->payment.vout,autxo->fee.txid,autxo->fee.vout,G.LP_mypub25519,autxo->coinaddr) < 0 ) return(clonestr("{\"error\":\"cant set ordermatch quote info\"}")); - if ( relcoin->etomic[0] != 0 ) + if ( relcoin->etomic[0] != 0 || basecoin->etomic[0] != 0 ) { struct iguana_info *coin; - if ( (coin= LP_coinfind("ETOMIC")) != 0 ) - { - strcpy(Q.etomicdest,Q.destaddr); + if ( relcoin->etomic[0] != 0 ) + strcpy(Q.etomicdest,relcoin->smartaddr); + else if (basecoin->etomic[0] != 0 ) + strcpy(Q.etomicdest,basecoin->smartaddr); + if ( relcoin->etomic[0] != 0 && (coin= LP_coinfind("ETOMIC")) != 0 ) strcpy(Q.destaddr,coin->smartaddr); - } else return(clonestr("{\"error\":\"cant find ETOMIC\"}")); } int32_t changed; From b04aa2ce0c108011c4d16801a0478449cde072bd Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 9 Feb 2018 19:40:35 +0200 Subject: [PATCH 093/197] Fix --- iguana/exchanges/LP_ordermatch.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index df666981b..d98862ba1 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -1434,9 +1434,12 @@ char *LP_autobuy(void *ctx,char *myipaddr,int32_t mypubsock,char *base,char *rel strcpy(Q.etomicdest,relcoin->smartaddr); else if (basecoin->etomic[0] != 0 ) strcpy(Q.etomicdest,basecoin->smartaddr); - if ( relcoin->etomic[0] != 0 && (coin= LP_coinfind("ETOMIC")) != 0 ) - strcpy(Q.destaddr,coin->smartaddr); - else return(clonestr("{\"error\":\"cant find ETOMIC\"}")); + if ( relcoin->etomic[0] != 0 ) + { + if ((coin= LP_coinfind("ETOMIC")) != 0 ) + strcpy(Q.destaddr,coin->smartaddr); + else return(clonestr("{\"error\":\"cant find ETOMIC\"}")); + } } int32_t changed; LP_mypriceset(&changed,autxo->coin,base,1. / maxprice); From 631803f07b5ecdf7ca53b192bea2eac994755969 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Feb 2018 01:09:57 +0200 Subject: [PATCH 094/197] Print atomic vars --- iguana/exchanges/LP_swap.c | 1 + 1 file changed, 1 insertion(+) diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index 9e7028b8d..b5dc64b51 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -1172,6 +1172,7 @@ struct basilisk_swap *bitcoin_swapinit(bits256 privkey,uint8_t *pubkey33,bits256 swap->I.aliceconfirms *= !swap->I.aliceistrusted; } printf(">>>>>>>>>> jumblrflag.%d <<<<<<<<< r.%u q.%u, %.8f bobconfs.%d, %.8f aliceconfs.%d taddr.%d %d\n",jumblrflag,swap->I.req.requestid,swap->I.req.quoteid,dstr(swap->I.bobsatoshis),swap->I.bobconfirms,dstr(swap->I.alicesatoshis),swap->I.aliceconfirms,bobcoin->taddr,alicecoin->taddr); + printf("etomic src (%s %s) dest (%s %s)\n",swap->I.bobtomic,swap->I.etomicsrc,swap->I.alicetomic,swap->I.etomicdest); if ( swap->I.iambob != 0 ) { basilisk_rawtx_setparms("myfee",swap->I.req.quoteid,&swap->myfee,bobcoin,0,0,LP_DEXFEE(swap->I.bobsatoshis) + 0*bobcoin->txfee,0,0,jumblrflag); From 9336956c9b7acef23083a4a95a24ed3af56384d7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Feb 2018 01:24:09 +0200 Subject: [PATCH 095/197] Test --- iguana/exchanges/LP_ordermatch.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index d98862ba1..fe720b4c1 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -852,11 +852,12 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru double price,qprice,myprice,bestprice,range,bid,ask; struct iguana_info *coin,*othercoin; struct LP_utxoinfo A,B,*autxo,*butxo; cJSON *reqjson; char str[65]; struct LP_address_utxo *utxos[1000]; int32_t r,counter,max = (int32_t)(sizeof(utxos)/sizeof(*utxos)); *newqp = *qp; qp = newqp; - //printf("bob %s received REQUEST.(%llu)\n",bits256_str(str,G.LP_mypub25519),(long long)qp->aliceid); + printf("bob %s received REQUEST.(%llu)\n",bits256_str(str,G.LP_mypub25519),(long long)qp->aliceid); if ( (coin= LP_coinfind(qp->srccoin)) == 0 || (othercoin= LP_coinfind(qp->destcoin)) != 0 ) return(0); if ( (myprice= LP_trades_bobprice(&bid,&ask,qp)) == 0. ) return(0); + printf("myprice %.8f\n",myprice); autxo = &A; butxo = &B; memset(autxo,0,sizeof(*autxo)); @@ -876,7 +877,11 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru struct iguana_info *ecoin; if ( (ecoin= LP_coinfind("ETOMIC")) != 0 ) strcpy(qp->coinaddr,ecoin->smartaddr); - else return(0); + else + { + printf("ETOMIC coin not found\n"); + return(0); + } } strcpy(butxo->coinaddr,qp->coinaddr); qp->srchash = G.LP_mypub25519; @@ -884,6 +889,7 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru memset(&qp->txid2,0,sizeof(qp->txid2)); qp->vout = qp->vout2 = -1; } else return(0); + printf("qprice %.8f vs myprice %.8f\n",qprice,myprice); if ( qprice > myprice ) { r = (LP_rand() % 100); @@ -912,7 +918,11 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru struct iguana_info *ecoin; if ( (ecoin= LP_coinfind("ETOMIC")) != 0 ) strcpy(qp->coinaddr,ecoin->smartaddr); - else return(0); + else + { + printf("ETOMIC coin not found\n"); + return(0); + } } if ( (butxo= LP_address_myutxopair(butxo,1,utxos,max,LP_coinfind(qp->srccoin),qp->coinaddr,qp->txfee,dstr(qp->destsatoshis),price,qp->desttxfee)) != 0 ) { @@ -928,7 +938,7 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru } else { - //printf("cant find utxopair aliceid.%llu %s/%s %.8f -> relvol %.8f\n",(long long)qp->aliceid,qp->srccoin,qp->destcoin,dstr(LP_basesatoshis(dstr(qp->destsatoshis),price,qp->txfee,qp->desttxfee)),dstr(qp->destsatoshis)); + printf("cant find utxopair aliceid.%llu %s/%s %.8f -> relvol %.8f\n",(long long)qp->aliceid,qp->srccoin,qp->destcoin,dstr(LP_basesatoshis(dstr(qp->destsatoshis),price,qp->txfee,qp->desttxfee)),dstr(qp->destsatoshis)); return(0); } if ( (qprice= LP_trades_pricevalidate(qp,coin,myprice)) < 0. ) From a0ed0f3627a665add443b34186af2121698e21b1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Feb 2018 01:29:28 +0200 Subject: [PATCH 096/197] Test --- iguana/exchanges/LP_ordermatch.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index fe720b4c1..3c3e491ba 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -856,7 +856,10 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru if ( (coin= LP_coinfind(qp->srccoin)) == 0 || (othercoin= LP_coinfind(qp->destcoin)) != 0 ) return(0); if ( (myprice= LP_trades_bobprice(&bid,&ask,qp)) == 0. ) + { + printf("myprice %.8f bid %.8f ask %.8f\n",myprice,bid,ask); return(0); + } printf("myprice %.8f\n",myprice); autxo = &A; butxo = &B; @@ -1443,7 +1446,10 @@ char *LP_autobuy(void *ctx,char *myipaddr,int32_t mypubsock,char *base,char *rel if ( relcoin->etomic[0] != 0 ) strcpy(Q.etomicdest,relcoin->smartaddr); else if (basecoin->etomic[0] != 0 ) - strcpy(Q.etomicdest,basecoin->smartaddr); + { + strcpy(Q.etomicdest,basecoin->smartaddr); + printf("Q.etomicdest (%s)\n",Q.etomicdest); + } if ( relcoin->etomic[0] != 0 ) { if ((coin= LP_coinfind("ETOMIC")) != 0 ) From 268a06d911985611342e4df3a9a47e9800d42297 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Feb 2018 01:35:06 +0200 Subject: [PATCH 097/197] Test --- 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 3c3e491ba..6ed4dd19e 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -533,7 +533,7 @@ char *LP_trade(void *ctx,char *myipaddr,int32_t mypubsock,struct LP_quoteinfo *q qp->srchash = destpubkey; LP_query(ctx,myipaddr,mypubsock,"request",qp); LP_Alicequery = *qp, LP_Alicemaxprice = maxprice, Alice_expiration = qp->timestamp + timeout, LP_Alicedestpubkey = destpubkey; - char str[65]; printf("LP_trade %s/%s %.8f vol %.8f dest.(%s) maxprice %.8f\n",qp->srccoin,qp->destcoin,dstr(qp->satoshis),dstr(qp->destsatoshis),bits256_str(str,LP_Alicedestpubkey),maxprice); + char str[65]; printf("LP_trade %s/%s %.8f vol %.8f dest.(%s) maxprice %.8f etomicdest.(%s)\n",qp->srccoin,qp->destcoin,dstr(qp->satoshis),dstr(qp->destsatoshis),bits256_str(str,LP_Alicedestpubkey),maxprice,qp->etomicdest); return(LP_recent_swaps(0)); } @@ -853,7 +853,7 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru *newqp = *qp; qp = newqp; printf("bob %s received REQUEST.(%llu)\n",bits256_str(str,G.LP_mypub25519),(long long)qp->aliceid); - if ( (coin= LP_coinfind(qp->srccoin)) == 0 || (othercoin= LP_coinfind(qp->destcoin)) != 0 ) + if ( (coin= LP_coinfind(qp->srccoin)) == 0 || (othercoin= LP_coinfind(qp->destcoin)) == 0 ) return(0); if ( (myprice= LP_trades_bobprice(&bid,&ask,qp)) == 0. ) { From 05c925a605330b829b9ab7eba9d7e81ac36d58fd Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Feb 2018 01:44:06 +0200 Subject: [PATCH 098/197] Test --- iguana/exchanges/LP_signatures.c | 10 +++------- iguana/exchanges/LP_swap.c | 2 ++ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/iguana/exchanges/LP_signatures.c b/iguana/exchanges/LP_signatures.c index 3854cb237..133a91608 100644 --- a/iguana/exchanges/LP_signatures.c +++ b/iguana/exchanges/LP_signatures.c @@ -48,16 +48,12 @@ cJSON *LP_quotejson(struct LP_quoteinfo *qp) jaddnum(retjson,"tradeid",qp->tradeid); jaddstr(retjson,"base",qp->srccoin); if ( LP_etomicsymbol(activesymbol,etomic,qp->srccoin) != 0 ) - { jaddstr(retjson,"bobetomic",etomic); - jaddstr(retjson,"etomicsrc",qp->etomicsrc); - } + jaddstr(retjson,"etomicsrc",qp->etomicsrc); jaddstr(retjson,"rel",qp->destcoin); if ( LP_etomicsymbol(activesymbol,etomic,qp->destcoin) != 0 ) - { jaddstr(retjson,"alicetomic",etomic); - jaddstr(retjson,"etomicdest",qp->etomicdest); - } + jaddstr(retjson,"etomicdest",qp->etomicdest); if ( qp->coinaddr[0] != 0 ) jaddstr(retjson,"address",qp->coinaddr); if ( qp->timestamp != 0 ) @@ -699,7 +695,7 @@ void LP_query(void *ctx,char *myipaddr,int32_t mypubsock,char *method,struct LP_ jadd(reqjson,"proof",LP_instantdex_txids(0,coin->smartaddr)); } msg = jprint(reqjson,1); - //printf("QUERY.(%s)\n",msg); + //printf("etomicdest.(%s) QUERY.(%s)\n",qp->etomicdest,msg); //if ( bits256_nonz(qp->srchash) == 0 || strcmp(method,"request") != 0 ) { memset(&zero,0,sizeof(zero)); diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index b5dc64b51..dc67fb498 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -1048,6 +1048,8 @@ struct basilisk_swap *bitcoin_swapinit(bits256 privkey,uint8_t *pubkey33,bits256 { //FILE *fp; char fname[512]; uint8_t *alicepub33=0,*bobpub33=0; int32_t jumblrflag=-2,x = -1; struct iguana_info *bobcoin,*alicecoin; char bobstr[65],alicestr[65]; + strcpy(swap->I.etomicsrc,qp->etomicsrc); + strcpy(swap->I.etomicdest,qp->etomicdest); strcpy(swap->I.bobstr,swap->I.req.src); strcpy(swap->I.alicestr,swap->I.req.dest); LP_etomicsymbol(bobstr,swap->I.bobtomic,swap->I.bobstr); From 252feebceb667ec81f787908c177386f9a6b2fa1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Feb 2018 21:16:51 +0200 Subject: [PATCH 099/197] Disable sock purging --- iguana/exchanges/LP_network.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_network.c b/iguana/exchanges/LP_network.c index a2d754b4b..8041d3df9 100644 --- a/iguana/exchanges/LP_network.c +++ b/iguana/exchanges/LP_network.c @@ -613,7 +613,9 @@ void LP_psockloop(void *_ptr) } // else printf("num pfds.%d retval.%d\n",n,retval); } } - if ( IAMLP != 0 && sendsock < 0 ) + if ( sendsock < 0 ) + usleep(10000); + if ( 0 && IAMLP != 0 && sendsock < 0 ) { usleep(30000); for (i=nonz=0; i Date: Sun, 11 Feb 2018 20:41:53 +0700 Subject: [PATCH 100/197] Send Alice's ETH payment and claim it by Bob. --- iguana/exchanges/LP_etomic.c | 69 +++++++- iguana/exchanges/LP_include.h | 2 +- iguana/exchanges/LP_remember.c | 36 ++-- iguana/exchanges/LP_swap.c | 2 +- iguana/exchanges/etomicswap/bob.c | 199 ++++++++++++---------- iguana/exchanges/etomicswap/etomiclib.cpp | 18 ++ iguana/exchanges/etomicswap/etomiclib.h | 138 +++++++-------- iguana/exchanges/mm.c | 8 +- 8 files changed, 287 insertions(+), 185 deletions(-) diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index c2320254c..bb532a5ad 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -41,7 +41,7 @@ int32_t LP_etomicsymbol(char *activesymbol,char *etomic,char *symbol) return(etomic[0] != 0); } -char *LP_etomicalice_start(struct basilisk_swap *swap) +char *LP_etomicalice_send_payment(struct basilisk_swap *swap) { AliceSendsEthPaymentInput input; AliceSendsErc20PaymentInput input20; BasicTxData txData; // set input and txData fields from the swap data structure @@ -49,14 +49,79 @@ char *LP_etomicalice_start(struct basilisk_swap *swap) if ( strcmp(swap->I.alicestr,"ETH") == 0 ) { memset(&input,0,sizeof(input)); + strcpy(input.bobAddress, swap->I.etomicsrc); + uint8arrayToHex(input.bobHash, swap->I.secretBn, 20); + uint8arrayToHex(input.aliceHash, swap->I.secretAm, 20); + uint8arrayToHex(input.dealId, swap->alicepayment.utxotxid.bytes, 32); + + strcpy(txData.from, swap->I.etomicdest); + strcpy(txData.to, ETOMIC_ALICECONTRACT); + satoshisToWei(txData.amount, swap->I.alicesatoshis); + uint8arrayToHex(txData.secretKey, swap->persistent_privkey.bytes, 32); return(aliceSendsEthPayment(input,txData)); } else { memset(&input20,0,sizeof(input20)); + strcpy(input20.bobAddress, swap->I.etomicdest); + uint8arrayToHex(input20.bobHash, swap->I.secretBn, 20); + uint8arrayToHex(input20.aliceHash, swap->I.secretAm, 20); + uint8arrayToHex(input20.dealId, swap->alicepayment.utxotxid.bytes, 32); + strcpy(input20.tokenAddress, swap->I.alicetomic); + satoshisToWei(input20.amount, swap->I.alicesatoshis); + + strcpy(txData.from, swap->I.etomicsrc); + strcpy(txData.to, ETOMIC_ALICECONTRACT); + strcpy(txData.amount, "0"); + uint8arrayToHex(txData.secretKey, swap->persistent_privkey.bytes, 32); return(aliceSendsErc20Payment(input20,txData)); } - return(0); +} + +char *LP_etomicalice_reclaims_payment(struct basilisk_swap *swap) +{ + AliceReclaimsAlicePaymentInput input; + BasicTxData txData; + memset(&txData,0,sizeof(txData)); + memset(&input,0,sizeof(input)); + uint8arrayToHex(input.dealId, swap->alicepayment.utxotxid.bytes, 32); + satoshisToWei(input.amount, swap->I.alicesatoshis); + strcpy(input.tokenAddress, swap->I.alicetomic); + strcpy(input.bobAddress, swap->I.etomicdest); + uint8arrayToHex(input.aliceHash, swap->I.secretAm, 20); + uint8arrayToHex(input.bobSecret, swap->I.secretBn256, 32); + + strcpy(txData.from, swap->I.etomicsrc); + strcpy(txData.to, ETOMIC_ALICECONTRACT); + strcpy(txData.amount, "0"); + uint8arrayToHex(txData.secretKey, swap->persistent_privkey.bytes, 32); +} + +char *LP_etomicbob_spends_alice_payment(struct LP_swap_remember *swap) +{ + BobSpendsAlicePaymentInput input; + BasicTxData txData; + + memset(&txData,0,sizeof(txData)); + memset(&input,0,sizeof(input)); + + uint8arrayToHex(input.dealId, swap->txids[BASILISK_ALICEPAYMENT].bytes, 32); + satoshisToWei(input.amount, swap->destamount); + + if (swap->alicetomic[0] != 0) + strcpy(input.tokenAddress, swap->alicetomic); + else + strcpy(input.tokenAddress, "0x0000000000000000000000000000000000000000"); + + strcpy(input.aliceAddress, swap->etomicdest); + uint8arrayToHex(input.aliceSecret, swap->secretAm256, 32); + uint8arrayToHex(input.bobHash, swap->secretBn, 20); + + strcpy(txData.from, swap->etomicsrc); + strcpy(txData.to, ETOMIC_ALICECONTRACT); + strcpy(txData.amount, "0"); + uint8arrayToHex(txData.secretKey, swap->persistentPrivKey.bytes, 32); + return bobSpendsAlicePayment(input, txData); } int32_t LP_etomic_priv2addr(char *coinaddr,bits256 privkey) diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index edcce170a..316f5dbb8 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -270,7 +270,7 @@ char *txnames[] = { "alicespend", "bobspend", "bobpayment", "alicepayment", "bob struct LP_swap_remember { - bits256 pubA0,pubB0,pubB1,privAm,privBn,paymentspent,Apaymentspent,depositspent,myprivs[2],txids[sizeof(txnames)/sizeof(*txnames)]; + bits256 persistentPrivKey,pubA0,pubB0,pubB1,privAm,privBn,paymentspent,Apaymentspent,depositspent,myprivs[2],txids[sizeof(txnames)/sizeof(*txnames)]; uint64_t Atxfee,Btxfee,srcamount,destamount,aliceid; int64_t values[sizeof(txnames)/sizeof(*txnames)]; uint32_t finishtime,tradeid,requestid,quoteid,plocktime,dlocktime,expiration,state,otherstate; diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 5e022eebe..ef81265d6 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -70,6 +70,11 @@ void basilisk_dontforget(struct basilisk_swap *swap,struct basilisk_rawtx *rawtx fprintf(fp,",\"bobtomic\":\"%s\"",swap->I.bobtomic); if ( swap->I.etomicsrc[0] != 0 ) fprintf(fp,",\"etomicsrc\":\"%s\"",swap->I.etomicsrc); + + char persistentPrivKeyStr[100]; + bits256_str(persistentPrivKeyStr,swap->persistent_privkey); + fprintf(fp,",\"persistentPrivKey\":\"%s\"",persistentPrivKeyStr); + fprintf(fp,",\"alicecoin\":\"%s\"",swap->I.alicestr); if ( swap->I.alicetomic[0] != 0 ) fprintf(fp,",\"alicetomic\":\"%s\"",swap->I.alicetomic); @@ -128,6 +133,7 @@ void basilisk_dontforget(struct basilisk_swap *swap,struct basilisk_rawtx *rawtx init_hexbytes_noT(secretBn256str,swap->I.secretBn256,32); fprintf(fp,",\"secretBn256\":\"%s\"",secretBn256str); } + for (i=0; i<2; i++) if ( bits256_nonz(swap->I.myprivs[i]) != 0 ) fprintf(fp,",\"myprivs%d\":\"%s\"",i,bits256_str(str,swap->I.myprivs[i])); @@ -845,6 +851,19 @@ int32_t LP_swap_load(struct LP_swap_remember *rswap,int32_t forceflag) free_json(txobj); continue; } + + if (jstr(txobj,"etomicsrc") != 0) + { + strcpy(rswap->etomicsrc,jstr(txobj,"etomicsrc")); + } + + if (jstr(txobj,"etomicdest") != 0) + { + strcpy(rswap->etomicdest,jstr(txobj,"etomicdest")); + } + + rswap->persistentPrivKey = jbits256(txobj,"persistentPrivKey"); + rswap->txids[i] = txid; if ( jstr(txobj,"Apayment") != 0 ) safecopy(rswap->alicepaymentaddr,jstr(txobj,"Apayment"),sizeof(rswap->alicepaymentaddr)); @@ -1019,24 +1038,8 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti srcAdest = srcBdest = destAdest = destBdest = 0; alice = LP_coinfind(rswap.alicecoin); bob = LP_coinfind(rswap.bobcoin); - if ( alice != 0 ) - strcpy(etomicdest,alice->smartaddr); - else etomicdest[0] = 0; - if ( bob != 0 ) - strcpy(etomicsrc,bob->smartaddr); - else etomicsrc[0] = 0; LP_etomicsymbol(bobstr,bobtomic,rswap.src); - if ( bobtomic[0] != 0 ) - { - if ( (coin= LP_coinfind(rswap.src)) != 0 ) - strcpy(etomicsrc,coin->smartaddr); - } LP_etomicsymbol(alicestr,alicetomic,rswap.dest); - if ( alicetomic[0] != 0 ) - { - if ( (coin= LP_coinfind(rswap.dest)) != 0 ) - strcpy(etomicdest,coin->smartaddr); - } if ( rswap.bobcoin[0] == 0 || rswap.alicecoin[0] == 0 || strcmp(rswap.bobcoin,bobstr) != 0 || strcmp(rswap.alicecoin,alicestr) != 0 ) { //printf("legacy r%u-q%u DB SWAPS.(%u %u) %llu files BOB.(%s) Alice.(%s) src.(%s) dest.(%s)\n",requestid,quoteid,rswap.requestid,rswap.quoteid,(long long)rswap.aliceid,rswap.bobcoin,rswap.alicecoin,rswap.src,rswap.dest); @@ -1275,6 +1278,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti if ( (rswap.txbytes[BASILISK_BOBSPEND]= basilisk_swap_Aspend("bobspend",rswap.alicecoin,rswap.Atxfee,alice->wiftaddr,alice->taddr,alice->pubtype,alice->p2shtype,alice->isPoS,alice->wiftype,ctx,rswap.privAm,rswap.privBn,rswap.txids[BASILISK_ALICEPAYMENT],0,rswap.pubkey33,rswap.expiration,&rswap.values[BASILISK_BOBSPEND],rswap.alicepaymentaddr,alice->zcash)) != 0 ) { //printf("bobspend.(%s)\n",rswap.txbytes[BASILISK_BOBSPEND]); + LP_etomicbob_spends_alice_payment(&rswap); } } LP_txbytes_update("bobspend",rswap.alicecoin,rswap.txbytes[BASILISK_BOBSPEND],&rswap.txids[BASILISK_BOBSPEND],&rswap.Apaymentspent,&rswap.sentflags[BASILISK_BOBSPEND]); diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index dc67fb498..f28af0c10 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -867,7 +867,7 @@ void LP_aliceloop(void *_swap) LP_swap_critical = (uint32_t)time(NULL); if ( swap->I.alicetomic[0] != 0 ) { - // artem: do stuff alice needs to do at the beginning of the swap, before dexfee + LP_etomicalice_send_payment(swap); } if ( LP_swapdata_rawtxsend(swap->N.pair,swap,0x80,data,maxlen,&swap->myfee,0x40,0) == 0 ) printf("error sending alicefee\n"); diff --git a/iguana/exchanges/etomicswap/bob.c b/iguana/exchanges/etomicswap/bob.c index ede02320d..08a52a49e 100644 --- a/iguana/exchanges/etomicswap/bob.c +++ b/iguana/exchanges/etomicswap/bob.c @@ -5,6 +5,7 @@ #include #include #include +#include #include "etomiclib.h" char* bobContractAddress = "0x9387Fd3a016bB0205e4e131Dde886B9d2BC000A2"; @@ -36,144 +37,142 @@ int main(int argc, char** argv) switch (action) { case BOB_ETH_DEPOSIT: - txData.amount = "1000000000000000000"; - txData.from = bobAddress; - txData.to = bobContractAddress; - txData.secretKey = getenv("BOB_PK"); - - BobSendsEthDepositInput input = { - .aliceAddress = aliceAddress, - .depositId = argv[2], - .bobHash = argv[3] - }; + strcpy(txData.amount, "1000000000000000000"); + strcpy(txData.from, bobAddress); + strcpy(txData.to, bobContractAddress); + strcpy(txData.secretKey, getenv("BOB_PK")); + + BobSendsEthDepositInput input; + + strcpy(input.aliceAddress, aliceAddress); + strcpy(input.depositId, argv[2]); + strcpy(input.bobHash, argv[3]); result = bobSendsEthDeposit(input, txData); printf("%s\n", result); free(result); break; case BOB_ERC20_DEPOSIT: - txData.amount = "0"; - txData.from = bobAddress; - txData.to = bobContractAddress; - txData.secretKey = getenv("BOB_PK"); + strcpy(txData.amount, "0"); + strcpy(txData.from, bobAddress); + strcpy(txData.to, bobContractAddress); + strcpy(txData.secretKey, getenv("BOB_PK")); BobSendsErc20DepositInput input1 = { - .depositId = argv[2], - .amount = "1000000000000000000", - .aliceAddress = aliceAddress, - .bobHash = argv[3], - .tokenAddress = tokenAddress + .amount = "1000000000000000000" }; + strcpy(input1.depositId, argv[2]); + strcpy(input1.aliceAddress, aliceAddress); + strcpy(input1.bobHash, argv[3]); + strcpy(input1.tokenAddress, tokenAddress); + result = bobSendsErc20Deposit(input1, txData); printf("%s\n", result); free(result); break; case BOB_CLAIMS_DEPOSIT: - txData.amount = "0"; - txData.from = bobAddress; - txData.to = bobContractAddress; - txData.secretKey = getenv("BOB_PK"); - - BobRefundsDepositInput input2 = { - .depositId = argv[2], - .amount = "1000000000000000000", - .aliceAddress = aliceAddress, - .tokenAddress = argv[3], - .aliceCanClaimAfter = argv[4], - .bobSecret = argv[5] - }; + strcpy(txData.amount, "0"); + strcpy(txData.from, bobAddress); + strcpy(txData.to, bobContractAddress); + strcpy(txData.secretKey, getenv("BOB_PK")); + + BobRefundsDepositInput input2; + strcpy(input2.depositId, argv[2]); + strcpy(input2.amount, "1000000000000000000"); + strcpy(input2.aliceAddress, aliceAddress); + strcpy(input2.tokenAddress, argv[3]); + strcpy(input2.aliceCanClaimAfter, argv[4]); + strcpy(input2.bobSecret, argv[5]); result = bobRefundsDeposit(input2, txData); printf("%s\n", result); free(result); break; case ALICE_CLAIMS_DEPOSIT: - txData.amount = "0"; - txData.from = aliceAddress; - txData.to = bobContractAddress; - txData.secretKey = getenv("ALICE_PK"); - - AliceClaimsBobDepositInput input3 = { - .depositId = argv[2], - .amount = "1000000000000000000", - .bobAddress = bobAddress, - .tokenAddress = argv[3], - .aliceCanClaimAfter = argv[4], - .bobHash = argv[5] - }; + strcpy(txData.amount, "0"); + strcpy(txData.from, aliceAddress); + strcpy(txData.to, bobContractAddress); + strcpy(txData.secretKey, getenv("ALICE_PK")); + + AliceClaimsBobDepositInput input3; + strcpy(input3.depositId, argv[2]); + strcpy(input3.amount, "1000000000000000000"); + strcpy(input3.bobAddress, bobAddress); + strcpy(input3.tokenAddress, argv[3]); + strcpy(input3.aliceCanClaimAfter, argv[4]); + strcpy(input3.bobHash, argv[5]); result = aliceClaimsBobDeposit(input3, txData); printf("%s\n", result); free(result); break; case BOB_ETH_PAYMENT: - txData.amount = "1000000000000000000"; - txData.from = bobAddress; - txData.to = bobContractAddress; - txData.secretKey = getenv("BOB_PK"); - - BobSendsEthPaymentInput input4 = { - .paymentId = argv[2], - .aliceHash = argv[3], - .aliceAddress = aliceAddress - }; + strcpy(txData.amount, "1000000000000000000"); + strcpy(txData.from, bobAddress); + strcpy(txData.to, bobContractAddress); + strcpy(txData.secretKey, getenv("BOB_PK")); + + BobSendsEthPaymentInput input4; + strcpy(input4.paymentId, argv[2]); + strcpy(input4.aliceHash, argv[3]); + strcpy(input4.aliceAddress, aliceAddress); result = bobSendsEthPayment(input4, txData); printf("%s\n", result); free(result); break; case BOB_ERC20_PAYMENT: - txData.amount = "0"; - txData.from = bobAddress; - txData.to = bobContractAddress; - txData.secretKey = getenv("BOB_PK"); - - BobSendsErc20PaymentInput input5 = { - .paymentId = argv[2], - .amount = "1000000000000000000", - .tokenAddress = tokenAddress, - .aliceAddress = aliceAddress, - .aliceHash = argv[3] - }; + strcpy(txData.amount, "0"); + strcpy(txData.from, bobAddress); + strcpy(txData.to, bobContractAddress); + strcpy(txData.secretKey, getenv("BOB_PK")); + + BobSendsErc20PaymentInput input5; + + strcpy(input5.paymentId, argv[2]); + strcpy(input5.amount, "1000000000000000000"); + strcpy(input5.tokenAddress, tokenAddress); + strcpy(input5.aliceAddress, aliceAddress); + strcpy(input5.aliceHash, argv[3]); result = bobSendsErc20Payment(input5, txData); printf("%s\n", result); free(result); break; case BOB_CLAIMS_PAYMENT: - txData.amount = "0"; - txData.from = bobAddress; - txData.to = bobContractAddress; - txData.secretKey = getenv("BOB_PK"); - - BobReclaimsBobPaymentInput input6 = { - .paymentId = argv[2], - .aliceAddress = aliceAddress, - .amount = "1000000000000000000", - .tokenAddress = argv[3], - .bobCanClaimAfter = argv[4], - .aliceHash = argv[5] - }; + strcpy(txData.amount, "0"); + strcpy(txData.from, bobAddress); + strcpy(txData.to, bobContractAddress); + strcpy(txData.secretKey, getenv("BOB_PK")); + + BobReclaimsBobPaymentInput input6; + + strcpy(input6.paymentId, argv[2]); + strcpy(input6.aliceAddress, aliceAddress); + strcpy(input6.amount, "1000000000000000000"); + strcpy(input6.tokenAddress, argv[3]); + strcpy(input6.bobCanClaimAfter, argv[4]); + strcpy(input6.aliceHash, argv[5]); result = bobReclaimsBobPayment(input6, txData); printf("%s\n", result); free(result); break; case ALICE_CLAIMS_PAYMENT: - txData.amount = "0"; - txData.from = aliceAddress; - txData.to = bobContractAddress; - txData.secretKey = getenv("ALICE_PK"); - - AliceSpendsBobPaymentInput input7 = { - .paymentId = argv[2], - .bobAddress = bobAddress, - .amount = "1000000000000000000", - .tokenAddress = argv[3], - .bobCanClaimAfter = argv[4], - .aliceSecret = argv[5] - }; + strcpy(txData.amount, "0"); + strcpy(txData.from, aliceAddress); + strcpy(txData.to, bobContractAddress); + strcpy(txData.secretKey, getenv("ALICE_PK")); + + AliceSpendsBobPaymentInput input7; + + strcpy(input7.paymentId, argv[2]); + strcpy(input7.bobAddress, bobAddress); + strcpy(input7.amount, "1000000000000000000"); + strcpy(input7.tokenAddress, argv[3]); + strcpy(input7.bobCanClaimAfter, argv[4]); + strcpy(input7.aliceSecret, argv[5]); result = aliceSpendsBobPayment(input7, txData); printf("%s\n", result); @@ -198,5 +197,19 @@ int main(int argc, char** argv) default: return 1; } + char *pubkey = getPubKeyFromPriv(getenv("BOB_PK")); + printf("pubkey: %s\n", pubkey); + free(pubkey); + uint8_t test[2]; + test[0] = 100; + test[1] = 100; + char buf[30]; + uint8arrayToHex(buf, test, 2); + printf("hex: %s\n", buf); + + uint64_t satoshis = 100000000; + char weiBuffer[100]; + satoshisToWei(weiBuffer, satoshis); + printf("wei: %s\n", weiBuffer); return 0; } diff --git a/iguana/exchanges/etomicswap/etomiclib.cpp b/iguana/exchanges/etomicswap/etomiclib.cpp index 5e3fe6e2b..9b4130a80 100644 --- a/iguana/exchanges/etomicswap/etomiclib.cpp +++ b/iguana/exchanges/etomicswap/etomiclib.cpp @@ -7,6 +7,8 @@ #include #include #include +#include + using namespace dev; using namespace dev::eth; @@ -355,3 +357,19 @@ uint64_t getErc20Balance(char* address, char* tokenAddress) free(hexBalance); return static_cast(balance); } + +void uint8arrayToHex(char *dest, uint8_t *input, int len) +{ + strcpy(dest, "0x"); + for (int i = 0; i < len; i++) + { + sprintf(dest + (i + 1) * 2, "%02x", input[i]); + } + dest[(len + 1) * 2] = '\0'; +} + +void satoshisToWei(char *dest, uint64_t input) +{ + sprintf(dest, "%" PRIu64, input); + strcat(dest, "0000000000"); +} diff --git a/iguana/exchanges/etomicswap/etomiclib.h b/iguana/exchanges/etomicswap/etomiclib.h index a5267eb4a..a8c594007 100644 --- a/iguana/exchanges/etomicswap/etomiclib.h +++ b/iguana/exchanges/etomicswap/etomiclib.h @@ -7,111 +7,111 @@ extern "C" { #endif typedef struct { - char* from; - char* to; - char* amount; - char* secretKey; + char from[65]; + char to[65]; + char amount[100]; + char secretKey[70]; } BasicTxData; typedef struct { - char* dealId; - char* bobAddress; - char* aliceHash; - char* bobHash; + char dealId[70]; + char bobAddress[65]; + char aliceHash[65]; + char bobHash[65]; } AliceSendsEthPaymentInput; typedef struct { - char* dealId; - char* amount; - char* tokenAddress; - char* bobAddress; - char* aliceHash; - char* bobHash; + char dealId[70]; + char amount[100]; + char tokenAddress[65]; + char bobAddress[65]; + char aliceHash[65]; + char bobHash[65]; } AliceSendsErc20PaymentInput; typedef struct { - char* dealId; - char* amount; - char* tokenAddress; - char* bobAddress; - char* aliceHash; - char* bobSecret; + char dealId[70]; + char amount[100]; + char tokenAddress[65]; + char bobAddress[65]; + char aliceHash[65]; + char bobSecret[70]; } AliceReclaimsAlicePaymentInput; typedef struct { - char* dealId; - char* amount; - char* tokenAddress; - char* aliceAddress; - char* aliceSecret; - char* bobHash; + char dealId[70]; + char amount[100]; + char tokenAddress[65]; + char aliceAddress[65]; + char aliceSecret[70]; + char bobHash[65]; } BobSpendsAlicePaymentInput; typedef struct { - char* depositId; - char* aliceAddress; - char* bobHash; + char depositId[70]; + char aliceAddress[65]; + char bobHash[65]; } BobSendsEthDepositInput; typedef struct { - char* depositId; - char* amount; - char* tokenAddress; - char* aliceAddress; - char* bobHash; + char depositId[70]; + char amount[100]; + char tokenAddress[65]; + char aliceAddress[65]; + char bobHash[65]; } BobSendsErc20DepositInput; typedef struct { - char* depositId; - char* amount; - char* tokenAddress; - char* aliceAddress; - char* bobSecret; - char* aliceCanClaimAfter; + char depositId[70]; + char amount[100]; + char tokenAddress[65]; + char aliceAddress[65]; + char bobSecret[70]; + char aliceCanClaimAfter[100]; } BobRefundsDepositInput; typedef struct { - char* depositId; - char* amount; - char* tokenAddress; - char* bobAddress; - char* bobHash; - char* aliceCanClaimAfter; + char depositId[70]; + char amount[100]; + char tokenAddress[65]; + char bobAddress[65]; + char bobHash[65]; + char aliceCanClaimAfter[100]; } AliceClaimsBobDepositInput; typedef struct { - char* paymentId; - char* aliceAddress; - char* aliceHash; + char paymentId[70]; + char aliceAddress[65]; + char aliceHash[65]; } BobSendsEthPaymentInput; typedef struct { - char* paymentId; - char* amount; - char* tokenAddress; - char* aliceAddress; - char* aliceHash; + char paymentId[70]; + char amount[100]; + char tokenAddress[65]; + char aliceAddress[65]; + char aliceHash[65]; } BobSendsErc20PaymentInput; typedef struct { - char* paymentId; - char* amount; - char* tokenAddress; - char* aliceAddress; - char* aliceHash; - char* bobCanClaimAfter; + char paymentId[70]; + char amount[100]; + char tokenAddress[65]; + char aliceAddress[65]; + char aliceHash[65]; + char bobCanClaimAfter[100]; } BobReclaimsBobPaymentInput; typedef struct { - char* paymentId; - char* amount; - char* tokenAddress; - char* aliceSecret; - char* bobAddress; - char* bobCanClaimAfter; + char paymentId[70]; + char amount[100]; + char tokenAddress[65]; + char aliceSecret[70]; + char bobAddress[65]; + char bobCanClaimAfter[100]; } AliceSpendsBobPaymentInput; -char* approveErc20(char* amount, char* from, char* secret); +char* approveErc20(char amount[100], char* from, char* secret); char* aliceSendsEthPayment(AliceSendsEthPaymentInput input, BasicTxData txData); char* aliceSendsErc20Payment(AliceSendsErc20PaymentInput input, BasicTxData txData); char* aliceReclaimsAlicePayment(AliceReclaimsAlicePaymentInput input, BasicTxData txData); @@ -128,7 +128,9 @@ char* privKey2Addr(char* privKey); char* pubKey2Addr(char* pubKey); char* getPubKeyFromPriv(char* privKey); uint64_t getEthBalance(char* address); -uint64_t getErc20Balance(char* address, char* tokenAddress); +uint64_t getErc20Balance(char* address, char tokenAddress[65]); +void uint8arrayToHex(char *dest, uint8_t *input, int len); +void satoshisToWei(char *dest, uint64_t input); // Your prototype or Definition #ifdef __cplusplus } diff --git a/iguana/exchanges/mm.c b/iguana/exchanges/mm.c index e25c729de..7717a60e5 100644 --- a/iguana/exchanges/mm.c +++ b/iguana/exchanges/mm.c @@ -115,10 +115,10 @@ void LP_main(void *ptr) void ETH_test() { BasicTxData txData; char* ethSignedTx; - txData.amount = "1000000000000000000"; - txData.from = "0xA7EF3f65714AE266414C9E58bB4bAa4E6FB82B41"; - txData.to = "0x9387Fd3a016bB0205e4e131Dde886B9d2BC000A2"; - txData.secretKey = getenv("BOB_PK"); + strcpy(txData.amount, "1000000000000000000"); + strcpy(txData.from, "0xA7EF3f65714AE266414C9E58bB4bAa4E6FB82B41"); + strcpy(txData.to, "0x9387Fd3a016bB0205e4e131Dde886B9d2BC000A2"); + strcpy(txData.secretKey, getenv("BOB_PK")); BobSendsEthDepositInput input = { .aliceAddress = "0x485d2cc2d13a9e12E4b53D606DB1c8adc884fB8a", .depositId = "0x28c5a7c25911ef59a577ddf811d0e58edb827efb0646a8a38df6e921ba53f431", From 1e5fc9c46d49b70c774f6e1ac3539b4cc2edbf2e Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Sun, 11 Feb 2018 20:51:22 +0700 Subject: [PATCH 101/197] Send Alice ETH payment. --- 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 f28af0c10..8732c3cfd 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -867,7 +867,7 @@ void LP_aliceloop(void *_swap) LP_swap_critical = (uint32_t)time(NULL); if ( swap->I.alicetomic[0] != 0 ) { - LP_etomicalice_send_payment(swap); + } if ( LP_swapdata_rawtxsend(swap->N.pair,swap,0x80,data,maxlen,&swap->myfee,0x40,0) == 0 ) printf("error sending alicefee\n"); @@ -892,7 +892,7 @@ void LP_aliceloop(void *_swap) { if ( swap->I.alicetomic[0] != 0 ) { - // artem: do stuff alice needs to do right before alicepayment goes out + LP_etomicalice_send_payment(swap); } m = swap->I.aliceconfirms; while ( (n= LP_numconfirms(alicestr,swap->alicepayment.I.destaddr,swap->alicepayment.I.signedtxid,0,1)) < m ) From 1058553c1918ba9f8c492ce4156b725176d2b5c4 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Sun, 11 Feb 2018 22:26:37 +0700 Subject: [PATCH 102/197] Send Alice ETH payment and claim by Bob. --- iguana/exchanges/LP_etomic.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index bb532a5ad..3b8dfb44d 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -52,12 +52,29 @@ char *LP_etomicalice_send_payment(struct basilisk_swap *swap) strcpy(input.bobAddress, swap->I.etomicsrc); uint8arrayToHex(input.bobHash, swap->I.secretBn, 20); uint8arrayToHex(input.aliceHash, swap->I.secretAm, 20); - uint8arrayToHex(input.dealId, swap->alicepayment.utxotxid.bytes, 32); + uint8arrayToHex(input.dealId, swap->alicepayment.I.actualtxid.bytes, 32); strcpy(txData.from, swap->I.etomicdest); strcpy(txData.to, ETOMIC_ALICECONTRACT); satoshisToWei(txData.amount, swap->I.alicesatoshis); uint8arrayToHex(txData.secretKey, swap->persistent_privkey.bytes, 32); + + char aliceSecret[100]; + uint8arrayToHex(aliceSecret, swap->I.privAm.bytes, 32); + printf("alice secret: %s\n", aliceSecret); + + init_hexbytes_noT(aliceSecret, swap->I.privAm.bytes, 32); + printf("alice secret: %s\n", aliceSecret); + + init_hexbytes_noT(aliceSecret, swap->alicepayment.I.actualtxid.bytes, 32); + printf("alice txid: %s\n", aliceSecret); + + bits256 hash; int32_t i; + for (i=0; i<32; i++) + hash.bytes[i] = swap->I.privAm.bytes[31-i]; + uint8arrayToHex(aliceSecret, hash.bytes, 32); + printf("alice secret: %s\n", aliceSecret); + return(aliceSendsEthPayment(input,txData)); } else @@ -84,7 +101,7 @@ char *LP_etomicalice_reclaims_payment(struct basilisk_swap *swap) BasicTxData txData; memset(&txData,0,sizeof(txData)); memset(&input,0,sizeof(input)); - uint8arrayToHex(input.dealId, swap->alicepayment.utxotxid.bytes, 32); + uint8arrayToHex(input.dealId, swap->alicepayment.I.actualtxid.bytes, 32); satoshisToWei(input.amount, swap->I.alicesatoshis); strcpy(input.tokenAddress, swap->I.alicetomic); strcpy(input.bobAddress, swap->I.etomicdest); @@ -114,9 +131,19 @@ char *LP_etomicbob_spends_alice_payment(struct LP_swap_remember *swap) strcpy(input.tokenAddress, "0x0000000000000000000000000000000000000000"); strcpy(input.aliceAddress, swap->etomicdest); - uint8arrayToHex(input.aliceSecret, swap->secretAm256, 32); + bits256 hash; int32_t i; + for (i=0; i<32; i++) + hash.bytes[i] = swap->privAm.bytes[31-i]; + uint8arrayToHex(input.aliceSecret, hash.bytes, 32); uint8arrayToHex(input.bobHash, swap->secretBn, 20); + char aliceSecret[100]; + uint8arrayToHex(aliceSecret, swap->privAm.bytes, 32); + printf("alice secret: %s\n", aliceSecret); + + uint8arrayToHex(aliceSecret, hash.bytes, 32); + printf("alice secret: %s\n", aliceSecret); + strcpy(txData.from, swap->etomicsrc); strcpy(txData.to, ETOMIC_ALICECONTRACT); strcpy(txData.amount, "0"); From 0d8165f60b800d4a4966bebc3c4b95a8042f9b6a Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 13 Feb 2018 18:20:10 +0300 Subject: [PATCH 103/197] Scripthash != script --- iguana/exchanges/LP_socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_socket.c b/iguana/exchanges/LP_socket.c index 08265e494..d750a5aac 100644 --- a/iguana/exchanges/LP_socket.c +++ b/iguana/exchanges/LP_socket.c @@ -530,7 +530,7 @@ cJSON *electrum_scripthash_cmd(char *symbol,uint8_t taddr,struct electrum_info * uint8_t addrtype,rmd160[20]; char scripthash[51],rmdstr[41],cmdbuf[128]; bitcoin_addr2rmd160(symbol,taddr,&addrtype,rmd160,coinaddr); init_hexbytes_noT(rmdstr,rmd160,20); - sprintf(scripthash,"76a914%s88ac",rmdstr); + sprintf(scripthash,"%s",rmdstr); sprintf(cmdbuf,"blockchain.scripthash.%s",cmd); return(electrum_strarg(symbol,ep,retjsonp,cmdbuf,scripthash,ELECTRUM_TIMEOUT)); } From 4a0785b1a3b243671bef2d0dce8fb2f2c2f7dcaf Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Tue, 13 Feb 2018 22:29:25 +0700 Subject: [PATCH 104/197] Bob sends ETH deposit and payment and able to refund deposit. --- iguana/exchanges/LP_etomic.c | 125 ++++++++++++++++++----- iguana/exchanges/LP_include.h | 4 +- iguana/exchanges/LP_remember.c | 25 +++-- iguana/exchanges/LP_swap.c | 40 +++++++- iguana/exchanges/etomicswap/bob.c | 15 +-- iguana/exchanges/etomicswap/etomiccurl.c | 35 ++++++- iguana/exchanges/etomicswap/etomiccurl.h | 8 ++ 7 files changed, 206 insertions(+), 46 deletions(-) diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index 3b8dfb44d..b708ed8ea 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -22,6 +22,8 @@ // Created by artem on 24.01.18. // #include "etomicswap/etomiclib.h" +#include "etomicswap/etomiccurl.h" +#include #define ETOMIC_ALICECONTRACT "0xe1D4236C5774D35Dc47dcc2E5E0CcFc463A3289c" #define ETOMIC_BOBCONTRACT "0x9387Fd3a016bB0205e4e131Dde886B9d2BC000A2" @@ -59,22 +61,6 @@ char *LP_etomicalice_send_payment(struct basilisk_swap *swap) satoshisToWei(txData.amount, swap->I.alicesatoshis); uint8arrayToHex(txData.secretKey, swap->persistent_privkey.bytes, 32); - char aliceSecret[100]; - uint8arrayToHex(aliceSecret, swap->I.privAm.bytes, 32); - printf("alice secret: %s\n", aliceSecret); - - init_hexbytes_noT(aliceSecret, swap->I.privAm.bytes, 32); - printf("alice secret: %s\n", aliceSecret); - - init_hexbytes_noT(aliceSecret, swap->alicepayment.I.actualtxid.bytes, 32); - printf("alice txid: %s\n", aliceSecret); - - bits256 hash; int32_t i; - for (i=0; i<32; i++) - hash.bytes[i] = swap->I.privAm.bytes[31-i]; - uint8arrayToHex(aliceSecret, hash.bytes, 32); - printf("alice secret: %s\n", aliceSecret); - return(aliceSendsEthPayment(input,txData)); } else @@ -137,13 +123,6 @@ char *LP_etomicbob_spends_alice_payment(struct LP_swap_remember *swap) uint8arrayToHex(input.aliceSecret, hash.bytes, 32); uint8arrayToHex(input.bobHash, swap->secretBn, 20); - char aliceSecret[100]; - uint8arrayToHex(aliceSecret, swap->privAm.bytes, 32); - printf("alice secret: %s\n", aliceSecret); - - uint8arrayToHex(aliceSecret, hash.bytes, 32); - printf("alice secret: %s\n", aliceSecret); - strcpy(txData.from, swap->etomicsrc); strcpy(txData.to, ETOMIC_ALICECONTRACT); strcpy(txData.amount, "0"); @@ -151,6 +130,106 @@ char *LP_etomicbob_spends_alice_payment(struct LP_swap_remember *swap) return bobSpendsAlicePayment(input, txData); } +char *LP_etomicbob_sends_deposit(struct basilisk_swap *swap) +{ + BobSendsEthDepositInput input; + BasicTxData txData; + memset(&txData,0,sizeof(txData)); + memset(&input,0,sizeof(input)); + + uint8arrayToHex(input.depositId, swap->bobdeposit.I.actualtxid.bytes, 32); + strcpy(input.aliceAddress, swap->I.etomicdest); + uint8arrayToHex(input.bobHash, swap->I.secretBn, 20); + + strcpy(txData.from, swap->I.etomicsrc); + strcpy(txData.to, ETOMIC_BOBCONTRACT); + satoshisToWei(txData.amount, swap->bobdeposit.I.amount); + uint8arrayToHex(txData.secretKey, swap->persistent_privkey.bytes, 32); + return bobSendsEthDeposit(input, txData); +} + +char *LP_etomicbob_refunds_deposit(struct LP_swap_remember *swap) +{ + BobRefundsDepositInput input; + BasicTxData txData; + memset(&txData,0,sizeof(txData)); + memset(&input,0,sizeof(input)); + + EthTxReceipt receipt = getEthTxReceipt(swap->bobDepositEthTx); + uint8arrayToHex(input.depositId, swap->txids[BASILISK_BOBDEPOSIT].bytes, 32); + strcpy(input.aliceAddress, swap->etomicdest); + sprintf(input.aliceCanClaimAfter, "%" PRIu64, receipt.blockNumber + 960); + + bits256 invertedSecret; + int32_t i; + for (i=0; i<32; i++) { + invertedSecret.bytes[i] = swap->privBn.bytes[31 - i]; + } + uint8arrayToHex(input.bobSecret, invertedSecret.bytes, 32); + + if (swap->bobtomic[0] != 0) { + strcpy(input.tokenAddress, swap->bobtomic); + } else { + strcpy(input.tokenAddress, "0x0000000000000000000000000000000000000000"); + } + satoshisToWei(input.amount, swap->values[BASILISK_BOBDEPOSIT]); + + strcpy(txData.from, swap->etomicsrc); + strcpy(txData.to, ETOMIC_BOBCONTRACT); + strcpy(txData.amount, "0"); + uint8arrayToHex(txData.secretKey, swap->persistentPrivKey.bytes, 32); + return bobRefundsDeposit(input, txData); +} + +char *LP_etomicbob_sends_payment(struct basilisk_swap *swap) +{ + BobSendsEthPaymentInput input; + BasicTxData txData; + memset(&txData,0,sizeof(txData)); + memset(&input,0,sizeof(input)); + + uint8arrayToHex(input.paymentId, swap->bobpayment.I.actualtxid.bytes, 32); + strcpy(input.aliceAddress, swap->I.etomicdest); + uint8arrayToHex(input.aliceHash, swap->I.secretAm, 20); + + strcpy(txData.from, swap->I.etomicsrc); + strcpy(txData.to, ETOMIC_BOBCONTRACT); + satoshisToWei(txData.amount, swap->bobpayment.I.amount); + uint8arrayToHex(txData.secretKey, swap->persistent_privkey.bytes, 32); + return bobSendsEthPayment(input, txData); +} + +char *LP_etomicalice_spends_bob_payment(struct LP_swap_remember *swap) +{ + AliceSpendsBobPaymentInput input; + BasicTxData txData; + + memset(&txData,0,sizeof(txData)); + memset(&input,0,sizeof(input)); + + uint8arrayToHex(input.paymentId, swap->txids[BASILISK_BOBPAYMENT].bytes, 32); + satoshisToWei(input.amount, swap->values[BASILISK_BOBPAYMENT]); + + if (swap->bobtomic[0] != 0) { + strcpy(input.tokenAddress, swap->bobtomic); + } else { + strcpy(input.tokenAddress, "0x0000000000000000000000000000000000000000"); + } + + strcpy(input.bobAddress, swap->etomicsrc); + bits256 hash; int32_t i; + for (i=0; i<32; i++) { + hash.bytes[i] = swap->privAm.bytes[31 - i]; + } + uint8arrayToHex(input.aliceSecret, hash.bytes, 32); + + strcpy(txData.from, swap->etomicdest); + strcpy(txData.to, ETOMIC_BOBCONTRACT); + strcpy(txData.amount, "0"); + uint8arrayToHex(txData.secretKey, swap->persistentPrivKey.bytes, 32); + return aliceSpendsBobPayment(input, txData); +} + int32_t LP_etomic_priv2addr(char *coinaddr,bits256 privkey) { char str[65],*addrstr; diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index 316f5dbb8..1aa167d75 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -202,7 +202,7 @@ struct basilisk_swap; struct basilisk_rawtxinfo { - char destaddr[64]; + char destaddr[64],ethTxid[75]; bits256 txid,signedtxid,actualtxid; int64_t amount,change,inputsum; int32_t redeemlen,datalen,completed,vintype,vouttype,numconfirms,spendlen,secretstart,suppress_pubkeys; @@ -276,7 +276,7 @@ struct LP_swap_remember uint32_t finishtime,tradeid,requestid,quoteid,plocktime,dlocktime,expiration,state,otherstate; int32_t iambob,finishedflag,origfinishedflag,Predeemlen,Dredeemlen,sentflags[sizeof(txnames)/sizeof(*txnames)]; uint8_t secretAm[20],secretAm256[32],secretBn[20],secretBn256[32],Predeemscript[1024],Dredeemscript[1024],pubkey33[33],other33[33]; - char Agui[65],Bgui[65],gui[65],src[65],dest[65],bobtomic[128],alicetomic[128],etomicsrc[65],etomicdest[65],destaddr[64],Adestaddr[64],Sdestaddr[64],alicepaymentaddr[64],bobpaymentaddr[64],bobdepositaddr[64],alicecoin[65],bobcoin[65],*txbytes[sizeof(txnames)/sizeof(*txnames)]; + char Agui[65],Bgui[65],gui[65],src[65],dest[65],bobtomic[128],alicetomic[128],etomicsrc[65],etomicdest[65],destaddr[64],Adestaddr[64],Sdestaddr[64],alicepaymentaddr[64],bobpaymentaddr[64],bobdepositaddr[64],alicecoin[65],bobcoin[65],*txbytes[sizeof(txnames)/sizeof(*txnames)],bobDepositEthTx[75],bobPaymentEthTx[75]; }; struct LP_outpoint diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index ef81265d6..5c0d6d803 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -17,7 +17,6 @@ // LP_remember.c // marketmaker // - void basilisk_dontforget_userdata(char *userdataname,FILE *fp,uint8_t *script,int32_t scriptlen) { int32_t i; char scriptstr[513]; @@ -70,7 +69,12 @@ void basilisk_dontforget(struct basilisk_swap *swap,struct basilisk_rawtx *rawtx fprintf(fp,",\"bobtomic\":\"%s\"",swap->I.bobtomic); if ( swap->I.etomicsrc[0] != 0 ) fprintf(fp,",\"etomicsrc\":\"%s\"",swap->I.etomicsrc); - + if (swap->bobdeposit.I.ethTxid[0] != 0) { + fprintf(fp,",\"bobDepositEthTx\":\"%s\"", swap->bobdeposit.I.ethTxid); + } + if (swap->bobpayment.I.ethTxid[0] != 0) { + fprintf(fp,",\"bobPaymentEthTx\":\"%s\"", swap->bobpayment.I.ethTxid); + } char persistentPrivKeyStr[100]; bits256_str(persistentPrivKeyStr,swap->persistent_privkey); fprintf(fp,",\"persistentPrivKey\":\"%s\"",persistentPrivKeyStr); @@ -852,17 +856,23 @@ int32_t LP_swap_load(struct LP_swap_remember *rswap,int32_t forceflag) continue; } - if (jstr(txobj,"etomicsrc") != 0) - { + if (jstr(txobj,"etomicsrc") != 0) { strcpy(rswap->etomicsrc,jstr(txobj,"etomicsrc")); } - if (jstr(txobj,"etomicdest") != 0) - { + if (jstr(txobj,"etomicdest") != 0) { strcpy(rswap->etomicdest,jstr(txobj,"etomicdest")); } - rswap->persistentPrivKey = jbits256(txobj,"persistentPrivKey"); + if (jstr(txobj,"bobDepositEthTx") != 0) { + strcpy(rswap->bobDepositEthTx, jstr(txobj,"bobDepositEthTx")); + } + + if (jstr(txobj,"bobPaymentEthTx") != 0) { + strcpy(rswap->bobPaymentEthTx, jstr(txobj,"bobPaymentEthTx")); + } + + rswap->persistentPrivKey = jbits256(txobj, "persistentPrivKey"); rswap->txids[i] = txid; if ( jstr(txobj,"Apayment") != 0 ) @@ -1337,6 +1347,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti len = basilisk_swapuserdata(userdata,rswap.privBn,0,rswap.myprivs[0],redeemscript,redeemlen); if ( (rswap.txbytes[BASILISK_BOBREFUND]= basilisk_swap_bobtxspend(&signedtxid,rswap.Btxfee,"bobrefund",rswap.bobcoin,bob->wiftaddr,bob->taddr,bob->pubtype,bob->p2shtype,bob->isPoS,bob->wiftype,ctx,rswap.myprivs[0],0,redeemscript,redeemlen,userdata,len,rswap.txids[BASILISK_BOBDEPOSIT],0,0,rswap.pubkey33,1,rswap.expiration,&rswap.values[BASILISK_BOBREFUND],0,0,rswap.bobdepositaddr,1,bob->zcash)) != 0 ) { + LP_etomicbob_refunds_deposit(&rswap); //printf("pubB1.(%s) bobrefund.(%s)\n",bits256_str(str,rswap.pubB1),rswap.txbytes[BASILISK_BOBREFUND]); } } diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index 8732c3cfd..86b52a9d6 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -792,6 +792,7 @@ void LP_bobloop(void *_swap) printf("error bobscripts deposit\n"); else { + uint8_t error = 0; swap->bobrefund.utxovout = 0; swap->bobrefund.utxotxid = swap->bobdeposit.I.signedtxid; basilisk_bobdeposit_refund(swap,swap->I.putduration); @@ -799,12 +800,36 @@ void LP_bobloop(void *_swap) LP_swapsfp_update(&swap->I.req); LP_swap_critical = (uint32_t)time(NULL); if ( LP_waitfor(swap->N.pair,swap,LP_SWAPSTEP_TIMEOUT*10,LP_verify_otherfee) < 0 ) + { + error = 1; printf("error waiting for alicefee\n"); - else if ( LP_swapdata_rawtxsend(swap->N.pair,swap,0x200,data,maxlen,&swap->bobdeposit,0x100,0) == 0 ) - printf("error sending bobdeposit\n"); - else if ( LP_waitfor(swap->N.pair,swap,1800,LP_verify_alicepayment) < 0 ) + } + + if ( error == 0 ) + { + if ( LP_swapdata_rawtxsend(swap->N.pair,swap,0x200,data,maxlen,&swap->bobdeposit,0x100,0) != 0 ) + { + if (swap->I.bobtomic[0] != 0) + { + char *depositTx = LP_etomicbob_sends_deposit(swap); + strcpy(swap->bobdeposit.I.ethTxid, depositTx); + free(depositTx); + } + } + else + { + error = 1; + printf("error sending bobdeposit\n"); + } + } + + if ( error == 0 && LP_waitfor(swap->N.pair,swap,1800,LP_verify_alicepayment) < 0 ) + { + error = 1; printf("error waiting for alicepayment\n"); - else + } + + if (error == 0) { LP_swap_critical = (uint32_t)time(NULL); if ( basilisk_bobscripts_set(swap,0,1) < 0 ) @@ -819,8 +844,13 @@ void LP_bobloop(void *_swap) sleep(10); } LP_swap_critical = (uint32_t)time(NULL); - if ( LP_swapdata_rawtxsend(swap->N.pair,swap,0x8000,data,maxlen,&swap->bobpayment,0x4000,0) == 0 ) + if ( LP_swapdata_rawtxsend(swap->N.pair,swap,0x8000,data,maxlen,&swap->bobpayment,0x4000,0) == 0 ) { printf("error sending bobpayment\n"); + } else if (swap->I.bobtomic[0] != 0) { + char *paymentTx = LP_etomicbob_sends_payment(swap); + strcpy(swap->bobpayment.I.ethTxid, paymentTx); + free(paymentTx); + } //if ( LP_waitfor(swap->N.pair,swap,10,LP_verify_alicespend) < 0 ) // printf("error waiting for alicespend\n"); //swap->sentflag = 1; diff --git a/iguana/exchanges/etomicswap/bob.c b/iguana/exchanges/etomicswap/bob.c index 08a52a49e..a2a1e0361 100644 --- a/iguana/exchanges/etomicswap/bob.c +++ b/iguana/exchanges/etomicswap/bob.c @@ -7,6 +7,7 @@ #include #include #include "etomiclib.h" +#include "etomiccurl.h" char* bobContractAddress = "0x9387Fd3a016bB0205e4e131Dde886B9d2BC000A2"; char* aliceAddress = "0x485d2cc2d13a9e12E4b53D606DB1c8adc884fB8a"; @@ -27,6 +28,7 @@ int main(int argc, char** argv) BOB_APPROVES_ERC20, BOB_ETH_BALANCE, BOB_ERC20_BALANCE, + TX_RECEIPT }; if (argc < 2) { return 1; @@ -194,18 +196,19 @@ int main(int argc, char** argv) case BOB_ERC20_BALANCE: printf("%" PRIu64 "\n", getErc20Balance(bobAddress, tokenAddress)); break; + case TX_RECEIPT: + printf("getTxReceipt\n"); + EthTxReceipt txReceipt; + txReceipt = getEthTxReceipt("0x9c3f31859dcba6d1032ed82074a0fe74a04b749d5e9feedc8a49bf78bf8f2b2c"); + printf("%" PRIu64 "\n", txReceipt.blockNumber); + printf("%s\n", txReceipt.blockHash); + break; default: return 1; } char *pubkey = getPubKeyFromPriv(getenv("BOB_PK")); printf("pubkey: %s\n", pubkey); free(pubkey); - uint8_t test[2]; - test[0] = 100; - test[1] = 100; - char buf[30]; - uint8arrayToHex(buf, test, 2); - printf("hex: %s\n", buf); uint64_t satoshis = 100000000; char weiBuffer[100]; diff --git a/iguana/exchanges/etomicswap/etomiccurl.c b/iguana/exchanges/etomicswap/etomiccurl.c index f8e3958be..52d6bdf57 100644 --- a/iguana/exchanges/etomicswap/etomiccurl.c +++ b/iguana/exchanges/etomicswap/etomiccurl.c @@ -88,6 +88,7 @@ char* sendRawTx(char* rawTx) strcpy(txId, tmp); cJSON_Delete(json); free(requestResult); + free(string); return txId; } @@ -109,6 +110,7 @@ int getNonce(char* address) int nonce = (int)strtol(cJSON_GetObjectItem(json, "result")->valuestring, NULL, 0); cJSON_Delete(json); free(requestResult); + free(string); return nonce; } @@ -132,6 +134,7 @@ char* getEthBalanceRequest(char* address) strcpy(balance, tmp); cJSON_Delete(json); free(requestResult); + free(string); return balance; } @@ -154,9 +157,35 @@ char* ethCall(char* to, const char* data) cJSON_Delete(request); cJSON *json = cJSON_Parse(requestResult); char* tmp = cJSON_GetObjectItem(json, "result")->valuestring; - char* balance = (char*)malloc(strlen(tmp) + 1); - strcpy(balance, tmp); + char* result = (char*)malloc(strlen(tmp) + 1); + strcpy(result, tmp); cJSON_Delete(json); free(requestResult); - return balance; + free(string); + return result; +} + +EthTxReceipt getEthTxReceipt(char *txId) +{ + EthTxReceipt result; + + char* string; + cJSON *request = cJSON_CreateObject(); + cJSON *params = cJSON_CreateArray(); + cJSON_AddItemToObject(request, "jsonrpc", cJSON_CreateString("2.0")); + cJSON_AddItemToObject(request, "method", cJSON_CreateString("eth_getTransactionReceipt")); + cJSON_AddItemToArray(params, cJSON_CreateString(txId)); + cJSON_AddItemToObject(request, "params", params); + cJSON_AddItemToObject(request, "id", cJSON_CreateNumber(2)); + string = cJSON_PrintUnformatted(request); + char *requestResult = sendRequest(string); + cJSON_Delete(request); + cJSON *json = cJSON_Parse(requestResult); + cJSON *tmp = cJSON_GetObjectItem(json, "result"); + strcpy(result.blockHash, cJSON_GetObjectItem(tmp, "blockHash")->valuestring); + result.blockNumber = (uint64_t)strtol(cJSON_GetObjectItem(tmp, "blockNumber")->valuestring, NULL, 0); + cJSON_Delete(json); + free(requestResult); + free(string); + return result; } diff --git a/iguana/exchanges/etomicswap/etomiccurl.h b/iguana/exchanges/etomicswap/etomiccurl.h index 54e71d4d5..a158c3060 100644 --- a/iguana/exchanges/etomicswap/etomiccurl.h +++ b/iguana/exchanges/etomicswap/etomiccurl.h @@ -1,11 +1,19 @@ +#include + #ifdef __cplusplus extern "C"{ #endif +typedef struct +{ + uint64_t blockNumber; + char blockHash[75]; +} EthTxReceipt; char* sendRawTx(char* rawTx); char* ethCall(char* to, const char* data); int getNonce(char* address); char* getEthBalanceRequest(char* address); +EthTxReceipt getEthTxReceipt(char *txId); #ifdef __cplusplus } From 3eff96ae7ed68509c026b58ca7b0494961cd9a08 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Wed, 14 Feb 2018 17:19:09 +0700 Subject: [PATCH 105/197] Adding ETH txid exchange when performing ETOMIC swaps. --- iguana/exchanges/LP_swap.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index 86b52a9d6..6c2cd505a 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -583,6 +583,10 @@ int32_t LP_rawtx_spendscript(struct basilisk_swap *swap,int32_t height,struct ba otherhash.bytes[i] = recvbuf[offset++]; for (i=0; i<32; i++) myhash.bytes[i] = recvbuf[offset++]; + + uint8arrayToHex(rawtx->I.ethTxid, recvbuf[offset], 32); + offset += 32; + printf("ETH txid received: %s", rawtx->I.ethTxid); offset += iguana_rwnum(0,&recvbuf[offset],sizeof(quoteid),"eid); offset += iguana_rwnum(0,&recvbuf[offset],sizeof(msgbits),&msgbits); datalen = recvbuf[offset++]; @@ -625,6 +629,8 @@ int32_t LP_rawtx_spendscript(struct basilisk_swap *swap,int32_t height,struct ba printf("%s rawtx data compare error, len %d vs %d <<<<<<<<<< warning\n",rawtx->name,rawtx->I.datalen,datalen); return(-1); } + + if ( recvlen != datalen+rawtx->I.redeemlen+75 ) printf("RECVLEN %d != %d + %d\n",recvlen,datalen,rawtx->I.redeemlen); txid = bits256_calctxid(coin->symbol,data,datalen); @@ -692,6 +698,17 @@ uint32_t LP_swapdata_rawtxsend(int32_t pairsock,struct basilisk_swap *swap,uint3 if ( bits256_nonz(rawtx->I.actualtxid) != 0 && msgbits != 0 ) { sendlen = 0; + if (rawtx->I.ethTxid[0] != 0 && strlen(rawtx->I.ethTxid) == 66) { + bytes *ethTxidBytes; + // ETH txid always starts with 0x + decode_hex(ethTxidBytes, 32, rawtx->I.ethTxid + 2); + memccpy(&sendbuf[sendlen], ethTxidBytes, 32); + free(ethTxidBytes); + } else { + // fill with zero bytes to always have fixed message size + memset(&sendbuf[sendlen], 0, 32); + } + sendlen += 32; sendbuf[sendlen++] = rawtx->I.datalen & 0xff; sendbuf[sendlen++] = (rawtx->I.datalen >> 8) & 0xff; sendbuf[sendlen++] = rawtx->I.redeemlen; @@ -703,6 +720,7 @@ uint32_t LP_swapdata_rawtxsend(int32_t pairsock,struct basilisk_swap *swap,uint3 memcpy(&sendbuf[sendlen],rawtx->redeemscript,rawtx->I.redeemlen); sendlen += rawtx->I.redeemlen; } + basilisk_dontforget_update(swap,rawtx); //printf("sendlen.%d datalen.%d redeemlen.%d\n",sendlen,rawtx->datalen,rawtx->redeemlen); if ( suppress_swapsend == 0 ) @@ -916,14 +934,17 @@ void LP_aliceloop(void *_swap) char str[65];printf("%d wait for bobdeposit %s numconfs.%d %s %s\n",n,swap->bobdeposit.I.destaddr,m,bobstr,bits256_str(str,swap->bobdeposit.I.signedtxid)); sleep(10); } + if ( swap->I.alicetomic[0] != 0 ) { + char *paymentEthTx = LP_etomicalice_send_payment(swap); + if (paymentEthTx[0] != 0) { + strcpy(swap->alicepayment.I.ethTxid, paymentEthTx); + } + free(paymentEthTx); + } if ( LP_swapdata_rawtxsend(swap->N.pair,swap,0x1000,data,maxlen,&swap->alicepayment,0x800,0) == 0 ) printf("error sending alicepayment\n"); else { - if ( swap->I.alicetomic[0] != 0 ) - { - LP_etomicalice_send_payment(swap); - } m = swap->I.aliceconfirms; while ( (n= LP_numconfirms(alicestr,swap->alicepayment.I.destaddr,swap->alicepayment.I.signedtxid,0,1)) < m ) { From 5a8c740d2ad3be1bfb5a0dcc1ce7822fc6d14c1a Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Wed, 14 Feb 2018 17:26:29 +0700 Subject: [PATCH 106/197] Fix build and warnings. --- iguana/exchanges/LP_swap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index 6c2cd505a..6b97e2c79 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -584,7 +584,7 @@ int32_t LP_rawtx_spendscript(struct basilisk_swap *swap,int32_t height,struct ba for (i=0; i<32; i++) myhash.bytes[i] = recvbuf[offset++]; - uint8arrayToHex(rawtx->I.ethTxid, recvbuf[offset], 32); + uint8arrayToHex(rawtx->I.ethTxid, &recvbuf[offset], 32); offset += 32; printf("ETH txid received: %s", rawtx->I.ethTxid); offset += iguana_rwnum(0,&recvbuf[offset],sizeof(quoteid),"eid); @@ -699,10 +699,10 @@ uint32_t LP_swapdata_rawtxsend(int32_t pairsock,struct basilisk_swap *swap,uint3 { sendlen = 0; if (rawtx->I.ethTxid[0] != 0 && strlen(rawtx->I.ethTxid) == 66) { - bytes *ethTxidBytes; + uint8_t *ethTxidBytes; // ETH txid always starts with 0x decode_hex(ethTxidBytes, 32, rawtx->I.ethTxid + 2); - memccpy(&sendbuf[sendlen], ethTxidBytes, 32); + memcpy(&sendbuf[sendlen], ethTxidBytes, 32); free(ethTxidBytes); } else { // fill with zero bytes to always have fixed message size From dc2de48910dfbde95339bc5abadce80099f9430d Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Wed, 14 Feb 2018 18:03:30 +0700 Subject: [PATCH 107/197] Exchange ETH txids. --- iguana/exchanges/LP_swap.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index 6b97e2c79..c13101d71 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -584,9 +584,6 @@ int32_t LP_rawtx_spendscript(struct basilisk_swap *swap,int32_t height,struct ba for (i=0; i<32; i++) myhash.bytes[i] = recvbuf[offset++]; - uint8arrayToHex(rawtx->I.ethTxid, &recvbuf[offset], 32); - offset += 32; - printf("ETH txid received: %s", rawtx->I.ethTxid); offset += iguana_rwnum(0,&recvbuf[offset],sizeof(quoteid),"eid); offset += iguana_rwnum(0,&recvbuf[offset],sizeof(msgbits),&msgbits); datalen = recvbuf[offset++]; @@ -597,6 +594,9 @@ int32_t LP_rawtx_spendscript(struct basilisk_swap *swap,int32_t height,struct ba return(-1); } rawtx->I.redeemlen = recvbuf[offset++]; + uint8arrayToHex(rawtx->I.ethTxid, &recvbuf[offset], 32); + offset += 32; + printf("ETH txid received: %s", rawtx->I.ethTxid); data = &recvbuf[offset]; if ( rawtx->I.redeemlen > 0 && rawtx->I.redeemlen < 0x100 ) { @@ -825,14 +825,16 @@ void LP_bobloop(void *_swap) if ( error == 0 ) { + if (swap->I.bobtomic[0] != 0) + { + char *depositTx = LP_etomicbob_sends_deposit(swap); + strcpy(swap->bobdeposit.I.ethTxid, depositTx); + free(depositTx); + } + if ( LP_swapdata_rawtxsend(swap->N.pair,swap,0x200,data,maxlen,&swap->bobdeposit,0x100,0) != 0 ) { - if (swap->I.bobtomic[0] != 0) - { - char *depositTx = LP_etomicbob_sends_deposit(swap); - strcpy(swap->bobdeposit.I.ethTxid, depositTx); - free(depositTx); - } + } else { From 59e1dc82d4f1b202f40b05d71eaa5b116b703dac Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Wed, 14 Feb 2018 18:12:42 +0700 Subject: [PATCH 108/197] Exchange ETH txids. --- iguana/exchanges/LP_swap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index c13101d71..e8a327467 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -698,6 +698,9 @@ uint32_t LP_swapdata_rawtxsend(int32_t pairsock,struct basilisk_swap *swap,uint3 if ( bits256_nonz(rawtx->I.actualtxid) != 0 && msgbits != 0 ) { sendlen = 0; + sendbuf[sendlen++] = rawtx->I.datalen & 0xff; + sendbuf[sendlen++] = (rawtx->I.datalen >> 8) & 0xff; + sendbuf[sendlen++] = rawtx->I.redeemlen; if (rawtx->I.ethTxid[0] != 0 && strlen(rawtx->I.ethTxid) == 66) { uint8_t *ethTxidBytes; // ETH txid always starts with 0x @@ -709,9 +712,6 @@ uint32_t LP_swapdata_rawtxsend(int32_t pairsock,struct basilisk_swap *swap,uint3 memset(&sendbuf[sendlen], 0, 32); } sendlen += 32; - sendbuf[sendlen++] = rawtx->I.datalen & 0xff; - sendbuf[sendlen++] = (rawtx->I.datalen >> 8) & 0xff; - sendbuf[sendlen++] = rawtx->I.redeemlen; //int32_t z; for (z=0; zI.datalen; z++) printf("%02x",rawtx->txbytes[z]); printf(" >>>>>>> send.%d %s\n",rawtx->I.datalen,rawtx->name); //printf("datalen.%d redeemlen.%d\n",rawtx->I.datalen,rawtx->I.redeemlen); memcpy(&sendbuf[sendlen],rawtx->txbytes,rawtx->I.datalen), sendlen += rawtx->I.datalen; From 3e0f8255f0cd50038a7f87b0d6056f0b06e43d69 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Wed, 14 Feb 2018 18:17:59 +0700 Subject: [PATCH 109/197] Exchange ETH txids. --- iguana/exchanges/LP_swap.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index e8a327467..b84b08c21 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -702,11 +702,10 @@ uint32_t LP_swapdata_rawtxsend(int32_t pairsock,struct basilisk_swap *swap,uint3 sendbuf[sendlen++] = (rawtx->I.datalen >> 8) & 0xff; sendbuf[sendlen++] = rawtx->I.redeemlen; if (rawtx->I.ethTxid[0] != 0 && strlen(rawtx->I.ethTxid) == 66) { - uint8_t *ethTxidBytes; + uint8_t ethTxidBytes[32]; // ETH txid always starts with 0x decode_hex(ethTxidBytes, 32, rawtx->I.ethTxid + 2); memcpy(&sendbuf[sendlen], ethTxidBytes, 32); - free(ethTxidBytes); } else { // fill with zero bytes to always have fixed message size memset(&sendbuf[sendlen], 0, 32); From 64e84d610b23d99d9554e63c364d61300a40f449 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Wed, 14 Feb 2018 18:32:51 +0700 Subject: [PATCH 110/197] Exchange ETH txids. --- iguana/exchanges/LP_swap.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index b84b08c21..24c189542 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -863,13 +863,16 @@ void LP_bobloop(void *_swap) sleep(10); } LP_swap_critical = (uint32_t)time(NULL); - if ( LP_swapdata_rawtxsend(swap->N.pair,swap,0x8000,data,maxlen,&swap->bobpayment,0x4000,0) == 0 ) { - printf("error sending bobpayment\n"); - } else if (swap->I.bobtomic[0] != 0) { + + if (swap->I.bobtomic[0] != 0) { char *paymentTx = LP_etomicbob_sends_payment(swap); strcpy(swap->bobpayment.I.ethTxid, paymentTx); free(paymentTx); } + + if ( LP_swapdata_rawtxsend(swap->N.pair,swap,0x8000,data,maxlen,&swap->bobpayment,0x4000,0) == 0 ) { + printf("error sending bobpayment\n"); + } //if ( LP_waitfor(swap->N.pair,swap,10,LP_verify_alicespend) < 0 ) // printf("error waiting for alicespend\n"); //swap->sentflag = 1; From 00c6897902dcfc5761142d9343435dcd9d267965 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Wed, 14 Feb 2018 19:55:47 +0700 Subject: [PATCH 111/197] Send ETH payments and deposits inside sendrawtx. --- iguana/exchanges/LP_etomic.c | 17 ++++++++++++++++ iguana/exchanges/LP_remember.c | 2 +- iguana/exchanges/LP_swap.c | 37 +++++++--------------------------- 3 files changed, 25 insertions(+), 31 deletions(-) diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index b708ed8ea..b59be7417 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -206,9 +206,11 @@ char *LP_etomicalice_spends_bob_payment(struct LP_swap_remember *swap) memset(&txData,0,sizeof(txData)); memset(&input,0,sizeof(input)); + EthTxReceipt receipt = getEthTxReceipt(swap->bobDepositEthTx); uint8arrayToHex(input.paymentId, swap->txids[BASILISK_BOBPAYMENT].bytes, 32); satoshisToWei(input.amount, swap->values[BASILISK_BOBPAYMENT]); + sprintf(input.bobCanClaimAfter, "%" PRIu64, receipt.blockNumber + 480); if (swap->bobtomic[0] != 0) { strcpy(input.tokenAddress, swap->bobtomic); @@ -230,6 +232,21 @@ char *LP_etomicalice_spends_bob_payment(struct LP_swap_remember *swap) return aliceSpendsBobPayment(input, txData); } +char *sendEthTx(struct basilisk_swap *swap, struct basilisk_rawtx *rawtx) +{ + if (rawtx == &swap->alicepayment && swap->I.alicetomic[0] != 0) { + return LP_etomicalice_send_payment(swap); + } else if (rawtx == &swap->bobdeposit && swap->I.bobtomic[0] != 0) { + return LP_etomicbob_sends_deposit(swap); + } else if (rawtx == &swap->bobpayment && swap->I.bobtomic[0] != 0) { + return LP_etomicbob_sends_payment(swap); + } else { + char *result = malloc(66); + strcpy(result, "0x0000000000000000000000000000000000000000000000000000000000000000"); + return result; + } +} + int32_t LP_etomic_priv2addr(char *coinaddr,bits256 privkey) { char str[65],*addrstr; diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 5c0d6d803..c9d0eed50 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -1207,7 +1207,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti rev.bytes[j] = rswap.myprivs[0].bytes[31 - j]; if ( (rswap.txbytes[BASILISK_ALICESPEND]= basilisk_swap_bobtxspend(&signedtxid,rswap.Btxfee,"alicespend",rswap.bobcoin,bob->wiftaddr,bob->taddr,bob->pubtype,bob->p2shtype,bob->isPoS,bob->wiftype,ctx,rswap.myprivs[0],0,redeemscript,redeemlen,userdata,len,rswap.txids[BASILISK_BOBPAYMENT],0,0,rswap.pubkey33,1,rswap.expiration,&rswap.values[BASILISK_ALICESPEND],0,0,rswap.bobpaymentaddr,1,bob->zcash)) != 0 ) { - //printf("alicespend.(%s)\n",rswap.txbytes[BASILISK_ALICESPEND]); + LP_etomicalice_spends_bob_payment(&rswap); } } LP_txbytes_update("alicespend",rswap.bobcoin,rswap.txbytes[BASILISK_ALICESPEND],&rswap.txids[BASILISK_ALICESPEND],&rswap.paymentspent,&rswap.sentflags[BASILISK_ALICESPEND]); diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index 24c189542..aca5f74f0 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -697,6 +697,11 @@ uint32_t LP_swapdata_rawtxsend(int32_t pairsock,struct basilisk_swap *swap,uint3 } if ( bits256_nonz(rawtx->I.actualtxid) != 0 && msgbits != 0 ) { + if (swap->I.bobtomic[0] != 0 || swap->I.alicetomic[0] != 0) { + char *ethTxId = sendEthTx(swap, rawtx); + strcpy(rawtx->I.ethTxid, ethTxId); + free(ethTxId); + } sendlen = 0; sendbuf[sendlen++] = rawtx->I.datalen & 0xff; sendbuf[sendlen++] = (rawtx->I.datalen >> 8) & 0xff; @@ -822,21 +827,8 @@ void LP_bobloop(void *_swap) printf("error waiting for alicefee\n"); } - if ( error == 0 ) - { - if (swap->I.bobtomic[0] != 0) - { - char *depositTx = LP_etomicbob_sends_deposit(swap); - strcpy(swap->bobdeposit.I.ethTxid, depositTx); - free(depositTx); - } - - if ( LP_swapdata_rawtxsend(swap->N.pair,swap,0x200,data,maxlen,&swap->bobdeposit,0x100,0) != 0 ) - { - - } - else - { + if ( error == 0 ) { + if ( LP_swapdata_rawtxsend(swap->N.pair,swap,0x200,data,maxlen,&swap->bobdeposit,0x100,0) == 0 ) { error = 1; printf("error sending bobdeposit\n"); } @@ -917,20 +909,12 @@ void LP_aliceloop(void *_swap) { LP_swapsfp_update(&swap->I.req); LP_swap_critical = (uint32_t)time(NULL); - if ( swap->I.alicetomic[0] != 0 ) - { - - } if ( LP_swapdata_rawtxsend(swap->N.pair,swap,0x80,data,maxlen,&swap->myfee,0x40,0) == 0 ) printf("error sending alicefee\n"); else if ( LP_waitfor(swap->N.pair,swap,1800,LP_verify_bobdeposit) < 0 ) printf("error waiting for bobdeposit\n"); else { - if ( swap->I.alicetomic[0] != 0 ) - { - // artem: do stuff alice needs to do after bobdeposit comes in - } m = swap->I.bobconfirms; while ( (n= LP_numconfirms(bobstr,swap->bobdeposit.I.destaddr,swap->bobdeposit.I.signedtxid,0,1)) < m ) { @@ -938,13 +922,6 @@ void LP_aliceloop(void *_swap) char str[65];printf("%d wait for bobdeposit %s numconfs.%d %s %s\n",n,swap->bobdeposit.I.destaddr,m,bobstr,bits256_str(str,swap->bobdeposit.I.signedtxid)); sleep(10); } - if ( swap->I.alicetomic[0] != 0 ) { - char *paymentEthTx = LP_etomicalice_send_payment(swap); - if (paymentEthTx[0] != 0) { - strcpy(swap->alicepayment.I.ethTxid, paymentEthTx); - } - free(paymentEthTx); - } if ( LP_swapdata_rawtxsend(swap->N.pair,swap,0x1000,data,maxlen,&swap->alicepayment,0x800,0) == 0 ) printf("error sending alicepayment\n"); else From 3511f9aeeb80799065fcb28ab823916d8fc1341f Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Wed, 14 Feb 2018 19:57:46 +0700 Subject: [PATCH 112/197] Fix warnings. --- iguana/exchanges/LP_etomic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index b59be7417..97c5dc422 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -241,7 +241,7 @@ char *sendEthTx(struct basilisk_swap *swap, struct basilisk_rawtx *rawtx) } else if (rawtx == &swap->bobpayment && swap->I.bobtomic[0] != 0) { return LP_etomicbob_sends_payment(swap); } else { - char *result = malloc(66); + char *result = malloc(67); strcpy(result, "0x0000000000000000000000000000000000000000000000000000000000000000"); return result; } From e699a75bf250b5bb7fdff012f4b591a67a13eba9 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Wed, 14 Feb 2018 20:22:25 +0700 Subject: [PATCH 113/197] Remove Bob double payment send. Fix Alice spend. --- iguana/exchanges/LP_etomic.c | 2 +- iguana/exchanges/LP_swap.c | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index 97c5dc422..dcad27e4e 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -206,7 +206,7 @@ char *LP_etomicalice_spends_bob_payment(struct LP_swap_remember *swap) memset(&txData,0,sizeof(txData)); memset(&input,0,sizeof(input)); - EthTxReceipt receipt = getEthTxReceipt(swap->bobDepositEthTx); + EthTxReceipt receipt = getEthTxReceipt(swap->bobPaymentEthTx); uint8arrayToHex(input.paymentId, swap->txids[BASILISK_BOBPAYMENT].bytes, 32); satoshisToWei(input.amount, swap->values[BASILISK_BOBPAYMENT]); diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index aca5f74f0..527f37461 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -856,12 +856,6 @@ void LP_bobloop(void *_swap) } LP_swap_critical = (uint32_t)time(NULL); - if (swap->I.bobtomic[0] != 0) { - char *paymentTx = LP_etomicbob_sends_payment(swap); - strcpy(swap->bobpayment.I.ethTxid, paymentTx); - free(paymentTx); - } - if ( LP_swapdata_rawtxsend(swap->N.pair,swap,0x8000,data,maxlen,&swap->bobpayment,0x4000,0) == 0 ) { printf("error sending bobpayment\n"); } From 84385107f4e0b1f9e6defcdcae9d5b57d1370cdc Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 15 Feb 2018 14:04:06 +0700 Subject: [PATCH 114/197] Add methods for reclaim/refunds. Stop put persistent privkey to file. --- iguana/exchanges/LP_etomic.c | 107 +++++++++++++++++++---- iguana/exchanges/LP_remember.c | 55 +++++++++--- iguana/exchanges/LP_swap.c | 2 +- iguana/exchanges/etomicswap/bob.c | 2 +- iguana/exchanges/etomicswap/etomiccurl.c | 11 ++- 5 files changed, 142 insertions(+), 35 deletions(-) diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index dcad27e4e..128092a66 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -81,23 +81,35 @@ char *LP_etomicalice_send_payment(struct basilisk_swap *swap) } } -char *LP_etomicalice_reclaims_payment(struct basilisk_swap *swap) +char *LP_etomicalice_reclaims_payment(struct LP_swap_remember *swap) { AliceReclaimsAlicePaymentInput input; BasicTxData txData; memset(&txData,0,sizeof(txData)); memset(&input,0,sizeof(input)); - uint8arrayToHex(input.dealId, swap->alicepayment.I.actualtxid.bytes, 32); - satoshisToWei(input.amount, swap->I.alicesatoshis); - strcpy(input.tokenAddress, swap->I.alicetomic); - strcpy(input.bobAddress, swap->I.etomicdest); - uint8arrayToHex(input.aliceHash, swap->I.secretAm, 20); - uint8arrayToHex(input.bobSecret, swap->I.secretBn256, 32); - strcpy(txData.from, swap->I.etomicsrc); + uint8arrayToHex(input.dealId, swap->txids[BASILISK_ALICEPAYMENT].bytes, 32); + satoshisToWei(input.amount, swap->values[BASILISK_ALICEPAYMENT]); + + if (swap->alicetomic[0] != 0) { + strcpy(input.tokenAddress, swap->alicetomic); + } else { + strcpy(input.tokenAddress, "0x0000000000000000000000000000000000000000"); + } + strcpy(input.bobAddress, swap->etomicdest); + uint8arrayToHex(input.aliceHash, swap->secretAm, 20); + bits256 invertedSecret; + int32_t i; + for (i=0; i<32; i++) { + invertedSecret.bytes[i] = swap->privBn.bytes[31 - i]; + } + uint8arrayToHex(input.bobSecret, invertedSecret.bytes, 32); + + strcpy(txData.from, swap->etomicsrc); strcpy(txData.to, ETOMIC_ALICECONTRACT); strcpy(txData.amount, "0"); - uint8arrayToHex(txData.secretKey, swap->persistent_privkey.bytes, 32); + uint8arrayToHex(txData.secretKey, swap->persistentPrivKey.bytes, 32); + return aliceReclaimsAlicePayment(input, txData); } char *LP_etomicbob_spends_alice_payment(struct LP_swap_remember *swap) @@ -111,16 +123,18 @@ char *LP_etomicbob_spends_alice_payment(struct LP_swap_remember *swap) uint8arrayToHex(input.dealId, swap->txids[BASILISK_ALICEPAYMENT].bytes, 32); satoshisToWei(input.amount, swap->destamount); - if (swap->alicetomic[0] != 0) + if (swap->alicetomic[0] != 0) { strcpy(input.tokenAddress, swap->alicetomic); - else + } else { strcpy(input.tokenAddress, "0x0000000000000000000000000000000000000000"); + } strcpy(input.aliceAddress, swap->etomicdest); - bits256 hash; int32_t i; - for (i=0; i<32; i++) - hash.bytes[i] = swap->privAm.bytes[31-i]; - uint8arrayToHex(input.aliceSecret, hash.bytes, 32); + bits256 invertedSecret; int32_t i; + for (i=0; i<32; i++) { + invertedSecret.bytes[i] = swap->privAm.bytes[31 - i]; + } + uint8arrayToHex(input.aliceSecret, invertedSecret.bytes, 32); uint8arrayToHex(input.bobHash, swap->secretBn, 20); strcpy(txData.from, swap->etomicsrc); @@ -199,6 +213,33 @@ char *LP_etomicbob_sends_payment(struct basilisk_swap *swap) return bobSendsEthPayment(input, txData); } +char *LP_etomicbob_reclaims_payment(struct LP_swap_remember *swap) +{ + BobReclaimsBobPaymentInput input; + BasicTxData txData; + memset(&txData,0,sizeof(txData)); + memset(&input,0,sizeof(input)); + + EthTxReceipt receipt = getEthTxReceipt(swap->bobPaymentEthTx); + uint8arrayToHex(input.paymentId, swap->txids[BASILISK_BOBPAYMENT].bytes, 32); + strcpy(input.aliceAddress, swap->etomicdest); + sprintf(input.bobCanClaimAfter, "%" PRIu64, receipt.blockNumber + 480); + uint8arrayToHex(input.aliceHash, swap->secretAm, 20); + + if (swap->bobtomic[0] != 0) { + strcpy(input.tokenAddress, swap->bobtomic); + } else { + strcpy(input.tokenAddress, "0x0000000000000000000000000000000000000000"); + } + satoshisToWei(input.amount, swap->values[BASILISK_BOBPAYMENT]); + + strcpy(txData.from, swap->etomicsrc); + strcpy(txData.to, ETOMIC_BOBCONTRACT); + strcpy(txData.amount, "0"); + uint8arrayToHex(txData.secretKey, swap->persistentPrivKey.bytes, 32); + return bobReclaimsBobPayment(input, txData); +} + char *LP_etomicalice_spends_bob_payment(struct LP_swap_remember *swap) { AliceSpendsBobPaymentInput input; @@ -219,11 +260,12 @@ char *LP_etomicalice_spends_bob_payment(struct LP_swap_remember *swap) } strcpy(input.bobAddress, swap->etomicsrc); - bits256 hash; int32_t i; + bits256 invertedSecret; int32_t i; + for (i=0; i<32; i++) { - hash.bytes[i] = swap->privAm.bytes[31 - i]; + invertedSecret.bytes[i] = swap->privAm.bytes[31 - i]; } - uint8arrayToHex(input.aliceSecret, hash.bytes, 32); + uint8arrayToHex(input.aliceSecret, invertedSecret.bytes, 32); strcpy(txData.from, swap->etomicdest); strcpy(txData.to, ETOMIC_BOBCONTRACT); @@ -232,6 +274,35 @@ char *LP_etomicalice_spends_bob_payment(struct LP_swap_remember *swap) return aliceSpendsBobPayment(input, txData); } +char *LP_etomicalice_claims_bob_deposit(struct LP_swap_remember *swap) +{ + AliceClaimsBobDepositInput input; + BasicTxData txData; + + memset(&txData,0,sizeof(txData)); + memset(&input,0,sizeof(input)); + EthTxReceipt receipt = getEthTxReceipt(swap->bobDepositEthTx); + + uint8arrayToHex(input.depositId, swap->txids[BASILISK_BOBDEPOSIT].bytes, 32); + satoshisToWei(input.amount, swap->values[BASILISK_BOBDEPOSIT]); + sprintf(input.aliceCanClaimAfter, "%" PRIu64, receipt.blockNumber + 960); + + if (swap->bobtomic[0] != 0) { + strcpy(input.tokenAddress, swap->bobtomic); + } else { + strcpy(input.tokenAddress, "0x0000000000000000000000000000000000000000"); + } + + strcpy(input.bobAddress, swap->etomicsrc); + uint8arrayToHex(input.bobHash, swap->secretBn, 20); + + strcpy(txData.from, swap->etomicdest); + strcpy(txData.to, ETOMIC_BOBCONTRACT); + strcpy(txData.amount, "0"); + uint8arrayToHex(txData.secretKey, swap->persistentPrivKey.bytes, 32); + return aliceClaimsBobDeposit(input, txData); +} + char *sendEthTx(struct basilisk_swap *swap, struct basilisk_rawtx *rawtx) { if (rawtx == &swap->alicepayment && swap->I.alicetomic[0] != 0) { diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index c9d0eed50..4a2b9719e 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -75,9 +75,6 @@ void basilisk_dontforget(struct basilisk_swap *swap,struct basilisk_rawtx *rawtx if (swap->bobpayment.I.ethTxid[0] != 0) { fprintf(fp,",\"bobPaymentEthTx\":\"%s\"", swap->bobpayment.I.ethTxid); } - char persistentPrivKeyStr[100]; - bits256_str(persistentPrivKeyStr,swap->persistent_privkey); - fprintf(fp,",\"persistentPrivKey\":\"%s\"",persistentPrivKeyStr); fprintf(fp,",\"alicecoin\":\"%s\"",swap->I.alicestr); if ( swap->I.alicetomic[0] != 0 ) @@ -872,8 +869,6 @@ int32_t LP_swap_load(struct LP_swap_remember *rswap,int32_t forceflag) strcpy(rswap->bobPaymentEthTx, jstr(txobj,"bobPaymentEthTx")); } - rswap->persistentPrivKey = jbits256(txobj, "persistentPrivKey"); - rswap->txids[i] = txid; if ( jstr(txobj,"Apayment") != 0 ) safecopy(rswap->alicepaymentaddr,jstr(txobj,"Apayment"),sizeof(rswap->alicepaymentaddr)); @@ -945,6 +940,21 @@ int32_t LP_swap_load(struct LP_swap_remember *rswap,int32_t forceflag) //printf("%s %s %.8f\n",txnames[i],bits256_str(str,txid),dstr(value)); } } + + struct iguana_info *ecoin,*coin; + if (rswap->iambob == 1) { + coin = LP_coinfind(rswap->bobcoin); + } else { + coin = LP_coinfind(rswap->alicecoin); + } + + bits256 privkey = LP_privkey(coin->symbol,coin->smartaddr,coin->taddr); + if (coin->etomic[0] != 0) { + if ((ecoin= LP_coinfind("ETOMIC")) != 0) { + privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr); + } + } + rswap->persistentPrivKey = privkey; free_json(txobj); } //else printf("no symbol\n"); free(fstr); @@ -1207,7 +1217,10 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti rev.bytes[j] = rswap.myprivs[0].bytes[31 - j]; if ( (rswap.txbytes[BASILISK_ALICESPEND]= basilisk_swap_bobtxspend(&signedtxid,rswap.Btxfee,"alicespend",rswap.bobcoin,bob->wiftaddr,bob->taddr,bob->pubtype,bob->p2shtype,bob->isPoS,bob->wiftype,ctx,rswap.myprivs[0],0,redeemscript,redeemlen,userdata,len,rswap.txids[BASILISK_BOBPAYMENT],0,0,rswap.pubkey33,1,rswap.expiration,&rswap.values[BASILISK_ALICESPEND],0,0,rswap.bobpaymentaddr,1,bob->zcash)) != 0 ) { - LP_etomicalice_spends_bob_payment(&rswap); + if (rswap.bobtomic[0] != 0) { + char *aliceSpendEthTxId = LP_etomicalice_spends_bob_payment(&rswap); + free(aliceSpendEthTxId); + } } } LP_txbytes_update("alicespend",rswap.bobcoin,rswap.txbytes[BASILISK_ALICESPEND],&rswap.txids[BASILISK_ALICESPEND],&rswap.paymentspent,&rswap.sentflags[BASILISK_ALICESPEND]); @@ -1233,8 +1246,13 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti if ( redeemlen > 0 ) { len = basilisk_swapuserdata(userdata,zero,1,rswap.myprivs[0],redeemscript,redeemlen); - if ( (rswap.txbytes[BASILISK_ALICECLAIM]= basilisk_swap_bobtxspend(&signedtxid,rswap.Btxfee,"aliceclaim",rswap.bobcoin,bob->wiftaddr,bob->taddr,bob->pubtype,bob->p2shtype,bob->isPoS,bob->wiftype,ctx,rswap.myprivs[0],0,redeemscript,redeemlen,userdata,len,rswap.txids[BASILISK_BOBDEPOSIT],0,0,rswap.pubkey33,0,claimtime,&rswap.values[BASILISK_ALICECLAIM],0,0,rswap.bobdepositaddr,1,bob->zcash)) != 0 ) - printf("claimtime.%u aliceclaim.(%s)\n",claimtime,rswap.txbytes[BASILISK_ALICECLAIM]); + if ( (rswap.txbytes[BASILISK_ALICECLAIM]= basilisk_swap_bobtxspend(&signedtxid,rswap.Btxfee,"aliceclaim",rswap.bobcoin,bob->wiftaddr,bob->taddr,bob->pubtype,bob->p2shtype,bob->isPoS,bob->wiftype,ctx,rswap.myprivs[0],0,redeemscript,redeemlen,userdata,len,rswap.txids[BASILISK_BOBDEPOSIT],0,0,rswap.pubkey33,0,claimtime,&rswap.values[BASILISK_ALICECLAIM],0,0,rswap.bobdepositaddr,1,bob->zcash)) != 0 ) { + printf("claimtime.%u aliceclaim.(%s)\n", claimtime, rswap.txbytes[BASILISK_ALICECLAIM]); + if (rswap.bobtomic[0] != 0) { + char *aliceClaimsEthTxId = LP_etomicalice_claims_bob_deposit(&rswap); + free(aliceClaimsEthTxId); + } + } } LP_txbytes_update("aliceclaim",rswap.bobcoin,rswap.txbytes[BASILISK_ALICECLAIM],&rswap.txids[BASILISK_ALICECLAIM],&rswap.depositspent,&rswap.sentflags[BASILISK_ALICECLAIM]); } @@ -1254,8 +1272,13 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti rswap.privBn = basilisk_swap_privBn_extract(&rswap.txids[BASILISK_BOBREFUND],rswap.bobcoin,rswap.txids[BASILISK_BOBDEPOSIT],rswap.privBn); if ( bits256_nonz(rswap.txids[BASILISK_ALICEPAYMENT]) != 0 && bits256_nonz(rswap.privAm) != 0 && bits256_nonz(rswap.privBn) != 0 ) { - if ( (rswap.txbytes[BASILISK_ALICERECLAIM]= basilisk_swap_Aspend("alicereclaim",rswap.alicecoin,rswap.Atxfee,alice->wiftaddr,alice->taddr,alice->pubtype,alice->p2shtype,alice->isPoS,alice->wiftype,ctx,rswap.privAm,rswap.privBn,rswap.txids[BASILISK_ALICEPAYMENT],0,rswap.pubkey33,rswap.expiration,&rswap.values[BASILISK_ALICERECLAIM],rswap.alicepaymentaddr,alice->zcash)) != 0 ) - printf("alicereclaim.(%s)\n",rswap.txbytes[BASILISK_ALICERECLAIM]); + if ( (rswap.txbytes[BASILISK_ALICERECLAIM]= basilisk_swap_Aspend("alicereclaim",rswap.alicecoin,rswap.Atxfee,alice->wiftaddr,alice->taddr,alice->pubtype,alice->p2shtype,alice->isPoS,alice->wiftype,ctx,rswap.privAm,rswap.privBn,rswap.txids[BASILISK_ALICEPAYMENT],0,rswap.pubkey33,rswap.expiration,&rswap.values[BASILISK_ALICERECLAIM],rswap.alicepaymentaddr,alice->zcash)) != 0 ) { + printf("alicereclaim.(%s)\n", rswap.txbytes[BASILISK_ALICERECLAIM]); + if (rswap.alicetomic[0] != 0) { + char *aliceReclaimEthTx = LP_etomicalice_reclaims_payment(&rswap); + free(aliceReclaimEthTx); + } + } } LP_txbytes_update("alicereclaim",rswap.alicecoin,rswap.txbytes[BASILISK_ALICERECLAIM],&rswap.txids[BASILISK_ALICERECLAIM],&rswap.Apaymentspent,&rswap.sentflags[BASILISK_ALICERECLAIM]); } @@ -1288,7 +1311,8 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti if ( (rswap.txbytes[BASILISK_BOBSPEND]= basilisk_swap_Aspend("bobspend",rswap.alicecoin,rswap.Atxfee,alice->wiftaddr,alice->taddr,alice->pubtype,alice->p2shtype,alice->isPoS,alice->wiftype,ctx,rswap.privAm,rswap.privBn,rswap.txids[BASILISK_ALICEPAYMENT],0,rswap.pubkey33,rswap.expiration,&rswap.values[BASILISK_BOBSPEND],rswap.alicepaymentaddr,alice->zcash)) != 0 ) { //printf("bobspend.(%s)\n",rswap.txbytes[BASILISK_BOBSPEND]); - LP_etomicbob_spends_alice_payment(&rswap); + char *bobSpendEthTx = LP_etomicbob_spends_alice_payment(&rswap); + free(bobSpendEthTx); } } LP_txbytes_update("bobspend",rswap.alicecoin,rswap.txbytes[BASILISK_BOBSPEND],&rswap.txids[BASILISK_BOBSPEND],&rswap.Apaymentspent,&rswap.sentflags[BASILISK_BOBSPEND]); @@ -1313,6 +1337,10 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti len = basilisk_swapuserdata(userdata,zero,1,rswap.myprivs[1],redeemscript,redeemlen); if ( (rswap.txbytes[BASILISK_BOBRECLAIM]= basilisk_swap_bobtxspend(&signedtxid,rswap.Btxfee,"bobreclaim",rswap.bobcoin,bob->wiftaddr,bob->taddr,bob->pubtype,bob->p2shtype,bob->isPoS,bob->wiftype,ctx,rswap.myprivs[1],0,redeemscript,redeemlen,userdata,len,rswap.txids[BASILISK_BOBPAYMENT],0,0,rswap.pubkey33,0,claimtime,&rswap.values[BASILISK_BOBRECLAIM],0,0,rswap.bobpaymentaddr,1,bob->zcash)) != 0 ) { + if (rswap.bobtomic[0] != 0) { + char *bobReclaimEthTx = LP_etomicbob_reclaims_payment(&rswap); + free(bobReclaimEthTx); + } //int32_t z; //for (z=0; z<20; z++) // printf("%02x",rswap.secretAm[z]); @@ -1347,7 +1375,10 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti len = basilisk_swapuserdata(userdata,rswap.privBn,0,rswap.myprivs[0],redeemscript,redeemlen); if ( (rswap.txbytes[BASILISK_BOBREFUND]= basilisk_swap_bobtxspend(&signedtxid,rswap.Btxfee,"bobrefund",rswap.bobcoin,bob->wiftaddr,bob->taddr,bob->pubtype,bob->p2shtype,bob->isPoS,bob->wiftype,ctx,rswap.myprivs[0],0,redeemscript,redeemlen,userdata,len,rswap.txids[BASILISK_BOBDEPOSIT],0,0,rswap.pubkey33,1,rswap.expiration,&rswap.values[BASILISK_BOBREFUND],0,0,rswap.bobdepositaddr,1,bob->zcash)) != 0 ) { - LP_etomicbob_refunds_deposit(&rswap); + if (rswap.bobtomic[0] != 0) { + char *bobRefundsEthTx = LP_etomicbob_refunds_deposit(&rswap); + free(bobRefundsEthTx); + } //printf("pubB1.(%s) bobrefund.(%s)\n",bits256_str(str,rswap.pubB1),rswap.txbytes[BASILISK_BOBREFUND]); } } diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index 527f37461..fdb9e6bc3 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -596,7 +596,7 @@ int32_t LP_rawtx_spendscript(struct basilisk_swap *swap,int32_t height,struct ba rawtx->I.redeemlen = recvbuf[offset++]; uint8arrayToHex(rawtx->I.ethTxid, &recvbuf[offset], 32); offset += 32; - printf("ETH txid received: %s", rawtx->I.ethTxid); + printf("ETH txid received: %s\n", rawtx->I.ethTxid); data = &recvbuf[offset]; if ( rawtx->I.redeemlen > 0 && rawtx->I.redeemlen < 0x100 ) { diff --git a/iguana/exchanges/etomicswap/bob.c b/iguana/exchanges/etomicswap/bob.c index a2a1e0361..2ee3f5cc2 100644 --- a/iguana/exchanges/etomicswap/bob.c +++ b/iguana/exchanges/etomicswap/bob.c @@ -199,7 +199,7 @@ int main(int argc, char** argv) case TX_RECEIPT: printf("getTxReceipt\n"); EthTxReceipt txReceipt; - txReceipt = getEthTxReceipt("0x9c3f31859dcba6d1032ed82074a0fe74a04b749d5e9feedc8a49bf78bf8f2b2c"); + txReceipt = getEthTxReceipt("0x82afa1b00f8a63e1a91430162e5cb2d4ebe915831ffd56e6e3227814913e23e6"); printf("%" PRIu64 "\n", txReceipt.blockNumber); printf("%s\n", txReceipt.blockHash); break; diff --git a/iguana/exchanges/etomicswap/etomiccurl.c b/iguana/exchanges/etomicswap/etomiccurl.c index 52d6bdf57..4212e7614 100644 --- a/iguana/exchanges/etomicswap/etomiccurl.c +++ b/iguana/exchanges/etomicswap/etomiccurl.c @@ -4,7 +4,7 @@ #include #include "../../../includes/cJSON.h" -static char* ethRpcUrl = "https://ropsten.infura.io/y07GHxUyTgeN2mdfOonu"; +static char *ethRpcUrl = "https://ropsten.infura.io/y07GHxUyTgeN2mdfOonu"; struct string { char *ptr; @@ -182,8 +182,13 @@ EthTxReceipt getEthTxReceipt(char *txId) cJSON_Delete(request); cJSON *json = cJSON_Parse(requestResult); cJSON *tmp = cJSON_GetObjectItem(json, "result"); - strcpy(result.blockHash, cJSON_GetObjectItem(tmp, "blockHash")->valuestring); - result.blockNumber = (uint64_t)strtol(cJSON_GetObjectItem(tmp, "blockNumber")->valuestring, NULL, 0); + if (is_cJSON_Null(tmp)) { + strcpy(result.blockHash, "0x0000000000000000000000000000000000000000000000000000000000000000"); + result.blockNumber = 0; + } else { + strcpy(result.blockHash, cJSON_GetObjectItem(tmp, "blockHash")->valuestring); + result.blockNumber = (uint64_t) strtol(cJSON_GetObjectItem(tmp, "blockNumber")->valuestring, NULL, 0); + } cJSON_Delete(json); free(requestResult); free(string); From 222584f497bcec770a74837de6bc4c8ae514b8fe Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 15 Feb 2018 14:53:36 +0700 Subject: [PATCH 115/197] Fix remember bobtomic/alicetomic. --- iguana/exchanges/LP_etomic.c | 57 ++++++++++++++++++++----------- iguana/exchanges/LP_nativeDEX.c | 2 +- iguana/exchanges/LP_remember.c | 22 +++++------- iguana/exchanges/LP_transaction.c | 14 ++++++++ 4 files changed, 60 insertions(+), 35 deletions(-) diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index 128092a66..4d68227ea 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -29,23 +29,10 @@ #define ETOMIC_BOBCONTRACT "0x9387Fd3a016bB0205e4e131Dde886B9d2BC000A2" #define ETOMIC_SATOSHICAT "0000000000" -int32_t LP_etomicsymbol(char *activesymbol,char *etomic,char *symbol) -{ - struct iguana_info *coin; - etomic[0] = activesymbol[0] = 0; - if ( (coin= LP_coinfind(symbol)) != 0 ) - { - strcpy(etomic,coin->etomic); - if ( etomic[0] != 0 ) - strcpy(activesymbol,"ETOMIC"); - else strcpy(activesymbol,symbol); - } - return(etomic[0] != 0); -} - char *LP_etomicalice_send_payment(struct basilisk_swap *swap) { AliceSendsEthPaymentInput input; AliceSendsErc20PaymentInput input20; BasicTxData txData; + // set input and txData fields from the swap data structure memset(&txData,0,sizeof(txData)); if ( strcmp(swap->I.alicestr,"ETH") == 0 ) @@ -88,6 +75,11 @@ char *LP_etomicalice_reclaims_payment(struct LP_swap_remember *swap) memset(&txData,0,sizeof(txData)); memset(&input,0,sizeof(input)); + struct iguana_info *ecoin; + bits256 privkey; + ecoin = LP_coinfind("ETOMIC"); + privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr); + uint8arrayToHex(input.dealId, swap->txids[BASILISK_ALICEPAYMENT].bytes, 32); satoshisToWei(input.amount, swap->values[BASILISK_ALICEPAYMENT]); @@ -108,7 +100,7 @@ char *LP_etomicalice_reclaims_payment(struct LP_swap_remember *swap) strcpy(txData.from, swap->etomicsrc); strcpy(txData.to, ETOMIC_ALICECONTRACT); strcpy(txData.amount, "0"); - uint8arrayToHex(txData.secretKey, swap->persistentPrivKey.bytes, 32); + uint8arrayToHex(txData.secretKey, privkey.bytes, 32); return aliceReclaimsAlicePayment(input, txData); } @@ -120,6 +112,11 @@ char *LP_etomicbob_spends_alice_payment(struct LP_swap_remember *swap) memset(&txData,0,sizeof(txData)); memset(&input,0,sizeof(input)); + struct iguana_info *ecoin; + bits256 privkey; + ecoin = LP_coinfind("ETOMIC"); + privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr); + uint8arrayToHex(input.dealId, swap->txids[BASILISK_ALICEPAYMENT].bytes, 32); satoshisToWei(input.amount, swap->destamount); @@ -140,7 +137,7 @@ char *LP_etomicbob_spends_alice_payment(struct LP_swap_remember *swap) strcpy(txData.from, swap->etomicsrc); strcpy(txData.to, ETOMIC_ALICECONTRACT); strcpy(txData.amount, "0"); - uint8arrayToHex(txData.secretKey, swap->persistentPrivKey.bytes, 32); + uint8arrayToHex(txData.secretKey, privkey.bytes, 32); return bobSpendsAlicePayment(input, txData); } @@ -169,6 +166,11 @@ char *LP_etomicbob_refunds_deposit(struct LP_swap_remember *swap) memset(&txData,0,sizeof(txData)); memset(&input,0,sizeof(input)); + struct iguana_info *ecoin; + bits256 privkey; + ecoin = LP_coinfind("ETOMIC"); + privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr); + EthTxReceipt receipt = getEthTxReceipt(swap->bobDepositEthTx); uint8arrayToHex(input.depositId, swap->txids[BASILISK_BOBDEPOSIT].bytes, 32); strcpy(input.aliceAddress, swap->etomicdest); @@ -191,7 +193,7 @@ char *LP_etomicbob_refunds_deposit(struct LP_swap_remember *swap) strcpy(txData.from, swap->etomicsrc); strcpy(txData.to, ETOMIC_BOBCONTRACT); strcpy(txData.amount, "0"); - uint8arrayToHex(txData.secretKey, swap->persistentPrivKey.bytes, 32); + uint8arrayToHex(txData.secretKey, privkey.bytes, 32); return bobRefundsDeposit(input, txData); } @@ -220,6 +222,11 @@ char *LP_etomicbob_reclaims_payment(struct LP_swap_remember *swap) memset(&txData,0,sizeof(txData)); memset(&input,0,sizeof(input)); + struct iguana_info *ecoin; + bits256 privkey; + ecoin = LP_coinfind("ETOMIC"); + privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr); + EthTxReceipt receipt = getEthTxReceipt(swap->bobPaymentEthTx); uint8arrayToHex(input.paymentId, swap->txids[BASILISK_BOBPAYMENT].bytes, 32); strcpy(input.aliceAddress, swap->etomicdest); @@ -236,7 +243,7 @@ char *LP_etomicbob_reclaims_payment(struct LP_swap_remember *swap) strcpy(txData.from, swap->etomicsrc); strcpy(txData.to, ETOMIC_BOBCONTRACT); strcpy(txData.amount, "0"); - uint8arrayToHex(txData.secretKey, swap->persistentPrivKey.bytes, 32); + uint8arrayToHex(txData.secretKey, privkey.bytes, 32); return bobReclaimsBobPayment(input, txData); } @@ -249,6 +256,11 @@ char *LP_etomicalice_spends_bob_payment(struct LP_swap_remember *swap) memset(&input,0,sizeof(input)); EthTxReceipt receipt = getEthTxReceipt(swap->bobPaymentEthTx); + struct iguana_info *ecoin; + bits256 privkey; + ecoin = LP_coinfind("ETOMIC"); + privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr); + uint8arrayToHex(input.paymentId, swap->txids[BASILISK_BOBPAYMENT].bytes, 32); satoshisToWei(input.amount, swap->values[BASILISK_BOBPAYMENT]); sprintf(input.bobCanClaimAfter, "%" PRIu64, receipt.blockNumber + 480); @@ -270,7 +282,7 @@ char *LP_etomicalice_spends_bob_payment(struct LP_swap_remember *swap) strcpy(txData.from, swap->etomicdest); strcpy(txData.to, ETOMIC_BOBCONTRACT); strcpy(txData.amount, "0"); - uint8arrayToHex(txData.secretKey, swap->persistentPrivKey.bytes, 32); + uint8arrayToHex(txData.secretKey, privkey.bytes, 32); return aliceSpendsBobPayment(input, txData); } @@ -283,6 +295,11 @@ char *LP_etomicalice_claims_bob_deposit(struct LP_swap_remember *swap) memset(&input,0,sizeof(input)); EthTxReceipt receipt = getEthTxReceipt(swap->bobDepositEthTx); + struct iguana_info *ecoin; + bits256 privkey; + ecoin = LP_coinfind("ETOMIC"); + privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr); + uint8arrayToHex(input.depositId, swap->txids[BASILISK_BOBDEPOSIT].bytes, 32); satoshisToWei(input.amount, swap->values[BASILISK_BOBDEPOSIT]); sprintf(input.aliceCanClaimAfter, "%" PRIu64, receipt.blockNumber + 960); @@ -299,7 +316,7 @@ char *LP_etomicalice_claims_bob_deposit(struct LP_swap_remember *swap) strcpy(txData.from, swap->etomicdest); strcpy(txData.to, ETOMIC_BOBCONTRACT); strcpy(txData.amount, "0"); - uint8arrayToHex(txData.secretKey, swap->persistentPrivKey.bytes, 32); + uint8arrayToHex(txData.secretKey, privkey.bytes, 32); return aliceClaimsBobDeposit(input, txData); } diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 8ace31355..2e01866a7 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -174,11 +174,11 @@ char *blocktrail_listtransactions(char *symbol,char *coinaddr,int32_t num,int32_ #include "LP_NXT.c" #include "LP_cache.c" #include "LP_RTmetrics.c" -#include "LP_etomic.c" #include "LP_utxo.c" #include "LP_prices.c" #include "LP_scan.c" #include "LP_transaction.c" +#include "LP_etomic.c" #include "LP_stats.c" #include "LP_remember.c" #include "LP_instantdex.c" diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 4a2b9719e..0525ec4a1 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -869,6 +869,14 @@ int32_t LP_swap_load(struct LP_swap_remember *rswap,int32_t forceflag) strcpy(rswap->bobPaymentEthTx, jstr(txobj,"bobPaymentEthTx")); } + if (jstr(txobj,"bobtomic") != 0) { + strcpy(rswap->bobtomic, jstr(txobj,"bobtomic")); + } + + if (jstr(txobj,"alicetomic") != 0) { + strcpy(rswap->alicetomic, jstr(txobj,"alicetomic")); + } + rswap->txids[i] = txid; if ( jstr(txobj,"Apayment") != 0 ) safecopy(rswap->alicepaymentaddr,jstr(txobj,"Apayment"),sizeof(rswap->alicepaymentaddr)); @@ -941,20 +949,6 @@ int32_t LP_swap_load(struct LP_swap_remember *rswap,int32_t forceflag) } } - struct iguana_info *ecoin,*coin; - if (rswap->iambob == 1) { - coin = LP_coinfind(rswap->bobcoin); - } else { - coin = LP_coinfind(rswap->alicecoin); - } - - bits256 privkey = LP_privkey(coin->symbol,coin->smartaddr,coin->taddr); - if (coin->etomic[0] != 0) { - if ((ecoin= LP_coinfind("ETOMIC")) != 0) { - privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr); - } - } - rswap->persistentPrivKey = privkey; free_json(txobj); } //else printf("no symbol\n"); free(fstr); diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index 2e0637a49..4944c1174 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -1863,6 +1863,20 @@ int32_t basilisk_swapuserdata(uint8_t *userdata,bits256 privkey,int32_t ifpath,b OP_HASH160 OP_EQUALVERIFY OP_CHECKSIG OP_ENDIF*/ +int32_t LP_etomicsymbol(char *activesymbol,char *etomic,char *symbol) +{ + struct iguana_info *coin; + etomic[0] = activesymbol[0] = 0; + if ( (coin= LP_coinfind(symbol)) != 0 ) + { + strcpy(etomic,coin->etomic); + if ( etomic[0] != 0 ) + strcpy(activesymbol,"ETOMIC"); + else strcpy(activesymbol,symbol); + } + return(etomic[0] != 0); +} + int32_t basilisk_bobpayment_reclaim(struct basilisk_swap *swap,int32_t delay) { static bits256 zero; From 733ba0c52c8feb2a2e25a813e2188428a9bab165 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 15 Feb 2018 15:12:52 +0700 Subject: [PATCH 116/197] Add 107 instead of 75 to datalen. ETH txid was added. --- iguana/exchanges/LP_swap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index fdb9e6bc3..1cb90d849 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -631,7 +631,7 @@ int32_t LP_rawtx_spendscript(struct basilisk_swap *swap,int32_t height,struct ba } - if ( recvlen != datalen+rawtx->I.redeemlen+75 ) + if ( recvlen != datalen+rawtx->I.redeemlen + 107 ) printf("RECVLEN %d != %d + %d\n",recvlen,datalen,rawtx->I.redeemlen); txid = bits256_calctxid(coin->symbol,data,datalen); //char str[65]; printf("rawtx.%s txid %s\n",rawtx->name,bits256_str(str,txid)); From 9ee7f407468c4e2957859e455b26162b05c5fd54 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 15 Feb 2018 15:20:59 +0700 Subject: [PATCH 117/197] Remove LP_swap_remember persistentPrivKey field. --- iguana/exchanges/LP_include.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index 1aa167d75..80ea208c8 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -270,7 +270,7 @@ char *txnames[] = { "alicespend", "bobspend", "bobpayment", "alicepayment", "bob struct LP_swap_remember { - bits256 persistentPrivKey,pubA0,pubB0,pubB1,privAm,privBn,paymentspent,Apaymentspent,depositspent,myprivs[2],txids[sizeof(txnames)/sizeof(*txnames)]; + bits256 pubA0,pubB0,pubB1,privAm,privBn,paymentspent,Apaymentspent,depositspent,myprivs[2],txids[sizeof(txnames)/sizeof(*txnames)]; uint64_t Atxfee,Btxfee,srcamount,destamount,aliceid; int64_t values[sizeof(txnames)/sizeof(*txnames)]; uint32_t finishtime,tradeid,requestid,quoteid,plocktime,dlocktime,expiration,state,otherstate; From 753a1aac7ef3b710dada76261eee1f608679d623 Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Thu, 15 Feb 2018 16:15:44 +0700 Subject: [PATCH 118/197] Add ERC20 bob deposit/payment. Bob spends alice payment only when alicetomic not empty. --- iguana/exchanges/LP_etomic.c | 63 +++++++++++++++++++++++++--------- iguana/exchanges/LP_remember.c | 6 ++-- 2 files changed, 51 insertions(+), 18 deletions(-) diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index 4d68227ea..e9f153da3 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -144,19 +144,34 @@ char *LP_etomicbob_spends_alice_payment(struct LP_swap_remember *swap) char *LP_etomicbob_sends_deposit(struct basilisk_swap *swap) { BobSendsEthDepositInput input; + BobSendsErc20DepositInput input20; BasicTxData txData; memset(&txData,0,sizeof(txData)); memset(&input,0,sizeof(input)); + memset(&input20,0,sizeof(input20)); + if ( strcmp(swap->I.bobstr,"ETH") == 0 ) { + uint8arrayToHex(input.depositId, swap->bobdeposit.I.actualtxid.bytes, 32); + strcpy(input.aliceAddress, swap->I.etomicdest); + uint8arrayToHex(input.bobHash, swap->I.secretBn, 20); - uint8arrayToHex(input.depositId, swap->bobdeposit.I.actualtxid.bytes, 32); - strcpy(input.aliceAddress, swap->I.etomicdest); - uint8arrayToHex(input.bobHash, swap->I.secretBn, 20); + strcpy(txData.from, swap->I.etomicsrc); + strcpy(txData.to, ETOMIC_BOBCONTRACT); + satoshisToWei(txData.amount, swap->bobdeposit.I.amount); + uint8arrayToHex(txData.secretKey, swap->persistent_privkey.bytes, 32); + return bobSendsEthDeposit(input, txData); + } else { + 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); - strcpy(txData.from, swap->I.etomicsrc); - strcpy(txData.to, ETOMIC_BOBCONTRACT); - satoshisToWei(txData.amount, swap->bobdeposit.I.amount); - uint8arrayToHex(txData.secretKey, swap->persistent_privkey.bytes, 32); - return bobSendsEthDeposit(input, txData); + strcpy(txData.from, swap->I.etomicsrc); + strcpy(txData.to, ETOMIC_BOBCONTRACT); + strcpy(txData.amount, "0"); + uint8arrayToHex(txData.secretKey, swap->persistent_privkey.bytes, 32); + return bobSendsErc20Deposit(input20, txData); + } } char *LP_etomicbob_refunds_deposit(struct LP_swap_remember *swap) @@ -200,19 +215,35 @@ char *LP_etomicbob_refunds_deposit(struct LP_swap_remember *swap) char *LP_etomicbob_sends_payment(struct basilisk_swap *swap) { BobSendsEthPaymentInput input; + BobSendsErc20PaymentInput input20; BasicTxData txData; memset(&txData,0,sizeof(txData)); memset(&input,0,sizeof(input)); + memset(&input20,0,sizeof(input20)); - uint8arrayToHex(input.paymentId, swap->bobpayment.I.actualtxid.bytes, 32); - strcpy(input.aliceAddress, swap->I.etomicdest); - uint8arrayToHex(input.aliceHash, swap->I.secretAm, 20); + if ( strcmp(swap->I.bobstr,"ETH") == 0 ) { + uint8arrayToHex(input.paymentId, swap->bobpayment.I.actualtxid.bytes, 32); + strcpy(input.aliceAddress, swap->I.etomicdest); + uint8arrayToHex(input.aliceHash, swap->I.secretAm, 20); - strcpy(txData.from, swap->I.etomicsrc); - strcpy(txData.to, ETOMIC_BOBCONTRACT); - satoshisToWei(txData.amount, swap->bobpayment.I.amount); - uint8arrayToHex(txData.secretKey, swap->persistent_privkey.bytes, 32); - return bobSendsEthPayment(input, txData); + strcpy(txData.from, swap->I.etomicsrc); + strcpy(txData.to, ETOMIC_BOBCONTRACT); + satoshisToWei(txData.amount, swap->bobpayment.I.amount); + uint8arrayToHex(txData.secretKey, swap->persistent_privkey.bytes, 32); + return bobSendsEthPayment(input, txData); + } else { + 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); + + strcpy(txData.from, swap->I.etomicsrc); + strcpy(txData.to, ETOMIC_BOBCONTRACT); + strcpy(txData.amount, "0"); + uint8arrayToHex(txData.secretKey, swap->persistent_privkey.bytes, 32); + return bobSendsErc20Payment(input20, txData); + } } char *LP_etomicbob_reclaims_payment(struct LP_swap_remember *swap) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 0525ec4a1..6c459971f 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -1304,9 +1304,11 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti { if ( (rswap.txbytes[BASILISK_BOBSPEND]= basilisk_swap_Aspend("bobspend",rswap.alicecoin,rswap.Atxfee,alice->wiftaddr,alice->taddr,alice->pubtype,alice->p2shtype,alice->isPoS,alice->wiftype,ctx,rswap.privAm,rswap.privBn,rswap.txids[BASILISK_ALICEPAYMENT],0,rswap.pubkey33,rswap.expiration,&rswap.values[BASILISK_BOBSPEND],rswap.alicepaymentaddr,alice->zcash)) != 0 ) { + if (rswap.alicetomic[0] != 0) { + char *bobSpendEthTx = LP_etomicbob_spends_alice_payment(&rswap); + free(bobSpendEthTx); + } //printf("bobspend.(%s)\n",rswap.txbytes[BASILISK_BOBSPEND]); - char *bobSpendEthTx = LP_etomicbob_spends_alice_payment(&rswap); - free(bobSpendEthTx); } } LP_txbytes_update("bobspend",rswap.alicecoin,rswap.txbytes[BASILISK_BOBSPEND],&rswap.txids[BASILISK_BOBSPEND],&rswap.Apaymentspent,&rswap.sentflags[BASILISK_BOBSPEND]); From fc3033619ce820106dc9adc5c4c6ad6f50dc7860 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 18 Feb 2018 17:33:49 +0200 Subject: [PATCH 119/197] Bobtomic --- iguana/exchanges/LP_commands.c | 15 +++++++++++++++ iguana/exchanges/LP_mmjson.c | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index 9593a6d23..e4f20517a 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -159,6 +159,7 @@ bot_settings(botid, newprice, newvolume)\n\ bot_status(botid)\n\ bot_stop(botid)\n\ bot_pause(botid)\n\ +calcaddress(passphrase)\n\ instantdex_deposit(weeks, amount, broadcast=1)\n\ instantdex_claim()\n\ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\ @@ -302,6 +303,20 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\ { return(LP_portfolio()); } + else if ( strcmp(method,"calcaddress") == 0 ) + { + bits256 privkey,pub; uint8_t pubkey33[33]; char *passphrase,coinaddr[64]; + if ( (passphrase= jstr(argjson,"passphrase")) != 0 ) + { + conv_NXTpassword(privkey.bytes,pub.bytes,(uint8_t *)passphrase,(int32_t)strlen(passphrase)); + bitcoin_priv2pub(ctx,"KMD",pubkey33,coinaddr,privkey,0,60); + retjson = cJSON_CreateObject(); + jaddstr(retjson,"passphrase",passphrase); + jaddstr(retjson,"coinaddr",coinaddr); + jaddbits256(retjson,"privkey",privkey); + return(jprint(retjson,1)); + } else return(clonestr("{\"error\":\"need to have passphrase\"}")); + } else if ( strcmp(method,"statsdisp") == 0 ) { return(jprint(LP_statslog_disp(juint(argjson,"starttime"),juint(argjson,"endtime"),jstr(argjson,"gui"),jbits256(argjson,"pubkey"),jstr(argjson,"base"),jstr(argjson,"rel")),1)); diff --git a/iguana/exchanges/LP_mmjson.c b/iguana/exchanges/LP_mmjson.c index 0438c99cc..dcbd3de0c 100644 --- a/iguana/exchanges/LP_mmjson.c +++ b/iguana/exchanges/LP_mmjson.c @@ -50,7 +50,7 @@ int32_t MM_numfields; char *MM_fields[] = { - "timestamp", "getdPoW", "dPoW", "aliceid", "src", "base", "basevol", "dest", "rel", "relvol", "price", "requestid", "quoteid", "finished", "expired", "bobdeposit", "alicepayment", "bobpayment", "paymentspent", "Apaymentspent", "depositspent", "ind", "method", "swapstatus", "method2", "gettradestatus", "coin", "rmd160", "pub", "pubsecp", "sig", "session", "notify", "pubkey", "price64", "credits", "utxocoin", "n", "bal", "min", "max", "postprice", "notarized", "notarizedhash", "notarizationtxid", "wantnotify", "isLP", "gui", "nogui", "tradeid", "address", "txid", "vout", "srchash", "txfee", "quotetime", "satoshis", "desthash", "txid2", "vout2", "destaddr", "desttxid", "destvout", "feetxid", "feevout", "desttxfee", "destsatoshis", "pending", "reserved", "broadcast", "ismine", "simplegui", "request", "proof", "connect", "expiration", "iambob", "Bgui", "", "Agui", "bob", "srcamount", "bobtxfee", "alice", "destamount", "alicetxfee", "sentflags", "values", "result", "success", "status", "finishtime", "tradestatus", "pair", "connected", "warning", "critical", "endcritical", "cli", "etomic", "bobetomic", "alicetomic", "etomicsrc", "etomicdest" + "timestamp", "getdPoW", "dPoW", "aliceid", "src", "base", "basevol", "dest", "rel", "relvol", "price", "requestid", "quoteid", "finished", "expired", "bobdeposit", "alicepayment", "bobpayment", "paymentspent", "Apaymentspent", "depositspent", "ind", "method", "swapstatus", "method2", "gettradestatus", "coin", "rmd160", "pub", "pubsecp", "sig", "session", "notify", "pubkey", "price64", "credits", "utxocoin", "n", "bal", "min", "max", "postprice", "notarized", "notarizedhash", "notarizationtxid", "wantnotify", "isLP", "gui", "nogui", "tradeid", "address", "txid", "vout", "srchash", "txfee", "quotetime", "satoshis", "desthash", "txid2", "vout2", "destaddr", "desttxid", "destvout", "feetxid", "feevout", "desttxfee", "destsatoshis", "pending", "reserved", "broadcast", "ismine", "simplegui", "request", "proof", "connect", "expiration", "iambob", "Bgui", "", "Agui", "bob", "srcamount", "bobtxfee", "alice", "destamount", "alicetxfee", "sentflags", "values", "result", "success", "status", "finishtime", "tradestatus", "pair", "connected", "warning", "critical", "endcritical", "cli", "etomic", "bobtomic", "alicetomic", "etomicsrc", "etomicdest" }; #define MMJSON_BOUNDARY ((int32_t)(sizeof(MM_fields)/sizeof(*MM_fields))) From 60346144fff11ba1b135eae4fc138357e40944e9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 18 Feb 2018 22:47:11 +0200 Subject: [PATCH 120/197] -bobetomic --- iguana/exchanges/LP_remember.c | 2 +- iguana/exchanges/LP_signatures.c | 4 ++-- iguana/exchanges/mm.c | 6 ++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 6c459971f..ed1dfd624 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -1027,7 +1027,7 @@ int32_t LP_spends_set(struct LP_swap_remember *rswap) cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requestid,uint32_t quoteid,int32_t forceflag,int32_t pendingonly) { static void *ctx; - struct LP_swap_remember rswap; int32_t i,j,flag,numspent,len,secretstart,redeemlen; char str[65],*srcAdest,*srcBdest,*destAdest,*destBdest,otheraddr[64],*fstr,fname[512],etomicsrc[128],etomicdest[128],bobtomic[128],alicetomic[128],bobstr[65],alicestr[65]; cJSON *item,*txoutobj,*retjson; bits256 rev,signedtxid,zero,deadtxid; uint32_t claimtime; struct iguana_info *bob=0,*alice=0,*coin; uint8_t redeemscript[1024],userdata[1024]; long fsize; + struct LP_swap_remember rswap; int32_t i,j,flag,numspent,len,secretstart,redeemlen; char str[65],*srcAdest,*srcBdest,*destAdest,*destBdest,otheraddr[64],*fstr,fname[512],etomicsrc[128],etomicdest[128],bobtomic[128],alicetomic[128],bobstr[65],alicestr[65]; cJSON *item,*txoutobj,*retjson; bits256 rev,signedtxid,zero,deadtxid; uint32_t claimtime; struct iguana_info *bob=0,*alice=0; uint8_t redeemscript[1024],userdata[1024]; long fsize; sprintf(fname,"%s/SWAPS/%u-%u.finished",GLOBAL_DBDIR,requestid,quoteid), OS_compatible_path(fname); if ( (fstr= OS_filestr(&fsize,fname)) != 0 ) { diff --git a/iguana/exchanges/LP_signatures.c b/iguana/exchanges/LP_signatures.c index 133a91608..49b76c7b4 100644 --- a/iguana/exchanges/LP_signatures.c +++ b/iguana/exchanges/LP_signatures.c @@ -48,7 +48,7 @@ cJSON *LP_quotejson(struct LP_quoteinfo *qp) jaddnum(retjson,"tradeid",qp->tradeid); jaddstr(retjson,"base",qp->srccoin); if ( LP_etomicsymbol(activesymbol,etomic,qp->srccoin) != 0 ) - jaddstr(retjson,"bobetomic",etomic); + jaddstr(retjson,"bobtomic",etomic); jaddstr(retjson,"etomicsrc",qp->etomicsrc); jaddstr(retjson,"rel",qp->destcoin); if ( LP_etomicsymbol(activesymbol,etomic,qp->destcoin) != 0 ) @@ -116,7 +116,7 @@ int32_t LP_quoteparse(struct LP_quoteinfo *qp,cJSON *argjson) safecopy(qp->srccoin,jstr(argjson,"base"),sizeof(qp->srccoin)); if ( LP_etomicsymbol(activesymbol,etomic,qp->srccoin) != 0 ) { - if ( (etomicstr= jstr(argjson,"bobetomic")) == 0 || strcmp(etomicstr,etomic) != 0 ) + if ( (etomicstr= jstr(argjson,"bobtomic")) == 0 || strcmp(etomicstr,etomic) != 0 ) { printf("etomic src mismatch (%s) vs (%s)\n",etomicstr!=0?etomicstr:"",etomic); return(-1); diff --git a/iguana/exchanges/mm.c b/iguana/exchanges/mm.c index 7717a60e5..05e327a69 100644 --- a/iguana/exchanges/mm.c +++ b/iguana/exchanges/mm.c @@ -231,10 +231,12 @@ int main(int argc, const char * argv[]) } if ( flag != 0 ) { - bitcoin_addr2rmd160("HUSH",28,&addrtype,rmd160,buf); + //bitcoin_addr2rmd160("HUSH",28,&addrtype,rmd160,buf); + bitcoin_addr2rmd160("BTC",0,&addrtype,rmd160,buf); bitcoin_address("KMD",coinaddr,0,addrtype == 184 ? 60 : 85,rmd160,20); bitcoin_addr2rmd160("KMD",0,&checktype,checkrmd160,coinaddr); - bitcoin_address("HUSH",checkaddr,28,checktype == 60 ? 184 : 189,checkrmd160,20); + //bitcoin_address("HUSH",checkaddr,28,checktype == 60 ? 184 : 189,checkrmd160,20); + bitcoin_address("BTC",checkaddr,0,checktype == 60 ? 0 : 5,checkrmd160,20); if ( memcmp(rmd160,checkrmd160,20) != 0 || strcmp(buf,checkaddr) != 0 ) { for (i=0; i<20; i++) From 366226844f21b7bad7c11e4d84fd3e05035ecea1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 19 Feb 2018 20:37:52 +0200 Subject: [PATCH 121/197] Fix ETH as alice --- 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 c0cdce1d0..80fa44b5d 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -875,7 +875,7 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru strcpy(qp->etomicsrc,coin->smartaddr); else if ( othercoin->etomic[0] != 0 ) strcpy(qp->etomicsrc,othercoin->smartaddr); - if ( coin->etomic[0] != 0 || othercoin->etomic[0] != 0 ) + if ( coin->etomic[0] != 0 )//|| othercoin->etomic[0] != 0 ) { struct iguana_info *ecoin; if ( (ecoin= LP_coinfind("ETOMIC")) != 0 ) @@ -916,7 +916,7 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru strcpy(qp->etomicsrc,coin->smartaddr); else if ( othercoin->etomic[0] != 0 ) strcpy(qp->etomicsrc,othercoin->smartaddr); - if ( coin->etomic[0] != 0 || othercoin->etomic[0] != 0 ) + if ( coin->etomic[0] != 0 )//|| othercoin->etomic[0] != 0 ) { struct iguana_info *ecoin; if ( (ecoin= LP_coinfind("ETOMIC")) != 0 ) From cfc520a50dbd8ce7edbee56ea6f13e42f794194e Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 19 Feb 2018 20:53:22 +0200 Subject: [PATCH 122/197] Print --- iguana/exchanges/LP_prices.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_prices.c b/iguana/exchanges/LP_prices.c index 5967db7a5..b04d062fb 100644 --- a/iguana/exchanges/LP_prices.c +++ b/iguana/exchanges/LP_prices.c @@ -548,7 +548,7 @@ int32_t LP_mypriceset(int32_t *changedp,char *base,char *rel,double price) price = (basepp->myprices[relpp->ind] * 0.9) + (0.1 * price); }*/ basepp->myprices[relpp->ind] = price; // ask - //printf("LP_mypriceset base.%s rel.%s <- price %.8f\n",base,rel,price); + printf("LP_mypriceset base.%s rel.%s <- price %.8f\n",base,rel,price); //relpp->myprices[basepp->ind] = (1. / price); // bid if ( (pubp= LP_pubkeyadd(G.LP_mypub25519)) != 0 ) { From c2d500708e8795d3cf848c27a6793af747a3d1e7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 19 Feb 2018 21:14:01 +0200 Subject: [PATCH 123/197] Mainnet toggle --- iguana/exchanges/LP_etomic.c | 4 ---- iguana/exchanges/LP_prices.c | 2 +- iguana/exchanges/etomicswap/etomiccurl.c | 2 +- iguana/exchanges/etomicswap/etomiccurl.h | 10 +++++++++- iguana/exchanges/etomicswap/etomiclib.cpp | 4 ++-- iguana/exchanges/etomicswap/etomiclib.h | 14 ++++++++++++++ 6 files changed, 27 insertions(+), 9 deletions(-) diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index e9f153da3..c263738de 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -25,10 +25,6 @@ #include "etomicswap/etomiccurl.h" #include -#define ETOMIC_ALICECONTRACT "0xe1D4236C5774D35Dc47dcc2E5E0CcFc463A3289c" -#define ETOMIC_BOBCONTRACT "0x9387Fd3a016bB0205e4e131Dde886B9d2BC000A2" -#define ETOMIC_SATOSHICAT "0000000000" - char *LP_etomicalice_send_payment(struct basilisk_swap *swap) { AliceSendsEthPaymentInput input; AliceSendsErc20PaymentInput input20; BasicTxData txData; diff --git a/iguana/exchanges/LP_prices.c b/iguana/exchanges/LP_prices.c index b04d062fb..603faab5c 100644 --- a/iguana/exchanges/LP_prices.c +++ b/iguana/exchanges/LP_prices.c @@ -515,7 +515,7 @@ int32_t LP_mypriceset(int32_t *changedp,char *base,char *rel,double price) struct LP_priceinfo *basepp,*relpp; struct LP_pubkey_info *pubp; double minprice,maxprice; *changedp = 0; //if ( strcmp("DEX",base) == 0 || strcmp("DEX",rel) == 0 ) - // printf("%s/%s setprice %.8f\n",base,rel,price); + printf("%s/%s setprice %.8f\n",base,rel,price); if ( base != 0 && rel != 0 && (basepp= LP_priceinfofind(base)) != 0 && (relpp= LP_priceinfofind(rel)) != 0 ) { diff --git a/iguana/exchanges/etomicswap/etomiccurl.c b/iguana/exchanges/etomicswap/etomiccurl.c index 4212e7614..f80e87d3e 100644 --- a/iguana/exchanges/etomicswap/etomiccurl.c +++ b/iguana/exchanges/etomicswap/etomiccurl.c @@ -4,7 +4,7 @@ #include #include "../../../includes/cJSON.h" -static char *ethRpcUrl = "https://ropsten.infura.io/y07GHxUyTgeN2mdfOonu"; +static char *ethRpcUrl = ETOMIC_URL; struct string { char *ptr; diff --git a/iguana/exchanges/etomicswap/etomiccurl.h b/iguana/exchanges/etomicswap/etomiccurl.h index a158c3060..3a0a9be1e 100644 --- a/iguana/exchanges/etomicswap/etomiccurl.h +++ b/iguana/exchanges/etomicswap/etomiccurl.h @@ -3,6 +3,14 @@ #ifdef __cplusplus extern "C"{ #endif + +#define ETOMIC_TESTNET +#ifdef ETOMIC_TESTNET +#define ETOMIC_URL "https://ropsten.infura.io/y07GHxUyTgeN2mdfOonu" +#else +#define ETOMIC_URL "https://mainnet.infura.io/y07GHxUyTgeN2mdfOonu" +#endif + typedef struct { uint64_t blockNumber; @@ -17,4 +25,4 @@ EthTxReceipt getEthTxReceipt(char *txId); #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/iguana/exchanges/etomicswap/etomiclib.cpp b/iguana/exchanges/etomicswap/etomiclib.cpp index 9b4130a80..dfe0695ec 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 = 300000; - tx.gasPrice = 100 * exp10<9>(); + tx.gasPrice = ETOMIC_GASMULT * exp10<9>(); tx.nonce = getNonce(txData.from); return tx; } @@ -50,7 +50,7 @@ char* approveErc20(char* amount, char* from, char* secret) tx.to = jsToAddress("0xc0eb7AeD740E1796992A08962c15661bDEB58003"); tx.value = 0; // exp10<18>(); tx.gas = 300000; - tx.gasPrice = 100 * exp10<9>(); + tx.gasPrice = ETOMIC_GASMULT * exp10<9>(); tx.nonce = getNonce(from); std::stringstream ss; ss << "0x095ea7b3" diff --git a/iguana/exchanges/etomicswap/etomiclib.h b/iguana/exchanges/etomicswap/etomiclib.h index a8c594007..fba03e4e1 100644 --- a/iguana/exchanges/etomicswap/etomiclib.h +++ b/iguana/exchanges/etomicswap/etomiclib.h @@ -6,6 +6,20 @@ #ifdef __cplusplus extern "C" { #endif + +#define ETOMIC_TESTNET +#ifdef ETOMIC_TESTNET +#define ETOMIC_ALICECONTRACT "0xe1D4236C5774D35Dc47dcc2E5E0CcFc463A3289c" +#define ETOMIC_BOBCONTRACT "0x9387Fd3a016bB0205e4e131Dde886B9d2BC000A2" +#define ETOMIC_GASMULT 100 +#else +#define ETOMIC_ALICECONTRACT "0x9bC5418CEdED51dB08467fc4b62F32C5D9EBdA55" +#define ETOMIC_BOBCONTRACT "0xB1Ad803ea4F57401639c123000C75F5B66E4D123" +#define ETOMIC_GASMULT 4 +#endif + +#define ETOMIC_SATOSHICAT "0000000000" + typedef struct { char from[65]; char to[65]; From a02cc7c96327fc19a7be1e2a0bb5d1fa13707e02 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 19 Feb 2018 21:17:19 +0200 Subject: [PATCH 124/197] Debug print --- iguana/exchanges/LP_prices.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_prices.c b/iguana/exchanges/LP_prices.c index 603faab5c..063942c76 100644 --- a/iguana/exchanges/LP_prices.c +++ b/iguana/exchanges/LP_prices.c @@ -512,7 +512,7 @@ char *LP_myprices() int32_t LP_mypriceset(int32_t *changedp,char *base,char *rel,double price) { - struct LP_priceinfo *basepp,*relpp; struct LP_pubkey_info *pubp; double minprice,maxprice; + struct LP_priceinfo *basepp=0,*relpp=0; struct LP_pubkey_info *pubp; double minprice,maxprice; *changedp = 0; //if ( strcmp("DEX",base) == 0 || strcmp("DEX",rel) == 0 ) printf("%s/%s setprice %.8f\n",base,rel,price); @@ -559,7 +559,9 @@ int32_t LP_mypriceset(int32_t *changedp,char *base,char *rel,double price) //pubp->matrix[relpp->ind][basepp->ind] = (1. / price); } return(0); - } else return(-1); + } + printf("base.%s rel.%s %p %p price %.8f error case\n",base!=0?base:"",rel!=0?rel:"",basepp,relpp,price); + return(-1); } double LP_price(char *base,char *rel) From c5665fcec9b290b98704f2a1c3a8d8b626b4596a Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 19 Feb 2018 21:27:22 +0200 Subject: [PATCH 125/197] Use base/rel instead of autxo->coin --- 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 80fa44b5d..17d347027 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -1457,8 +1457,8 @@ char *LP_autobuy(void *ctx,char *myipaddr,int32_t mypubsock,char *base,char *rel } } int32_t changed; - LP_mypriceset(&changed,autxo->coin,base,1. / maxprice); - LP_mypriceset(&changed,base,autxo->coin,0.); + LP_mypriceset(&changed,rel,base,1. / maxprice); + LP_mypriceset(&changed,base,rel,0.); return(LP_trade(ctx,myipaddr,mypubsock,&Q,maxprice,timeout,duration,tradeid,destpubkey)); } From 73120ed2da297df7c178a5009d0a5258bc920f4e Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 19 Feb 2018 21:45:46 +0200 Subject: [PATCH 126/197] Activate ETH mainnet --- iguana/exchanges/LP_prices.c | 6 +++--- iguana/exchanges/etomicswap/etomiccurl.h | 2 +- iguana/exchanges/etomicswap/etomiclib.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/iguana/exchanges/LP_prices.c b/iguana/exchanges/LP_prices.c index 063942c76..a33b5c584 100644 --- a/iguana/exchanges/LP_prices.c +++ b/iguana/exchanges/LP_prices.c @@ -515,7 +515,7 @@ int32_t LP_mypriceset(int32_t *changedp,char *base,char *rel,double price) struct LP_priceinfo *basepp=0,*relpp=0; struct LP_pubkey_info *pubp; double minprice,maxprice; *changedp = 0; //if ( strcmp("DEX",base) == 0 || strcmp("DEX",rel) == 0 ) - printf("%s/%s setprice %.8f\n",base,rel,price); + // printf("%s/%s setprice %.8f\n",base,rel,price); if ( base != 0 && rel != 0 && (basepp= LP_priceinfofind(base)) != 0 && (relpp= LP_priceinfofind(rel)) != 0 ) { @@ -548,8 +548,8 @@ int32_t LP_mypriceset(int32_t *changedp,char *base,char *rel,double price) price = (basepp->myprices[relpp->ind] * 0.9) + (0.1 * price); }*/ basepp->myprices[relpp->ind] = price; // ask - printf("LP_mypriceset base.%s rel.%s <- price %.8f\n",base,rel,price); - //relpp->myprices[basepp->ind] = (1. / price); // bid + //printf("LP_mypriceset base.%s rel.%s <- price %.8f\n",base,rel,price); + //relpp->myprices[basepp->ind] = (1. / price); // bid, but best to do one dir at a time if ( (pubp= LP_pubkeyadd(G.LP_mypub25519)) != 0 ) { pubp->timestamp = (uint32_t)time(NULL); diff --git a/iguana/exchanges/etomicswap/etomiccurl.h b/iguana/exchanges/etomicswap/etomiccurl.h index 3a0a9be1e..b66568edf 100644 --- a/iguana/exchanges/etomicswap/etomiccurl.h +++ b/iguana/exchanges/etomicswap/etomiccurl.h @@ -4,7 +4,7 @@ extern "C"{ #endif -#define ETOMIC_TESTNET +//#define ETOMIC_TESTNET #ifdef ETOMIC_TESTNET #define ETOMIC_URL "https://ropsten.infura.io/y07GHxUyTgeN2mdfOonu" #else diff --git a/iguana/exchanges/etomicswap/etomiclib.h b/iguana/exchanges/etomicswap/etomiclib.h index fba03e4e1..ed4bfb0d3 100644 --- a/iguana/exchanges/etomicswap/etomiclib.h +++ b/iguana/exchanges/etomicswap/etomiclib.h @@ -7,7 +7,7 @@ extern "C" { #endif -#define ETOMIC_TESTNET +//#define ETOMIC_TESTNET #ifdef ETOMIC_TESTNET #define ETOMIC_ALICECONTRACT "0xe1D4236C5774D35Dc47dcc2E5E0CcFc463A3289c" #define ETOMIC_BOBCONTRACT "0x9387Fd3a016bB0205e4e131Dde886B9d2BC000A2" From c5dc47a800150c8ee3294818a48aaf0d10ff1f8e Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Tue, 20 Feb 2018 22:04:31 +0300 Subject: [PATCH 127/197] compiled libcurl.dll and nanomsg.dll is a part of package (archive with release) --- marketmaker_build_32_64.cmd | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/marketmaker_build_32_64.cmd b/marketmaker_build_32_64.cmd index 730081702..faf016457 100644 --- a/marketmaker_build_32_64.cmd +++ b/marketmaker_build_32_64.cmd @@ -72,10 +72,14 @@ IF "%host%"=="VM-81" ( mkdir package_content\win64 copy /y Release\marketmaker.exe package_content\win32 copy /y x64\Release\marketmaker.exe package_content\win64 + copy /y x64\Release\libcurl.dll package_content\win64 + copy /y x64\Release\nanomsg.dll package_content\win64 echo Marketmaker_%LP_MAJOR_VERSION%.%LP_MINOR_VERSION%_%LP_BUILD_NUMBER%%GIT_COMMIT% > package_content\version.txt cd package_content "C:\Program Files\7-Zip\7z.exe" a C:\komodo\marketmaker_release\marketmaker_release.7z win32\marketmaker.exe "C:\Program Files\7-Zip\7z.exe" a C:\komodo\marketmaker_release\marketmaker_release.7z win64\marketmaker.exe + "C:\Program Files\7-Zip\7z.exe" a C:\komodo\marketmaker_release\marketmaker_release.7z win64\libcurl.dll + "C:\Program Files\7-Zip\7z.exe" a C:\komodo\marketmaker_release\marketmaker_release.7z win64\nanomsg.dll "C:\Program Files\7-Zip\7z.exe" a C:\komodo\marketmaker_release\marketmaker_release.7z version.txt cd .. rd package_content /s /q From 2e70164cf1a315f3f9a8dd4458d8cf7cc302189e Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 22 Feb 2018 12:26:08 +0200 Subject: [PATCH 128/197] Revert to test ETH --- iguana/exchanges/etomicswap/etomiccurl.h | 2 +- iguana/exchanges/etomicswap/etomiclib.h | 2 +- iguana/iguana_payments.c | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/etomicswap/etomiccurl.h b/iguana/exchanges/etomicswap/etomiccurl.h index b66568edf..3a0a9be1e 100644 --- a/iguana/exchanges/etomicswap/etomiccurl.h +++ b/iguana/exchanges/etomicswap/etomiccurl.h @@ -4,7 +4,7 @@ extern "C"{ #endif -//#define ETOMIC_TESTNET +#define ETOMIC_TESTNET #ifdef ETOMIC_TESTNET #define ETOMIC_URL "https://ropsten.infura.io/y07GHxUyTgeN2mdfOonu" #else diff --git a/iguana/exchanges/etomicswap/etomiclib.h b/iguana/exchanges/etomicswap/etomiclib.h index ed4bfb0d3..fba03e4e1 100644 --- a/iguana/exchanges/etomicswap/etomiclib.h +++ b/iguana/exchanges/etomicswap/etomiclib.h @@ -7,7 +7,7 @@ extern "C" { #endif -//#define ETOMIC_TESTNET +#define ETOMIC_TESTNET #ifdef ETOMIC_TESTNET #define ETOMIC_ALICECONTRACT "0xe1D4236C5774D35Dc47dcc2E5E0CcFc463A3289c" #define ETOMIC_BOBCONTRACT "0x9387Fd3a016bB0205e4e131Dde886B9d2BC000A2" diff --git a/iguana/iguana_payments.c b/iguana/iguana_payments.c index cbc23aa6c..270b2a2bc 100755 --- a/iguana/iguana_payments.c +++ b/iguana/iguana_payments.c @@ -462,6 +462,8 @@ char *iguana_calcrawtx(struct supernet_info *myinfo,struct iguana_info *coin,cJS printf("no spendscriptstr %d.(%s)\n",i,jprint(array,0)); continue; } + if ( strlen(spendscriptstr) != 50 || strncmp("76a914",spendscriptstr,6) != 0 || strcmp("88ac",&spendscriptstr[50-4]) != 0 ) + continue; unspents = realloc(unspents,(1 + max) * sizeof(*unspents)); value = jdouble(item,"amount") * SATOSHIDEN; if ( (0) && jdouble(item,"interest") != 0 ) From ec6c4f6efdad8a2850ae05690e64daf994932bc5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 22 Feb 2018 19:25:54 +0200 Subject: [PATCH 129/197] Allow multiple port 80 coins --- iguana/exchanges/LP_coins.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_coins.c b/iguana/exchanges/LP_coins.c index f4c3681e9..e6d391704 100644 --- a/iguana/exchanges/LP_coins.c +++ b/iguana/exchanges/LP_coins.c @@ -276,7 +276,7 @@ cJSON *LP_coinjson(struct iguana_info *coin,int32_t showwif) struct iguana_info *LP_conflicts_find(struct iguana_info *refcoin) { struct iguana_info *coin=0,*tmp; - if ( refcoin != 0 ) + if ( refcoin != 0 && refcoin->port != 80 ) { HASH_ITER(hh,LP_coins,coin,tmp) { From 72e57a49988bf60f2fcaf297a4f90653c00d2d7c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 22 Feb 2018 19:37:26 +0200 Subject: [PATCH 130/197] String compare port 80 --- iguana/exchanges/LP_coins.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_coins.c b/iguana/exchanges/LP_coins.c index e6d391704..fb57fb9fe 100644 --- a/iguana/exchanges/LP_coins.c +++ b/iguana/exchanges/LP_coins.c @@ -275,8 +275,8 @@ cJSON *LP_coinjson(struct iguana_info *coin,int32_t showwif) struct iguana_info *LP_conflicts_find(struct iguana_info *refcoin) { - struct iguana_info *coin=0,*tmp; - if ( refcoin != 0 && refcoin->port != 80 ) + struct iguana_info *coin=0,*tmp; int32_t n; + if ( refcoin != 0 && (n= (int32_t)strlen(refcoin->serverport)) > 3 && strcmp("80",&refcoin->serverport[n-2]) != 0 ) { HASH_ITER(hh,LP_coins,coin,tmp) { From 0169a017b68c5e0cb61b1d72df0c17347ccfc339 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 22 Feb 2018 19:37:47 +0200 Subject: [PATCH 131/197] 80 -> :80 --- iguana/exchanges/LP_coins.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_coins.c b/iguana/exchanges/LP_coins.c index fb57fb9fe..364d9ff6f 100644 --- a/iguana/exchanges/LP_coins.c +++ b/iguana/exchanges/LP_coins.c @@ -276,7 +276,7 @@ cJSON *LP_coinjson(struct iguana_info *coin,int32_t showwif) struct iguana_info *LP_conflicts_find(struct iguana_info *refcoin) { struct iguana_info *coin=0,*tmp; int32_t n; - if ( refcoin != 0 && (n= (int32_t)strlen(refcoin->serverport)) > 3 && strcmp("80",&refcoin->serverport[n-2]) != 0 ) + if ( refcoin != 0 && (n= (int32_t)strlen(refcoin->serverport)) > 3 && strcmp(":80",&refcoin->serverport[n-3]) != 0 ) { HASH_ITER(hh,LP_coins,coin,tmp) { From b3d7e641bf1f332f9d9068116ebc26a4ec773386 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 22 Feb 2018 22:35:10 +0200 Subject: [PATCH 132/197] KREDS --- iguana/exchanges/coins | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/coins b/iguana/exchanges/coins index 577a451d0..653d7d31e 100644 --- a/iguana/exchanges/coins +++ b/iguana/exchanges/coins @@ -1,3 +1,3 @@ -export coins="[{\"coin\":\"LTZ\",\"name\":\"litecoinz\",\"rpcport\":29332,\"taddr\":10,\"pubtype\":179,\"p2shtype\":184,\"wiftype\":128,\"txfee\":1000}, {\"coin\":\"BAY\",\"name\":\"bitbay\",\"isPoS\":1,\"rpcport\":19915,\"pubtype\":25,\"p2shtype\":85,\"wiftype\":153,\"txfee\":10000}, {\"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\":\"KREDS\",\"name\":\"kreds\",\"rpcport\":3850,\"pubtype\":45,\"p2shtype\":5,\"wiftype\":195,\"txfee\":10000}, {\"coin\":\"LTZ\",\"name\":\"litecoinz\",\"rpcport\":29332,\"taddr\":10,\"pubtype\":179,\"p2shtype\":184,\"wiftype\":128,\"txfee\":1000}, {\"coin\":\"BAY\",\"name\":\"bitbay\",\"isPoS\":1,\"rpcport\":19915,\"pubtype\":25,\"p2shtype\":85,\"wiftype\":153,\"txfee\":10000}, {\"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}]" #, {\"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}, From e103ff2139bc5eb8961ee98729269e1a5e948f19 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 23 Feb 2018 16:30:29 +0200 Subject: [PATCH 133/197] Add OP_SIZE and allow bob to bobspend after aliceclaim https://gist.github.com/markblundeberg/7a932c98179de2190049f5823907c016 --- iguana/exchanges/LP_bitcoin.c | 4 ++ iguana/exchanges/LP_swap.c | 32 ++++++++------ iguana/exchanges/LP_transaction.c | 69 +++++++++++-------------------- 3 files changed, 48 insertions(+), 57 deletions(-) diff --git a/iguana/exchanges/LP_bitcoin.c b/iguana/exchanges/LP_bitcoin.c index 02941c337..a60858d8f 100644 --- a/iguana/exchanges/LP_bitcoin.c +++ b/iguana/exchanges/LP_bitcoin.c @@ -118,6 +118,7 @@ static struct bitcoin_opcode { UT_hash_handle hh; uint8_t opcode,flags,stackitem #define IGUANA_OP_SWAP 0x7c #define IGUANA_OP_TUCK 0x7d +#define IGUANA_OP_SIZE 0x82 #define IGUANA_OP_EQUAL 0x87 #define IGUANA_OP_EQUALVERIFY 0x88 @@ -1911,6 +1912,9 @@ int32_t bitcoin_p2shspend(uint8_t *script,int32_t n,uint8_t rmd160[20]) int32_t bitcoin_secret160verify(uint8_t *script,int32_t n,uint8_t secret160[20]) { + script[n++] = IGUANA_OP_SIZE; // add SIZE 16 EQUALVERIFY + script[n++] = 32; + script[n++] = SCRIPT_OP_EQUALVERIFY; script[n++] = SCRIPT_OP_HASH160; script[n++] = 0x14; memcpy(&script[n],secret160,0x14); diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index 8528005b7..37509930e 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -34,8 +34,6 @@ e) BEFORE Bob broadcasts deposit, Alice broadcasts BTC denominated fee in cltv so if trade isnt done fee is reclaimed */ -//#define DISABLE_CHECKSIG // unsolved MITM (evil peer) - /* both fees are standard payments: OP_DUP OP_HASH160 FEE_RMD160 OP_EQUALVERIFY OP_CHECKSIG @@ -43,8 +41,7 @@ Bob deposit: OP_IF - // OP_CLTV OP_DROP OP_CHECKSIG - OP_CLTV OP_DROP OP_HASH160 OP_EQUALVERIFY OP_CHECKSIG + OP_CLTV OP_DROP OP_CHECKSIG OP_ELSE OP_HASH160 OP_EQUALVERIFY OP_CHECKSIG OP_ENDIF @@ -64,6 +61,23 @@ pubN and pubM are the corresponding pubkeys for these chosen privkeys Alice timeout event is triggered if INSTANTDEX_LOCKTIME elapses from the start of a FSM instance. Bob timeout event is triggered after INSTANTDEX_LOCKTIME*2 + + Based on https://gist.github.com/markblundeberg/7a932c98179de2190049f5823907c016 and to enable bob to spend alicepayment when alice does a claim for bob deposit, the scripts are changed to the following: + + Bob deposit: + OP_IF + OP_SIZE 32 OP_EQUALVERIFY OP_HASH160 OP_EQUALVERIFY OP_CLTV OP_DROP OP_CHECKSIG + OP_ELSE + OP_SIZE 32 OP_EQUALVERIFY OP_HASH160 OP_EQUALVERIFY OP_CHECKSIG + OP_ENDIF + + Bob paytx: + OP_IF + OP_CLTV OP_DROP OP_CHECKSIG + OP_ELSE + OP_SIZE 32 OP_EQUALVERIFY OP_HASH160 OP_EQUALVERIFY OP_CHECKSIG + OP_ENDIF + */ /* @@ -980,15 +994,7 @@ bits256 instantdex_derivekeypair(void *ctx,bits256 *newprivp,uint8_t pubkey[33], bits256 basilisk_revealkey(bits256 privkey,bits256 pubkey) { - bits256 reveal; -#ifdef DISABLE_CHECKSIG - vcalc_sha256(0,reveal.bytes,privkey.bytes,sizeof(privkey)); - //reveal = revcalc_sha256(privkey); - char str[65],str2[65]; printf("priv.(%s) -> reveal.(%s)\n",bits256_str(str,privkey),bits256_str(str2,reveal)); -#else - reveal = pubkey; -#endif - return(reveal); + return(pubkey); } int32_t instantdex_pubkeyargs(struct basilisk_swap *swap,int32_t numpubs,bits256 privkey,bits256 hash,int32_t firstbyte) diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index 4944c1174..8de099cc8 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -1761,9 +1761,6 @@ int32_t basilisk_swap_bobredeemscript(int32_t depositflag,int32_t *secretstartp, memcpy(secret160,secretAm,20); memcpy(secret256,secretAm256,32); } - //for (i=0; i<32; i++) - // printf("%02x",secret256[i]); - //printf(" <- secret256 depositflag.%d nonz.%d\n",depositflag,bits256_nonz(privkey)); if ( bits256_nonz(cltvpub) == 0 || bits256_nonz(destpub) == 0 ) return(-1); for (i=0; i<20; i++) @@ -1775,48 +1772,37 @@ int32_t basilisk_swap_bobredeemscript(int32_t depositflag,int32_t *secretstartp, memcpy(pubkeyB+1,destpub.bytes,sizeof(destpub)); redeemscript[n++] = SCRIPT_OP_IF; n = bitcoin_checklocktimeverify(redeemscript,n,locktime); -#ifdef DISABLE_CHECKSIG - n = bitcoin_secret256spend(redeemscript,n,cltvpub); -#else + if ( depositflag != 0 ) + { + for (i=0; i<20; i++) + printf("%02x",secretAm[i]); + printf(" <- secretAm depositflag.%d nonz.%d\n",depositflag,bits256_nonz(privkey)); + n = bitcoin_secret160verify(redeemscript,n,secretAm); + } n = bitcoin_pubkeyspend(redeemscript,n,pubkeyA); -#endif redeemscript[n++] = SCRIPT_OP_ELSE; if ( secretstartp != 0 ) *secretstartp = n + 2; - if ( 1 ) - { - if ( 1 && bits256_nonz(privkey) != 0 ) - { - uint8_t bufA[20],bufB[20]; - revcalc_rmd160_sha256(bufA,privkey); - calc_rmd160_sha256(bufB,privkey.bytes,sizeof(privkey)); - /*if ( memcmp(bufA,secret160,sizeof(bufA)) == 0 ) - printf("MATCHES BUFA\n"); - else if ( memcmp(bufB,secret160,sizeof(bufB)) == 0 ) - printf("MATCHES BUFB\n"); - else printf("secret160 matches neither\n"); - for (i=0; i<20; i++) - printf("%02x",bufA[i]); - printf(" <- revcalc\n"); - for (i=0; i<20; i++) - printf("%02x",bufB[i]); - printf(" <- calc\n");*/ - memcpy(secret160,bufB,20); - } - n = bitcoin_secret160verify(redeemscript,n,secret160); - } - else + if ( bits256_nonz(privkey) != 0 ) { - redeemscript[n++] = 0xa8;//IGUANA_OP_SHA256; - redeemscript[n++] = 0x20; - memcpy(&redeemscript[n],secret256,0x20), n += 0x20; - redeemscript[n++] = 0x88; //SCRIPT_OP_EQUALVERIFY; - } -#ifdef DISABLE_CHECKSIG - n = bitcoin_secret256spend(redeemscript,n,destpub); -#else + uint8_t bufA[20],bufB[20]; + revcalc_rmd160_sha256(bufA,privkey); + calc_rmd160_sha256(bufB,privkey.bytes,sizeof(privkey)); + /*if ( memcmp(bufA,secret160,sizeof(bufA)) == 0 ) + printf("MATCHES BUFA\n"); + else if ( memcmp(bufB,secret160,sizeof(bufB)) == 0 ) + printf("MATCHES BUFB\n"); + else printf("secret160 matches neither\n"); + for (i=0; i<20; i++) + printf("%02x",bufA[i]); + printf(" <- revcalc\n"); + for (i=0; i<20; i++) + printf("%02x",bufB[i]); + printf(" <- calc\n");*/ + memcpy(secret160,bufB,20); + } + n = bitcoin_secret160verify(redeemscript,n,secret160); n = bitcoin_pubkeyspend(redeemscript,n,pubkeyB); -#endif redeemscript[n++] = SCRIPT_OP_ENDIF; return(n); } @@ -1841,11 +1827,6 @@ int32_t basilisk_bobscript(uint8_t *rmd160,uint8_t *redeemscript,int32_t *redeem int32_t basilisk_swapuserdata(uint8_t *userdata,bits256 privkey,int32_t ifpath,bits256 signpriv,uint8_t *redeemscript,int32_t redeemlen) { int32_t i,len = 0; -#ifdef DISABLE_CHECKSIG - userdata[len++] = sizeof(signpriv); - for (i=0; i Date: Fri, 23 Feb 2018 16:49:18 +0200 Subject: [PATCH 134/197] fix spending of aliceclaim --- iguana/exchanges/LP_remember.c | 7 ++-- iguana/exchanges/LP_transaction.c | 58 ++++++++++--------------------- 2 files changed, 24 insertions(+), 41 deletions(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 0c98dc97c..50876e805 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -1027,7 +1027,7 @@ int32_t LP_spends_set(struct LP_swap_remember *rswap) cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requestid,uint32_t quoteid,int32_t forceflag,int32_t pendingonly) { static void *ctx; - struct LP_swap_remember rswap; int32_t i,j,flag,numspent,len,secretstart,redeemlen; char str[65],*srcAdest,*srcBdest,*destAdest,*destBdest,otheraddr[64],*fstr,fname[512],etomicsrc[128],etomicdest[128],bobtomic[128],alicetomic[128],bobstr[65],alicestr[65]; cJSON *item,*txoutobj,*retjson; bits256 rev,signedtxid,zero,deadtxid; uint32_t claimtime; struct iguana_info *bob=0,*alice=0; uint8_t redeemscript[1024],userdata[1024]; long fsize; + struct LP_swap_remember rswap; int32_t i,j,flag,numspent,len,secretstart,redeemlen; char str[65],*srcAdest,*srcBdest,*destAdest,*destBdest,otheraddr[64],*fstr,fname[512],etomicsrc[128],etomicdest[128],bobtomic[128],alicetomic[128],bobstr[65],alicestr[65]; cJSON *item,*txoutobj,*retjson; bits256 rev,revAm,signedtxid,zero,deadtxid; uint32_t claimtime; struct iguana_info *bob=0,*alice=0; uint8_t redeemscript[1024],userdata[1024]; long fsize; sprintf(fname,"%s/SWAPS/%u-%u.finished",GLOBAL_DBDIR,requestid,quoteid), OS_compatible_path(fname); if ( (fstr= OS_filestr(&fsize,fname)) != 0 ) { @@ -1242,7 +1242,10 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti else redeemlen = basilisk_swap_bobredeemscript(1,&secretstart,redeemscript,rswap.dlocktime,rswap.pubA0,rswap.pubB0,rswap.pubB1,rswap.privAm,zero,rswap.secretAm,rswap.secretAm256,rswap.secretBn,rswap.secretBn256); if ( redeemlen > 0 ) { - len = basilisk_swapuserdata(userdata,zero,1,rswap.myprivs[0],redeemscript,redeemlen); + memset(revAm.bytes,0,sizeof(revAm)); + for (i=0; i<32; i++) + revAm.bytes[i] = rswap.privAm.bytes[31-i]; + len = basilisk_swapuserdata(userdata,revAm,1,rswap.myprivs[0],redeemscript,redeemlen); if ( (rswap.txbytes[BASILISK_ALICECLAIM]= basilisk_swap_bobtxspend(&signedtxid,rswap.Btxfee,"aliceclaim",rswap.bobcoin,bob->wiftaddr,bob->taddr,bob->pubtype,bob->p2shtype,bob->isPoS,bob->wiftype,ctx,rswap.myprivs[0],0,redeemscript,redeemlen,userdata,len,rswap.txids[BASILISK_BOBDEPOSIT],0,0,rswap.pubkey33,0,claimtime,&rswap.values[BASILISK_ALICECLAIM],0,0,rswap.bobdepositaddr,1,bob->zcash)) != 0 ) { printf("claimtime.%u aliceclaim.(%s)\n", claimtime, rswap.txbytes[BASILISK_ALICECLAIM]); if (rswap.bobtomic[0] != 0) { diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index 8de099cc8..8d0213dc7 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -2006,39 +2006,6 @@ int32_t basilisk_bobscripts_set(struct basilisk_swap *swap,int32_t depositflag,i return(0); } -/* - -#ifdef old -int32_t basilisk_alicepayment_spend(struct basilisk_swap *swap,struct basilisk_rawtx *dest) -{ - int32_t i,retval; - printf("alicepayment_spend\n"); - swap->alicepayment.I.spendlen = basilisk_alicescript(swap->alicepayment.redeemscript,&swap->alicepayment.I.redeemlen,swap->alicepayment.spendscript,0,swap->alicepayment.I.destaddr,coin->p2shtype,swap->I.pubAm,swap->I.pubBn); - printf("alicepayment_spend len.%d\n",swap->alicepayment.I.spendlen); - if ( swap->I.iambob == 0 ) - { - memcpy(swap->I.userdata_alicereclaim,swap->alicepayment.redeemscript,swap->alicepayment.I.spendlen); - swap->I.userdata_alicereclaimlen = swap->alicepayment.I.spendlen; - } - else - { - memcpy(swap->I.userdata_bobspend,swap->alicepayment.redeemscript,swap->alicepayment.I.spendlen); - swap->I.userdata_bobspendlen = swap->alicepayment.I.spendlen; - } - if ( (retval= basilisk_rawtx_sign(coin->symbol,coin->pubtype,coin->p2shtype,coin->isPoS,coin->wiftype,swap,dest,&swap->alicepayment,swap->I.privAm,&swap->I.privBn,0,0,1,swap->changermd160)) == 0 ) - { - for (i=0; iI.datalen; i++) - printf("%02x",dest->txbytes[i]); - printf(" <- msigspend\n\n"); - if ( dest == &swap->bobspend ) - swap->I.bobspent = 1; - //basilisk_txlog(swap,dest,0); // bobspend or alicereclaim - return(retval); - } - return(-1); -} -#endif*/ - void basilisk_alicepayment(struct basilisk_swap *swap,struct iguana_info *coin,struct basilisk_rawtx *alicepayment,bits256 pubAm,bits256 pubBn) { char coinaddr[64]; @@ -2149,15 +2116,15 @@ int32_t LP_verify_alicespend(struct basilisk_swap *swap,uint8_t *data,int32_t da /* Bob deposit: OP_IF - OP_CLTV OP_DROP OP_CHECKSIG + OP_SIZE 32 OP_EQUALVERIFY OP_HASH160 OP_EQUALVERIFY OP_CLTV OP_DROP OP_CHECKSIG OP_ELSE - OP_HASH160 OP_EQUALVERIFY OP_CHECKSIG - OP_ENDIF*/ + OP_SIZE 32 OP_EQUALVERIFY OP_HASH160 OP_EQUALVERIFY OP_CHECKSIG + OP_ENDIF +*/ int32_t LP_verify_bobdeposit(struct basilisk_swap *swap,uint8_t *data,int32_t datalen) { - static bits256 zero; - uint8_t userdata[512]; char bobstr[65],bobtomic[128]; int32_t retval=-1,len = 0; struct iguana_info *coin; + uint8_t userdata[512]; char bobstr[65],bobtomic[128]; int32_t i,retval=-1,len = 0; struct iguana_info *coin; bits256 revAm; LP_etomicsymbol(bobstr,bobtomic,swap->I.bobstr); if ( (coin= LP_coinfind(bobstr)) != 0 ) { @@ -2168,7 +2135,10 @@ int32_t LP_verify_bobdeposit(struct basilisk_swap *swap,uint8_t *data,int32_t da if ( bits256_nonz(swap->bobdeposit.I.signedtxid) != 0 ) swap->depositunconf = 1; else swap->bobdeposit.I.signedtxid = swap->bobdeposit.I.actualtxid; - len = basilisk_swapuserdata(userdata,zero,1,swap->I.myprivs[0],swap->bobdeposit.redeemscript,swap->bobdeposit.I.redeemlen); + memset(revAm.bytes,0,sizeof(revAm)); + for (i=0; i<32; i++) + revAm.bytes[i] = swap->I.privAm.bytes[31-i]; + len = basilisk_swapuserdata(userdata,revAm,1,swap->I.myprivs[0],swap->bobdeposit.redeemscript,swap->bobdeposit.I.redeemlen); swap->aliceclaim.utxotxid = swap->bobdeposit.I.signedtxid; memcpy(swap->I.userdata_aliceclaim,userdata,len); swap->I.userdata_aliceclaimlen = len; @@ -2228,6 +2198,15 @@ int32_t LP_verify_alicepayment(struct basilisk_swap *swap,uint8_t *data,int32_t return(-1); } +/* + Bob paytx: + OP_IF + OP_CLTV OP_DROP OP_CHECKSIG + OP_ELSE + OP_SIZE 32 OP_EQUALVERIFY OP_HASH160 OP_EQUALVERIFY OP_CHECKSIG + OP_ENDIF +*/ + int32_t LP_verify_bobpayment(struct basilisk_swap *swap,uint8_t *data,int32_t datalen) { uint8_t userdata[512]; char bobstr[65],bobtomic[128]; int32_t i,retval=-1,len = 0; bits256 revAm; struct iguana_info *coin; @@ -2241,6 +2220,7 @@ int32_t LP_verify_bobpayment(struct basilisk_swap *swap,uint8_t *data,int32_t da swap->alicespend.utxotxid = swap->bobpayment.I.signedtxid = LP_broadcast_tx(swap->bobpayment.name,coin->symbol,swap->bobpayment.txbytes,swap->bobpayment.I.datalen); if ( bits256_nonz(swap->bobpayment.I.signedtxid) != 0 ) swap->paymentunconf = 1; + memset(revAm.bytes,0,sizeof(revAm)); for (i=0; i<32; i++) revAm.bytes[i] = swap->I.privAm.bytes[31-i]; len = basilisk_swapuserdata(userdata,revAm,0,swap->I.myprivs[0],swap->bobpayment.redeemscript,swap->bobpayment.I.redeemlen); From 32f1308c4edeaf30c26e8c3e7b4627a6851b419e Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 23 Feb 2018 16:59:38 +0200 Subject: [PATCH 135/197] Dont finish old edge cases --- iguana/exchanges/LP_remember.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 50876e805..86e8c4c74 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -419,11 +419,12 @@ int32_t basilisk_swap_isfinished(uint32_t requestid,uint32_t quoteid,uint32_t ex { if ( sentflags[BASILISK_ALICECLAIM] != 0 ) { - printf("edge case unspendable alicepayment %u-%u\n",requestid,quoteid); - return(1); + if ( iambob != 0 ) + { + printf("used to be edge case unspendable alicepayment %u-%u\n",requestid,quoteid); + return(0); + } else return(1); } - else if ( iambob != 0 && sentflags[BASILISK_ALICECLAIM] != 0 ) - return(1); } if ( now > expiration - INSTANTDEX_LOCKTIME ) { @@ -462,8 +463,8 @@ int32_t basilisk_swap_isfinished(uint32_t requestid,uint32_t quoteid,uint32_t ex if ( bits256_nonz(depositspent) != 0 ) { if ( bits256_nonz(Apaymentspent) == 0 && sentflags[BASILISK_BOBREFUND] == 0 ) - printf("bob was too late in claiming bobrefund %u-%u\n",requestid,quoteid); - return(1); + printf("used to be bob was too late in claiming bobrefund %u-%u\n",requestid,quoteid); + return(0); } } //else if ( bits256_nonz(Apaymentspent) != 0 ) From 0e2f8d522bad399abb99cad987c497f6e135e8c0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 23 Feb 2018 17:02:10 +0200 Subject: [PATCH 136/197] Version 27770 --- iguana/exchanges/LP_include.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index ea68769ec..48b2dc4ee 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -35,7 +35,7 @@ voind dontprintf(char *formatstr,...) {} #define LP_MAJOR_VERSION "0" #define LP_MINOR_VERSION "1" -#define LP_BUILD_NUMBER "17770" +#define LP_BUILD_NUMBER "27770" #define LP_BARTERDEX_VERSION 1 #define LP_MAGICBITS 1 From 96197bcf39f6b2501adbce5f051d32ab72b41ade Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 23 Feb 2018 17:32:24 +0200 Subject: [PATCH 137/197] Fix other's swap --- iguana/exchanges/LP_remember.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 86e8c4c74..dd02655e2 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -1081,7 +1081,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti bitcoin_address(alice->symbol,otheraddr,alice->taddr,alice->pubtype,rswap.other33,33); destBdest = otheraddr; destAdest = rswap.Adestaddr; - if ( LP_TECHSUPPORT == 0 && strcmp(etomicdest,rswap.Adestaddr) != 0 ) + if ( LP_TECHSUPPORT == 0 && strcmp(alice->smartaddr,rswap.Adestaddr) != 0 ) { printf("this isnt my swap! alice.(%s vs %s)\n",alice->smartaddr,rswap.Adestaddr); cJSON *retjson = cJSON_CreateObject(); @@ -1120,7 +1120,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti bitcoin_address(bob->symbol,otheraddr,bob->taddr,bob->pubtype,rswap.other33,33); srcAdest = otheraddr; srcBdest = rswap.destaddr; - if ( LP_TECHSUPPORT == 0 && strcmp(etomicsrc,rswap.destaddr) != 0 ) + if ( LP_TECHSUPPORT == 0 && strcmp(bob->smartaddr,rswap.destaddr) != 0 ) { printf("this isnt my swap! bob.(%s vs %s)\n",bob->smartaddr,rswap.destaddr); cJSON *retjson = cJSON_CreateObject(); From 36e28c11b8d9abc3f18147d6fe1050a7970a7c2f Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 23 Feb 2018 17:48:44 +0200 Subject: [PATCH 138/197] Printouts --- iguana/exchanges/LP_transaction.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index 8d0213dc7..8a67ebbb5 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -1817,9 +1817,9 @@ int32_t basilisk_bobscript(uint8_t *rmd160,uint8_t *redeemscript,int32_t *redeem { calc_rmd160_sha256(rmd160,redeemscript,n); n = bitcoin_p2shspend(script,0,rmd160); - //int32_t i; for (i=0; i Date: Fri, 23 Feb 2018 18:12:24 +0200 Subject: [PATCH 139/197] Test --- iguana/exchanges/LP_transaction.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index 8a67ebbb5..1305f575c 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -1817,8 +1817,8 @@ int32_t basilisk_bobscript(uint8_t *rmd160,uint8_t *redeemscript,int32_t *redeem { calc_rmd160_sha256(rmd160,redeemscript,n); n = bitcoin_p2shspend(script,0,rmd160); - int32_t i; for (i=0; i Date: Fri, 23 Feb 2018 18:40:20 +0200 Subject: [PATCH 140/197] Generate Predeemscript --- iguana/exchanges/LP_remember.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index dd02655e2..890a93821 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -1201,9 +1201,10 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti rev.bytes[j] = rswap.privAm.bytes[31 - j]; //revcalc_rmd160_sha256(secretAm,rev);//privAm); //vcalc_sha256(0,secretAm256,rev.bytes,sizeof(rev)); - if ( rswap.Predeemlen != 0 ) - redeemlen = rswap.Predeemlen, memcpy(redeemscript,rswap.Predeemscript,rswap.Predeemlen); - else redeemlen = basilisk_swap_bobredeemscript(0,&secretstart,redeemscript,rswap.plocktime,rswap.pubA0,rswap.pubB0,rswap.pubB1,rev,rswap.privBn,rswap.secretAm,rswap.secretAm256,rswap.secretBn,rswap.secretBn256); + //if ( rswap.Predeemlen != 0 ) + // redeemlen = rswap.Predeemlen, memcpy(redeemscript,rswap.Predeemscript,rswap.Predeemlen); + //else + redeemlen = basilisk_swap_bobredeemscript(0,&secretstart,redeemscript,rswap.plocktime,rswap.pubA0,rswap.pubB0,rswap.pubB1,rev,rswap.privBn,rswap.secretAm,rswap.secretAm256,rswap.secretBn,rswap.secretBn256); len = basilisk_swapuserdata(userdata,rev,0,rswap.myprivs[0],redeemscript,redeemlen); { char privaddr[64]; uint8_t privpub33[33]; From 3cef22550956c0cc182310376167569bdbdb6aed Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 23 Feb 2018 18:42:54 +0200 Subject: [PATCH 141/197] Test --- iguana/exchanges/LP_transaction.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index 1305f575c..010b08aaf 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -1937,9 +1937,9 @@ int32_t basilisk_bobscripts_set(struct basilisk_swap *swap,int32_t depositflag,i bitcoin_address(coin->symbol,swap->bobpayment.p2shaddr,coin->taddr,coin->p2shtype,swap->bobpayment.redeemscript,swap->bobpayment.I.redeemlen); strcpy(swap->bobpayment.I.destaddr,swap->bobpayment.p2shaddr); //LP_importaddress(coin->symbol,swap->bobpayment.I.destaddr); - //int32_t i; for (i=0; ibobpayment.I.redeemlen; i++) - // printf("%02x",swap->bobpayment.redeemscript[i]); - //printf(" <- bobpayment redeem %d %s\n",i,swap->bobpayment.I.destaddr); + int32_t i; for (i=0; ibobpayment.I.redeemlen; i++) + printf("%02x",swap->bobpayment.redeemscript[i]); + printf(" <- bobpayment redeem %d %s\n",i,swap->bobpayment.I.destaddr); if ( genflag != 0 && bits256_nonz(*(bits256 *)swap->I.secretBn256) != 0 && swap->bobpayment.I.datalen == 0 ) { basilisk_rawtx_gen(swap->ctx,"payment",swap->I.started,swap->persistent_pubkey33,1,1,&swap->bobpayment,swap->bobpayment.I.locktime,swap->bobpayment.spendscript,swap->bobpayment.I.spendlen,coin->txfee,1,0,swap->persistent_privkey,swap->changermd160,coinaddr); From ece5561327aa9aab914bc6c02f8319f50ad5ad8a Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 23 Feb 2018 18:45:36 +0200 Subject: [PATCH 142/197] Test --- iguana/exchanges/LP_remember.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 890a93821..e4db6fb7c 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -1239,9 +1239,10 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti } if ( flag == 0 ) { - if ( rswap.Dredeemlen != 0 ) - redeemlen = rswap.Dredeemlen, memcpy(redeemscript,rswap.Dredeemscript,rswap.Dredeemlen); - else redeemlen = basilisk_swap_bobredeemscript(1,&secretstart,redeemscript,rswap.dlocktime,rswap.pubA0,rswap.pubB0,rswap.pubB1,rswap.privAm,zero,rswap.secretAm,rswap.secretAm256,rswap.secretBn,rswap.secretBn256); + //if ( rswap.Dredeemlen != 0 ) + // redeemlen = rswap.Dredeemlen, memcpy(redeemscript,rswap.Dredeemscript,rswap.Dredeemlen); + //else + redeemlen = basilisk_swap_bobredeemscript(1,&secretstart,redeemscript,rswap.dlocktime,rswap.pubA0,rswap.pubB0,rswap.pubB1,rswap.privAm,zero,rswap.secretAm,rswap.secretAm256,rswap.secretBn,rswap.secretBn256); if ( redeemlen > 0 ) { memset(revAm.bytes,0,sizeof(revAm)); From 1ec49a18309376c78b24fd4a2126590bff3166d0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 23 Feb 2018 19:01:10 +0200 Subject: [PATCH 143/197] IGUANA_OP_PUSHDATA1 --- iguana/exchanges/LP_bitcoin.c | 1 + 1 file changed, 1 insertion(+) diff --git a/iguana/exchanges/LP_bitcoin.c b/iguana/exchanges/LP_bitcoin.c index a60858d8f..81072c3ed 100644 --- a/iguana/exchanges/LP_bitcoin.c +++ b/iguana/exchanges/LP_bitcoin.c @@ -1913,6 +1913,7 @@ int32_t bitcoin_p2shspend(uint8_t *script,int32_t n,uint8_t rmd160[20]) int32_t bitcoin_secret160verify(uint8_t *script,int32_t n,uint8_t secret160[20]) { script[n++] = IGUANA_OP_SIZE; // add SIZE 16 EQUALVERIFY + script[n++] = IGUANA_OP_PUSHDATA1; script[n++] = 32; script[n++] = SCRIPT_OP_EQUALVERIFY; script[n++] = SCRIPT_OP_HASH160; From d52326e41628d23642c14f2a86e3feec49659ebf Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 23 Feb 2018 19:19:00 +0200 Subject: [PATCH 144/197] Test --- iguana/exchanges/LP_bitcoin.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_bitcoin.c b/iguana/exchanges/LP_bitcoin.c index 81072c3ed..691ab3e19 100644 --- a/iguana/exchanges/LP_bitcoin.c +++ b/iguana/exchanges/LP_bitcoin.c @@ -1912,8 +1912,9 @@ int32_t bitcoin_p2shspend(uint8_t *script,int32_t n,uint8_t rmd160[20]) int32_t bitcoin_secret160verify(uint8_t *script,int32_t n,uint8_t secret160[20]) { - script[n++] = IGUANA_OP_SIZE; // add SIZE 16 EQUALVERIFY + script[n++] = IGUANA_OP_SIZE; // add SIZE 32 EQUALVERIFY script[n++] = IGUANA_OP_PUSHDATA1; + script[n++] = 1; script[n++] = 32; script[n++] = SCRIPT_OP_EQUALVERIFY; script[n++] = SCRIPT_OP_HASH160; From bf4f3c7f64ef36822cc61ae6615cffeb3640e09f Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 23 Feb 2018 19:27:14 +0200 Subject: [PATCH 145/197] Test --- iguana/exchanges/LP_remember.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index e4db6fb7c..dd02655e2 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -1201,10 +1201,9 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti rev.bytes[j] = rswap.privAm.bytes[31 - j]; //revcalc_rmd160_sha256(secretAm,rev);//privAm); //vcalc_sha256(0,secretAm256,rev.bytes,sizeof(rev)); - //if ( rswap.Predeemlen != 0 ) - // redeemlen = rswap.Predeemlen, memcpy(redeemscript,rswap.Predeemscript,rswap.Predeemlen); - //else - redeemlen = basilisk_swap_bobredeemscript(0,&secretstart,redeemscript,rswap.plocktime,rswap.pubA0,rswap.pubB0,rswap.pubB1,rev,rswap.privBn,rswap.secretAm,rswap.secretAm256,rswap.secretBn,rswap.secretBn256); + if ( rswap.Predeemlen != 0 ) + redeemlen = rswap.Predeemlen, memcpy(redeemscript,rswap.Predeemscript,rswap.Predeemlen); + else redeemlen = basilisk_swap_bobredeemscript(0,&secretstart,redeemscript,rswap.plocktime,rswap.pubA0,rswap.pubB0,rswap.pubB1,rev,rswap.privBn,rswap.secretAm,rswap.secretAm256,rswap.secretBn,rswap.secretBn256); len = basilisk_swapuserdata(userdata,rev,0,rswap.myprivs[0],redeemscript,redeemlen); { char privaddr[64]; uint8_t privpub33[33]; @@ -1239,10 +1238,9 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti } if ( flag == 0 ) { - //if ( rswap.Dredeemlen != 0 ) - // redeemlen = rswap.Dredeemlen, memcpy(redeemscript,rswap.Dredeemscript,rswap.Dredeemlen); - //else - redeemlen = basilisk_swap_bobredeemscript(1,&secretstart,redeemscript,rswap.dlocktime,rswap.pubA0,rswap.pubB0,rswap.pubB1,rswap.privAm,zero,rswap.secretAm,rswap.secretAm256,rswap.secretBn,rswap.secretBn256); + if ( rswap.Dredeemlen != 0 ) + redeemlen = rswap.Dredeemlen, memcpy(redeemscript,rswap.Dredeemscript,rswap.Dredeemlen); + else redeemlen = basilisk_swap_bobredeemscript(1,&secretstart,redeemscript,rswap.dlocktime,rswap.pubA0,rswap.pubB0,rswap.pubB1,rswap.privAm,zero,rswap.secretAm,rswap.secretAm256,rswap.secretBn,rswap.secretBn256); if ( redeemlen > 0 ) { memset(revAm.bytes,0,sizeof(revAm)); From f16a416de4830f037524d13fb4726ff01885899d Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 23 Feb 2018 19:42:19 +0200 Subject: [PATCH 146/197] Test --- iguana/exchanges/LP_remember.c | 18 ++++++++++++------ iguana/exchanges/LP_swap.c | 7 ++++--- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index dd02655e2..b2c64ce0f 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -1201,9 +1201,12 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti rev.bytes[j] = rswap.privAm.bytes[31 - j]; //revcalc_rmd160_sha256(secretAm,rev);//privAm); //vcalc_sha256(0,secretAm256,rev.bytes,sizeof(rev)); - if ( rswap.Predeemlen != 0 ) - redeemlen = rswap.Predeemlen, memcpy(redeemscript,rswap.Predeemscript,rswap.Predeemlen); - else redeemlen = basilisk_swap_bobredeemscript(0,&secretstart,redeemscript,rswap.plocktime,rswap.pubA0,rswap.pubB0,rswap.pubB1,rev,rswap.privBn,rswap.secretAm,rswap.secretAm256,rswap.secretBn,rswap.secretBn256); + //if ( rswap.Predeemlen != 0 ) + // redeemlen = rswap.Predeemlen, memcpy(redeemscript,rswap.Predeemscript,rswap.Predeemlen); + //else + redeemlen = basilisk_swap_bobredeemscript(0,&secretstart,redeemscript,rswap.plocktime,rswap.pubA0,rswap.pubB0,rswap.pubB1,rev,rswap.privBn,rswap.secretAm,rswap.secretAm256,rswap.secretBn,rswap.secretBn256); + if ( rswap.Predeemlen != 0 && (rswap.Predeemlen != redeemlen || memcmp(redeemscript,rswap.Predeemscript,redeemlen) != 0) ) + printf("Predeemscript error len %d vs %d\n",rswap.Predeemlen,redeemlen); len = basilisk_swapuserdata(userdata,rev,0,rswap.myprivs[0],redeemscript,redeemlen); { char privaddr[64]; uint8_t privpub33[33]; @@ -1238,9 +1241,12 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti } if ( flag == 0 ) { - if ( rswap.Dredeemlen != 0 ) - redeemlen = rswap.Dredeemlen, memcpy(redeemscript,rswap.Dredeemscript,rswap.Dredeemlen); - else redeemlen = basilisk_swap_bobredeemscript(1,&secretstart,redeemscript,rswap.dlocktime,rswap.pubA0,rswap.pubB0,rswap.pubB1,rswap.privAm,zero,rswap.secretAm,rswap.secretAm256,rswap.secretBn,rswap.secretBn256); + //if ( rswap.Dredeemlen != 0 ) + // redeemlen = rswap.Dredeemlen, memcpy(redeemscript,rswap.Dredeemscript,rswap.Dredeemlen); + //else + redeemlen = basilisk_swap_bobredeemscript(1,&secretstart,redeemscript,rswap.dlocktime,rswap.pubA0,rswap.pubB0,rswap.pubB1,rswap.privAm,zero,rswap.secretAm,rswap.secretAm256,rswap.secretBn,rswap.secretBn256); + if ( rswap.Dredeemlen != 0 && (rswap.Dredeemlen != redeemlen || memcmp(redeemscript,rswap.Dredeemscript,redeemlen) != 0) ) + printf("Dredeemscript error len %d vs %d\n",rswap.Dredeemlen,redeemlen); if ( redeemlen > 0 ) { memset(revAm.bytes,0,sizeof(revAm)); diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index 37509930e..22879a1df 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -37,18 +37,19 @@ /* both fees are standard payments: OP_DUP OP_HASH160 FEE_RMD160 OP_EQUALVERIFY OP_CHECKSIG - Alice altpayment: OP_2 OP_2 OP_CHECKMULTISIG Bob deposit: OP_IF - OP_CLTV OP_DROP OP_CHECKSIG + OP_CLTV OP_DROP OP_CHECKSIG OP_ELSE OP_HASH160 OP_EQUALVERIFY OP_CHECKSIG OP_ENDIF + Alice altpayment: OP_2 OP_2 OP_CHECKMULTISIG + Bob paytx: OP_IF - OP_CLTV OP_DROP OP_CHECKSIG + OP_CLTV OP_DROP OP_CHECKSIG OP_ELSE OP_HASH160 OP_EQUALVERIFY OP_CHECKSIG OP_ENDIF From f4bc02561badd2b35f5eb5e9f6601a3623f8d3d3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 23 Feb 2018 19:43:14 +0200 Subject: [PATCH 147/197] Test --- iguana/exchanges/LP_remember.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index b2c64ce0f..0a6c2e69c 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -1207,6 +1207,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti redeemlen = basilisk_swap_bobredeemscript(0,&secretstart,redeemscript,rswap.plocktime,rswap.pubA0,rswap.pubB0,rswap.pubB1,rev,rswap.privBn,rswap.secretAm,rswap.secretAm256,rswap.secretBn,rswap.secretBn256); if ( rswap.Predeemlen != 0 && (rswap.Predeemlen != redeemlen || memcmp(redeemscript,rswap.Predeemscript,redeemlen) != 0) ) printf("Predeemscript error len %d vs %d\n",rswap.Predeemlen,redeemlen); + else printf("Predeemscript missing\n"); len = basilisk_swapuserdata(userdata,rev,0,rswap.myprivs[0],redeemscript,redeemlen); { char privaddr[64]; uint8_t privpub33[33]; @@ -1247,6 +1248,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti redeemlen = basilisk_swap_bobredeemscript(1,&secretstart,redeemscript,rswap.dlocktime,rswap.pubA0,rswap.pubB0,rswap.pubB1,rswap.privAm,zero,rswap.secretAm,rswap.secretAm256,rswap.secretBn,rswap.secretBn256); if ( rswap.Dredeemlen != 0 && (rswap.Dredeemlen != redeemlen || memcmp(redeemscript,rswap.Dredeemscript,redeemlen) != 0) ) printf("Dredeemscript error len %d vs %d\n",rswap.Dredeemlen,redeemlen); + else printf("Dredeemscript missing\n"); if ( redeemlen > 0 ) { memset(revAm.bytes,0,sizeof(revAm)); From 118e51208929196678bb726918dc447afc9c99c6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 23 Feb 2018 20:07:39 +0200 Subject: [PATCH 148/197] Test --- iguana/exchanges/LP_include.h | 2 +- iguana/exchanges/LP_remember.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index 48b2dc4ee..cd41b8caa 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -22,7 +22,7 @@ #define LP_INCLUDE_H #ifndef LP_TECHSUPPORT -#define LP_TECHSUPPORT 0 +#define LP_TECHSUPPORT 1 #endif #define LP_DONT_CMDCHANNEL diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 0a6c2e69c..0397bc33b 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -1028,7 +1028,7 @@ int32_t LP_spends_set(struct LP_swap_remember *rswap) cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requestid,uint32_t quoteid,int32_t forceflag,int32_t pendingonly) { static void *ctx; - struct LP_swap_remember rswap; int32_t i,j,flag,numspent,len,secretstart,redeemlen; char str[65],*srcAdest,*srcBdest,*destAdest,*destBdest,otheraddr[64],*fstr,fname[512],etomicsrc[128],etomicdest[128],bobtomic[128],alicetomic[128],bobstr[65],alicestr[65]; cJSON *item,*txoutobj,*retjson; bits256 rev,revAm,signedtxid,zero,deadtxid; uint32_t claimtime; struct iguana_info *bob=0,*alice=0; uint8_t redeemscript[1024],userdata[1024]; long fsize; + struct LP_swap_remember rswap; int32_t i,j,flag,numspent,len,secretstart,redeemlen; char str[65],*srcAdest,*srcBdest,*destAdest,*destBdest,otheraddr[64],*fstr,fname[512],bobtomic[128],alicetomic[128],bobstr[65],alicestr[65]; cJSON *item,*txoutobj,*retjson; bits256 rev,revAm,signedtxid,zero,deadtxid; uint32_t claimtime; struct iguana_info *bob=0,*alice=0; uint8_t redeemscript[1024],userdata[1024]; long fsize; sprintf(fname,"%s/SWAPS/%u-%u.finished",GLOBAL_DBDIR,requestid,quoteid), OS_compatible_path(fname); if ( (fstr= OS_filestr(&fsize,fname)) != 0 ) { From 1f45b45571b3b0441227bba214dd7138a0eb7eba Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 23 Feb 2018 20:16:51 +0200 Subject: [PATCH 149/197] Print --- iguana/exchanges/LP_remember.c | 1 + 1 file changed, 1 insertion(+) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 0397bc33b..35cb8bc62 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -894,6 +894,7 @@ int32_t LP_swap_load(struct LP_swap_remember *rswap,int32_t forceflag) { rswap->Predeemlen >>= 1; decode_hex(rswap->Predeemscript,rswap->Predeemlen,rstr); + printf("Predeemscript.(%s)\n",rstr); } else if ( strcmp(txnames[i],"bobdeposit") == 0 && (rstr= jstr(txobj,"redeem")) != 0 && (rswap->Dredeemlen= is_hexstr(rstr,0)) > 0 ) { From 8794a9a4077a6d180204aed427b31741d315b5cb Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 23 Feb 2018 20:20:05 +0200 Subject: [PATCH 150/197] Test --- iguana/exchanges/LP_remember.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 35cb8bc62..d927c02f1 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -894,7 +894,7 @@ int32_t LP_swap_load(struct LP_swap_remember *rswap,int32_t forceflag) { rswap->Predeemlen >>= 1; decode_hex(rswap->Predeemscript,rswap->Predeemlen,rstr); - printf("Predeemscript.(%s)\n",rstr); + printf("%p Predeemscript.(%s)\n",rswap->Predeemscript,rstr); } else if ( strcmp(txnames[i],"bobdeposit") == 0 && (rstr= jstr(txobj,"redeem")) != 0 && (rswap->Dredeemlen= is_hexstr(rstr,0)) > 0 ) { @@ -1208,7 +1208,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti redeemlen = basilisk_swap_bobredeemscript(0,&secretstart,redeemscript,rswap.plocktime,rswap.pubA0,rswap.pubB0,rswap.pubB1,rev,rswap.privBn,rswap.secretAm,rswap.secretAm256,rswap.secretBn,rswap.secretBn256); if ( rswap.Predeemlen != 0 && (rswap.Predeemlen != redeemlen || memcmp(redeemscript,rswap.Predeemscript,redeemlen) != 0) ) printf("Predeemscript error len %d vs %d\n",rswap.Predeemlen,redeemlen); - else printf("Predeemscript missing\n"); + else printf("%p Predeemscript missing\n",rswap.Predeemscript); len = basilisk_swapuserdata(userdata,rev,0,rswap.myprivs[0],redeemscript,redeemlen); { char privaddr[64]; uint8_t privpub33[33]; From e26a38ddfb8f3ca4363ca0bc0654903e8c883fa6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 23 Feb 2018 20:24:17 +0200 Subject: [PATCH 151/197] Test --- iguana/exchanges/LP_remember.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index d927c02f1..78cff68cc 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -1206,9 +1206,11 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti // redeemlen = rswap.Predeemlen, memcpy(redeemscript,rswap.Predeemscript,rswap.Predeemlen); //else redeemlen = basilisk_swap_bobredeemscript(0,&secretstart,redeemscript,rswap.plocktime,rswap.pubA0,rswap.pubB0,rswap.pubB1,rev,rswap.privBn,rswap.secretAm,rswap.secretAm256,rswap.secretBn,rswap.secretBn256); - if ( rswap.Predeemlen != 0 && (rswap.Predeemlen != redeemlen || memcmp(redeemscript,rswap.Predeemscript,redeemlen) != 0) ) - printf("Predeemscript error len %d vs %d\n",rswap.Predeemlen,redeemlen); - else printf("%p Predeemscript missing\n",rswap.Predeemscript); + if ( rswap.Predeemlen != 0 ) + { + if ( rswap.Predeemlen != redeemlen || memcmp(redeemscript,rswap.Predeemscript,redeemlen) != 0 ) + printf("Predeemscript error len %d vs %d, cmp.%d\n",rswap.Predeemlen,redeemlen,memcmp(redeemscript,rswap.Predeemscript,redeemlen)); + } else printf("%p Predeemscript missing\n",rswap.Predeemscript); len = basilisk_swapuserdata(userdata,rev,0,rswap.myprivs[0],redeemscript,redeemlen); { char privaddr[64]; uint8_t privpub33[33]; @@ -1247,9 +1249,11 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti // redeemlen = rswap.Dredeemlen, memcpy(redeemscript,rswap.Dredeemscript,rswap.Dredeemlen); //else redeemlen = basilisk_swap_bobredeemscript(1,&secretstart,redeemscript,rswap.dlocktime,rswap.pubA0,rswap.pubB0,rswap.pubB1,rswap.privAm,zero,rswap.secretAm,rswap.secretAm256,rswap.secretBn,rswap.secretBn256); - if ( rswap.Dredeemlen != 0 && (rswap.Dredeemlen != redeemlen || memcmp(redeemscript,rswap.Dredeemscript,redeemlen) != 0) ) - printf("Dredeemscript error len %d vs %d\n",rswap.Dredeemlen,redeemlen); - else printf("Dredeemscript missing\n"); + if ( rswap.Dredeemlen != 0 ) + { + if ( rswap.Dredeemlen != redeemlen || memcmp(redeemscript,rswap.Dredeemscript,redeemlen) != 0 ) + printf("Dredeemscript error len %d vs %d, cmp.%d\n",rswap.Dredeemlen,redeemlen,memcmp(redeemscript,rswap.Dredeemscript,redeemlen)); + } else printf("%p Dredeemscript missing\n",rswap.Dredeemscript); if ( redeemlen > 0 ) { memset(revAm.bytes,0,sizeof(revAm)); From 6fd28cf180cf49d38f46a0044aafea5104e97f4b Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 23 Feb 2018 20:32:52 +0200 Subject: [PATCH 152/197] Test --- iguana/exchanges/LP_remember.c | 12 +++++++++--- iguana/exchanges/LP_transaction.c | 22 +++++++++++----------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 78cff68cc..7a9806609 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -1210,19 +1210,25 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti { if ( rswap.Predeemlen != redeemlen || memcmp(redeemscript,rswap.Predeemscript,redeemlen) != 0 ) printf("Predeemscript error len %d vs %d, cmp.%d\n",rswap.Predeemlen,redeemlen,memcmp(redeemscript,rswap.Predeemscript,redeemlen)); + else printf("Predeem matches\n"); } else printf("%p Predeemscript missing\n",rswap.Predeemscript); len = basilisk_swapuserdata(userdata,rev,0,rswap.myprivs[0],redeemscript,redeemlen); { - char privaddr[64]; uint8_t privpub33[33]; + char privaddr[64]; uint8_t privpub33[33],secretAm[20]; + revcalc_rmd160_sha256(secretAm,rev); + for (j=0; j<20; j++) + printf("%02x",secretAm[j]); bitcoin_pubkey33(ctx,privpub33,rswap.myprivs[0]); bitcoin_address(rswap.bobcoin,privaddr,0,60,privpub33,33); - printf("alicespend len.%d redeemlen.%d priv0addr.(%s) priv0.(%s)\n",len,redeemlen,privaddr,bits256_str(str,rswap.myprivs[0])); + printf(" alicespend len.%d redeemlen.%d priv0addr.(%s) priv0.(%s)\n",len,redeemlen,privaddr,bits256_str(str,rswap.myprivs[0])); } for (j=0; j<32; j++) rev.bytes[j] = rswap.myprivs[0].bytes[31 - j]; if ( (rswap.txbytes[BASILISK_ALICESPEND]= basilisk_swap_bobtxspend(&signedtxid,rswap.Btxfee,"alicespend",rswap.bobcoin,bob->wiftaddr,bob->taddr,bob->pubtype,bob->p2shtype,bob->isPoS,bob->wiftype,ctx,rswap.myprivs[0],0,redeemscript,redeemlen,userdata,len,rswap.txids[BASILISK_BOBPAYMENT],0,0,rswap.pubkey33,1,rswap.expiration,&rswap.values[BASILISK_ALICESPEND],0,0,rswap.bobpaymentaddr,1,bob->zcash)) != 0 ) { - if (rswap.bobtomic[0] != 0) { + printf("alicespend.(%s)\n",rswap.txbytes[BASILISK_ALICESPEND]); + if ( rswap.bobtomic[0] != 0 ) + { char *aliceSpendEthTxId = LP_etomicalice_spends_bob_payment(&rswap); free(aliceSpendEthTxId); } diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index 010b08aaf..d3c0f9c58 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -1788,17 +1788,17 @@ int32_t basilisk_swap_bobredeemscript(int32_t depositflag,int32_t *secretstartp, uint8_t bufA[20],bufB[20]; revcalc_rmd160_sha256(bufA,privkey); calc_rmd160_sha256(bufB,privkey.bytes,sizeof(privkey)); - /*if ( memcmp(bufA,secret160,sizeof(bufA)) == 0 ) - printf("MATCHES BUFA\n"); - else if ( memcmp(bufB,secret160,sizeof(bufB)) == 0 ) - printf("MATCHES BUFB\n"); - else printf("secret160 matches neither\n"); - for (i=0; i<20; i++) - printf("%02x",bufA[i]); - printf(" <- revcalc\n"); - for (i=0; i<20; i++) - printf("%02x",bufB[i]); - printf(" <- calc\n");*/ + if ( memcmp(bufA,secret160,sizeof(bufA)) == 0 ) + printf("MATCHES BUFA\n"); + else if ( memcmp(bufB,secret160,sizeof(bufB)) == 0 ) + printf("MATCHES BUFB\n"); + else printf("secret160 matches neither\n"); + for (i=0; i<20; i++) + printf("%02x",bufA[i]); + printf(" <- revcalc\n"); + for (i=0; i<20; i++) + printf("%02x",bufB[i]); + printf(" <- calc\n"); memcpy(secret160,bufB,20); } n = bitcoin_secret160verify(redeemscript,n,secret160); From c8f658875b971a135c4de018942da2246849dffc Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 23 Feb 2018 21:06:06 +0200 Subject: [PATCH 153/197] Test --- iguana/exchanges/LP_bitcoin.c | 1 - iguana/exchanges/LP_remember.c | 18 +++++------------- iguana/exchanges/LP_transaction.c | 22 +++++++++++----------- 3 files changed, 16 insertions(+), 25 deletions(-) diff --git a/iguana/exchanges/LP_bitcoin.c b/iguana/exchanges/LP_bitcoin.c index 691ab3e19..666f96d3e 100644 --- a/iguana/exchanges/LP_bitcoin.c +++ b/iguana/exchanges/LP_bitcoin.c @@ -1913,7 +1913,6 @@ int32_t bitcoin_p2shspend(uint8_t *script,int32_t n,uint8_t rmd160[20]) int32_t bitcoin_secret160verify(uint8_t *script,int32_t n,uint8_t secret160[20]) { script[n++] = IGUANA_OP_SIZE; // add SIZE 32 EQUALVERIFY - script[n++] = IGUANA_OP_PUSHDATA1; script[n++] = 1; script[n++] = 32; script[n++] = SCRIPT_OP_EQUALVERIFY; diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 7a9806609..cf9044d22 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -1200,12 +1200,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti memset(rev.bytes,0,sizeof(rev)); for (j=0; j<32; j++) rev.bytes[j] = rswap.privAm.bytes[31 - j]; - //revcalc_rmd160_sha256(secretAm,rev);//privAm); - //vcalc_sha256(0,secretAm256,rev.bytes,sizeof(rev)); - //if ( rswap.Predeemlen != 0 ) - // redeemlen = rswap.Predeemlen, memcpy(redeemscript,rswap.Predeemscript,rswap.Predeemlen); - //else - redeemlen = basilisk_swap_bobredeemscript(0,&secretstart,redeemscript,rswap.plocktime,rswap.pubA0,rswap.pubB0,rswap.pubB1,rev,rswap.privBn,rswap.secretAm,rswap.secretAm256,rswap.secretBn,rswap.secretBn256); + redeemlen = basilisk_swap_bobredeemscript(0,&secretstart,redeemscript,rswap.plocktime,rswap.pubA0,rswap.pubB0,rswap.pubB1,rev,rswap.privBn,rswap.secretAm,rswap.secretAm256,rswap.secretBn,rswap.secretBn256); if ( rswap.Predeemlen != 0 ) { if ( rswap.Predeemlen != redeemlen || memcmp(redeemscript,rswap.Predeemscript,redeemlen) != 0 ) @@ -1213,17 +1208,14 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti else printf("Predeem matches\n"); } else printf("%p Predeemscript missing\n",rswap.Predeemscript); len = basilisk_swapuserdata(userdata,rev,0,rswap.myprivs[0],redeemscript,redeemlen); + if ( 0 ) { - char privaddr[64]; uint8_t privpub33[33],secretAm[20]; - revcalc_rmd160_sha256(secretAm,rev); + uint8_t secretAm[20]; + calc_rmd160_sha256(secretAm,rswap.privAm.bytes,sizeof(rswap.privAm)); for (j=0; j<20; j++) printf("%02x",secretAm[j]); - bitcoin_pubkey33(ctx,privpub33,rswap.myprivs[0]); - bitcoin_address(rswap.bobcoin,privaddr,0,60,privpub33,33); - printf(" alicespend len.%d redeemlen.%d priv0addr.(%s) priv0.(%s)\n",len,redeemlen,privaddr,bits256_str(str,rswap.myprivs[0])); + printf(" secretAm, privAm %s alicespend len.%d redeemlen.%d\n",bits256_str(str,rswap.privAm),len,redeemlen); } - for (j=0; j<32; j++) - rev.bytes[j] = rswap.myprivs[0].bytes[31 - j]; if ( (rswap.txbytes[BASILISK_ALICESPEND]= basilisk_swap_bobtxspend(&signedtxid,rswap.Btxfee,"alicespend",rswap.bobcoin,bob->wiftaddr,bob->taddr,bob->pubtype,bob->p2shtype,bob->isPoS,bob->wiftype,ctx,rswap.myprivs[0],0,redeemscript,redeemlen,userdata,len,rswap.txids[BASILISK_BOBPAYMENT],0,0,rswap.pubkey33,1,rswap.expiration,&rswap.values[BASILISK_ALICESPEND],0,0,rswap.bobpaymentaddr,1,bob->zcash)) != 0 ) { printf("alicespend.(%s)\n",rswap.txbytes[BASILISK_ALICESPEND]); diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index d3c0f9c58..010b08aaf 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -1788,17 +1788,17 @@ int32_t basilisk_swap_bobredeemscript(int32_t depositflag,int32_t *secretstartp, uint8_t bufA[20],bufB[20]; revcalc_rmd160_sha256(bufA,privkey); calc_rmd160_sha256(bufB,privkey.bytes,sizeof(privkey)); - if ( memcmp(bufA,secret160,sizeof(bufA)) == 0 ) - printf("MATCHES BUFA\n"); - else if ( memcmp(bufB,secret160,sizeof(bufB)) == 0 ) - printf("MATCHES BUFB\n"); - else printf("secret160 matches neither\n"); - for (i=0; i<20; i++) - printf("%02x",bufA[i]); - printf(" <- revcalc\n"); - for (i=0; i<20; i++) - printf("%02x",bufB[i]); - printf(" <- calc\n"); + /*if ( memcmp(bufA,secret160,sizeof(bufA)) == 0 ) + printf("MATCHES BUFA\n"); + else if ( memcmp(bufB,secret160,sizeof(bufB)) == 0 ) + printf("MATCHES BUFB\n"); + else printf("secret160 matches neither\n"); + for (i=0; i<20; i++) + printf("%02x",bufA[i]); + printf(" <- revcalc\n"); + for (i=0; i<20; i++) + printf("%02x",bufB[i]); + printf(" <- calc\n");*/ memcpy(secret160,bufB,20); } n = bitcoin_secret160verify(redeemscript,n,secret160); From 7e67f09ab24dc34238ad7b993ecbed747d2c663a Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 23 Feb 2018 21:46:01 +0200 Subject: [PATCH 154/197] -prints --- iguana/exchanges/LP_remember.c | 4 ++-- iguana/exchanges/LP_transaction.c | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index cf9044d22..e0e62fca4 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -894,7 +894,7 @@ int32_t LP_swap_load(struct LP_swap_remember *rswap,int32_t forceflag) { rswap->Predeemlen >>= 1; decode_hex(rswap->Predeemscript,rswap->Predeemlen,rstr); - printf("%p Predeemscript.(%s)\n",rswap->Predeemscript,rstr); + //printf("%p Predeemscript.(%s)\n",rswap->Predeemscript,rstr); } else if ( strcmp(txnames[i],"bobdeposit") == 0 && (rstr= jstr(txobj,"redeem")) != 0 && (rswap->Dredeemlen= is_hexstr(rstr,0)) > 0 ) { @@ -1205,7 +1205,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti { if ( rswap.Predeemlen != redeemlen || memcmp(redeemscript,rswap.Predeemscript,redeemlen) != 0 ) printf("Predeemscript error len %d vs %d, cmp.%d\n",rswap.Predeemlen,redeemlen,memcmp(redeemscript,rswap.Predeemscript,redeemlen)); - else printf("Predeem matches\n"); + //else printf("Predeem matches\n"); } else printf("%p Predeemscript missing\n",rswap.Predeemscript); len = basilisk_swapuserdata(userdata,rev,0,rswap.myprivs[0],redeemscript,redeemlen); if ( 0 ) diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index 010b08aaf..4a015c639 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -1774,9 +1774,9 @@ int32_t basilisk_swap_bobredeemscript(int32_t depositflag,int32_t *secretstartp, n = bitcoin_checklocktimeverify(redeemscript,n,locktime); if ( depositflag != 0 ) { - for (i=0; i<20; i++) - printf("%02x",secretAm[i]); - printf(" <- secretAm depositflag.%d nonz.%d\n",depositflag,bits256_nonz(privkey)); + //for (i=0; i<20; i++) + // printf("%02x",secretAm[i]); + //printf(" <- secretAm depositflag.%d nonz.%d\n",depositflag,bits256_nonz(privkey)); n = bitcoin_secret160verify(redeemscript,n,secretAm); } n = bitcoin_pubkeyspend(redeemscript,n,pubkeyA); @@ -1817,9 +1817,9 @@ int32_t basilisk_bobscript(uint8_t *rmd160,uint8_t *redeemscript,int32_t *redeem { calc_rmd160_sha256(rmd160,redeemscript,n); n = bitcoin_p2shspend(script,0,rmd160); - int32_t i; for (i=0; i<*redeemlenp; i++) - printf("%02x",redeemscript[i]); - printf(" <- redeem.%d bobtx dflag.%d spendscript.[%d]\n",*redeemlenp,depositflag,n); + //int32_t i; for (i=0; i<*redeemlenp; i++) + // printf("%02x",redeemscript[i]); + //printf(" <- redeem.%d bobtx dflag.%d spendscript.[%d]\n",*redeemlenp,depositflag,n); } return(n); } From 25d4f6f1c6055a19ca96a6c51b7998638151cca0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 23 Feb 2018 22:02:17 +0200 Subject: [PATCH 155/197] Remove print --- iguana/exchanges/LP_remember.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index e0e62fca4..78886729d 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -1218,7 +1218,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti } if ( (rswap.txbytes[BASILISK_ALICESPEND]= basilisk_swap_bobtxspend(&signedtxid,rswap.Btxfee,"alicespend",rswap.bobcoin,bob->wiftaddr,bob->taddr,bob->pubtype,bob->p2shtype,bob->isPoS,bob->wiftype,ctx,rswap.myprivs[0],0,redeemscript,redeemlen,userdata,len,rswap.txids[BASILISK_BOBPAYMENT],0,0,rswap.pubkey33,1,rswap.expiration,&rswap.values[BASILISK_ALICESPEND],0,0,rswap.bobpaymentaddr,1,bob->zcash)) != 0 ) { - printf("alicespend.(%s)\n",rswap.txbytes[BASILISK_ALICESPEND]); + //printf("alicespend.(%s)\n",rswap.txbytes[BASILISK_ALICESPEND]); if ( rswap.bobtomic[0] != 0 ) { char *aliceSpendEthTxId = LP_etomicalice_spends_bob_payment(&rswap); @@ -1268,7 +1268,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti } LP_txbytes_update("aliceclaim",rswap.bobcoin,rswap.txbytes[BASILISK_ALICECLAIM],&rswap.txids[BASILISK_ALICECLAIM],&rswap.depositspent,&rswap.sentflags[BASILISK_ALICECLAIM]); } - } else printf("now %u before expiration %u\n",(uint32_t)time(NULL),rswap.expiration); + } // else printf("now %u before expiration %u\n",(uint32_t)time(NULL),rswap.expiration); } if ( (rswap.sentflags[BASILISK_ALICEPAYMENT] != 0 || bits256_nonz(rswap.txids[BASILISK_ALICEPAYMENT]) != 0)&& bits256_nonz(rswap.Apaymentspent) == 0 && rswap.sentflags[BASILISK_ALICERECLAIM] == 0 ) { From 0a1e9945c28348856cefe43c3d71780af5ad4729 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 23 Feb 2018 22:05:30 +0200 Subject: [PATCH 156/197] -print --- iguana/exchanges/LP_remember.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 78886729d..b6edfef95 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -932,7 +932,7 @@ int32_t LP_swap_load(struct LP_swap_remember *rswap,int32_t forceflag) { if ( (sentobj= LP_gettx(symbol,txid,1)) == 0 ) { - char str2[65]; printf("%s %s ready to broadcast %s r%u q%u\n",symbol,bits256_str(str2,txid),txnames[i],rswap->requestid,rswap->quoteid); + //char str2[65]; printf("%s %s ready to broadcast %s r%u q%u\n",symbol,bits256_str(str2,txid),txnames[i],rswap->requestid,rswap->quoteid); } else { From 5635ff299b3ffe3830590c5ee91d4050c3521dec Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 23 Feb 2018 22:16:15 +0200 Subject: [PATCH 157/197] Srccoin --- iguana/dPoW.h | 2 +- iguana/dpow/dpow_fsm.c | 8 ++++---- iguana/dpow/dpow_network.c | 8 ++++---- iguana/dpow/dpow_rpc.c | 4 ++-- iguana/iguana_notary.c | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/iguana/dPoW.h b/iguana/dPoW.h index ba9e5c00e..9c2f22208 100755 --- a/iguana/dPoW.h +++ b/iguana/dPoW.h @@ -149,7 +149,7 @@ char *basilisk_respond_addmessage(struct supernet_info *myinfo,uint8_t *key,int3 int32_t dpow_getchaintip(struct supernet_info *myinfo,bits256 *blockhashp,uint32_t *blocktimep,bits256 *txs,uint32_t *numtxp,struct iguana_info *coin); void dpow_send(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_block *bp,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgbits,uint8_t *data,int32_t datalen); int32_t dpow_nanomsg_update(struct supernet_info *myinfo); -int32_t dpow_haveutxo(struct supernet_info *myinfo,struct iguana_info *coin,bits256 *txidp,int32_t *voutp,char *coinaddr); +int32_t dpow_haveutxo(struct supernet_info *myinfo,struct iguana_info *coin,bits256 *txidp,int32_t *voutp,char *coinaddr,char *srccoin); void komodo_assetcoins(int32_t fullnode,uint64_t mask); int32_t iguana_isnotarychain(char *symbol); diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index 7933c35c2..45509ef8f 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -121,7 +121,7 @@ int32_t dpow_datahandler(struct supernet_info *myinfo,struct dpow_info *dp,struc return(0); } -int32_t dpow_checkutxo(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_block *bp,struct iguana_info *coin,bits256 *txidp,int32_t *voutp,char *coinaddr) +int32_t dpow_checkutxo(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_block *bp,struct iguana_info *coin,bits256 *txidp,int32_t *voutp,char *coinaddr,char *srccoin) { int32_t haveutxo,completed,minutxo,n; bits256 signedtxid; cJSON *addresses; char *rawtx,*sendtx; if ( strcmp("BTC",coin->symbol) == 0 ) @@ -134,7 +134,7 @@ int32_t dpow_checkutxo(struct supernet_info *myinfo,struct dpow_info *dp,struct minutxo = 49; n = 10; } - if ( (haveutxo= dpow_haveutxo(myinfo,coin,txidp,voutp,coinaddr)) <= minutxo && time(NULL) > dp->lastsplit+bp->duration && (bp->myind != 0 || dp->ratifying == 0) ) + if ( (haveutxo= dpow_haveutxo(myinfo,coin,txidp,voutp,coinaddr,srccoin)) <= minutxo && time(NULL) > dp->lastsplit+bp->duration && (bp->myind != 0 || dp->ratifying == 0) ) { addresses = cJSON_CreateArray(); jaddistr(addresses,coinaddr); @@ -350,14 +350,14 @@ void dpow_statemachinestart(void *ptr) } else { - if ( dpow_checkutxo(myinfo,dp,bp,bp->destcoin,&ep->dest.prev_hash,&ep->dest.prev_vout,destaddr) < 0 ) + if ( dpow_checkutxo(myinfo,dp,bp,bp->destcoin,&ep->dest.prev_hash,&ep->dest.prev_vout,destaddr,src->symbol) < 0 ) { printf("dont have %s %s utxo, please send funds\n",dp->dest,destaddr); dp->ratifying -= bp->isratify; free(ptr); return; } - if ( dpow_checkutxo(myinfo,dp,bp,bp->srccoin,&ep->src.prev_hash,&ep->src.prev_vout,srcaddr) < 0 ) + if ( dpow_checkutxo(myinfo,dp,bp,bp->srccoin,&ep->src.prev_hash,&ep->src.prev_vout,srcaddr,"") < 0 ) { printf("dont have %s %s utxo, please send funds\n",dp->symbol,srcaddr); dp->ratifying -= bp->isratify; diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index 0f6fb2c6a..ab7bcddf1 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -1529,7 +1529,7 @@ void dpow_nanoutxoset(struct supernet_info *myinfo,struct dpow_info *dp,struct d if ( err != 0 ) { bitcoin_address(coinaddr,bp->srccoin->chain->pubtype,dp->minerkey33,33); - if ( dpow_haveutxo(myinfo,bp->srccoin,&bp->notaries[bp->myind].ratifysrcutxo,&vout,coinaddr) > 0 ) + if ( dpow_haveutxo(myinfo,bp->srccoin,&bp->notaries[bp->myind].ratifysrcutxo,&vout,coinaddr,"") > 0 ) { bp->notaries[bp->myind].ratifysrcvout = vout; np->srcutxo = bp->notaries[bp->myind].ratifysrcutxo; @@ -1547,7 +1547,7 @@ void dpow_nanoutxoset(struct supernet_info *myinfo,struct dpow_info *dp,struct d if ( err != 0 ) { bitcoin_address(coinaddr,bp->destcoin->chain->pubtype,dp->minerkey33,33); - if ( dpow_haveutxo(myinfo,bp->destcoin,&bp->notaries[bp->myind].ratifydestutxo,&vout,coinaddr) > 0 ) + if ( dpow_haveutxo(myinfo,bp->destcoin,&bp->notaries[bp->myind].ratifydestutxo,&vout,coinaddr,bp->srccoin) > 0 ) { bp->notaries[bp->myind].ratifydestvout = vout; np->destutxo = bp->notaries[bp->myind].ratifydestutxo; @@ -1733,11 +1733,11 @@ void dpow_ratify_update(struct supernet_info *myinfo,struct dpow_info *dp,struct { bitcoin_address(srcaddr,bp->srccoin->chain->pubtype,dp->minerkey33,33); bitcoin_address(destaddr,bp->destcoin->chain->pubtype,dp->minerkey33,33); - if ( dpow_checkutxo(myinfo,dp,bp,bp->destcoin,&bp->notaries[i].dest.prev_hash,&bp->notaries[i].dest.prev_vout,destaddr) < 0 ) + if ( dpow_checkutxo(myinfo,dp,bp,bp->destcoin,&bp->notaries[i].dest.prev_hash,&bp->notaries[i].dest.prev_vout,destaddr,bp->srccoin) < 0 ) { printf("dont have %s %s utxo, please send funds\n",dp->dest,destaddr); } - if ( dpow_checkutxo(myinfo,dp,bp,bp->srccoin,&bp->notaries[i].src.prev_hash,&bp->notaries[i].src.prev_vout,srcaddr) < 0 ) + if ( dpow_checkutxo(myinfo,dp,bp,bp->srccoin,&bp->notaries[i].src.prev_hash,&bp->notaries[i].src.prev_vout,srcaddr,"") < 0 ) { printf("dont have %s %s utxo, please send funds\n",dp->symbol,srcaddr); } diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index ec271e5a8..f3e729a89 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -770,7 +770,7 @@ int32_t dpow_vini_ismine(struct supernet_info *myinfo,struct dpow_info *dp,cJSON return(-1); } -int32_t dpow_haveutxo(struct supernet_info *myinfo,struct iguana_info *coin,bits256 *txidp,int32_t *voutp,char *coinaddr) +int32_t dpow_haveutxo(struct supernet_info *myinfo,struct iguana_info *coin,bits256 *txidp,int32_t *voutp,char *coinaddr,char *srccoin) { int32_t vout,haveutxo = 0; uint32_t i,j,n,r; bits256 txid; cJSON *unspents,*item; uint64_t satoshis; char *str,*address; uint8_t script[35]; memset(txidp,0,sizeof(*txidp)); @@ -820,7 +820,7 @@ int32_t dpow_haveutxo(struct supernet_info *myinfo,struct iguana_info *coin,bits } } if ( haveutxo == 0 ) - printf("no %s utxo: need to fund address.(%s) or wait for splitfund to confirm\n",coin->symbol,coinaddr); + printf("no (%s -> %s) utxo: need to fund address.(%s) or wait for splitfund to confirm\n",srccoin,coin->symbol,coinaddr); } //else printf("null utxo array size\n"); free_json(unspents); } else printf("null return from dpow_listunspent\n"); diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index cac141dd2..e14d5721d 100755 --- a/iguana/iguana_notary.c +++ b/iguana/iguana_notary.c @@ -24,7 +24,7 @@ int32_t dpow_datahandler(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_block *bp,uint8_t nn_senderind,uint32_t channel,uint32_t height,uint8_t *data,int32_t datalen); uint64_t dpow_maskmin(uint64_t refmask,struct dpow_block *bp,int8_t *lastkp); -int32_t dpow_checkutxo(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_block *bp,struct iguana_info *coin,bits256 *txidp,int32_t *voutp,char *coinaddr); +int32_t dpow_checkutxo(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_block *bp,struct iguana_info *coin,bits256 *txidp,int32_t *voutp,char *coinaddr,char *srccoin); #include "dpow/dpow_network.c" #include "dpow/dpow_rpc.c" From 678ba92178105e9828e8499bafdd54a873a22df4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 23 Feb 2018 22:36:35 +0200 Subject: [PATCH 158/197] Auto clear price for Alice after trade starts --- iguana/exchanges/LP_ordermatch.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index bf5b97699..50e80acb4 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -1006,7 +1006,7 @@ struct LP_quoteinfo *LP_trades_gotconnect(void *ctx,struct LP_quoteinfo *qp,stru struct LP_quoteinfo *LP_trades_gotconnected(void *ctx,struct LP_quoteinfo *qp,struct LP_quoteinfo *newqp,char *pairstr) { - char *retstr; + char *retstr; int32_t changed; char str[65]; printf("alice %s received CONNECTED.(%llu)\n",bits256_str(str,G.LP_mypub25519),(long long)qp->aliceid); *newqp = *qp; qp = newqp; @@ -1016,6 +1016,7 @@ struct LP_quoteinfo *LP_trades_gotconnected(void *ctx,struct LP_quoteinfo *qp,st LP_aliceid(qp->tradeid,qp->aliceid,"connected",0,0); if ( (retstr= LP_connectedalice(qp,pairstr)) != 0 ) free(retstr); + LP_mypriceset(&changed,qp->destcoin,qp->srccoin,0.); return(qp); } //printf("LP_trades_alicevalidate error\n"); From a3cc81c7bdb7c643471d06aa7f9bed071e55c4c5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 23 Feb 2018 22:37:58 +0200 Subject: [PATCH 159/197] -prints --- 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 50e80acb4..f0f58ad39 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -306,7 +306,7 @@ int32_t LP_nearest_utxovalue(struct iguana_info *coin,char *coinaddr,struct LP_a } if ( replacei >= 0 ) { - printf("REPLACE bestdist %.8f height %d with dist %.8f height %d\n",dstr(bestdist),bestup->U.height,dstr(utxos[replacei]->U.value - targetval),utxos[replacei]->U.height); + //printf("REPLACE bestdist %.8f height %d with dist %.8f height %d\n",dstr(bestdist),bestup->U.height,dstr(utxos[replacei]->U.value - targetval),utxos[replacei]->U.height); return(replacei); } } @@ -423,7 +423,7 @@ struct LP_utxoinfo *LP_address_myutxopair(struct LP_utxoinfo *butxo,int32_t iamb { up = utxos[mini]; utxos[mini] = 0; - printf("found mini.%d %.8f for targetval %.8f -> targetval2 %.8f, ratio %.2f\n",mini,dstr(up->U.value),dstr(targetval),dstr(targetval2),(double)up->U.value/targetval); + //printf("found mini.%d %.8f for targetval %.8f -> targetval2 %.8f, ratio %.2f\n",mini,dstr(up->U.value),dstr(targetval),dstr(targetval2),(double)up->U.value/targetval); if ( (double)up->U.value/targetval < ratio-1 ) { From 680bbc15c7fd3b928183cd06fd720e35b83578b2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 23 Feb 2018 22:46:10 +0200 Subject: [PATCH 160/197] Allow Alice to trade after swap starts --- iguana/exchanges/LP_ordermatch.c | 1 + 1 file changed, 1 insertion(+) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index f0f58ad39..6bfe5ea2b 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -1017,6 +1017,7 @@ struct LP_quoteinfo *LP_trades_gotconnected(void *ctx,struct LP_quoteinfo *qp,st if ( (retstr= LP_connectedalice(qp,pairstr)) != 0 ) free(retstr); LP_mypriceset(&changed,qp->destcoin,qp->srccoin,0.); + LP_alicequery_clear(); return(qp); } //printf("LP_trades_alicevalidate error\n"); From 906f745e47fd1dcd107c72979f411967bc507bec Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 24 Feb 2018 13:38:52 +0200 Subject: [PATCH 161/197] Test --- iguana/exchanges/LP_remember.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index b6edfef95..1511b2cbf 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -1243,15 +1243,15 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti } if ( flag == 0 ) { - //if ( rswap.Dredeemlen != 0 ) - // redeemlen = rswap.Dredeemlen, memcpy(redeemscript,rswap.Dredeemscript,rswap.Dredeemlen); - //else - redeemlen = basilisk_swap_bobredeemscript(1,&secretstart,redeemscript,rswap.dlocktime,rswap.pubA0,rswap.pubB0,rswap.pubB1,rswap.privAm,zero,rswap.secretAm,rswap.secretAm256,rswap.secretBn,rswap.secretBn256); if ( rswap.Dredeemlen != 0 ) + redeemlen = rswap.Dredeemlen, memcpy(redeemscript,rswap.Dredeemscript,rswap.Dredeemlen); + else + redeemlen = basilisk_swap_bobredeemscript(1,&secretstart,redeemscript,rswap.dlocktime,rswap.pubA0,rswap.pubB0,rswap.pubB1,rswap.privAm,zero,rswap.secretAm,rswap.secretAm256,rswap.secretBn,rswap.secretBn256); + /*if ( rswap.Dredeemlen != 0 ) { if ( rswap.Dredeemlen != redeemlen || memcmp(redeemscript,rswap.Dredeemscript,redeemlen) != 0 ) printf("Dredeemscript error len %d vs %d, cmp.%d\n",rswap.Dredeemlen,redeemlen,memcmp(redeemscript,rswap.Dredeemscript,redeemlen)); - } else printf("%p Dredeemscript missing\n",rswap.Dredeemscript); + } else printf("%p Dredeemscript missing\n",rswap.Dredeemscript);*/ if ( redeemlen > 0 ) { memset(revAm.bytes,0,sizeof(revAm)); From 05507b4c59e2dfd05e50391b0e743f4717eaca9f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 24 Feb 2018 14:47:16 +0200 Subject: [PATCH 162/197] Test --- iguana/exchanges/LP_remember.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 1511b2cbf..ae106aaa3 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -1232,7 +1232,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti } if ( rswap.sentflags[BASILISK_ALICECLAIM] == 0 && (rswap.sentflags[BASILISK_BOBDEPOSIT] != 0 || bits256_nonz(rswap.txids[BASILISK_BOBDEPOSIT]) != 0) && bits256_nonz(rswap.depositspent) == 0 ) { - if ( time(NULL) > rswap.expiration+777 ) + if ( time(NULL) > rswap.dlocktime+777 ) { flag = 0; if ( bob->electrum == 0 ) @@ -1254,11 +1254,12 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti } else printf("%p Dredeemscript missing\n",rswap.Dredeemscript);*/ if ( redeemlen > 0 ) { - memset(revAm.bytes,0,sizeof(revAm)); - for (i=0; i<32; i++) - revAm.bytes[i] = rswap.privAm.bytes[31-i]; - len = basilisk_swapuserdata(userdata,revAm,1,rswap.myprivs[0],redeemscript,redeemlen); - if ( (rswap.txbytes[BASILISK_ALICECLAIM]= basilisk_swap_bobtxspend(&signedtxid,rswap.Btxfee,"aliceclaim",rswap.bobcoin,bob->wiftaddr,bob->taddr,bob->pubtype,bob->p2shtype,bob->isPoS,bob->wiftype,ctx,rswap.myprivs[0],0,redeemscript,redeemlen,userdata,len,rswap.txids[BASILISK_BOBDEPOSIT],0,0,rswap.pubkey33,0,claimtime,&rswap.values[BASILISK_ALICECLAIM],0,0,rswap.bobdepositaddr,1,bob->zcash)) != 0 ) { + //memset(revAm.bytes,0,sizeof(revAm)); + //for (i=0; i<32; i++) + // revAm.bytes[i] = rswap.privAm.bytes[31-i]; + len = basilisk_swapuserdata(userdata,rswap.privAm,1,rswap.myprivs[0],redeemscript,redeemlen); + if ( (rswap.txbytes[BASILISK_ALICECLAIM]= basilisk_swap_bobtxspend(&signedtxid,rswap.Btxfee,"aliceclaim",rswap.bobcoin,bob->wiftaddr,bob->taddr,bob->pubtype,bob->p2shtype,bob->isPoS,bob->wiftype,ctx,rswap.myprivs[0],0,redeemscript,redeemlen,userdata,len,rswap.txids[BASILISK_BOBDEPOSIT],0,0,rswap.pubkey33,0,claimtime,&rswap.values[BASILISK_ALICECLAIM],0,0,rswap.bobdepositaddr,1,bob->zcash)) != 0 ) + { printf("claimtime.%u aliceclaim.(%s)\n", claimtime, rswap.txbytes[BASILISK_ALICECLAIM]); if (rswap.bobtomic[0] != 0) { char *aliceClaimsEthTxId = LP_etomicalice_claims_bob_deposit(&rswap); From cac6ae60c0f1d0c726f0927b217bd143054b6363 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 24 Feb 2018 15:03:59 +0200 Subject: [PATCH 163/197] Test --- iguana/exchanges/LP_remember.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index ae106aaa3..4a5fc0fe2 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -1254,14 +1254,15 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti } else printf("%p Dredeemscript missing\n",rswap.Dredeemscript);*/ if ( redeemlen > 0 ) { - //memset(revAm.bytes,0,sizeof(revAm)); - //for (i=0; i<32; i++) - // revAm.bytes[i] = rswap.privAm.bytes[31-i]; - len = basilisk_swapuserdata(userdata,rswap.privAm,1,rswap.myprivs[0],redeemscript,redeemlen); - if ( (rswap.txbytes[BASILISK_ALICECLAIM]= basilisk_swap_bobtxspend(&signedtxid,rswap.Btxfee,"aliceclaim",rswap.bobcoin,bob->wiftaddr,bob->taddr,bob->pubtype,bob->p2shtype,bob->isPoS,bob->wiftype,ctx,rswap.myprivs[0],0,redeemscript,redeemlen,userdata,len,rswap.txids[BASILISK_BOBDEPOSIT],0,0,rswap.pubkey33,0,claimtime,&rswap.values[BASILISK_ALICECLAIM],0,0,rswap.bobdepositaddr,1,bob->zcash)) != 0 ) + memset(revAm.bytes,0,sizeof(revAm)); + for (i=0; i<32; i++) + revAm.bytes[i] = rswap.privAm.bytes[31-i]; + len = basilisk_swapuserdata(userdata,revAm,1,rswap.myprivs[0],redeemscript,redeemlen); + if ( (rswap.txbytes[BASILISK_ALICECLAIM]= basilisk_swap_bobtxspend(&signedtxid,rswap.Btxfee,"aliceclaim",rswap.bobcoin,bob->wiftaddr,bob->taddr,bob->pubtype,bob->p2shtype,bob->isPoS,bob->wiftype,ctx,rswap.myprivs[0],0,redeemscript,redeemlen,userdata,len,rswap.txids[BASILISK_BOBDEPOSIT],0,0,rswap.pubkey33,0,rswap.dlocktime+777,&rswap.values[BASILISK_ALICECLAIM],0,0,rswap.bobdepositaddr,1,bob->zcash)) != 0 ) { - printf("claimtime.%u aliceclaim.(%s)\n", claimtime, rswap.txbytes[BASILISK_ALICECLAIM]); - if (rswap.bobtomic[0] != 0) { + printf("dlocktime.%u claimtime.%u aliceclaim.(%s)\n",rswap.dlocktime,claimtime,rswap.txbytes[BASILISK_ALICECLAIM]); + if ( rswap.bobtomic[0] != 0 ) + { char *aliceClaimsEthTxId = LP_etomicalice_claims_bob_deposit(&rswap); free(aliceClaimsEthTxId); } From d4f5346ae18a4e65451c33d7473dd9144e9c4ef6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 24 Feb 2018 15:18:52 +0200 Subject: [PATCH 164/197] Test --- iguana/exchanges/LP_remember.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 4a5fc0fe2..40fc10653 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -1318,7 +1318,11 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti if ( bits256_nonz(rswap.privAm) == 0 ) { rswap.privAm = basilisk_swap_privbob_extract(rswap.bobcoin,rswap.paymentspent,0,1); - //printf("try to bobspend aspend.%s have privAm.%d\n",bits256_str(str,rswap.paymentspent),bits256_nonz(rswap.privAm)); + if ( bits256_nonz(rswap.privAm) == 0 && bits256_nonz(rswap.depositspent) != 0 ) + { + rswap.privAm = basilisk_swap_privbob_extract(rswap.bobcoin,rswap.depositspent,0,1); + printf("try to bobspend aspend.%s have privAm.%d\n",bits256_str(str,rswap.depositspent),bits256_nonz(rswap.privAm)); + } } if ( bits256_nonz(rswap.privAm) != 0 && bits256_nonz(rswap.privBn) != 0 ) { @@ -1351,7 +1355,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti if ( redeemlen > 0 ) { len = basilisk_swapuserdata(userdata,zero,1,rswap.myprivs[1],redeemscript,redeemlen); - if ( (rswap.txbytes[BASILISK_BOBRECLAIM]= basilisk_swap_bobtxspend(&signedtxid,rswap.Btxfee,"bobreclaim",rswap.bobcoin,bob->wiftaddr,bob->taddr,bob->pubtype,bob->p2shtype,bob->isPoS,bob->wiftype,ctx,rswap.myprivs[1],0,redeemscript,redeemlen,userdata,len,rswap.txids[BASILISK_BOBPAYMENT],0,0,rswap.pubkey33,0,claimtime,&rswap.values[BASILISK_BOBRECLAIM],0,0,rswap.bobpaymentaddr,1,bob->zcash)) != 0 ) + if ( (rswap.txbytes[BASILISK_BOBRECLAIM]= basilisk_swap_bobtxspend(&signedtxid,rswap.Btxfee,"bobreclaim",rswap.bobcoin,bob->wiftaddr,bob->taddr,bob->pubtype,bob->p2shtype,bob->isPoS,bob->wiftype,ctx,rswap.myprivs[1],0,redeemscript,redeemlen,userdata,len,rswap.txids[BASILISK_BOBPAYMENT],0,0,rswap.pubkey33,0,rswap.plocktime+777,&rswap.values[BASILISK_BOBRECLAIM],0,0,rswap.bobpaymentaddr,1,bob->zcash)) != 0 ) { if (rswap.bobtomic[0] != 0) { char *bobReclaimEthTx = LP_etomicbob_reclaims_payment(&rswap); From 706520cc0a0df7cea149bb97a3aafc621d4134bf Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 24 Feb 2018 15:43:27 +0200 Subject: [PATCH 165/197] Test --- iguana/exchanges/LP_remember.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 40fc10653..520b34b07 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -1302,7 +1302,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti { if ( rswap.sentflags[BASILISK_BOBSPEND] == 0 && bits256_nonz(rswap.Apaymentspent) == 0 ) { - //printf("try to bobspend aspend.%s have privAm.%d aspent.%d\n",bits256_str(str,rswap.txids[BASILISK_ALICESPEND]),bits256_nonz(rswap.privAm),rswap.sentflags[BASILISK_ALICESPEND]); + printf("try to bobspend aspend.%s have privAm.%d aspent.%d\n",bits256_str(str,rswap.txids[BASILISK_ALICESPEND]),bits256_nonz(rswap.privAm),rswap.sentflags[BASILISK_ALICESPEND]); if ( rswap.sentflags[BASILISK_ALICESPEND] != 0 || bits256_nonz(rswap.paymentspent) != 0 || bits256_nonz(rswap.privAm) != 0 ) { flag = 0; @@ -1312,7 +1312,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti free_json(txoutobj), flag = 0; else flag = -1, rswap.Apaymentspent = deadtxid; } - //printf("flag.%d apayment.%s\n",flag,bits256_str(str,rswap.paymentspent)); + printf("flag.%d apayment.%s\n",flag,bits256_str(str,rswap.paymentspent)); if ( flag == 0 ) { if ( bits256_nonz(rswap.privAm) == 0 ) @@ -1320,7 +1320,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti rswap.privAm = basilisk_swap_privbob_extract(rswap.bobcoin,rswap.paymentspent,0,1); if ( bits256_nonz(rswap.privAm) == 0 && bits256_nonz(rswap.depositspent) != 0 ) { - rswap.privAm = basilisk_swap_privbob_extract(rswap.bobcoin,rswap.depositspent,0,1); + rswap.privAm = basilisk_swap_privbob_extract(rswap.alicecoin,rswap.depositspent,0,1); printf("try to bobspend aspend.%s have privAm.%d\n",bits256_str(str,rswap.depositspent),bits256_nonz(rswap.privAm)); } } From 8ebdf7e90ff19050f4d915d85d4d8f0514726934 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 24 Feb 2018 15:46:17 +0200 Subject: [PATCH 166/197] Test --- iguana/exchanges/LP_remember.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 520b34b07..dbbf7661f 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -1303,7 +1303,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti if ( rswap.sentflags[BASILISK_BOBSPEND] == 0 && bits256_nonz(rswap.Apaymentspent) == 0 ) { printf("try to bobspend aspend.%s have privAm.%d aspent.%d\n",bits256_str(str,rswap.txids[BASILISK_ALICESPEND]),bits256_nonz(rswap.privAm),rswap.sentflags[BASILISK_ALICESPEND]); - if ( rswap.sentflags[BASILISK_ALICESPEND] != 0 || bits256_nonz(rswap.paymentspent) != 0 || bits256_nonz(rswap.privAm) != 0 ) + if ( rswap.sentflags[BASILISK_ALICESPEND] != 0 || bits256_nonz(rswap.paymentspent) != 0 || bits256_nonz(rswap.privAm) != 0 || bits256_nonz(rswap.depositspent) != 0 ) { flag = 0; if ( alice->electrum == 0 ) From 934c376d7b305af3bb9490d780e9ad858e1b6897 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 24 Feb 2018 15:51:14 +0200 Subject: [PATCH 167/197] Test --- iguana/exchanges/LP_remember.c | 6 +++--- iguana/exchanges/LP_transaction.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index dbbf7661f..1579bd565 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -250,7 +250,7 @@ bits256 basilisk_swap_privbob_extract(char *symbol,bits256 spendtxid,int32_t vin privkey.bytes[31 - i] = script[siglen+2+i]; else privkey.bytes[i] = script[siglen+2+i]; } - //char str[65]; printf("extracted privbob.(%s)\n",bits256_str(str,privkey)); + char str[65]; printf("extracted privbob.(%s)\n",bits256_str(str,privkey)); } return(privkey); } @@ -1302,7 +1302,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti { if ( rswap.sentflags[BASILISK_BOBSPEND] == 0 && bits256_nonz(rswap.Apaymentspent) == 0 ) { - printf("try to bobspend aspend.%s have privAm.%d aspent.%d\n",bits256_str(str,rswap.txids[BASILISK_ALICESPEND]),bits256_nonz(rswap.privAm),rswap.sentflags[BASILISK_ALICESPEND]); + //printf("try to bobspend aspend.%s have privAm.%d aspent.%d\n",bits256_str(str,rswap.txids[BASILISK_ALICESPEND]),bits256_nonz(rswap.privAm),rswap.sentflags[BASILISK_ALICESPEND]); if ( rswap.sentflags[BASILISK_ALICESPEND] != 0 || bits256_nonz(rswap.paymentspent) != 0 || bits256_nonz(rswap.privAm) != 0 || bits256_nonz(rswap.depositspent) != 0 ) { flag = 0; @@ -1312,7 +1312,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti free_json(txoutobj), flag = 0; else flag = -1, rswap.Apaymentspent = deadtxid; } - printf("flag.%d apayment.%s\n",flag,bits256_str(str,rswap.paymentspent)); + //printf("flag.%d apayment.%s\n",flag,bits256_str(str,rswap.paymentspent)); if ( flag == 0 ) { if ( bits256_nonz(rswap.privAm) == 0 ) diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index 4a015c639..05d3e9a91 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -1624,7 +1624,7 @@ int32_t basilisk_swap_getsigscript(char *symbol,uint8_t *script,int32_t maxlen,b { scriptlen >>= 1; decode_hex(script,scriptlen,hexstr); - //char str[65]; printf("%s/v%d sigscript.(%s)\n",bits256_str(str,txid),vini,hexstr); + char str[65]; printf("%s %s/v%d sigscript.(%s)\n",symbol,bits256_str(str,txid),vini,hexstr); } } free_json(retjson); From 4d08ba5191a33f3d38a8df90923b5e02f3201007 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 24 Feb 2018 15:54:40 +0200 Subject: [PATCH 168/197] Test --- iguana/exchanges/LP_transaction.c | 1 + 1 file changed, 1 insertion(+) diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index 05d3e9a91..0d2bef45a 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -1615,6 +1615,7 @@ int32_t LP_swap_getcoinaddr(char *symbol,char *coinaddr,bits256 txid,int32_t vou int32_t basilisk_swap_getsigscript(char *symbol,uint8_t *script,int32_t maxlen,bits256 txid,int32_t vini) { cJSON *retjson,*vins,*item,*skey; int32_t n,scriptlen = 0; char *hexstr; + char str[65]; printf("getsigscript %s %s/v%d\n",symbol,bits256_str(str,txid),vini); if ( (retjson= LP_gettx(symbol,txid,0)) != 0 ) { if ( (vins= jarray(&n,retjson,"vin")) != 0 && vini < n ) From b3b37bbb241549236ca1dc542d5abc7bd6072080 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 24 Feb 2018 15:56:54 +0200 Subject: [PATCH 169/197] Test --- iguana/exchanges/LP_transaction.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index 0d2bef45a..8f0712e68 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -1616,8 +1616,9 @@ int32_t basilisk_swap_getsigscript(char *symbol,uint8_t *script,int32_t maxlen,b { cJSON *retjson,*vins,*item,*skey; int32_t n,scriptlen = 0; char *hexstr; char str[65]; printf("getsigscript %s %s/v%d\n",symbol,bits256_str(str,txid),vini); - if ( (retjson= LP_gettx(symbol,txid,0)) != 0 ) + if ( bits256_nonz(txid) != 0 && (retjson= LP_gettx(symbol,txid,0)) != 0 ) { + printf("gettx.(%s)\n",jprint(retjson,0)); if ( (vins= jarray(&n,retjson,"vin")) != 0 && vini < n ) { item = jitem(vins,vini); From 880b45fd74bd932138b08fc309959e871f3d0e13 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 24 Feb 2018 16:07:04 +0200 Subject: [PATCH 170/197] Test --- iguana/exchanges/LP_remember.c | 2 +- iguana/exchanges/LP_transaction.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 1579bd565..08f91aeff 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -1320,7 +1320,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti rswap.privAm = basilisk_swap_privbob_extract(rswap.bobcoin,rswap.paymentspent,0,1); if ( bits256_nonz(rswap.privAm) == 0 && bits256_nonz(rswap.depositspent) != 0 ) { - rswap.privAm = basilisk_swap_privbob_extract(rswap.alicecoin,rswap.depositspent,0,1); + rswap.privAm = basilisk_swap_privbob_extract(rswap.bobcoin,rswap.depositspent,0,1); printf("try to bobspend aspend.%s have privAm.%d\n",bits256_str(str,rswap.depositspent),bits256_nonz(rswap.privAm)); } } diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index 8f0712e68..22e729b0c 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -1618,7 +1618,7 @@ int32_t basilisk_swap_getsigscript(char *symbol,uint8_t *script,int32_t maxlen,b char str[65]; printf("getsigscript %s %s/v%d\n",symbol,bits256_str(str,txid),vini); if ( bits256_nonz(txid) != 0 && (retjson= LP_gettx(symbol,txid,0)) != 0 ) { - printf("gettx.(%s)\n",jprint(retjson,0)); + //printf("gettx.(%s)\n",jprint(retjson,0)); if ( (vins= jarray(&n,retjson,"vin")) != 0 && vini < n ) { item = jitem(vins,vini); From e78fb1afe3ed32333fbf035aaa06c1d4c5f5f5b3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 24 Feb 2018 16:14:52 +0200 Subject: [PATCH 171/197] Test --- iguana/exchanges/LP_remember.c | 2 +- iguana/exchanges/LP_transaction.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 08f91aeff..7e50b6f3e 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -1332,7 +1332,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti char *bobSpendEthTx = LP_etomicbob_spends_alice_payment(&rswap); free(bobSpendEthTx); } - //printf("bobspend.(%s)\n",rswap.txbytes[BASILISK_BOBSPEND]); + printf("bobspend.(%s)\n",rswap.txbytes[BASILISK_BOBSPEND]); } } LP_txbytes_update("bobspend",rswap.alicecoin,rswap.txbytes[BASILISK_BOBSPEND],&rswap.txids[BASILISK_BOBSPEND],&rswap.Apaymentspent,&rswap.sentflags[BASILISK_BOBSPEND]); diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index 22e729b0c..f5ae502ca 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -1615,7 +1615,7 @@ int32_t LP_swap_getcoinaddr(char *symbol,char *coinaddr,bits256 txid,int32_t vou int32_t basilisk_swap_getsigscript(char *symbol,uint8_t *script,int32_t maxlen,bits256 txid,int32_t vini) { cJSON *retjson,*vins,*item,*skey; int32_t n,scriptlen = 0; char *hexstr; - char str[65]; printf("getsigscript %s %s/v%d\n",symbol,bits256_str(str,txid),vini); + //char str[65]; printf("getsigscript %s %s/v%d\n",symbol,bits256_str(str,txid),vini); if ( bits256_nonz(txid) != 0 && (retjson= LP_gettx(symbol,txid,0)) != 0 ) { //printf("gettx.(%s)\n",jprint(retjson,0)); @@ -1626,7 +1626,7 @@ int32_t basilisk_swap_getsigscript(char *symbol,uint8_t *script,int32_t maxlen,b { scriptlen >>= 1; decode_hex(script,scriptlen,hexstr); - char str[65]; printf("%s %s/v%d sigscript.(%s)\n",symbol,bits256_str(str,txid),vini,hexstr); + //char str[65]; printf("%s %s/v%d sigscript.(%s)\n",symbol,bits256_str(str,txid),vini,hexstr); } } free_json(retjson); From 82123c2cacd44c133f9acec72344da3746bae081 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 24 Feb 2018 16:22:40 +0200 Subject: [PATCH 172/197] Test --- iguana/exchanges/LP_remember.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 7e50b6f3e..392d2f114 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -415,6 +415,8 @@ int32_t basilisk_swap_isfinished(uint32_t requestid,uint32_t quoteid,uint32_t ex int32_t i,n = 0; uint32_t now = (uint32_t)time(NULL); if ( bits256_nonz(paymentspent) != 0 && bits256_nonz(Apaymentspent) != 0 && bits256_nonz(depositspent) != 0 ) return(1); + else if ( sentflags[BASILISK_BOBPAYMENT] == 0 && bits256_nonz(txids[BASILISK_BOBPAYMENT]) == 0 && bits256_nonz(Apaymentspent) != 0 && bits256_nonz(depositspent) != 0 ) + return(1); else if ( sentflags[BASILISK_BOBPAYMENT] != 0 && sentflags[BASILISK_ALICEPAYMENT] != 0 && sentflags[BASILISK_BOBDEPOSIT] != 0 && sentflags[BASILISK_BOBRECLAIM] != 0 ) { if ( sentflags[BASILISK_ALICECLAIM] != 0 ) From 13bdccec11b8d7ceb38b66023048722d62eb83b1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 24 Feb 2018 16:24:53 +0200 Subject: [PATCH 173/197] Test --- iguana/exchanges/LP_remember.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 392d2f114..1cfd5afb7 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -1262,7 +1262,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti len = basilisk_swapuserdata(userdata,revAm,1,rswap.myprivs[0],redeemscript,redeemlen); if ( (rswap.txbytes[BASILISK_ALICECLAIM]= basilisk_swap_bobtxspend(&signedtxid,rswap.Btxfee,"aliceclaim",rswap.bobcoin,bob->wiftaddr,bob->taddr,bob->pubtype,bob->p2shtype,bob->isPoS,bob->wiftype,ctx,rswap.myprivs[0],0,redeemscript,redeemlen,userdata,len,rswap.txids[BASILISK_BOBDEPOSIT],0,0,rswap.pubkey33,0,rswap.dlocktime+777,&rswap.values[BASILISK_ALICECLAIM],0,0,rswap.bobdepositaddr,1,bob->zcash)) != 0 ) { - printf("dlocktime.%u claimtime.%u aliceclaim.(%s)\n",rswap.dlocktime,claimtime,rswap.txbytes[BASILISK_ALICECLAIM]); + //printf("dlocktime.%u claimtime.%u aliceclaim.(%s)\n",rswap.dlocktime,claimtime,rswap.txbytes[BASILISK_ALICECLAIM]); if ( rswap.bobtomic[0] != 0 ) { char *aliceClaimsEthTxId = LP_etomicalice_claims_bob_deposit(&rswap); @@ -1323,7 +1323,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti if ( bits256_nonz(rswap.privAm) == 0 && bits256_nonz(rswap.depositspent) != 0 ) { rswap.privAm = basilisk_swap_privbob_extract(rswap.bobcoin,rswap.depositspent,0,1); - printf("try to bobspend aspend.%s have privAm.%d\n",bits256_str(str,rswap.depositspent),bits256_nonz(rswap.privAm)); + //printf("try to bobspend aspend.%s have privAm.%d\n",bits256_str(str,rswap.depositspent),bits256_nonz(rswap.privAm)); } } if ( bits256_nonz(rswap.privAm) != 0 && bits256_nonz(rswap.privBn) != 0 ) @@ -1334,7 +1334,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti char *bobSpendEthTx = LP_etomicbob_spends_alice_payment(&rswap); free(bobSpendEthTx); } - printf("bobspend.(%s)\n",rswap.txbytes[BASILISK_BOBSPEND]); + //printf("bobspend.(%s)\n",rswap.txbytes[BASILISK_BOBSPEND]); } } LP_txbytes_update("bobspend",rswap.alicecoin,rswap.txbytes[BASILISK_BOBSPEND],&rswap.txids[BASILISK_BOBSPEND],&rswap.Apaymentspent,&rswap.sentflags[BASILISK_BOBSPEND]); From d6c84e53f69551cb954dd20e18f61c3bc85a4be1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 24 Feb 2018 16:47:54 +0200 Subject: [PATCH 174/197] Test --- iguana/exchanges/LP_remember.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 1cfd5afb7..03e32f779 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -417,6 +417,8 @@ int32_t basilisk_swap_isfinished(uint32_t requestid,uint32_t quoteid,uint32_t ex return(1); else if ( sentflags[BASILISK_BOBPAYMENT] == 0 && bits256_nonz(txids[BASILISK_BOBPAYMENT]) == 0 && bits256_nonz(Apaymentspent) != 0 && bits256_nonz(depositspent) != 0 ) return(1); + else if ( sentflags[BASILISK_BOBPAYMENT] == 0 && bits256_nonz(txids[BASILISK_BOBPAYMENT]) == 0 && sentflags[BASILISK_ALICEPAYMENT] == 0 && bits256_nonz(txids[BASILISK_ALICEPAYMENT]) == 0 && bits256_nonz(depositspent) != 0 ) + return(1); else if ( sentflags[BASILISK_BOBPAYMENT] != 0 && sentflags[BASILISK_ALICEPAYMENT] != 0 && sentflags[BASILISK_BOBDEPOSIT] != 0 && sentflags[BASILISK_BOBRECLAIM] != 0 ) { if ( sentflags[BASILISK_ALICECLAIM] != 0 ) @@ -464,8 +466,8 @@ int32_t basilisk_swap_isfinished(uint32_t requestid,uint32_t quoteid,uint32_t ex { if ( bits256_nonz(depositspent) != 0 ) { - if ( bits256_nonz(Apaymentspent) == 0 && sentflags[BASILISK_BOBREFUND] == 0 ) - printf("used to be bob was too late in claiming bobrefund %u-%u\n",requestid,quoteid); + //if ( bits256_nonz(Apaymentspent) == 0 && sentflags[BASILISK_BOBREFUND] == 0 ) + // printf("used to be bob was too late in claiming bobrefund %u-%u\n",requestid,quoteid); return(0); } } From 3e6ae39b95d0c61e5f6a94ad4e045ebc6f207862 Mon Sep 17 00:00:00 2001 From: Mihail Fedorov Date: Sun, 25 Feb 2018 15:01:48 +0300 Subject: [PATCH 175/197] should be ok --- iguana/coins/vote2018_7776 | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 iguana/coins/vote2018_7776 diff --git a/iguana/coins/vote2018_7776 b/iguana/coins/vote2018_7776 old mode 100644 new mode 100755 From 58f62c8a8e977bcdcddd0cd8ddb6a22630ca9f73 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 25 Feb 2018 22:07:50 +0200 Subject: [PATCH 176/197] Test --- iguana/m_LP_StaticNanoMsg | 4 ++-- iguana/m_mm | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/iguana/m_LP_StaticNanoMsg b/iguana/m_LP_StaticNanoMsg index 12dd63b2f..d2d295351 100755 --- a/iguana/m_LP_StaticNanoMsg +++ b/iguana/m_LP_StaticNanoMsg @@ -6,8 +6,8 @@ git pull cd secp256k1; ./m_unix; cd .. cd ../crypto777; make -f m_LP_StaticNanoMsg all; make -f m_LP_StaticNanoMsg clean; cd ../iguana -clang -g -Wno-deprecated -c -O2 -DLIQUIDITY_PROVIDER=1 -DUSE_STATIC_NANOMSG *.c ../basilisk/basilisk.c ../gecko/gecko.c ../datachain/datachain.c -clang -g -Wno-deprecated -c -DLIQUIDITY_PROVIDER=1 -DUSE_STATIC_NANOMSG main.c iguana777.c iguana_bundles.c ../basilisk/basilisk.c iguana_ramchain.c +clang -g -DNOTETOMIC -Wno-deprecated -c -O2 -DLIQUIDITY_PROVIDER=1 -DUSE_STATIC_NANOMSG *.c ../basilisk/basilisk.c ../gecko/gecko.c ../datachain/datachain.c +clang -g -DNOTETOMIC -Wno-deprecated -c -DLIQUIDITY_PROVIDER=1 -DUSE_STATIC_NANOMSG main.c iguana777.c iguana_bundles.c ../basilisk/basilisk.c iguana_ramchain.c clang -g -o ../agents/iguana *.o ../agents/libcrypto777.a ../OSlibs/linux/$(uname -m)/libnanomsg-static.a -lcurl -lssl -lcrypto -lpthread -lz -lm -lanl -lrt -lnsl diff --git a/iguana/m_mm b/iguana/m_mm index 1f3d1b87f..b54ab120a 100755 --- a/iguana/m_mm +++ b/iguana/m_mm @@ -10,4 +10,4 @@ if [[ "$OSTYPE" == "darwin"* ]]; then nanomsg_lib="../OSlibs/osx/$(uname -m)/libnanomsg-static.a" fi -gcc -g -o marketmaker -I../crypto777 exchanges/mm.c ../crypto777/cJSON.c mini-gmp.c groestl.c segwit_addr.c secp256k1.o ../agents/libcrypto777.a $nanomsg_lib -lcurl -lpthread -lm +gcc -g -o marketmaker -DNOTETOMIC -I../crypto777 exchanges/mm.c ../crypto777/cJSON.c mini-gmp.c groestl.c segwit_addr.c secp256k1.o ../agents/libcrypto777.a $nanomsg_lib -lcurl -lpthread -lm From fb957fa3eedefd3acca83d30927c8cab49df1d6a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 25 Feb 2018 22:12:15 +0200 Subject: [PATCH 177/197] test --- iguana/exchanges/LP_nativeDEX.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 12342f52f..7d598d394 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -178,7 +178,9 @@ char *blocktrail_listtransactions(char *symbol,char *coinaddr,int32_t num,int32_ #include "LP_prices.c" #include "LP_scan.c" #include "LP_transaction.c" +#ifndef NOTETOMIC #include "LP_etomic.c" +#endif #include "LP_stats.c" #include "LP_remember.c" #include "LP_instantdex.c" From 10a85ad0b995cfd037d9cfafbeca5557d8149588 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 25 Feb 2018 22:19:35 +0200 Subject: [PATCH 178/197] Test --- iguana/exchanges/LP_bitcoin.c | 5 ++++- iguana/exchanges/LP_privkey.c | 2 ++ iguana/exchanges/LP_remember.c | 24 ++++++++++++++++++++---- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/iguana/exchanges/LP_bitcoin.c b/iguana/exchanges/LP_bitcoin.c index 666f96d3e..29d8d90d6 100644 --- a/iguana/exchanges/LP_bitcoin.c +++ b/iguana/exchanges/LP_bitcoin.c @@ -2120,6 +2120,7 @@ char *bitcoin_address(char *symbol,char *coinaddr,uint8_t taddr,uint8_t addrtype { static void *ctx; int32_t offset,i,len5; char prefixed[64]; uint8_t data[64],data5[64],bigpubkey[65]; bits256 hash; struct iguana_info *coin; +#ifndef NOTETOMIC if ( (coin= LP_coinfind(symbol)) != 0 && coin->etomic[0] != 0 ) { if ( len == 20 ) @@ -2142,10 +2143,12 @@ char *bitcoin_address(char *symbol,char *coinaddr,uint8_t taddr,uint8_t addrtype for (i=0; i<65; i++) printf("%02x",bigpubkey[i]); printf(" -> %s\n",coinaddr);*/ - } else LP_etomic_pub2addr(coinaddr,pubkey_or_rmd160+1); + } + else LP_etomic_pub2addr(coinaddr,pubkey_or_rmd160+1); return(coinaddr); } } +#endif coinaddr[0] = 0; offset = 1 + (taddr != 0); if ( len != 20 ) diff --git a/iguana/exchanges/LP_privkey.c b/iguana/exchanges/LP_privkey.c index ff9cde5aa..f8ec16e37 100644 --- a/iguana/exchanges/LP_privkey.c +++ b/iguana/exchanges/LP_privkey.c @@ -299,6 +299,7 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan RS_encode(G.LP_NXTaddr,nxtaddr); } bitcoin_priv2pub(ctx,coin->symbol,coin->pubkey33,coin->smartaddr,privkey,coin->taddr,coin->pubtype); +#ifndef NOTETOMIC if ( coin->etomic[0] != 0 ) { uint8_t check64[64],checktype,checkrmd160[20],rmd160[20]; char checkaddr[64],checkaddr2[64]; @@ -318,6 +319,7 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan } else printf("pubkey 64 mismatch\n"); } else printf("error creating pubkey\n"); } +#endif OS_randombytes(tmpkey.bytes,sizeof(tmpkey)); if ( bits256_nonz(privkey) == 0 || (siglen= bitcoin_sign(ctx,coin->symbol,sig,tmpkey,privkey,0)) <= 0 ) { diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 9f6490b88..254441454 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -1223,11 +1223,13 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti if ( (rswap.txbytes[BASILISK_ALICESPEND]= basilisk_swap_bobtxspend(&signedtxid,rswap.Btxfee,"alicespend",rswap.bobcoin,bob->wiftaddr,bob->taddr,bob->pubtype,bob->p2shtype,bob->isPoS,bob->wiftype,ctx,rswap.myprivs[0],0,redeemscript,redeemlen,userdata,len,rswap.txids[BASILISK_BOBPAYMENT],0,0,rswap.pubkey33,1,rswap.expiration,&rswap.values[BASILISK_ALICESPEND],0,0,rswap.bobpaymentaddr,1,bob->zcash)) != 0 ) { //printf("alicespend.(%s)\n",rswap.txbytes[BASILISK_ALICESPEND]); +#ifndef NOTETOMIC if ( rswap.bobtomic[0] != 0 ) { char *aliceSpendEthTxId = LP_etomicalice_spends_bob_payment(&rswap); free(aliceSpendEthTxId); } +#endif } } LP_txbytes_update("alicespend",rswap.bobcoin,rswap.txbytes[BASILISK_ALICESPEND],&rswap.txids[BASILISK_ALICESPEND],&rswap.paymentspent,&rswap.sentflags[BASILISK_ALICESPEND]); @@ -1265,11 +1267,13 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti if ( (rswap.txbytes[BASILISK_ALICECLAIM]= basilisk_swap_bobtxspend(&signedtxid,rswap.Btxfee,"aliceclaim",rswap.bobcoin,bob->wiftaddr,bob->taddr,bob->pubtype,bob->p2shtype,bob->isPoS,bob->wiftype,ctx,rswap.myprivs[0],0,redeemscript,redeemlen,userdata,len,rswap.txids[BASILISK_BOBDEPOSIT],0,0,rswap.pubkey33,0,rswap.dlocktime+777,&rswap.values[BASILISK_ALICECLAIM],0,0,rswap.bobdepositaddr,1,bob->zcash)) != 0 ) { //printf("dlocktime.%u claimtime.%u aliceclaim.(%s)\n",rswap.dlocktime,claimtime,rswap.txbytes[BASILISK_ALICECLAIM]); +#ifndef NOTETOMIC if ( rswap.bobtomic[0] != 0 ) { char *aliceClaimsEthTxId = LP_etomicalice_claims_bob_deposit(&rswap); free(aliceClaimsEthTxId); } +#endif } } LP_txbytes_update("aliceclaim",rswap.bobcoin,rswap.txbytes[BASILISK_ALICECLAIM],&rswap.txids[BASILISK_ALICECLAIM],&rswap.depositspent,&rswap.sentflags[BASILISK_ALICECLAIM]); @@ -1292,10 +1296,13 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti { if ( (rswap.txbytes[BASILISK_ALICERECLAIM]= basilisk_swap_Aspend("alicereclaim",rswap.alicecoin,rswap.Atxfee,alice->wiftaddr,alice->taddr,alice->pubtype,alice->p2shtype,alice->isPoS,alice->wiftype,ctx,rswap.privAm,rswap.privBn,rswap.txids[BASILISK_ALICEPAYMENT],0,rswap.pubkey33,rswap.expiration,&rswap.values[BASILISK_ALICERECLAIM],rswap.alicepaymentaddr,alice->zcash)) != 0 ) { printf("alicereclaim.(%s)\n", rswap.txbytes[BASILISK_ALICERECLAIM]); - if (rswap.alicetomic[0] != 0) { +#ifndef NOTETOMIC + if ( rswap.alicetomic[0] != 0 ) + { char *aliceReclaimEthTx = LP_etomicalice_reclaims_payment(&rswap); free(aliceReclaimEthTx); } +#endif } } LP_txbytes_update("alicereclaim",rswap.alicecoin,rswap.txbytes[BASILISK_ALICERECLAIM],&rswap.txids[BASILISK_ALICERECLAIM],&rswap.Apaymentspent,&rswap.sentflags[BASILISK_ALICERECLAIM]); @@ -1332,10 +1339,13 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti { if ( (rswap.txbytes[BASILISK_BOBSPEND]= basilisk_swap_Aspend("bobspend",rswap.alicecoin,rswap.Atxfee,alice->wiftaddr,alice->taddr,alice->pubtype,alice->p2shtype,alice->isPoS,alice->wiftype,ctx,rswap.privAm,rswap.privBn,rswap.txids[BASILISK_ALICEPAYMENT],0,rswap.pubkey33,rswap.expiration,&rswap.values[BASILISK_BOBSPEND],rswap.alicepaymentaddr,alice->zcash)) != 0 ) { - if (rswap.alicetomic[0] != 0) { +#ifndef NOTETOMIC + if ( rswap.alicetomic[0] != 0 ) + { char *bobSpendEthTx = LP_etomicbob_spends_alice_payment(&rswap); free(bobSpendEthTx); } +#endif //printf("bobspend.(%s)\n",rswap.txbytes[BASILISK_BOBSPEND]); } } @@ -1361,10 +1371,13 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti len = basilisk_swapuserdata(userdata,zero,1,rswap.myprivs[1],redeemscript,redeemlen); if ( (rswap.txbytes[BASILISK_BOBRECLAIM]= basilisk_swap_bobtxspend(&signedtxid,rswap.Btxfee,"bobreclaim",rswap.bobcoin,bob->wiftaddr,bob->taddr,bob->pubtype,bob->p2shtype,bob->isPoS,bob->wiftype,ctx,rswap.myprivs[1],0,redeemscript,redeemlen,userdata,len,rswap.txids[BASILISK_BOBPAYMENT],0,0,rswap.pubkey33,0,rswap.plocktime+777,&rswap.values[BASILISK_BOBRECLAIM],0,0,rswap.bobpaymentaddr,1,bob->zcash)) != 0 ) { - if (rswap.bobtomic[0] != 0) { +#ifndef NOTETOMIC + if ( rswap.bobtomic[0] != 0 ) + { char *bobReclaimEthTx = LP_etomicbob_reclaims_payment(&rswap); free(bobReclaimEthTx); } +#endif //int32_t z; //for (z=0; z<20; z++) // printf("%02x",rswap.secretAm[z]); @@ -1399,10 +1412,13 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti len = basilisk_swapuserdata(userdata,rswap.privBn,0,rswap.myprivs[0],redeemscript,redeemlen); if ( (rswap.txbytes[BASILISK_BOBREFUND]= basilisk_swap_bobtxspend(&signedtxid,rswap.Btxfee,"bobrefund",rswap.bobcoin,bob->wiftaddr,bob->taddr,bob->pubtype,bob->p2shtype,bob->isPoS,bob->wiftype,ctx,rswap.myprivs[0],0,redeemscript,redeemlen,userdata,len,rswap.txids[BASILISK_BOBDEPOSIT],0,0,rswap.pubkey33,1,rswap.expiration,&rswap.values[BASILISK_BOBREFUND],0,0,rswap.bobdepositaddr,1,bob->zcash)) != 0 ) { - if (rswap.bobtomic[0] != 0) { +#ifndef NOTETOMIC + if ( rswap.bobtomic[0] != 0 ) + { char *bobRefundsEthTx = LP_etomicbob_refunds_deposit(&rswap); free(bobRefundsEthTx); } +#endif //printf("pubB1.(%s) bobrefund.(%s)\n",bits256_str(str,rswap.pubB1),rswap.txbytes[BASILISK_BOBREFUND]); } } From cf92b32be8b0a299fcfbc5c76689fedc078ef12f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 25 Feb 2018 22:22:07 +0200 Subject: [PATCH 179/197] Test --- iguana/exchanges/LP_swap.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index ef198fb44..756cb9e39 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -610,7 +610,9 @@ int32_t LP_rawtx_spendscript(struct basilisk_swap *swap,int32_t height,struct ba return(-1); } rawtx->I.redeemlen = recvbuf[offset++]; +#ifndef NOTETOMIC uint8arrayToHex(rawtx->I.ethTxid, &recvbuf[offset], 32); +#endif offset += 32; printf("ETH txid received: %s\n", rawtx->I.ethTxid); data = &recvbuf[offset]; @@ -713,11 +715,14 @@ uint32_t LP_swapdata_rawtxsend(int32_t pairsock,struct basilisk_swap *swap,uint3 } if ( bits256_nonz(rawtx->I.actualtxid) != 0 && msgbits != 0 ) { - if (swap->I.bobtomic[0] != 0 || swap->I.alicetomic[0] != 0) { +#ifndef NOTETOMIC + if ( swap->I.bobtomic[0] != 0 || swap->I.alicetomic[0] != 0 ) + { char *ethTxId = sendEthTx(swap, rawtx); strcpy(rawtx->I.ethTxid, ethTxId); free(ethTxId); } +#endif sendlen = 0; sendbuf[sendlen++] = rawtx->I.datalen & 0xff; sendbuf[sendlen++] = (rawtx->I.datalen >> 8) & 0xff; From 7c52b7fb142fd0254f25ded42bf56e8356c8f6ca Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 25 Feb 2018 22:42:45 +0200 Subject: [PATCH 180/197] -prints --- iguana/exchanges/LP_ordermatch.c | 5 ++--- iguana/exchanges/LP_swap.c | 9 ++++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index f487b900c..fe2da5232 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -869,7 +869,6 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru printf("myprice %.8f bid %.8f ask %.8f\n",myprice,bid,ask); return(0); } - printf("myprice %.8f\n",myprice); autxo = &A; butxo = &B; memset(autxo,0,sizeof(*autxo)); @@ -973,7 +972,7 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru printf("i.%d qprice %.8f myprice %.8f price %.8f [%.8f]\n",i,qprice,myprice,price,p); if ( LP_allocated(qp->txid,qp->vout) == 0 && LP_allocated(qp->txid2,qp->vout2) == 0 ) { - printf("found unallocated txids\n"); + //printf("found unallocated txids\n"); reqjson = LP_quotejson(qp); LP_unavailableset(qp->txid,qp->vout,qp->timestamp + LP_RESERVETIME,qp->desthash); LP_unavailableset(qp->txid2,qp->vout2,qp->timestamp + LP_RESERVETIME,qp->desthash); @@ -987,7 +986,7 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru memset(zero.bytes,0,sizeof(zero)); LP_reserved_msg(1,qp->srccoin,qp->destcoin,zero,jprint(reqjson,0)); free_json(reqjson); - printf("Send RESERVED id.%llu\n",(long long)qp->aliceid); + //printf("Send RESERVED id.%llu\n",(long long)qp->aliceid); return(qp); } else printf("request processing selected ineligible utxos?\n"); return(0); diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index 756cb9e39..64ac8a3be 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -612,9 +612,9 @@ int32_t LP_rawtx_spendscript(struct basilisk_swap *swap,int32_t height,struct ba rawtx->I.redeemlen = recvbuf[offset++]; #ifndef NOTETOMIC uint8arrayToHex(rawtx->I.ethTxid, &recvbuf[offset], 32); + printf("ETH txid received: %s\n", rawtx->I.ethTxid); #endif offset += 32; - printf("ETH txid received: %s\n", rawtx->I.ethTxid); data = &recvbuf[offset]; if ( rawtx->I.redeemlen > 0 && rawtx->I.redeemlen < 0x100 ) { @@ -727,12 +727,15 @@ uint32_t LP_swapdata_rawtxsend(int32_t pairsock,struct basilisk_swap *swap,uint3 sendbuf[sendlen++] = rawtx->I.datalen & 0xff; sendbuf[sendlen++] = (rawtx->I.datalen >> 8) & 0xff; sendbuf[sendlen++] = rawtx->I.redeemlen; - if (rawtx->I.ethTxid[0] != 0 && strlen(rawtx->I.ethTxid) == 66) { + if ( rawtx->I.ethTxid[0] != 0 && strlen(rawtx->I.ethTxid) == 66 ) + { uint8_t ethTxidBytes[32]; // ETH txid always starts with 0x decode_hex(ethTxidBytes, 32, rawtx->I.ethTxid + 2); memcpy(&sendbuf[sendlen], ethTxidBytes, 32); - } else { + } + else + { // fill with zero bytes to always have fixed message size memset(&sendbuf[sendlen], 0, 32); } From 32289f5a3f40e12466126ce734205a74772e20bc Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 25 Feb 2018 22:43:25 +0200 Subject: [PATCH 181/197] -prints --- iguana/exchanges/LP_ordermatch.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index fe2da5232..7794e3bca 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -861,7 +861,7 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru double price=0.,p=0.,qprice,myprice,bestprice,range,bid,ask; struct iguana_info *coin,*othercoin; struct LP_utxoinfo A,B,*autxo,*butxo; cJSON *reqjson; char str[65]; struct LP_address_utxo *utxos[1000]; int32_t i,r,counter,max = (int32_t)(sizeof(utxos)/sizeof(*utxos)); *newqp = *qp; qp = newqp; - printf("bob %s received REQUEST.(%llu)\n",bits256_str(str,G.LP_mypub25519),(long long)qp->aliceid); + //printf("bob %s received REQUEST.(%llu)\n",bits256_str(str,G.LP_mypub25519),(long long)qp->aliceid); if ( (coin= LP_coinfind(qp->srccoin)) == 0 || (othercoin= LP_coinfind(qp->destcoin)) == 0 ) return(0); if ( (myprice= LP_trades_bobprice(&bid,&ask,qp)) == 0. ) @@ -912,7 +912,7 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru } else { - printf("ignore as qprice %.8f vs myprice %.8f\n",qprice,myprice); + //printf("ignore as qprice %.8f vs myprice %.8f\n",qprice,myprice); return(0); } //LP_RTmetrics_update(qp->srccoin,qp->destcoin); @@ -1000,7 +1000,7 @@ struct LP_quoteinfo *LP_trades_gotreserved(void *ctx,struct LP_quoteinfo *qp,str qp = newqp; if ( (qprice= LP_trades_alicevalidate(ctx,qp)) > 0. ) { - printf("got qprice %.8f\n",qprice); + //printf("got qprice %.8f\n",qprice); LP_aliceid(qp->tradeid,qp->aliceid,"reserved",0,0); if ( (retstr= LP_quotereceived(qp)) != 0 ) free(retstr); From 1987a679b43a5a10429fa9e6bf1fe849099cb15b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 25 Feb 2018 23:50:37 +0200 Subject: [PATCH 182/197] typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4a5d94898..b0577f2a1 100755 --- a/README.md +++ b/README.md @@ -259,7 +259,7 @@ The iguana binary and its linked libraries are in ```$HOME/tmp/iguana```. # Cmake build of marketmaker with linked etomic lib for ETH/ERC20 atomic swaps: 0. `make sure g++-7 ln to /usr/bin/g++` 1. `cd ~/SuperNET` -2. `git checkout etomic` +2. `git checkout dev` 3. `git submodule update --init --recursive` 4. `mkdir build` 5. `cd build` From 028c9deb03e45158addf680cb258985f1cc03e33 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 25 Feb 2018 23:57:23 +0200 Subject: [PATCH 183/197] Test --- iguana/m_mm_StaticNanoMsg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/m_mm_StaticNanoMsg b/iguana/m_mm_StaticNanoMsg index 2c224b764..20f0e8c81 100755 --- a/iguana/m_mm_StaticNanoMsg +++ b/iguana/m_mm_StaticNanoMsg @@ -19,7 +19,7 @@ all: +$(MAKE) -C secp256k1 -f m_unix_Makefile all +$(MAKE) -C ../crypto777 -f m_LP_StaticNanoMsg all +$(MAKE) -C ../crypto777 -f m_LP_StaticNanoMsg clean - $(CC) -o ../agents/marketmaker -I../crypto777 exchanges/mm.c ../crypto777/cJSON.c mini-gmp.c groestl.c segwit_addr.c secp256k1.o ../agents/libcrypto777.a ../OSlibs/linux/$(shell uname -m)/libnanomsg-static.a -lcurl -lpthread -lm -lanl + $(CC) -DNOTETOMIC -o ../agents/marketmaker -I../crypto777 exchanges/mm.c ../crypto777/cJSON.c mini-gmp.c groestl.c segwit_addr.c secp256k1.o ../agents/libcrypto777.a ../OSlibs/linux/$(shell uname -m)/libnanomsg-static.a -lcurl -lpthread -lm -lanl @echo "===========================" @echo " marketmaker -> `pwd`/../agents/marketmaker" @echo "===========================" From 38cbe3ba205f387d121bf79171a8de39ad6f66be Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 25 Feb 2018 23:58:06 +0200 Subject: [PATCH 184/197] Fix static mm --- iguana/m_mm_StaticNanoMsg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/m_mm_StaticNanoMsg b/iguana/m_mm_StaticNanoMsg index 2c224b764..280a3bd70 100755 --- a/iguana/m_mm_StaticNanoMsg +++ b/iguana/m_mm_StaticNanoMsg @@ -19,7 +19,7 @@ all: +$(MAKE) -C secp256k1 -f m_unix_Makefile all +$(MAKE) -C ../crypto777 -f m_LP_StaticNanoMsg all +$(MAKE) -C ../crypto777 -f m_LP_StaticNanoMsg clean - $(CC) -o ../agents/marketmaker -I../crypto777 exchanges/mm.c ../crypto777/cJSON.c mini-gmp.c groestl.c segwit_addr.c secp256k1.o ../agents/libcrypto777.a ../OSlibs/linux/$(shell uname -m)/libnanomsg-static.a -lcurl -lpthread -lm -lanl + $(CC) -DNOTETOMIC -o ../agents/marketmaker -I../crypto777 exchanges/mm.c ../crypto777/cJSON.c mini-gmp.c groestl.c segwit_addr.c secp256k1.o ../agents/libcrypto777.a ../OSlibs/linux/$(shell uname -m)/libnanomsg-static.a -lcurl -lpthread -lm -lanl @echo "===========================" @echo " marketmaker -> `pwd`/../agents/marketmaker" @echo "===========================" From ea64929eecaa856021922ee867bb41f7e51b3537 Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Mon, 26 Feb 2018 04:23:37 +0300 Subject: [PATCH 185/197] added NOTETOMIC preprocessor definition to build without etomic lib for ETH/ERC20 atomic swaps --- marketmaker.vcxproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/marketmaker.vcxproj b/marketmaker.vcxproj index fbe023dc8..99c4d66cf 100644 --- a/marketmaker.vcxproj +++ b/marketmaker.vcxproj @@ -86,7 +86,7 @@ Level2 Disabled - _CRT_SECURE_NO_WARNINGS;NATIVE_WINDOWS;WIN32;_DEBUG;_CONSOLE;IGUANA_LOG2PACKETSIZE=20;IGUANA_MAXPACKETSIZE=1572864;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;NATIVE_WINDOWS;WIN32;_DEBUG;_CONSOLE;IGUANA_LOG2PACKETSIZE=20;IGUANA_MAXPACKETSIZE=1572864;NOTETOMIC;%(PreprocessorDefinitions) 8Bytes .\iguana;%(AdditionalIncludeDirectories) @@ -103,7 +103,7 @@ Level3 Disabled - _DEBUG;_CONSOLE;NATIVE_WINDOWS;WIN32;IGUANA_LOG2PACKETSIZE=20;IGUANA_MAXPACKETSIZE=1572864;%(PreprocessorDefinitions) + _DEBUG;_CONSOLE;NATIVE_WINDOWS;WIN32;IGUANA_LOG2PACKETSIZE=20;IGUANA_MAXPACKETSIZE=1572864;NOTETOMIC;%(PreprocessorDefinitions) 8Bytes @@ -121,7 +121,7 @@ MaxSpeed true true - _CRT_SECURE_NO_WARNINGS;NATIVE_WINDOWS;WIN32;_CONSOLE;NDEBUG;IGUANA_LOG2PACKETSIZE=20;IGUANA_MAXPACKETSIZE=1572864;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;NATIVE_WINDOWS;WIN32;_CONSOLE;NDEBUG;IGUANA_LOG2PACKETSIZE=20;IGUANA_MAXPACKETSIZE=1572864;NOTETOMIC;%(PreprocessorDefinitions) 8Bytes @@ -141,7 +141,7 @@ MaxSpeed true true - WIN64;_WIN64;_CRT_SECURE_NO_WARNINGS;NATIVE_WINDOWS;WIN32;WIN32_LEAN_AND_MEAN;_CONSOLE;NDEBUG;IGUANA_LOG2PACKETSIZE=20;IGUANA_MAXPACKETSIZE=1572864;%(PreprocessorDefinitions) + WIN64;_WIN64;_CRT_SECURE_NO_WARNINGS;NATIVE_WINDOWS;WIN32;WIN32_LEAN_AND_MEAN;_CONSOLE;NDEBUG;IGUANA_LOG2PACKETSIZE=20;IGUANA_MAXPACKETSIZE=1572864;NOTETOMIC;%(PreprocessorDefinitions) 8Bytes MultiThreaded From b38d2d9db9f322350f74c5236a367280925618a8 Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Mon, 26 Feb 2018 04:30:47 +0300 Subject: [PATCH 186/197] added sample script to build cpp-ethereum libs under Windows (not fully tested) --- marketmaker_build_cpp-ethereum.cmd | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 marketmaker_build_cpp-ethereum.cmd diff --git a/marketmaker_build_cpp-ethereum.cmd b/marketmaker_build_cpp-ethereum.cmd new file mode 100644 index 000000000..589d2924b --- /dev/null +++ b/marketmaker_build_cpp-ethereum.cmd @@ -0,0 +1,15 @@ +@echo off +rem Sample script to build cpp-ethereum libs by Decker (don't fully tested yet) +rem Make sure cpp-ethereum is empty, before run. + +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 +mkdir build_win64_release +cd build_win64_release +cmake .. -G "Visual Studio 14 2015 Win64" +cmake --build . --config Release +rem cmake --build . \ No newline at end of file From cc810059d9b1e4f967fb30c8530aee755fd86962 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 26 Feb 2018 07:31:58 +0200 Subject: [PATCH 187/197] Test --- iguana/exchanges/prices/autoprice | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/prices/autoprice b/iguana/exchanges/prices/autoprice index 95f21db79..89607c48f 100755 --- a/iguana/exchanges/prices/autoprice +++ b/iguana/exchanges/prices/autoprice @@ -1,11 +1,18 @@ #!/bin/bash margin=0.05 source userpass -./auto_chipskmd -./auto_chipsbtc + +# KMD/BTC must be first as other prices depend on it #curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"KMD\",\"rel\":\"BTC\",\"margin\":$margin,\"refbase\":\"komodo\",\"refrel\":\"coinmarketcap\"}" #curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"BTC\",\"rel\":\"KMD\",\"fixed\":0.00025,\"margin\":$margin}" #curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"KMD\",\"rel\":\"BTC\",\"fixed\":4000,\"margin\":$margin}" +curl --url "http://127.0.0.1:7783" --data "{\"minprice\":0.0003,\"maxprice\":0.001,\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"KMD\",\"rel\":\"BTC\",\"margin\":0.05,\"refbase\":\"komodo\",\"refrel\":\"coinmarketcap\"}" + +./auto_chipskmd +./auto_chipsbtc + + + #curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"KMD\",\"rel\":\"MNZ\",\"offset\":0.0,\"refbase\":\"KMD\",\"refrel\":\"BTC\",\"factor\":15000,\"margin\":-0.2}" curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"HUSH\",\"rel\":\"KMD\",\"margin\":$margin,\"refbase\":\"hush\",\"refrel\":\"coinmarketcap\"}" From 5813a5b624818274562841569f1922e769274f00 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 26 Feb 2018 07:51:24 +0200 Subject: [PATCH 188/197] Test --- iguana/exchanges/prices/autoprice | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/prices/autoprice b/iguana/exchanges/prices/autoprice index 89607c48f..1b24f38c2 100755 --- a/iguana/exchanges/prices/autoprice +++ b/iguana/exchanges/prices/autoprice @@ -45,7 +45,7 @@ curl --url "http://127.0.0.1:7783" --data "{\"margin\":$margin,\"base\":\"SUPERN curl --url "http://127.0.0.1:7783" --data "{\"margin\":$margin,\"base\":\"HODL\",\"rel\":\"KMD\",\"fundvalue_bid\":\"assetNAV_KMD\",\"fundvalue_ask\":\"assetNAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"address\":\"RNcUaMUEFLxVwtTo7rgruhwYanGk1jTkeU\",\"holdings\":[{\"coin\":\"siacoin\",\"balance\":185000000,\"comment\":\"using siafunds equal to million siacoin\"}],\"divisor\":10000000}" -dexholdings="{\"coin\":\"blocknet\",\"balance\":4975836}" +dexholdings="{\"coin\":\"blocknet\",\"balance\":4000000}" curl --url "http://127.0.0.1:7783" --data "{\"base\":\"DEX\",\"rel\":\"KMD\",\"margin\":$margin,\"fundvalue_bid\":\"assetNAV_KMD\",\"fundvalue_ask\":\"assetNAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"address\":\"RThtXup6Zo7LZAi8kRWgjAyi1s4u6U9Cpf\",\"holdings\":[$dexholdings],\"divisor\":1000000}" curl --url "http://127.0.0.1:7783" --data "{\"base\":\"BOTS\",\"rel\":\"KMD\",\"margin\":$margin,\"fundvalue_bid\":\"assetNAV_KMD\",\"fundvalue_ask\":\"assetNAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"address\":\"RNdqHx26GWy9bk8MtmH1UiXjQcXE4RKK2P\",\"holdings\":[$dexholdings],\"divisor\":3333333}" From bd22e265dd85a84175eadc33901312d1ffd48d4c Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 26 Feb 2018 08:58:26 +0200 Subject: [PATCH 189/197] Test --- iguana/exchanges/LP_peers.c | 2 +- iguana/exchanges/LP_rpc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_peers.c b/iguana/exchanges/LP_peers.c index 42bb8986f..6a5b7c311 100644 --- a/iguana/exchanges/LP_peers.c +++ b/iguana/exchanges/LP_peers.c @@ -275,7 +275,7 @@ void LP_peer_recv(char *ipaddr,int32_t ismine,struct LP_pubkey_info *pubp) if ( (peer= LP_peerfind((uint32_t)calc_ipbits(ipaddr),RPC_port)) != 0 ) { peer->numrecv++; - if ( ismine != 0 && bits256_cmp(G.LP_mypub25519,pubp->pubkey) != 0 && (bits256_nonz(peer->pubkey) == 0 || pubp->pairsock < 0) ) + if ( ismine != 0 && bits256_cmp(G.LP_mypub25519,pubp->pubkey) != 0 && (bits256_cmp(peer->pubkey,pubp->pubkey) != 0 || pubp->pairsock != peer->pairsock) ) { peer->pubkey = pubp->pubkey; pubp->pairsock = peer->pairsock; diff --git a/iguana/exchanges/LP_rpc.c b/iguana/exchanges/LP_rpc.c index 5d80cf06f..b8e20e017 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -656,7 +656,7 @@ again: best = fastest; retstr = calloc(1,16); sprintf(retstr,"%0.8f",((double)best * 1024)/SATOSHIDEN); - printf("LP_getestimatedrate (%s) -> %s\n",jprint(retjson,0),retstr); + //printf("LP_getestimatedrate (%s) -> %s\n",jprint(retjson,0),retstr); free(retjson); } /*if ( (retjson= electrum_estimatefee(coin->symbol,coin->electrum,&retjson,numblocks)) != 0 ) From c9f1818faf37ba35856dfc3b480c71dd0aa601c8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 26 Feb 2018 09:49:32 +0200 Subject: [PATCH 190/197] Fix swap status crash --- iguana/exchanges/LP_remember.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 254441454..e078e7082 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -1811,7 +1811,7 @@ char *basilisk_swapentries(char *refbase,char *refrel,int32_t limit) if ( ridqid == 0 || j == count ) { if ( basilisk_swap_addarray(pending,refbase,refrel) > 0 ) - jaddi(retarray,pending); + jaddi(retarray,jduplicate(pending)); else free_json(pending); } else free_json(pending); } From 15802718baff6a1c29cdd6d26be4403ffc75c37b Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 26 Feb 2018 11:13:39 +0200 Subject: [PATCH 191/197] Timelock --- iguana/exchanges/LP_commands.c | 5 +++ iguana/exchanges/LP_instantdex.c | 29 +++++++++++++ iguana/exchanges/LP_ordermatch.c | 4 +- iguana/exchanges/LP_transaction.c | 69 ++++++++++++++++++++++++++----- iguana/exchanges/timelock | 3 ++ 5 files changed, 97 insertions(+), 13 deletions(-) create mode 100755 iguana/exchanges/timelock diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index b7be20389..585e68745 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -163,6 +163,7 @@ bot_pause(botid)\n\ calcaddress(passphrase)\n\ instantdex_deposit(weeks, amount, broadcast=1)\n\ instantdex_claim()\n\ +timelock(coin, duration, destaddr=(tradeaddr), amount)\n\ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\ \"}")); //sell(base, rel, price, basevolume, timeout=10, duration=3600)\n\ @@ -511,6 +512,10 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\ { return(LP_sendrawtransaction(coin,jstr(argjson,"signedtx"))); } + else if ( strcmp(method,"timelock") == 0 ) + { + return(LP_timelock(coin,juint(argjson,"duration"),jstr(argjson,"destaddr"),jdouble(argjson,"amount")*SATOSHIDEN)); + } else if ( strcmp(method,"getrawtransaction") == 0 ) { return(jprint(LP_gettx(coin,jbits256(argjson,"txid"),0),1)); diff --git a/iguana/exchanges/LP_instantdex.c b/iguana/exchanges/LP_instantdex.c index e3215ba5f..019e5e644 100644 --- a/iguana/exchanges/LP_instantdex.c +++ b/iguana/exchanges/LP_instantdex.c @@ -164,6 +164,35 @@ int32_t LP_deposit_addr(char *symbol,char *p2shaddr,uint8_t *script,uint8_t tadd return(n); } +char *LP_timelock(char *symbol,uint32_t duration,char *destaddr,uint64_t satoshis) +{ + struct iguana_info *coin; uint32_t expiration; char *retstr,p2shaddr[64],redeemscript[256]; cJSON *argjson,*array,*item; int32_t n=0; uint8_t addrtype,rmd160[20],p2sh160[20],script[40]; + if ( (coin= LP_coinfind(symbol)) != 0 ) + { + expiration = (uint32_t)time(NULL) + duration; + if ( destaddr == 0 ) + destaddr = coin->smartaddr; + bitcoin_addr2rmd160(symbol,coin->taddr,&addrtype,rmd160,destaddr); + n = bitcoin_timelockspend(script,0,rmd160,expiration); + init_hexbytes_noT(redeemscript,script,n); + calc_rmd160_sha256(p2sh160,script,n); + bitcoin_address(symbol,p2shaddr,coin->taddr,coin->p2shtype,p2sh160,20); + argjson = cJSON_CreateObject(); + array = cJSON_CreateArray(); + item = cJSON_CreateObject(); + jaddnum(item,p2shaddr,dstr(satoshis)); + jaddi(array,item); + jadd(argjson,"outputs",array); + jaddstr(argjson,"opreturn",redeemscript); + //printf("deposit.(%s)\n",jprint(argjson,0)); + if ( (retstr= LP_withdraw(coin,argjson)) != 0 ) + { + printf("timelock.(%s)\n",retstr); + return(retstr); + } else return(clonestr("{\"error\":\"null return from LP_withdraw\"}")); + } else return(clonestr("{\"error\":\"cant find coin\"}")); +} + char *LP_instantdex_deposit(struct iguana_info *coin,int32_t weeks,double amount,int32_t broadcast) { char p2shaddr[64],*retstr,*hexstr; uint8_t script[512]; int32_t weeki,scriptlen; cJSON *argjson,*retjson,*array,*item,*obj; uint32_t timestamp; bits256 txid,sendtxid; uint64_t amount64; diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index 7794e3bca..715e027f1 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -500,10 +500,10 @@ int32_t LP_connectstartbob(void *ctx,int32_t pubsock,char *base,char *rel,double //char str[65]; printf("BOB pubsock.%d binds to %d (%s)\n",pubsock,pair,bits256_str(str,qp->desthash)); bits256 zero; memset(zero.bytes,0,sizeof(zero)); - for (i=0; i<10; i++) + for (i=0; i<3; i++) { LP_reserved_msg(1,qp->srccoin,qp->destcoin,qp->desthash,jprint(reqjson,0)); - sleep(3); + sleep(10); if ( swap->received != 0 ) { printf("swap %u-%u has started t%u\n",swap->I.req.requestid,swap->I.req.quoteid,swap->received); diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index 5509e9b15..bdc3cf94b 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -1199,10 +1199,10 @@ int32_t LP_vins_select(void *ctx,struct iguana_info *coin,int64_t *totalp,int64_ return(n); } -char *LP_createrawtransaction(cJSON **txobjp,int32_t *numvinsp,struct iguana_info *coin,struct vin_info *V,int32_t max,bits256 privkey,cJSON *outputs,cJSON *vins,cJSON *privkeys,int64_t txfee,bits256 utxotxid,int32_t utxovout,uint32_t locktime) +char *LP_createrawtransaction(cJSON **txobjp,int32_t *numvinsp,struct iguana_info *coin,struct vin_info *V,int32_t max,bits256 privkey,cJSON *outputs,cJSON *vins,cJSON *privkeys,int64_t txfee,bits256 utxotxid,int32_t utxovout,uint32_t locktime,char *opretstr) { static void *ctx; - cJSON *txobj,*item; uint8_t addrtype,rmd160[20],script[64],spendscript[256]; char *coinaddr,*rawtxbytes; bits256 txid; uint32_t timestamp; int64_t change=0,adjust=0,total,value,amount = 0; int32_t i,dustcombine,scriptlen,spendlen,suppress_pubkeys,ignore_cltverr,numvouts=0,numvins=0,numutxos=0; struct LP_address_utxo *utxos[LP_MAXVINS*256]; struct LP_address *ap; + cJSON *txobj,*item; uint8_t addrtype,rmd160[20],script[8192],spendscript[256]; char *coinaddr,*rawtxbytes,*scriptstr; bits256 txid; uint32_t timestamp; int64_t change=0,adjust=0,total,value,amount = 0; int32_t i,len,dustcombine,scriptlen,spendlen,suppress_pubkeys,ignore_cltverr,numvouts=0,numvins=0,numutxos=0; struct LP_address_utxo *utxos[LP_MAXVINS*256]; struct LP_address *ap; if ( ctx == 0 ) ctx = bitcoin_ctx(); *numvinsp = 0; @@ -1297,15 +1297,32 @@ char *LP_createrawtransaction(cJSON **txobjp,int32_t *numvinsp,struct iguana_inf free_json(txobj); return(0); } - bitcoin_addr2rmd160(coin->symbol,coin->taddr,&addrtype,rmd160,coinaddr); - if ( addrtype == coin->pubtype ) - spendlen = bitcoin_standardspend(spendscript,0,rmd160); - else spendlen = bitcoin_p2shspend(spendscript,0,rmd160); - if ( i == numvouts-1 && strcmp(coinaddr,coin->smartaddr) == 0 && change != 0 ) + if ( (scriptstr= jstr(item,"script")) != 0 ) { - printf("combine last vout %.8f with change %.8f\n",dstr(value+adjust),dstr(change)); - value += change; - change = 0; + spendlen = (int32_t)strlen(scriptstr) >> 1; + if ( spendlen < sizeof(script) ) + { + decode_hex(script,spendlen,scriptstr); + printf("i.%d using external script.(%s)\n",i,scriptstr); + } + else + { + printf("custom script.%d too long %d\n",i,spendlen); + return(0); + } + } + else + { + bitcoin_addr2rmd160(coin->symbol,coin->taddr,&addrtype,rmd160,coinaddr); + if ( addrtype == coin->pubtype ) + spendlen = bitcoin_standardspend(spendscript,0,rmd160); + else spendlen = bitcoin_p2shspend(spendscript,0,rmd160); + if ( i == numvouts-1 && strcmp(coinaddr,coin->smartaddr) == 0 && change != 0 ) + { + printf("combine last vout %.8f with change %.8f\n",dstr(value+adjust),dstr(change)); + value += change; + change = 0; + } } txobj = bitcoin_txoutput(txobj,spendscript,spendlen,value + adjust); } @@ -1323,6 +1340,36 @@ char *LP_createrawtransaction(cJSON **txobjp,int32_t *numvinsp,struct iguana_inf } if ( change != 0 ) txobj = bitcoin_txoutput(txobj,script,scriptlen,change); + if ( opretstr != 0 ) + { + spendlen = (int32_t)strlen(opretstr) >> 1; + if ( spendlen < sizeof(script) ) + { + len = 0; + script[len++] = SCRIPT_OP_RETURN; + if ( spendlen < 76 ) + script[len++] = spendlen; + else if ( spendlen <= 0xff ) + { + script[len++] = 0x4c; + script[len++] = spendlen; + } + else if ( spendlen <= 0xffff ) + { + script[len++] = 0x4d; + script[len++] = (spendlen & 0xff); + script[len++] = ((spendlen >> 8) & 0xff); + } + decode_hex(&script[len],spendlen,opretstr); + txobj = bitcoin_txoutput(txobj,len + script,scriptlen,change); + printf("OP_RETURN.[%d, %d] script.(%s)\n",len,spendlen,opretstr); + } + else + { + printf("custom script.%d too long %d\n",i,spendlen); + return(0); + } + } if ( (rawtxbytes= bitcoin_json2hex(coin->symbol,coin->isPoS,&txid,txobj,V)) != 0 ) { } else printf("error making rawtx suppress.%d\n",suppress_pubkeys); @@ -1378,7 +1425,7 @@ char *LP_withdraw(struct iguana_info *coin,cJSON *argjson) vins = cJSON_CreateArray(); memset(V,0,sizeof(*V) * maxV); numvins = 0; - if ( (rawtx= LP_createrawtransaction(&txobj,&numvins,coin,V,maxV,privkey,outputs,vins,privkeys,iter == 0 ? txfee : newtxfee,utxotxid,utxovout,locktime)) != 0 ) + if ( (rawtx= LP_createrawtransaction(&txobj,&numvins,coin,V,maxV,privkey,outputs,vins,privkeys,iter == 0 ? txfee : newtxfee,utxotxid,utxovout,locktime,jstr(argjson,"opreturn"))) != 0 ) { completed = 0; memset(&msgtx,0,sizeof(msgtx)); diff --git a/iguana/exchanges/timelock b/iguana/exchanges/timelock new file mode 100755 index 000000000..a3fc3b688 --- /dev/null +++ b/iguana/exchanges/timelock @@ -0,0 +1,3 @@ +#!/bin/bash +source userpass +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"timelock\",\"coin\":\"KMD\",\"duration\":1000,\"amount\":1}" From 38fdc8b86b4155851d96afcf910086e3643b80f2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 26 Feb 2018 11:18:24 +0200 Subject: [PATCH 192/197] Test --- iguana/exchanges/LP_transaction.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index bdc3cf94b..f234cda5b 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -1361,7 +1361,7 @@ char *LP_createrawtransaction(cJSON **txobjp,int32_t *numvinsp,struct iguana_inf script[len++] = ((spendlen >> 8) & 0xff); } decode_hex(&script[len],spendlen,opretstr); - txobj = bitcoin_txoutput(txobj,len + script,scriptlen,change); + txobj = bitcoin_txoutput(txobj,script,len + scriptlen,change); printf("OP_RETURN.[%d, %d] script.(%s)\n",len,spendlen,opretstr); } else From 8d5561a3ce5e59a00ecc55fa05508cd713f51e6f Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 26 Feb 2018 11:27:05 +0200 Subject: [PATCH 193/197] Test --- iguana/exchanges/LP_transaction.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index f234cda5b..eb4e5d8c2 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -1361,7 +1361,7 @@ char *LP_createrawtransaction(cJSON **txobjp,int32_t *numvinsp,struct iguana_inf script[len++] = ((spendlen >> 8) & 0xff); } decode_hex(&script[len],spendlen,opretstr); - txobj = bitcoin_txoutput(txobj,script,len + scriptlen,change); + txobj = bitcoin_txoutput(txobj,script,len + spendlen,0); printf("OP_RETURN.[%d, %d] script.(%s)\n",len,spendlen,opretstr); } else From d04ccc1e8b24042bd4154afcab3f145ebfca9415 Mon Sep 17 00:00:00 2001 From: Mihail Fedorov Date: Mon, 26 Feb 2018 18:56:51 +0300 Subject: [PATCH 194/197] NINJA coin --- iguana/iguana_notary.c | 2 +- iguana/m_splitfund | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index 23729cacd..dc46acee9 100755 --- a/iguana/iguana_notary.c +++ b/iguana/iguana_notary.c @@ -570,7 +570,7 @@ STRING_ARG(iguana,addnotary,ipaddr) } char NOTARY_CURRENCIES[][16] = { - "REVS", "SUPERNET", "DEX", "PANGEA", "JUMBLR", "BET", "CRYPTO", "HODL", "BOTS", "MGW", "COQUI", "WLC", "KV", "CEAL", "MESH", "MNZ", "CHIPS", "MSHARK", "AXO", "ETOMIC", "BTCH", "VOTE2018", "CHAIN" }; // "LTC", "USD", "EUR", "JPY", "GBP", "AUD", "CAD", "CHF", "NZD", "CNY", "RUB", "MXN", "BRL", "INR", "HKD", "TRY", "ZAR", "PLN", "NOK", "SEK", "DKK", "CZK", "HUF", "ILS", "KRW", "MYR", "PHP", "RON", "SGD", "THB", "BGN", "IDR", "HRK", + "REVS", "SUPERNET", "DEX", "PANGEA", "JUMBLR", "BET", "CRYPTO", "HODL", "BOTS", "MGW", "COQUI", "WLC", "KV", "CEAL", "MESH", "MNZ", "CHIPS", "MSHARK", "AXO", "ETOMIC", "BTCH", "VOTE2018", "NINJA", "CHAIN" }; // "LTC", "USD", "EUR", "JPY", "GBP", "AUD", "CAD", "CHF", "NZD", "CNY", "RUB", "MXN", "BRL", "INR", "HKD", "TRY", "ZAR", "PLN", "NOK", "SEK", "DKK", "CZK", "HUF", "ILS", "KRW", "MYR", "PHP", "RON", "SGD", "THB", "BGN", "IDR", "HRK", void _iguana_notarystats(char *fname,int32_t totals[64],int32_t dispflag) { diff --git a/iguana/m_splitfund b/iguana/m_splitfund index 2a017d39c..b0aa189aa 100755 --- a/iguana/m_splitfund +++ b/iguana/m_splitfund @@ -27,3 +27,4 @@ curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"BTCH\",\"agent\":\"iguana curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"ETOMIC\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":10}" curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"VOTE2018\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":10}" curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"CHIPS\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":10}" +curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"NINJA\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":10}" From 52ecaaea0cf590fe3f2e21a56e803033c7a8eaa9 Mon Sep 17 00:00:00 2001 From: Mihail Fedorov Date: Mon, 26 Feb 2018 18:58:13 +0300 Subject: [PATCH 195/197] NINJA coin --- iguana/coins/ninja_7776 | 1 + 1 file changed, 1 insertion(+) create mode 100755 iguana/coins/ninja_7776 diff --git a/iguana/coins/ninja_7776 b/iguana/coins/ninja_7776 new file mode 100755 index 000000000..bb895089e --- /dev/null +++ b/iguana/coins/ninja_7776 @@ -0,0 +1 @@ +curl --url "http://127.0.0.1:7776" --data "{\"conf\":\"NINJA.conf\",\"path\":\"${HOME#"/"}/.komodo/NINJA\",\"unitval\":\"20\",\"zcash\":1,\"RELAY\":-1,\"VALIDATE\":0,\"prefetchlag\":-1,\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":4,\"endpend\":4,\"services\":129,\"maxpeers\":8,\"newcoin\":\"NINJA\",\"name\":\"NINJA\",\"hasheaders\":1,\"useaddmultisig\":0,\"netmagic\":\"78a7bd45\",\"p2p\":15430,\"rpc\":15431,\"pubval\":60,\"p2shval\":85,\"wifval\":188,\"txfee_satoshis\":\"10000\",\"isPoS\":0,\"minoutput\":10000,\"minconfirms\":2,\"genesishash\":\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\",\"protover\":170002,\"genesisblock\":\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\",\"debug\":0,\"seedipaddr\":\"192.241.134.19\"}" From 41989117d6b624cd1ed3765168f6e7f114b55446 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 26 Feb 2018 18:56:03 +0200 Subject: [PATCH 196/197] Timelock/unlockspend --- iguana/exchanges/LP_commands.c | 5 ++ iguana/exchanges/LP_instantdex.c | 135 ++++++++++++++++++++++++------- iguana/exchanges/LP_ordermatch.c | 9 ++- iguana/exchanges/unlockedspend | 3 + 4 files changed, 119 insertions(+), 33 deletions(-) create mode 100755 iguana/exchanges/unlockedspend diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index 585e68745..be3c73466 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -164,6 +164,7 @@ calcaddress(passphrase)\n\ instantdex_deposit(weeks, amount, broadcast=1)\n\ instantdex_claim()\n\ timelock(coin, duration, destaddr=(tradeaddr), amount)\n\ +unlockedspend(coin, txid)\n\ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\ \"}")); //sell(base, rel, price, basevolume, timeout=10, duration=3600)\n\ @@ -516,6 +517,10 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\ { return(LP_timelock(coin,juint(argjson,"duration"),jstr(argjson,"destaddr"),jdouble(argjson,"amount")*SATOSHIDEN)); } + else if ( strcmp(method,"unlockedspend") == 0 ) + { + return(LP_unlockedspend(ctx,coin,jbits256(argjson,"txid"))); + } else if ( strcmp(method,"getrawtransaction") == 0 ) { return(jprint(LP_gettx(coin,jbits256(argjson,"txid"),0),1)); diff --git a/iguana/exchanges/LP_instantdex.c b/iguana/exchanges/LP_instantdex.c index 019e5e644..9552ab367 100644 --- a/iguana/exchanges/LP_instantdex.c +++ b/iguana/exchanges/LP_instantdex.c @@ -164,35 +164,6 @@ int32_t LP_deposit_addr(char *symbol,char *p2shaddr,uint8_t *script,uint8_t tadd return(n); } -char *LP_timelock(char *symbol,uint32_t duration,char *destaddr,uint64_t satoshis) -{ - struct iguana_info *coin; uint32_t expiration; char *retstr,p2shaddr[64],redeemscript[256]; cJSON *argjson,*array,*item; int32_t n=0; uint8_t addrtype,rmd160[20],p2sh160[20],script[40]; - if ( (coin= LP_coinfind(symbol)) != 0 ) - { - expiration = (uint32_t)time(NULL) + duration; - if ( destaddr == 0 ) - destaddr = coin->smartaddr; - bitcoin_addr2rmd160(symbol,coin->taddr,&addrtype,rmd160,destaddr); - n = bitcoin_timelockspend(script,0,rmd160,expiration); - init_hexbytes_noT(redeemscript,script,n); - calc_rmd160_sha256(p2sh160,script,n); - bitcoin_address(symbol,p2shaddr,coin->taddr,coin->p2shtype,p2sh160,20); - argjson = cJSON_CreateObject(); - array = cJSON_CreateArray(); - item = cJSON_CreateObject(); - jaddnum(item,p2shaddr,dstr(satoshis)); - jaddi(array,item); - jadd(argjson,"outputs",array); - jaddstr(argjson,"opreturn",redeemscript); - //printf("deposit.(%s)\n",jprint(argjson,0)); - if ( (retstr= LP_withdraw(coin,argjson)) != 0 ) - { - printf("timelock.(%s)\n",retstr); - return(retstr); - } else return(clonestr("{\"error\":\"null return from LP_withdraw\"}")); - } else return(clonestr("{\"error\":\"cant find coin\"}")); -} - char *LP_instantdex_deposit(struct iguana_info *coin,int32_t weeks,double amount,int32_t broadcast) { char p2shaddr[64],*retstr,*hexstr; uint8_t script[512]; int32_t weeki,scriptlen; cJSON *argjson,*retjson,*array,*item,*obj; uint32_t timestamp; bits256 txid,sendtxid; uint64_t amount64; @@ -314,6 +285,112 @@ int64_t LP_claimtx(void *ctx,struct iguana_info *coin,bits256 *claimtxidp,bits25 return(sum); } +uint32_t LP_claimtime(struct iguana_info *coin,uint32_t expiration) +{ + uint32_t heighttime,now = (uint32_t)time(NULL); + heighttime = LP_heighttime(coin->symbol,coin->height); + printf("claimtime: now %u height.%d heighttime.%u expiration.%u\n",now,coin->height,heighttime,expiration); + if ( heighttime >= expiration ) + return(heighttime + 1); + return(0); +} + +char *LP_unlockedspend(void *ctx,char *symbol,bits256 utxotxid) +{ + cJSON *txjson,*vouts,*vout0,*opret,*sobj,*retjson; uint16_t utxovout; char *signedtx,*opretstr,vinaddr[64],destaddr[64]; uint32_t expiration,claimtime; uint8_t redeemscript[128]; bits256 signedtxid,sendtxid; int32_t numvouts,redeemlen; int64_t satoshis,destamount; struct iguana_info *coin; + if ( (coin= LP_coinfind(symbol)) == 0 ) + return(clonestr("{\"error\":\"cant find coin\"}")); + retjson = cJSON_CreateObject(); + utxovout = 0; + memset(&sendtxid,0,sizeof(sendtxid)); + if ( (txjson= LP_gettx(coin->symbol,utxotxid,1)) != 0 ) + { + if ( (vouts= jarray(&numvouts,txjson,"vout")) != 0 && numvouts >= 2 ) + { + vout0 = jitem(vouts,0); + LP_destaddr(vinaddr,vout0); + satoshis = LP_value_extract(vout0,0); + opret = jitem(vouts,numvouts - 1); + jaddstr(retjson,"result","success"); + jaddbits256(retjson,"lockedtxid",utxotxid); + jaddnum(retjson,"amount",dstr(satoshis)); + if ( (sobj= jobj(opret,"scriptPubKey")) != 0 ) + { + if ( (opretstr= jstr(sobj,"hex")) != 0 ) + { + jaddstr(retjson,"opreturn",opretstr); + redeemlen = (int32_t)strlen(opretstr) >> 1; + if ( redeemlen == 34 ) + { + decode_hex(redeemscript,redeemlen,opretstr); + if ( redeemscript[0] == SCRIPT_OP_RETURN && redeemscript[1] == 32 && redeemscript[2] == 4 && redeemscript[7] == 0xb1 && redeemscript[8] == 0x75 && redeemscript[9] == 0x76 && redeemscript[10] == 0xa9 && redeemscript[11] == 0x14 && redeemscript[32] == 0x88 && redeemscript[33] == 0xac ) + { + expiration = 0; + expiration = (expiration << 8) | redeemscript[3]; + expiration = (expiration << 8) | redeemscript[4]; + expiration = (expiration << 8) | redeemscript[5]; + expiration = (expiration << 8) | redeemscript[6]; + bitcoin_address(symbol,destaddr,coin->taddr,coin->pubtype,&redeemscript[12],20); + jaddstr(retjson,"address",destaddr); + jaddnum(retjson,"expiration",expiration); + claimtime = LP_claimtime(coin,expiration); + jaddnum(retjson,"claimtime",claimtime); + if ( claimtime != 0 && strcmp(destaddr,coin->smartaddr) == 0 && time(NULL) > expiration ) + { + char str[65]; printf("LP_timespend satoshis %.8f %s/v%d\n",dstr(satoshis - coin->txfee),bits256_str(str,utxotxid),utxovout); + if ( (signedtx= basilisk_swap_bobtxspend(&signedtxid,coin->txfee,"timespend",coin->symbol,coin->wiftaddr,coin->taddr,coin->pubtype,coin->p2shtype,coin->isPoS,coin->wiftype,ctx,G.LP_privkey,0,redeemscript+2,redeemlen-2,0,0,utxotxid,utxovout,coin->smartaddr,G.LP_pubsecp,0,claimtime,&destamount,0,0,vinaddr,0,coin->zcash)) != 0 ) + { + //sendtxid = LP_broadcast("timespend",symbol,signedtx,signedtxid); + jaddstr(retjson,"signedtx",signedtx); + jaddbits256(retjson,"txid",signedtxid); + if ( bits256_cmp(sendtxid,signedtxid) == 0 ) + jaddbits256(retjson,"sendtxid",sendtxid); + else printf("error sending %s\n",bits256_str(str,signedtxid)); + free(signedtx); + } + else + { + printf("error doing timespend %s/v%d %.8f\n",bits256_str(str,utxotxid),utxovout,dstr(satoshis)); + jaddstr(retjson,"error","couldnt sign timespend"); + } + } + } else jaddstr(retjson,"error","mismatched redeemscript"); + } + } + } + } + free_json(txjson); + } + return(jprint(retjson,1)); +} + +char *LP_timelock(char *symbol,uint32_t duration,char *destaddr,uint64_t satoshis) +{ + struct iguana_info *coin; uint32_t expiration; char *retstr,p2shaddr[64],redeemscript[256]; cJSON *argjson,*array,*item; int32_t n=0; uint8_t addrtype,rmd160[20],p2sh160[20],script[40]; + if ( (coin= LP_coinfind(symbol)) != 0 ) + { + expiration = (uint32_t)time(NULL) + duration; + if ( destaddr == 0 ) + destaddr = coin->smartaddr; + bitcoin_addr2rmd160(symbol,coin->taddr,&addrtype,rmd160,destaddr); + n = bitcoin_timelockspend(script,0,rmd160,expiration); + init_hexbytes_noT(redeemscript,script,n); + calc_rmd160_sha256(p2sh160,script,n); + bitcoin_address(symbol,p2shaddr,coin->taddr,coin->p2shtype,p2sh160,20); + argjson = cJSON_CreateObject(); + array = cJSON_CreateArray(); + item = cJSON_CreateObject(); + jaddnum(item,p2shaddr,dstr(satoshis + coin->txfee)); + jaddi(array,item); + jadd(argjson,"outputs",array); + jaddstr(argjson,"opreturn",redeemscript); + //printf("deposit.(%s)\n",jprint(argjson,0)); + if ( (retstr= LP_withdraw(coin,argjson)) != 0 ) + return(retstr); + else return(clonestr("{\"error\":\"timelock got null return from LP_withdraw\"}")); + } else return(clonestr("{\"error\":\"cant find coin\"}")); +} + int32_t LP_claim_submit(void *ctx,cJSON *txids,int64_t *sump,struct iguana_info *coin,bits256 utxotxid) { uint8_t redeemscript[512]; bits256 claimtxid; cJSON *txjson,*vout0,*vout1,*vout2,*vouts,*item; int32_t numvouts; char str[65],vinaddr[64],destaddr[64],checkaddr[64]; int32_t j,utxovout,flagi = 0,redeemlen,weeki,iter; int64_t weeksatoshis,satoshis; uint32_t expiration,claimtime; diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index 715e027f1..9b9372cf9 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -498,11 +498,15 @@ int32_t LP_connectstartbob(void *ctx,int32_t pubsock,char *base,char *rel,double if ( (kmdcoin= LP_coinfind("KMD")) != 0 ) jadd(reqjson,"proof",LP_instantdex_txids(0,kmdcoin->smartaddr)); //char str[65]; printf("BOB pubsock.%d binds to %d (%s)\n",pubsock,pair,bits256_str(str,qp->desthash)); + LP_importaddress(qp->destcoin,qp->destaddr); + LP_otheraddress(qp->srccoin,otheraddr,qp->destcoin,qp->destaddr); + LP_importaddress(qp->srccoin,otheraddr); bits256 zero; memset(zero.bytes,0,sizeof(zero)); - for (i=0; i<3; i++) + for (i=0; i<1; i++) { LP_reserved_msg(1,qp->srccoin,qp->destcoin,qp->desthash,jprint(reqjson,0)); + break; sleep(10); if ( swap->received != 0 ) { @@ -513,9 +517,6 @@ int32_t LP_connectstartbob(void *ctx,int32_t pubsock,char *base,char *rel,double LP_reserved_msg(1,qp->srccoin,qp->destcoin,zero,jprint(reqjson,0)); } free_json(reqjson); - LP_importaddress(qp->destcoin,qp->destaddr); - LP_otheraddress(qp->srccoin,otheraddr,qp->destcoin,qp->destaddr); - LP_importaddress(qp->srccoin,otheraddr); retval = 0; } else printf("error launching swaploop\n"); } else printf("couldnt bind to any port %s\n",pairstr); diff --git a/iguana/exchanges/unlockedspend b/iguana/exchanges/unlockedspend new file mode 100755 index 000000000..f6f40c191 --- /dev/null +++ b/iguana/exchanges/unlockedspend @@ -0,0 +1,3 @@ +#!/bin/bash +source userpass +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"unlockedspend\",\"coin\":\"KMD\",\"txid\":\"e858e382a816b4cab22e3fd3e29901c7ef497cd1fdad7683314cc9187eca34fd\"}" From b7ffefdc1bf4747a868f845d15d33f767c83316a Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 26 Feb 2018 18:58:20 +0200 Subject: [PATCH 197/197] Test --- iguana/exchanges/LP_instantdex.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_instantdex.c b/iguana/exchanges/LP_instantdex.c index 9552ab367..02c584080 100644 --- a/iguana/exchanges/LP_instantdex.c +++ b/iguana/exchanges/LP_instantdex.c @@ -326,10 +326,10 @@ char *LP_unlockedspend(void *ctx,char *symbol,bits256 utxotxid) if ( redeemscript[0] == SCRIPT_OP_RETURN && redeemscript[1] == 32 && redeemscript[2] == 4 && redeemscript[7] == 0xb1 && redeemscript[8] == 0x75 && redeemscript[9] == 0x76 && redeemscript[10] == 0xa9 && redeemscript[11] == 0x14 && redeemscript[32] == 0x88 && redeemscript[33] == 0xac ) { expiration = 0; - expiration = (expiration << 8) | redeemscript[3]; - expiration = (expiration << 8) | redeemscript[4]; - expiration = (expiration << 8) | redeemscript[5]; expiration = (expiration << 8) | redeemscript[6]; + expiration = (expiration << 8) | redeemscript[5]; + expiration = (expiration << 8) | redeemscript[4]; + expiration = (expiration << 8) | redeemscript[3]; bitcoin_address(symbol,destaddr,coin->taddr,coin->pubtype,&redeemscript[12],20); jaddstr(retjson,"address",destaddr); jaddnum(retjson,"expiration",expiration);