Browse Source

Test

etomic
jl777 7 years ago
parent
commit
c4ceb558a8
  1. 2
      iguana/dpow/dpow_rpc.c
  2. 6
      iguana/exchanges/LP_commands.c
  3. 3
      iguana/exchanges/LP_nativeDEX.c
  4. 6
      iguana/exchanges/LP_ordermatch.c
  5. 1
      iguana/exchanges/LP_prices.c

2
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);

6
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 )

3
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.
//

6
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);

1
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);

Loading…
Cancel
Save