Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/jl777/SuperNET into dev-deck…
Browse files Browse the repository at this point in the history
…er-dev
  • Loading branch information
DeckerSU committed Feb 20, 2018
2 parents 204ba07 + 4d20d4a commit 2d6a7c5
Show file tree
Hide file tree
Showing 38 changed files with 544 additions and 204 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ x64
agents/iguana.exe
Debug/*

iguana/nanomsglib
iguana/nanomsgsrc
OSlibs/linux
OSlibs/osx

iguana/pnacl/Release/iguana_unstripped.pexe

iguana/pnacl/Release/iguana.pexe
Expand Down
2 changes: 1 addition & 1 deletion crypto777/bitcoind_RPC.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ char *post_process_bitcoind_RPC(char *debugstr,char *command,char *rpcstr,char *
char *retstr = 0;
cJSON *json,*result,*error;
#ifdef FROM_MARKETMAKER
//usleep(500);
//usleep(1000);
#endif
//printf("<<<<<<<<<<< bitcoind_RPC: %s post_process_bitcoind_RPC.%s.[%s]\n",debugstr,command,rpcstr);
if ( command == 0 || rpcstr == 0 || rpcstr[0] == 0 )
Expand Down
45 changes: 45 additions & 0 deletions iguana/build_static_nanomsg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

#Check if libnanomsg-static.a file is already exists or not
if [[ "$OSTYPE" == "linux-gnu" ]]; then
echo "Linux"
file="../OSlibs/linux/$(uname -m)/libnanomsg-static.a"
makedir="../OSlibs/linux/$(uname -m)/"
copytarget="../OSlibs/linux/$(uname -m)/libnanomsg-static.a"
elif [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OSX
echo "Mac OSX"
file="../OSlibs/osx/$(uname -m)/libnanomsg-static.a"
makedir="../OSlibs/osx/$(uname -m)/"
copytarget="../OSlibs/osx/$(uname -m)/libnanomsg-static.a"
fi

if [ ! -f "$file" ]
then
echo "$0: File '${file}' not found."
#Download nanomsg library 1.0 stable
rm -rf nanomsgsrc
git clone https://github.com/nanomsg/nanomsg.git nanomsgsrc

#Create destination folder
mkdir nanomsglib

#Switch into nanomsgsrc folder
cd nanomsgsrc

#Create build directory and switch into it
mkdir build && cd build

#Compile
cmake .. -DCMAKE_INSTALL_PREFIX=../../nanomsglib/ -DCMAKE_BUILD_TYPE=Debug -DNN_STATIC_LIB=1
cmake --build .
ctest -C Debug .
cmake --build . --target install

cd ../..
pwd
mkdir -p $makedir
cp -av nanomsglib/lib/libnanomsg.a $copytarget
fi


70 changes: 34 additions & 36 deletions iguana/dpow/dpow_fsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,25 +91,25 @@ int32_t dpow_datahandler(struct supernet_info *myinfo,struct dpow_info *dp,struc
{
//printf("verify (%s) it is properly signed! set ht.%d signedtxid to %s\n",coin->symbol,height,bits256_str(str,txid));
/*if ( channel == DPOW_BTCTXIDCHANNEL )
{
if ( bp->state < 1000 )
{
bp->desttxid = txid;
bp->state = 1000;
dp->destupdated = 0;
dpow_signedtxgen(myinfo,dp,bp->srccoin,bp,bp->bestk,bp->bestmask,myind,DPOW_SIGCHANNEL,0,bp->isratify);
//dpow_sigscheck(myinfo,dp,bp,DPOW_SIGCHANNEL,myind,0);
}
}
else
{
if ( bp->state != 0xffffffff )
{
bp->srctxid = txid;
printf("set state elapsed %d COMPLETED %s.(%s) %s.(%s)\n",(int32_t)(time(NULL) - bp->starttime),dp->symbol,bits256_str(str,bp->desttxid),dp->dest,bits256_str(str2,txid));
bp->state = 0xffffffff;
}
}*/
{
if ( bp->state < 1000 )
{
bp->desttxid = txid;
bp->state = 1000;
dp->destupdated = 0;
dpow_signedtxgen(myinfo,dp,bp->srccoin,bp,bp->bestk,bp->bestmask,myind,DPOW_SIGCHANNEL,0,bp->isratify);
//dpow_sigscheck(myinfo,dp,bp,DPOW_SIGCHANNEL,myind,0);
}
}
else
{
if ( bp->state != 0xffffffff )
{
bp->srctxid = txid;
printf("set state elapsed %d COMPLETED %s.(%s) %s.(%s)\n",(int32_t)(time(NULL) - bp->starttime),dp->symbol,bits256_str(str,bp->desttxid),dp->dest,bits256_str(str2,txid));
bp->state = 0xffffffff;
}
}*/
}
else
{
Expand Down Expand Up @@ -155,6 +155,8 @@ int32_t dpow_checkutxo(struct supernet_info *myinfo,struct dpow_info *dp,struct
return(haveutxo);
}

uint32_t Numallocated;

void dpow_statemachinestart(void *ptr)
{
void **ptrs = ptr;
Expand All @@ -177,6 +179,7 @@ void dpow_statemachinestart(void *ptr)
if ( src == 0 || dest == 0 )
{
printf("null coin ptr? (%s %p or %s %p)\n",dp->symbol,src,dp->dest,dest);
free(ptr);
return;
}
if ( strcmp(src->symbol,"KMD") == 0 )
Expand All @@ -186,6 +189,7 @@ void dpow_statemachinestart(void *ptr)
if ( (bp= dp->blocks[checkpoint.blockhash.height]) == 0 )
{
bp = calloc(1,sizeof(*bp));
Numallocated++;
bp->minsigs = minsigs;
bp->duration = duration;
bp->srccoin = src;
Expand All @@ -200,6 +204,8 @@ void dpow_statemachinestart(void *ptr)
if ( numratified > 64 )
{
fprintf(stderr,"cant ratify more than 64 notaries ratified has %d\n",numratified);
free(ptr);
free_json(ratified);
return;
}
for (i=0; i<numratified; i++)
Expand Down Expand Up @@ -238,24 +244,14 @@ void dpow_statemachinestart(void *ptr)
bp->numratified = numratified;
bp->ratified = ratified;
printf("numratified.%d %s\n",numratified,jprint(ratified,0));
}
else
{
printf("i.%d numratified.%d\n",i,numratified);
free_json(ratified);
}
} else printf("i.%d numratified.%d\n",i,numratified);
}
free_json(ratified);
}
bp->bestk = -1;
dp->blocks[checkpoint.blockhash.height] = bp;
bp->beacon = rand256(0);
vcalc_sha256(0,bp->commit.bytes,bp->beacon.bytes,sizeof(bp->beacon));
/*if ( checkpoint.blockhash.height >= DPOW_FIRSTRATIFY && dp->blocks[checkpoint.blockhash.height - DPOW_FIRSTRATIFY] != 0 )
{
printf("purge %s.%d\n",dp->dest,checkpoint.blockhash.height - DPOW_FIRSTRATIFY);
free(dp->blocks[checkpoint.blockhash.height - DPOW_FIRSTRATIFY]);
dp->blocks[checkpoint.blockhash.height - DPOW_FIRSTRATIFY] = 0;
}*/
}
if ( bp->isratify != 0 && dp->ratifying != 0 )
{
Expand Down Expand Up @@ -336,6 +332,7 @@ void dpow_statemachinestart(void *ptr)
printf("%02x",bp->ratified_pubkeys[0][i]);
printf(" new, cant change notary0\n");
dp->ratifying -= bp->isratify;
free(ptr);
return;
}
//printf(" myind.%d myaddr.(%s %s)\n",myind,srcaddr,destaddr);
Expand All @@ -356,15 +353,15 @@ void dpow_statemachinestart(void *ptr)
if ( dpow_checkutxo(myinfo,dp,bp,bp->destcoin,&ep->dest.prev_hash,&ep->dest.prev_vout,destaddr) < 0 )
{
printf("dont have %s %s utxo, please send funds\n",dp->dest,destaddr);
free(ptr);
dp->ratifying -= bp->isratify;
free(ptr);
return;
}
if ( dpow_checkutxo(myinfo,dp,bp,bp->srccoin,&ep->src.prev_hash,&ep->src.prev_vout,srcaddr) < 0 )
{
printf("dont have %s %s utxo, please send funds\n",dp->symbol,srcaddr);
free(ptr);
dp->ratifying -= bp->isratify;
free(ptr);
return;
}
if ( bp->isratify != 0 )
Expand All @@ -388,6 +385,7 @@ void dpow_statemachinestart(void *ptr)
{
printf("abort %s ht.%d due to new checkpoint.%d\n",dp->symbol,checkpoint.blockhash.height,dp->checkpoint.blockhash.height);
dp->ratifying -= bp->isratify;
free(ptr);
return;
}
sleep(1);
Expand All @@ -396,7 +394,7 @@ void dpow_statemachinestart(void *ptr)
if ( bp->isratify == 0 )
{
//if ( (starttime= checkpoint.timestamp) == 0 )
bp->starttime = starttime;
bp->starttime = starttime;
extralen = dpow_paxpending(extras,&bp->paxwdcrc);
bp->notaries[bp->myind].paxwdcrc = bp->paxwdcrc;
}
Expand Down Expand Up @@ -458,11 +456,11 @@ void dpow_statemachinestart(void *ptr)
break;
}
}
printf("END isratify.%d:%d bestk.%d %llx sigs.%llx state.%x machine ht.%d completed state.%x %s.%s %s.%s recvmask.%llx paxwdcrc.%x %p %p\n",bp->isratify,dp->ratifying,bp->bestk,(long long)bp->bestmask,(long long)(bp->bestk>=0?bp->destsigsmasks[bp->bestk]:0),bp->state,bp->height,bp->state,dp->dest,bits256_str(str,bp->desttxid),dp->symbol,bits256_str(str2,bp->srctxid),(long long)bp->recvmask,bp->paxwdcrc,src,dest);
printf("[%d] END isratify.%d:%d bestk.%d %llx sigs.%llx state.%x machine ht.%d completed state.%x %s.%s %s.%s recvmask.%llx paxwdcrc.%x %p %p\n",Numallocated,bp->isratify,dp->ratifying,bp->bestk,(long long)bp->bestmask,(long long)(bp->bestk>=0?bp->destsigsmasks[bp->bestk]:0),bp->state,bp->height,bp->state,dp->dest,bits256_str(str,bp->desttxid),dp->symbol,bits256_str(str2,bp->srctxid),(long long)bp->recvmask,bp->paxwdcrc,src,dest);
bp->state = 0xffffffff;
dp->lastrecvmask = bp->recvmask;
dp->ratifying -= bp->isratify;
dp->blocks[bp->height] = 0;
// dp->blocks[bp->height] = 0;
free(ptr);
}

