Browse Source

Merge pull request #207 from jl777/dev

Dev
win-cross
jl777 8 years ago
committed by GitHub
parent
commit
e430814d31
  1. 2
      iguana/coins/genshark
  2. 2
      iguana/dpow/dpow_network.c
  3. 8
      iguana/iguana777.c
  4. 2
      iguana/iguana_msg.c
  5. 9
      iguana/iguana_payments.c
  6. 12
      iguana/ramchain_api.c
  7. 2
      iguana/tests/dexgetB
  8. 2
      iguana/tests/dexgetH
  9. 2
      iguana/tests/dexgetO
  10. 1
      iguana/tests/dexkvsearch
  11. 2
      iguana/tests/getinfo
  12. 2
      iguana/tests/getinfoS

2
iguana/coins/genshark

@ -0,0 +1,2 @@
curl --url "http://127.0.0.1:7778" --data "{\"conf\":\"SHARK.conf\",\"path\":\"${HOME#"/"}/.komodo/SHARK\",\"unitval\":\"20\",\"zcash\":1,\"RELAY\":1,\"VALIDATE\":1,\"prefetchlag\":-1,\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":4,\"endpend\":4,\"services\":129,\"maxpeers\":8,\"newcoin\":\"SHARK\",\"name\":\"SHARK\",\"hasheaders\":1,\"useaddmultisig\":0,\"netmagic\":\"54a5e30c\",\"p2p\":10113,\"rpc\":10114,\"pubval\":60,\"p2shval\":85,\"wifval\":188,\"txfee_satoshis\":\"10000\",\"isPoS\":0,\"minoutput\":10000,\"minconfirms\":2,\"genesishash\":\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\",\"protover\":170002,\"genesisblock\":\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\",\"debug\":0,\"seedipaddr\":\"78.47.196.146\"}"

2
iguana/dpow/dpow_network.c

