Browse Source

Merge latest jl777 dev. Fix conflicts.

pass-iguana-arg
Artem Pikulin 7 years ago
parent
commit
b506464328
  1. 12
      crypto777/bitcoind_RPC.c
  2. 1
      iguana/coins/eql_7776
  3. 1
      iguana/coins/glxt_7776
  4. 4
      iguana/dPoW.h
  5. 7
      iguana/dpow/dpow_fsm.c
  6. 41
      iguana/dpow/dpow_network.c
  7. 33
      iguana/dpow/dpow_rpc.c
  8. 22
      iguana/dpow/dpow_tx.c
  9. 2
      iguana/exchanges/LP_bitcoin.c
  10. 6
      iguana/exchanges/LP_coins.c
  11. 9
      iguana/exchanges/LP_commands.c
  12. 3
      iguana/exchanges/LP_nativeDEX.c
  13. 13
      iguana/exchanges/LP_network.c
  14. 201
      iguana/exchanges/LP_privkey.c
  15. 3
      iguana/exchanges/LP_rpc.c
  16. 7
      iguana/exchanges/LP_scan.c
  17. 2
      iguana/exchanges/LP_secp.c
  18. 7
      iguana/exchanges/LP_signatures.c
  19. 2
      iguana/exchanges/LP_swap.c
  20. 116
      iguana/exchanges/LP_transaction.c
  21. 2
      iguana/exchanges/coins
  22. 3
      iguana/exchanges/movecoinbases
  23. 2
      iguana/exchanges/prices/autoprice
  24. 5
      iguana/exchanges/stats.c
  25. 2
      iguana/exchanges/supernet
  26. 10
      iguana/iguana_notary.c
  27. 3
      iguana/m_notary_run
  28. 2
      iguana/m_splitfund
  29. 2
      iguana/mini-gmp.c

12
crypto777/bitcoind_RPC.c

@ -14,6 +14,7 @@
******************************************************************************/ ******************************************************************************/
//#define KEEPALIVE breaks marketmaker api
#ifndef FROM_JS #ifndef FROM_JS
#include "OS_portable.h" #include "OS_portable.h"
@ -143,7 +144,11 @@ 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)
{ {
CURL *curl_handle; static int didinit,count,count2; static double elapsedsum,elapsedsum2; extern int32_t USE_JAY; #ifdef KEEPALIVE
static
#endif
CURL *curl_handle = 0;
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; 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;
@ -151,7 +156,6 @@ char *bitcoind_RPC(char **retstrp,char *debugstr,char *url,char *userpass,char *
{ {
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)) )
{ {
@ -174,6 +178,7 @@ try_again:
if ( retstrp != 0 ) if ( retstrp != 0 )
*retstrp = 0; *retstrp = 0;
starttime = OS_milliseconds(); starttime = OS_milliseconds();
if ( curl_handle == 0 )
curl_handle = curl_easy_init(); curl_handle = curl_easy_init();
headers = curl_slist_append(0,"Expect:"); headers = curl_slist_append(0,"Expect:");
@ -244,7 +249,10 @@ try_again:
//laststart = milliseconds(); //laststart = milliseconds();
res = curl_easy_perform(curl_handle); res = curl_easy_perform(curl_handle);
curl_slist_free_all(headers); curl_slist_free_all(headers);
#ifndef KEEPALIVE
curl_easy_cleanup(curl_handle); curl_easy_cleanup(curl_handle);
curl_handle = 0;
#endif
if ( databuf != 0 ) // clean up temporary buffer if ( databuf != 0 ) // clean up temporary buffer
{ {
free(databuf); free(databuf);

1
iguana/coins/eql_7776

@ -0,0 +1 @@
curl --url "http://127.0.0.1:7776" --data "{\"conf\":\"EQL.conf\",\"path\":\"${HOME#"/"}/.komodo/EQL\",\"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\":\"EQL\",\"name\":\"EQL\",\"hasheaders\":1,\"useaddmultisig\":0,\"netmagic\":\"b890e458\",\"p2p\":10305,\"rpc\":10306,\"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\"}"

1
iguana/coins/glxt_7776

@ -0,0 +1 @@
curl --url "http://127.0.0.1:7776" --data "{\"conf\":\"GLXT.conf\",\"path\":\"${HOME#"/"}/.komodo/GLXT\",\"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\":\"GLXT\",\"name\":\"GLXT\",\"hasheaders\":1,\"useaddmultisig\":0,\"netmagic\":\"0beebb40\",\"p2p\":15722,\"rpc\":15723,\"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\"}"

4
iguana/dPoW.h

@ -119,6 +119,7 @@ struct dpow_block
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,matches,bestmatches; int8_t myind,bestk,ratifybestk,pendingbestk,pendingratifybestk,matches,bestmatches;
cJSON *ratified; cJSON *ratified;
uint16_t CCid;
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];
char signedtx[32768]; uint8_t ratifyrawtx[2][32768]; uint32_t pendingcrcs[2]; char signedtx[32768]; uint8_t ratifyrawtx[2][32768]; uint32_t pendingcrcs[2];
@ -143,6 +144,7 @@ struct dpow_info
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,DESTHEIGHT,prevDESTHEIGHT,SHORTFLAG,ratifying,minsigs,freq; int32_t lastheight,maxblocks,SRCHEIGHT,DESTHEIGHT,prevDESTHEIGHT,SHORTFLAG,ratifying,minsigs,freq;
struct pax_transaction *PAX; struct pax_transaction *PAX;
uint32_t fullCCid;
portable_mutex_t paxmutex,dexmutex; portable_mutex_t paxmutex,dexmutex;
uint32_t ipbits[128],numipbits; uint32_t ipbits[128],numipbits;
struct dpow_block **blocks,*currentbp; struct dpow_block **blocks,*currentbp;
@ -158,7 +160,7 @@ struct komodo_ccdataMoMoM
}; };
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 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); int32_t dpow_paxpending(struct supernet_info *myinfo,uint8_t *hex,int32_t hexsize,uint32_t *paxwdcrcp,bits256 MoM,uint32_t MoMdepth,uint16_t CCid,int32_t src_or_dest,struct dpow_block *bp);
void dex_updateclient(struct supernet_info *myinfo); 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 *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); 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);

7
iguana/dpow/dpow_fsm.c

@ -302,6 +302,7 @@ void dpow_statemachinestart(void *ptr)
Numallocated++; Numallocated++;
bp->MoM = MoM; bp->MoM = MoM;
bp->MoMdepth = MoMdepth; bp->MoMdepth = MoMdepth;
bp->CCid = dp->fullCCid & 0xffff;
bp->minsigs = minsigs; bp->minsigs = minsigs;
bp->duration = duration; bp->duration = duration;
bp->srccoin = src; bp->srccoin = src;
@ -438,7 +439,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 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)); printf("[%d] notarize %s->%s %s ht.%d minsigs.%d duration.%d start.%u MoM[%d] %s CCid.%u\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),bp->CCid);
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++)
@ -520,7 +521,7 @@ void dpow_statemachinestart(void *ptr)
if ( strcmp(bp->destcoin->symbol,"KMD") == 0 ) if ( strcmp(bp->destcoin->symbol,"KMD") == 0 )
src_or_dest = 0; src_or_dest = 0;
else src_or_dest = 1; else src_or_dest = 1;
extralen = dpow_paxpending(extras,sizeof(extras),&bp->paxwdcrc,bp->MoM,bp->MoMdepth,src_or_dest,bp); extralen = dpow_paxpending(myinfo,extras,sizeof(extras),&bp->paxwdcrc,bp->MoM,bp->MoMdepth,bp->CCid,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 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)); 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));
@ -541,7 +542,7 @@ void dpow_statemachinestart(void *ptr)
if ( strcmp(bp->destcoin->symbol,"KMD") == 0 ) if ( strcmp(bp->destcoin->symbol,"KMD") == 0 )
src_or_dest = 0; src_or_dest = 0;
else src_or_dest = 1; else src_or_dest = 1;
extralen = dpow_paxpending(extras,sizeof(extras),&bp->paxwdcrc,bp->MoM,bp->MoMdepth,src_or_dest,bp); extralen = dpow_paxpending(myinfo,extras,sizeof(extras),&bp->paxwdcrc,bp->MoM,bp->MoMdepth,bp->CCid,src_or_dest,bp);
bp->notaries[bp->myind].paxwdcrc = bp->paxwdcrc; bp->notaries[bp->myind].paxwdcrc = bp->paxwdcrc;
} }
if ( dp->checkpoint.blockhash.height > checkpoint.blockhash.height ) //(checkpoint.blockhash.height % 100) != 0 && if ( dp->checkpoint.blockhash.height > checkpoint.blockhash.height ) //(checkpoint.blockhash.height % 100) != 0 &&

41
iguana/dpow/dpow_network.c

