From a02e3cabe3e9c4bf806970761700d953a0d0ca26 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 20 Sep 2016 07:24:01 -0300 Subject: [PATCH 1/7] test --- iguana/coins/basilisk | 2 ++ iguana/iguana_sign.c | 9 +++++++-- iguana/iguana_unspents.c | 2 ++ iguana/tests/decoderawtransaction | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/iguana/coins/basilisk b/iguana/coins/basilisk index 6306b6456..c56cc2a5a 100755 --- a/iguana/coins/basilisk +++ b/iguana/coins/basilisk @@ -2,3 +2,5 @@ curl --url "http://127.0.0.1:7778" --data "{\"poll\":100,\"active\":1,\"agent\": #curl --url "http://127.0.0.1:7778" --data "{\"prefetchlag\":5,\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTC\",\"startpend\":1,\"endpend\":1,\"services\":128,\"maxpeers\":16,\"RELAY\":0,\"VALIDATE\":0,\"portp2p\":8333}" #curl --url "http://127.0.0.1:7778" --data "{\"RELAY\":0,\"VALIDATE\":0,\"prefetchlag\":11,\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":1,\"endpend\":1,\"services\":128,\"maxpeers\":16,\"newcoin\":\"LTC\",\"name\":\"Litecoin\",\"hasheaders\":1,\"useaddmultisig\":0,\"netmagic\":\"fbc0b6db\",\"p2p\":9333,\"rpc\":9334,\"pubval\":48,\"p2shval\":5,\"wifval\":176,\"txfee_satoshis\":\"100000\",\"isPoS\":0,\"minoutput\":10000,\"minconfirms\":2,\"genesishash\":\"12a765e31ffd4059bada1e25190f6e98c99d9714d334efa41a195a7e7e04bfe2\",\"genesis\":{\"version\":1,\"timestamp\":1317972665,\"nBits\":\"1e0ffff0\",\"nonce\":2084524493,\"merkle_root\":\"97ddfbbae6be97fd6cdf3e7ca13232a3afff2353e29badfab7f73011edd4ced9\"},\"alertpubkey\":\"040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9\",\"protover\":70002}" +curl --url "http://127.0.0.1:7778" --data "{\"RELAY\":0,\"VALIDATE\":0,\"prefetchlag\":-1,\"poll\":10,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":18,\"endpend\":18,\"services\":129,\"maxpeers\":256,\"newcoin\":\"SYS\",\"name\":\"SYScoin\",\"hasheaders\":0,\"useaddmultisig\":0,\"netmagic\":\"f9beb4d9\",\"p2p\":8369,\"rpc\":8370,\"pubval\":0,\"p2shval\":5,\"wifval\":128,\"txfee_satoshis\":\"100000\",\"isPoS\":0,\"minoutput\":10000,\"minconfirms\":2,\"genesishash\":\"0000072d66e51ab87de265765cc8bdd2d229a4307c672a1b3d5af692519cf765\",\"genesis\":{\"version\":1,\"timestamp\":1450473723,\"nBits\":\"1e0ffff0\",\"nonce\":5258726,\"merkle_root\":\"5215c5a2af9b63f2550b635eb2b354bb13645fd8fa31275394eb161944303065\"},\"protover\":70012,\"auxpow\":1,\"fixit\":0}" + diff --git a/iguana/iguana_sign.c b/iguana/iguana_sign.c index 8204993c3..a731f16da 100755 --- a/iguana/iguana_sign.c +++ b/iguana/iguana_sign.c @@ -200,6 +200,11 @@ int32_t iguana_parsevinobj(struct supernet_info *myinfo,struct iguana_info *coin lastbyte = _decode_hex(&spendstr[strlen(spendstr)-2]); if ( lastbyte == SCRIPT_OP_CHECKMULTISIG ) need_op0 = 1; + if ( V != 0 ) + { + V->spendlen = (int32_t)strlen(spendstr) >> 1; + decode_hex(V->spendscript,V->spendlen,spendstr); + } } } if ( (redeemstr= jstr(vinobj,"redeemScript")) == 0 || is_hexstr(redeemstr,(int32_t)strlen(redeemstr)) <= 0 ) @@ -268,7 +273,7 @@ int32_t iguana_parsevinobj(struct supernet_info *myinfo,struct iguana_info *coin { if ( vin->vinscript == 0 ) { - printf("null vinscript case\n"); + //printf("null vinscript case -> need to sign this tx\n"); vin->vinscript = serialized; vin->vinscript[0] = 0; vin->scriptlen = 1; @@ -344,7 +349,7 @@ int32_t iguana_parsevinobj(struct supernet_info *myinfo,struct iguana_info *coin } //printf("output sequence.[%d] <- %x\n",len,vin->sequence); len += iguana_rwnum(rwflag,&serialized[len],sizeof(vin->sequence),&vin->sequence); - if ( spendstr != 0 ) + if ( 0 && spendstr != 0 ) { //printf("serialized.%p len.%d\n",serialized,len); n = iguana_parsehexstr(&vin->spendscript,&vin->spendlen,V!=0?V->spendscript:0,V!=0?&V->spendlen:0,&serialized[len],spendstr); diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index 44bef6db7..7b7af4af4 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -835,6 +835,8 @@ int32_t iguana_RTunspent_check(struct supernet_info *myinfo,struct iguana_info * { bits256 txid; int32_t vout,spentheight; memset(&txid,0,sizeof(txid)); + //if ( coin->FULLNODE == 0 && coin->VALIDATENODE == 0 ) + // return(0); if ( iguana_RTunspentind2txid(myinfo,coin,&spentheight,&txid,&vout,outpt) == 0 ) { //char str[65]; printf("verify %s/v%d is not already used\n",bits256_str(str,txid),vout); diff --git a/iguana/tests/decoderawtransaction b/iguana/tests/decoderawtransaction index 628535553..09a16c3a8 100755 --- a/iguana/tests/decoderawtransaction +++ b/iguana/tests/decoderawtransaction @@ -1 +1 @@ -curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"decoderawtransaction\",\"params\":[\"01000000aeefda57019a2aba7f29b3b63732a547f199c7c89cb3b2a7bba23bdc1398772d971573d831010000006a4730440220192e93b9191af641070411ad1945144cf9a1193f9b4263f1b1bf51b558b0b8f202205df39d89e2aa4179d4771966ef38b34e1b570645036cd952c9e91e721b3d23f9012102743d2afdb88ede68fb5938e961b1f41c2b6267b3286516543eb4e4ab87ad0d0affffffff76a9142f4c0f91fc06ac228c120aee41741d0d3909683288ac02c0d40100000000001976a9145da2ae69885741a6946e01ad8aa8b5312eed856088acf0d6e10b000000001976a9142f4c0f91fc06ac228c120aee41741d0d3909683288ac\", 1]}" +curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"SYS\",\"method\":\"decoderawtransaction\",\"params\":[\"0100000002006a9affa9b868cd4da9598f9a311bc8315dd0beafcdc4066f7eb4a55d19fae80100000000ffffffff00bcb83647bdcf661a4e71e96ee0ee84f77f09e278120a9479e19c709238963d0000000000ffffffff0210270000000000001976a914df3f034f9805301d881b0d8c24a106f8d4c7fc8c88acdc840100000000001976a9142f4c0f91fc06ac228c120aee41741d0d3909683288ac00000000\", 1]}" From 2f3122a8a6480e6a18b9d9bfd5bff36af60dc404 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 20 Sep 2016 08:02:47 -0300 Subject: [PATCH 2/7] test --- basilisk/basilisk_tradebot.c | 2 ++ iguana/iguana_unspents.c | 4 ++-- iguana/tests/LPinit | 1 + iguana/tests/decoderawtransaction | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 iguana/tests/LPinit diff --git a/basilisk/basilisk_tradebot.c b/basilisk/basilisk_tradebot.c index 39b750f1a..2656fc468 100755 --- a/basilisk/basilisk_tradebot.c +++ b/basilisk/basilisk_tradebot.c @@ -192,6 +192,8 @@ double basilisk_request_listprocess(struct supernet_info *myinfo,struct basilisk { if ( (aveprice= instantdex_avehbla(myinfo,retvals,list[0].src,list[0].dest,1.3 * dstr(list[0].srcamount))) == 0. || refprice > aveprice ) aveprice = refprice; + if ( fabs(aveprice) < SMALLVAL ) + return(0); destamount = (1.0 - profitmargin) * aveprice * list[0].srcamount; if ( (retstr= InstantDEX_available(myinfo,iguana_coinfind(list[0].dest),0,0,list[0].dest)) != 0 ) { diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index 7b7af4af4..414bc9f9a 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -835,8 +835,8 @@ int32_t iguana_RTunspent_check(struct supernet_info *myinfo,struct iguana_info * { bits256 txid; int32_t vout,spentheight; memset(&txid,0,sizeof(txid)); - //if ( coin->FULLNODE == 0 && coin->VALIDATENODE == 0 ) - // return(0); + if ( coin->FULLNODE == 0 && coin->VALIDATENODE == 0 ) + return(0); if ( iguana_RTunspentind2txid(myinfo,coin,&spentheight,&txid,&vout,outpt) == 0 ) { //char str[65]; printf("verify %s/v%d is not already used\n",bits256_str(str,txid),vout); diff --git a/iguana/tests/LPinit b/iguana/tests/LPinit new file mode 100644 index 000000000..a52902733 --- /dev/null +++ b/iguana/tests/LPinit @@ -0,0 +1 @@ +curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"tradebot\",\"method\":\"liquidity\",\"targetcoin\",\"BTCD\",\"vals\":{\"profit\":0.005}}" diff --git a/iguana/tests/decoderawtransaction b/iguana/tests/decoderawtransaction index 09a16c3a8..6a00a8aff 100755 --- a/iguana/tests/decoderawtransaction +++ b/iguana/tests/decoderawtransaction @@ -1 +1 @@ -curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"SYS\",\"method\":\"decoderawtransaction\",\"params\":[\"0100000002006a9affa9b868cd4da9598f9a311bc8315dd0beafcdc4066f7eb4a55d19fae80100000000ffffffff00bcb83647bdcf661a4e71e96ee0ee84f77f09e278120a9479e19c709238963d0000000000ffffffff0210270000000000001976a914df3f034f9805301d881b0d8c24a106f8d4c7fc8c88acdc840100000000001976a9142f4c0f91fc06ac228c120aee41741d0d3909683288ac00000000\", 1]}" +curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"SYS\",\"method\":\"decoderawtransaction\",\"params\":[\"010000000100bcb83647bdcf661a4e71e96ee0ee84f77f09e278120a9479e19c709238963d0000000000ffffffff0210270000000000001976a914df3f034f9805301d881b0d8c24a106f8d4c7fc8c88ac9e370100000000001976a9142f4c0f91fc06ac228c120aee41741d0d3909683288ac00000000\", 1]}" From 848907b125f5c11f3a485aeb09bca58ba65fe165 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 20 Sep 2016 08:18:33 -0300 Subject: [PATCH 3/7] test --- iguana/iguana777.c | 7 ++++--- iguana/iguana777.h | 2 +- iguana/iguana_init.c | 1 - iguana/main.c | 19 +------------------ includes/iguana_structs.h | 2 +- 5 files changed, 7 insertions(+), 24 deletions(-) diff --git a/iguana/iguana777.c b/iguana/iguana777.c index 154e50406..ceca16074 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -78,6 +78,7 @@ struct iguana_info *iguana_coinadd(char *symbol,char *name,cJSON *argjson,int32_ printf("ADD ALLCOINS.(%s) name.(%s) size %ld numvirts.%d\n",symbol,name,sizeof(*coin),myinfo->allcoins_numvirts); coin->symbolcrc = symbolcrc = calc_crc32(0,symbol,(int32_t)strlen(symbol)); //portable_mutex_lock(&myinfo->allcoins_mutex); + coin->coinid = myinfo->totalcoins++; HASH_ADD(hh,myinfo->allcoins,symbolcrc,sizeof(coin->symbolcrc),coin); //portable_mutex_unlock(&myinfo->allcoins_mutex); struct iguana_info *virt,*tmp; @@ -755,7 +756,7 @@ void iguana_helper(void *arg) } } } - if ( helperid == 0 ) + if ( (helperid % IGUANA_NUMHELPERS) == (coin->coinid % IGUANA_NUMHELPERS) ) iguana_coin_mainiter(myinfo,coin,&numpeers,&MEM,MEMB); } } @@ -932,11 +933,11 @@ void iguana_coinloop(void *arg) } if ( coin->FULLNODE != 0 || coin->VALIDATENODE != 0 || coin->MAXPEERS == 1 ) { - portable_mutex_lock(&coin->allcoins_mutex); + //portable_mutex_lock(&coin->allcoins_mutex); coin->busy_processing = 1; flag += iguana_processrecv(myinfo,coin); coin->busy_processing = 0; - portable_mutex_unlock(&coin->allcoins_mutex); + //portable_mutex_unlock(&coin->allcoins_mutex); /*if ( strcmp(coin->symbol,"BTCD") == 0 && coin->RTheight > 0 && coin->RTheight > coin->chain->bundlesize ) { int32_t hdrsi,nonz,errs; struct iguana_pkhash *refP; struct iguana_bundle *bp; diff --git a/iguana/iguana777.h b/iguana/iguana777.h index 061db9adc..ee45bc7d1 100755 --- a/iguana/iguana777.h +++ b/iguana/iguana777.h @@ -77,7 +77,7 @@ struct supernet_info char ipaddr[64],NXTAPIURL[512],secret[4096],password[4096],rpcsymbol[64],handle[1024],permanentfile[1024]; char *decryptstr; int32_t maxdelay,IAMRELAY,IAMNOTARY,IAMLP,publicRPC,basilisk_busy,genesisresults,remoteorigin; - uint32_t expiration,dirty,DEXactive,DEXpoll; + uint32_t expiration,dirty,DEXactive,DEXpoll,totalcoins; uint16_t argport,rpcport; struct basilisk_info basilisks; struct exchange_info *tradingexchanges[SUPERNET_MAXEXCHANGES]; int32_t numexchanges; diff --git a/iguana/iguana_init.c b/iguana/iguana_init.c index 3cab6200e..52e152492 100755 --- a/iguana/iguana_init.c +++ b/iguana/iguana_init.c @@ -68,7 +68,6 @@ void iguana_initcoin(struct iguana_info *coin,cJSON *argjson) portable_mutex_init(&coin->blocks_mutex); portable_mutex_init(&coin->special_mutex); portable_mutex_init(&coin->allcoins_mutex); - portable_mutex_init(&coin->allcoins_mutex); coin->txfee = 10000; iguana_meminit(&coin->blockMEM,"blockMEM",coin->blockspace,coin->blockspacesize,0); iguana_initQs(coin); diff --git a/iguana/main.c b/iguana/main.c index 1c5ef4efd..bc7c7bbe4 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -457,8 +457,7 @@ rm BTC.xz; mksquashfs DB/BTC BTC.xz -comp xz -b 1048576 -comp xz -Xdict-size 102 void mainloop(struct supernet_info *myinfo) { - struct iguana_info *coin,*tmp; int32_t i,counter=0,depth; portable_mutex_t *stack[IGUANA_MAXCOINS]; - double lastmilli = 0; + struct iguana_info *coin; int32_t counter=0,depth; double lastmilli = 0; sleep(3); printf("mainloop\n"); while ( 1 ) @@ -472,25 +471,9 @@ void mainloop(struct supernet_info *myinfo) counter++; coin = 0; depth = 0; - if ( 1 ) - { - HASH_ITER(hh,myinfo->allcoins,coin,tmp) - { - portable_mutex_lock(&coin->allcoins_mutex); - stack[depth++] = &coin->allcoins_mutex; - } - } //printf("check jsonQ\n"); while ( iguana_jsonQ(myinfo,0) != 0 ) ; - if ( 1 ) - { - if ( depth > 0 ) - { - for (i=depth-1; i>=0; i--) - portable_mutex_unlock(stack[i]); - } - } lastmilli = OS_milliseconds(); } usleep(30000); diff --git a/includes/iguana_structs.h b/includes/iguana_structs.h index 0b37c4ca9..b4f6166c0 100755 --- a/includes/iguana_structs.h +++ b/includes/iguana_structs.h @@ -483,7 +483,7 @@ struct iguana_info struct OS_memspace RTrawmem,RTmem,RThashmem; // struct iguana_ramchain RTramchain; bits256 RThash1; int32_t numremain,numpendings,zcount,recvcount,bcount,pcount,lastbundle,numsaved,pendbalances,numverified,blockdepth; - uint32_t recvtime,hdrstime,backstoptime,lastbundletime,numreqsent,numbundlesQ,lastbundleitime,lastdisp,RTgenesis,firstRTgenesis,RTstarti,idletime,stucktime,stuckmonitor,maxstuck,lastreqtime,RThdrstime,nextchecked,lastcheckpoint,sigserrs,sigsvalidated; + uint32_t recvtime,hdrstime,backstoptime,lastbundletime,numreqsent,numbundlesQ,lastbundleitime,lastdisp,RTgenesis,firstRTgenesis,RTstarti,idletime,stucktime,stuckmonitor,maxstuck,lastreqtime,RThdrstime,nextchecked,lastcheckpoint,sigserrs,sigsvalidated,coinid; double bandwidth,maxbandwidth,backstopmillis; bits256 backstophash2; int64_t spaceused; int32_t disableUTXO,initialheight,mapflags,minconfirms,numrecv,bindsock,isRT,backstop,blocksrecv,merging,firstRTheight,polltimeout,numreqtxids,allhashes,balanceflush,basilisk_busy,almostRT,busy_processing; bits256 reqtxids[64]; void *launched,*started,*rpcloop; From 0a1b4a2f0810f33197749f600307d64d5389bda0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 20 Sep 2016 08:43:16 -0300 Subject: [PATCH 4/7] test --- iguana/coins/basilisk | 4 ++-- iguana/tests/LPinit | 0 iguana/tests/decoderawtransaction | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) mode change 100644 => 100755 iguana/tests/LPinit diff --git a/iguana/coins/basilisk b/iguana/coins/basilisk index c56cc2a5a..e44fb0725 100755 --- a/iguana/coins/basilisk +++ b/iguana/coins/basilisk @@ -1,5 +1,5 @@ -curl --url "http://127.0.0.1:7778" --data "{\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTCD\",\"startpend\":1,\"endpend\":1,\"services\":128,\"maxpeers\":16,\"RELAY\":0,\"VALIDATE\":0,\"portp2p\":14631,\"rpc\":14632}" -#curl --url "http://127.0.0.1:7778" --data "{\"prefetchlag\":5,\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTC\",\"startpend\":1,\"endpend\":1,\"services\":128,\"maxpeers\":16,\"RELAY\":0,\"VALIDATE\":0,\"portp2p\":8333}" +#curl --url "http://127.0.0.1:7778" --data "{\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTCD\",\"startpend\":1,\"endpend\":1,\"services\":128,\"maxpeers\":16,\"RELAY\":0,\"VALIDATE\":0,\"portp2p\":14631,\"rpc\":14632}" +curl --url "http://127.0.0.1:7778" --data "{\"prefetchlag\":5,\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTC\",\"startpend\":1,\"endpend\":1,\"services\":128,\"maxpeers\":16,\"RELAY\":0,\"VALIDATE\":0,\"portp2p\":8333}" #curl --url "http://127.0.0.1:7778" --data "{\"RELAY\":0,\"VALIDATE\":0,\"prefetchlag\":11,\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":1,\"endpend\":1,\"services\":128,\"maxpeers\":16,\"newcoin\":\"LTC\",\"name\":\"Litecoin\",\"hasheaders\":1,\"useaddmultisig\":0,\"netmagic\":\"fbc0b6db\",\"p2p\":9333,\"rpc\":9334,\"pubval\":48,\"p2shval\":5,\"wifval\":176,\"txfee_satoshis\":\"100000\",\"isPoS\":0,\"minoutput\":10000,\"minconfirms\":2,\"genesishash\":\"12a765e31ffd4059bada1e25190f6e98c99d9714d334efa41a195a7e7e04bfe2\",\"genesis\":{\"version\":1,\"timestamp\":1317972665,\"nBits\":\"1e0ffff0\",\"nonce\":2084524493,\"merkle_root\":\"97ddfbbae6be97fd6cdf3e7ca13232a3afff2353e29badfab7f73011edd4ced9\"},\"alertpubkey\":\"040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9\",\"protover\":70002}" curl --url "http://127.0.0.1:7778" --data "{\"RELAY\":0,\"VALIDATE\":0,\"prefetchlag\":-1,\"poll\":10,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":18,\"endpend\":18,\"services\":129,\"maxpeers\":256,\"newcoin\":\"SYS\",\"name\":\"SYScoin\",\"hasheaders\":0,\"useaddmultisig\":0,\"netmagic\":\"f9beb4d9\",\"p2p\":8369,\"rpc\":8370,\"pubval\":0,\"p2shval\":5,\"wifval\":128,\"txfee_satoshis\":\"100000\",\"isPoS\":0,\"minoutput\":10000,\"minconfirms\":2,\"genesishash\":\"0000072d66e51ab87de265765cc8bdd2d229a4307c672a1b3d5af692519cf765\",\"genesis\":{\"version\":1,\"timestamp\":1450473723,\"nBits\":\"1e0ffff0\",\"nonce\":5258726,\"merkle_root\":\"5215c5a2af9b63f2550b635eb2b354bb13645fd8fa31275394eb161944303065\"},\"protover\":70012,\"auxpow\":1,\"fixit\":0}" diff --git a/iguana/tests/LPinit b/iguana/tests/LPinit old mode 100644 new mode 100755 diff --git a/iguana/tests/decoderawtransaction b/iguana/tests/decoderawtransaction index 6a00a8aff..7fb5f5f33 100755 --- a/iguana/tests/decoderawtransaction +++ b/iguana/tests/decoderawtransaction @@ -1 +1 @@ -curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"SYS\",\"method\":\"decoderawtransaction\",\"params\":[\"010000000100bcb83647bdcf661a4e71e96ee0ee84f77f09e278120a9479e19c709238963d0000000000ffffffff0210270000000000001976a914df3f034f9805301d881b0d8c24a106f8d4c7fc8c88ac9e370100000000001976a9142f4c0f91fc06ac228c120aee41741d0d3909683288ac00000000\", 1]}" +curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"SYS\",\"method\":\"decoderawtransaction\",\"params\":[\"0100000002836a9affa9b868cd4da9598f9a311bc8315dd0beafcdc4066f7eb4a55d19fae8010000006b483045022100f892c8848a9b9cbc97cc6558b088a4d00ef7da574be31558a252b7ba394d388302205b2a2f9b50bdf7f970fc6c1da5cb4d07a7a1a1e6dfd6f37692f01ad466cade4c012102743d2afdb88ede68fb5938e961b1f41c2b6267b3286516543eb4e4ab87ad0d0affffffffd7bcb83647bdcf661a4e71e96ee0ee84f77f09e278120a9479e19c709238963d000000006a47304402206e9393c76191d9c1383765eae918f91b5977d3eb5dcf63168c14d2a8d37e479c022003a6fd30ee59b9e330b4d18b4c1318ccafde6e0edff836e230bf792f017d73c7012102743d2afdb88ede68fb5938e961b1f41c2b6267b3286516543eb4e4ab87ad0d0affffffff02204e0000000000001976a914d93f7d2bd03a6f9f83ccbd06ec277b4549aff73988accc5d0100000000001976a9142f4c0f91fc06ac228c120aee41741d0d3909683288ac00000000\", 1]}" From 853bb5b7dd40b86ed1bbdfff5b6fb3addaa116b2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 20 Sep 2016 09:03:31 -0300 Subject: [PATCH 5/7] test --- iguana/iguana_rpc.c | 5 ++++- iguana/tests/LPinit | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/iguana/iguana_rpc.c b/iguana/iguana_rpc.c index acf86102a..b670b134e 100755 --- a/iguana/iguana_rpc.c +++ b/iguana/iguana_rpc.c @@ -1054,7 +1054,7 @@ char *SuperNET_rpcparse(struct supernet_info *myinfo,char *retbuf,int32_t bufsiz for (i=0; i Date: Tue, 20 Sep 2016 09:17:37 -0300 Subject: [PATCH 6/7] test --- basilisk/basilisk.c | 2 +- basilisk/basilisk_DEX.c | 16 +++++++++------- basilisk/basilisk_swap.c | 4 ++-- basilisk/basilisk_tradebot.c | 8 ++++---- includes/iguana_structs.h | 2 +- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/basilisk/basilisk.c b/basilisk/basilisk.c index c54a5fc0b..9786b8f56 100755 --- a/basilisk/basilisk.c +++ b/basilisk/basilisk.c @@ -820,7 +820,7 @@ void basilisk_requests_poll(struct supernet_info *myinfo) } else printf("null incoming\n"); if ( hwm > 0. ) { - if ( bits256_cmp(myinfo->myaddr.persistent,issueR.hash) == 0 ) // my request + if ( bits256_cmp(myinfo->myaddr.persistent,issueR.srchash) == 0 ) // my request { printf("my req hwm %f\n",hwm); if ( (retstr= InstantDEX_accept(myinfo,0,0,0,issueR.requestid,issueR.quoteid)) != 0 ) diff --git a/basilisk/basilisk_DEX.c b/basilisk/basilisk_DEX.c index c2d01b418..f8445e521 100755 --- a/basilisk/basilisk_DEX.c +++ b/basilisk/basilisk_DEX.c @@ -103,7 +103,7 @@ int32_t basilisk_rwDEXquote(int32_t rwflag,uint8_t *serialized,struct basilisk_r len += iguana_rwnum(rwflag,&serialized[len],sizeof(rp->relaybits),&rp->relaybits); len += iguana_rwnum(rwflag,&serialized[len],sizeof(rp->srcamount),&rp->srcamount); len += iguana_rwnum(rwflag,&serialized[len],sizeof(rp->minamount),&rp->minamount); - len += iguana_rwbignum(rwflag,&serialized[len],sizeof(rp->hash),rp->hash.bytes); + len += iguana_rwbignum(rwflag,&serialized[len],sizeof(rp->srchash),rp->srchash.bytes); len += iguana_rwbignum(rwflag,&serialized[len],sizeof(rp->desthash),rp->desthash.bytes); len += iguana_rwnum(rwflag,&serialized[len],sizeof(rp->destamount),&rp->destamount); if ( rwflag != 0 ) @@ -148,7 +148,7 @@ cJSON *basilisk_requestjson(struct basilisk_request *rp) expand_ipbits(ipaddr,rp->relaybits); jaddstr(item,"relay",ipaddr); } - jaddbits256(item,"hash",rp->hash); + jaddbits256(item,"srchash",rp->srchash); if ( bits256_nonz(rp->desthash) != 0 ) jaddbits256(item,"desthash",rp->desthash); jaddstr(item,"src",rp->src); @@ -189,7 +189,7 @@ cJSON *basilisk_requestjson(struct basilisk_request *rp) return(item); } -int32_t basilisk_request_create(struct basilisk_request *rp,cJSON *valsobj,bits256 hash,uint32_t timestamp) +int32_t basilisk_request_create(struct basilisk_request *rp,cJSON *valsobj,bits256 desthash,uint32_t timestamp) { char *dest,*src; uint32_t i; memset(rp,0,sizeof(*rp)); @@ -197,7 +197,7 @@ int32_t basilisk_request_create(struct basilisk_request *rp,cJSON *valsobj,bits2 { if ( (rp->destamount= j64bits(valsobj,"destsatoshis")) != 0 ) { - rp->desthash = jbits256(valsobj,"desthash"); + rp->desthash = desthash; for (i=0; i<4; i++) if ( rp->desthash.ulongs[i] != 0 ) break; @@ -206,7 +206,7 @@ int32_t basilisk_request_create(struct basilisk_request *rp,cJSON *valsobj,bits2 } rp->minamount = j64bits(valsobj,"minamount"); rp->timestamp = timestamp; - rp->hash = hash; + rp->srchash = jbits256(valsobj,"srchash"); strncpy(rp->src,src,sizeof(rp->src)-1); strncpy(rp->dest,dest,sizeof(rp->dest)-1); rp->requestid = basilisk_requestid(rp); @@ -224,7 +224,7 @@ int32_t basilisk_request_create(struct basilisk_request *rp,cJSON *valsobj,bits2 char *basilisk_start(struct supernet_info *myinfo,struct basilisk_request *rp,uint32_t statebits) { cJSON *retjson; - if ( (bits256_cmp(rp->hash,myinfo->myaddr.persistent) == 0 || bits256_cmp(rp->desthash,myinfo->myaddr.persistent) == 0) ) + if ( (bits256_cmp(rp->srchash,myinfo->myaddr.persistent) == 0 || bits256_cmp(rp->desthash,myinfo->myaddr.persistent) == 0) ) { printf("START thread to complete %u/%u for (%s %.8f) <-> (%s %.8f) q.%u\n",rp->requestid,rp->quoteid,rp->src,dstr(rp->srcamount),rp->dest,dstr(rp->destamount),rp->quoteid); if ( basilisk_thread_start(myinfo,rp) != 0 ) @@ -333,7 +333,7 @@ char *basilisk_respond_requests(struct supernet_info *myinfo,bits256 hash,uint32 for (i=0; iquoteid && (bits256_cmp(hash,rp->hash) == 0 || bits256_cmp(hash,rp->desthash) == 0)) ) + if ( quoteid == 0 || (quoteid == rp->quoteid && (bits256_cmp(hash,rp->srchash) == 0 || bits256_cmp(hash,rp->desthash) == 0)) ) qflag = 1; else qflag = 0; if ( requestid == 0 || (rp->requestid == requestid && qflag != 0) ) @@ -424,6 +424,8 @@ HASH_ARRAY_STRING(InstantDEX,request,hash,vals,hexstr) uint8_t serialized[512]; struct basilisk_request R; cJSON *reqjson; uint32_t datalen=0,DEX_channel; myinfo->DEXactive = (uint32_t)time(NULL) + BASILISK_TIMEOUT; jadd64bits(vals,"minamount",jdouble(vals,"minprice") * jdouble(vals,"amount") * SATOSHIDEN); + if ( jobj(vals,"srchash") == 0 ) + jaddbits256(vals,"srchash",myinfo->myaddr.pubkey); if ( jobj(vals,"desthash") == 0 ) jaddbits256(vals,"desthash",hash); jadd64bits(vals,"satoshis",jdouble(vals,"amount") * SATOSHIDEN); diff --git a/basilisk/basilisk_swap.c b/basilisk/basilisk_swap.c index 78f8f516a..b2bb9c482 100755 --- a/basilisk/basilisk_swap.c +++ b/basilisk/basilisk_swap.c @@ -751,7 +751,7 @@ struct basilisk_swap *bitcoin_swapinit(struct supernet_info *myinfo,struct basil swap->choosei %= INSTANTDEX_DECKSIZE; swap->otherchoosei = -1; swap->myhash = myinfo->myaddr.persistent; - if ( bits256_cmp(swap->myhash,swap->req.hash) == 0 ) + if ( bits256_cmp(swap->myhash,swap->req.srchash) == 0 ) { swap->otherhash = swap->req.desthash; if ( strcmp(swap->req.src,swap->bobstr) == 0 ) @@ -764,7 +764,7 @@ struct basilisk_swap *bitcoin_swapinit(struct supernet_info *myinfo,struct basil } else if ( bits256_cmp(swap->myhash,swap->req.desthash) == 0 ) { - swap->otherhash = swap->req.hash; + swap->otherhash = swap->req.srchash; if ( strcmp(swap->req.dest,swap->bobstr) == 0 ) swap->iambob = 1; else if ( strcmp(swap->req.src,swap->alicestr) != 0 ) diff --git a/basilisk/basilisk_tradebot.c b/basilisk/basilisk_tradebot.c index 2656fc468..846188ea2 100755 --- a/basilisk/basilisk_tradebot.c +++ b/basilisk/basilisk_tradebot.c @@ -29,7 +29,7 @@ uint32_t basilisk_requestid(struct basilisk_request *rp) for (i=0; i %s %.8f %s crc.%u\n",R.timestamp,R.requestid,R.quoteid,R.src,dstr(R.srcamount),bits256_str(str,R.hash),R.dest,dstr(R.destamount),bits256_str(str2,R.desthash),calc_crc32(0,(void *)&R,sizeof(R))); + char str[65],str2[65]; printf("B REQUESTID: t.%u r.%u q.%u %s %.8f %s -> %s %.8f %s crc.%u\n",R.timestamp,R.requestid,R.quoteid,R.src,dstr(R.srcamount),bits256_str(str,R.srchash),R.dest,dstr(R.destamount),bits256_str(str2,R.desthash),calc_crc32(0,(void *)&R,sizeof(R))); } return(calc_crc32(0,(void *)&R,sizeof(R))); } @@ -46,7 +46,7 @@ struct basilisk_request *basilisk_parsejson(struct basilisk_request *rp,cJSON *r { uint32_t requestid,quoteid; memset(rp,0,sizeof(*rp)); - rp->hash = jbits256(reqjson,"hash"); + rp->srchash = jbits256(reqjson,"srchash"); rp->desthash = jbits256(reqjson,"desthash"); rp->srcamount = j64bits(reqjson,"srcamount"); rp->minamount = j64bits(reqjson,"minamount"); @@ -102,7 +102,7 @@ struct basilisk_swap *basilisk_request_started(struct supernet_info *myinfo,uint int32_t basilisk_request_cmpref(struct basilisk_request *ref,struct basilisk_request *rp) { - if ( bits256_cmp(rp->hash,ref->hash) != 0 || memcmp(rp->src,ref->src,sizeof(ref->src)) != 0 || memcmp(rp->dest,ref->dest,sizeof(ref->dest)) != 0 || rp->srcamount != ref->srcamount || rp->timestamp != ref->timestamp ) + if ( bits256_cmp(rp->srchash,ref->srchash) != 0 || memcmp(rp->src,ref->src,sizeof(ref->src)) != 0 || memcmp(rp->dest,ref->dest,sizeof(ref->dest)) != 0 || rp->srcamount != ref->srcamount || rp->timestamp != ref->timestamp ) { printf("basilisk_request_listprocess mismatched hash\n"); return(-1); @@ -162,7 +162,7 @@ double basilisk_request_listprocess(struct supernet_info *myinfo,struct basilisk printf("need to verify null quoteid is list[0] requestid.%u quoteid.%u\n",list[0].requestid,list[0].quoteid); if ( (active= basilisk_request_started(myinfo,list[0].requestid)) != 0 ) pendingid = active->req.quoteid; - if ( bits256_cmp(myinfo->myaddr.persistent,list[0].hash) == 0 ) // my request + if ( bits256_cmp(myinfo->myaddr.persistent,list[0].srchash) == 0 ) // my request myrequest = 1; for (i=0; i Date: Tue, 20 Sep 2016 09:50:47 -0300 Subject: [PATCH 7/7] test --- basilisk/basilisk.c | 2 +- basilisk/basilisk_tradebot.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/basilisk/basilisk.c b/basilisk/basilisk.c index 9786b8f56..92e59900e 100755 --- a/basilisk/basilisk.c +++ b/basilisk/basilisk.c @@ -806,7 +806,7 @@ void basilisk_requests_poll(struct supernet_info *myinfo) memset(&issueR,0,sizeof(issueR)); if ( (retstr= InstantDEX_incoming(myinfo,0,0,0,0)) != 0 ) { -//printf("poll.(%s)\n",retstr); + printf("poll.(%s)\n",retstr); if ( (retjson= cJSON_Parse(retstr)) != 0 ) { if ( (outerarray= jarray(&n,retjson,"responses")) != 0 ) diff --git a/basilisk/basilisk_tradebot.c b/basilisk/basilisk_tradebot.c index 846188ea2..642430a2a 100755 --- a/basilisk/basilisk_tradebot.c +++ b/basilisk/basilisk_tradebot.c @@ -232,7 +232,7 @@ double basilisk_process_results(struct supernet_info *myinfo,struct basilisk_req { cJSON *array,*item; int32_t i,n,m,nonz; struct basilisk_request tmpR,R,refR,list[BASILISK_MAXRELAYS]; double metric=0.; memset(&refR,0,sizeof(refR)); - //printf("process.(%s)\n",jprint(retjson,0)); +printf("process.(%s)\n",jprint(retjson,0)); if ( (array= jarray(&n,retjson,"messages")) != 0 ) { for (i=nonz=m=0; i