@ -402,7 +402,7 @@ char *_dex_reqsend(struct supernet_info *myinfo,char *handler,uint8_t *key,int32
printf("%d: subscribe connect (%s)\n",myinfo->numdexipbits,str); printf("%d: subscribe connect (%s)\n",myinfo->numdexipbits,str);
} }
} }
if ( (rand() % 100) < 0 ) if ( (rand() % 100) < 40 )
{ {
nanomsg_tcpname(0,str,ipaddr,REP_SOCK); nanomsg_tcpname(0,str,ipaddr,REP_SOCK);
nn_connect(myinfo->reqsock,str); nn_connect(myinfo->reqsock,str);

8
iguana/iguana777.c

@ -886,6 +886,8 @@ void iguana_coinloop(void *arg)
coin = coins[0]; coin = coins[0];
if ( (coin->notarychain= iguana_isnotarychain(coin->symbol)) >= 0 ) if ( (coin->notarychain= iguana_isnotarychain(coin->symbol)) >= 0 )
coin->VALIDATENODE = 0; coin->VALIDATENODE = 0;
//if ( coin->FULLNODE > 0 )
// coin->notarychain = -1;
printf("begin coinloop[%d] %s notarychain.%d\n",n,coin->symbol,coin->notarychain); printf("begin coinloop[%d] %s notarychain.%d\n",n,coin->symbol,coin->notarychain);
memset(zero.bytes,0,sizeof(zero)); memset(zero.bytes,0,sizeof(zero));
while ( 1 ) while ( 1 )
@ -901,7 +903,7 @@ void iguana_coinloop(void *arg)
if ( coin->notarychain >= 0 && myinfo->IAMNOTARY != 0 ) if ( coin->notarychain >= 0 && myinfo->IAMNOTARY != 0 )
init_alladdresses(myinfo,coin); init_alladdresses(myinfo,coin);
} }
if ( coin->FULLNODE < 0 || coin->notarychain >= 0 ) if ( coin->FULLNODE < 0 )//|| (coin->notarychain >= 0 && coin->FULLNODE == 0) )
{ {
continue; continue;
} }
@ -958,7 +960,7 @@ void iguana_coinloop(void *arg)
} }
now = (uint32_t)time(NULL); now = (uint32_t)time(NULL);
coin->idletime = 0; coin->idletime = 0;
if ( coin->started != 0 && coin->active != 0 ) if ( coin->started != 0 && coin->active != 0 && (coin->notarychain < 0 || coin->FULLNODE == 0) )
{ {
//printf("%s numranked.%d isRT.%d numsaved.%d M.%d L.%d numverified.%d hdrsi.%d\n",coin->symbol,coin->peers->numranked,coin->isRT,coin->numsaved,coin->blocks.hwmchain.height,coin->longestchain,coin->numverified,coin->current!=0?coin->current->hdrsi:-1); //printf("%s numranked.%d isRT.%d numsaved.%d M.%d L.%d numverified.%d hdrsi.%d\n",coin->symbol,coin->peers->numranked,coin->isRT,coin->numsaved,coin->blocks.hwmchain.height,coin->longestchain,coin->numverified,coin->current!=0?coin->current->hdrsi:-1);
if ( coin->peers->numranked > 4 && coin->isRT == 0 && now > coin->startutc+77 && coin->numsaved >= (coin->longestchain/coin->chain->bundlesize)*coin->chain->bundlesize && coin->blocks.hwmchain.height >= coin->longestchain-30 ) if ( coin->peers->numranked > 4 && coin->isRT == 0 && now > coin->startutc+77 && coin->numsaved >= (coin->longestchain/coin->chain->bundlesize)*coin->chain->bundlesize && coin->blocks.hwmchain.height >= coin->longestchain-30 )
@ -1209,7 +1211,7 @@ int32_t iguana_launchcoin(struct supernet_info *myinfo,char *symbol,cJSON *json,
coins = mycalloc('A',1+1,sizeof(*coins)); coins = mycalloc('A',1+1,sizeof(*coins));
if ( (coin= iguana_setcoin(symbol,coins,maxpeers,maxrecvcache,services,initialheight,maphash,minconfirms,maxrequests,maxbundles,json,virtcoin)) != 0 ) if ( (coin= iguana_setcoin(symbol,coins,maxpeers,maxrecvcache,services,initialheight,maphash,minconfirms,maxrequests,maxbundles,json,virtcoin)) != 0 )
{ {
if ( iguana_isnotarychain(coin->symbol) < 0 ) if ( iguana_isnotarychain(coin->symbol) < 0 || coin->FULLNODE >= 0 )
{ {
coins[0] = (void *)((long)1); coins[0] = (void *)((long)1);
coins[1] = coin; coins[1] = coin;

2
iguana/iguana_msg.c

@ -476,6 +476,8 @@ void iguana_gotping(struct supernet_info *myinfo,struct iguana_info *coin,struct
int32_t iguana_send_ping(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr) int32_t iguana_send_ping(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr)
{ {
int32_t len; uint64_t nonce; uint8_t serialized[sizeof(struct iguana_msghdr) + sizeof(nonce)]; int32_t len; uint64_t nonce; uint8_t serialized[sizeof(struct iguana_msghdr) + sizeof(nonce)];
if ( coin->FULLNODE <= 0 )
return(0);
if ( addr->msgcounts.verack == 0 ) if ( addr->msgcounts.verack == 0 )
{ {
if ( strcmp(addr->ipaddr,myinfo->ipaddr) != 0 ) if ( strcmp(addr->ipaddr,myinfo->ipaddr) != 0 )

9
iguana/iguana_payments.c

@ -605,6 +605,8 @@ STRING_AND_INT(bitcoinrpc,sendrawtransaction,rawtx,allowhighfees)
cJSON *retjson = cJSON_CreateObject(); bits256 txid; cJSON *retjson = cJSON_CreateObject(); bits256 txid;
if ( remoteaddr != 0 ) if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}")); return(clonestr("{\"error\":\"no remote\"}"));
if ( coin->notarychain >= 0 && coin->FULLNODE == 0 )
return(_dex_sendrawtransaction(myinfo,coin->symbol,rawtx));
txid = iguana_sendrawtransaction(myinfo,coin,rawtx); txid = iguana_sendrawtransaction(myinfo,coin,rawtx);
jaddbits256(retjson,"result",txid); jaddbits256(retjson,"result",txid);
return(jprint(retjson,1)); return(jprint(retjson,1));
@ -678,6 +680,7 @@ INT_ARRAY_STRING(bitcoinrpc,createmultisig,M,pubkeys,ignore)
if ( n < 0 || n > 16 || M < 0 || M > n ) if ( n < 0 || n > 16 || M < 0 || M > n )
return(clonestr("{\"error\":\"illegal number of pubkeys\"}")); return(clonestr("{\"error\":\"illegal number of pubkeys\"}"));
memset(&V,0,sizeof(V)); memset(&V,0,sizeof(V));
printf("create M.%d of N.%d (%s)\n",M,n,jprint(pubkeys,0));
V.M = M, V.N = n; V.M = M, V.N = n;
pkjson = cJSON_CreateArray(); pkjson = cJSON_CreateArray();
addresses = cJSON_CreateArray(); addresses = cJSON_CreateArray();
@ -714,6 +717,7 @@ INT_ARRAY_STRING(bitcoinrpc,createmultisig,M,pubkeys,ignore)
jaddstr(retjson,"error","couldnt get all pubkeys"); jaddstr(retjson,"error","couldnt get all pubkeys");
free_json(pkjson); free_json(pkjson);
} }
printf("CREATEMULTISIG.(%s)\n",jprint(retjson,0));
return(jprint(retjson,1)); return(jprint(retjson,1));
} }
@ -727,7 +731,6 @@ INT_ARRAY_STRING(bitcoinrpc,addmultisigaddress,M,pubkeys,account) //
myinfo->expiration++; myinfo->expiration++;
if ( (retstr= bitcoinrpc_createmultisig(IGUANA_CALLARGS,M,pubkeys,account)) != 0 ) if ( (retstr= bitcoinrpc_createmultisig(IGUANA_CALLARGS,M,pubkeys,account)) != 0 )
{ {
//printf("CREATEMULTISIG.(%s)\n",retstr);
if ( (retjson= cJSON_Parse(retstr)) != 0 ) if ( (retjson= cJSON_Parse(retstr)) != 0 )
{ {
if ( (msigaddr= jstr(retjson,"address")) != 0 ) if ( (msigaddr= jstr(retjson,"address")) != 0 )
@ -764,6 +767,8 @@ HASH_AND_TWOINTS(bitcoinrpc,gettxout,txid,vout,mempool)
return(clonestr("{\"error\":\"no remote\"}")); return(clonestr("{\"error\":\"no remote\"}"));
if ( coin != 0 ) if ( coin != 0 )
{ {
if ( coin->notarychain >= 0 && coin->FULLNODE == 0 )
return(_dex_gettxout(myinfo,coin->symbol,txid,vout));
if ( (value= _RTgettxout(coin,&ptr,&height,&scriptlen,script,rmd160,coinaddr,txid,vout,mempool)) > 0 ) if ( (value= _RTgettxout(coin,&ptr,&height,&scriptlen,script,rmd160,coinaddr,txid,vout,mempool)) > 0 )
{ {
jaddbits256(retjson,"bestblock",coin->blocks.hwmchain.RO.hash2); jaddbits256(retjson,"bestblock",coin->blocks.hwmchain.RO.hash2);
@ -958,6 +963,8 @@ HASH_AND_INT(bitcoinrpc,getrawtransaction,txid,verbose)
struct iguana_txid *tx,T; char *txbytes; bits256 checktxid; int32_t len=0,height,extralen=65536; cJSON *retjson,*txobj; uint8_t *extraspace; struct iguana_RTtxid *RTptr; struct iguana_txid *tx,T; char *txbytes; bits256 checktxid; int32_t len=0,height,extralen=65536; cJSON *retjson,*txobj; uint8_t *extraspace; struct iguana_RTtxid *RTptr;
if ( remoteaddr != 0 ) if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}")); return(clonestr("{\"error\":\"no remote\"}"));
if ( coin->notarychain >= 0 && coin->FULLNODE == 0 )
return(_dex_getrawtransaction(myinfo,coin->symbol,txid));
HASH_FIND(hh,coin->RTdataset,txid.bytes,sizeof(txid),RTptr); HASH_FIND(hh,coin->RTdataset,txid.bytes,sizeof(txid),RTptr);
if ( RTptr != 0 && RTptr->rawtxbytes != 0 && RTptr->txlen > 0 ) if ( RTptr != 0 && RTptr->rawtxbytes != 0 && RTptr->txlen > 0 )
{ {

12
iguana/ramchain_api.c

@ -114,7 +114,10 @@ STRING_ARG(iguana,removecoin,activecoin)
INT_ARG(bitcoinrpc,getblockhash,height) INT_ARG(bitcoinrpc,getblockhash,height)
{ {
cJSON *retjson = cJSON_CreateObject(); cJSON *retjson;
if ( coin->notarychain >= 0 && coin->FULLNODE == 0 )
return(_dex_getblockhash(myinfo,coin->symbol,height));
retjson = cJSON_CreateObject();
jaddbits256(retjson,"result",iguana_blockhash(coin,height)); jaddbits256(retjson,"result",iguana_blockhash(coin,height));
return(jprint(retjson,1)); return(jprint(retjson,1));
} }
@ -122,6 +125,8 @@ INT_ARG(bitcoinrpc,getblockhash,height)
HASH_AND_TWOINTS(bitcoinrpc,getblock,blockhash,verbose,remoteonly) HASH_AND_TWOINTS(bitcoinrpc,getblock,blockhash,verbose,remoteonly)
{ {
char *blockstr,*datastr; struct iguana_msgblock msg; struct iguana_block *block; cJSON *retjson; bits256 txid; int32_t len; char *blockstr,*datastr; struct iguana_msgblock msg; struct iguana_block *block; cJSON *retjson; bits256 txid; int32_t len;
if ( coin->notarychain >= 0 && coin->FULLNODE == 0 )
return(_dex_getblock(myinfo,coin->symbol,blockhash));
retjson = cJSON_CreateObject(); retjson = cJSON_CreateObject();
memset(&msg,0,sizeof(msg)); memset(&msg,0,sizeof(msg));
if ( remoteonly == 0 && (block= iguana_blockfind("getblockRPC",coin,blockhash)) != 0 ) if ( remoteonly == 0 && (block= iguana_blockfind("getblockRPC",coin,blockhash)) != 0 )
@ -157,7 +162,10 @@ HASH_AND_TWOINTS(bitcoinrpc,getblock,blockhash,verbose,remoteonly)
ZERO_ARGS(bitcoinrpc,getbestblockhash) ZERO_ARGS(bitcoinrpc,getbestblockhash)
{ {
cJSON *retjson = cJSON_CreateObject(); cJSON *retjson;
if ( coin->notarychain >= 0 && coin->FULLNODE == 0 )
return(_dex_getbestblockhash(myinfo,coin->symbol));
retjson = cJSON_CreateObject();
char str[65]; jaddstr(retjson,"result",bits256_str(str,coin->blocks.hwmchain.RO.hash2)); char str[65]; jaddstr(retjson,"result",bits256_str(str,coin->blocks.hwmchain.RO.hash2));
return(jprint(retjson,1)); return(jprint(retjson,1));
} }

2
iguana/tests/dexgetB

@ -1,2 +1,2 @@
#!/bin/bash #!/bin/bash
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"getblock\",\"hash\":\"0000000000000000033245c0bd104a80c2a7ed7e04330e034d4833f9928d18e7\",\"symbol\":\"BTC\"}" curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"getblock\",\"hash\":\"02faa3cb03cf4bad4522303877cfa23abe6ccd3c070176efd684f77ca2e56d95\",\"symbol\":\"SHARK\"}"

2
iguana/tests/dexgetH

@ -1,2 +1,2 @@
#!/bin/bash #!/bin/bash
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"getblockhash\",\"height\":100000,\"symbol\":\"KMD\"}" curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"getblockhash\",\"height\":100,\"symbol\":\"SHARK\"}"

2
iguana/tests/dexgetO

@ -1,2 +1,2 @@
#!/bin/bash #!/bin/bash
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"gettxout\",\"vout\":0,\"txid\":\"aa82ebd1c5bd2a9e19214cbc959df1745378676fddfd6f4903930ac16485c7ae\",\"symbol\":\"BTC\"}" curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"gettxout\",\"vout\":1,\"txid\":\"e29562d41d3ad468f579f2b8a9031e23483c639a8434e7c8cda46e6f17bcf1c7\",\"symbol\":\"BTC\"}"

1
iguana/tests/dexkvsearch

@ -1,3 +1,4 @@
#!/bin/bash #!/bin/bash
#curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"kvsearch\",\"key\":\"foo\",\"symbol\":\"KMD\"}" #curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"kvsearch\",\"key\":\"foo\",\"symbol\":\"KMD\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"kvsearch\",\"key\":\"test\",\"symbol\":\"KV\"}" curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"kvsearch\",\"key\":\"test\",\"symbol\":\"KV\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"kvsearch\",\"key\":\"777\",\"symbol\":\"KV\"}"

2
iguana/tests/getinfo

@ -1,2 +1,2 @@
#!/bin/bash #!/bin/bash
curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"getinfo\",\"params\":[]}" curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"SHARK\",\"method\":\"getinfo\",\"params\":[]}"

2
iguana/tests/getinfoS

@ -0,0 +1,2 @@
#!/bin/bash
curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"SHARK\",\"method\":\"getinfo\",\"params\":[]}"
Loading…
Cancel
Save