Browse Source

Merge pull request #853 from jl777/beta

Beta
beta_season3
jl777 7 years ago
committed by GitHub
parent
commit
a1795a7fc1
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .gitignore
  2. 6
      basilisk/basilisk.c
  3. 6
      basilisk/basilisk_bitcoin.c
  4. 9
      crypto777/bitcoind_RPC.c
  5. 1279
      deprecated/iguana_notary.c
  6. 63
      iguana/SuperNET_keys.c
  7. 2
      iguana/acsplit
  8. 2
      iguana/coins/beer_7776
  9. 2
      iguana/coins/game_7776
  10. 2
      iguana/coins/pizza_7776
  11. 18
      iguana/dPoW.h
  12. 228
      iguana/dpow/dPoW.h
  13. 228
      iguana/dpow/dpow_fsm.c
  14. 201
      iguana/dpow/dpow_network.c
  15. 62
      iguana/dpow/dpow_rpc.c
  16. 20
      iguana/dpow/dpow_tx.c
  17. 81
      iguana/elected
  18. 1
      iguana/elected.2017
  19. 84
      iguana/elected.new
  20. 3
      iguana/exchanges/LP_coins.c
  21. 8
      iguana/exchanges/LP_commands.c
  22. 7
      iguana/exchanges/LP_include.h
  23. 17
      iguana/exchanges/LP_ordermatch.c
  24. 5
      iguana/exchanges/LP_portfolio.c
  25. 8
      iguana/exchanges/LP_remember.c
  26. 28
      iguana/exchanges/LP_rpc.c
  27. 14
      iguana/exchanges/LP_signatures.c
  28. 9
      iguana/exchanges/LP_socket.c
  29. 1
      iguana/exchanges/LP_swap.c
  30. 23
      iguana/exchanges/LP_transaction.c
  31. 20
      iguana/exchanges/LP_utxo.c
  32. 2
      iguana/exchanges/coins
  33. 2
      iguana/exchanges/kickstart
  34. 2
      iguana/exchanges/prices/autoprice
  35. 2
      iguana/exchanges/splitfunds
  36. 2
      iguana/exchanges/supernet
  37. 3
      iguana/iguana777.c
  38. 4
      iguana/iguana777.h
  39. 4
      iguana/iguana_chains.c
  40. 302
      iguana/iguana_notary.c
  41. 11
      iguana/iguana_wallet.c
  42. 18
      iguana/m_notary_run
  43. 2
      iguana/tests/active
  44. 2
      includes/iguana_apideclares.h
  45. 2
      includes/iguana_structs.h

2
.gitignore

@ -262,3 +262,5 @@ Release/*
build_win64_release/* build_win64_release/*
DB/* DB/*
iguana/exchanges/manychains

6
basilisk/basilisk.c

@ -947,17 +947,17 @@ void basilisks_loop(void *arg)
//fprintf(stderr,"E "); //fprintf(stderr,"E ");
if ( myinfo->numdpows == 1 ) if ( myinfo->numdpows == 1 )
{ {
iguana_dPoWupdate(myinfo,&myinfo->DPOWS[0]); iguana_dPoWupdate(myinfo,myinfo->DPOWS[0]);
endmilli = startmilli + 100; endmilli = startmilli + 100;
} }
else if ( myinfo->numdpows > 1 ) else if ( myinfo->numdpows > 1 )
{ {
dp = &myinfo->DPOWS[counter % myinfo->numdpows]; dp = myinfo->DPOWS[counter % myinfo->numdpows];
iguana_dPoWupdate(myinfo,dp); iguana_dPoWupdate(myinfo,dp);
//if ( (counter % myinfo->numdpows) != 0 ) //if ( (counter % myinfo->numdpows) != 0 )
{ {
//fprintf(stderr,"F "); //fprintf(stderr,"F ");
iguana_dPoWupdate(myinfo,&myinfo->DPOWS[0]); iguana_dPoWupdate(myinfo,myinfo->DPOWS[0]);
} }
endmilli = startmilli + 30; endmilli = startmilli + 30;
} }

6
basilisk/basilisk_bitcoin.c

@ -585,7 +585,9 @@ char *iguana_utxoduplicates(struct supernet_info *myinfo,struct iguana_info *coi
if ( signedtxidp != 0 ) if ( signedtxidp != 0 )
memset(signedtxidp,0,sizeof(*signedtxidp)); memset(signedtxidp,0,sizeof(*signedtxidp));
bitcoin_address(changeaddr,coin->chain->pubtype,myinfo->persistent_pubkey33,33); bitcoin_address(changeaddr,coin->chain->pubtype,myinfo->persistent_pubkey33,33);
txfee = (coin->txfee + duplicates*coin->txfee*2); txfee = (coin->txfee + duplicates*coin->txfee/10);
if ( strcmp(coin->symbol,"GAME") == 0 )
printf("GAME txfee %.8f\n",dstr(txfee));
if ( (txobj= bitcoin_txcreate(coin->symbol,coin->chain->isPoS,0,1,0)) != 0 ) if ( (txobj= bitcoin_txcreate(coin->symbol,coin->chain->isPoS,0,1,0)) != 0 )
{ {
if ( duplicates <= 0 ) if ( duplicates <= 0 )
@ -609,7 +611,7 @@ char *iguana_utxoduplicates(struct supernet_info *myinfo,struct iguana_info *coi
{ {
if ( *completedp != 0 ) if ( *completedp != 0 )
{ {
printf("splitfunds signedtx.(%s)\n",signedtx); printf("splitfunds %s signedtx.(%s)\n",coin->symbol,signedtx);
if ( sendflag != 0 ) if ( sendflag != 0 )
iguana_sendrawtransaction(myinfo,coin,signedtx); iguana_sendrawtransaction(myinfo,coin,signedtx);
free(rawtx); free(rawtx);

9
crypto777/bitcoind_RPC.c

@ -80,13 +80,13 @@ char *post_process_bitcoind_RPC(char *debugstr,char *command,char *rpcstr,char *
if ( command == 0 || rpcstr == 0 || rpcstr[0] == 0 ) if ( command == 0 || rpcstr == 0 || rpcstr[0] == 0 )
{ {
if ( strcmp(command,"signrawtransaction") != 0 && strcmp(command,"getrawtransaction") != 0 ) if ( strcmp(command,"signrawtransaction") != 0 && strcmp(command,"getrawtransaction") != 0 )
printf("<<<<<<<<<<< A bitcoind_RPC: %s post_process_bitcoind_RPC.%s.[%s]\n",debugstr,command,params); printf("<<<<<<<<<<< A bitcoind_RPC: %s post_process_bitcoind_RPC.%s\n",debugstr,command);
return(rpcstr); return(rpcstr);
} }
json = cJSON_Parse(rpcstr); json = cJSON_Parse(rpcstr);
if ( json == 0 ) if ( json == 0 )
{ {
printf("<<<<<<<<<<< B bitcoind_RPC: %s post_process_bitcoind_RPC.%s can't parse.(%s) params.(%s)\n",debugstr,command,rpcstr,params); printf("<<<<<<<<<<< B bitcoind_RPC: %s post_process_bitcoind_RPC.%s can't parse.(%s)\n",debugstr,command,rpcstr);
free(rpcstr); free(rpcstr);
return(0); return(0);
} }
@ -143,14 +143,15 @@ char *Jay_NXTrequest(char *command,char *params)
char *bitcoind_RPC(char **retstrp,char *debugstr,char *url,char *userpass,char *command,char *params,int32_t timeout) char *bitcoind_RPC(char **retstrp,char *debugstr,char *url,char *userpass,char *command,char *params,int32_t timeout)
{ {
static int didinit,count,count2; static double elapsedsum,elapsedsum2; extern int32_t USE_JAY; CURL *curl_handle; static int didinit,count,count2; static double elapsedsum,elapsedsum2; extern int32_t USE_JAY;
struct MemoryStruct chunk; struct MemoryStruct chunk;
struct curl_slist *headers = NULL; struct return_string s; CURLcode res; CURL *curl_handle; struct curl_slist *headers = NULL; struct return_string s; CURLcode res;
char *bracket0,*bracket1,*retstr,*databuf = 0; long len; int32_t specialcase,numretries; double starttime; char *bracket0,*bracket1,*retstr,*databuf = 0; long len; int32_t specialcase,numretries; double starttime;
if ( didinit == 0 ) if ( didinit == 0 )
{ {
didinit = 1; didinit = 1;
curl_global_init(CURL_GLOBAL_ALL); //init the curl session curl_global_init(CURL_GLOBAL_ALL); //init the curl session
//curl_handle = curl_easy_init();
} }
if ( (0) && (USE_JAY != 0 && (strncmp(url,"http://127.0.0.1:7876/nxt",strlen("http://127.0.0.1:7876/nxt")) == 0 || strncmp(url,"https://127.0.0.1:7876/nxt",strlen("https://127.0.0.1:7876/nxt")) == 0)) ) if ( (0) && (USE_JAY != 0 && (strncmp(url,"http://127.0.0.1:7876/nxt",strlen("http://127.0.0.1:7876/nxt")) == 0 || strncmp(url,"https://127.0.0.1:7876/nxt",strlen("https://127.0.0.1:7876/nxt")) == 0)) )
{ {

1279
deprecated/iguana_notary.c

File diff suppressed because it is too large

63
iguana/SuperNET_keys.c

@ -310,13 +310,70 @@ int32_t _SuperNET_encryptjson(struct supernet_info *myinfo,char *destfname,char
return(0); return(0);
} }
int32_t curve25519_donna(uint8_t *mypublic,const uint8_t *secret,const uint8_t *basepoint);
static const char base58_chars[] = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
int32_t iguana_wifstr_valid(char *wifstr)
{
bits256 privkey,cmpkey; uint8_t wiftype; char cmpstr[128],cmpstr2[128]; int32_t i,len,n,a,A;
if ( (len= (int32_t)strlen(wifstr)) < 50 || len > 54 )
{
//printf("len.%d is wrong for wif %s\n",len,wifstr);
return(0);
}
memset(privkey.bytes,0,sizeof(privkey));
memset(cmpkey.bytes,0,sizeof(cmpkey));
for (i=n=a=A=0; wifstr[i]!=0; i++)
{
if ( strchr(base58_chars,wifstr[i]) == 0 )
return(0);
if ( wifstr[i] >= '1' && wifstr[i] <= '9' )
n++;
else if ( wifstr[i] >= 'A' && wifstr[i] <= 'Z' )
A++;
else if ( wifstr[i] >= 'a' && wifstr[i] <= 'z' )
a++;
}
if ( n == 0 || A == 0 || a == 0 )
return(0);
if ( A > 5*a || a > 5*A || a > n*20 || A > n*20 ) // unlikely it is a real wif
{
//printf("reject wif %s due to n.%d a.%d A.%d (%d %d %d %d)\n",wifstr,n,a,A,A > 5*a,a < 5*A,a > n*20,A > n*20);
return(0);
}
bitcoin_wif2priv(&wiftype,&privkey,wifstr);
bitcoin_priv2wif(cmpstr,privkey,wiftype);
if ( strcmp(cmpstr,wifstr) == 0 )
{
//printf("%s is valid wif\n",wifstr);
return(1);
}
else if ( bits256_nonz(privkey) != 0 )
{
bitcoin_wif2priv(&wiftype,&cmpkey,cmpstr);
bitcoin_priv2wiflong(cmpstr2,privkey,wiftype);
if ( bits256_cmp(privkey,cmpkey) == 0 )
return(1);
// char str[65],str2[65]; printf("mismatched wifstr %s -> %s -> %s %s %s\n",wifstr,bits256_str(str,privkey),cmpstr,bits256_str(str2,cmpkey),cmpstr2);
}
//char str[65]; printf("%s is not a wif, privkey.%s\n",wifstr,bits256_str(str,privkey));
return(0);
}
void SuperNET_setkeys(struct supernet_info *myinfo,void *pass,int32_t passlen,int32_t dosha256) void SuperNET_setkeys(struct supernet_info *myinfo,void *pass,int32_t passlen,int32_t dosha256)
{ {
bits256 hash; static uint8_t basepoint[32] = {9}; bits256 hash; uint8_t addrtype,usedwif = 0;
if ( dosha256 != 0 ) if ( dosha256 != 0 )
{ {
memcpy(myinfo->secret,pass,passlen+1); memcpy(myinfo->secret,pass,passlen+1);
myinfo->myaddr.nxt64bits = conv_NXTpassword(myinfo->persistent_priv.bytes,myinfo->myaddr.persistent.bytes,pass,passlen); if ( iguana_wifstr_valid((char *)pass) > 0 )
{
usedwif = 1;
bitcoin_wif2priv(&addrtype,&myinfo->persistent_priv,(char *)pass);
curve25519_donna(myinfo->myaddr.persistent.bytes,myinfo->persistent_priv.bytes,basepoint);
}
else myinfo->myaddr.nxt64bits = conv_NXTpassword(myinfo->persistent_priv.bytes,myinfo->myaddr.persistent.bytes,pass,passlen);
} }
else else
{ {
@ -329,6 +386,8 @@ void SuperNET_setkeys(struct supernet_info *myinfo,void *pass,int32_t passlen,in
bitcoin_pubkey33(myinfo->ctx,myinfo->persistent_pubkey33,myinfo->persistent_priv); bitcoin_pubkey33(myinfo->ctx,myinfo->persistent_pubkey33,myinfo->persistent_priv);
bitcoin_address(myinfo->myaddr.BTC,0,myinfo->persistent_pubkey33,33); bitcoin_address(myinfo->myaddr.BTC,0,myinfo->persistent_pubkey33,33);
bitcoin_address(myinfo->myaddr.BTCD,60,myinfo->persistent_pubkey33,33); bitcoin_address(myinfo->myaddr.BTCD,60,myinfo->persistent_pubkey33,33);
if ( (0) && usedwif != 0 )
printf("usedwif for %s %s\n",myinfo->myaddr.BTCD,myinfo->myaddr.BTC);
} }
void SuperNET_parsemyinfo(struct supernet_info *myinfo,cJSON *msgjson) void SuperNET_parsemyinfo(struct supernet_info *myinfo,cJSON *msgjson)

2
iguana/acsplit

@ -1 +1 @@
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\""${1}"\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":"${2}"}" curl --url "http://127.0.0.1:7776" --data "{\"coin\":\""${1}"\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"10000\",\"sendflag\":1,\"duplicates\":"${2}"}"

2
iguana/coins/beer_7776

@ -0,0 +1,2 @@
#!/bin/bash
curl --url "http://127.0.0.1:7776" --data "{\"conf\":\"BEER.conf\",\"path\":\"${HOME#"/"}/.komodo/BEER\",\"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\":\"BEER\",\"name\":\"BEER\",\"hasheaders\":1,\"useaddmultisig\":0,\"netmagic\":\"9fecbb6e\",\"p2p\":8922,\"rpc\":8923,\"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/coins/game_7776

@ -0,0 +1,2 @@
#!/bin/bash
curl --url "http://127.0.0.1:7776" --data "{\"txfee\":0.01,\"conf\":\"gamecredits.conf\",\"path\":\"${HOME#"/"}/.gamecredits\",\"startpend\":8,\"endpend\":4,\"services\":129,\"RELAY\":-1,\"VALIDATE\":0,\"prefetchlag\":-1,\"poll\":10,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"maxpeers\":256,\"newcoin\":\"GAME\",\"name\":\"gamecredits\",\"netmagic\":\"fbc0b6db\",\"p2p\":40002,\"rpc\":40001,\"pubval\":38,\"p2shval\":5,\"wifval\":166,\"txfee_satoshis\":\"1000000\",\"minconfirms\":2,\"genesishash\":\"91ec5f25ee9a0ffa1af7d4da4db9a552228dd2dc77cdb15b738be4e1f55f30ee\",\"genesis\":{\"hashalgo\":\"scrypt\",\"version\":1,\"timestamp\":1392757140,\"nBits\":\"1e0ffff0\",\"nonce\":2084565393,\"merkle_root\":\"d849db99a14164f4b4c8ad6d2d8d7e2b1ba7f89963e9f4bf9fad5ff1a4754429\"},\"alertpubkey\":\"04fc9702847840aaf195de8442ebecedf5b095cdbb9bc716bda9110971b28a49e0ead8564ff0db22209e0374782c093bb899692d524e9d6a6956e7c5ecbcd68284\",\"auxpow\":1,\"protover\":80006,\"isPoS\":0,\"fixit\":0}"

2
iguana/coins/pizza_7776

@ -0,0 +1,2 @@
#!/bin/bash
curl --url "http://127.0.0.1:7776" --data "{\"conf\":\"PIZZA.conf\",\"path\":\"${HOME#"/"}/.komodo/PIZZA\",\"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\":\"PIZZA\",\"name\":\"PIZZA\",\"hasheaders\":1,\"useaddmultisig\":0,\"netmagic\":\"adbe523c\",\"p2p\":11607,\"rpc\":11608,\"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\"}"

18
iguana/dPoW.h

@ -16,10 +16,11 @@
#ifndef INCLUDE_DPOW_H #ifndef INCLUDE_DPOW_H
#define INCLUDE_DPOW_H #define INCLUDE_DPOW_H
#define DPOW_MAXMOMDEPTH (1440 * 7) //#define DPOW_MAXMOMDEPTH (1440 * 7)
#define DPOW_FIRSTRATIFY 1000 #define DPOW_FIRSTRATIFY 1000
#define DPOW_MAXFREQ 100
#define DPOW_CHECKPOINTFREQ 10 #define DPOW_CHECKPOINTFREQ 10
#define DPOW_MINSIGS 13 #define DPOW_MINSIGS 13
#define DPOW_MIN_ASSETCHAIN_SIGS 11 #define DPOW_MIN_ASSETCHAIN_SIGS 11
@ -28,7 +29,7 @@
#define DPOW_VERSION 0x1782 #define DPOW_VERSION 0x1782
#define DPOW_UTXOSIZE 10000//50000 #define DPOW_UTXOSIZE 10000//50000
#define DPOW_MINOUTPUT 6000 #define DPOW_MINOUTPUT 6000
#define DPOW_DURATION 600 #define DPOW_DURATION 1200
#define DPOW_RATIFYDURATION (3600 * 24) #define DPOW_RATIFYDURATION (3600 * 24)
//#define DPOW_ENTRIESCHANNEL ('e' | ('n' << 8) | ('t' << 16) | ('r' << 24)) //#define DPOW_ENTRIESCHANNEL ('e' | ('n' << 8) | ('t' << 16) | ('r' << 24))
@ -48,7 +49,7 @@
#define DPOW_MAXRELAYS 64 #define DPOW_MAXRELAYS 64
#define DPOW_MAXSIGLEN 128 #define DPOW_MAXSIGLEN 128
#define DEX_VERSION 0x0105 #define DEX_VERSION 0x0106
#define DPOW_SOCKPORT 7775 #define DPOW_SOCKPORT 7775
#define DEX_SOCK 7774 #define DEX_SOCK 7774
#define PUB_SOCK 7773 #define PUB_SOCK 7773
@ -104,16 +105,19 @@ struct dpow_checkpoint
bits256 miner; uint32_t blocktime,timestamp; bits256 miner; uint32_t blocktime,timestamp;
}; };
struct dpow_recvdata { uint64_t recvmask,bestmask; int8_t bestk; };
struct dpow_block struct dpow_block
{ {
bits256 hashmsg,desttxid,srctxid,beacon,commit,MoM; bits256 hashmsg,desttxid,srctxid,beacon,commit,MoM;
struct iguana_info *srccoin,*destcoin; char *opret_symbol; struct iguana_info *srccoin,*destcoin; char *opret_symbol;
uint64_t destsigsmasks[DPOW_MAXRELAYS],srcsigsmasks[DPOW_MAXRELAYS]; uint64_t destsigsmasks[DPOW_MAXRELAYS],srcsigsmasks[DPOW_MAXRELAYS];
uint64_t recvmask,bestmask,ratifybestmask,ratifyrecvmask,pendingbestmask,pendingratifybestmask,ratifysigmasks[2]; uint64_t recvmask,bestmask,ratifybestmask,ratifyrecvmask,pendingbestmask,pendingratifybestmask,ratifysigmasks[2];
struct dpow_recvdata recv[64];
struct dpow_entry notaries[DPOW_MAXRELAYS]; struct dpow_entry notaries[DPOW_MAXRELAYS];
uint32_t MoMdepth,state,starttime,timestamp,waiting,sigcrcs[2],txidcrcs[2],utxocrcs[2],lastepoch,paxwdcrc; uint32_t MoMdepth,state,starttime,timestamp,waiting,sigcrcs[2],txidcrcs[2],utxocrcs[2],lastepoch,paxwdcrc,lastnanosend;
int32_t rawratifiedlens[2],height,numnotaries,numerrors,completed,minsigs,duration,numratified,isratify,require0,scores[DPOW_MAXRELAYS]; int32_t rawratifiedlens[2],height,numnotaries,numerrors,completed,minsigs,duration,numratified,isratify,require0,scores[DPOW_MAXRELAYS];
int8_t myind,bestk,ratifybestk,pendingbestk,pendingratifybestk; int8_t myind,bestk,ratifybestk,pendingbestk,pendingratifybestk,matches,bestmatches;
cJSON *ratified; cJSON *ratified;
uint8_t ratified_pubkeys[DPOW_MAXRELAYS][33],ratifysigs[2][DPOW_MAXSIGLEN],ratifysiglens[2]; uint8_t ratified_pubkeys[DPOW_MAXRELAYS][33],ratifysigs[2][DPOW_MAXSIGLEN],ratifysiglens[2];
char handles[DPOW_MAXRELAYS][32]; char handles[DPOW_MAXRELAYS][32];
@ -137,11 +141,11 @@ struct dpow_info
struct dpow_hashheight approved[DPOW_FIFOSIZE],notarized[DPOW_FIFOSIZE]; struct dpow_hashheight approved[DPOW_FIFOSIZE],notarized[DPOW_FIFOSIZE];
bits256 activehash,lastnotarized,srctx[DPOW_MAXTX],desttx[DPOW_MAXTX]; bits256 activehash,lastnotarized,srctx[DPOW_MAXTX],desttx[DPOW_MAXTX];
uint32_t SRCREALTIME,lastsrcupdate,destupdated,srcconfirms,numdesttx,numsrctx,lastsplit,cancelratify; uint32_t SRCREALTIME,lastsrcupdate,destupdated,srcconfirms,numdesttx,numsrctx,lastsplit,cancelratify;
int32_t lastheight,maxblocks,SRCHEIGHT,SHORTFLAG,ratifying; int32_t lastheight,maxblocks,SRCHEIGHT,DESTHEIGHT,prevDESTHEIGHT,SHORTFLAG,ratifying,minsigs,freq;
struct pax_transaction *PAX; struct pax_transaction *PAX;
portable_mutex_t paxmutex,dexmutex; portable_mutex_t paxmutex,dexmutex;
uint32_t ipbits[128],numipbits; uint32_t ipbits[128],numipbits;
struct dpow_block **blocks; struct dpow_block **blocks,*currentbp;
}; };
struct komodo_ccdatapair { int32_t notarization_height; uint32_t MoMoMoffset; }; struct komodo_ccdatapair { int32_t notarization_height; uint32_t MoMoMoffset; };

228
iguana/dpow/dPoW.h

@ -1,228 +0,0 @@
/******************************************************************************
* Copyright © 2014-2018 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. *
* *
******************************************************************************/
#ifndef INCLUDE_DPOW_H
#define INCLUDE_DPOW_H
#define DPOW_MAXMOMDEPTH (1440)
#define DPOW_FIRSTRATIFY 1000
#define DPOW_CHECKPOINTFREQ 10
#define DPOW_MINSIGS 13
#define DPOW_MIN_ASSETCHAIN_SIGS 11
//#define DPOW_M(bp) ((bp)->minsigs) // (((bp)->numnotaries >> 1) + 1)
#define DPOW_MODIND(bp,offset) (((((bp)->height / DPOW_CHECKPOINTFREQ) % (bp)->numnotaries) + (offset)) % (bp)->numnotaries)
#define DPOW_VERSION 0x1782
#define DPOW_UTXOSIZE 10000//50000
#define DPOW_MINOUTPUT 6000
#define DPOW_DURATION 600
#define DPOW_RATIFYDURATION (3600 * 24)
//#define DPOW_ENTRIESCHANNEL ('e' | ('n' << 8) | ('t' << 16) | ('r' << 24))
//#define DPOW_BTCENTRIESCHANNEL (~DPOW_ENTRIESCHANNEL)
//#define DPOW_UTXOCHANNEL ('d' | ('P' << 8) | ('o' << 16) | ('W' << 24))
#define DPOW_SIGCHANNEL ('s' | ('i' << 8) | ('g' << 16) | ('s' << 24))
#define DPOW_SIGBTCCHANNEL (~DPOW_SIGCHANNEL)
#define DPOW_TXIDCHANNEL ('t' | ('x' << 8) | ('i' << 16) | ('d' << 24))
#define DPOW_BTCTXIDCHANNEL (~DPOW_TXIDCHANNEL)
#define DPOW_FIFOSIZE 64
#define DPOW_MAXTX 8192
#define DPOW_THIRDPARTY_CONFIRMS 0
#define DPOW_KOMODOCONFIRMS 10
#define DPOW_BTCCONFIRMS 1
#define DPOW_MAXRELAYS 64
#define DPOW_MAXSIGLEN 128
#define DEX_VERSION 0x0105
#define DPOW_SOCKPORT 7775
#define DEX_SOCK 7774
#define PUB_SOCK 7773
#define REP_SOCK 7772
#define DPOW_EPOCHDURATION 600
struct dpow_coinentry
{
bits256 prev_hash;
uint8_t siglens[DPOW_MAXRELAYS],sigs[DPOW_MAXRELAYS][DPOW_MAXSIGLEN];
int32_t prev_vout;
};
struct dpow_utxoentry
{
bits256 srchash,desthash,commit,hashmsg;
uint64_t recvmask,othermasks[DPOW_MAXRELAYS];
int32_t srcvout,destvout,height;
int8_t bestk; uint8_t pubkey[33];
};
struct dpow_entry
{
bits256 commit,beacon,ratifysrcutxo,ratifydestutxo;
uint64_t masks[2][DPOW_MAXRELAYS],recvmask,othermask,bestmask,ratifyrecvmask,ratifybestmask;
int32_t height; uint32_t pendingcrcs[2],paxwdcrc;
uint16_t ratifysrcvout,ratifydestvout;
int8_t bestk,ratifybestk;
uint8_t pubkey[33],ratifysigs[2][DPOW_MAXSIGLEN],ratifysiglens[2];
struct dpow_coinentry src,dest;
};
struct dpow_sigentry
{
bits256 beacon;
uint64_t mask;
int32_t refcount;
uint8_t senderind,lastk,siglen,sig[DPOW_MAXSIGLEN],senderpub[33];
};
struct komodo_notaries
{
struct basilisk_relay RELAYS[DPOW_MAXRELAYS];
int32_t NUMRELAYS,RELAYID;
};
struct dpow_hashheight { bits256 hash; int32_t height; };
struct dpow_checkpoint
{
struct dpow_hashheight blockhash,approved;
bits256 miner; uint32_t blocktime,timestamp;
};
struct dpow_block
{
bits256 hashmsg,desttxid,srctxid,beacon,commit,MoM;
struct iguana_info *srccoin,*destcoin; char *opret_symbol;
uint64_t destsigsmasks[DPOW_MAXRELAYS],srcsigsmasks[DPOW_MAXRELAYS];
uint64_t recvmask,bestmask,ratifybestmask,ratifyrecvmask,pendingbestmask,pendingratifybestmask,ratifysigmasks[2];
struct dpow_entry notaries[DPOW_MAXRELAYS];
uint32_t MoMdepth,state,starttime,timestamp,waiting,sigcrcs[2],txidcrcs[2],utxocrcs[2],lastepoch,paxwdcrc;
int32_t rawratifiedlens[2],height,numnotaries,numerrors,completed,minsigs,duration,numratified,isratify,require0,scores[DPOW_MAXRELAYS];
int8_t myind,bestk,ratifybestk,pendingbestk,pendingratifybestk;
cJSON *ratified;
uint8_t ratified_pubkeys[DPOW_MAXRELAYS][33],ratifysigs[2][DPOW_MAXSIGLEN],ratifysiglens[2];
char handles[DPOW_MAXRELAYS][32];
char signedtx[32768]; uint8_t ratifyrawtx[2][32768]; uint32_t pendingcrcs[2];
};
struct pax_transaction
{
UT_hash_handle hh;
bits256 txid;
uint64_t komodoshis,fiatoshis;
int32_t marked,height,kmdheight;
uint16_t vout;
char symbol[16],coinaddr[64]; uint8_t rmd160[20],shortflag;
};
struct dpow_info
{
char symbol[16],dest[16]; uint8_t minerkey33[33],minerid; uint64_t lastrecvmask;
struct dpow_checkpoint checkpoint,last,destchaintip,srcfifo[DPOW_FIFOSIZE],destfifo[DPOW_FIFOSIZE];
struct dpow_hashheight approved[DPOW_FIFOSIZE],notarized[DPOW_FIFOSIZE];
bits256 activehash,lastnotarized,srctx[DPOW_MAXTX],desttx[DPOW_MAXTX];
uint32_t SRCREALTIME,lastsrcupdate,destupdated,srcconfirms,numdesttx,numsrctx,lastsplit,cancelratify;
int32_t lastheight,maxblocks,SRCHEIGHT,SHORTFLAG,ratifying;
struct pax_transaction *PAX;
portable_mutex_t paxmutex,dexmutex;
uint32_t ipbits[128],numipbits;
struct dpow_block **blocks;
};
struct komodo_ccdatapair { int32_t notarization_height; uint32_t MoMoMoffset; };
struct komodo_ccdataMoMoM
{
bits256 MoMoM;
int32_t kmdstarti,kmdendi,MoMoMdepth,numpairs,len;
struct komodo_ccdatapair *pairs;
};
uint64_t dpow_notarybestk(uint64_t refmask,struct dpow_block *bp,int8_t *lastkp);
int32_t dpow_paxpending(uint8_t *hex,int32_t hexsize,uint32_t *paxwdcrcp,bits256 MoM,uint32_t MoMdepth,int32_t src_or_dest,struct dpow_block *bp);
void dex_updateclient(struct supernet_info *myinfo);
char *dex_reqsend(struct supernet_info *myinfo,char *handler,uint8_t *data,int32_t datalen,int32_t M,char *field);
char *basilisk_respond_addmessage(struct supernet_info *myinfo,uint8_t *key,int32_t keylen,uint8_t *data,int32_t datalen,int32_t sendping,uint32_t duration);
int32_t dpow_getchaintip(struct supernet_info *myinfo,bits256 *merklerootp,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,char *srccoin);
void komodo_assetcoins(int32_t fullnode,uint64_t mask);
int32_t iguana_isnotarychain(char *symbol);
cJSON *dpow_getinfo(struct supernet_info *myinfo,struct iguana_info *coin);
cJSON *dpow_gettransaction(struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid);
cJSON *dpow_getblock(struct supernet_info *myinfo,struct iguana_info *coin,bits256 blockhash);
bits256 dpow_getblockhash(struct supernet_info *myinfo,struct iguana_info *coin,int32_t height);
bits256 dpow_getbestblockhash(struct supernet_info *myinfo,struct iguana_info *coin);
char *dpow_sendrawtransaction(struct supernet_info *myinfo,struct iguana_info *coin,char *signedtx);
cJSON *dpow_gettxout(struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid,int32_t vout);
char *dpow_importaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address);
char *dpow_validateaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address);
cJSON *dpow_listunspent(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr);
cJSON *dpow_listtransactions(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr,int32_t count,int32_t skip);
char *dpow_alladdresses(struct supernet_info *myinfo,struct iguana_info *coin);
cJSON *dpow_kvupdate(struct supernet_info *myinfo,struct iguana_info *coin,char *key,char *value,int32_t flags);
cJSON *dpow_kvsearch(struct supernet_info *myinfo,struct iguana_info *coin,char *key);
void init_alladdresses(struct supernet_info *myinfo,struct iguana_info *coin);
cJSON *dpow_getmessage(struct supernet_info *myinfo,char *jsonstr);
cJSON *dpow_addmessage(struct supernet_info *myinfo,char *jsonstr);
cJSON *dpow_psock(struct supernet_info *myinfo,char *jsonstr);
char *_dex_getinfo(struct supernet_info *myinfo,char *symbol);
char *_dex_getrawtransaction(struct supernet_info *myinfo,char *symbol,bits256 txid);
char *_dex_getblock(struct supernet_info *myinfo,char *symbol,bits256 hash2);
char *_dex_getblockhash(struct supernet_info *myinfo,char *symbol,int32_t height);
char *_dex_getbestblockhash(struct supernet_info *myinfo,char *symbol);
char *_dex_sendrawtransaction(struct supernet_info *myinfo,char *symbol,char *signedtx);
char *_dex_gettxout(struct supernet_info *myinfo,char *symbol,bits256 txid,int32_t vout);
char *_dex_gettxin(struct supernet_info *myinfo,char *symbol,bits256 txid,int32_t vout);
char *_dex_importaddress(struct supernet_info *myinfo,char *symbol,char *address);
char *_dex_validateaddress(struct supernet_info *myinfo,char *symbol,char *address);
char *_dex_getmessage(struct supernet_info *myinfo,char *jsonstr);
char *_dex_listunspent(struct supernet_info *myinfo,char *symbol,char *address);
char *_dex_listunspent2(struct supernet_info *myinfo,char *symbol,char *address);
char *_dex_listspent(struct supernet_info *myinfo,char *symbol,char *address);
char *_dex_getbalance(struct supernet_info *myinfo,char *symbol,char *address);
char *_dex_listtransactions(struct supernet_info *myinfo,char *symbol,char *coinaddr,int32_t count,int32_t skip);
char *_dex_listtransactions2(struct supernet_info *myinfo,char *symbol,char *coinaddr,int32_t count,int32_t skip);
char *_dex_alladdresses(struct supernet_info *myinfo,char *symbol);
int32_t _dex_getheight(struct supernet_info *myinfo,char *symbol);
char *_dex_getnotaries(struct supernet_info *myinfo,char *symbol);
char *_dex_kvupdate(struct supernet_info *myinfo,char *symbol,char *key,char *value,int32_t flags);
char *_dex_kvsearch(struct supernet_info *myinfo,char *symbol,char *key);
char *_dex_psock(struct supernet_info *myinfo,char *jsonstr);
int32_t komodo_notaries(char *symbol,uint8_t pubkeys[64][33],int32_t height);
cJSON *dpow_checkaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address);
void dex_channelsend(struct supernet_info *myinfo,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgid,uint8_t *data,int32_t datalen);
void kmd_bitcoinscan();
cJSON *kmd_getbalance(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr);
struct iguana_info *iguana_coinfind(char *symbol);
cJSON *kmd_listtransactions(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr,int32_t count,int32_t skip);
cJSON *kmd_listunspent(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr);
cJSON *kmd_listspent(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr);
cJSON *kmd_gettxin(struct iguana_info *coin,bits256 txid,int32_t vout);
cJSON *dpow_listspent(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr);
cJSON *dpow_getbalance(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr);
cJSON *dpow_gettxin(struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid,int32_t vout);
#endif