2 changes: 1 addition & 1 deletion iguana/dpow/dpow_prices.c
Original file line number Diff line number Diff line change
Expand Up @@ -1839,7 +1839,7 @@ int32_t PAX_idle(struct supernet_info *myinfo)//struct PAX_data *argdp,int32_t i
{
static double lastupdate,lastdayupdate; static uint32_t didinit; static char *userhome; int32_t idlegap = 10;
FILE *fp; long filesize; char fname[512]; double splineval; uint32_t pvals[128],timestamp; int32_t i,datenum,seconds,c; struct tai t; struct PAX_data *dp; uint8_t data[512];
if ( Currencymasks[0] == 0 )
if ( 1 || Currencymasks[0] == 0 ) // disable pax price gatherings
return(0);
if ( time(NULL) > didinit+12*3600 )
{
Expand Down
2 changes: 1 addition & 1 deletion iguana/dpow/dpow_rpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ char *dpow_sendrawtransaction(struct supernet_info *myinfo,struct iguana_info *c
jaddistr(array,signedtx);
paramstr = jprint(array,1);
retstr = bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"sendrawtransaction",paramstr);
printf(">>>>>>>>>>> %s dpow_sendrawtransaction.(%s) -> (%s)\n",coin->symbol,paramstr,retstr);
printf(">>>>>>>>>>> %s dpow_sendrawtransaction (%s)\n",coin->symbol,retstr);
free(paramstr);
return(retstr);
}
Expand Down
43 changes: 30 additions & 13 deletions iguana/exchanges/LP_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ bot_settings(botid, newprice, newvolume)\n\
bot_status(botid)\n\
bot_stop(botid)\n\
bot_pause(botid)\n\
calcaddress(passphrase)\n\
instantdex_deposit(weeks, amount, broadcast=1)\n\
instantdex_claim()\n\
jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\
Expand All @@ -177,14 +178,17 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\
{
char pub33str[67];
G.USERPASS_COUNTER = 1;
retjson = cJSON_CreateObject();
jaddstr(retjson,"userpass",G.USERPASS);
jaddbits256(retjson,"mypubkey",G.LP_mypub25519);
init_hexbytes_noT(pub33str,G.LP_pubsecp,33);
jaddstr(retjson,"pubsecp",pub33str);
jadd(retjson,"coins",LP_coinsjson(LP_showwif));
LP_cmdcount++;
return(jprint(retjson,1));
if ( 0 )
{
retjson = cJSON_CreateObject();
jaddstr(retjson,"userpass",G.USERPASS);
jaddbits256(retjson,"mypubkey",G.LP_mypub25519);
init_hexbytes_noT(pub33str,G.LP_pubsecp,33);
jaddstr(retjson,"pubsecp",pub33str);
jadd(retjson,"coins",LP_coinsjson(LP_showwif));
LP_cmdcount++;
return(jprint(retjson,1));
}
}
// if passphrase api and passphrase is right, ignore userpass, use hass of passphrase
if ( strcmp(method,"passphrase") == 0 && (passphrase= jstr(argjson,"passphrase")) != 0 )
Expand Down Expand Up @@ -300,6 +304,21 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\
{
return(LP_portfolio());
}
else if ( strcmp(method,"calcaddress") == 0 )
{
bits256 privkey,pub; uint8_t pubkey33[33]; char *passphrase,coinaddr[64];
if ( (passphrase= jstr(argjson,"passphrase")) != 0 )
{
conv_NXTpassword(privkey.bytes,pub.bytes,(uint8_t *)passphrase,(int32_t)strlen(passphrase));
privkey.bytes[0] &= 248, privkey.bytes[31] &= 127, privkey.bytes[31] |= 64;
bitcoin_priv2pub(ctx,"KMD",pubkey33,coinaddr,privkey,0,60);
retjson = cJSON_CreateObject();
jaddstr(retjson,"passphrase",passphrase);
jaddstr(retjson,"coinaddr",coinaddr);
jaddbits256(retjson,"privkey",privkey);
return(jprint(retjson,1));
} else return(clonestr("{\"error\":\"need to have passphrase\"}"));
}
else if ( strcmp(method,"statsdisp") == 0 )
{
return(jprint(LP_statslog_disp(juint(argjson,"starttime"),juint(argjson,"endtime"),jstr(argjson,"gui"),jbits256(argjson,"pubkey"),jstr(argjson,"base"),jstr(argjson,"rel")),1));
Expand All @@ -324,7 +343,7 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\
return(basilisk_swapentries(coin,0,jint(argjson,"limit")));
else if ( base[0] != 0 && rel[0] != 0 )
return(basilisk_swapentries(base,rel,jint(argjson,"limit")));
else return(basilisk_swaplist(0,0,0,jint(argjson,"pending")));
else return(basilisk_swaplist(0,0,1,jint(argjson,"pending")));
}
else if ( strcmp(method,"dynamictrust") == 0 )
{
Expand Down Expand Up @@ -426,7 +445,7 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\
//*
if ( (ptr= LP_coinsearch(coin)) != 0 )
{
if ( ptr->userpass[0] == 0 )
if ( ptr->userpass[0] == 0 && strcmp(ptr->symbol,"ETH") != 0 )
{
cJSON *retjson = cJSON_CreateObject();
jaddstr(retjson,"error",LP_DONTCHANGE_ERRMSG0);
Expand All @@ -437,7 +456,7 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\
{
ptr->inactive = 0;
cJSON *array; int32_t notarized;
if ( LP_getheight(&notarized,ptr) <= 0 )
if ( strcmp(ptr->symbol,"ETH") != 0 && LP_getheight(&notarized,ptr) <= 0 )
{
ptr->inactive = (uint32_t)time(NULL);
return(clonestr("{\"error\":\"coin cant be activated till synced\"}"));
Expand All @@ -450,8 +469,6 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\
if ( strcmp(ptr->symbol,"KMD") == 0 )
LP_importaddress("KMD",BOTS_BONDADDRESS);
}
if ( 0 && strcmp(coin,"BCH") == 0 )
test_validate(ptr,"010000000110b365ea6b8a9f2d56dc12de868e382dc787b2e29355f9b357dcf764c5e29cb1010000006b483045022100c605b993f1db5f31046ebb9065bea0a047f478342bbad8fcfc6af81d05236bd502206e9993a737a8814b935b5e522e750c915e7d37e3bd8367f087d4510f66acac47412102ebc786cb83de8dc3922ab83c21f3f8a2f3216940c3bf9da43ce39e2a3a882c92ffffffff014bc22900000000001976a91459fdba29ea85c65ad90f6d38f7a6646476b26b1688ac00000000");
array = cJSON_CreateArray();
jaddi(array,LP_coinjson(ptr,0));
return(jprint(array,1));
Expand Down
6 changes: 4 additions & 2 deletions iguana/exchanges/LP_include.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#define LP_INCLUDE_H

#ifndef LP_TECHSUPPORT
#define LP_TECHSUPPORT 0
#define LP_TECHSUPPORT 1
#endif

#define LP_DONT_CMDCHANNEL
Expand All @@ -35,7 +35,7 @@ voind dontprintf(char *formatstr,...) {}

#define LP_MAJOR_VERSION "0"
#define LP_MINOR_VERSION "1"
#define LP_BUILD_NUMBER "17763"
#define LP_BUILD_NUMBER "17770"
#define LP_BARTERDEX_VERSION 1
#define LP_MAGICBITS 1

Expand Down Expand Up @@ -510,6 +510,7 @@ cJSON *LP_myzdebits();
int32_t _LP_utxos_remove(bits256 txid,int32_t vout);
int32_t LP_utxos_remove(bits256 txid,int32_t vout);
struct LP_transaction *LP_transactionadd(struct iguana_info *coin,bits256 txid,int32_t height,int32_t numvouts,int32_t numvins);
char *bitcoin_address(char *symbol,char *coinaddr,uint8_t taddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160,int32_t len);
void LP_tradebot_finished(uint32_t tradeid,uint32_t requestid,uint32_t quoteid);
uint64_t LP_txfeecalc(struct iguana_info *coin,uint64_t txfee,int32_t txlen);
struct LP_address *_LP_address(struct iguana_info *coin,char *coinaddr);
Expand Down Expand Up @@ -547,6 +548,7 @@ int32_t LP_listunspent_both(char *symbol,char *coinaddr,int32_t fullflag);
uint16_t LP_randpeer(char *destip);
void LP_tradebot_pauseall();
void LP_portfolio_reset();
int32_t bitcoin_addr2rmd160(char *symbol,uint8_t taddr,uint8_t *addrtypep,uint8_t rmd160[20],char *coinaddr);
struct LP_pubkey_info *LP_pubkeyadd(bits256 pubkey);
uint32_t LP_atomic_locktime(char *base,char *rel);
struct LP_pubkey_info *LP_pubkeyfind(bits256 pubkey);
Expand Down
Loading

0 comments on commit 2d6a7c5

Please sign in to comment.