@ -1308,6 +1308,8 @@ int32_t dpow_addnotary(struct supernet_info *myinfo,struct dpow_info *dp,char *i
char str[512]; uint32_t ipbits,*ptr; int32_t i,iter,n,retval = -1; char str[512]; uint32_t ipbits,*ptr; int32_t i,iter,n,retval = -1;
if ( myinfo->IAMNOTARY == 0 ) if ( myinfo->IAMNOTARY == 0 )
return(-1); return(-1);
if ( strcmp(ipaddr,"88.99.251.101") == 0 || strcmp(ipaddr,"82.202.193.100") == 0 )
return(-1);
portable_mutex_lock(&myinfo->notarymutex); portable_mutex_lock(&myinfo->notarymutex);
if ( myinfo->dpowsock >= 0 )//&& myinfo->dexsock >= 0 ) if ( myinfo->dpowsock >= 0 )//&& myinfo->dexsock >= 0 )
{ {
@ -1462,9 +1464,33 @@ void dpow_nanomsginit(struct supernet_info *myinfo,char *ipaddr)
dpow_addnotary(myinfo,0,ipaddr); dpow_addnotary(myinfo,0,ipaddr);
} }
int32_t dpow_crossconnected(uint64_t *badmaskp,struct dpow_block *bp,uint64_t bestmask)
{
int32_t i,j,n,num = 0; uint64_t mask;
*badmaskp = 0;
for (i=0; i<bp->numnotaries; i++)
{
mask = ((1LL << i) & bestmask);
if ( mask != 0 )
{
for (n=j=0; j<bp->numnotaries; j++)
{
if ( ((1LL << j) & bestmask) != 0 && (mask & bp->notaries[j].recvmask) != 0 )
n++;
}
//printf("%d ",n);
if ( n == bp->minsigs )
num++;
else *badmaskp |= mask;
}
}
//printf("-> num.%d for bestmask.%llx\n",num,(long long)bestmask);
return(num);
}
void dpow_bestconsensus(struct dpow_info *dp,struct dpow_block *bp) void dpow_bestconsensus(struct dpow_info *dp,struct dpow_block *bp)
{ {
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]; 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],badmask,matchesmask,recvmask,topmask; uint32_t crcval=0; char srcaddr[64],destaddr[64];
memset(wts,0,sizeof(wts)); memset(wts,0,sizeof(wts));
memset(owts,0,sizeof(owts)); memset(owts,0,sizeof(owts));
for (i=0; i<bp->numnotaries; i++) for (i=0; i<bp->numnotaries; i++)
@ -1518,11 +1544,14 @@ void dpow_bestconsensus(struct dpow_info *dp,struct dpow_block *bp)
{ {
//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] > matches && bitweight(masks[i]) == bp->minsigs ) if ( counts[i] > matches && bitweight(masks[i]) == bp->minsigs )
{
if ( dpow_crossconnected(&badmask,bp,masks[i]) == bp->minsigs )
{ {
matches = counts[i]; matches = counts[i];
besti = i; besti = i;
} }
} }
}
for (i=0; i<bp->numnotaries; i++) for (i=0; i<bp->numnotaries; i++)
{ {
if ( ((1LL << i) & masks[besti]) != 0 ) if ( ((1LL << i) & masks[besti]) != 0 )
@ -1537,6 +1566,8 @@ void dpow_bestconsensus(struct dpow_info *dp,struct dpow_block *bp)
bp->bestmatches = bestmatches; 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];
if ( bp->myind == 0 )
printf("matches.%d bestmatches.%d recv.%llx (%d %llx)\n",matches,bestmatches,(long long)bp->recvmask,bp->bestk,(long long)bp->bestmask);
if ( 0 && bp->myind == 0 && strcmp("CHIPS",dp->symbol) == 0 ) if ( 0 && bp->myind == 0 && strcmp("CHIPS",dp->symbol) == 0 )
{ {
for (i=0; i<bp->numnotaries; i++) for (i=0; i<bp->numnotaries; i++)
@ -1924,8 +1955,8 @@ void dpow_notarize_update(struct supernet_info *myinfo,struct dpow_info *dp,stru
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; bp->lastnanosend = now;
} }
if ( 0 && strcmp("CHIPS",dp->symbol) == 0 && bp->myind == 0 ) if ( 1 && strcmp("KMD",dp->symbol) == 0 && bp->myind == 0 )
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); printf("%s recv.%llx best.(%d %llx) m.%d p.%d:%d b.%d state.%d minsigs.%d pend.%d\n",dp->symbol,(long long)bp->recvmask,bp->bestk,(long long)bp->bestmask,matches,paxmatches,paxbestmatches,bestmatches,bp->state,bp->minsigs,bp->pendingbestk);
if ( bestmatches == bp->minsigs && paxbestmatches == bp->minsigs && bp->bestk >= 0 && bp->bestmask != 0 ) if ( bestmatches == bp->minsigs && paxbestmatches == bp->minsigs && bp->bestk >= 0 && bp->bestmask != 0 )
{ {
if ( bp->pendingbestk < 0 )//bp->pendingbestk != bp->bestk || bp->pendingbestmask != bp->bestmask ) if ( bp->pendingbestk < 0 )//bp->pendingbestk != bp->bestk || bp->pendingbestmask != bp->bestmask )
@ -1967,7 +1998,7 @@ 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() % 1024) == 0 || (bp->myind == 0 && (rand() % 50) == 0 && (strcmp(dp->symbol,"CHIPS") == 0 || strcmp(dp->symbol,"GAME") == 0)) ) if ( (rand() % 130) == 0 )
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); 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);
} }
} }
@ -2039,7 +2070,7 @@ void dpow_send(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_blo
if ( strcmp(bp->destcoin->symbol,"KMD") == 0 ) if ( strcmp(bp->destcoin->symbol,"KMD") == 0 )
src_or_dest = 0; src_or_dest = 0;
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(myinfo,extras,sizeof(extras),&paxwdcrc,bp->MoM,bp->MoMdepth,bp->CCid,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(dp,bp); //dpow_bestconsensus(dp,bp);
dpow_nanoutxoset(myinfo,dp,&np->notarize,bp,0); dpow_nanoutxoset(myinfo,dp,&np->notarize,bp,0);

33
iguana/dpow/dpow_rpc.c

@ -78,6 +78,17 @@ cJSON *dpow_getinfo(struct supernet_info *myinfo,struct iguana_info *coin)
return(json); return(json);
} }
uint32_t dpow_CCid(struct supernet_info *myinfo,struct iguana_info *coin)
{
uint32_t CCid = 0; cJSON *retjson;
if ( (retjson= dpow_getinfo(myinfo,coin)) != 0 )
{
CCid = juint(retjson,"CCid");
free_json(retjson);
}
return(CCid);
}
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)) int32_t Notaries_numseeds;// = (int32_t)(sizeof(seeds)/sizeof(*seeds))
@ -99,8 +110,7 @@ int32_t komodo_initjson(char *fname)
Notaries_port = port; Notaries_port = port;
if ( (num= juint(argjson,"BTCminsigs")) > Notaries_BTCminsigs ) if ( (num= juint(argjson,"BTCminsigs")) > Notaries_BTCminsigs )
Notaries_BTCminsigs = num; Notaries_BTCminsigs = num;
if ( (num= juint(argjson,"minsigs")) > Notaries_minsigs ) Notaries_minsigs = juint(argjson,"minsigs");
Notaries_minsigs = num;
if ( (array= jarray(&n,argjson,"seeds")) != 0 && n <= 64 ) if ( (array= jarray(&n,argjson,"seeds")) != 0 && n <= 64 )
{ {
for (i=0; i<n&&i<64; i++) for (i=0; i<n&&i<64; i++)
@ -252,16 +262,16 @@ cJSON *issue_calcMoM(struct iguana_info *coin,int32_t height,int32_t MoMdepth)
return(retjson); 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,uint16_t CCid)
{ {
char buf[128],*retstr=0; cJSON *retjson = 0; struct iguana_info *src; char buf[128],*retstr=0; cJSON *retjson = 0; struct iguana_info *src;
if ( coin->FULLNODE < 0 && strcmp(coin->symbol,"KMD") == 0 && (src= iguana_coinfind(symbol)) != 0 ) if ( coin->FULLNODE < 0 && strcmp(coin->symbol,"KMD") == 0 && (src= iguana_coinfind(symbol)) != 0 )
{ {
sprintf(buf,"[\"%s\", \"%d\", \"%d\"]",symbol,kmdheight,src->MoMoMheight); sprintf(buf,"[\"%s\", \"%d\", \"%d\"]",symbol,kmdheight,CCid);
if ( (retstr= bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"MoMoMdata",buf)) != 0 ) if ( (retstr= bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"MoMoMdata",buf)) != 0 )
{ {
retjson = cJSON_Parse(retstr); retjson = cJSON_Parse(retstr);
printf("MoMoM.%s -> %s\n",buf,retstr); printf("%s kmdheight.%d CCid.%u MoMoM.%s -> %s\n",symbol,kmdheight,CCid,buf,retstr);
free(retstr); free(retstr);
} }
usleep(10000); usleep(10000);
@ -269,22 +279,29 @@ cJSON *dpow_MoMoMdata(struct iguana_info *coin,char *symbol,int32_t kmdheight)
return(retjson); return(retjson);
} }
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) int32_t dpow_paxpending(struct supernet_info *myinfo,uint8_t *hex,int32_t hexsize,uint32_t *paxwdcrcp,bits256 MoM,uint32_t MoMdepth,uint16_t CCid,int32_t src_or_dest,struct dpow_block *bp)
{ {
struct iguana_info *coin,*kmdcoin=0; char *retstr,*hexstr; cJSON *retjson; int32_t hexlen=0,n=0; uint32_t paxwdcrc; struct iguana_info *coin,*kmdcoin=0; char *retstr,*hexstr; cJSON *retjson,*infojson; int32_t kmdheight=0,hexlen=0,n=0; uint32_t paxwdcrc;
paxwdcrc = 0; paxwdcrc = 0;
if ( strcmp(bp->srccoin->symbol,"GAME") != 0 || src_or_dest != 0 ) if ( strcmp(bp->srccoin->symbol,"GAME") != 0 || src_or_dest != 0 )
{ {
n += iguana_rwbignum(1,&hex[n],sizeof(MoM),MoM.bytes); n += iguana_rwbignum(1,&hex[n],sizeof(MoM),MoM.bytes);
MoMdepth = (MoMdepth & 0xffff) | ((uint32_t)CCid<<16);
n += iguana_rwnum(1,&hex[n],sizeof(MoMdepth),(uint32_t *)&MoMdepth); n += iguana_rwnum(1,&hex[n],sizeof(MoMdepth),(uint32_t *)&MoMdepth);
if ( strncmp(bp->srccoin->symbol,"TXSCL",5) == 0 && src_or_dest == 0 && strcmp(bp->destcoin->symbol,"KMD") == 0 ) if ( strncmp(bp->srccoin->symbol,"TXSCL",5) == 0 && src_or_dest == 0 && strcmp(bp->destcoin->symbol,"KMD") == 0 )
{ {
kmdcoin = bp->destcoin; kmdcoin = bp->destcoin;
if ( (retjson= dpow_MoMoMdata(kmdcoin,bp->srccoin->symbol,(kmdcoin->lastbestheight/10)*10 - 5)) != 0 ) if ( (infojson= dpow_getinfo(myinfo,kmdcoin)) != 0 )
{
kmdheight = jint(infojson,"blocks");
free_json(infojson);
}
if ( (retjson= dpow_MoMoMdata(kmdcoin,bp->srccoin->symbol,kmdheight,bp->CCid)) != 0 )
{ {
if ( (hexstr= jstr(retjson,"data")) != 0 && (hexlen= (int32_t)strlen(hexstr)) > 0 && n+hexlen/2 <= hexsize ) if ( (hexstr= jstr(retjson,"data")) != 0 && (hexlen= (int32_t)strlen(hexstr)) > 0 && n+hexlen/2 <= hexsize )
{ {
hexlen >>= 1; hexlen >>= 1;
printf("add MoMoMdata.(%s)\n",hexstr);
decode_hex(&hex[n],hexlen,hexstr), n += hexlen; decode_hex(&hex[n],hexlen,hexstr), n += hexlen;
} }
free_json(retjson); free_json(retjson);

22
iguana/dpow/dpow_tx.c

@ -101,7 +101,7 @@ 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; int8_t bestk = -1; uint64_t bestmask,mask = 0;//bp->require0; int32_t m,j,k,z,n; int8_t bestk = -1; uint64_t bestmask,mask = 0;//bp->require0;
bestmask = 0; bestmask = 0;
for (m=j=0; j<bp->numnotaries; j++) for (m=j=0; j<bp->numnotaries; j++)
{ {
@ -110,6 +110,11 @@ uint64_t dpow_notarybestk(uint64_t refmask,struct dpow_block *bp,int8_t *lastkp)
//if ( bp->require0 != 0 && k == 0 ) //if ( bp->require0 != 0 && k == 0 )
// continue; // continue;
if ( bits256_nonz(bp->notaries[k].src.prev_hash) != 0 && bits256_nonz(bp->notaries[k].dest.prev_hash) != 0 && bp->paxwdcrc == bp->notaries[k].paxwdcrc ) if ( bits256_nonz(bp->notaries[k].src.prev_hash) != 0 && bits256_nonz(bp->notaries[k].dest.prev_hash) != 0 && bp->paxwdcrc == bp->notaries[k].paxwdcrc )
{
for (z=n=0; z<bp->numnotaries; z++)
if ( (bp->notaries[z].recvmask & (1LL << k)) != 0 )
n++;
if ( n >= bp->numnotaries/2 )
{ {
mask |= (1LL << k); mask |= (1LL << k);
if ( ++m == bp->minsigs )//-bp->require0 ) if ( ++m == bp->minsigs )//-bp->require0 )
@ -120,6 +125,7 @@ uint64_t dpow_notarybestk(uint64_t refmask,struct dpow_block *bp,int8_t *lastkp)
} }
} }
} }
}
if ( bestk >= 0 ) if ( bestk >= 0 )
*lastkp = bestk; *lastkp = bestk;
return(bestmask); return(bestmask);
@ -193,7 +199,7 @@ struct dpow_block *dpow_heightfind(struct supernet_info *myinfo,struct dpow_info
return(bp); return(bp);
} }
int32_t dpow_voutstandard(struct dpow_block *bp,uint8_t *serialized,int32_t m,int32_t src_or_dest,uint8_t pubkeys[][33],int32_t numratified) int32_t dpow_voutstandard(struct supernet_info *myinfo,struct dpow_block *bp,uint8_t *serialized,int32_t m,int32_t src_or_dest,uint8_t pubkeys[][33],int32_t numratified)
{ {
uint32_t paxwdcrc=0,locktime=0,numvouts; struct iguana_info *coin; uint64_t satoshis,satoshisB; int32_t i,n=0,opretlen,len=0; uint8_t opret[16384],data[16384],extras[16384]; uint32_t paxwdcrc=0,locktime=0,numvouts; struct iguana_info *coin; uint64_t satoshis,satoshisB; int32_t i,n=0,opretlen,len=0; uint8_t opret[16384],data[16384],extras[16384];
numvouts = 2; numvouts = 2;
@ -232,7 +238,7 @@ int32_t dpow_voutstandard(struct dpow_block *bp,uint8_t *serialized,int32_t m,in
} }
if ( bp->MoMdepth > 0 && strcmp(bp->destcoin->symbol,"KMD") == 0 ) // || strcmp(bp->srccoin->symbol,"KMD") == 0) ) if ( bp->MoMdepth > 0 && strcmp(bp->destcoin->symbol,"KMD") == 0 ) // || strcmp(bp->srccoin->symbol,"KMD") == 0) )
{ {
n = dpow_paxpending(extras,sizeof(extras),&paxwdcrc,bp->MoM,bp->MoMdepth,src_or_dest,bp); n = dpow_paxpending(myinfo,extras,sizeof(extras),&paxwdcrc,bp->MoM,bp->MoMdepth,bp->CCid,src_or_dest,bp);
} }
satoshis = 0; satoshis = 0;
len += iguana_rwnum(1,&serialized[len],sizeof(satoshis),&satoshis); len += iguana_rwnum(1,&serialized[len],sizeof(satoshis),&satoshis);
@ -258,7 +264,7 @@ int32_t dpow_voutstandard(struct dpow_block *bp,uint8_t *serialized,int32_t m,in
return(len); return(len);
} }
bits256 dpow_notarytx(char *signedtx,int32_t *numsigsp,int32_t isPoS,struct dpow_block *bp,int8_t bestk,uint64_t bestmask,int32_t usesigs,int32_t src_or_dest,uint8_t pubkeys[][33],int32_t numratified) bits256 dpow_notarytx(struct supernet_info *myinfo,char *signedtx,int32_t *numsigsp,int32_t isPoS,struct dpow_block *bp,int8_t bestk,uint64_t bestmask,int32_t usesigs,int32_t src_or_dest,uint8_t pubkeys[][33],int32_t numratified)
{ {
uint32_t k,m,numsigs,version,vout,crcval,sequenceid = 0xffffffff; bits256 zero; int32_t n,siglen,len; uint8_t serialized[32768],*sig; bits256 txid; struct dpow_entry *ep; struct dpow_coinentry *cp; uint32_t k,m,numsigs,version,vout,crcval,sequenceid = 0xffffffff; bits256 zero; int32_t n,siglen,len; uint8_t serialized[32768],*sig; bits256 txid; struct dpow_entry *ep; struct dpow_coinentry *cp;
signedtx[0] = 0; signedtx[0] = 0;
@ -332,7 +338,7 @@ bits256 dpow_notarytx(char *signedtx,int32_t *numsigsp,int32_t isPoS,struct dpow
break; break;
} }
} }
if ( (n= dpow_voutstandard(bp,&serialized[len],m,src_or_dest,pubkeys,numratified)) < 0 ) if ( (n= dpow_voutstandard(myinfo,bp,&serialized[len],m,src_or_dest,pubkeys,numratified)) < 0 )
{ {
printf("error dpow_voutstandard m.%d src_or_dest.%d\n",m,src_or_dest); printf("error dpow_voutstandard m.%d src_or_dest.%d\n",m,src_or_dest);
return(zero); return(zero);
@ -510,7 +516,7 @@ int32_t dpow_signedtxgen(struct supernet_info *myinfo,struct dpow_info *dp,struc
srchash.bytes[j] = dp->minerkey33[j+1]; srchash.bytes[j] = dp->minerkey33[j+1];
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(myinfo,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("%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); //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
{ {
@ -573,8 +579,8 @@ void dpow_sigscheck(struct supernet_info *myinfo,struct dpow_info *dp,struct dpo
channel = (src_or_dest != 0) ? DPOW_SIGBTCCHANNEL : DPOW_SIGCHANNEL; channel = (src_or_dest != 0) ? DPOW_SIGBTCCHANNEL : DPOW_SIGCHANNEL;
if ( bestk >= 0 && bp->state != 0xffffffff && coin != 0 ) if ( bestk >= 0 && bp->state != 0xffffffff && coin != 0 )
{ {
dpow_notarytx(bp->signedtx,&numsigs,coin->chain->isPoS,bp,bestk,bestmask,0,src_or_dest,pubkeys,numratified); // setcrcval dpow_notarytx(myinfo,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(myinfo,bp->signedtx,&numsigs,coin->chain->isPoS,bp,bestk,bestmask,1,src_or_dest,pubkeys,numratified);
if ( strcmp("GAME",coin->symbol) == 0 ) if ( strcmp("GAME",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); 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;

2
iguana/exchanges/LP_bitcoin.c

@ -2093,7 +2093,7 @@ int32_t bitcoin_addr2rmd160(char *symbol,uint8_t taddr,uint8_t *addrtypep,uint8_
} }
else if ( (strcmp(symbol,"GRS") == 0 || strcmp(symbol,"SMART") == 0) && (buf[20+offset]&0xff) == hash.bytes[0] && (buf[21+offset]&0xff) == hash.bytes[1] && (buf[22+offset]&0xff) == hash.bytes[2] && (buf[23+offset]&0xff) == hash.bytes[3] ) else if ( (strcmp(symbol,"GRS") == 0 || strcmp(symbol,"SMART") == 0) && (buf[20+offset]&0xff) == hash.bytes[0] && (buf[21+offset]&0xff) == hash.bytes[1] && (buf[22+offset]&0xff) == hash.bytes[2] && (buf[23+offset]&0xff) == hash.bytes[3] )
return(20); return(20);
else else if ( strcmp(symbol,"BTC") != 0 || *addrtypep == 0 || *addrtypep == 5 )
{ {
int32_t i; int32_t i;
//if ( len > 20 ) //if ( len > 20 )

6
iguana/exchanges/LP_coins.c

@ -432,6 +432,11 @@ uint16_t LP_coininit(struct iguana_info *coin,char *symbol,char *name,char *asse
coin->zcash = LP_IS_BITCOINGOLD; coin->zcash = LP_IS_BITCOINGOLD;
printf("set coin.%s <- LP_IS_BITCOINGOLD %d\n",symbol,coin->zcash); printf("set coin.%s <- LP_IS_BITCOINGOLD %d\n",symbol,coin->zcash);
} }
else if ( strcmp(symbol,"CMM") == 0 )
{
coin->zcash = LP_IS_BITCOINCASH;
//printf("set coin.%s <- LP_IS_BITCOINCASH %d\n",symbol,coin->zcash);
}
coin->decimals = decimals; coin->decimals = decimals;
return(port); return(port);
} }
@ -500,7 +505,6 @@ struct iguana_info *LP_coinfind(char *symbol)
struct iguana_info *LP_coincreate(cJSON *item) struct iguana_info *LP_coincreate(cJSON *item)
{ {
struct iguana_info cdata,*coin=0; int32_t isPoS,longestchain = 1; uint16_t port; uint64_t txfee; double estimatedrate; uint8_t pubtype,p2shtype,wiftype; char *name=0,*symbol,*assetname=0; struct iguana_info cdata,*coin=0; int32_t isPoS,longestchain = 1; uint16_t port; uint64_t txfee; double estimatedrate; uint8_t pubtype,p2shtype,wiftype; char *name=0,*symbol,*assetname=0;
if ( (symbol= jstr(item,"coin")) != 0 && symbol[0] != 0 && strlen(symbol) < 16 && LP_coinfind(symbol) == 0 && (port= juint(item,"rpcport")) != 0 ) if ( (symbol= jstr(item,"coin")) != 0 && symbol[0] != 0 && strlen(symbol) < 16 && LP_coinfind(symbol) == 0 && (port= juint(item,"rpcport")) != 0 )
{ {
isPoS = jint(item,"isPoS"); isPoS = jint(item,"isPoS");

9
iguana/exchanges/LP_commands.c

@ -144,6 +144,7 @@ fundvalue(address="", holdings=[], divisor=0)\n\
orderbook(base, rel, duration=3600)\n\ orderbook(base, rel, duration=3600)\n\
getprices()\n\ getprices()\n\
inuse()\n\ inuse()\n\
movecoinbases(coin)\n\
getmyprice(base, rel)\n\ getmyprice(base, rel)\n\
getprice(base, rel)\n\ getprice(base, rel)\n\
//sendmessage(base=coin, rel="", pubkey=zero, <argjson method2>)\n\ //sendmessage(base=coin, rel="", pubkey=zero, <argjson method2>)\n\
@ -276,6 +277,10 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\
} }
return(jprint(retjson,1)); return(jprint(retjson,1));
} }
else if ( strcmp(method,"verus") == 0 )
{
return(verusblocks());
}
else if ( strcmp(method,"instantdex_claim") == 0 ) else if ( strcmp(method,"instantdex_claim") == 0 )
{ {
if ( (ptr= LP_coinsearch("KMD")) != 0 ) if ( (ptr= LP_coinsearch("KMD")) != 0 )
@ -708,6 +713,10 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\
return(LP_txblast(ptr,argjson)); return(LP_txblast(ptr,argjson));
else return(clonestr("{\"error\":\"cant find coind\"}")); else return(clonestr("{\"error\":\"cant find coind\"}"));
} }
else if ( strcmp(method,"movecoinbases") == 0 )
{
return(LP_movecoinbases(coin));
}
else if ( strcmp(method,"withdraw") == 0 ) else if ( strcmp(method,"withdraw") == 0 )
{ {
if ( (ptr= LP_coinsearch(coin)) != 0 ) if ( (ptr= LP_coinsearch(coin)) != 0 )

3
iguana/exchanges/LP_nativeDEX.c

@ -667,7 +667,7 @@ void LP_coinsloop(void *_coins)
{ {
if ( LP_blockinit(coin,coin->lastscanht) < 0 ) if ( LP_blockinit(coin,coin->lastscanht) < 0 )
{ {
printf("blockinit.%s %d error\n",coin->symbol,coin->lastscanht); printf("please ignore this blockinit.%s %d error\n",coin->symbol,coin->lastscanht);
sleep(10); sleep(10);
break; break;
} }
@ -893,6 +893,7 @@ void gameaddrs()
} }
} }
void LP_initcoins(void *ctx,int32_t pubsock,cJSON *coins) void LP_initcoins(void *ctx,int32_t pubsock,cJSON *coins)
{ {
int32_t i,n,notarized; cJSON *item; char *symbol,*etomic; struct iguana_info *coin; int32_t i,n,notarized; cJSON *item; char *symbol,*etomic; struct iguana_info *coin;

13
iguana/exchanges/LP_network.c

@ -27,6 +27,7 @@ struct psock
} *PSOCKS; } *PSOCKS;
uint16_t Numpsocks,Psockport = MIN_PSOCK_PORT,Pcmdport = MAX_PSOCK_PORT; uint16_t Numpsocks,Psockport = MIN_PSOCK_PORT,Pcmdport = MAX_PSOCK_PORT;
extern portable_mutex_t LP_commandQmutex;
#ifdef FROM_JS #ifdef FROM_JS
@ -879,8 +880,16 @@ char *LP_psock(int32_t *pullsockp,char *ipaddr,int32_t ispaired,int32_t cmdchann
char *issue_LP_psock(char *destip,uint16_t destport,int32_t ispaired,int32_t cmdchannel) char *issue_LP_psock(char *destip,uint16_t destport,int32_t ispaired,int32_t cmdchannel)
{ {
char str[65],url[512],*retstr; char str[65],url[512],*retstr; bits256 pub25519; int32_t netid;
sprintf(url,"http://%s:%u/api/stats/psock?ispaired=%d&cmdchannel=%d&pubkey=%s&netid=%d",destip,destport-1,ispaired,cmdchannel,bits256_str(str,G.LP_mypub25519),G.netid); #ifdef FROM_MARKETMAKER
pub25519 = G.LP_mypub25519;
netid = G.netid;
#else
extern bits256 BET_mypub25519;
pub25519 = BET_mypub25519;
netid = 0;
#endif
sprintf(url,"http://%s:%u/api/stats/psock?ispaired=%d&cmdchannel=%d&pubkey=%s&netid=%d",destip,destport-1,ispaired,cmdchannel,bits256_str(str,pub25519),netid);
//return(LP_issue_curl("psock",destip,destport,url)); //return(LP_issue_curl("psock",destip,destport,url));
retstr = issue_curlt(url,LP_HTTP_TIMEOUT*10); retstr = issue_curlt(url,LP_HTTP_TIMEOUT*10);
printf("issue_LP_psock got (%s) from %s\n",retstr,url); // this is needed?! printf("issue_LP_psock got (%s) from %s\n",retstr,url); // this is needed?!

201
iguana/exchanges/LP_privkey.c

@ -415,6 +415,205 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan
return(privkey); return(privkey);
} }
void verus_utxos(struct iguana_info *coin,char *coinaddr)
{
cJSON *array,*item; char buf[64],str[65]; int32_t i,m,vout,n=0; bits256 txid;
sprintf(buf,"[%d, 99999999, [\"%s\"]]",1,coinaddr);
array = bitcoin_json(coin,"listunspent",buf);
if ( array != 0 )
{
if ( (n= cJSON_GetArraySize(array)) > 0 )
{
for (i=m=0; i<n; i++)
{
item = jitem(array,i);
if ( fabs(jdouble(item,"amount") - 64.) < 0.00011 )
{
txid = jbits256(item,"txid");
vout = jint(item,"vout");
printf("%d: %s/v%d\n",m,bits256_str(str,txid),vout);
m++;
}
}
}
free_json(array);
}
printf("scanned %d utxos m.%d\n",n,m);
}
char *verusblocks()
{
bits256 hash,txid; uint8_t script[44]; double value,avestakedsize,stakedval,RTu3sum,powsum,supply,possum,histo[1280],myhisto[1280]; int32_t num2,num4,num8,num16,num32,num64,num17500,numpow,numpos,num,locked,height,i,m,n,z,numstaked,posflag,npos,npow; char hashstr[64],firstaddr[64],stakingaddr[64],*addr0,*lastaddr,*hexstr; cJSON *blockjson,*txobj,*vouts,*vout,*vout1,*sobj,*addresses,*txs;
struct iguana_info *coin = LP_coinfind("VRSC");
if ( coin == 0 )
return(clonestr("{\"error\":\"VRSC not active\"}"));
char *coinaddr = "RHV2As4rox97BuE3LK96vMeNY8VsGRTmBj";
if ( strcmp(coinaddr,coin->smartaddr) != 0 )
return(clonestr("{\"error\":\"mismatched smartaddr\"}"));
//verus_utxos(coin,coin->smartaddr);
hash = LP_getbestblockhash(coin);
memset(histo,0,sizeof(histo));
memset(myhisto,0,sizeof(myhisto));
num17500 = num16 = num32 = num64 = num2 = num4 = num8 = numstaked = 0;
avestakedsize = possum = powsum = supply = RTu3sum = 0.;
numpow = numpos = num = npos = npow = 0;
if ( bits256_nonz(hash) != 0 )
{
bits256_str(hashstr,hash);
height = -1;
while ( (blockjson= LP_blockjson(&height,coin->symbol,hashstr,0)) != 0 )
{
num++;
stakedval = 0.;
height = juint(blockjson,"height");
if ( (txs= jarray(&n,blockjson,"tx")) != 0 )
{
txid = jbits256i(txs,0);
value = 0;
posflag = 0;
locked = 0;
lastaddr = addr0 = "";
memset(script,0,sizeof(script));
memset(firstaddr,0,sizeof(firstaddr));
memset(stakingaddr,0,sizeof(stakingaddr));
if ( (txobj= LP_gettx("verus",coin->symbol,txid,0)) != 0 )
{
//printf("TX.(%s)\n",jprint(txobj,0));
if ( (vouts= jarray(&m,txobj,"vout")) != 0 )
{
if ( (vout= jitem(vouts,0)) != 0 )
{
value = jdouble(vout,"value");
supply += value;
hexstr = 0;
if ( m == 2 && (vout1= jitem(vouts,1)) != 0 )
{
// 6a2001039bbc0bb17576a9149a3af738444dd86b55c86752247aec2e7deb842688ac
if ( jdouble(vout1,"value") == 0. && (sobj= jobj(vout1,"scriptPubKey")) != 0 && (hexstr= jstr(sobj,"hex")) != 0 && strlen(hexstr) <= 88 )
{
if ( strlen(hexstr) == 68 )
{
decode_hex(script,34,hexstr);
bitcoin_address(coin->symbol,firstaddr,coin->taddr,coin->pubtype,&script[12],20);
//printf("%s\n",&hexstr[24]);
}
else
{
decode_hex(script,44,hexstr);
bitcoin_address(coin->symbol,firstaddr,coin->taddr,coin->pubtype,&script[10],33);
}
locked = ((int32_t)script[6] << 16) + ((int32_t)script[5] << 8) + script[4];
addr0 = firstaddr;
} else printf("unexpected vout1.(%s) (%s).%d %.8f\n",jprint(vout1,0),hexstr!=0?hexstr:"",(int32_t)strlen(hexstr),jdouble(vout1,"value"));
} else printf("coinbase without opret (%s)\n",jprint(vouts,0));
}
}
free_json(txobj);
}
if ( n > 1 && (txobj= LP_gettx("verus",coin->symbol,jbits256i(txs,n-1),0)) != 0 )
{
if ( (vouts= jarray(&m,txobj,"vout")) != 0 )
{
if ( (vout= jitem(vouts,0)) != 0 && m == 1 )
{
if ( (sobj= jobj(vout,"scriptPubKey")) != 0 && (addresses= jarray(&z,sobj,"addresses")) != 0 )
{
lastaddr = jstri(addresses,0);
if ( lastaddr == 0 )
lastaddr = "";
else
{
strcpy(stakingaddr,lastaddr);
stakedval = jdouble(vout,"value");
avestakedsize += stakedval;
numstaked++;
//printf("stakedval %f\n",stakedval);
posflag = 1;
//printf("ht.%d found staking address.(%s) %.8f (%s)\n",height,stakingaddr,stakedval,jprint(vout,0));
}
} else printf("no addresses[0] in (%s) %s\n",jprint(vout,0),sobj!=0?jprint(sobj,0):"");
} //else printf("n.%d m.%d no first out in lastvout.(%s)\n",n,m,jprint(txobj,0));
} // else printf("cant find vout.(%s)\n",jprint(txobj,0));
free_json(txobj);
}
if ( posflag != 0 )
{
numpos++;
if ( strcmp(coinaddr,stakingaddr) == 0 || strcmp("RTu3JZZKLJTcfNwBa19dWRagEfQq49STqC",stakingaddr) == 0 )
{
if (strcmp("RTu3JZZKLJTcfNwBa19dWRagEfQq49STqC",stakingaddr) == 0 )
RTu3sum += value;
possum += value, npos++;
if ( num < 1500 )
printf("ht.%-5d lock.%-7d PoS cb.(%s) stake.(%s) %.8f %.8f\n",height,locked,addr0,stakingaddr,value,stakedval);
if ( height > 17500 )
{
char strbuf[64];
sprintf(strbuf,"%.0f",stakedval);
if ( strcmp(strbuf,"64") == 0 )
num64++;
else if ( strcmp(strbuf,"32") == 0 )
num32++;
else if ( strcmp(strbuf,"16") == 0 )
num16++;
else if ( strcmp(strbuf,"8") == 0 )
num8++;
else if ( strcmp(strbuf,"4") == 0 )
num4++;
else if ( strcmp(strbuf,"2") == 0 )
num2++;
else printf("got strbuf.(%s)\n",strbuf);
}
}
else if ( 0 && num < 100 )
printf("ht.%-5d lock.%-7d PoS cb.(%s) stake.(%s) %.8f %.8f\n",height,locked,addr0,stakingaddr,value,stakedval);
}
else
{
numpow++;
if ( num < 100 && strcmp(coinaddr,addr0) == 0 )
printf("ht.%-5d lock.%-7d PoW coinbase.(%s) %.8f\n",height,locked,addr0,value);
if ( strcmp(coinaddr,addr0) == 0 )
powsum += value, npow++;
}
histo[locked/1000] += value;
if ( strcmp(coinaddr,addr0) == 0 || strcmp("RTu3JZZKLJTcfNwBa19dWRagEfQq49STqC",addr0) == 0 )
myhisto[locked/1000] += value;
}
bits256_str(hashstr,jbits256(blockjson,"previousblockhash"));
free_json(blockjson);
if ( height == 5040 )
break;
else if ( height == 17500 )
{
num17500 = num;
printf("num2.%d num4.%d num8.%d num16.%d / num17500.%d -> %.2f%% %.2f%% %.2f%% %.2f%% [%.3f %.3f %.3f %.3f] %.3f ave %.8f\n",num2,num4,num8,num16,num17500,100.*(double)num2/num17500,100.*(double)num4/num17500,100.*(double)num8/num17500,100.*(double)num16/num17500,(100.*(double)num2/num17500)/2.75,(100.*(double)num4/num17500)/2.75,(100.*(double)num8/num17500)/4.5,(100.*(double)num16/num17500)/14,(100.*(double)(num2+num4+num8+num16)/num17500)/24,avestakedsize/numstaked);
}
else if ( (num % 1000) == 0 || (num < 1000 && (num % 100) == 0) )
{
printf("num.%d PoW %.2f%% %.0f %d v %d PoS %.2f%% %.0f -> %.0f supply %.0f PoW %.1f%% PoS %.1f%% both %.1f%% RTu3 %.8f %.1f%%\n",num,100.*(double)numpow/num,powsum,npow,npos,100.*(double)numpos/num,possum,powsum+possum,supply,100.*powsum/supply,100.*possum/supply,100.*(powsum+possum)/supply,RTu3sum,100.*RTu3sum/supply);
}
}
}
if ( num > 0 )
{
if ( 0 )
{
for (i=0; i<sizeof(histo)/sizeof(*histo); i++)
if ( histo[i] != 0 )
printf("%d %.8f, ",i*1000,histo[i]);
printf("timelocked\n");
for (i=0; i<sizeof(myhisto)/sizeof(*myhisto); i++)
if ( myhisto[i] != 0 )
printf("%d %.8f, ",i*1000,myhisto[i]);
printf("mytimelocked\n");
}
printf("num.%d PoW %.2f%% %.8f %d v %d PoS %.2f%% %.8f -> %.8f supply %.8f PoW %.1f%% PoS %.1f%% both %.1f%% RTu3sum %.8f %.1f%%\n",num,100.*(double)numpow/num,powsum,npow,npos,100.*(double)numpos/num,possum,powsum+possum,supply,100.*powsum/supply,100.*possum/supply,100.*(powsum+possum)/supply,RTu3sum,100.*RTu3sum/supply);
printf("num2.%d num4.%d num8.%d num16.%d / num17500.%d -> %.2f%% %.2f%% %.2f%% %.2f%% [%.3f %.3f %.3f %.3f] %.3f ave %.8f\n",num2,num4,num8,num16,num17500,100.*(double)num2/num17500,100.*(double)num4/num17500,100.*(double)num8/num17500,100.*(double)num16/num17500,(100.*(double)num2/num17500)/2.75,(100.*(double)num4/num17500)/2.75,(100.*(double)num8/num17500)/4.5,(100.*(double)num16/num17500)/14,(100.*(double)(num2+num4+num8+num16)/num17500)/24,avestakedsize/numstaked);
}
return(clonestr("{\"result\":\"success\"}"));
}
void LP_privkey_updates(void *ctx,int32_t pubsock,char *passphrase) void LP_privkey_updates(void *ctx,int32_t pubsock,char *passphrase)
{ {
struct iguana_info *coin,*tmp; bits256 pubkey,privkey; uint8_t pubkey33[33]; int32_t initonly; struct iguana_info *coin,*tmp; bits256 pubkey,privkey; uint8_t pubkey33[33]; int32_t initonly;
@ -431,8 +630,10 @@ void LP_privkey_updates(void *ctx,int32_t pubsock,char *passphrase)
coin->counter = 0; coin->counter = 0;
memset(coin->smartaddr,0,sizeof(coin->smartaddr)); memset(coin->smartaddr,0,sizeof(coin->smartaddr));
if ( bits256_nonz(privkey) == 0 || coin->smartaddr[0] == 0 ) if ( bits256_nonz(privkey) == 0 || coin->smartaddr[0] == 0 )
{
privkey = LP_privkeycalc(ctx,pubkey33,&pubkey,coin,passphrase,""); privkey = LP_privkeycalc(ctx,pubkey33,&pubkey,coin,passphrase,"");
} }
}
//printf("i.%d of %d\n",i,LP_numcoins); //printf("i.%d of %d\n",i,LP_numcoins);
else if ( IAMLP == 0 || coin->inactive == 0 ) else if ( IAMLP == 0 || coin->inactive == 0 )
{ {

3
iguana/exchanges/LP_rpc.c

@ -750,6 +750,8 @@ again:
} }
if ( strcmp(coin->estimatefeestr,"estimatesmartfee") == 0 && (rate= jdouble(errjson,"feerate")) != 0 ) if ( strcmp(coin->estimatefeestr,"estimatesmartfee") == 0 && (rate= jdouble(errjson,"feerate")) != 0 )
{ {
static uint32_t counter;
if ( counter++ < 10 )
printf("extracted feerate %.8f from estimatesmartfee\n",rate); printf("extracted feerate %.8f from estimatesmartfee\n",rate);
rate /= 1024.; rate /= 1024.;
} }
@ -1030,6 +1032,7 @@ uint32_t LP_heighttime(char *symbol,int32_t height)
cJSON *LP_blockjson(int32_t *heightp,char *symbol,char *blockhashstr,int32_t height) cJSON *LP_blockjson(int32_t *heightp,char *symbol,char *blockhashstr,int32_t height)
{ {
cJSON *json = 0; int32_t flag = 0; struct iguana_info *coin; cJSON *json = 0; int32_t flag = 0; struct iguana_info *coin;
*heightp = 0;
if ( symbol == 0 || symbol[0] == 0 ) if ( symbol == 0 || symbol[0] == 0 )
return(cJSON_Parse("{\"error\":\"null symbol\"}")); return(cJSON_Parse("{\"error\":\"null symbol\"}"));
coin = LP_coinfind(symbol); coin = LP_coinfind(symbol);

7
iguana/exchanges/LP_scan.c

@ -23,7 +23,7 @@ int32_t LP_blockinit(struct iguana_info *coin,int32_t height)
{ {
int32_t i,iter,numtx,checkht=-1; cJSON *blockobj,*txs,*txobj; bits256 txid; struct LP_transaction *tx; int32_t i,iter,numtx,checkht=-1; cJSON *blockobj,*txs,*txobj; bits256 txid; struct LP_transaction *tx;
portable_mutex_lock(&LP_blockinit_mutex); portable_mutex_lock(&LP_blockinit_mutex);
if ( (blockobj= LP_blockjson(&checkht,coin->symbol,0,height)) != 0 && checkht == height ) if ( (blockobj= LP_blockjson(&checkht,coin->symbol,0,height)) != 0 && (checkht == 0 || checkht == height) )
{ {
if ( (txs= jarray(&numtx,blockobj,"tx")) != 0 ) if ( (txs= jarray(&numtx,blockobj,"tx")) != 0 )
{ {
@ -54,9 +54,10 @@ int32_t LP_blockinit(struct iguana_info *coin,int32_t height)
free_json(blockobj); free_json(blockobj);
} }
portable_mutex_unlock(&LP_blockinit_mutex); portable_mutex_unlock(&LP_blockinit_mutex);
if ( checkht == height ) if ( checkht == 0 || checkht == height )
return(0); return(0);
else return(-1); printf("%s blockinit error checkht.%d vs height.%d\n",ASSETCHAINS_SYMBOL,checkht,height);
return(-1);
} }
int32_t LP_scanblockchain(struct iguana_info *coin,int32_t startheight,int32_t endheight) int32_t LP_scanblockchain(struct iguana_info *coin,int32_t startheight,int32_t endheight)

2
iguana/exchanges/LP_secp.c

@ -97,7 +97,7 @@ int32_t bitcoin_sign(void *ctx,char *symbol,uint8_t *sig,bits256 txhash2,bits256
printf("bitcoin_sign illegal privkey\n"); printf("bitcoin_sign illegal privkey\n");
return(-1); return(-1);
} }
if ( strcmp(symbol,"BCH") == 0 || strcmp(symbol,"BTG") == 0 ) if ( strcmp(symbol,"BCH") == 0 || strcmp(symbol,"BTG") == 0 || strcmp(symbol,"CMM") == 0 )
{ {
//char str[65]; printf("BCH/BTG deterministic signature %s\n",bits256_str(str,txhash2)); //char str[65]; printf("BCH/BTG deterministic signature %s\n",bits256_str(str,txhash2));
funcp = 0; funcp = 0;

7
iguana/exchanges/LP_signatures.c

@ -721,9 +721,12 @@ void LP_query(void *ctx,char *myipaddr,int32_t mypubsock,char *method,struct LP_
if ( IPC_ENDPOINT >= 0 ) if ( IPC_ENDPOINT >= 0 )
LP_queuecommand(0,msg,IPC_ENDPOINT,-1,0); LP_queuecommand(0,msg,IPC_ENDPOINT,-1,0);
memset(&zero,0,sizeof(zero)); memset(&zero,0,sizeof(zero));
if ( bits256_nonz(qp->srchash) != 0 )
LP_reserved_msg(1,qp->srccoin,qp->destcoin,qp->srchash,clonestr(msg));
LP_reserved_msg(1,qp->srccoin,qp->destcoin,zero,clonestr(msg)); LP_reserved_msg(1,qp->srccoin,qp->destcoin,zero,clonestr(msg));
//if ( bits256_nonz(qp->srchash) != 0 )
{
sleep(1);
LP_reserved_msg(1,qp->srccoin,qp->destcoin,qp->srchash,clonestr(msg));
}
free(msg); free(msg);
} }

2
iguana/exchanges/LP_swap.c

@ -897,7 +897,7 @@ void LP_bobloop(void *_swap)
} }
} }
LP_unavailableset(swap->bobpayment.utxotxid,swap->bobpayment.utxovout,(uint32_t)time(NULL)+60,swap->I.otherhash); LP_unavailableset(swap->bobpayment.utxotxid,swap->bobpayment.utxovout,(uint32_t)time(NULL)+60,swap->I.otherhash);
if ( error == 0 && LP_waitfor(swap->N.pair,swap,alicewaittimeout,LP_verify_alicepayment) < 0 ) if ( error == 0 && LP_waitfor(swap->N.pair,swap,bobwaittimeout + alicewaittimeout,LP_verify_alicepayment) < 0 )
{ {
error = 1; error = 1;
err = -2006, printf("error waiting for alicepayment\n"); err = -2006, printf("error waiting for alicepayment\n");

116
iguana/exchanges/LP_transaction.c

@ -427,7 +427,7 @@ int32_t bitcoin_verifyvins(void *ctx,char *symbol,uint8_t taddr,uint8_t pubtype,
vpnstr[0] = 0; vpnstr[0] = 0;
*signedtx = 0; *signedtx = 0;
memset(signedtxidp,0,sizeof(*signedtxidp)); memset(signedtxidp,0,sizeof(*signedtxidp));
//printf("bitcoin_verifyvins numvins.%d numvouts.%d signtx.%d privkey.%d M.%d N.%d\n",msgtx->tx_in,numvouts,signtx,bits256_nonz(V[0].signers[0].privkey),V[0].M,V[0].N); //printf("bitcoin_verifyvins suppress.%d numvins.%d numvouts.%d signtx.%d privkey.%d M.%d N.%d\n",suppress_pubkeys,msgtx->tx_in,numvouts,signtx,bits256_nonz(V[0].signers[0].privkey),V[0].M,V[0].N);
for (vini=0; vini<msgtx->tx_in; vini++) for (vini=0; vini<msgtx->tx_in; vini++)
{ {
if ( V->p2shscript[0] != 0 && V->p2shlen != 0 ) if ( V->p2shscript[0] != 0 && V->p2shlen != 0 )
@ -1073,7 +1073,7 @@ int32_t LP_vins_select(void *ctx,struct iguana_info *coin,int64_t *totalp,int64_
if ( utxovout == up->U.vout && bits256_cmp(utxotxid,up->U.txid) == 0 ) if ( utxovout == up->U.vout && bits256_cmp(utxotxid,up->U.txid) == 0 )
{ {
preselected[numpre++] = up; preselected[numpre++] = up;
printf("found utxotxid in slot.%d\n",j); //printf("found utxotxid in slot.%d\n",j);
utxos[j] = 0; utxos[j] = 0;
continue; continue;
} }
@ -1117,7 +1117,7 @@ int32_t LP_vins_select(void *ctx,struct iguana_info *coin,int64_t *totalp,int64_
preselected[numpre++] = up; preselected[numpre++] = up;
else else
{ {
printf("couldnt add address_utxo after not finding\n"); printf("couldnt add address_utxo %s/v%d after not finding\n",bits256_str(str,utxotxid),utxovout);
sleep(1); sleep(1);
value = LP_txvalue(0,coin->symbol,utxotxid,utxovout); value = LP_txvalue(0,coin->symbol,utxotxid,utxovout);
LP_address_utxoadd(0,(uint32_t)time(NULL),"withdraw",coin,coin->smartaddr,utxotxid,utxovout,value,1,-1); LP_address_utxoadd(0,(uint32_t)time(NULL),"withdraw",coin,coin->smartaddr,utxotxid,utxovout,value,1,-1);
@ -1205,7 +1205,7 @@ int32_t LP_vins_select(void *ctx,struct iguana_info *coin,int64_t *totalp,int64_
char str[65]; printf("%s/%d %.8f hodl interest %.8f -> sum %.8f\n",bits256_str(str,up->U.txid),up->U.vout,dstr(up->U.value),dstr(interest),dstr(interestsum)); char str[65]; printf("%s/%d %.8f hodl interest %.8f -> sum %.8f\n",bits256_str(str,up->U.txid),up->U.vout,dstr(up->U.value),dstr(interest),dstr(interestsum));
} }
} }
printf("numunspents.%d vini.%d value %.8f, total %.8f remains %.8f interest %.8f sum %.8f %s/v%d\n",numunspents,n,dstr(up->U.value),dstr(total),dstr(remains),dstr(interest),dstr(interestsum),bits256_str(str,up->U.txid),up->U.vout); //printf("suppress.%d numunspents.%d vini.%d value %.8f, total %.8f remains %.8f interest %.8f sum %.8f %s/v%d\n",suppress_pubkeys,numunspents,n,dstr(up->U.value),dstr(total),dstr(remains),dstr(interest),dstr(interestsum),bits256_str(str,up->U.txid),up->U.vout);
vp = &V[n++]; vp = &V[n++];
vp->N = vp->M = 1; vp->N = vp->M = 1;
vp->signers[0].privkey = privkey; vp->signers[0].privkey = privkey;
@ -1227,7 +1227,7 @@ int32_t LP_vins_select(void *ctx,struct iguana_info *coin,int64_t *totalp,int64_
return(n); return(n);
} }
char *LP_createrawtransaction(cJSON **txobjp,int32_t *numvinsp,struct iguana_info *coin,struct vin_info *V,int32_t max,bits256 privkey,cJSON *outputs,cJSON *vins,cJSON *privkeys,int64_t txfee,bits256 utxotxid,int32_t utxovout,uint32_t locktime,char *opretstr,char *passphrase) char *LP_createrawtransaction(cJSON **txobjp,int32_t *numvinsp,struct iguana_info *coin,struct vin_info *V,int32_t max,bits256 privkey,cJSON *outputs,cJSON *vins,cJSON *privkeys,int64_t txfee,bits256 utxotxid,int32_t utxovout,int32_t onevin,uint32_t locktime,char *opretstr,char *passphrase)
{ {
static void *ctx; static void *ctx;
cJSON *txobj,*item; uint8_t addrtype,rmd160[20],data[8192+64],script[8192],spendscript[256]; char *coinaddr,*rawtxbytes,*scriptstr; bits256 txid; uint32_t crc32,timestamp; int64_t change=0,adjust=0,total,value,amount = 0; int32_t origspendlen=0,i,offset,len,dustcombine,scriptlen,spendlen,suppress_pubkeys,ignore_cltverr,numvouts=0,numvins=0,numutxos=0; struct LP_address_utxo *utxos[LP_MAXVINS*256]; struct LP_address *ap; cJSON *txobj,*item; uint8_t addrtype,rmd160[20],data[8192+64],script[8192],spendscript[256]; char *coinaddr,*rawtxbytes,*scriptstr; bits256 txid; uint32_t crc32,timestamp; int64_t change=0,adjust=0,total,value,amount = 0; int32_t origspendlen=0,i,offset,len,dustcombine,scriptlen,spendlen,suppress_pubkeys,ignore_cltverr,numvouts=0,numvins=0,numutxos=0; struct LP_address_utxo *utxos[LP_MAXVINS*256]; struct LP_address *ap;
@ -1284,6 +1284,29 @@ char *LP_createrawtransaction(cJSON **txobjp,int32_t *numvinsp,struct iguana_inf
return(0); return(0);
} }
memset(utxos,0,sizeof(utxos)); memset(utxos,0,sizeof(utxos));
//char str[65];
if ( onevin != 0 )
{
if ( (txobj= LP_gettxout(coin->symbol,coin->smartaddr,utxotxid,utxovout)) != 0 )
{
struct LP_address_utxo U;
memset(&U,0,sizeof(U));
utxos[0] = &U;
utxos[0]->U.txid = utxotxid;
utxos[0]->U.vout = utxovout;
utxos[0]->U.value = LP_value_extract(txobj,0,utxotxid);
free_json(txobj);
//char str[65]; printf("add onevin %s/v%d %.8f\n",bits256_str(str,utxotxid),utxovout,dstr(utxos[0]->U.value));
numutxos = 1;
}
else
{
printf("LP_createrawtransaction: onevin spent already\n");
return(0);
}
}
else
{
if ( (numutxos= LP_address_utxo_ptrs(coin,0,utxos,(int32_t)(sizeof(utxos)/sizeof(*utxos)),ap,coin->smartaddr)) <= 0 ) if ( (numutxos= LP_address_utxo_ptrs(coin,0,utxos,(int32_t)(sizeof(utxos)/sizeof(*utxos)),ap,coin->smartaddr)) <= 0 )
{ {
if ( bits256_nonz(utxotxid) == 0 ) if ( bits256_nonz(utxotxid) == 0 )
@ -1292,10 +1315,7 @@ char *LP_createrawtransaction(cJSON **txobjp,int32_t *numvinsp,struct iguana_inf
return(0); return(0);
} }
} }
//char str[65]; }
//for (i=0; i<numutxos; i++)
// printf("utxo.%d %s/v%d %.8f\n",i,bits256_str(str,utxos[i]->U.txid),utxos[i]->U.vout,dstr(utxos[i]->U.value));
ignore_cltverr = 0; ignore_cltverr = 0;
suppress_pubkeys = 1; suppress_pubkeys = 1;
scriptlen = bitcoin_standardspend(script,0,G.LP_myrmd160); scriptlen = bitcoin_standardspend(script,0,G.LP_myrmd160);
@ -1779,7 +1799,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=0,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],wifstr[64],*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 )
{ {
@ -1811,6 +1831,7 @@ char *LP_withdraw(struct iguana_info *coin,cJSON *argjson)
locktime = juint(argjson,"locktime"); locktime = juint(argjson,"locktime");
txfee = juint(argjson,"txfee"); txfee = juint(argjson,"txfee");
autofee = (strcmp(coin->symbol,"BTC") == 0); autofee = (strcmp(coin->symbol,"BTC") == 0);
//printf("LP_withdraw: %s/v%d %s\n",bits256_str(str,utxotxid),utxovout,jprint(outputs,0));
if ( txfee == 0 ) if ( txfee == 0 )
{ {
autofee = 1; autofee = 1;
@ -1832,11 +1853,25 @@ char *LP_withdraw(struct iguana_info *coin,cJSON *argjson)
vins = cJSON_CreateArray(); vins = cJSON_CreateArray();
memset(V,0,sizeof(*V) * maxV); memset(V,0,sizeof(*V) * maxV);
numvins = 0; numvins = 0;
if ( (rawtx= LP_createrawtransaction(&txobj,&numvins,coin,V,maxV,privkey,outputs,vins,privkeys,iter == 0 ? txfee : newtxfee,utxotxid,utxovout,locktime,jstr(argjson,"opreturn"),jstr(argjson,"passphrase"))) != 0 ) if ( (rawtx= LP_createrawtransaction(&txobj,&numvins,coin,V,maxV,privkey,outputs,vins,privkeys,iter == 0 ? txfee : newtxfee,utxotxid,utxovout,jint(argjson,"onevin"),locktime,jstr(argjson,"opreturn"),jstr(argjson,"passphrase"))) != 0 )
{ {
completed = 0; completed = 0;
memset(&msgtx,0,sizeof(msgtx)); memset(&msgtx,0,sizeof(msgtx));
memset(signedtxid.bytes,0,sizeof(signedtxid)); memset(signedtxid.bytes,0,sizeof(signedtxid));
if ( jint(argjson,"onevin") != 0 )
{
V[0].suppress_pubkeys = 1;
bitcoin_priv2wif(coin->symbol,coin->wiftaddr,wifstr,privkey,coin->wiftype);
if ( (signedtx= bitcoin_signrawtransaction(&completed,&signedtxid,coin,rawtx,wifstr)) != 0 && completed == 0 )
{
printf("incomplete signing\n");
free(signedtx);
signedtx = 0;
}
}
else
{
//printf("created V[0].suppress %d\n",V[0].suppress_pubkeys);
if ( (completed= iguana_signrawtransaction(ctx,coin->symbol,coin->wiftaddr,coin->taddr,coin->pubtype,coin->p2shtype,coin->isPoS,coin->longestchain,&msgtx,&signedtx,&signedtxid,V,numvins,rawtx,vins,privkeys,coin->zcash)) < 0 ) if ( (completed= iguana_signrawtransaction(ctx,coin->symbol,coin->wiftaddr,coin->taddr,coin->pubtype,coin->p2shtype,coin->isPoS,coin->longestchain,&msgtx,&signedtx,&signedtxid,V,numvins,rawtx,vins,privkeys,coin->zcash)) < 0 )
printf("couldnt sign withdraw %s\n",bits256_str(str,signedtxid)); printf("couldnt sign withdraw %s\n",bits256_str(str,signedtxid));
else if ( completed == 0 ) else if ( completed == 0 )
@ -1845,6 +1880,7 @@ char *LP_withdraw(struct iguana_info *coin,cJSON *argjson)
if ( signedtx != 0 ) if ( signedtx != 0 )
free(signedtx), signedtx = 0; free(signedtx), signedtx = 0;
} }
}
if ( signedtx == 0 ) if ( signedtx == 0 )
break; break;
datalen = (int32_t)strlen(signedtx) / 2; datalen = (int32_t)strlen(signedtx) / 2;
@ -1950,6 +1986,64 @@ char *LP_autosplit(struct iguana_info *coin)
return(clonestr("{\"error\":\"couldnt autosplit\"}")); return(clonestr("{\"error\":\"couldnt autosplit\"}"));
} }
char *LP_movecoinbases(char *symbol)
{
static bits256 zero; bits256 utxotxid,txid; struct iguana_info *coin; cJSON *retjson,*outputs,*argjson,*txids,*unspents,*item,*gen,*output; int32_t i,n,utxovout; char *retstr,*hexstr;
if ( (coin= LP_coinfind(symbol)) != 0 )
{
if ( coin->electrum == 0 )
{
txids = cJSON_CreateArray();
if ( (unspents= LP_listunspent(symbol,coin->smartaddr,zero,zero)) != 0 )
{
if ( (n= cJSON_GetArraySize(unspents)) > 0 )
{
for (i=0; i<n; i++)
{
item = jitem(unspents,i);
if ( is_cJSON_True(jobj(item,"generated")) != 0 )
{
utxotxid = jbits256(item,"txid");
utxovout = jint(item,"vout");
argjson = cJSON_CreateObject();
outputs = cJSON_CreateArray();
output = cJSON_CreateObject();
jaddnum(output,coin->smartaddr,0.0001);
jaddi(outputs,output);
jadd(argjson,"outputs",outputs);
jaddnum(argjson,"broadcast",1);
jaddstr(argjson,"coin",coin->symbol);
jaddbits256(argjson,"utxotxid",utxotxid);
jaddnum(argjson,"utxovout",utxovout);
jaddnum(argjson,"onevin",1);
if ( (retstr= LP_withdraw(coin,argjson)) != 0 )
{
if ( (retjson= cJSON_Parse(retstr)) != 0 )
{
txid = jbits256(retjson,"txid");
hexstr = jstr(retjson,"hex");
if ( bits256_nonz(txid) != 0 && hexstr != 0 )
{
printf("%s -> %s\n",jprint(item,0),hexstr);
jaddibits256(txids,txid);
}
free_json(retjson);
}
free(retstr);
}
free_json(argjson);
}
}
}
free_json(unspents);
}
return(jprint(txids,1));
}
return(clonestr("{\"error\":\"LP_movecoinbases cant be electrum\"}"));
}
return(clonestr("{\"error\":\"LP_movecoinbases couldnt find coin\"}"));
}
#ifndef NOTETOMIC #ifndef NOTETOMIC
char *LP_eth_withdraw(struct iguana_info *coin,cJSON *argjson) char *LP_eth_withdraw(struct iguana_info *coin,cJSON *argjson)

2
iguana/exchanges/coins

File diff suppressed because one or more lines are too long

3
iguana/exchanges/movecoinbases

@ -0,0 +1,3 @@
#!/bin/bash
source userpass
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"movecoinbases\",\"coin\":\"VRSC\"}"

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 }, {\"coin\":\"utrum\",\"balance\":2100000}],\"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}, {\"coin\":\"verus\",\"balance\":65000}],\"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}"

5
iguana/exchanges/stats.c

@ -33,6 +33,7 @@
char *stats_JSON(void *ctx,int32_t fastflag,char *myipaddr,int32_t mypubsock,cJSON *argjson,char *remoteaddr,uint16_t port); char *stats_JSON(void *ctx,int32_t fastflag,char *myipaddr,int32_t mypubsock,cJSON *argjson,char *remoteaddr,uint16_t port);
void LP_queuecommand(char **retstrp,char *buf,int32_t responsesock,int32_t stats_JSONonly,uint32_t queueid); void LP_queuecommand(char **retstrp,char *buf,int32_t responsesock,int32_t stats_JSONonly,uint32_t queueid);
extern uint32_t DOCKERFLAG; extern uint32_t DOCKERFLAG;
extern char LP_myipaddr[];
char *stats_validmethods[] = char *stats_validmethods[] =
{ {
@ -549,7 +550,7 @@ char *stats_rpcparse(char *retbuf,int32_t bufsize,int32_t *jsonflagp,int32_t *po
//free(buf); //free(buf);
//while ( retstr == 0 ) //while ( retstr == 0 )
// usleep(10000); // usleep(10000);
if ( (retstr= stats_JSON(ctx,0,myipaddr,-1,argjson,remoteaddr,port)) != 0 ) if ( (retstr= stats_JSON(ctx,0,LP_myipaddr,-1,argjson,remoteaddr,port)) != 0 )
{ {
if ( (retitem= cJSON_Parse(retstr)) != 0 ) if ( (retitem= cJSON_Parse(retstr)) != 0 )
jaddi(retarray,retitem); jaddi(retarray,retitem);
@ -598,7 +599,7 @@ char *stats_rpcparse(char *retbuf,int32_t bufsize,int32_t *jsonflagp,int32_t *po
buf = jprint(arg,0); buf = jprint(arg,0);
LP_queuecommand(&retstr,buf,IPC_ENDPOINT,1,queueid); LP_queuecommand(&retstr,buf,IPC_ENDPOINT,1,queueid);
free(buf); free(buf);
} else retstr = stats_JSON(ctx,jint(arg,"fast"),myipaddr,-1,arg,remoteaddr,port); } else retstr = stats_JSON(ctx,jint(arg,"fast"),LP_myipaddr,-1,arg,remoteaddr,port);
#endif #endif
if ( fastflag == 0 ) if ( fastflag == 0 )
portable_mutex_unlock(&LP_commandmutex); portable_mutex_unlock(&LP_commandmutex);

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 }, {\"coin\":\"utrum\",\"balance\":2100000}],\"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\":2350000}, {\"coin\":\"verus\",\"balance\":65000}],\"divisor\":612529}"

10
iguana/iguana_notary.c

@ -360,7 +360,9 @@ THREE_STRINGS_AND_DOUBLE(iguana,dpow,symbol,dest,pubkey,freq)
dp->srcconfirms = DPOW_FIFOSIZE; dp->srcconfirms = DPOW_FIFOSIZE;
if ( strcmp("BTC",dp->dest) == 0 ) if ( strcmp("BTC",dp->dest) == 0 )
{ {
if ( freq == 0 )
dp->freq = DPOW_CHECKPOINTFREQ; dp->freq = DPOW_CHECKPOINTFREQ;
else dp->freq = freq;
dp->minsigs = Notaries_BTCminsigs; //DPOW_MINSIGS; dp->minsigs = Notaries_BTCminsigs; //DPOW_MINSIGS;
} }
else else
@ -428,13 +430,11 @@ THREE_STRINGS_AND_DOUBLE(iguana,dpow,symbol,dest,pubkey,freq)
portable_mutex_init(&dp->paxmutex); portable_mutex_init(&dp->paxmutex);
portable_mutex_init(&dp->dexmutex); portable_mutex_init(&dp->dexmutex);
PAX_init(); PAX_init();
//printf(">>>>>>>>>>>>>>> call paxpending\n"); dp->fullCCid = dpow_CCid(myinfo,src);
//uint8_t buf[32768];
//dpow_paxpending(buf);
myinfo->numdpows++; myinfo->numdpows++;
for (i=0; i<33; i++) for (i=0; i<33; i++)
printf("%02x",dp->minerkey33[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); printf(" DPOW with pubkey.(%s) %s.valid%d %s -> %s %s.valid%d, num.%d freq.%d minsigs.%d CCid.%u\n",tmp,srcaddr,srcvalid,dp->symbol,dp->dest,destaddr,destvalid,myinfo->numdpows,dp->freq,dp->minsigs,dp->fullCCid);
return(clonestr("{\"result\":\"success\"}")); return(clonestr("{\"result\":\"success\"}"));
} }
@ -535,7 +535,7 @@ STRING_ARG(iguana,addnotary,ipaddr)
} }
char NOTARY_CURRENCIES[][65] = { char NOTARY_CURRENCIES[][65] = {
"REVS", "SUPERNET", "DEX", "PANGEA", "JUMBLR", "BET", "CRYPTO", "HODL", "BOTS", "MGW", "COQUI", "WLC", "KV", "CEAL", "MESH", "MNZ", "CHIPS", "MSHARK", "AXO", "ETOMIC", "BTCH", "VOTE2018", "NINJA", "OOT", "CHAIN", "BNTN", "PRLPAY" "REVS", "SUPERNET", "DEX", "PANGEA", "JUMBLR", "BET", "CRYPTO", "HODL", "BOTS", "MGW", "COQUI", "WLC", "KV", "CEAL", "MESH", "MNZ", "CHIPS", "MSHARK", "AXO", "ETOMIC", "BTCH", "VOTE2018", "NINJA", "OOT", "CHAIN", "BNTN", "PRLPAY", "DSEC", "GLXT", "EQL"
}; };
// "LTC", "USD", "EUR", "JPY", "GBP", "AUD", "CAD", "CHF", "NZD", "CNY", "RUB", "MXN", "BRL", "INR", "HKD", "TRY", "ZAR", "PLN", "NOK", "SEK", "DKK", "CZK", "HUF", "ILS", "KRW", "MYR", "PHP", "RON", "SGD", "THB", "BGN", "IDR", "HRK", // "LTC", "USD", "EUR", "JPY", "GBP", "AUD", "CAD", "CHF", "NZD", "CNY", "RUB", "MXN", "BRL", "INR", "HKD", "TRY", "ZAR", "PLN", "NOK", "SEK", "DKK", "CZK", "HUF", "ILS", "KRW", "MYR", "PHP", "RON", "SGD", "THB", "BGN", "IDR", "HRK",

3
iguana/m_notary_run

@ -23,6 +23,7 @@ curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"ad
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\":\"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\":\"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\":\"138.121.203.210\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"139.99.149.41\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"209.58.169.65\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"209.58.169.65\"}"
#tests/addnotarys_7776 #tests/addnotarys_7776
@ -60,6 +61,8 @@ coins/bntn_7776
coins/chain_7776 coins/chain_7776
coins/prlpay_7776 coins/prlpay_7776
coins/dsec_7776 coins/dsec_7776
coins/glxt_7776
coins/eql_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}"

2
iguana/m_splitfund

@ -33,3 +33,5 @@ curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"BNTN\",\"agent\":\"iguana
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"PRLPAY\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"10000\",\"sendflag\":1,\"duplicates\":50}" curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"PRLPAY\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"10000\",\"sendflag\":1,\"duplicates\":50}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"CHAIN\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"10000\",\"sendflag\":1,\"duplicates\":50}" curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"CHAIN\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"10000\",\"sendflag\":1,\"duplicates\":50}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"DSEC\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"10000\",\"sendflag\":1,\"duplicates\":50}" curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"DSEC\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"10000\",\"sendflag\":1,\"duplicates\":50}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"GLXT\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"10000\",\"sendflag\":1,\"duplicates\":50}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"EQL\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"10000\",\"sendflag\":1,\"duplicates\":50}"

2
iguana/mini-gmp.c

@ -4403,7 +4403,7 @@ int32_t bitcoin_base58decode(uint8_t *data,char *coinaddr)
if ( *p != '\0' ) if ( *p != '\0' )
{ {
int32_t zeroval(); int32_t zeroval();
printf("bitcoin_base58decode error: p %02x != 0x00\n",*p); //printf("bitcoin_base58decode error: p %02x != 0x00\n",*p);
mpz_clear(bn), mpz_clear(bn58); mpz_clear(bn), mpz_clear(bn58);
return(-1); return(-1);
} }

Loading…
Cancel
Save