228
iguana/dpow/dpow_fsm.c

@ -230,185 +230,31 @@ int32_t dpow_opreturn_parsesrc(bits256 *blockhashp,int32_t *heightp,bits256 *txi
return(-1); return(-1);
} }
int32_t dpow_txhasnotarization(uint64_t *signedmaskp,int32_t *nothtp,struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid,int32_t height,struct komodo_ccdataMoMoM *mdata)
{
cJSON *txobj,*vins,*vin,*vouts,*vout,*spentobj,*sobj; char *hexstr; uint8_t script[256]; bits256 spenttxid; uint64_t notarymask=0; int32_t i,j,numnotaries,len,spentvout,numvins,numvouts,hasnotarization = 0;
if ( (txobj= dpow_gettransaction(myinfo,coin,txid)) != 0 )
{
if ( (vins= jarray(&numvins,txobj,"vin")) != 0 )
{
if ( numvins >= DPOW_MIN_ASSETCHAIN_SIGS )
{
notarymask = numnotaries = 0;
for (i=0; i<numvins; i++)
{
vin = jitem(vins,i);
spenttxid = jbits256(vin,"txid");
spentvout = jint(vin,"vout");
if ( (spentobj= dpow_gettransaction(myinfo,coin,spenttxid)) != 0 )
{
if ( (vouts= jarray(&numvouts,spentobj,"vout")) != 0 )
{
if ( spentvout < numvouts )
{
vout = jitem(vouts,spentvout);
if ( (sobj= jobj(vout,"scriptPubKey")) != 0 && (hexstr= jstr(sobj,"hex")) != 0 && (len= is_hexstr(hexstr,0)) == 35*2 )
{
len >>= 1;
decode_hex(script,len,hexstr);
if ( script[0] == 33 && script[34] == 0xac )
{
for (j=0; j<Notaries_num; j++)
{
if ( strncmp(Notaries_elected[j][1],hexstr+2,66) == 0 )
{
if ( ((1LL << j) & notarymask) == 0 )
{
//printf("n%d ",j);
numnotaries++;
notarymask |= (1LL << j);
break;
}
}
}
}
}
}
}
free_json(spentobj);
}
}
if ( numnotaries > 0 )
{
if ( numnotaries >= DPOW_MIN_ASSETCHAIN_SIGS )
{
hasnotarization = 1;
*nothtp = 0;
if ( (vouts= jarray(&numvouts,txobj,"vout")) != 0 )
{
bits256 blockhash,txid,MoM; uint32_t MoMdepth; char symbol[65];//,str[65],str2[65],str3[65];
vout = jitem(vouts,numvouts-1);
if ( (sobj= jobj(vout,"scriptPubKey")) != 0 && (hexstr= jstr(sobj,"hex")) != 0 && (len= is_hexstr(hexstr,0)) > 36*2 && len < sizeof(script)*2 )
{
len >>= 1;
decode_hex(script,len,hexstr);
if ( dpow_opreturn_parsesrc(&blockhash,nothtp,&txid,symbol,&MoM,&MoMdepth,script,len,mdata) > 0 && strcmp(symbol,coin->symbol) == 0 )
{
// if ( Notaries_port != DPOW_SOCKPORT ) // keep going till valid MoM found, useful for new chains without any MoM
{
if ( bits256_nonz(MoM) == 0 || MoMdepth == 0 || *nothtp >= height || *nothtp < 0 )
{
*nothtp = 0;
}
}
if ( mdata->pairs != 0 && mdata->numpairs > 0 )
{
for (j=0; j<mdata->numpairs; j++)
{
if ( mdata->pairs[j].notarization_height > coin->MoMoMheight )
{
coin->MoMoMheight = mdata->pairs[j].notarization_height;
printf("set %s MoMoMheight <- %d\n",coin->symbol,coin->MoMoMheight);
}
}
}
//printf("%s.%d notarizationht.%d %s -> %s MoM.%s [%d]\n",symbol,height,*nothtp,bits256_str(str,blockhash),bits256_str(str2,txid),bits256_str(str3,MoM),MoMdepth);
}
}
}
}
}
}
}
free_json(txobj);
}
if ( hasnotarization != 0 )
(*signedmaskp) = notarymask;
return(hasnotarization);
}
int32_t dpow_hasnotarization(uint64_t *signedmaskp,int32_t *nothtp,struct supernet_info *myinfo,struct iguana_info *coin,cJSON *blockjson,int32_t ht,struct komodo_ccdataMoMoM *mdata)
{
int32_t i,n,hasnotarization = 0; bits256 txid; cJSON *txarray;
*nothtp = 0;
*signedmaskp = 0;
memset(mdata,0,sizeof(*mdata));
if ( (txarray= jarray(&n,blockjson,"tx")) != 0 )
{
for (i=0; i<n; i++)
{
txid = jbits256i(txarray,i);
hasnotarization += dpow_txhasnotarization(signedmaskp,nothtp,myinfo,coin,txid,ht,mdata);
}
}
return(hasnotarization);
}
bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct iguana_info *coin,int32_t height) bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct iguana_info *coin,int32_t height)
{ {
struct komodo_ccdataMoMoM mdata; bits256 MoM,blockhash,merkle,*merkles; cJSON *blockjson; uint64_t signedmask; int32_t breakht=0,notht=0,ht,maxdepth = DPOW_MAXMOMDEPTH,MoMdepth = 0; bits256 MoM; cJSON *MoMjson,*infojson; int32_t prevMoMheight;
*MoMdepthp = 0;
memset(MoM.bytes,0,sizeof(MoM)); memset(MoM.bytes,0,sizeof(MoM));
blockhash = dpow_getblockhash(myinfo,coin,height); if ( (infojson= dpow_getinfo(myinfo,coin)) != 0 )
//printf("start MoM calc %s height.%d\n",coin->symbol,height);
if ( (blockjson= dpow_getblock(myinfo,coin,blockhash)) != 0 )
{ {
merkle = jbits256(blockjson,"merkleroot"); if ( (prevMoMheight= jint(infojson,"prevMoMheight")) >= 0 )
free_json(blockjson);
if ( bits256_nonz(merkle) != 0 )
{ {
merkles = calloc(4*maxdepth+1,sizeof(*merkles)); if ( prevMoMheight == 0 )
merkles[MoMdepth++] = merkle; prevMoMheight = 1;
ht = height - MoMdepth; *MoMdepthp = (height - prevMoMheight);
while ( MoMdepth < maxdepth && ht > breakht && ht > 0 ) //printf("%s ht.%d prevMoM.%d -> depth %d\n",coin->symbol,height,prevMoMheight,*MoMdepthp);
{ if ( *MoMdepthp > 1440*30 )
//fprintf(stderr,"%s.%d ",coin->symbol,ht); *MoMdepthp = 1440*30;
blockhash = dpow_getblockhash(myinfo,coin,ht); if ( *MoMdepthp > 0 && (MoMjson= issue_calcMoM(coin,height,*MoMdepthp)) != 0 )
if ( (blockjson= dpow_getblock(myinfo,coin,blockhash)) != 0 )
{
if ( breakht == 0 && dpow_hasnotarization(&signedmask,&notht,myinfo,coin,blockjson,ht,&mdata) > 0 )
{
breakht = notht;
printf("%s has notarization at %d for breakht.%d\n",coin->symbol,ht,notht);
}
merkle = jbits256(blockjson,"merkleroot");
free_json(blockjson);
if ( bits256_nonz(merkle) != 0 )
merkles[MoMdepth++] = merkle;
else
{
printf("%s MoMdepth.%d ht.%d from height.%d, null merkleroot\n",coin->symbol,MoMdepth,ht,height);
MoMdepth = 0;
if ( mdata.pairs != 0 )
free(mdata.pairs);
break;
}
}
else
{
printf("%s MoMdepth.%d ht.%d from height.%d, no blockhash\n",coin->symbol,MoMdepth,ht,height);
MoMdepth = 0;
if ( mdata.pairs != 0 )
free(mdata.pairs);
break;
}
ht = height - MoMdepth;
usleep(10000);
}
if ( MoMdepth > 0 )
{ {
MoM = iguana_merkle(coin->symbol,merkles,MoMdepth); MoM = jbits256(MoMjson,"MoM");
char str[65]; printf("%s from height.%d ht.%d MoMdepth.%d -> MoM %s\n",coin->symbol,height,ht,MoMdepth,bits256_str(str,MoM)); free_json(MoMjson);
} }
else }
{ free_json(infojson);
printf("unexpected %s from height.%d MoMdepth.%d vs max.%d\n",coin->symbol,height,MoMdepth,maxdepth); }
MoMdepth = 0; if ( bits256_nonz(MoM) == 0 )
} *MoMdepthp = 0;
free(merkles);
} else printf("%s.ht%d null merkles\n",coin->symbol,height);
} else printf("%s.ht%d null block\n",coin->symbol,height);
*MoMdepthp = MoMdepth;
//printf("done MoM calc %s height.%d MoMdepth.%d\n",coin->symbol,height,MoMdepth);
return(MoM); return(MoM);
} }
@ -439,13 +285,14 @@ void dpow_statemachinestart(void *ptr)
return; return;
} }
MoMdepth = 0; MoMdepth = 0;
portable_mutex_lock(&src->MoM_mutex); memset(&MoM,0,sizeof(MoM));
MoM = dpow_calcMoM(&MoMdepth,myinfo,src,checkpoint.blockhash.height);
portable_mutex_unlock(&src->MoM_mutex);
if ( strcmp(src->symbol,"KMD") == 0 ) if ( strcmp(src->symbol,"KMD") == 0 )
kmdheight = checkpoint.blockhash.height; kmdheight = checkpoint.blockhash.height;
else if ( strcmp(dest->symbol,"KMD") == 0 ) else if ( strcmp(dest->symbol,"KMD") == 0 )
{
MoM = dpow_calcMoM(&MoMdepth,myinfo,src,checkpoint.blockhash.height);
kmdheight = dest->longestchain; kmdheight = dest->longestchain;
}
if ( (bp= dp->blocks[checkpoint.blockhash.height]) == 0 ) if ( (bp= dp->blocks[checkpoint.blockhash.height]) == 0 )
{ {
bp = calloc(1,sizeof(*bp)); bp = calloc(1,sizeof(*bp));
@ -458,6 +305,8 @@ void dpow_statemachinestart(void *ptr)
bp->srccoin = src; bp->srccoin = src;
bp->destcoin = dest; bp->destcoin = dest;
bp->myind = -1; bp->myind = -1;
for (i=0; i<sizeof(bp->notaries)/sizeof(*bp->notaries); i++)
bp->notaries[i].bestk = -1;
bp->opret_symbol = dp->symbol; bp->opret_symbol = dp->symbol;
if ( jsonstr != 0 && (ratified= cJSON_Parse(jsonstr)) != 0 ) if ( jsonstr != 0 && (ratified= cJSON_Parse(jsonstr)) != 0 )
{ {
@ -511,8 +360,9 @@ void dpow_statemachinestart(void *ptr)
} }
free_json(ratified); free_json(ratified);
} }
bp->bestk = -1; bp->pendingbestk = bp->bestk = -1;
dp->blocks[checkpoint.blockhash.height] = bp; dp->blocks[checkpoint.blockhash.height] = bp;
dp->currentbp = bp;
bp->beacon = rand256(0); bp->beacon = rand256(0);
vcalc_sha256(0,bp->commit.bytes,bp->beacon.bytes,sizeof(bp->beacon)); vcalc_sha256(0,bp->commit.bytes,bp->beacon.bytes,sizeof(bp->beacon));
} }
@ -558,9 +408,9 @@ void dpow_statemachinestart(void *ptr)
{ {
myind = i; myind = i;
ep = &bp->notaries[myind]; ep = &bp->notaries[myind];
for (j=0; j<33; j++) //for (j=0; j<33; j++)
printf("%02x",dp->minerkey33[j]); // printf("%02x",dp->minerkey33[j]);
printf(" MYIND.%d <<<<<<<<<<<<<<<<<<<<<<\n",myind); //printf(" MYIND.%d <<<<<<<<<<<<<<<<<<<<<<\n",myind);
} }
} }
if ( strcmp("KMD",src->symbol) == 0 ) if ( strcmp("KMD",src->symbol) == 0 )
@ -573,9 +423,10 @@ void dpow_statemachinestart(void *ptr)
printf(" statemachinestart this node %s %s is not official notary numnotaries.%d kmdht.%d bpht.%d\n",srcaddr,destaddr,bp->numnotaries,kmdheight,bp->height); printf(" statemachinestart this node %s %s is not official notary numnotaries.%d kmdht.%d bpht.%d\n",srcaddr,destaddr,bp->numnotaries,kmdheight,bp->height);
free(ptr); free(ptr);
dp->ratifying -= bp->isratify; dp->ratifying -= bp->isratify;
exit(-1);
return; return;
} }
printf("myind.%d\n",myind); //printf("myind.%d\n",myind);
} }
else else
{ {
@ -585,7 +436,7 @@ void dpow_statemachinestart(void *ptr)
return; return;
} }
bp->myind = myind; bp->myind = myind;
printf("[%d] notarize %s->%s %s ht.%d minsigs.%d duration.%d start.%u\n",bp->myind,dp->symbol,dp->dest,bits256_str(str,checkpoint.blockhash.hash),checkpoint.blockhash.height,minsigs,duration,checkpoint.timestamp); printf("[%d] notarize %s->%s %s ht.%d minsigs.%d duration.%d start.%u MoM[%d] %s\n",bp->myind,dp->symbol,dp->dest,bits256_str(str,checkpoint.blockhash.hash),checkpoint.blockhash.height,minsigs,duration,checkpoint.timestamp,bp->MoMdepth,bits256_str(str2,bp->MoM));
if ( bp->isratify != 0 && memcmp(bp->notaries[0].pubkey,bp->ratified_pubkeys[0],33) != 0 ) if ( bp->isratify != 0 && memcmp(bp->notaries[0].pubkey,bp->ratified_pubkeys[0],33) != 0 )
{ {
for (i=0; i<33; i++) for (i=0; i<33; i++)
@ -635,6 +486,13 @@ void dpow_statemachinestart(void *ptr)
bp->notaries[myind].ratifydestvout = ep->dest.prev_vout; bp->notaries[myind].ratifydestvout = ep->dest.prev_vout;
} }
} }
/*if ( strcmp(dp->symbol,"CHIPS") == 0 && myind == 0 )
{
char str[65];
printf(">>>>>>> CHIPS myind.%d %s/v%d\n",myind,bits256_str(str,bp->notaries[myind].src.prev_hash),bp->notaries[myind].src.prev_vout);
bp->desttxid = bp->notaries[myind].src.prev_hash;
dpow_signedtxgen(myinfo,dp,src,bp,bp->myind,1LL<<bp->myind,bp->myind,DPOW_SIGCHANNEL,0,0);
}*/
bp->recvmask |= (1LL << myind); bp->recvmask |= (1LL << myind);
bp->notaries[myind].othermask |= (1LL << myind); bp->notaries[myind].othermask |= (1LL << myind);
dp->checkpoint = checkpoint; dp->checkpoint = checkpoint;
@ -644,7 +502,7 @@ void dpow_statemachinestart(void *ptr)
bp->myind = myind; bp->myind = myind;
while ( bp->isratify == 0 && dp->destupdated == 0 ) while ( bp->isratify == 0 && dp->destupdated == 0 )
{ {
if ( (checkpoint.blockhash.height % 100) != 0 && dp->checkpoint.blockhash.height > checkpoint.blockhash.height ) if ( dp->checkpoint.blockhash.height > checkpoint.blockhash.height ) //(checkpoint.blockhash.height % 100) != 0 &&
{ {
//printf("abort %s ht.%d due to new checkpoint.%d\n",dp->symbol,checkpoint.blockhash.height,dp->checkpoint.blockhash.height); //printf("abort %s ht.%d due to new checkpoint.%d\n",dp->symbol,checkpoint.blockhash.height,dp->checkpoint.blockhash.height);
dp->ratifying -= bp->isratify; dp->ratifying -= bp->isratify;
@ -663,7 +521,7 @@ void dpow_statemachinestart(void *ptr)
extralen = dpow_paxpending(extras,sizeof(extras),&bp->paxwdcrc,bp->MoM,bp->MoMdepth,src_or_dest,bp); extralen = dpow_paxpending(extras,sizeof(extras),&bp->paxwdcrc,bp->MoM,bp->MoMdepth,src_or_dest,bp);
bp->notaries[bp->myind].paxwdcrc = bp->paxwdcrc; bp->notaries[bp->myind].paxwdcrc = bp->paxwdcrc;
} }
printf("PAXWDCRC.%x myind.%d isratify.%d DPOW.%s statemachine checkpoint.%d %s start.%u+dur.%d vs %ld\n",bp->paxwdcrc,bp->myind,bp->isratify,src->symbol,checkpoint.blockhash.height,bits256_str(str,checkpoint.blockhash.hash),starttime,bp->duration,time(NULL)); printf("PAXWDCRC.%x myind.%d isratify.%d DPOW.%s statemachine checkpoint.%d %s start.%u+dur.%d vs %ld MoM[%d] %s\n",bp->paxwdcrc,bp->myind,bp->isratify,src->symbol,checkpoint.blockhash.height,bits256_str(str,checkpoint.blockhash.hash),starttime,bp->duration,time(NULL),bp->MoMdepth,bits256_str(str2,bp->MoM));
for (i=0; i<sizeof(srchash); i++) for (i=0; i<sizeof(srchash); i++)
srchash.bytes[i] = dp->minerkey33[i+1]; srchash.bytes[i] = dp->minerkey33[i+1];
//printf("start utxosync start.%u %u\n",starttime,(uint32_t)time(NULL)); //printf("start utxosync start.%u %u\n",starttime,(uint32_t)time(NULL));
@ -673,7 +531,7 @@ void dpow_statemachinestart(void *ptr)
{ {
if ( bp->isratify == 0 ) if ( bp->isratify == 0 )
{ {
if ( myinfo->DPOWS[0].ratifying != 0 ) if ( myinfo->DPOWS[0]->ratifying != 0 )
{ {
printf("break due to already ratifying\n"); printf("break due to already ratifying\n");
break; break;
@ -684,7 +542,7 @@ void dpow_statemachinestart(void *ptr)
extralen = dpow_paxpending(extras,sizeof(extras),&bp->paxwdcrc,bp->MoM,bp->MoMdepth,src_or_dest,bp); extralen = dpow_paxpending(extras,sizeof(extras),&bp->paxwdcrc,bp->MoM,bp->MoMdepth,src_or_dest,bp);
bp->notaries[bp->myind].paxwdcrc = bp->paxwdcrc; bp->notaries[bp->myind].paxwdcrc = bp->paxwdcrc;
} }
if ( (checkpoint.blockhash.height % 100) != 0 && dp->checkpoint.blockhash.height > checkpoint.blockhash.height ) if ( dp->checkpoint.blockhash.height > checkpoint.blockhash.height ) //(checkpoint.blockhash.height % 100) != 0 &&
{ {
if ( bp->isratify == 0 ) if ( bp->isratify == 0 )
{ {

201
iguana/dpow/dpow_network.c

@ -16,6 +16,7 @@
extern uint16_t Notaries_port; extern uint16_t Notaries_port;
extern int32_t Notaries_numseeds; extern int32_t Notaries_numseeds;
extern char *Notaries_seeds[]; extern char *Notaries_seeds[];
extern char *Notaries_elected[65][2];
struct signed_nnpacket struct signed_nnpacket
{ {
@ -80,10 +81,22 @@ int32_t signed_nn_send(struct supernet_info *myinfo,void *ctx,bits256 privkey,in
//printf(" signed pubkey\n"); //printf(" signed pubkey\n");
if ( memcmp(pubkey33,signpubkey33,33) == 0 ) if ( memcmp(pubkey33,signpubkey33,33) == 0 )
{ {
sentbytes = nn_send(sock,sigpacket,size + sizeof(*sigpacket),0); sentbytes = 0;
for (j=0; j<100; j++)
{
struct nn_pollfd pfd;
pfd.fd = sock;
pfd.events = NN_POLLOUT;
if ( nn_poll(&pfd,1,10) > 0 )
{
sentbytes = nn_send(sock,sigpacket,size + sizeof(*sigpacket),0);
break;
}
usleep(1000);
}
//for (i=0; i<size+sizeof(*sigpacket); i++) //for (i=0; i<size+sizeof(*sigpacket); i++)
// printf("%02x",((uint8_t *)sigpacket)[i]); // printf("%02x",((uint8_t *)sigpacket)[i]);
//printf(" <- nnsend\n"); //printf(" <- nnsend.%d\n",sock);
free(sigpacket); free(sigpacket);
return(sentbytes - siglen); return(sentbytes - siglen);
} }
@ -1449,13 +1462,34 @@ void dpow_nanomsginit(struct supernet_info *myinfo,char *ipaddr)
dpow_addnotary(myinfo,0,ipaddr); dpow_addnotary(myinfo,0,ipaddr);
} }
void dpow_bestconsensus(struct dpow_block *bp) void dpow_bestconsensus(struct dpow_info *dp,struct dpow_block *bp)
{ {
int8_t bestks[64]; int32_t counts[64],i,j,numcrcs=0,numdiff,besti,best,bestmatches = 0,matches = 0; uint64_t masks[64],matchesmask,recvmask; uint32_t crcval=0; char srcaddr[64],destaddr[64]; int8_t bestks[64]; uint32_t sortbuf[64],wts[64],owts[64],counts[64]; int32_t i,j,median,numcrcs=0,numdiff,besti,bestmatches = 0,matches = 0; uint64_t masks[64],matchesmask,recvmask,topmask; uint32_t crcval=0; char srcaddr[64],destaddr[64];
memset(wts,0,sizeof(wts));
memset(owts,0,sizeof(owts));
for (i=0; i<bp->numnotaries; i++)
{
recvmask = bp->notaries[i].recvmask;
wts[i] = bitweight(recvmask);
for (j=0; j<bp->numnotaries; j++)
if ( ((1LL << j) & recvmask) != 0 )
owts[j]++;
}
topmask = 0xffffffffffffffffLL;
recvmask = 0;
for (i=0; i<bp->numnotaries; i++)
sortbuf[i] = (wts[i] * owts[i]);
revsort32(sortbuf,bp->numnotaries,sizeof(*sortbuf));
median = sortbuf[bp->numnotaries / 2];
if ( ((bp->height / dp->freq) % 10) == 0 )
{
for (i=0; i<bp->numnotaries; i++)
if ( wts[i]*owts[i] < median )
topmask &= ~(1LL << i);
}
memset(masks,0,sizeof(masks)); memset(masks,0,sizeof(masks));
memset(bestks,0xff,sizeof(bestks)); memset(bestks,0xff,sizeof(bestks));
memset(counts,0,sizeof(counts)); memset(counts,0,sizeof(counts));
recvmask = 0;
for (numdiff=i=0; i<bp->numnotaries; i++) for (numdiff=i=0; i<bp->numnotaries; i++)
{ {
if ( bits256_nonz(bp->notaries[i].src.prev_hash) != 0 && bits256_nonz(bp->notaries[i].dest.prev_hash) != 0 ) if ( bits256_nonz(bp->notaries[i].src.prev_hash) != 0 && bits256_nonz(bp->notaries[i].dest.prev_hash) != 0 )
@ -1465,7 +1499,7 @@ void dpow_bestconsensus(struct dpow_block *bp)
//if ( bp->require0 != 0 && (bp->notaries[i].bestmask & 1) == 0 ) //if ( bp->require0 != 0 && (bp->notaries[i].bestmask & 1) == 0 )
// continue; // continue;
for (j=0; j<numdiff; j++) for (j=0; j<numdiff; j++)
if ( bp->notaries[i].bestk == bestks[j] && bp->notaries[i].bestmask == masks[j] ) if ( bp->notaries[i].bestk == bestks[j] && bp->notaries[i].bestmask == masks[j] && bitweight(bp->notaries[i].bestmask) == bp->minsigs )
{ {
counts[j]++; counts[j]++;
break; break;
@ -1479,27 +1513,46 @@ void dpow_bestconsensus(struct dpow_block *bp)
numdiff++; numdiff++;
} }
} }
besti = -1, best = 0; besti = -1, matches = 0;
for (i=0; i<numdiff; i++) for (i=0; i<numdiff; i++)
{ {
//printf("(%d %llx).%d ",bestks[i],(long long)masks[i],counts[i]); //printf("(%d %llx).%d ",bestks[i],(long long)masks[i],counts[i]);
if ( counts[i] > best && bitweight(masks[i]) >= bp->minsigs ) if ( counts[i] > matches && bitweight(masks[i]) == bp->minsigs )
{ {
best = counts[i]; matches = counts[i];
besti = i; besti = i;
} }
} }
if ( besti >= 0 && bestks[besti] >= 0 && masks[besti] != 0 && (recvmask & masks[besti]) == masks[besti] ) for (i=0; i<bp->numnotaries; i++)
{ {
if ( ((1LL << i) & masks[besti]) != 0 )
{
if ( bp->notaries[i].bestmask == masks[besti] )
bestmatches++;
}
}
if ( (bestmatches > bp->bestmatches || (bestmatches == bp->bestmatches && matches > bp->matches)) && besti >= 0 && bestks[besti] >= 0 && masks[besti] != 0 && (recvmask & masks[besti]) == masks[besti] )
{
bp->matches = matches;
bp->bestmatches = bestmatches;
bp->notaries[bp->myind].bestmask = bp->bestmask = masks[besti]; bp->notaries[bp->myind].bestmask = bp->bestmask = masks[besti];
bp->notaries[bp->myind].bestk = bp->bestk = bestks[besti]; bp->notaries[bp->myind].bestk = bp->bestk = bestks[besti];
//printf("set best.%d to (%d %llx) recv.%llx\n",best,bp->bestk,(long long)bp->bestmask,(long long)recvmask); if ( 0 && bp->myind == 0 && strcmp("CHIPS",dp->symbol) == 0 )
{
for (i=0; i<bp->numnotaries; i++)
printf("%d:%d%s ",wts[i],owts[i],wts[i]*owts[i]>median?"*":"");
printf("median.%d %s.%d set matches.%d best.%d to (%d %llx) recv.%llx topmask.%llx\n",sortbuf[bp->numnotaries/2],dp->symbol,bp->height,bp->matches,bp->bestmatches,bp->bestk,(long long)bp->bestmask,(long long)recvmask,(long long)topmask);
for (i=0; i<bp->numnotaries; i++)
if ( wts[i] == 0 || owts[i] == 0 )
printf("%s.%d:%d ",Notaries_elected[i][0],wts[i],owts[i]);
printf(" <- problem nodes.%s\n",dp->symbol);
}
} }
bp->recvmask |= recvmask; bp->recvmask |= recvmask;
if ( bp->bestmask == 0 )//|| (time(NULL) / 180) != bp->lastepoch ) if ( bp->bestmask == 0 )//|| (time(NULL) / 180) != bp->lastepoch )
{ {
bp->bestmask = dpow_notarybestk(bp->recvmask,bp,&bp->bestk); bp->bestmask = dpow_notarybestk(bp->recvmask,bp,&bp->bestk);
if ( 0 && (time(NULL) / 180) != bp->lastepoch ) if ( 0 && (time(NULL) / 180) != bp->lastepoch ) // diverges too fast
{ {
bp->lastepoch = (uint32_t)(time(NULL) / 180); bp->lastepoch = (uint32_t)(time(NULL) / 180);
printf("epoch %u\n",bp->lastepoch % bp->numnotaries); printf("epoch %u\n",bp->lastepoch % bp->numnotaries);
@ -1510,7 +1563,7 @@ void dpow_bestconsensus(struct dpow_block *bp)
void dpow_nanoutxoset(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_nanoutxo *np,struct dpow_block *bp,int32_t isratify) void dpow_nanoutxoset(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_nanoutxo *np,struct dpow_block *bp,int32_t isratify)
{ {
int32_t i,err,vout; cJSON *ujson; char coinaddr[64],str[65]; int32_t i,err,vout,bestk; cJSON *ujson; char coinaddr[64],str[65];
if ( bp->myind < 0 ) if ( bp->myind < 0 )
return; return;
if ( isratify != 0 ) if ( isratify != 0 )
@ -1575,7 +1628,7 @@ void dpow_nanoutxoset(struct supernet_info *myinfo,struct dpow_info *dp,struct d
} }
else else
{ {
dpow_bestconsensus(bp); dpow_bestconsensus(dp,bp);
np->srcutxo = bp->notaries[bp->myind].src.prev_hash; np->srcutxo = bp->notaries[bp->myind].src.prev_hash;
np->srcvout = bp->notaries[bp->myind].src.prev_vout; np->srcvout = bp->notaries[bp->myind].src.prev_vout;
np->destutxo = bp->notaries[bp->myind].dest.prev_hash; np->destutxo = bp->notaries[bp->myind].dest.prev_hash;
@ -1588,12 +1641,12 @@ void dpow_nanoutxoset(struct supernet_info *myinfo,struct dpow_info *dp,struct d
np->bestmask = bp->bestmask, np->bestk = bp->bestk; np->bestmask = bp->bestmask, np->bestk = bp->bestk;
else np->bestk = bp->notaries[bp->myind].bestk; else np->bestk = bp->notaries[bp->myind].bestk;
} else np->bestk = bp->pendingbestk; } else np->bestk = bp->pendingbestk;
if ( (int8_t)np->bestk >= 0 ) if ( (bestk= (int8_t)bp->pendingbestk) >= 0 || (bestk= (int8_t)np->bestk) >= 0 )
{ {
if ( (np->siglens[0]= bp->notaries[bp->myind].src.siglens[bp->bestk]) > 0 ) if ( (np->siglens[0]= bp->notaries[bp->myind].src.siglens[bestk]) > 0 )
memcpy(np->sigs[0],bp->notaries[bp->myind].src.sigs[bp->bestk],np->siglens[0]); memcpy(np->sigs[0],bp->notaries[bp->myind].src.sigs[bestk],np->siglens[0]);
if ( (np->siglens[1]= bp->notaries[bp->myind].dest.siglens[bp->bestk]) > 0 ) if ( (np->siglens[1]= bp->notaries[bp->myind].dest.siglens[bestk]) > 0 )
memcpy(np->sigs[1],bp->notaries[bp->myind].dest.sigs[bp->bestk],np->siglens[1]); memcpy(np->sigs[1],bp->notaries[bp->myind].dest.sigs[bestk],np->siglens[1]);
} }
} }
} }
@ -1715,7 +1768,7 @@ void dpow_ratify_update(struct supernet_info *myinfo,struct dpow_info *dp,struct
} }
} }
//printf("crcval.%x numcrcs.%d bestmatches.%d matchesmask.%llx\n",crcval,numcrcs,bestmatches,(long long)matchesmask); //printf("crcval.%x numcrcs.%d bestmatches.%d matchesmask.%llx\n",crcval,numcrcs,bestmatches,(long long)matchesmask);
if ( bestmatches >= bp->minsigs )//&& numcrcs >= bp->minsigs ) if ( bestmatches == bp->minsigs )//&& numcrcs == bp->minsigs )
{ {
if ( bp->pendingratifybestk != bp->ratifybestk || bp->pendingratifybestmask != bp->ratifybestmask ) if ( bp->pendingratifybestk != bp->ratifybestk || bp->pendingratifybestmask != bp->ratifybestmask )
{ {
@ -1780,7 +1833,7 @@ void dpow_ratify_update(struct supernet_info *myinfo,struct dpow_info *dp,struct
void dpow_notarize_update(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_block *bp,uint8_t senderind,int8_t bestk,uint64_t bestmask,uint64_t recvmask,bits256 srcutxo,uint16_t srcvout,bits256 destutxo,uint16_t destvout,uint8_t siglens[2],uint8_t sigs[2][DPOW_MAXSIGLEN],uint32_t paxwdcrc) void dpow_notarize_update(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_block *bp,uint8_t senderind,int8_t bestk,uint64_t bestmask,uint64_t recvmask,bits256 srcutxo,uint16_t srcvout,bits256 destutxo,uint16_t destvout,uint8_t siglens[2],uint8_t sigs[2][DPOW_MAXSIGLEN],uint32_t paxwdcrc)
{ {
bits256 srchash; int32_t i,flag,bestmatches = 0,matches = 0,paxmatches = 0,paxbestmatches = 0; bits256 srchash; uint32_t now; int32_t i,flag,bestmatches = 0,matches = 0,paxmatches = 0,paxbestmatches = 0;
if ( bp->myind < 0 ) if ( bp->myind < 0 )
return; return;
if ( bp->isratify == 0 && bp->state != 0xffffffff && senderind >= 0 && senderind < bp->numnotaries && bits256_nonz(srcutxo) != 0 && bits256_nonz(destutxo) != 0 ) if ( bp->isratify == 0 && bp->state != 0xffffffff && senderind >= 0 && senderind < bp->numnotaries && bits256_nonz(srcutxo) != 0 && bits256_nonz(destutxo) != 0 )
@ -1789,6 +1842,7 @@ void dpow_notarize_update(struct supernet_info *myinfo,struct dpow_info *dp,stru
{ {
bp->notaries[senderind].src.prev_hash = srcutxo; bp->notaries[senderind].src.prev_hash = srcutxo;
bp->notaries[senderind].src.prev_vout = srcvout; bp->notaries[senderind].src.prev_vout = srcvout;
//char str[65]; printf("%s senderind.%d <- %s/v%d\n",dp->symbol,senderind,bits256_str(str,srcutxo),srcvout);
} }
if ( bits256_nonz(destutxo) != 0 ) if ( bits256_nonz(destutxo) != 0 )
{ {
@ -1803,8 +1857,9 @@ void dpow_notarize_update(struct supernet_info *myinfo,struct dpow_info *dp,stru
{ {
//fprintf(stderr,"{%d %x} ",senderind,paxwdcrc); //fprintf(stderr,"{%d %x} ",senderind,paxwdcrc);
} }
if ( (bp->notaries[senderind].bestk= bestk) >= 0 ) if ( bestk >= 0 || bp->notaries[senderind].bestk < 0 )
{ {
bp->notaries[senderind].bestk = bestk;
if ( (bp->notaries[senderind].src.siglens[bestk]= siglens[0]) != 0 ) if ( (bp->notaries[senderind].src.siglens[bestk]= siglens[0]) != 0 )
{ {
memcpy(bp->notaries[senderind].src.sigs[bestk],sigs[0],siglens[0]); memcpy(bp->notaries[senderind].src.sigs[bestk],sigs[0],siglens[0]);
@ -1826,7 +1881,7 @@ void dpow_notarize_update(struct supernet_info *myinfo,struct dpow_info *dp,stru
bp->recvmask |= (1LL << senderind) | (1LL << bp->myind); bp->recvmask |= (1LL << senderind) | (1LL << bp->myind);
bp->bestmask = dpow_maskmin(bp->recvmask,bp,&bp->bestk); bp->bestmask = dpow_maskmin(bp->recvmask,bp,&bp->bestk);
} }
dpow_bestconsensus(bp); dpow_bestconsensus(dp,bp);
if ( bp->bestk >= 0 ) if ( bp->bestk >= 0 )
bp->notaries[bp->myind].bestk = bp->bestk; bp->notaries[bp->myind].bestk = bp->bestk;
if ( bp->bestmask != 0 ) if ( bp->bestmask != 0 )
@ -1836,6 +1891,7 @@ void dpow_notarize_update(struct supernet_info *myinfo,struct dpow_info *dp,stru
if ( bp->bestk >= 0 ) if ( bp->bestk >= 0 )
{ {
flag = -1; flag = -1;
now = (uint32_t)time(NULL);
for (i=0; i<bp->numnotaries; i++) for (i=0; i<bp->numnotaries; i++)
{ {
if ( bp->paxwdcrc == bp->notaries[i].paxwdcrc ) if ( bp->paxwdcrc == bp->notaries[i].paxwdcrc )
@ -1852,40 +1908,50 @@ void dpow_notarize_update(struct supernet_info *myinfo,struct dpow_info *dp,stru
} //else printf("?%x ",bp->notaries[i].paxwdcrc); } //else printf("?%x ",bp->notaries[i].paxwdcrc);
} }
} }
else if ( i == senderind && ((1LL << bp->myind) & bp->bestmask) != 0 && ((1LL << i) & bp->bestmask) != 0 && ((1LL << bp->myind) & bp->notaries[i].recvmask) == 0 ) else if ( i != bp->myind && i == senderind && ((1LL << bp->myind) & bp->bestmask) != 0 && ((1LL << i) & bp->bestmask) != 0 && ((1LL << bp->myind) & bp->notaries[i].recvmask) == 0 )
flag = senderind; {
if ( now > bp->lastnanosend+1 )
flag = senderind;
}
if ( 0 && bp->myind <= 1 && bp->notaries[i].paxwdcrc != 0 ) if ( 0 && bp->myind <= 1 && bp->notaries[i].paxwdcrc != 0 )
printf("%d.(%x %d %llx r%llx) ",i,bp->notaries[i].paxwdcrc,bp->notaries[i].bestk,(long long)bp->notaries[i].bestmask,(long long)bp->notaries[i].recvmask); printf("%d.(%x %d %llx r%llx) ",i,bp->notaries[i].paxwdcrc,bp->notaries[i].bestk,(long long)bp->notaries[i].bestmask,(long long)bp->notaries[i].recvmask);
} }
if ( flag >= 0 ) if ( flag >= 0 || now > bp->lastnanosend+13 )
{ {
//printf("flag.%d -> send\n",flag); //printf("flag.%d -> send\n",flag);
for (i=0; i<sizeof(srchash); i++) for (i=0; i<sizeof(srchash); i++)
srchash.bytes[i] = dp->minerkey33[i+1]; srchash.bytes[i] = dp->minerkey33[i+1];
dpow_send(myinfo,dp,bp,srchash,bp->hashmsg,0,bp->height,(void *)"ping",0); dpow_send(myinfo,dp,bp,srchash,bp->hashmsg,0,bp->height,(void *)"ping",0);
bp->lastnanosend = now;
} }
if ( 0 && bp->myind <= 1 ) if ( 0 && strcmp("CHIPS",dp->symbol) == 0 && bp->myind == 0 )
printf("recv.%llx best.(%d %llx) m.%d p.%d:%d b.%d\n",(long long)bp->recvmask,bp->bestk,(long long)bp->bestmask,matches,paxmatches,paxbestmatches,bestmatches); printf("%s recv.%llx best.(%d %llx) m.%d p.%d:%d b.%d state.%d minsigs.%d\n",dp->symbol,(long long)bp->recvmask,bp->bestk,(long long)bp->bestmask,matches,paxmatches,paxbestmatches,bestmatches,bp->state,bp->minsigs);
if ( bestmatches >= bp->minsigs && paxbestmatches >= bp->minsigs ) if ( bestmatches == bp->minsigs && paxbestmatches == bp->minsigs && bp->bestk >= 0 && bp->bestmask != 0 )
{ {
if ( bp->pendingbestk != bp->bestk || bp->pendingbestmask != bp->bestmask ) if ( bp->pendingbestk < 0 )//bp->pendingbestk != bp->bestk || bp->pendingbestmask != bp->bestmask )
{ {
printf("new PENDING BESTK (%d %llx) state.%d\n",bp->bestk,(long long)bp->bestmask,bp->state); printf("new PENDING BESTK (%d %llx) state.%d\n",bp->bestk,(long long)bp->bestmask,bp->state);
bp->pendingbestk = bp->bestk; bp->pendingbestk = bp->bestk;
bp->pendingbestmask = bp->bestmask; bp->pendingbestmask = bp->bestmask;
dpow_signedtxgen(myinfo,dp,bp->destcoin,bp,bp->bestk,bp->bestmask,bp->myind,DPOW_SIGBTCCHANNEL,1,0); dpow_signedtxgen(myinfo,dp,bp->destcoin,bp,bp->pendingbestk,bp->pendingbestmask,bp->myind,DPOW_SIGBTCCHANNEL,1,0);
//printf("finished signing\n"); //printf("finished signing\n");
} }
if ( bp->destsigsmasks[bp->bestk] == bp->bestmask ) // have all sigs if ( (bp->pendingbestmask & (1LL << bp->myind)) != 0 && bits256_nonz(bp->desttxid) != 0 && bp->srcsigsmasks[bp->pendingbestk] == 0 )
{
printf("generate sigs for bestk.%d %llx\n",bp->pendingbestk,(long long)bp->pendingbestmask);
dpow_signedtxgen(myinfo,dp,bp->srccoin,bp,bp->pendingbestk,bp->pendingbestmask,bp->myind,DPOW_SIGCHANNEL,0,0);
}
if ( bp->destsigsmasks[bp->pendingbestk] == bp->pendingbestmask ) // have all sigs
{ {
if ( bp->state < 1000 ) if ( bp->state < 1000 )
dpow_sigscheck(myinfo,dp,bp,bp->myind,1,bp->bestk,bp->bestmask,0,0); dpow_sigscheck(myinfo,dp,bp,bp->myind,1,bp->pendingbestk,bp->pendingbestmask,0,0);
if ( bp->srcsigsmasks[bp->bestk] == bp->bestmask ) // have all sigs if ( bp->srcsigsmasks[bp->pendingbestk] == bp->pendingbestmask ) // have all sigs
{ {
if ( bp->state != 0xffffffff ) if ( bp->state != 0xffffffff )
dpow_sigscheck(myinfo,dp,bp,bp->myind,0,bp->bestk,bp->bestmask,0,0); dpow_sigscheck(myinfo,dp,bp,bp->myind,0,bp->pendingbestk,bp->pendingbestmask,0,0);
} //else printf("srcmask.%llx != bestmask.%llx\n",(long long)bp->srcsigsmasks[bp->bestk],(long long)bp->bestmask); } // else if ( strcmp(dp->symbol,"CHIPS") == 0 || strcmp(dp->symbol,"GAME") == 0 )printf("srcmask.[%d:%d] %llx %llx != bestmask.%llx\n",bp->bestk,bp->pendingbestk,(long long)bp->srcsigsmasks[bp->pendingbestk],(long long)bp->srcsigsmasks[bp->bestk],(long long)bp->pendingbestmask);
} //else printf("destmask.%llx != bestmask.%llx\n",(long long)bp->destsigsmasks[bp->bestk],(long long)bp->bestmask); } //else if ( strcmp(dp->symbol,"CHIPS") == 0 || strcmp(dp->symbol,"GAME") == 0 )
//printf("destmask.%llx != bestmask.%llx\n",(long long)bp->destsigsmasks[bp->bestk],(long long)bp->bestmask);
} }
} }
else else
@ -1901,8 +1967,8 @@ void dpow_notarize_update(struct supernet_info *myinfo,struct dpow_info *dp,stru
printf("mypaxcrc.%x\n",bp->paxwdcrc); printf("mypaxcrc.%x\n",bp->paxwdcrc);
} }
char str[65]; char str[65];
if ( (rand() % 130) == 0 || strcmp(dp->symbol,"CHIPS") == 0 ) if ( (rand() % 1024) == 0 || (bp->myind == 0 && (rand() % 50) == 0 && (strcmp(dp->symbol,"CHIPS") == 0 || strcmp(dp->symbol,"GAME") == 0)) )
printf("%p ht.%d [%d] ips.%d %s NOTARIZE.%d matches.%d paxmatches.%d bestmatches.%d bestk.%d %llx recv.%llx sigmasks.(%llx %llx) senderind.%d state.%x (%x %x %x) MoM.%s [%d]\n",bp,bp->height,bp->myind,dp->numipbits,dp->symbol,bp->minsigs,matches,paxmatches,bestmatches,bp->bestk,(long long)bp->bestmask,(long long)bp->recvmask,(long long)(bp->bestk>=0?bp->destsigsmasks[bp->bestk]:0),(long long)(bp->bestk>=0?bp->srcsigsmasks[bp->bestk]:0),senderind,bp->state,bp->hashmsg.uints[0],bp->desttxid.uints[0],bp->srctxid.uints[0],bits256_str(str,bp->MoM),bp->MoMdepth); printf("%x ht.%d [%d] ips.%d %s NOTARIZE.%d matches.%d paxmatches.%d bestmatches.%d bestk.%d:%d %llx recv.%llx sigmasks.(%llx %llx) senderind.%d state.%x (%x %x %x) MoM.%s [%d]\n",bp->paxwdcrc,bp->height,bp->myind,dp->numipbits,dp->symbol,bp->minsigs,matches,paxmatches,bestmatches,bp->bestk,bp->pendingbestk,(long long)bp->bestmask,(long long)bp->recvmask,(long long)(bp->bestk>=0?bp->destsigsmasks[bp->bestk]:0),(long long)(bp->bestk>=0?bp->srcsigsmasks[bp->bestk]:0),senderind,bp->state,bp->hashmsg.uints[0],bp->desttxid.uints[0],bp->srctxid.uints[0],bits256_str(str,bp->MoM),bp->MoMdepth);
} }
} }
@ -1914,20 +1980,46 @@ void dpow_nanoutxoget(struct supernet_info *myinfo,struct dpow_info *dp,struct d
} }
else else
{ {
int32_t i,bestmatches=0,matches = 0,dispflag = 0;
dpow_notarize_update(myinfo,dp,bp,senderind,(int8_t)np->bestk,np->bestmask,np->recvmask,np->srcutxo,np->srcvout,np->destutxo,np->destvout,np->siglens,np->sigs,np->paxwdcrc); dpow_notarize_update(myinfo,dp,bp,senderind,(int8_t)np->bestk,np->bestmask,np->recvmask,np->srcutxo,np->srcvout,np->destutxo,np->destvout,np->siglens,np->sigs,np->paxwdcrc);
if ( 0 && bp->myind <= 2 ) if ( np->bestk >= 0 )
printf("lag.[%d] RECV.%d r%llx (%d %llx) %llx/%llx\n",(int32_t)(time(NULL)-channel),senderind,(long long)np->recvmask,(int8_t)np->bestk,(long long)np->bestmask,(long long)np->srcutxo.txid,(long long)np->destutxo.txid); {
if ( bp->recv[senderind].recvmask != np->recvmask || bp->recv[senderind].bestk != np->bestk || bp->recv[senderind].bestmask != np->bestmask )
dispflag = 1;
bp->recv[senderind].recvmask = np->recvmask;
bp->recv[senderind].bestk = np->bestk;
bp->recv[senderind].bestmask = np->bestmask;
for (i=0; i<bp->numnotaries; i++)
{
if ( bp->recv[i].recvmask == np->recvmask && bp->recv[i].bestmask == np->bestmask && bp->recv[i].bestk == np->bestk )
{
matches++;
if ( ((1LL << i) & np->bestmask) != 0 )
bestmatches++;
}
}
}
if ( 0 && bp->myind == 0 && dispflag != 0 )
{
printf("%s.%d RECV.%-2d %llx (%2d %llx) %llx/%llx matches.%-2d best.%-2d %s\n",dp->symbol,bp->height,senderind,(long long)np->recvmask,(int8_t)np->bestk,(long long)np->bestmask,(long long)np->srcutxo.txid,(long long)np->destutxo.txid,matches,bestmatches,Notaries_elected[senderind][0]);
}
} }
//dpow_bestmask_update(myinfo,dp,bp,nn_senderind,nn_bestk,nn_bestmask,nn_recvmask); //dpow_bestmask_update(myinfo,dp,bp,nn_senderind,nn_bestk,nn_bestmask,nn_recvmask);
} }
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) 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)
{ {
struct dpow_nanomsghdr *np; int32_t i,src_or_dest,size,extralen=0,sentbytes = 0; uint32_t crc32,paxwdcrc; uint8_t extras[10000]; struct dpow_nanomsghdr *np; int32_t i,maxiters,src_or_dest,size,extralen=0,sentbytes = 0; uint32_t crc32,paxwdcrc; uint8_t extras[10000];
if ( bp->myind < 0 ) if ( bp->myind < 0 )
{
printf("bp->myind.%d error\n",bp->myind);
return; return;
}
if ( time(NULL) < myinfo->nanoinit+5 ) if ( time(NULL) < myinfo->nanoinit+5 )
{
printf("dpow_send waiting for init\n");
return; return;
}
crc32 = calc_crc32(0,data,datalen); crc32 = calc_crc32(0,data,datalen);
//dp->crcs[firstz] = crc32; //dp->crcs[firstz] = crc32;
size = (int32_t)(sizeof(*np) + datalen); size = (int32_t)(sizeof(*np) + datalen);
@ -1949,7 +2041,7 @@ void dpow_send(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_blo
else src_or_dest = 1; else src_or_dest = 1;
extralen = dpow_paxpending(extras,sizeof(extras),&paxwdcrc,bp->MoM,bp->MoMdepth,src_or_dest,bp); extralen = dpow_paxpending(extras,sizeof(extras),&paxwdcrc,bp->MoM,bp->MoMdepth,src_or_dest,bp);
bp->paxwdcrc = bp->notaries[bp->myind].paxwdcrc = np->notarize.paxwdcrc = paxwdcrc; bp->paxwdcrc = bp->notaries[bp->myind].paxwdcrc = np->notarize.paxwdcrc = paxwdcrc;
//dpow_bestconsensus(bp); //dpow_bestconsensus(dp,bp);
dpow_nanoutxoset(myinfo,dp,&np->notarize,bp,0); dpow_nanoutxoset(myinfo,dp,&np->notarize,bp,0);
} }
else else
@ -1974,22 +2066,25 @@ void dpow_send(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_blo
memcpy(np->packet,data,datalen); memcpy(np->packet,data,datalen);
sentbytes = -1; sentbytes = -1;
// deadlocks! portable_mutex_lock(&myinfo->dpowmutex); // deadlocks! portable_mutex_lock(&myinfo->dpowmutex);
for (i=0; i<100; i++) maxiters = 100;
for (i=0; i<maxiters; i++)
{ {
struct nn_pollfd pfd; struct nn_pollfd pfd;
pfd.fd = myinfo->dpowsock; pfd.fd = myinfo->dpowsock;
pfd.events = NN_POLLOUT; pfd.events = NN_POLLOUT;
if ( nn_poll(&pfd,1,100) > 0 ) if ( nn_poll(&pfd,1,10) > 0 )
{ {
sentbytes = signed_nn_send(myinfo,myinfo->ctx,myinfo->persistent_priv,myinfo->dpowsock,np,size); sentbytes = signed_nn_send(myinfo,myinfo->ctx,myinfo->persistent_priv,myinfo->dpowsock,np,size);
break; break;
} }
usleep(1000); usleep(1000);
} }
if ( i == maxiters )
printf("maxiters expired for signed_nn_send dpowsock.%d\n",myinfo->dpowsock);
//portable_mutex_unlock(&myinfo->dpowmutex); //portable_mutex_unlock(&myinfo->dpowmutex);
free(np); free(np);
if ( 0 && bp->myind <= 2 ) if ( 0 && bp->myind == 0 )
printf("%d NANOSEND.%d ht.%d channel.%08x (%d) pax.%08x datalen.%d (%d %llx) (%d %llx) recv.%llx\n",i,sentbytes,np->height,np->channel,size,np->notarize.paxwdcrc,datalen,(int8_t)np->notarize.bestk,(long long)np->notarize.bestmask,bp->notaries[bp->myind].bestk,(long long)bp->notaries[bp->myind].bestmask,(long long)bp->recvmask); printf("%d NANOSEND.%d %s.%d channel.%08x (%d) pax.%08x datalen.%d (%d %llx) (%d %llx) recv.%llx\n",i,sentbytes,dp->symbol,np->height,np->channel,size,np->notarize.paxwdcrc,datalen,(int8_t)np->notarize.bestk,(long long)np->notarize.bestmask,bp->notaries[bp->myind].bestk,(long long)bp->notaries[bp->myind].bestmask,(long long)bp->recvmask);
} }
void dpow_ipbitsadd(struct supernet_info *myinfo,struct dpow_info *dp,uint32_t *ipbits,int32_t numipbits,int32_t maxipbits,int32_t fromid,uint32_t senderipbits) void dpow_ipbitsadd(struct supernet_info *myinfo,struct dpow_info *dp,uint32_t *ipbits,int32_t numipbits,int32_t maxipbits,int32_t fromid,uint32_t senderipbits)
@ -2066,9 +2161,9 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo)
dp = 0; dp = 0;
for (i=0; i<myinfo->numdpows; i++) for (i=0; i<myinfo->numdpows; i++)
{ {
if ( strcmp(np->symbol,myinfo->DPOWS[i].symbol) == 0 ) if ( strcmp(np->symbol,myinfo->DPOWS[i]->symbol) == 0 )
{ {
dp = &myinfo->DPOWS[i]; dp = myinfo->DPOWS[i];
break; break;
} }
} }
@ -2102,7 +2197,7 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo)
} else flags |= 1; } else flags |= 1;
if ( freeptr != 0 ) if ( freeptr != 0 )
nn_freemsg(freeptr), np = 0, freeptr = 0; nn_freemsg(freeptr), np = 0, freeptr = 0;
if ( 0 && myinfo->dexsock >= 0 ) // from servers /*if ( 0 && myinfo->dexsock >= 0 ) // from servers
{ {
freeptr = 0; freeptr = 0;
if ( (flags & 2) == 0 && (size= signed_nn_recv(&freeptr,myinfo,myinfo->notaries,myinfo->numnotaries,myinfo->dexsock,&dexp)) > 0 ) if ( (flags & 2) == 0 && (size= signed_nn_recv(&freeptr,myinfo,myinfo->notaries,myinfo->numnotaries,myinfo->dexsock,&dexp)) > 0 )
@ -2119,8 +2214,8 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo)
} else flags |= 2; } else flags |= 2;
if ( freeptr != 0 ) if ( freeptr != 0 )
nn_freemsg(freeptr), dexp = 0, freeptr = 0; nn_freemsg(freeptr), dexp = 0, freeptr = 0;
} }*/
if ( 0 && myinfo->repsock >= 0 ) // from clients /*if ( 0 && myinfo->repsock >= 0 ) // from clients
{ {
dexp = 0; dexp = 0;
if ( (flags & 4) == 0 && (size= nn_recv(myinfo->repsock,&dexp,NN_MSG,0)) > 0 ) if ( (flags & 4) == 0 && (size= nn_recv(myinfo->repsock,&dexp,NN_MSG,0)) > 0 )
@ -2163,7 +2258,7 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo)
} else flags |= 4; } else flags |= 4;
if ( dexp != 0 ) if ( dexp != 0 )
nn_freemsg(dexp), dexp = 0; nn_freemsg(dexp), dexp = 0;
} }*/
if ( (num + n + num2) != lastval ) if ( (num + n + num2) != lastval )
{ {
//printf("lastval.%d: num.%d n.%d num2.%d rep packets\n",lastval,num,n,num2); //printf("lastval.%d: num.%d n.%d num2.%d rep packets\n",lastval,num,n,num2);

62
iguana/dpow/dpow_rpc.c

@ -72,16 +72,18 @@ cJSON *dpow_getinfo(struct supernet_info *myinfo,struct iguana_info *coin)
} }
char *Notaries_elected[65][2]; char *Notaries_elected[65][2];
char *seeds[] = { "78.47.196.146", "5.9.102.210", "149.56.29.163", "191.235.80.138", "88.198.65.74", "94.102.63.226", "129.232.225.202", "104.255.64.3", "52.72.135.200", "149.56.28.84", "103.18.58.150", "221.121.144.140", "123.249.79.12", "103.18.58.146", "27.50.93.252", "176.9.0.233", "94.102.63.227", "167.114.227.223", "27.50.68.219", "192.99.233.217", "94.102.63.217", "45.64.168.216" }; //char *seeds[] = { "78.47.196.146", "5.9.102.210", "149.56.29.163", "191.235.80.138", "88.198.65.74", "94.102.63.226", "129.232.225.202", "104.255.64.3", "52.72.135.200", "149.56.28.84", "103.18.58.150", "221.121.144.140", "123.249.79.12", "103.18.58.146", "27.50.93.252", "176.9.0.233", "94.102.63.227", "167.114.227.223", "27.50.68.219", "192.99.233.217", "94.102.63.217", "45.64.168.216" };
int32_t Notaries_numseeds = (int32_t)(sizeof(seeds)/sizeof(*seeds)),Notaries_num,Notaries_BTCminsigs = DPOW_MINSIGS,Notaries_minsigs = DPOW_MIN_ASSETCHAIN_SIGS; int32_t Notaries_numseeds;// = (int32_t)(sizeof(seeds)/sizeof(*seeds))
int32_t Notaries_num,Notaries_BTCminsigs = DPOW_MINSIGS;
int32_t Notaries_minsigs = DPOW_MIN_ASSETCHAIN_SIGS;
uint16_t Notaries_port = DPOW_SOCKPORT; uint16_t Notaries_port = DPOW_SOCKPORT;
char *Notaries_seeds[65]; char *Notaries_seeds[65];
int32_t komodo_initjson(char *fname) int32_t komodo_initjson(char *fname)
{ {
char *fstr,*field,*hexstr; cJSON *argjson,*array,*item; long fsize; uint16_t port; int32_t i,n,num,retval = -1; char *fstr,*field,*hexstr; cJSON *argjson,*array,*item; long fsize; uint16_t port; int32_t i,n,num,retval = -1;
for (i=0; i<Notaries_numseeds; i++) //for (i=0; i<Notaries_numseeds; i++)
Notaries_seeds[i] = seeds[i]; // Notaries_seeds[i] = seeds[i];
if ( (fstr= OS_filestr(&fsize,fname)) != 0 ) if ( (fstr= OS_filestr(&fsize,fname)) != 0 )
{ {
if ( (argjson= cJSON_Parse(fstr)) != 0 ) if ( (argjson= cJSON_Parse(fstr)) != 0 )
@ -99,6 +101,7 @@ int32_t komodo_initjson(char *fname)
Notaries_seeds[i] = clonestr(jstri(array,i)); Notaries_seeds[i] = clonestr(jstri(array,i));
printf("%s ",Notaries_seeds[i]); printf("%s ",Notaries_seeds[i]);
} }
Notaries_numseeds = i;
printf("Notaries_numseeds.%d\n",Notaries_numseeds); printf("Notaries_numseeds.%d\n",Notaries_numseeds);
} }
if ( (array= jarray(&n,argjson,"notaries")) != 0 && n <= 64 ) if ( (array= jarray(&n,argjson,"notaries")) != 0 && n <= 64 )
@ -226,6 +229,21 @@ bits256 dpow_getbestblockhash(struct supernet_info *myinfo,struct iguana_info *c
return(blockhash); return(blockhash);
} }
cJSON *issue_calcMoM(struct iguana_info *coin,int32_t height,int32_t MoMdepth)
{
char buf[128],*retstr=0; cJSON *retjson = 0;
if ( coin->FULLNODE < 0 )
{
sprintf(buf,"[\"%d\", \"%d\"]",height,MoMdepth);
if ( (retstr= bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"calc_MoM",buf)) != 0 )
{
retjson = cJSON_Parse(retstr);
//printf("MoM.%s -> %s\n",buf,retstr);
free(retstr);
}
}
return(retjson);
}
cJSON *dpow_MoMoMdata(struct iguana_info *coin,char *symbol,int32_t kmdheight) cJSON *dpow_MoMoMdata(struct iguana_info *coin,char *symbol,int32_t kmdheight)
{ {
@ -357,11 +375,25 @@ cJSON *dpow_getblock(struct supernet_info *myinfo,struct iguana_info *coin,bits2
char *dpow_validateaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address) char *dpow_validateaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address)
{ {
char buf[128],*retstr=0; char buf[128],*retstr=0; cJSON *retjson;
if ( coin->FULLNODE < 0 ) if ( coin->FULLNODE < 0 )
{ {
sprintf(buf,"\"%s\"",address); sprintf(buf,"\"%s\"",address);
retstr = bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"validateaddress",buf); retstr = bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,coin->validateaddress,buf);
//printf("%s %s %s %s %s\n",coin->symbol,coin->chain->serverport,coin->chain->userpass,coin->validateaddress,buf);
//printf("%s -> (%s)\n",buf,retstr!=0?retstr:"null");
if ( (retjson= cJSON_Parse(retstr)) != 0 )
{
if ( strcmp(coin->symbol,"BTC") == 0 && jobj(retjson,"error") == 0 && jobj(retjson,"ismine") == 0 && strcmp(coin->validateaddress,"validateaddress") == 0 )
{
printf("autochange %s validateaddress -> getaddressinfo\n",coin->symbol);
strcpy(coin->validateaddress,"getaddressinfo");
free_json(retjson);
free(retjson);
return(bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,coin->validateaddress,buf));
}
free_json(retjson);
}
usleep(10000); usleep(10000);
} }
else if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 ) else if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 )
@ -531,7 +563,7 @@ cJSON *dpow_listtransactions(struct supernet_info *myinfo,struct iguana_info *co
char *dpow_signrawtransaction(struct supernet_info *myinfo,struct iguana_info *coin,char *rawtx,cJSON *vins) char *dpow_signrawtransaction(struct supernet_info *myinfo,struct iguana_info *coin,char *rawtx,cJSON *vins)
{ {
cJSON *array,*privkeys,*item; char *wifstr,*str,*paramstr,*retstr; uint8_t script[256]; int32_t i,n,len,hashtype; struct vin_info V; struct iguana_waddress *waddr; struct iguana_waccount *wacct; cJSON *array,*privkeys,*item,*retjson; char *wifstr,*str,*paramstr,*retstr; uint8_t script[256]; int32_t i,n,len,hashtype; struct vin_info V; struct iguana_waddress *waddr; struct iguana_waccount *wacct;
if ( coin->FULLNODE < 0 ) if ( coin->FULLNODE < 0 )
{ {
array = cJSON_CreateArray(); array = cJSON_CreateArray();
@ -539,7 +571,17 @@ char *dpow_signrawtransaction(struct supernet_info *myinfo,struct iguana_info *c
jaddi(array,jduplicate(vins)); jaddi(array,jduplicate(vins));
paramstr = jprint(array,1); paramstr = jprint(array,1);
//printf("signrawtransaction\n"); //printf("signrawtransaction\n");
retstr = bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"signrawtransaction",paramstr); retstr = bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,coin->signtxstr,paramstr);
if ( strcmp(coin->signtxstr,"signrawtransaction") == 0 && (retjson= cJSON_Parse(retstr)) != 0 )
{
if ( jobj(retjson,"error") != 0 )
{
strcpy(coin->signtxstr,"signrawtransactionwithwallet");
free(retstr);
retstr = bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,coin->signtxstr,paramstr);
}
free_json(retjson);
}
//printf("%s signrawtransaction.(%s) params.(%s)\n",coin->symbol,retstr,paramstr); //printf("%s signrawtransaction.(%s) params.(%s)\n",coin->symbol,retstr,paramstr);
free(paramstr); free(paramstr);
usleep(10000); usleep(10000);
@ -578,7 +620,7 @@ char *dpow_signrawtransaction(struct supernet_info *myinfo,struct iguana_info *c
} }
} }
retstr = bitcoinrpc_signrawtransaction(myinfo,coin,0,0,rawtx,vins,privkeys,"ALL"); retstr = bitcoinrpc_signrawtransaction(myinfo,coin,0,0,rawtx,vins,privkeys,"ALL");
printf("call sign.(%s) vins.(%s) privs.(%s) -> (%s)\n",rawtx,jprint(vins,0),jprint(privkeys,0),retstr); //printf("call sign.(%s) vins.(%s) privs.(%s) -> (%s)\n",rawtx,jprint(vins,0),jprint(privkeys,0),retstr);
free_json(privkeys); free_json(privkeys);
return(retstr); return(retstr);
} }
@ -1149,7 +1191,7 @@ void dpow_issuer_voutupdate(struct dpow_info *dp,char *symbol,int32_t isspecial,
if ( script[offset] == 'W' && strcmp(dp->symbol,"KMD") != 0 ) if ( script[offset] == 'W' && strcmp(dp->symbol,"KMD") != 0 )
{ {
// if valid add to pricefeed for issue // if valid add to pricefeed for issue
printf("WITHDRAW ht.%d txi.%d vout.%d %.8f opretlen.%d\n",height,txi,vout,dstr(fiatoshis),opretlen); printf("notary vout.%s ht.%d txi.%d vout.%d %.8f opretlen.%d\n",symbol,height,txi,vout,dstr(fiatoshis),opretlen);
if ( opretlen == 38 ) // any KMD tx if ( opretlen == 38 ) // any KMD tx
{ {
offset++; offset++;

20
iguana/dpow/dpow_tx.c

@ -54,7 +54,7 @@ uint64_t dpow_lastk_mask(struct dpow_block *bp,int8_t *lastkp)
{ {
bp->recvmask |= (1LL << k); bp->recvmask |= (1LL << k);
mask |= (1LL << k); mask |= (1LL << k);
if ( ++m >= bp->minsigs ) if ( ++m == bp->minsigs )
{ {
*lastkp = k; *lastkp = k;
break; break;
@ -101,9 +101,8 @@ uint64_t dpow_ratifybest(uint64_t refmask,struct dpow_block *bp,int8_t *lastkp)
uint64_t dpow_notarybestk(uint64_t refmask,struct dpow_block *bp,int8_t *lastkp) uint64_t dpow_notarybestk(uint64_t refmask,struct dpow_block *bp,int8_t *lastkp)
{ {
int32_t m,j,k; uint64_t bestmask,mask = 0;//bp->require0; int32_t m,j,k; int8_t bestk = -1; uint64_t bestmask,mask = 0;//bp->require0;
bestmask = 0; bestmask = 0;
*lastkp = -1;
for (m=j=0; j<bp->numnotaries; j++) for (m=j=0; j<bp->numnotaries; j++)
{ {
//k = (j + ((uint32_t)time(NULL) / 180)) % bp->numnotaries; //k = (j + ((uint32_t)time(NULL) / 180)) % bp->numnotaries;
@ -115,12 +114,14 @@ uint64_t dpow_notarybestk(uint64_t refmask,struct dpow_block *bp,int8_t *lastkp)
mask |= (1LL << k); mask |= (1LL << k);
if ( ++m == bp->minsigs )//-bp->require0 ) if ( ++m == bp->minsigs )//-bp->require0 )
{ {
*lastkp = k; bestk = k;
bestmask = mask;// | bp->require0; bestmask = mask;// | bp->require0;
//printf("m.%d == minsigs.%d (%d %llx)\n",m,bp->minsigs,k,(long long)bestmask); //printf("m.%d == minsigs.%d (%d %llx)\n",m,bp->minsigs,k,(long long)bestmask);
} }
} }
} }
if ( bestk >= 0 )
*lastkp = bestk;
return(bestmask); return(bestmask);
} }
@ -482,17 +483,17 @@ void dpow_rawtxsign(struct supernet_info *myinfo,struct dpow_info *dp,struct igu
retval = 0; retval = 0;
break; break;
} else printf("sig.%d of %d didnt match pubkey? (%s)\n",j,m,jprint(vinitem,0)); } else printf("sig.%d of %d didnt match pubkey? (%s)\n",j,m,jprint(vinitem,0));
} // else printf("notmine.(%s)\n",jprint(item,0)); } //else printf("notmine.(%s)\n",jprint(item,0));
} }
} else printf("no vin[] (%s)\n",jprint(txobj2,0)); } else printf("no vin[] (%s)\n",jprint(txobj2,0));
free_json(txobj2); free_json(txobj2);
} else printf("cant parse.(%s)\n",rawtx2); } else printf("cant parse.(%s)\n",rawtx2);
free(rawtx2); free(rawtx2);
} //else printf("error decoding (%s) %s\n",signedtx==0?"":signedtx,jsonstr); } else printf("error decoding (%s) %s\n",signedtx==0?"":signedtx,jsonstr);
free_json(signobj); free_json(signobj);
} else printf("error parsing.(%s)\n",jsonstr); } else printf("error parsing.(%s)\n",jsonstr);
free(jsonstr); free(jsonstr);
} } else printf("%s null signature in dpow_rawtxsign\n",dp->symbol);
} }
int32_t dpow_signedtxgen(struct supernet_info *myinfo,struct dpow_info *dp,struct iguana_info *coin,struct dpow_block *bp,int8_t bestk,uint64_t bestmask,int32_t myind,uint32_t deprec,int32_t src_or_dest,int32_t useratified) int32_t dpow_signedtxgen(struct supernet_info *myinfo,struct dpow_info *dp,struct iguana_info *coin,struct dpow_block *bp,int8_t bestk,uint64_t bestmask,int32_t myind,uint32_t deprec,int32_t src_or_dest,int32_t useratified)
@ -507,7 +508,7 @@ int32_t dpow_signedtxgen(struct supernet_info *myinfo,struct dpow_info *dp,struc
if ( (vins= dpow_vins(coin,bp,bestk,bestmask,1,src_or_dest,useratified)) != 0 ) if ( (vins= dpow_vins(coin,bp,bestk,bestmask,1,src_or_dest,useratified)) != 0 )
{ {
txid = dpow_notarytx(rawtx,&numsigs,coin->chain->isPoS,bp,bestk,bestmask,0,src_or_dest,bp->numratified!=0?bp->ratified_pubkeys:0,useratified*bp->numratified); txid = dpow_notarytx(rawtx,&numsigs,coin->chain->isPoS,bp,bestk,bestmask,0,src_or_dest,bp->numratified!=0?bp->ratified_pubkeys:0,useratified*bp->numratified);
//char str[65]; printf("signedtxgen %s src_or_dest.%d (%d %llx) useratified.%d raw.(%s)\n",bits256_str(str,txid),src_or_dest,bestk,(long long)bestmask,useratified,rawtx); //char str[65]; printf("%s signedtxgen %s src_or_dest.%d (%d %llx) useratified.%d raw.(%s)\n",dp->symbol,bits256_str(str,txid),src_or_dest,bestk,(long long)bestmask,useratified,rawtx);
if ( bits256_nonz(txid) != 0 && rawtx[0] != 0 ) // send tx to share utxo set if ( bits256_nonz(txid) != 0 && rawtx[0] != 0 ) // send tx to share utxo set
{ {
if ( useratified != 0 ) if ( useratified != 0 )
@ -571,7 +572,8 @@ void dpow_sigscheck(struct supernet_info *myinfo,struct dpow_info *dp,struct dpo
{ {
dpow_notarytx(bp->signedtx,&numsigs,coin->chain->isPoS,bp,bestk,bestmask,0,src_or_dest,pubkeys,numratified); // setcrcval dpow_notarytx(bp->signedtx,&numsigs,coin->chain->isPoS,bp,bestk,bestmask,0,src_or_dest,pubkeys,numratified); // setcrcval
signedtxid = dpow_notarytx(bp->signedtx,&numsigs,coin->chain->isPoS,bp,bestk,bestmask,1,src_or_dest,pubkeys,numratified); signedtxid = dpow_notarytx(bp->signedtx,&numsigs,coin->chain->isPoS,bp,bestk,bestmask,1,src_or_dest,pubkeys,numratified);
//printf("src_or_dest.%d bestk.%d %llx %s numsigs.%d signedtx.(%s)\n",src_or_dest,bestk,(long long)bestmask,bits256_str(str,signedtxid),numsigs,bp->signedtx); if ( strcmp("CHIPS",coin->symbol) == 0 )
printf("src_or_dest.%d bestk.%d %llx %s numsigs.%d signedtx.(%s)\n",src_or_dest,bestk,(long long)bestmask,bits256_str(str,signedtxid),numsigs,bp->signedtx);
bp->state = 1; bp->state = 1;
if ( bits256_nonz(signedtxid) != 0 && numsigs == bp->minsigs ) if ( bits256_nonz(signedtxid) != 0 && numsigs == bp->minsigs )
{ {

81
iguana/elected

File diff suppressed because one or more lines are too long

1
iguana/elected.2017

File diff suppressed because one or more lines are too long

84
iguana/elected.new

@ -0,0 +1,84 @@
{
"port": 7775,
"BTCminsigs": 14,
"minsigs": 13,
"seeds": [
"95.213.205.222",
"167.114.208.203",
"139.99.122.140",
"104.255.168.213",
"78.47.196.146",
"138.121.203.226",
"167.99.69.47",
"139.99.144.122",
"77.95.229.63",
"37.9.62.186",
"145.239.204.33",
"74.208.210.191"
],
"notaries": [
{"dev1_jl777": "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" },
{"dev2_kolo": "030f34af4b908fb8eb2099accb56b8d157d49f6cfb691baa80fdd34f385efed961" },
{"dev3_kolo": "025af9d2b2a05338478159e9ac84543968fd18c45fd9307866b56f33898653b014" },
{"dev4_decker": "028eea44a09674dda00d88ffd199a09c9b75ba9782382cc8f1e97c0fd565fe5707" },
{"a-team_SH": "03b59ad322b17cb94080dc8e6dc10a0a865de6d47c16fb5b1a0b5f77f9507f3cce" },
{"artik_AR": "029acf1dcd9f5ff9c455f8bb717d4ae0c703e089d16cf8424619c491dff5994c90" },
{"artik_EU": "03f54b2c24f82632e3cdebe4568ba0acf487a80f8a89779173cdb78f74514847ce" },
{"artik_NA": "0224e31f93eff0cc30eaf0b2389fbc591085c0e122c4d11862c1729d090106c842" },
{"artik_SH": "02bdd8840a34486f38305f311c0e2ae73e84046f6e9c3dd3571e32e58339d20937" },
{"badass_EU": "0209d48554768dd8dada988b98aca23405057ac4b5b46838a9378b95c3e79b9b9e" },
{"badass_NA": "02afa1a9f948e1634a29dc718d218e9d150c531cfa852843a1643a02184a63c1a7" },
{"batman_AR": "033ecb640ec5852f42be24c3bf33ca123fb32ced134bed6aa2ba249cf31b0f2563" },
{"batman_SH": "02ca5898931181d0b8aafc75ef56fce9c43656c0b6c9f64306e7c8542f6207018c" },
{"ca333_EU": "03fc87b8c804f12a6bd18efd43b0ba2828e4e38834f6b44c0bfee19f966a12ba99" },
{"chainmakers_EU": "02f3b08938a7f8d2609d567aebc4989eeded6e2e880c058fdf092c5da82c3bc5ee" },
{"chainmakers_NA": "0276c6d1c65abc64c8559710b8aff4b9e33787072d3dda4ec9a47b30da0725f57a" },
{"chainstrike_SH": "0370bcf10575d8fb0291afad7bf3a76929734f888228bc49e35c5c49b336002153" },
{"cipi_AR": "02c4f89a5b382750836cb787880d30e23502265054e1c327a5bfce67116d757ce8" },
{"cipi_NA": "02858904a2a1a0b44df4c937b65ee1f5b66186ab87a751858cf270dee1d5031f18" },
{"crackers_EU": "03bc819982d3c6feb801ec3b720425b017d9b6ee9a40746b84422cbbf929dc73c3" },
{"crackers_NA": "03205049103113d48c7c7af811b4c8f194dafc43a50d5313e61a22900fc1805b45" },
{"dwy_EU": "0259c646288580221fdf0e92dbeecaee214504fdc8bbdf4a3019d6ec18b7540424" },
{"emmanux_SH": "033f316114d950497fc1d9348f03770cd420f14f662ab2db6172df44c389a2667a" },
{"etszombi_EU": "0281b1ad28d238a2b217e0af123ce020b79e91b9b10ad65a7917216eda6fe64bf7" },
{"fullmoon_AR": "03380314c4f42fa854df8c471618751879f9e8f0ff5dbabda2bd77d0f96cb35676" },
{"fullmoon_NA": "030216211d8e2a48bae9e5d7eb3a42ca2b7aae8770979a791f883869aea2fa6eef" },
{"fullmoon_SH": "03f34282fa57ecc7aba8afaf66c30099b5601e98dcbfd0d8a58c86c20d8b692c64" },
{"goldenman_EU": "02d6f13a8f745921cdb811e32237bb98950af1a5952be7b3d429abd9152f8e388d" },
{"indenodes_AR": "02ec0fa5a40f47fd4a38ea5c89e375ad0b6ddf4807c99733c9c3dc15fb978ee147" },
{"indenodes_EU": "0221387ff95c44cb52b86552e3ec118a3c311ca65b75bf807c6c07eaeb1be8303c" },
{"indenodes_NA": "02698c6f1c9e43b66e82dbb163e8df0e5a2f62f3a7a882ca387d82f86e0b3fa988" },
{"indenodes_SH": "0334e6e1ec8285c4b85bd6dae67e17d67d1f20e7328efad17ce6fd24ae97cdd65e" },
{"jackson_AR": "038ff7cfe34cb13b524e0941d5cf710beca2ffb7e05ddf15ced7d4f14fbb0a6f69" },
{"jeezy_EU": "023cb3e593fb85c5659688528e9a4f1c4c7f19206edc7e517d20f794ba686fd6d6" },
{"karasugoi_NA": "02a348b03b9c1a8eac1b56f85c402b041c9bce918833f2ea16d13452309052a982" },
{"komodoninja_EU": "038e567b99806b200b267b27bbca2abf6a3e8576406df5f872e3b38d30843cd5ba" },
{"komodoninja_SH": "033178586896915e8456ebf407b1915351a617f46984001790f0cce3d6f3ada5c2" },
{"komodopioneers_SH": "033ace50aedf8df70035b962a805431363a61cc4e69d99d90726a2d48fb195f68c" },
{"libscott_SH": "03301a8248d41bc5dc926088a8cf31b65e2daf49eed7eb26af4fb03aae19682b95" },
{"lukechilds_AR": "031aa66313ee024bbee8c17915cf7d105656d0ace5b4a43a3ab5eae1e14ec02696" },
{"madmax_AR": "03891555b4a4393d655bf76f0ad0fb74e5159a615b6925907678edc2aac5e06a75" },
{"meshbits_AR": "02957fd48ae6cb361b8a28cdb1b8ccf5067ff68eb1f90cba7df5f7934ed8eb4b2c" },
{"meshbits_SH": "025c6e94877515dfd7b05682b9cc2fe4a49e076efe291e54fcec3add78183c1edb" },
{"metaphilibert_AR": "02adad675fae12b25fdd0f57250b0caf7f795c43f346153a31fe3e72e7db1d6ac6" },
{"metaphilibert_SH": "0284af1a5ef01503e6316a2ca4abf8423a794e9fc17ac6846f042b6f4adedc3309" },
{"patchkez_SH": "0296270f394140640f8fa15684fc11255371abb6b9f253416ea2734e34607799c4" },
{"pbca26_NA": "0276aca53a058556c485bbb60bdc54b600efe402a8b97f0341a7c04803ce204cb5" },
{"peer2cloud_AR": "034e5563cb885999ae1530bd66fab728e580016629e8377579493b386bf6cebb15" },
{"peer2cloud_SH": "03396ac453b3f23e20f30d4793c5b8ab6ded6993242df4f09fd91eb9a4f8aede84" },
{"polycryptoblog_NA": "02708dcda7c45fb54b78469673c2587bfdd126e381654819c4c23df0e00b679622" },
{"hyper_AR": "020f2f984d522051bd5247b61b080b4374a7ab389d959408313e8062acad3266b4" },
{"hyper_EU": "03d00cf9ceace209c59fb013e112a786ad583d7de5ca45b1e0df3b4023bb14bf51" },
{"hyper_SH": "0383d0b37f59f4ee5e3e98a47e461c861d49d0d90c80e9e16f7e63686a2dc071f3" },
{"hyper_NA": "03d91c43230336c0d4b769c9c940145a8c53168bf62e34d1bccd7f6cfc7e5592de" },
{"popcornbag_AR": "02761f106fb34fbfc5ddcc0c0aa831ed98e462a908550b280a1f7bd32c060c6fa3" },
{"popcornbag_NA": "03c6085c7fdfff70988fda9b197371f1caf8397f1729a844790e421ee07b3a93e8" },
{"alien_AR": "0348d9b1fc6acf81290405580f525ee49b4749ed4637b51a28b18caa26543b20f0" },
{"alien_EU": "020aab8308d4df375a846a9e3b1c7e99597b90497efa021d50bcf1bbba23246527" },
{"thegaltmines_NA": "031bea28bec98b6380958a493a703ddc3353d7b05eb452109a773eefd15a32e421" },
{"titomane_AR": "029d19215440d8cb9cc6c6b7a4744ae7fb9fb18d986e371b06aeb34b64845f9325" },
{"titomane_EU": "0360b4805d885ff596f94312eed3e4e17cb56aa8077c6dd78d905f8de89da9499f" },
{"titomane_SH": "03573713c5b20c1e682a2e8c0f8437625b3530f278e705af9b6614de29277a435b" },
{"webworker01_NA": "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" },
{"xrobesx_NA": "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }
]}

3
iguana/exchanges/LP_coins.c

@ -367,6 +367,9 @@ struct iguana_info *LP_coinadd(struct iguana_info *cdata)
portable_mutex_lock(&LP_coinmutex); portable_mutex_lock(&LP_coinmutex);
HASH_ADD_KEYPTR(hh,LP_coins,coin->symbol,strlen(coin->symbol),coin); HASH_ADD_KEYPTR(hh,LP_coins,coin->symbol,strlen(coin->symbol),coin);
portable_mutex_unlock(&LP_coinmutex); portable_mutex_unlock(&LP_coinmutex);
strcpy(coin->validateaddress,"validateaddress");
strcpy(coin->getinfostr,"getinfo");
strcpy(coin->estimatefeestr,"estimatefee");
return(coin); return(coin);
} }

8
iguana/exchanges/LP_commands.c

@ -127,6 +127,7 @@ swapstatus(coin, limit=10)\n\
swapstatus(base, rel, limit=10)\n\ swapstatus(base, rel, limit=10)\n\
swapstatus(requestid, quoteid, pending=0, fast=0)\n\ swapstatus(requestid, quoteid, pending=0, fast=0)\n\
recentswaps(limit=3)\n\ recentswaps(limit=3)\n\
kickstart(requestid, quoteid)\n\
notarizations(coin)\n\ notarizations(coin)\n\
public API:\n \ public API:\n \
getcoins()\n\ getcoins()\n\
@ -413,6 +414,13 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\
taddr = (jobj(argjson,"taddr") == 0) ? 0 : juint(argjson,"taddr"); taddr = (jobj(argjson,"taddr") == 0) ? 0 : juint(argjson,"taddr");
return(LP_secretaddresses(ctx,jstr(argjson,"prefix"),jstr(argjson,"passphrase"),juint(argjson,"num"),taddr,pubtype)); return(LP_secretaddresses(ctx,jstr(argjson,"prefix"),jstr(argjson,"passphrase"),juint(argjson,"num"),taddr,pubtype));
} }
else if ( strcmp(method,"kickstart") == 0 )
{
uint32_t requestid,quoteid;
if ( (requestid= juint(argjson,"requestid")) != 0 && (quoteid= juint(argjson,"quoteid")) != 0 )
return(LP_kickstart(requestid,quoteid));
else return(clonestr("{\"error\":\"kickstart needs requestid and quoteid\"}"));
}
else if ( strcmp(method,"swapstatus") == 0 ) else if ( strcmp(method,"swapstatus") == 0 )
{ {
uint32_t requestid,quoteid; uint32_t requestid,quoteid;

7
iguana/exchanges/LP_include.h

@ -29,9 +29,10 @@
#ifdef FROMGUI #ifdef FROMGUI
#define printf dontprintf #define printf dontprintf
#define fprintf dontprintf //#define fprintf fdontprintf dont do this!
voind dontprintf(char *formatstr,...) {} void dontprintf(char *formatstr,...) {}
//void fdontprintf(FILE *fp,char *formatstr,...) {}
#endif #endif
#define LP_MAJOR_VERSION "0" #define LP_MAJOR_VERSION "0"
@ -306,7 +307,7 @@ struct iguana_info
int32_t numutxos,notarized,longestchain,firstrefht,firstscanht,lastscanht,height; uint16_t busport,did_addrutxo_reset; int32_t numutxos,notarized,longestchain,firstrefht,firstscanht,lastscanht,height; uint16_t busport,did_addrutxo_reset;
uint32_t txversion,dPoWtime,lastautosplit,lastresetutxo,loadedcache,electrumlist,lastunspent,importedprivkey,lastpushtime,lastutxosync,addr_listunspent_requested,lastutxos,updaterate,counter,inactive,lastmempool,lastgetinfo,ratetime,heighttime,lastmonitor,obooktime; uint32_t txversion,dPoWtime,lastautosplit,lastresetutxo,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; 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],estimatefeestr[32],getinfostr[32],etomic[64]; char symbol[128],smartaddr[64],userpass[1024],serverport[128],instantdex_address[64],estimatefeestr[32],getinfostr[32],etomic[64],validateaddress[64];
// portfolio // portfolio
double price_kmd,force,perc,goal,goalperc,relvolume,rate; double price_kmd,force,perc,goal,goalperc,relvolume,rate;
void *electrum; void *ctx; void *electrum; void *ctx;

17
iguana/exchanges/LP_ordermatch.c

@ -770,9 +770,7 @@ char *LP_connectedalice(struct LP_quoteinfo *qp,char *pairstr) // alice
int32_t LP_aliceonly(char *symbol) int32_t LP_aliceonly(char *symbol)
{ {
if ( strcmp(symbol,"GAME") == 0 ) return(0);
return(1);
else return(0);
} }
int32_t LP_validSPV(char *symbol,char *coinaddr,bits256 txid,int32_t vout) int32_t LP_validSPV(char *symbol,char *coinaddr,bits256 txid,int32_t vout)
@ -1412,7 +1410,7 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson,
} else printf("got reserved response from destpubkey %s\n",bits256_str(str,Q.srchash)); } else printf("got reserved response from destpubkey %s\n",bits256_str(str,Q.srchash));
} }
} }
if ( bits256_cmp(G.LP_mypub25519,Q.desthash) == 0 && bits256_cmp(G.LP_mypub25519,Q.srchash) != 0 ) // alice if ( bits256_cmp(G.LP_mypub25519,Q.desthash) == 0 && bits256_cmp(G.LP_mypub25519,Q.srchash) != 0 && (Q.vout != Q.vout2 || bits256_cmp(Q.txid,Q.txid2) != 0) ) // alice
{ {
if ( Qtrades == 0 ) if ( Qtrades == 0 )
{ {
@ -1468,10 +1466,13 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson,
{ {
//if ( LP_Alicemaxprice != 0. ) //if ( LP_Alicemaxprice != 0. )
// return(retval); // return(retval);
bestprice = LP_bob_competition(&counter,aliceid,qprice,-1); if ( Q.destvout != Q.feevout || bits256_cmp(Q.desttxid,Q.feetxid) != 0 )
if ( Qtrades == 0 )//|| (bits256_cmp(Q.srchash,G.LP_mypub25519) == 0 && bits256_cmp(G.LP_mypub25519,Q.desthash) != 0) ) {
LP_trades_gotrequest(ctx,&Q,&Q2,jstr(argjson,"pair")); bestprice = LP_bob_competition(&counter,aliceid,qprice,-1);
else LP_tradecommandQ(&Q,jstr(argjson,"pair"),LP_REQUEST); if ( Qtrades == 0 )//|| (bits256_cmp(Q.srchash,G.LP_mypub25519) == 0 && bits256_cmp(G.LP_mypub25519,Q.desthash) != 0) )
LP_trades_gotrequest(ctx,&Q,&Q2,jstr(argjson,"pair"));
else LP_tradecommandQ(&Q,jstr(argjson,"pair"),LP_REQUEST);
}
} }
else if ( strcmp(method,"connect") == 0 ) else if ( strcmp(method,"connect") == 0 )
{ {

5
iguana/exchanges/LP_portfolio.c

@ -473,7 +473,7 @@ int32_t LP_autoref_clear(char *base,char *rel)
void LP_autoprice_iter(void *ctx,struct LP_priceinfo *btcpp) void LP_autoprice_iter(void *ctx,struct LP_priceinfo *btcpp)
{ {
static cJSON *tickerjson; static uint32_t lasttime; static cJSON *tickerjson; static uint32_t lasttime;
char *retstr,*base,*rel; cJSON *retjson,*bid,*ask,*fundjson,*argjson; uint64_t bidsatoshis,asksatoshis; int32_t i,changed; double bidprice,askprice,bch_usd,bch_btc,nxtkmd,price,factor,offset,newprice,buymargin,sellmargin,price_btc,price_usd,kmd_btc,kmd_usd; struct LP_priceinfo *kmdpp,*fiatpp,*nxtpp,*basepp,*relpp; char *retstr,*base,*rel; cJSON *retjson,*bid,*ask,*fundjson,*argjson; uint64_t bidsatoshis,asksatoshis; int32_t i,changed; double bidprice,askprice,bch_usd,ltc_btc,bch_btc,nxtkmd,price,factor,offset,newprice,buymargin,sellmargin,price_btc,price_usd,kmd_btc,kmd_usd; struct LP_priceinfo *kmdpp,*fiatpp,*nxtpp,*basepp,*relpp;
printf("AUTOPRICE numautorefs.%d\n",num_LP_autorefs); printf("AUTOPRICE numautorefs.%d\n",num_LP_autorefs);
if ( (retstr= issue_curlt("https://bittrex.com/api/v1.1/public/getmarketsummaries",LP_HTTP_TIMEOUT*10)) == 0 ) if ( (retstr= issue_curlt("https://bittrex.com/api/v1.1/public/getmarketsummaries",LP_HTTP_TIMEOUT*10)) == 0 )
{ {
@ -551,6 +551,7 @@ void LP_autoprice_iter(void *ctx,struct LP_priceinfo *btcpp)
} }
kmd_btc = LP_CMCbtcprice(&kmd_usd,"komodo"); kmd_btc = LP_CMCbtcprice(&kmd_usd,"komodo");
bch_btc = LP_CMCbtcprice(&bch_usd,"bitcoin-cash"); bch_btc = LP_CMCbtcprice(&bch_usd,"bitcoin-cash");
ltc_btc = LP_CMCbtcprice(&bch_usd,"litecoin");
for (i=0; i<num_LP_autorefs; i++) for (i=0; i<num_LP_autorefs; i++)
{ {
rel = LP_autorefs[i].rel; rel = LP_autorefs[i].rel;
@ -609,6 +610,8 @@ void LP_autoprice_iter(void *ctx,struct LP_priceinfo *btcpp)
price = kmd_btc / price_btc; price = kmd_btc / price_btc;
else if ( strcmp(rel,"BCH") == 0 && bch_btc > SMALLVAL ) else if ( strcmp(rel,"BCH") == 0 && bch_btc > SMALLVAL )
price = bch_btc / price_btc; price = bch_btc / price_btc;
else if ( strcmp(rel,"LTC") == 0 && ltc_btc > SMALLVAL )
price = ltc_btc / price_btc;
else if ( strcmp(rel,"BTC") == 0 ) else if ( strcmp(rel,"BTC") == 0 )
price = 1. / price_btc; price = 1. / price_btc;
else continue; else continue;

8
iguana/exchanges/LP_remember.c

@ -1687,6 +1687,14 @@ char *basilisk_swapentry(int32_t fastflag,uint32_t requestid,uint32_t quoteid,in
else return(clonestr("{\"error\":\"cant find requestid-quoteid\"}")); else return(clonestr("{\"error\":\"cant find requestid-quoteid\"}"));
} }
char *LP_kickstart(uint32_t requestid,uint32_t quoteid)
{
char fname[512];
sprintf(fname,"%s/SWAPS/%u-%u.finished",GLOBAL_DBDIR,requestid,quoteid), OS_compatible_path(fname);
OS_portable_removefile(fname);
return(basilisk_swapentry(0,requestid,quoteid,1));
}
extern struct LP_quoteinfo LP_Alicequery; extern struct LP_quoteinfo LP_Alicequery;
extern uint32_t Alice_expiration; extern uint32_t Alice_expiration;

28
iguana/exchanges/LP_rpc.c

@ -49,19 +49,19 @@ cJSON *bitcoin_json(struct iguana_info *coin,char *method,char *params)
// bitcoind_passthru callers: "importaddress", "estimatefee", "getblockhash", "sendrawtransaction", "signrawtransaction" // bitcoind_passthru callers: "importaddress", "estimatefee", "getblockhash", "sendrawtransaction", "signrawtransaction"
if ( coin != 0 ) if ( coin != 0 )
{ {
//if ( strcmp(method,"listunspent") == 0 ) if ( 0 && strcmp(method,"gettxout") == 0 && strcmp("BCH",coin->symbol) == 0 )
// printf("issue.(%s, %s, %s, %s, %s)\n",coin->symbol,coin->serverport,coin->userpass,method,params); printf("issue.(%s, %s, %s, %s, %s)\n",coin->symbol,coin->serverport,coin->userpass,method,params);
if ( coin->electrum != 0 && (strcmp(method,"getblock") == 0 || strcmp(method,"paxprice") == 0 || strcmp(method,"getrawmempool") == 0) ) if ( coin->electrum != 0 && (strcmp(method,"getblock") == 0 || strcmp(method,"paxprice") == 0 || strcmp(method,"getrawmempool") == 0) )
return(cJSON_Parse("{\"error\":\"illegal electrum call\"}")); return(cJSON_Parse("{\"error\":\"illegal electrum call\"}"));
if ( coin->inactive == 0 || strcmp(method,"importprivkey") == 0 || strcmp(method,"validateaddress") == 0 || strcmp(method,"getrawtransaction") == 0 || strcmp(method,"getblock") == 0 || strcmp(method,"getinfo") == 0 || strcmp(method,"getblockchaininfo") == 0 ) if ( coin->inactive == 0 || strcmp(method,"getrawtransaction") == 0 || strcmp(method,"getblock") == 0 || strcmp(method,"getinfo") == 0 || strcmp(method,"getblockchaininfo") == 0 || strcmp(method,"importprivkey") == 0 || strcmp(method,"validateaddress") == 0 || strcmp(method,"getaddressinfo") == 0 || strcmp(method,"importaddress") == 0 )
{ {
if ( coin->electrum == 0 ) if ( coin->electrum == 0 )
{ {
retstr = bitcoind_passthru(coin->symbol,coin->serverport,coin->userpass,method,params); retstr = bitcoind_passthru(coin->symbol,coin->serverport,coin->userpass,method,params);
if ( 0 && strcmp("BCH",coin->symbol) == 0 )
printf("%s.(%s %s): %s.%s -> (%s)\n",coin->symbol,coin->serverport,coin->userpass,method,params,retstr!=0?retstr:"");
if ( retstr != 0 && retstr[0] != 0 ) if ( retstr != 0 && retstr[0] != 0 )
{ {
//if ( strcmp(method,"listunspent") == 0 )
// printf("%s.(%s %s): %s.%s -> (%s)\n",coin->symbol,coin->serverport,coin->userpass,method,params,retstr);
retjson = cJSON_Parse(retstr); retjson = cJSON_Parse(retstr);
free(retstr); free(retstr);
} }
@ -77,7 +77,7 @@ cJSON *bitcoin_json(struct iguana_info *coin,char *method,char *params)
} }
} }
} }
} else retjson = cJSON_Parse("{\"result\":\"disabled\"}"); } //else retjson = cJSON_Parse("{\"result\":\"disabled\"}");
} else printf("bitcoin_json cant talk to NULL coin\n"); } else printf("bitcoin_json cant talk to NULL coin\n");
return(retjson); return(retjson);
} }
@ -344,7 +344,19 @@ cJSON *LP_validateaddress(char *symbol,char *address)
else else
{ {
sprintf(buf,"[\"%s\"]",address); sprintf(buf,"[\"%s\"]",address);
return(bitcoin_json(coin,"validateaddress",buf)); if ( coin->validateaddress[0] == 0 )
strcpy(coin->validateaddress,"validateaddress");
if ( (retjson= bitcoin_json(coin,coin->validateaddress,buf)) != 0 )
{
if ( strcmp(coin->symbol,"BTC") == 0 && jobj(retjson,"error") == 0 && jobj(retjson,"ismine") == 0 && strcmp(coin->validateaddress,"validateaddress") == 0 )
{
printf("autochange %s validateaddress -> getaddressinfo\n",coin->symbol);
strcpy(coin->validateaddress,"getaddressinfo");
free(retjson);
return(bitcoin_json(coin,coin->validateaddress,buf));
}
}
return(retjson);
} }
} }
@ -629,7 +641,7 @@ int32_t LP_importaddress(char *symbol,char *address)
sprintf(buf,"[\"%s\", \"%s\", false]",address,address); sprintf(buf,"[\"%s\", \"%s\", false]",address,address);
if ( (retstr= bitcoind_passthru(symbol,coin->serverport,coin->userpass,"importaddress",buf)) != 0 ) if ( (retstr= bitcoind_passthru(symbol,coin->serverport,coin->userpass,"importaddress",buf)) != 0 )
{ {
//printf("importaddress.(%s %s) -> (%s)\n",symbol,address,retstr); printf("importaddress.(%s %s) -> (%s)\n",symbol,address,retstr);
free(retstr); free(retstr);
} //else printf("importaddress.(%s %s)\n",symbol,address); } //else printf("importaddress.(%s %s)\n",symbol,address);
return(1); return(1);

14
iguana/exchanges/LP_signatures.c

@ -459,7 +459,7 @@ char *LP_pricepings(void *ctx,char *myipaddr,int32_t pubsock,char *base,char *re
char *LP_postprice_recv(cJSON *argjson) char *LP_postprice_recv(cJSON *argjson)
{ {
bits256 pubkey; double price; char *base,*rel,*argstr; bits256 pubkey; double price; uint8_t pubkey33[33]; char *base,*rel,*argstr,coinaddr[64];
//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 ) if ( (base= jstr(argjson,"base")) != 0 && (rel= jstr(argjson,"rel")) != 0 && (price= jdouble(argjson,"price")) > SMALLVAL )
{ {
@ -482,7 +482,17 @@ char *LP_postprice_recv(cJSON *argjson)
} }
else else
{ {
printf("sig failure.(%s)\n",jprint(argjson,0)); if ( jstr(argjson,"pubsecp") != 0 )
{
static char lasterror[64];
decode_hex(pubkey33,33,jstr(argjson,"pubsecp"));
bitcoin_address("KMD",coinaddr,0,60,pubkey33,33);
if ( strcmp(coinaddr,lasterror) != 0 )
{
printf("sig failure.(%s) %s\n",jprint(argjson,0),coinaddr);
strcpy(lasterror,coinaddr);
}
}
return(clonestr("{\"error\":\"sig failure\"}")); return(clonestr("{\"error\":\"sig failure\"}"));
} }
} }

9
iguana/exchanges/LP_socket.c

@ -613,12 +613,17 @@ cJSON *electrum_address_listunspent(char *symbol,struct electrum_info *ep,cJSON
if ( (ap= LP_address(coin,addr)) != 0 ) if ( (ap= LP_address(coin,addr)) != 0 )
{ {
if ( ap->unspenttime == 0 ) if ( ap->unspenttime == 0 )
usecache = 0; {
ap->unspenttime = (uint32_t)time(NULL);
ap->unspentheight = height;
usecache = 1;
}
else if ( ap->unspentheight < height ) else if ( ap->unspentheight < height )
usecache = 0; usecache = 0;
else if ( G.LP_pendingswaps != 0 && time(NULL) > ap->unspenttime+13 ) else if ( G.LP_pendingswaps != 0 && time(NULL) > ap->unspenttime+13 )
usecache = 0; usecache = 0;
} }
//usecache = 0; // disable unspents cache
if ( usecache == 0 || electrumflag > 1 ) if ( usecache == 0 || electrumflag > 1 )
{ {
if ( strcmp(symbol,"BCH") == 0 ) if ( strcmp(symbol,"BCH") == 0 )
@ -1064,7 +1069,7 @@ void LP_dedicatedloop(void *arg)
else else
{ {
#ifndef _WIN32 #ifndef _WIN32
printf("no more electrum data when expected2\n"); printf("no more electrum data when expected2 len.%d n.%d\n",len,n);
electrum_kickstart(ep); electrum_kickstart(ep);
#endif #endif
break; break;

1
iguana/exchanges/LP_swap.c

@ -705,6 +705,7 @@ uint32_t LP_swapdata_rawtxsend(int32_t pairsock,struct basilisk_swap *swap,uint3
{ {
if ( bits256_nonz(rawtx->I.signedtxid) != 0 && bits256_nonz(rawtx->I.actualtxid) == 0 ) if ( bits256_nonz(rawtx->I.signedtxid) != 0 && bits256_nonz(rawtx->I.actualtxid) == 0 )
{ {
basilisk_dontforget_update(swap,rawtx);
rawtx->I.actualtxid = LP_broadcast_tx(rawtx->name,rawtx->symbol,rawtx->txbytes,rawtx->I.datalen); rawtx->I.actualtxid = LP_broadcast_tx(rawtx->name,rawtx->symbol,rawtx->txbytes,rawtx->I.datalen);
if ( bits256_cmp(rawtx->I.actualtxid,rawtx->I.signedtxid) != 0 ) if ( bits256_cmp(rawtx->I.actualtxid,rawtx->I.signedtxid) != 0 )
{ {

23
iguana/exchanges/LP_transaction.c

@ -1035,6 +1035,8 @@ uint64_t _komodo_interestnew(uint64_t nValue,uint32_t nLockTime,uint32_t tiptime
//printf("minutes.%d tiptime.%u locktime.%u\n",minutes,tiptime,nLockTime); //printf("minutes.%d tiptime.%u locktime.%u\n",minutes,tiptime,nLockTime);
if ( minutes > 365 * 24 * 60 ) if ( minutes > 365 * 24 * 60 )
minutes = 365 * 24 * 60; minutes = 365 * 24 * 60;
if ( nLockTime > 1536000000 && minutes > 31*24*60 )
minutes = 31 * 24 * 60;
minutes -= 59; minutes -= 59;
interest = ((nValue / 10512000) * minutes); interest = ((nValue / 10512000) * minutes);
} }
@ -1625,7 +1627,7 @@ char *LP_createblasttransaction(uint64_t *changep,int32_t *changeoutp,cJSON **tx
return(0); return(0);
} }
} }
if ( change < 6000 ) if ( change < 6000 || change < txfee )
change = 0; change = 0;
*changep = change; *changep = change;
if ( change != 0 ) if ( change != 0 )
@ -1777,7 +1779,7 @@ char *LP_txblast(struct iguana_info *coin,cJSON *argjson)
char *LP_withdraw(struct iguana_info *coin,cJSON *argjson) char *LP_withdraw(struct iguana_info *coin,cJSON *argjson)
{ {
static void *ctx; static void *ctx;
int32_t broadcast,allocated_outputs=0,iter,i,num,utxovout,autofee,completed=0,maxV,numvins,numvouts,datalen,suppress_pubkeys; bits256 privkey; struct LP_address *ap; char changeaddr[64],vinaddr[64],str[65],*signret,*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; int32_t broadcast,allocated_outputs=0,iter,i,num,utxovout,autofee,completed=0,maxV,numvins,numvouts,datalen,suppress_pubkeys; bits256 privkey; struct LP_address *ap; char changeaddr[64],vinaddr[64],str[65],*signret,*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=0,newtxfee=10000;
//printf("withdraw.%s %s\n",coin->symbol,jprint(argjson,0)); //printf("withdraw.%s %s\n",coin->symbol,jprint(argjson,0));
if ( coin->etomic[0] != 0 ) if ( coin->etomic[0] != 0 )
{ {
@ -1848,7 +1850,7 @@ char *LP_withdraw(struct iguana_info *coin,cJSON *argjson)
datalen = (int32_t)strlen(signedtx) / 2; datalen = (int32_t)strlen(signedtx) / 2;
if ( autofee != 0 && iter == 0 && strcmp(coin->symbol,"BTC") == 0 ) if ( autofee != 0 && iter == 0 && strcmp(coin->symbol,"BTC") == 0 )
{ {
newtxfee = LP_txfeecalc(coin,0,datalen); txfee = newtxfee = LP_txfeecalc(coin,0,datalen);
printf("txfee %.8f -> newtxfee %.8f, numvins.%d\n",dstr(txfee),dstr(newtxfee),numvins); printf("txfee %.8f -> newtxfee %.8f, numvins.%d\n",dstr(txfee),dstr(newtxfee),numvins);
for (i=0; i<numvins; i++) for (i=0; i<numvins; i++)
{ {
@ -1903,6 +1905,7 @@ char *LP_withdraw(struct iguana_info *coin,cJSON *argjson)
if ( txobj != 0 ) if ( txobj != 0 )
jadd(retjson,"tx",txobj); jadd(retjson,"tx",txobj);
jaddbits256(retjson,"txid",signedtxid); jaddbits256(retjson,"txid",signedtxid);
jaddnum(retjson,"txfee",txfee);
jadd(retjson,"complete",completed!=0?jtrue():jfalse()); jadd(retjson,"complete",completed!=0?jtrue():jfalse());
if ( allocated_outputs != 0 ) if ( allocated_outputs != 0 )
free_json(outputs); free_json(outputs);
@ -1911,15 +1914,17 @@ char *LP_withdraw(struct iguana_info *coin,cJSON *argjson)
char *LP_autosplit(struct iguana_info *coin) char *LP_autosplit(struct iguana_info *coin)
{ {
char *retstr; cJSON *argjson,*withdrawjson,*outputs,*item; int64_t total,balance,halfval; char *retstr; cJSON *argjson,*withdrawjson,*outputs,*item; int64_t total,balance,halfval,txfee;
if ( coin->etomic[0] == 0 ) if ( coin->etomic[0] == 0 )
{ {
if ( coin->electrum != 0 ) if ( coin->electrum != 0 )
balance = LP_unspents_load(coin->symbol,coin->smartaddr); balance = LP_unspents_load(coin->symbol,coin->smartaddr);
else balance = LP_RTsmartbalance(coin); else balance = LP_RTsmartbalance(coin);
//printf("%s balance %.8f\n",coin->symbol,dstr(balance)); if ( (txfee= coin->txfee) == 0 ) // BTC
balance -= coin->txfee - 0.001; txfee = LP_txfeecalc(coin,0,500);
if ( balance > coin->txfee ) balance -= (txfee + 100000);
//printf("balance %.8f, txfee %.8f, threshold %.8f\n",dstr(balance),dstr(txfee),dstr((1000000 - (txfee + 100000))));
if ( balance > txfee && balance >= (1000000 - (txfee + 100000)) )
{ {
halfval = (balance / 100) * 45; halfval = (balance / 100) * 45;
argjson = cJSON_CreateObject(); argjson = cJSON_CreateObject();
@ -1936,11 +1941,11 @@ char *LP_autosplit(struct iguana_info *coin)
jadd(argjson,"outputs",outputs); jadd(argjson,"outputs",outputs);
jaddnum(argjson,"broadcast",1); jaddnum(argjson,"broadcast",1);
jaddstr(argjson,"coin",coin->symbol); jaddstr(argjson,"coin",coin->symbol);
//printf("autosplit.(%s)\n",jprint(argjson,0)); //printf("halfval %.8f autosplit.(%s)\n",dstr(halfval),jprint(argjson,0));
retstr = LP_withdraw(coin,argjson); retstr = LP_withdraw(coin,argjson);
free_json(argjson); free_json(argjson);
return(retstr); return(retstr);
} else return(clonestr("{\"error\":\"less than 0.0011 in balance\"}")); } else return(clonestr("{\"error\":\"balance too small to autosplit, please make more deposits\"}"));
} }
return(clonestr("{\"error\":\"couldnt autosplit\"}")); return(clonestr("{\"error\":\"couldnt autosplit\"}"));
} }

20
iguana/exchanges/LP_utxo.c

@ -357,7 +357,7 @@ int32_t LP_address_minmax(int32_t iambob,uint64_t *medianp,uint64_t *minp,uint64
int32_t LP_address_utxo_ptrs(struct iguana_info *coin,int32_t iambob,struct LP_address_utxo **utxos,int32_t max,struct LP_address *ap,char *coinaddr) int32_t LP_address_utxo_ptrs(struct iguana_info *coin,int32_t iambob,struct LP_address_utxo **utxos,int32_t max,struct LP_address *ap,char *coinaddr)
{ {
struct LP_address_utxo *up,*tmp; struct LP_transaction *tx; cJSON *txout; int32_t n = 0; struct LP_address_utxo *up,*tmp; struct LP_transaction *tx; cJSON *txout; int32_t i,n = 0;
if ( strcmp(ap->coinaddr,coinaddr) != 0 ) if ( strcmp(ap->coinaddr,coinaddr) != 0 )
printf("UNEXPECTED coinaddr mismatch (%s) != (%s)\n",ap->coinaddr,coinaddr); printf("UNEXPECTED coinaddr mismatch (%s) != (%s)\n",ap->coinaddr,coinaddr);
//portable_mutex_lock(&LP_utxomutex); //portable_mutex_lock(&LP_utxomutex);
@ -402,9 +402,15 @@ int32_t LP_address_utxo_ptrs(struct iguana_info *coin,int32_t iambob,struct LP_a
} }
if ( LP_allocated(up->U.txid,up->U.vout) == 0 ) if ( LP_allocated(up->U.txid,up->U.vout) == 0 )
{ {
utxos[n++] = up; for (i=0; i<n; i++)
if ( n >= max ) if ( utxos[i]->U.vout == up->U.vout && bits256_cmp(utxos[i]->U.txid,up->U.txid) == 0 )
break; break;
if ( i == n )
{
utxos[n++] = up;
if ( n >= max )
break;
}
} //else printf("LP_allocated skip %u\n",LP_allocated(up->U.txid,up->U.vout)); } //else printf("LP_allocated skip %u\n",LP_allocated(up->U.txid,up->U.vout));
} }
else else
@ -1139,14 +1145,14 @@ uint64_t LP_txvalue(char *coinaddr,char *symbol,bits256 txid,int32_t vout)
value = LP_value_extract(txobj,0,txid);//SATOSHIDEN * (jdouble(txobj,"value") + jdouble(txobj,"interest")); value = LP_value_extract(txobj,0,txid);//SATOSHIDEN * (jdouble(txobj,"value") + jdouble(txobj,"interest"));
if ( coinaddr != 0 ) if ( coinaddr != 0 )
LP_destaddr(coinaddr,txobj); LP_destaddr(coinaddr,txobj);
//printf("LP_txvalue %s tx %s/v%d value %.8f\n",coin->symbol,bits256_str(str,txid),vout,dstr(value)); //printf("LP_txvalue %s tx %s/v%d value %.8f (%s)\n",coin->symbol,bits256_str(str,txid),vout,dstr(value),jprint(txobj,0));
if ( value != 0 ) if ( value != 0 )
{ {
free_json(txobj); free_json(txobj);
return(value); return(value);
} }
} } //else printf("null return from LP_gettxout %s %s %s/v%d\n",coin->symbol,coinaddr,bits256_str(str,txid),vout);
printf("pruned node? LP_txvalue couldnt find %s tx %s/v%d (%s)\n",coin->symbol,bits256_str(str,txid),vout,txobj!=0?jprint(txobj,0):""); printf("pruned node or rpc access broken? LP_txvalue couldnt find %s tx %s/v%d (%s)\n",coin->symbol,bits256_str(str,txid),vout,txobj!=0?jprint(txobj,0):"");
if ( txobj != 0 ) if ( txobj != 0 )
free_json(txobj); free_json(txobj);
} }

2
iguana/exchanges/coins

File diff suppressed because one or more lines are too long

2
iguana/exchanges/kickstart

@ -1,3 +1,3 @@
#!/bin/bash #!/bin/bash
source userpass source userpass
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"KMD\",\"ipaddr\":\"\",\"port\":0}" curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"kickstart\",\"requestid\":772275036,\"quoteid\":1846027555}"

2
iguana/exchanges/prices/autoprice

@ -39,7 +39,7 @@ sharkholdings="{\"coin\":\"iota\",\"balance\":1500000}, {\"coin\":\"komodo\",\"b
curl --url "http://127.0.0.1:7783" --data "{\"base\":\"MSHARK\",\"rel\":\"KMD\",\"fundvalue_bid\":\"NAV_KMD\",\"fundvalue_ask\":\"assetNAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"margin\":$margin,\"address\":\"RTu3JZZKLJTcfNwBa19dWRagEfQq49STqC\",\"holdings\":[$sharkholdings],\"divisor\":1400000}" curl --url "http://127.0.0.1:7783" --data "{\"base\":\"MSHARK\",\"rel\":\"KMD\",\"fundvalue_bid\":\"NAV_KMD\",\"fundvalue_ask\":\"assetNAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"margin\":$margin,\"address\":\"RTu3JZZKLJTcfNwBa19dWRagEfQq49STqC\",\"holdings\":[$sharkholdings],\"divisor\":1400000}"
curl --url "http://127.0.0.1:7783" --data "{\"margin\":$margin,\"base\":\"SUPERNET\",\"rel\":\"KMD\",\"fundvalue_bid\":\"NAV_KMD\",\"fundvalue_ask\":\"NAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"address\":\"RRyyejME7LRTuvdziWsXkAbSW1fdiohGwK\",\"holdings\":[{\"coin\":\"iota\",\"balance\":11000000}, {\"coin\":\"stratis\",\"balance\":1300000}, {\"coin\":\"zcash\",\"balance\":0.10000}, {\"coin\":\"syscoin\",\"balance\":20000000}, {\"coin\":\"waves\",\"balance\":700000}, {\"coin\":\"bitcoin\",\"balance\":570}, {\"coin\":\"bitcoin-cash\",\"balance\":1500}, {\"coin\":\"heat-ledger\",\"balance\":2323851 }, {\"coin\":\"decred\",\"balance\":0.20000}, {\"coin\":\"vericoin\",\"balance\":2199368 }, {\"coin\":\"byteball\",\"balance\":4238}, {\"coin\":\"iocoin\",\"balance\":0.150000}, {\"coin\":\"quantum-resistant-ledger\",\"balance\":0.375000}, {\"coin\":\"chips\",\"balance\":2577006 }, {\"coin\":\"hush\",\"balance\":100000 }, {\"coin\":\"mobilego\",\"balance\":100000 }],\"divisor\":612529}" curl --url "http://127.0.0.1:7783" --data "{\"margin\":$margin,\"base\":\"SUPERNET\",\"rel\":\"KMD\",\"fundvalue_bid\":\"NAV_KMD\",\"fundvalue_ask\":\"NAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"address\":\"RRyyejME7LRTuvdziWsXkAbSW1fdiohGwK\",\"holdings\":[{\"coin\":\"iota\",\"balance\":11000000}, {\"coin\":\"stratis\",\"balance\":1300000}, {\"coin\":\"zcash\",\"balance\":0.10000}, {\"coin\":\"syscoin\",\"balance\":20000000}, {\"coin\":\"waves\",\"balance\":700000}, {\"coin\":\"bitcoin\",\"balance\":570}, {\"coin\":\"bitcoin-cash\",\"balance\":1500}, {\"coin\":\"heat-ledger\",\"balance\":2323851 }, {\"coin\":\"decred\",\"balance\":0.20000}, {\"coin\":\"vericoin\",\"balance\":2199368 }, {\"coin\":\"byteball\",\"balance\":4238}, {\"coin\":\"iocoin\",\"balance\":0.150000}, {\"coin\":\"quantum-resistant-ledger\",\"balance\":0.375000}, {\"coin\":\"chips\",\"balance\":2577006 }, {\"coin\":\"hush\",\"balance\":100000 }, {\"coin\":\"mobilego\",\"balance\":100000 }, {\"coin\":\"utrum\",\"balance\":2100000}],\"divisor\":612529}"
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}" 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}"

2
iguana/exchanges/splitfunds

@ -2,5 +2,5 @@
source userpass source userpass
export address=RGPido1EWcPWngDfkAcn4M4HXYt8avR4vs export address=RGPido1EWcPWngDfkAcn4M4HXYt8avR4vs
export script=2103f82c8c363d23076420a39904f9616d59c26a3d8dc7c51f67d8d3a94335431970ac export script=2103f82c8c363d23076420a39904f9616d59c26a3d8dc7c51f67d8d3a94335431970ac
curl --url "http://127.0.0.1:7783" --data "{\"broadcast\":1,\"userpass\":\"$userpass\",\"method\":\"withdraw\",\"coin\":\"$1\",\"outputs\":[{\"$address\":0.0005,\"script\":\"$script\"}, {\"$address\":0.0005,\"script\":\"$script\"}, {\"$address\":0.0005,\"script\":\"$script\"}, {\"$address\":0.0005,\"script\":\"$script\"}, {\"$address\":0.0005,\"script\":\"$script\"}, {\"$address\":0.0005,\"script\":\"$script\"}, {\"$address\":0.0005,\"script\":\"$script\"}, {\"$address\":0.0005,\"script\":\"$script\"}, {\"$address\":0.0005,\"script\":\"$script\"}, {\"$address\":0.0005,\"script\":\"$script\"}, {\"RGPido1EWcPWngDfkAcn4M4HXYt8avR4vs\":0.0001}]}" curl --url "http://127.0.0.1:7783" --data "{\"broadcast\":1,\"userpass\":\"$userpass\",\"method\":\"withdraw\",\"coin\":\"$1\",\"outputs\":[{\"$address\":0.0001,\"script\":\"$script\"}, {\"$address\":0.0001,\"script\":\"$script\"}, {\"$address\":0.0001,\"script\":\"$script\"}, {\"$address\":0.0001,\"script\":\"$script\"}, {\"$address\":0.0001,\"script\":\"$script\"}, {\"$address\":0.0001,\"script\":\"$script\"}, {\"$address\":0.0001,\"script\":\"$script\"}, {\"$address\":0.0001,\"script\":\"$script\"}, {\"$address\":0.0001,\"script\":\"$script\"}, {\"$address\":0.0001,\"script\":\"$script\"}, {\"$address\":0.0001}]}"

2
iguana/exchanges/supernet

@ -15,5 +15,5 @@ echo supernet
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"balances\",\"address\":\"RRyyejME7LRTuvdziWsXkAbSW1fdiohGwK\"}" curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"balances\",\"address\":\"RRyyejME7LRTuvdziWsXkAbSW1fdiohGwK\"}"
echo supernet echo supernet
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"fundvalue\",\"address\":\"RRyyejME7LRTuvdziWsXkAbSW1fdiohGwK\",\"holdings\":[{\"coin\":\"iota\",\"balance\":11000000}, {\"coin\":\"stratis\",\"balance\":1300000}, {\"coin\":\"zcash\",\"balance\":0.10000}, {\"coin\":\"syscoin\",\"balance\":20000000}, {\"coin\":\"waves\",\"balance\":700000}, {\"coin\":\"bitcoin\",\"balance\":570}, {\"coin\":\"bitcoin-cash\",\"balance\":1500}, {\"coin\":\"heat-ledger\",\"balance\":2323851 }, {\"coin\":\"decred\",\"balance\":0.20000}, {\"coin\":\"vericoin\",\"balance\":2199368 }, {\"coin\":\"byteball\",\"balance\":4238}, {\"coin\":\"iocoin\",\"balance\":0.150000}, {\"coin\":\"quantum-resistant-ledger\",\"balance\":0.375000}, {\"coin\":\"hush\",\"balance\":100000 }, {\"coin\":\"mobilego\",\"balance\":100000 }],\"divisor\":612529}" curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"fundvalue\",\"address\":\"RRyyejME7LRTuvdziWsXkAbSW1fdiohGwK\",\"holdings\":[{\"coin\":\"iota\",\"balance\":11000000}, {\"coin\":\"stratis\",\"balance\":1300000}, {\"coin\":\"zcash\",\"balance\":0.10000}, {\"coin\":\"syscoin\",\"balance\":20000000}, {\"coin\":\"waves\",\"balance\":700000}, {\"coin\":\"bitcoin\",\"balance\":570}, {\"coin\":\"bitcoin-cash\",\"balance\":1500}, {\"coin\":\"heat-ledger\",\"balance\":2323851 }, {\"coin\":\"decred\",\"balance\":0.20000}, {\"coin\":\"vericoin\",\"balance\":2199368 }, {\"coin\":\"byteball\",\"balance\":4238}, {\"coin\":\"iocoin\",\"balance\":0.150000}, {\"coin\":\"quantum-resistant-ledger\",\"balance\":0.375000}, {\"coin\":\"hush\",\"balance\":100000 }, {\"coin\":\"mobilego\",\"balance\":100000 }, {\"coin\":\"utrum\",\"balance\":2100000}],\"divisor\":612529}"

3
iguana/iguana777.c

@ -49,6 +49,9 @@ struct iguana_info *iguana_coinadd(char *symbol,char *name,cJSON *argjson,int32_
myinfo->allcoins_being_added = 1; myinfo->allcoins_being_added = 1;
coin = mycalloc('C',1,sizeof(*coin)); coin = mycalloc('C',1,sizeof(*coin));
strcpy(coin->getinfostr,"getinfo"); strcpy(coin->getinfostr,"getinfo");
strcpy(coin->validateaddress,"validateaddress");
strcpy(coin->estimatefeestr,"estimatefee");
strcpy(coin->signtxstr,"signrawtransaction");
coin->blockspacesize = IGUANA_MAXPACKETSIZE + 8192; coin->blockspacesize = IGUANA_MAXPACKETSIZE + 8192;
coin->blockspace = calloc(1,coin->blockspacesize); coin->blockspace = calloc(1,coin->blockspacesize);
if ( virtcoin != 0 || ((privatechain= jstr(argjson,"geckochain")) != 0 && privatechain[0] != 0) ) if ( virtcoin != 0 || ((privatechain= jstr(argjson,"geckochain")) != 0 && privatechain[0] != 0) )

4
iguana/iguana777.h

@ -167,7 +167,7 @@ struct supernet_info
uint8_t *pingbuf; uint8_t *pingbuf;
struct basilisk_request DEXaccept; struct basilisk_request DEXaccept;
FILE *dexfp; FILE *dexfp;
struct dpow_info DPOWS[1024]; int32_t numdpows,dpowsock,dexsock,pubsock,repsock,subsock,reqsock; struct dpow_info *DPOWS[8192]; int32_t numdpows,dpowsock,dexsock,pubsock,repsock,subsock,reqsock;
struct delayedPoW_info dPoW; struct delayedPoW_info dPoW;
struct basilisk_spend *spends; int32_t numspends; struct basilisk_spend *spends; int32_t numspends;
char bindaddr[64]; char bindaddr[64];
@ -180,7 +180,7 @@ struct supernet_info
#ifdef NOTARY_TESTMODE #ifdef NOTARY_TESTMODE
char dexseed_ipaddrs[1][64]; char dexseed_ipaddrs[1][64];
#else #else
char dexseed_ipaddrs[4][64]; char dexseed_ipaddrs[8][64];
#endif #endif
uint32_t dexipbits[128]; int32_t numdexipbits; portable_mutex_t dexmutex; uint32_t dexipbits[128]; int32_t numdexipbits; portable_mutex_t dexmutex;
// compatibility // compatibility

4
iguana/iguana_chains.c

@ -322,7 +322,7 @@ void iguana_chainparms(struct supernet_info *myinfo,struct iguana_chain *chain,c
if ( (port= extract_userpass(chain->serverport,chain->userpass,chain->symbol,chain->userhome,path,conf)) != 0 ) if ( (port= extract_userpass(chain->serverport,chain->userpass,chain->symbol,chain->userhome,path,conf)) != 0 )
chain->rpcport = port; chain->rpcport = port;
//if ( conf[0] != 0 ) //if ( conf[0] != 0 )
printf("PATH.(%s) CONF.(%s)\n",path!=0?path:"",conf); printf("PATH.(%s) CONF.(%s) txfee %.8f\n",path!=0?path:"",conf,dstr(chain->txfee));
if ( juint(argjson,"p2p") != 0 ) if ( juint(argjson,"p2p") != 0 )
chain->portp2p = juint(argjson,"p2p"); chain->portp2p = juint(argjson,"p2p");
else chain->portp2p = juint(argjson,"portp2p"); else chain->portp2p = juint(argjson,"portp2p");
@ -468,7 +468,7 @@ void iguana_chainparms(struct supernet_info *myinfo,struct iguana_chain *chain,c
} }
} }
sprintf(chain->messagemagic,"%s Signed Message:\n",chain->name); sprintf(chain->messagemagic,"%s Signed Message:\n",chain->name);
printf("COIN.%s serverport.(%s) RPCport.%u P2P.%u magic.%08x\n",chain->symbol,chain->serverport,chain->rpcport,chain->portp2p,*(uint32_t *)chain->netmagic); printf("COIN.%s serverport.(%s) RPCport.%u P2P.%u magic.%08x txfee %.8f\n",chain->symbol,chain->serverport,chain->rpcport,chain->portp2p,*(uint32_t *)chain->netmagic,dstr(chain->txfee));
} }
} }

302
iguana/iguana_notary.c

@ -60,23 +60,20 @@ void dpow_checkpointset(struct supernet_info *myinfo,struct dpow_checkpoint *che
void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t height,bits256 hash,uint32_t timestamp,uint32_t blocktime) void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t height,bits256 hash,uint32_t timestamp,uint32_t blocktime)
{ {
struct komodo_ccdataMoMoM mdata; void **ptrs; char str[65]; cJSON *blockjson; struct iguana_info *coin; struct dpow_checkpoint checkpoint; int32_t freq,minsigs,i,ht,notht; uint64_t signedmask; struct dpow_block *bp; //struct komodo_ccdataMoMoM mdata; cJSON *blockjson; uint64_t signedmask; struct iguana_info *coin;
void **ptrs; char str[65]; struct dpow_checkpoint checkpoint; int32_t i,ht,suppress=0; struct dpow_block *bp;
dpow_checkpointset(myinfo,&dp->last,height,hash,timestamp,blocktime); dpow_checkpointset(myinfo,&dp->last,height,hash,timestamp,blocktime);
checkpoint = dp->srcfifo[dp->srcconfirms]; checkpoint = dp->srcfifo[dp->srcconfirms];
if ( strcmp("BTC",dp->dest) == 0 ) dpow_fifoupdate(myinfo,dp->srcfifo,dp->last);
{ if ( strcmp(dp->dest,"KMD") == 0 )
freq = DPOW_CHECKPOINTFREQ;
minsigs = Notaries_BTCminsigs; //DPOW_MINSIGS;
}
else
{ {
minsigs = Notaries_minsigs; //DPOW_MIN_ASSETCHAIN_SIGS; if ( dp->DESTHEIGHT < dp->prevDESTHEIGHT+DPOW_CHECKPOINTFREQ )
if ( strcmp("CHIPS",dp->symbol) == 0 ) {
freq = 100; suppress = 1;
else freq = 1; //fprintf(stderr,"suppress %s -> KMD\n",dp->symbol);
}
} }
dpow_fifoupdate(myinfo,dp->srcfifo,dp->last); /*if ( strcmp(dp->dest,"KMD") == 0 )//|| strcmp(dp->dest,"CHAIN") == 0 )
if ( strcmp(dp->dest,"KMD") == 0 || strcmp(dp->dest,"CHAIN") == 0 )
{ {
//if ( dp->SRCREALTIME == 0 ) //if ( dp->SRCREALTIME == 0 )
// return; // return;
@ -97,7 +94,7 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he
if ( height > 0 && blocktime > 0 ) if ( height > 0 && blocktime > 0 )
{ {
dpow_checkpointset(myinfo,&dp->last,height,hash,timestamp,blocktime); dpow_checkpointset(myinfo,&dp->last,height,hash,timestamp,blocktime);
if ( (0) && strcmp("CHIPS",dp->symbol) == 0 ) if ( (0) && strcmp("KMD",dp->symbol) == 0 )
printf("dynamic set %s/%s %s <- height.%d\n",dp->symbol,dp->dest,bits256_str(str,hash),height); printf("dynamic set %s/%s %s <- height.%d\n",dp->symbol,dp->dest,bits256_str(str,hash),height);
checkpoint = dp->last; checkpoint = dp->last;
} else return; } else return;
@ -111,22 +108,25 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he
printf("lastnotarized.(%s) is current checkpoint, skip\n",bits256_str(str,dp->lastnotarized)); printf("lastnotarized.(%s) is current checkpoint, skip\n",bits256_str(str,dp->lastnotarized));
return; return;
} }
if ( (0) && strcmp("CHIPS",dp->symbol) == 0 ) if ( (0) && strcmp("KMD",dp->symbol) == 0 )
printf("checkpoint.(%s) is not active and not lastnotarized\n",bits256_str(str,checkpoint.blockhash.hash)); printf("checkpoint.(%s) is not active and not lastnotarized\n",bits256_str(str,checkpoint.blockhash.hash));
} else return; } else return;
} else return; } else return;
} else return; } else return;
} else return; } else return;
} }*/
if ( bits256_nonz(checkpoint.blockhash.hash) != 0 && (checkpoint.blockhash.height % freq) == 0 ) if ( dp->freq <= 0 )
dp->freq = 1;
if ( suppress == 0 && bits256_nonz(checkpoint.blockhash.hash) != 0 && (checkpoint.blockhash.height % dp->freq) == 0 )
{ {
if ( (0) && strcmp("CHIPS",dp->symbol) == 0 ) if ( (0) && strcmp("KMD",dp->symbol) == 0 )
printf("%s/%s src ht.%d dest.%u nonz.%d %s minsigs.%d\n",dp->symbol,dp->dest,checkpoint.blockhash.height,dp->destupdated,bits256_nonz(checkpoint.blockhash.hash),bits256_str(str,dp->last.blockhash.hash),minsigs); printf("%s/%s src ht.%d dest.%u nonz.%d %s minsigs.%d freq.%d\n",dp->symbol,dp->dest,checkpoint.blockhash.height,dp->destupdated,bits256_nonz(checkpoint.blockhash.hash),bits256_str(str,dp->last.blockhash.hash),dp->minsigs,dp->freq);
dpow_heightfind(myinfo,dp,checkpoint.blockhash.height + 1000); dpow_heightfind(myinfo,dp,checkpoint.blockhash.height + 1000);
dp->prevDESTHEIGHT = dp->DESTHEIGHT;
ptrs = calloc(1,sizeof(void *)*5 + sizeof(struct dpow_checkpoint) + sizeof(pthread_t)); ptrs = calloc(1,sizeof(void *)*5 + sizeof(struct dpow_checkpoint) + sizeof(pthread_t));
ptrs[0] = (void *)myinfo; ptrs[0] = (void *)myinfo;
ptrs[1] = (void *)dp; ptrs[1] = (void *)dp;
ptrs[2] = (void *)(uint64_t)minsigs; ptrs[2] = (void *)(uint64_t)dp->minsigs;
if ( strcmp(dp->dest,"KMD") != 0 ) if ( strcmp(dp->dest,"KMD") != 0 )
ptrs[3] = (void *)DPOW_DURATION; ptrs[3] = (void *)DPOW_DURATION;
else ptrs[3] = (void *)(DPOW_DURATION * 60); // essentially try forever for assetchains else ptrs[3] = (void *)(DPOW_DURATION * 60); // essentially try forever for assetchains
@ -137,14 +137,16 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he
if ( OS_thread_create((void *)((uint64_t)&ptrs[5] + sizeof(struct dpow_checkpoint)),NULL,(void *)dpow_statemachinestart,(void *)ptrs) != 0 ) if ( OS_thread_create((void *)((uint64_t)&ptrs[5] + sizeof(struct dpow_checkpoint)),NULL,(void *)dpow_statemachinestart,(void *)ptrs) != 0 )
{ {
} }
if ( ht > 500 ) if ( ht > DPOW_MAXFREQ*5 )
{ {
if ( (0) && strcmp("CHIPS",dp->symbol) == 0 ) if ( (0) && strcmp("CHIPS",dp->symbol) == 0 )
printf("ht.%d maxblocks.%d\n",ht,dp->maxblocks); printf("ht.%d maxblocks.%d\n",ht,dp->maxblocks);
for (i=ht-500; i>ht-10000&&i>100; i--) for (i=ht-DPOW_MAXFREQ*5; i>ht-DPOW_MAXFREQ*100&&i>DPOW_MAXFREQ; i--)
{ {
if ( (i % 100) != 0 && (bp= dp->blocks[i]) != 0 && bp->state == 0xffffffff ) if ( (bp= dp->blocks[i]) != 0 && bp->state == 0xffffffff ) //(i % DPOW_MAXFREQ) != 0 &&
{ {
if ( dp->currentbp == dp->blocks[i] )
dp->currentbp = 0;
dp->blocks[i] = 0; dp->blocks[i] = 0;
Numallocated--; Numallocated--;
free(bp); free(bp);
@ -191,6 +193,7 @@ void dpow_destconfirm(struct supernet_info *myinfo,struct dpow_info *dp,struct d
void dpow_destupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t height,bits256 hash,uint32_t timestamp,uint32_t blocktime) void dpow_destupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t height,bits256 hash,uint32_t timestamp,uint32_t blocktime)
{ {
dp->destupdated = timestamp; dp->destupdated = timestamp;
dp->DESTHEIGHT = height;
dpow_checkpointset(myinfo,&dp->destchaintip,height,hash,timestamp,blocktime); dpow_checkpointset(myinfo,&dp->destchaintip,height,hash,timestamp,blocktime);
dpow_approvedset(myinfo,dp,&dp->destchaintip,dp->desttx,dp->numdesttx); dpow_approvedset(myinfo,dp,&dp->destchaintip,dp->desttx,dp->numdesttx);
dpow_fifoupdate(myinfo,dp->destfifo,dp->destchaintip); dpow_fifoupdate(myinfo,dp->destfifo,dp->destchaintip);
@ -229,17 +232,18 @@ void iguana_dPoWupdate(struct supernet_info *myinfo,struct dpow_info *dp)
} else dpow_destupdate(myinfo,dp,height,blockhash,(uint32_t)time(NULL),blocktime); } else dpow_destupdate(myinfo,dp,height,blockhash,(uint32_t)time(NULL),blocktime);
} // else printf("error getchaintip for %s\n",dp->dest); } // else printf("error getchaintip for %s\n",dp->dest);
dp->numsrctx = sizeof(dp->srctx)/sizeof(*dp->srctx); dp->numsrctx = sizeof(dp->srctx)/sizeof(*dp->srctx);
if ( (strcmp(dp->dest,"KMD") == 0 || strcmp(dp->dest,"CHAIN") == 0) && dp->SRCHEIGHT < src->longestchain ) /*if ( (strcmp(dp->dest,"KMD") == 0 || strcmp(dp->dest,"CHAIN") == 0) && dp->SRCHEIGHT < src->longestchain )
{ {
//fprintf(stderr,"[I "); //fprintf(stderr,"[I ");
dp->SRCHEIGHT = dpow_issuer_iteration(dp,src,dp->SRCHEIGHT,&dp->SRCREALTIME); dp->SRCHEIGHT = dpow_issuer_iteration(dp,src,dp->SRCHEIGHT,&dp->SRCREALTIME);
//fprintf(stderr," %d] ",dp->SRCHEIGHT); //fprintf(stderr," %d] ",dp->SRCHEIGHT);
} }*/
if ( (height= dpow_getchaintip(myinfo,&merkleroot,&blockhash,&blocktime,dp->srctx,&dp->numsrctx,src)) != dp->last.blockhash.height && height >= 0 ) if ( (height= dpow_getchaintip(myinfo,&merkleroot,&blockhash,&blocktime,dp->srctx,&dp->numsrctx,src)) != dp->last.blockhash.height && height > 0 )
{ {
//char str[65]; printf("[%s].%d %s %s height.%d vs last.%d\n",dp->dest,dp->SRCHEIGHT,dp->symbol,bits256_str(str,blockhash),height,dp->last.blockhash.height);
if ( dp->lastheight == 0 ) if ( dp->lastheight == 0 )
dp->lastheight = height-1; dp->lastheight = height-1;
char str[65]; printf("[%s].%d %s %s height.%d vs last.%d\n",dp->dest,dp->SRCHEIGHT,dp->symbol,bits256_str(str,blockhash),height,dp->lastheight);
dp->SRCHEIGHT = height;
if ( height < dp->last.blockhash.height ) if ( height < dp->last.blockhash.height )
{ {
printf("iguana_dPoWupdate src.%s reorg detected %d vs %d approved.%d notarized.%d\n",dp->symbol,height,dp->last.blockhash.height,dp->approved[0].height,dp->notarized[0].height); printf("iguana_dPoWupdate src.%s reorg detected %d vs %d approved.%d notarized.%d\n",dp->symbol,height,dp->last.blockhash.height,dp->approved[0].height,dp->notarized[0].height);
@ -252,12 +256,13 @@ void iguana_dPoWupdate(struct supernet_info *myinfo,struct dpow_info *dp)
{ {
while ( dp->lastheight <= height ) while ( dp->lastheight <= height )
{ {
printf("dp->lastheight.%d <= height.%d\n",dp->lastheight,height);
blockhash = dpow_getblockhash(myinfo,src,dp->lastheight); blockhash = dpow_getblockhash(myinfo,src,dp->lastheight);
dpow_srcupdate(myinfo,dp,dp->lastheight++,blockhash,(uint32_t)time(NULL),blocktime); dpow_srcupdate(myinfo,dp,dp->lastheight++,blockhash,(uint32_t)time(NULL),blocktime);
} }
} }
} }
else if ( strcmp(dp->symbol,"KMD") == 0 ) else //if ( strcmp(dp->symbol,"KMD") == 0 )
{ {
while ( dp->lastheight <= height ) while ( dp->lastheight <= height )
{ {
@ -265,13 +270,13 @@ void iguana_dPoWupdate(struct supernet_info *myinfo,struct dpow_info *dp)
dpow_srcupdate(myinfo,dp,dp->lastheight++,blockhash,(uint32_t)time(NULL),blocktime); dpow_srcupdate(myinfo,dp,dp->lastheight++,blockhash,(uint32_t)time(NULL),blocktime);
} }
} }
else if ( time(NULL) > dp->lastsrcupdate+60 || height != dp->lastheight ) /*else if ( time(NULL) > dp->lastsrcupdate+60 || height != dp->lastheight )
{ {
dp->lastsrcupdate = (uint32_t)time(NULL); dp->lastsrcupdate = (uint32_t)time(NULL);
dp->lastheight = height; dp->lastheight = height;
blockhash = dpow_getblockhash(myinfo,src,dp->lastheight); blockhash = dpow_getblockhash(myinfo,src,dp->lastheight);
dpow_srcupdate(myinfo,dp,dp->lastheight,blockhash,(uint32_t)time(NULL),blocktime); dpow_srcupdate(myinfo,dp,dp->lastheight,blockhash,(uint32_t)time(NULL),blocktime);
} }*/
} //else printf("error getchaintip for %s\n",dp->symbol); } //else printf("error getchaintip for %s\n",dp->symbol);
} else printf("iguana_dPoWupdate missing src.(%s) %p or dest.(%s) %p\n",dp->symbol,src,dp->dest,dest); } else printf("iguana_dPoWupdate missing src.(%s) %p or dest.(%s) %p\n",dp->symbol,src,dp->dest,dest);
} }
@ -292,9 +297,14 @@ void dpow_addresses()
#include "../includes/iguana_apideclares.h" #include "../includes/iguana_apideclares.h"
#include "../includes/iguana_apideclares2.h" #include "../includes/iguana_apideclares2.h"
THREE_STRINGS(iguana,dpow,symbol,dest,pubkey) THREE_STRINGS_AND_DOUBLE(iguana,dpow,symbol,dest,pubkey,freq)
{ {
char *retstr,srcaddr[64],destaddr[64]; struct iguana_info *src,*destcoin; cJSON *ismine; int32_t i,srcvalid,destvalid; struct dpow_info *dp = &myinfo->DPOWS[myinfo->numdpows]; char *retstr,srcaddr[64],destaddr[64]; struct iguana_info *src,*destcoin; cJSON *ismine; int32_t i,srcvalid,destvalid; struct dpow_info *dp;
if ( (dp= myinfo->DPOWS[myinfo->numdpows]) == 0 )
myinfo->DPOWS[myinfo->numdpows] = calloc(1,sizeof(*dp));
if ( (dp= myinfo->DPOWS[myinfo->numdpows]) == 0 )
return(clonestr("{\"error\":\"dPoW cant allocate memory\"}"));
memset(dp,0,sizeof(*dp));
destvalid = srcvalid = 0; destvalid = srcvalid = 0;
if ( myinfo->NOTARY.RELAYID < 0 ) if ( myinfo->NOTARY.RELAYID < 0 )
{ {
@ -326,10 +336,10 @@ THREE_STRINGS(iguana,dpow,symbol,dest,pubkey)
return(clonestr("{\"error\":\"cant dPoW KMD without BTC\"}")); return(clonestr("{\"error\":\"cant dPoW KMD without BTC\"}"));
else if ( iguana_coinfind(dest) == 0 ) else if ( iguana_coinfind(dest) == 0 )
return(clonestr("{\"error\":\"cant dPoW without KMD (dest)\"}")); return(clonestr("{\"error\":\"cant dPoW without KMD (dest)\"}"));
if ( myinfo->numdpows > 1 ) if ( myinfo->numdpows > 0 )
{ {
for (i=1; i<myinfo->numdpows; i++) for (i=0; i<myinfo->numdpows; i++)
if ( strcmp(symbol,myinfo->DPOWS[i].symbol) == 0 ) if ( strcmp(symbol,myinfo->DPOWS[i]->symbol) == 0 )
{ {
dp->symbol[0] = 0; dp->symbol[0] = 0;
return(clonestr("{\"error\":\"cant dPoW same coin again\"}")); return(clonestr("{\"error\":\"cant dPoW same coin again\"}"));
@ -348,6 +358,20 @@ THREE_STRINGS(iguana,dpow,symbol,dest,pubkey)
} }
if ( dp->srcconfirms > DPOW_FIFOSIZE ) if ( dp->srcconfirms > DPOW_FIFOSIZE )
dp->srcconfirms = DPOW_FIFOSIZE; dp->srcconfirms = DPOW_FIFOSIZE;
if ( strcmp("BTC",dp->dest) == 0 )
{
dp->freq = DPOW_CHECKPOINTFREQ;
dp->minsigs = Notaries_BTCminsigs; //DPOW_MINSIGS;
}
else
{
dp->minsigs = Notaries_minsigs; //DPOW_MIN_ASSETCHAIN_SIGS;
if ( freq == 0 && (strcmp("CHIPS",dp->symbol) == 0 || strncmp("TEST",dp->symbol,4) == 0) )
dp->freq = DPOW_MAXFREQ;
else if ( freq > 2 )
dp->freq = freq;
else dp->freq = 2;
}
src = iguana_coinfind(dp->symbol); src = iguana_coinfind(dp->symbol);
destcoin = iguana_coinfind(dp->dest); destcoin = iguana_coinfind(dp->dest);
if ( src == 0 || destcoin == 0 ) if ( src == 0 || destcoin == 0 )
@ -364,23 +388,28 @@ THREE_STRINGS(iguana,dpow,symbol,dest,pubkey)
json = cJSON_Parse(retstr); json = cJSON_Parse(retstr);
if ( (ismine= jobj(json,"ismine")) != 0 && is_cJSON_True(ismine) != 0 ) if ( (ismine= jobj(json,"ismine")) != 0 && is_cJSON_True(ismine) != 0 )
srcvalid = 1; srcvalid = 1;
else srcvalid = 0; else
{
srcvalid = 0;
printf("src validation error %s %s %s\n",src->symbol,srcaddr,retstr);
}
free(retstr); free(retstr);
retstr = 0; retstr = 0;
} } else printf("%s %s didnt return anything\n",src->symbol,srcaddr);
bitcoin_address(destaddr,destcoin->chain->pubtype,dp->minerkey33,33); bitcoin_address(destaddr,destcoin->chain->pubtype,dp->minerkey33,33);
if ( (retstr= dpow_validateaddress(myinfo,destcoin,destaddr)) != 0 ) if ( (retstr= dpow_validateaddress(myinfo,destcoin,destaddr)) != 0 )
{ {
json = cJSON_Parse(retstr); json = cJSON_Parse(retstr);
if ( (ismine= jobj(json,"ismine")) != 0 && is_cJSON_True(ismine) != 0 ) if ( (ismine= jobj(json,"ismine")) != 0 && is_cJSON_True(ismine) != 0 )
destvalid = 1; destvalid = 1;
else destvalid = 0; else
{
destvalid = 0;
printf("dest validation error %s %s %s\n",src->symbol,srcaddr,retstr);
}
free(retstr); free(retstr);
retstr = 0; retstr = 0;
} } else printf("%s %s didnt return anything\n",destcoin->symbol,destaddr);
for (i=0; i<33; i++)
printf("%02x",dp->minerkey33[i]);
printf(" DPOW with pubkey.(%s) %s.valid%d %s -> %s %s.valid%d\n",tmp,srcaddr,srcvalid,dp->symbol,dp->dest,destaddr,destvalid);
if ( srcvalid <= 0 || destvalid <= 0 ) if ( srcvalid <= 0 || destvalid <= 0 )
{ {
dp->symbol[0] = 0; dp->symbol[0] = 0;
@ -393,7 +422,7 @@ THREE_STRINGS(iguana,dpow,symbol,dest,pubkey)
} }
if ( dp->blocks == 0 ) if ( dp->blocks == 0 )
{ {
dp->maxblocks = 1000000; dp->maxblocks = 10000;
dp->blocks = calloc(dp->maxblocks,sizeof(*dp->blocks)); dp->blocks = calloc(dp->maxblocks,sizeof(*dp->blocks));
} }
portable_mutex_init(&dp->paxmutex); portable_mutex_init(&dp->paxmutex);
@ -403,6 +432,9 @@ THREE_STRINGS(iguana,dpow,symbol,dest,pubkey)
//uint8_t buf[32768]; //uint8_t buf[32768];
//dpow_paxpending(buf); //dpow_paxpending(buf);
myinfo->numdpows++; myinfo->numdpows++;
for (i=0; i<33; i++)
printf("%02x",dp->minerkey33[i]);
printf(" DPOW with pubkey.(%s) %s.valid%d %s -> %s %s.valid%d, num.%d freq.%d minsigs.%d\n",tmp,srcaddr,srcvalid,dp->symbol,dp->dest,destaddr,destvalid,myinfo->numdpows,dp->freq,dp->minsigs);
return(clonestr("{\"result\":\"success\"}")); return(clonestr("{\"result\":\"success\"}"));
} }
@ -466,7 +498,7 @@ STRING_ARG(dpow,pending,fiat)
base[i] = 0; base[i] = 0;
for (i=0; i<myinfo->numdpows; i++) for (i=0; i<myinfo->numdpows; i++)
{ {
dp = &myinfo->DPOWS[i]; dp = myinfo->DPOWS[i];
if ( strcmp(dp->symbol,base) == 0 ) if ( strcmp(dp->symbol,base) == 0 )
return(jprint(dpow_withdraws_pending(dp),1)); return(jprint(dpow_withdraws_pending(dp),1));
} }
@ -579,6 +611,121 @@ void iguana_notarystats(int32_t totals[64],int32_t dispflag)
} }
} }
// slow and should be redone to use calc_MoM rpc
int32_t dpow_txhasnotarization(uint64_t *signedmaskp,int32_t *nothtp,struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid,int32_t height,struct komodo_ccdataMoMoM *mdata)
{
cJSON *txobj,*vins,*vin,*vouts,*vout,*spentobj,*sobj; char *hexstr; uint8_t script[256]; bits256 spenttxid; uint64_t notarymask=0; int32_t i,j,numnotaries,len,spentvout,numvins,numvouts,hasnotarization = 0;
if ( (txobj= dpow_gettransaction(myinfo,coin,txid)) != 0 )
{
if ( (vins= jarray(&numvins,txobj,"vin")) != 0 )
{
if ( numvins >= DPOW_MIN_ASSETCHAIN_SIGS )
{
notarymask = numnotaries = 0;
for (i=0; i<numvins; i++)
{
vin = jitem(vins,i);
spenttxid = jbits256(vin,"txid");
spentvout = jint(vin,"vout");
if ( (spentobj= dpow_gettransaction(myinfo,coin,spenttxid)) != 0 )
{
if ( (vouts= jarray(&numvouts,spentobj,"vout")) != 0 )
{
if ( spentvout < numvouts )
{
vout = jitem(vouts,spentvout);
if ( (sobj= jobj(vout,"scriptPubKey")) != 0 && (hexstr= jstr(sobj,"hex")) != 0 && (len= is_hexstr(hexstr,0)) == 35*2 )
{
len >>= 1;
decode_hex(script,len,hexstr);
if ( script[0] == 33 && script[34] == 0xac )
{
for (j=0; j<Notaries_num; j++)
{
if ( strncmp(Notaries_elected[j][1],hexstr+2,66) == 0 )
{
if ( ((1LL << j) & notarymask) == 0 )
{
//printf("n%d ",j);
numnotaries++;
notarymask |= (1LL << j);
break;
}
}
}
}
}
}
}
free_json(spentobj);
}
}
if ( numnotaries > 0 )
{
if ( numnotaries >= DPOW_MIN_ASSETCHAIN_SIGS )
{
hasnotarization = 1;
*nothtp = 0;
if ( (vouts= jarray(&numvouts,txobj,"vout")) != 0 )
{
bits256 blockhash,txid,MoM; uint32_t MoMdepth; char symbol[65];//,str[65],str2[65],str3[65];
vout = jitem(vouts,numvouts-1);
if ( (sobj= jobj(vout,"scriptPubKey")) != 0 && (hexstr= jstr(sobj,"hex")) != 0 && (len= is_hexstr(hexstr,0)) > 36*2 && len < sizeof(script)*2 )
{
len >>= 1;
decode_hex(script,len,hexstr);
if ( dpow_opreturn_parsesrc(&blockhash,nothtp,&txid,symbol,&MoM,&MoMdepth,script,len,mdata) > 0 && strcmp(symbol,coin->symbol) == 0 )
{
// if ( Notaries_port != DPOW_SOCKPORT ) // keep going till valid MoM found, useful for new chains without any MoM
{
if ( bits256_nonz(MoM) == 0 || MoMdepth == 0 || *nothtp >= height || *nothtp < 0 )
{
*nothtp = 0;
}
}
if ( mdata->pairs != 0 && mdata->numpairs > 0 )
{
for (j=0; j<mdata->numpairs; j++)
{
if ( mdata->pairs[j].notarization_height > coin->MoMoMheight )
{
coin->MoMoMheight = mdata->pairs[j].notarization_height;
printf("set %s MoMoMheight <- %d\n",coin->symbol,coin->MoMoMheight);
}
}
}
//printf("%s.%d notarizationht.%d %s -> %s MoM.%s [%d]\n",symbol,height,*nothtp,bits256_str(str,blockhash),bits256_str(str2,txid),bits256_str(str3,MoM),MoMdepth);
}
}
}
}
}
}
}
free_json(txobj);
}
if ( hasnotarization != 0 )
(*signedmaskp) = notarymask;
return(hasnotarization);
}
int32_t dpow_hasnotarization(uint64_t *signedmaskp,int32_t *nothtp,struct supernet_info *myinfo,struct iguana_info *coin,cJSON *blockjson,int32_t ht,struct komodo_ccdataMoMoM *mdata)
{
int32_t i,n,hasnotarization = 0; bits256 txid; cJSON *txarray;
*nothtp = 0;
*signedmaskp = 0;
memset(mdata,0,sizeof(*mdata));
if ( (txarray= jarray(&n,blockjson,"tx")) != 0 )
{
for (i=0; i<n; i++)
{
txid = jbits256i(txarray,i);
hasnotarization += dpow_txhasnotarization(signedmaskp,nothtp,myinfo,coin,txid,ht,mdata);
}
}
return(hasnotarization);
}
STRING_AND_TWOINTS(dpow,notarizations,symbol,height,numblocks) STRING_AND_TWOINTS(dpow,notarizations,symbol,height,numblocks)
{ {
struct komodo_ccdataMoMoM mdata; int32_t i,j,ht,maxheight,notht,masksums[64]; uint64_t signedmask; cJSON *retjson,*blockjson,*item,*array; bits256 blockhash; struct komodo_ccdataMoMoM mdata; int32_t i,j,ht,maxheight,notht,masksums[64]; uint64_t signedmask; cJSON *retjson,*blockjson,*item,*array; bits256 blockhash;
@ -720,9 +867,33 @@ STRING_AND_INT(dpow,fundnotaries,symbol,numblocks)
return(clonestr("{\"result\":\"success\"}")); return(clonestr("{\"result\":\"success\"}"));
} }
extern char *Notaries_elected[65][2];
cJSON *dpow_recvmasks(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_block *bp)
{
int32_t i; cJSON *retjson,*item; char hexstr[64];
retjson = cJSON_CreateArray();
if ( dp == 0 || bp == 0 )
return(retjson);
for (i=0; i<bp->numnotaries; i++)
{
item = cJSON_CreateObject();
jaddstr(item,"notary",Notaries_elected[i][0]);
jaddnum(item,"bestk",bp->notaries[i].bestk);
sprintf(hexstr,"%16llx",(long long)bp->notaries[i].recvmask);
jaddstr(item,"recvmask",hexstr);
sprintf(hexstr,"%16llx",(long long)bp->notaries[i].bestmask);
jaddstr(item,"bestmask",hexstr);
jaddi(retjson,item);
}
return(retjson);
}
STRING_ARG(dpow,active,maskhex) STRING_ARG(dpow,active,maskhex)
{ {
uint8_t data[8],revdata[8],pubkeys[64][33]; char pubkeystr[67]; int32_t i,len,current,n; uint64_t mask; cJSON *infojson,*retjson,*array = cJSON_CreateArray(); uint8_t data[8],revdata[8],pubkeys[64][33]; int32_t i,len,current,n; uint64_t mask; cJSON *infojson,*retjson,*array,*notarray;
array = cJSON_CreateArray();
notarray = cJSON_CreateArray();
if ( (infojson= dpow_getinfo(myinfo,coin)) != 0 ) if ( (infojson= dpow_getinfo(myinfo,coin)) != 0 )
{ {
current = jint(infojson,"blocks"); current = jint(infojson,"blocks");
@ -731,22 +902,24 @@ STRING_ARG(dpow,active,maskhex)
n = komodo_notaries("KMD",pubkeys,current); n = komodo_notaries("KMD",pubkeys,current);
if ( maskhex == 0 || maskhex[0] == 0 ) if ( maskhex == 0 || maskhex[0] == 0 )
{ {
mask = myinfo->DPOWS[0].lastrecvmask; return(jprint(dpow_recvmasks(myinfo,myinfo->DPOWS[0],myinfo->DPOWS[0]->currentbp),1));
/*mask = myinfo->DPOWS[0]->lastrecvmask;
for (i=0; i<n; i++) for (i=0; i<n; i++)
{ {
if ( ((1LL << i) & mask) != 0 ) if ( ((1LL << i) & mask) != 0 )
{ {
init_hexbytes_noT(pubkeystr,pubkeys[i],33); init_hexbytes_noT(pubkeystr,pubkeys[i],33);
printf("(%d %llx %s) ",i,(long long)(1LL << i),pubkeystr); //printf("(%d %llx %s) ",i,(long long)(1LL << i),pubkeystr);
jaddistr(array,pubkeystr); jaddistr(array,pubkeystr);
} }
} }
retjson = cJSON_CreateObject(); retjson = cJSON_CreateObject();
jadd64bits(retjson,"recvmask",mask); jadd64bits(retjson,"recvmask",mask);
jadd(retjson,"notaries",array); jadd(retjson,"notaries",array);
return(jprint(retjson,1)); return(jprint(retjson,1));*/
} }
printf("dpow active (%s)\n",maskhex); //printf("dpow active (%s)\n",maskhex);
if ( (len= (int32_t)strlen(maskhex)) <= 16 ) if ( (len= (int32_t)strlen(maskhex)) <= 16 )
{ {
len >>= 1; len >>= 1;
@ -756,23 +929,30 @@ STRING_ARG(dpow,active,maskhex)
revdata[i] = data[len-1-i]; revdata[i] = data[len-1-i];
mask = 0; mask = 0;
memcpy(&mask,revdata,sizeof(revdata)); memcpy(&mask,revdata,sizeof(revdata));
for (i=0; i<len; i++) //for (i=0; i<len; i++)
printf("%02x",data[i]); // printf("%02x",data[i]);
printf(" <- hex mask.%llx\n",(long long)mask); //printf(" <- hex mask.%llx\n",(long long)mask);
for (i=0; i<(len<<3); i++) for (i=0; i<(len<<3); i++)
{
if ( ((1LL << i) & mask) != 0 ) if ( ((1LL << i) & mask) != 0 )
{ {
init_hexbytes_noT(pubkeystr,pubkeys[i],33); //init_hexbytes_noT(pubkeystr,pubkeys[i],33);
printf("(%d %llx %s) ",i,(long long)(1LL << i),pubkeystr); //printf("(%d %llx %s) ",i,(long long)(1LL << i),pubkeystr);
jaddistr(array,pubkeystr); jaddistr(array,Notaries_elected[i][0]);
} }
return(jprint(array,1)); else jaddistr(notarray,Notaries_elected[i][0]);
}
retjson = cJSON_CreateObject();
jaddstr(retjson,"maskhex",maskhex);
jadd(retjson,"set",array);
jadd(retjson,"not",notarray);
return(jprint(retjson,1));
} else return(clonestr("{\"error\":\"maskhex too long\"}")); } else return(clonestr("{\"error\":\"maskhex too long\"}"));
} }
ZERO_ARGS(dpow,cancelratify) ZERO_ARGS(dpow,cancelratify)
{ {
myinfo->DPOWS[0].cancelratify = 1; myinfo->DPOWS[0]->cancelratify = 1;
return(clonestr("{\"result\":\"queued dpow cancel ratify\"}")); return(clonestr("{\"result\":\"queued dpow cancel ratify\"}"));
} }
@ -787,18 +967,18 @@ TWOINTS_AND_ARRAY(dpow,ratify,minsigs,timestamp,ratified)
ptrs[0] = (void *)myinfo; ptrs[0] = (void *)myinfo;
if ( (source= jstr(json,"source")) == 0 ) if ( (source= jstr(json,"source")) == 0 )
source = "KMD"; source = "KMD";
ptrs[1] = (void *)&myinfo->DPOWS[0]; ptrs[1] = (void *)myinfo->DPOWS[0];
for (i=0; i<myinfo->numdpows; i++) for (i=0; i<myinfo->numdpows; i++)
if ( strcmp(myinfo->DPOWS[0].symbol,source) == 0 ) if ( strcmp(myinfo->DPOWS[0]->symbol,source) == 0 )
{ {
ptrs[1] = (void *)&myinfo->DPOWS[i]; ptrs[1] = (void *)myinfo->DPOWS[i];
break; break;
} }
ptrs[2] = (void *)(long)minsigs; ptrs[2] = (void *)(long)minsigs;
ptrs[3] = (void *)DPOW_RATIFYDURATION; ptrs[3] = (void *)DPOW_RATIFYDURATION;
ptrs[4] = (void *)jprint(ratified,0); ptrs[4] = (void *)jprint(ratified,0);
memcpy(&ptrs[5],&checkpoint,sizeof(checkpoint)); memcpy(&ptrs[5],&checkpoint,sizeof(checkpoint));
myinfo->DPOWS[0].cancelratify = 0; myinfo->DPOWS[0]->cancelratify = 0;
if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)dpow_statemachinestart,(void *)ptrs) != 0 ) if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)dpow_statemachinestart,(void *)ptrs) != 0 )
{ {
} }

11
iguana/iguana_wallet.c

@ -980,7 +980,7 @@ cJSON *iguana_privkeysjson(struct supernet_info *myinfo,struct iguana_info *coin
if ( address != 0 ) if ( address != 0 )
{ {
strcpy(&addresses[64 * n++],address); strcpy(&addresses[64 * n++],address);
} else printf("cant get address from.(%s)\n",jprint(item,0)); } //else printf("cant get address from.(%s)\n",jprint(item,0));
} }
for (i=0; i<n; i++) for (i=0; i<n; i++)
{ {
@ -1402,7 +1402,7 @@ TWOSTRINGS_AND_INT(bitcoinrpc,walletpassphrase,password,permanentfile,timeout)
THREE_STRINGS(bitcoinrpc,encryptwallet,passphrase,password,permanentfile) THREE_STRINGS(bitcoinrpc,encryptwallet,passphrase,password,permanentfile)
{ {
char *retstr,buf[128],wifstr[128]; cJSON *retjson; int32_t need_KMD = 0,need_BTC = 0; char *retstr,buf[128],wifstr[128]; cJSON *retjson; int32_t need_KMD = 0,need_BTC = 0,need_GAME = 0;
if ( remoteaddr != 0 || coin == 0 ) if ( remoteaddr != 0 || coin == 0 )
return(clonestr("{\"error\":\"no remote encrypt or no coin\"}")); return(clonestr("{\"error\":\"no remote encrypt or no coin\"}"));
iguana_walletlock(myinfo,coin); iguana_walletlock(myinfo,coin);
@ -1439,6 +1439,8 @@ THREE_STRINGS(bitcoinrpc,encryptwallet,passphrase,password,permanentfile)
need_KMD = 1; need_KMD = 1;
if ( strcmp(coin->symbol,"BTC") != 0 ) if ( strcmp(coin->symbol,"BTC") != 0 )
need_BTC = 1; need_BTC = 1;
if ( strcmp(coin->symbol,"GAME") != 0 )
need_GAME = 1;
if ( need_KMD != 0 && (coin= iguana_coinfind("KMD")) != 0 ) if ( need_KMD != 0 && (coin= iguana_coinfind("KMD")) != 0 )
{ {
bitcoin_priv2wif(wifstr,waddr.privkey,coin->chain->wiftype); bitcoin_priv2wif(wifstr,waddr.privkey,coin->chain->wiftype);
@ -1456,6 +1458,11 @@ THREE_STRINGS(bitcoinrpc,encryptwallet,passphrase,password,permanentfile)
bitcoin_priv2wif(wifstr,waddr.privkey,128); bitcoin_priv2wif(wifstr,waddr.privkey,128);
jaddstr(retjson,"BTCwif",wifstr); jaddstr(retjson,"BTCwif",wifstr);
} }
if ( need_GAME != 0 && (coin= iguana_coinfind("GAME")) != 0 )
{
bitcoin_priv2wif(wifstr,waddr.privkey,coin->chain->wiftype);
jaddstr(retjson,"GAMEwif",wifstr);
}
/*if ( (dexstr= _dex_importaddress(myinfo,coin->symbol,waddr.coinaddr)) != 0 ) /*if ( (dexstr= _dex_importaddress(myinfo,coin->symbol,waddr.coinaddr)) != 0 )
{ {
if ( (dexjson= cJSON_Parse(dexstr)) != 0 ) if ( (dexjson= cJSON_Parse(dexstr)) != 0 )

18
iguana/m_notary_run

@ -16,11 +16,22 @@ source pubkey.txt
sleep 4 sleep 4
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"SuperNET\",\"method\":\"myipaddr\",\"ipaddr\":\"$myip\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"SuperNET\",\"method\":\"myipaddr\",\"ipaddr\":\"$myip\"}"
sleep 3 sleep 3
tests/addnotarys_7776 curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"78.47.196.146\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"82.202.193.98\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"54.95.68.31\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"142.54.164.114\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"45.7.229.33\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"103.6.12.111\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"155.254.17.21\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"138.121.203.210\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"209.58.169.65\"}"
#tests/addnotarys_7776
coins/btc_7776 coins/btc_7776
coins/ltc_7776 #coins/ltc_7776
coins/kmd_7776 coins/kmd_7776
coins/chips_7776 coins/chips_7776
coins/game_7776
./wp_7776 ./wp_7776
coins/revs_7776 coins/revs_7776
@ -43,7 +54,7 @@ coins/mnz_7776
coins/axo_7776 coins/axo_7776
coins/etomic_7776 coins/etomic_7776
coins/btch_7776 coins/btch_7776
coins/vote2018_7776 #coins/vote2018_7776
coins/ninja_7776 coins/ninja_7776
coins/oot_7776 coins/oot_7776
coins/bntn_7776 coins/bntn_7776
@ -53,4 +64,5 @@ coins/prlpay_7776
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"passthru\",\"method\":\"paxfiats\",\"timeout\":900000}" #curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"passthru\",\"method\":\"paxfiats\",\"timeout\":900000}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"$myip\"}" #curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"$myip\"}"
sleep 30
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"KMD\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"KMD\",\"pubkey\":\"$pubkey\"}"

2
iguana/tests/active

@ -0,0 +1,2 @@
#!/bin/bash
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"dpow\",\"method\":\"active\",\"maskhex\":\"7fc27f67df27e619\"}"

2
includes/iguana_apideclares.h

@ -174,7 +174,7 @@ STRING_AND_INT(iguana,snapshot,symbol,height);
INT_ARRAY_STRING(iguana,dividends,height,vals,symbol); INT_ARRAY_STRING(iguana,dividends,height,vals,symbol);
THREE_STRINGS(iguana,passthru,asset,function,hex); THREE_STRINGS(iguana,passthru,asset,function,hex);
STRING_ARG(iguana,initfastfind,activecoin); STRING_ARG(iguana,initfastfind,activecoin);
THREE_STRINGS(iguana,dpow,symbol,dest,pubkey); THREE_STRINGS_AND_DOUBLE(iguana,dpow,symbol,dest,pubkey,freq);
STRING_ARG(iguana,peers,activecoin); STRING_ARG(iguana,peers,activecoin);
STRING_AND_INT(iguana,maxpeers,activecoin,max); STRING_AND_INT(iguana,maxpeers,activecoin,max);
STRING_ARG(iguana,getconnectioncount,activecoin); STRING_ARG(iguana,getconnectioncount,activecoin);

2
includes/iguana_structs.h

@ -528,7 +528,7 @@ struct iguana_info
#ifdef DEPRECATED_HHUTXO #ifdef DEPRECATED_HHUTXO
struct iguana_hhaccount *accountstable; struct iguana_hhaccount *accountstable;
#endif #endif
char lastdispstr[2048],getinfostr[64]; char lastdispstr[2048],getinfostr[64],validateaddress[64],estimatefeestr[64],signtxstr[64];
double txidfind_totalmillis,txidfind_num,spendtxid_totalmillis,spendtxid_num; double txidfind_totalmillis,txidfind_num,spendtxid_totalmillis,spendtxid_num;
struct iguana_monitorinfo monitoring[256]; struct iguana_monitorinfo monitoring[256];
int32_t notarychain,didaddresses; int32_t notarychain,didaddresses;

Loading…
Cancel
Save