diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index f69d68886..6da004617 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -394,7 +394,7 @@ cJSON *dpow_listunspent(struct supernet_info *myinfo,struct iguana_info *coin,ch char buf[128],*retstr; cJSON *array,*json = 0; if ( coin->FULLNODE < 0 ) { - sprintf(buf,"0, 99999999, [\"%s\"]",coinaddr); + sprintf(buf,"1, 99999999, [\"%s\"]",coinaddr); if ( (retstr= bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"listunspent",buf)) != 0 ) { json = cJSON_Parse(retstr); diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index c57e9b3fd..8cad0c58c 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -436,7 +436,10 @@ stop()\n\ } } if ( strcmp(method,"postprice") == 0 ) + { + // LP_checksig retstr = LP_postedprice(argjson); + } else if ( strcmp(method,"postutxos") == 0 ) retstr = LP_postedutxos(argjson); else if ( strcmp(method,"getprices") == 0 ) @@ -496,7 +499,7 @@ stop()\n\ //printf("GOT ADDR_UNSPENTS %s %s\n",jstr(argjson,"coin"),jstr(argjson,"address")); if ( (ptr= LP_coinsearch(jstr(argjson,"coin"))) != 0 ) { - char *coinaddr; //cJSON *array,*item,*req; int32_t i,n,vout,height; bits256 zero,txid; uint64_t value; + char *coinaddr; if ( (coinaddr= jstr(argjson,"address")) != 0 ) { if ( coinaddr[0] != 0 ) @@ -535,6 +538,7 @@ stop()\n\ { char *rmd160str,*secpstr; bits256 pub; struct LP_pubkeyinfo *pubp; pub = jbits256(argjson,"pub"); + // LP_checksig if ( bits256_nonz(pub) != 0 && (rmd160str= jstr(argjson,"rmd160")) != 0 && strlen(rmd160str) == 40 ) { if ( (pubp= LP_pubkeyadd(pub)) != 0 ) diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 43db6df03..fcaaf1ee3 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -18,10 +18,9 @@ // LP_nativeDEX.c // marketmaker // +// sign critical api calls (pubkey reg, listunspent, orders?) // dPoW security -> 4: KMD notarized, 5: BTC notarized -// locktime to fee // new testchain -// sign critical api calls (pubkey reg, listunspent, orders?) // process stats.log local file -> map of realtime activity! // handles <-> pubkeys, deal with offline pubkeys, reputations, bonds etc. // diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index 5124c073d..86fcecf50 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -222,6 +222,7 @@ char *LP_quotereceived(cJSON *argjson) char *LP_pricepings(void *ctx,char *myipaddr,int32_t pubsock,char *base,char *rel,double price) { bits256 zero; cJSON *reqjson = cJSON_CreateObject(); + // LP_addsig memset(zero.bytes,0,sizeof(zero)); jaddbits256(reqjson,"pubkey",G.LP_mypub25519); jaddstr(reqjson,"base",base); @@ -235,6 +236,7 @@ char *LP_pricepings(void *ctx,char *myipaddr,int32_t pubsock,char *base,char *re void LP_notify_pubkeys(void *ctx,int32_t pubsock) { bits256 zero; char secpstr[67]; cJSON *reqjson = cJSON_CreateObject(); + // LP_addsig memset(zero.bytes,0,sizeof(zero)); jaddstr(reqjson,"method","notify"); jaddstr(reqjson,"rmd160",G.LP_myrmd160str); @@ -396,6 +398,7 @@ void LP_query(void *ctx,char *myipaddr,int32_t mypubsock,char *method,struct LP_ jaddbits256(reqjson,"pubkey",qp->srchash); jaddstr(reqjson,"method",method); msg = jprint(reqjson,1); + // LP_addsig printf("QUERY.(%s)\n",msg); memset(&zero,0,sizeof(zero)); portable_mutex_lock(&LP_reservedmutex); @@ -605,6 +608,7 @@ int32_t LP_connectstartbob(void *ctx,int32_t pubsock,struct LP_utxoinfo *utxo,cJ jaddstr(retjson,"pair",pairstr); jaddnum(retjson,"requestid",qp->R.requestid); jaddnum(retjson,"quoteid",qp->R.quoteid); + // LP_addsig char str[65]; printf("BOB pubsock.%d binds to %d (%s)\n",pubsock,pair,bits256_str(str,utxo->S.otherpubkey)); LP_reserved_msg(base,rel,utxo->S.otherpubkey,jprint(retjson,1)); retval = 0; @@ -827,6 +831,7 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson, char *method,*msg,*retstr,str[65]; int32_t DEXselector = 0; uint64_t value,value2; cJSON *retjson; double qprice,price,bid,ask; struct LP_utxoinfo A,B,*autxo,*butxo; struct iguana_info *coin; struct LP_address_utxo *utxos[1000]; struct LP_quoteinfo Q; int32_t retval = -1,max=(int32_t)(sizeof(utxos)/sizeof(*utxos)); if ( (method= jstr(argjson,"method")) != 0 && (strcmp(method,"reserved") == 0 ||strcmp(method,"connected") == 0 || strcmp(method,"request") == 0 || strcmp(method,"connect") == 0) ) { + // LP_checksig LP_quoteparse(&Q,argjson); LP_requestinit(&Q.R,Q.srchash,Q.desthash,Q.srccoin,Q.satoshis-2*Q.txfee,Q.destcoin,Q.destsatoshis-2*Q.desttxfee,Q.timestamp,Q.quotetime,DEXselector); LP_tradecommand_log(argjson); @@ -934,6 +939,7 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson, msg = jprint(retjson,1); butxo->T.lasttime = (uint32_t)time(NULL); printf("return after queued RESERVED: set swappending.%u accept qprice %.8f, min %.8f\n(%s)\n",butxo->T.swappending,qprice,price,msg); + // LP_addsig LP_reserved_msg(Q.srccoin,Q.destcoin,butxo->S.otherpubkey,msg); return(retval); } else printf("warning swappending.%u swap.%p\n",butxo->T.swappending,butxo->S.swap); diff --git a/iguana/exchanges/LP_prices.c b/iguana/exchanges/LP_prices.c index 58bb302ed..91b4d29cb 100644 --- a/iguana/exchanges/LP_prices.c +++ b/iguana/exchanges/LP_prices.c @@ -845,6 +845,7 @@ char *LP_pricestr(char *base,char *rel,double origprice) if ( LP_pricevalid(price) > 0 ) { retjson = cJSON_CreateObject(); + // LP_addsig jaddstr(retjson,"result","success"); jaddstr(retjson,"method","postprice"); jaddbits256(retjson,"pubkey",G.LP_mypub25519); diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index eaf6414f4..0c45df38c 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -1633,9 +1633,11 @@ int32_t LP_verify_otherfee(struct basilisk_swap *swap,uint8_t *data,int32_t data printf("otherfee amount %.8f -> %s vs %s locktime %u vs %u\n",dstr(swap->otherfee.I.amount),swap->otherfee.p2shaddr,swap->otherfee.I.destaddr,swap->otherfee.I.locktime,swap->I.started+1); if ( strcmp(swap->otherfee.I.destaddr,swap->otherfee.p2shaddr) == 0 ) { - printf("dexfee verified\n"); + if ( swap->otherfee.I.locktime == swap->I.started+1 ) + printf("dexfee verified\n"); + else printf("locktime mismatch in otherfee, reject %u vs %u\n",swap->otherfee.I.locktime,swap->I.started+1); return(0); - } + } else printf("destaddress mismatch in other fee, reject (%s) vs (%s)\n",swap->otherfee.I.destaddr,swap->otherfee.p2shaddr); } return(-1); } diff --git a/iguana/exchanges/sell b/iguana/exchanges/sell index 6410148c8..fccc4d61e 100755 --- a/iguana/exchanges/sell +++ b/iguana/exchanges/sell @@ -1,3 +1,3 @@ #!/bin/bash source userpass -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"sell\",\"base\":\"KMD\",\"rel\":\"BTC\",\"basevolume\":10.0\"price\":0.0005}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"sell\",\"base\":\"KMD\",\"rel\":\"BTC\",\"basevolume\":10.0\",price\":0.0005}" diff --git a/iguana/m_mm b/iguana/m_mm index f124ecaa1..b5ba405ca 100755 --- a/iguana/m_mm +++ b/iguana/m_mm @@ -1,3 +1,3 @@ cd secp256k1; ./m_unix; cd .. cd ../crypto777; ./m_LP; cd ../iguana -gcc -pg -o marketmaker -I../crypto777 exchanges/mm.c mini-gmp.c secp256k1.o ../agents/libcrypto777.a -lnanomsg -lcurl -lpthread -lm +gcc -g -o marketmaker -I../crypto777 exchanges/mm.c mini-gmp.c secp256k1.o ../agents/libcrypto777.a -lnanomsg -lcurl -lpthread -lm