From 39bd78b7a5646c2ac0bd6de97f39ea256cb5a872 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 25 Jun 2016 08:21:47 -0300 Subject: [PATCH] test --- datachain/datachain.c | 2 -- gecko/gecko_miner.c | 4 ++-- iguana/SuperNET_keys.c | 19 +++++++++---------- iguana/iguana_wallet.c | 4 ++-- iguana/main.c | 2 +- includes/iguana_funcs.h | 2 +- 6 files changed, 15 insertions(+), 18 deletions(-) diff --git a/datachain/datachain.c b/datachain/datachain.c index 7550689b8..06db691eb 100755 --- a/datachain/datachain.c +++ b/datachain/datachain.c @@ -304,7 +304,6 @@ int32_t iguana_opreturn(struct supernet_info *myinfo,int32_t ordered,struct igua void datachain_update_spend(struct supernet_info *myinfo,int32_t ordered,struct iguana_info *coin,uint32_t timestamp,struct iguana_bundle *bp,int32_t height,bits256 txid,int32_t vout,uint8_t rmd160[20],int64_t value) { - return; if ( strcmp("BTC",coin->symbol) == 0 ) datachain_update_txidvout(myinfo,ordered,coin,&myinfo->dPoW.BTC,DATACHAIN_ISBTC,height,txid,vout,rmd160,value); else if ( strcmp("BTCD",coin->symbol) == 0 ) @@ -314,7 +313,6 @@ void datachain_update_spend(struct supernet_info *myinfo,int32_t ordered,struct int64_t datachain_update(struct supernet_info *myinfo,int32_t ordered,struct iguana_info *coin,uint32_t timestamp,struct iguana_bundle *bp,uint8_t rmd160[20],int64_t crypto777_payment,uint8_t type,int32_t height,uint64_t hdrsi_unspentind,int64_t value,uint32_t fileid,uint64_t scriptpos,int32_t scriptlen,bits256 txid,int32_t vout) { - return(0); if ( memcmp(rmd160,CRYPTO777_RMD160,20) == 0 ) crypto777_payment += value; else if ( crypto777_payment != 0 && (type == IGUANA_SCRIPT_OPRETURN || type == IGUANA_SCRIPT_3of3 || type == IGUANA_SCRIPT_2of2 || type == IGUANA_SCRIPT_1of1) ) diff --git a/gecko/gecko_miner.c b/gecko/gecko_miner.c index b61d84ed7..91b202cdc 100755 --- a/gecko/gecko_miner.c +++ b/gecko/gecko_miner.c @@ -331,12 +331,12 @@ int32_t gecko_blocksubmit(struct supernet_info *myinfo,struct iguana_info *btcd, void gecko_miner(struct supernet_info *myinfo,struct iguana_info *btcd,struct iguana_info *virt,int32_t maxmillis,uint8_t *minerpubkey33) { struct iguana_zblock newblock; uint32_t prevtimestamp,nBits; int64_t reward = 0; int32_t i,gap,txn_count; char *blockstr,*space[256]; struct gecko_memtx **txptrs; void *ptr; //struct iguana_bundle *bp; - if ( virt->virtualchain == 0 )//|| myinfo->RELAYID < 0 || myinfo->numrelays < 1 ) + if ( virt->virtualchain == 0 || myinfo->RELAYID < 0 || myinfo->numrelays < 1 ) { printf("skip non-virtual chain.%s\n",virt->symbol); return; } - if ( 0 && (virt->blocks.hwmchain.height % myinfo->numrelays) != myinfo->RELAYID ) + if ( (virt->blocks.hwmchain.height % myinfo->numrelays) != myinfo->RELAYID ) { if ( myinfo->numrelays < 3 ) return; diff --git a/iguana/SuperNET_keys.c b/iguana/SuperNET_keys.c index a637849ad..de533e3ef 100755 --- a/iguana/SuperNET_keys.c +++ b/iguana/SuperNET_keys.c @@ -126,7 +126,7 @@ bits256 SuperNET_linehash(char *_line) return(hash); } -int32_t SuperNET_savejsonfile(char *finalfname,bits256 privkey,bits256 destpubkey,cJSON *json) +int32_t SuperNET_savejsonfile(struct supernet_info *myinfo,char *finalfname,bits256 privkey,bits256 destpubkey,cJSON *json) { char *confstr,*ciphered; char destfname[1024]; FILE *fp; int32_t retval = -1; strcpy(destfname,finalfname); @@ -135,10 +135,9 @@ int32_t SuperNET_savejsonfile(char *finalfname,bits256 privkey,bits256 destpubke confstr = jprint(json,0); if ( bits256_nonz(privkey) != 0 && bits256_cmp(privkey,GENESIS_PUBKEY) != 0 ) { - //sprintf(fname,"confs/iguana.%llu",(long long)wallet2shared.txid); if ( (ciphered= SuperNET_cipher(0,0,json,0,privkey,destpubkey,confstr)) != 0 ) { - //printf("ciphered.save (%s) <- (%s)\n",fname,confstr); + printf("ciphered.save (%s) <- (%s)\n",destfname,confstr); if ( (fp= fopen(destfname,"wb")) != 0 ) { if ( fwrite(ciphered,1,strlen(ciphered)+1,fp) == strlen(ciphered)+1 ) @@ -150,8 +149,7 @@ int32_t SuperNET_savejsonfile(char *finalfname,bits256 privkey,bits256 destpubke } else { - //sprintf(fname,"confs/iguana.conf"); - //printf("save (%s) <- (%s)\n",destfname,confstr); + printf("save (%s) <- (%s)\n",destfname,confstr); if ( (fp= fopen(destfname,"wb")) != 0 ) { if ( fwrite(confstr,1,strlen(confstr)+1,fp) == strlen(confstr)+1 ) @@ -163,7 +161,7 @@ int32_t SuperNET_savejsonfile(char *finalfname,bits256 privkey,bits256 destpubke if ( retval == 0 && strcmp(destfname,finalfname) != 0 ) { char oldfname[1024]; int64_t fsize,dsize; - if ( (fsize= OS_filesize(finalfname)) >= (dsize= OS_filesize(destfname)) ) + if ( (fsize= OS_filesize(finalfname)) > (dsize= OS_filesize(destfname)) ) printf("skip replacing (%s) since new one is smaller %lld vs %lld\n",finalfname,(long long)fsize,(long long)dsize); else { @@ -172,6 +170,7 @@ int32_t SuperNET_savejsonfile(char *finalfname,bits256 privkey,bits256 destpubke OS_renamefile(destfname,finalfname); } } + myinfo->dirty = 0; return(retval); } @@ -255,7 +254,7 @@ cJSON *SuperNET_decryptedjson(char *destfname,char *passphrase,int32_t passsize, return(msgjson); } -int32_t _SuperNET_encryptjson(char *destfname,char *passphrase,int32_t passsize,char *fname2fa,int32_t fnamesize,cJSON *argjson) +int32_t _SuperNET_encryptjson(struct supernet_info *myinfo,char *destfname,char *passphrase,int32_t passsize,char *fname2fa,int32_t fnamesize,cJSON *argjson) { bits256 wallethash,wallet2priv,wallet2shared,wallet2pub; char str[65]; wallethash = wallet2priv = GENESIS_PRIVKEY; @@ -270,7 +269,7 @@ int32_t _SuperNET_encryptjson(char *destfname,char *passphrase,int32_t passsize, sprintf(destfname,"confs/%s",bits256_str(str,wallet2pub)); //printf("SAVE ARGJSON.(%s) [%s, %s] -> destfname.(%s)\n",jprint(argjson,0),passphrase,fname2fa,destfname); //printf("shared.%llx -> pub.%s\n",(long long)wallet2shared.txid,bits256_str(str,wallet2pub)); - SuperNET_savejsonfile(destfname,wallethash,wallet2pub,argjson); + SuperNET_savejsonfile(myinfo,destfname,wallethash,wallet2pub,argjson); return(0); } @@ -355,7 +354,7 @@ char *SuperNET_keysinit(struct supernet_info *myinfo,char *argjsonstr) OS_randombytes((void *)&r,sizeof(r)); jadd64bits(json,"rand",r); //printf("call SuperNET_encryptjson\n"); - _SuperNET_encryptjson(destfname,passphrase,sizeof(passphrase),fname2fa,sizeof(fname2fa),json); + _SuperNET_encryptjson(myinfo,destfname,passphrase,sizeof(passphrase),fname2fa,sizeof(fname2fa),json); //printf("save.(%s)\n",jprint(json,0)); free_json(json); } @@ -423,7 +422,7 @@ THREE_STRINGS(SuperNET,encryptjson,password,permanentfile,payload) jdelete(argjson,"permanentfile"); jdelete(argjson,"timestamp"); jdelete(argjson,"tag"); - if ( _SuperNET_encryptjson(destfname,pass,sizeof(pass),fname2,sizeof(fname2),argjson) == 0 ) + if ( _SuperNET_encryptjson(myinfo,destfname,pass,sizeof(pass),fname2,sizeof(fname2),argjson) == 0 ) { jaddstr(retjson,"result","success"); jaddstr(retjson,"filename",destfname); diff --git a/iguana/iguana_wallet.c b/iguana/iguana_wallet.c index fd3a7fdea..cf3c62767 100755 --- a/iguana/iguana_wallet.c +++ b/iguana/iguana_wallet.c @@ -402,7 +402,7 @@ int32_t iguana_loginsave(struct supernet_info *myinfo,struct iguana_info *coin,c { if ( (passphrase= jstr(loginjson,"passphrase")) != 0 ) { - _SuperNET_encryptjson(destfname,passphrase,0,myinfo->permanentfile,0,loginjson); + _SuperNET_encryptjson(myinfo,destfname,passphrase,0,myinfo->permanentfile,0,loginjson); //printf("loginsave.(%s) <= (%s)\n",destfname,newstr); //iguana_walletlock(myinfo); } @@ -1103,7 +1103,7 @@ FOUR_STRINGS(bitcoinrpc,walletpassphrasechange,oldpassword,newpassword,oldperman { if ( (passphrase= jstr(loginjson,"passphrase")) != 0 ) { - _SuperNET_encryptjson(destfname,passphrase,0,newpermanentfile,0,loginjson); + _SuperNET_encryptjson(myinfo,destfname,passphrase,0,newpermanentfile,0,loginjson); //iguana_walletlock(myinfo); retstr = SuperNET_login(IGUANA_CALLARGS,myinfo->handle,newpassword,newpermanentfile,0); } diff --git a/iguana/main.c b/iguana/main.c index 3e36ca1a7..758e3abf5 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -2270,7 +2270,7 @@ FOUR_STRINGS(SuperNET,login,handle,password,permanentfile,passphrase) myinfo->dirty = (uint32_t)time(NULL); } jaddstr(argjson,"passphrase",passphrase); - if ( (str= SuperNET_encryptjson(myinfo,coin,argjson,remoteaddr,password,myinfo->permanentfile,"")) != 0 ) + if ( (str= SuperNET_encryptjson(myinfo,coin,argjson,remoteaddr,password,myinfo->permanentfile,myinfo->decryptstr == 0 ? "" : myinfo->decryptstr)) != 0 ) free(str); myinfo->expiration = (uint32_t)(time(NULL) + 3600); return(SuperNET_activehandle(IGUANA_CALLARGS)); diff --git a/includes/iguana_funcs.h b/includes/iguana_funcs.h index e635eb320..818366bd5 100755 --- a/includes/iguana_funcs.h +++ b/includes/iguana_funcs.h @@ -365,7 +365,7 @@ int32_t iguana_peerslotinit(struct iguana_info *coin,struct iguana_peer *addr,in void iguana_blockunmark(struct iguana_info *coin,struct iguana_block *block,struct iguana_bundle *bp,int32_t i,int32_t deletefile); int32_t iguana_reqblocks(struct iguana_info *coin); void iguana_walletlock(struct supernet_info *myinfo,struct iguana_info *coin); -int32_t _SuperNET_encryptjson(char *destfname,char *passphrase,int32_t passsize,char *fname2fa,int32_t fnamesize,cJSON *argjson); +int32_t _SuperNET_encryptjson(struct supernet_info *myinfo,char *destfname,char *passphrase,int32_t passsize,char *fname2fa,int32_t fnamesize,cJSON *argjson); int32_t bitcoin_pubkeylen(const uint8_t *pubkey); struct iguana_block *iguana_bundleblock(struct iguana_info *coin,bits256 *hash2p,struct iguana_bundle *bp,int32_t i); void *iguana_ramchainfile(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_ramchain *dest,struct iguana_ramchain *R,struct iguana_bundle *bp,int32_t bundlei,struct iguana_block *block);