diff --git a/iguana/exchanges/LP_coins.c b/iguana/exchanges/LP_coins.c index 7b6c28667..954e37869 100644 --- a/iguana/exchanges/LP_coins.c +++ b/iguana/exchanges/LP_coins.c @@ -54,9 +54,9 @@ char *parse_conf_line(char *line,char *field) return(clonestr(line)); } -void LP_userpassfp(char *symbol,char *username,char *password,FILE *fp) +uint16_t LP_userpassfp(char *symbol,char *username,char *password,FILE *fp) { - char *rpcuser,*rpcpassword,*str,line[8192]; + char *rpcuser,*rpcpassword,*str,line[8192]; uint16_t port = 0; rpcuser = rpcpassword = 0; username[0] = password[0] = 0; while ( fgets(line,sizeof(line),fp) != 0 ) @@ -68,6 +68,16 @@ void LP_userpassfp(char *symbol,char *username,char *password,FILE *fp) rpcuser = parse_conf_line(str,(char *)"rpcuser"); else if ( (str= strstr(line,(char *)"rpcpassword")) != 0 ) rpcpassword = parse_conf_line(str,(char *)"rpcpassword"); + else if ( (str= strstr(line,(char *)"rpcport")) != 0 ) + { + str = parse_conf_line(str,(char *)"rpcport"); + if ( str != 0 ) + { + port = atoi(str); + //printf("RPCPORT.%u\n",port); + free(str); + } + } } if ( rpcuser != 0 && rpcpassword != 0 ) { @@ -79,6 +89,7 @@ void LP_userpassfp(char *symbol,char *username,char *password,FILE *fp) free(rpcuser); if ( rpcpassword != 0 ) free(rpcpassword); + return(port); } void LP_statefname(char *fname,char *symbol,char *assetname,char *str,char *name,char *confpath) @@ -143,9 +154,9 @@ void LP_statefname(char *fname,char *symbol,char *assetname,char *str,char *name strcat(fname,str); } -int32_t LP_userpass(char *userpass,char *symbol,char *assetname,char *confroot,char *name,char *confpath) +uint16_t LP_userpass(char *userpass,char *symbol,char *assetname,char *confroot,char *name,char *confpath,uint16_t origport) { - FILE *fp; char fname[512],username[512],password[512],confname[512]; + FILE *fp; char fname[512],username[512],password[512],confname[512]; uint16_t port = 0; userpass[0] = 0; sprintf(confname,"%s.conf",confroot); if ( 0 ) @@ -160,14 +171,15 @@ int32_t LP_userpass(char *userpass,char *symbol,char *assetname,char *confroot,c LP_statefname(fname,symbol,assetname,confname,name,confpath); if ( (fp= fopen(fname,"rb")) != 0 ) { - LP_userpassfp(symbol,username,password,fp); + if ( (port= LP_userpassfp(symbol,username,password,fp)) == 0 ) + port = origport; sprintf(userpass,"%s:%s",username,password); fclose(fp); if ( 0 ) printf("LP_statefname.(%s) <- %s %s %s (%s) (%s)\n",fname,name,symbol,assetname,userpass,confpath); - return((int32_t)strlen(userpass)); + return(port); } else printf("cant open.(%s)\n",fname); - return(-1); + return(0); } cJSON *LP_coinjson(struct iguana_info *coin,int32_t showwif) @@ -269,12 +281,11 @@ struct iguana_info *LP_coinadd(struct iguana_info *cdata) return(coin); } -int32_t LP_coininit(struct iguana_info *coin,char *symbol,char *name,char *assetname,int32_t isPoS,uint16_t port,uint8_t pubtype,uint8_t p2shtype,uint8_t wiftype,uint64_t txfee,double estimatedrate,int32_t longestchain,uint8_t wiftaddr,uint8_t taddr,uint16_t busport,char *confpath) +uint16_t LP_coininit(struct iguana_info *coin,char *symbol,char *name,char *assetname,int32_t isPoS,uint16_t port,uint8_t pubtype,uint8_t p2shtype,uint8_t wiftype,uint64_t txfee,double estimatedrate,int32_t longestchain,uint8_t wiftaddr,uint8_t taddr,uint16_t busport,char *confpath) { char *name2; memset(coin,0,sizeof(*coin)); safecopy(coin->symbol,symbol,sizeof(coin->symbol)); - sprintf(coin->serverport,"127.0.0.1:%u",port); coin->updaterate = (uint32_t)time(NULL); coin->isPoS = isPoS; coin->taddr = taddr; @@ -296,7 +307,9 @@ int32_t LP_coininit(struct iguana_info *coin,char *symbol,char *name,char *asset coin->noimportprivkey_flag = 1; printf("truncate importprivkey for %s\n",symbol); } - return(LP_userpass(coin->userpass,symbol,assetname,name,name2,confpath)); + port = LP_userpass(coin->userpass,symbol,assetname,name,name2,confpath,port); + sprintf(coin->serverport,"127.0.0.1:%u",port); + return(port); } int32_t LP_isdisabled(char *base,char *rel) @@ -339,7 +352,10 @@ struct iguana_info *LP_coinfind(char *symbol) else if ( strcmp(symbol,"KMD") == 0 ) name = "komodo"; else return(0); - isinactive = LP_coininit(&cdata,symbol,name,assetname,isPoS,port,pubtype,p2shtype,wiftype,txfee,estimatedrate,longestchain,0,0,busport,0) < 0; + port = LP_coininit(&cdata,symbol,name,assetname,isPoS,port,pubtype,p2shtype,wiftype,txfee,estimatedrate,longestchain,0,0,busport,0); + if ( port == 0 ) + isinactive = 1; + else isinactive = 0; if ( (coin= LP_coinadd(&cdata)) != 0 ) { coin->inactive = isinactive * (uint32_t)time(NULL); diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index ecf6de1a7..ec5a4eda7 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -372,8 +372,15 @@ dividends(coin, height, )\n\ else if ( strcmp(method,"listunspent") == 0 ) { if ( (ptr= LP_coinsearch(jstr(argjson,"coin"))) != 0 ) - return(jprint(LP_address_utxos(ptr,jstr(argjson,"address"),1),1)); - else return(clonestr("{\"error\":\"cant find coind\"}")); + { + char *coinaddr; + if ( (coinaddr= jstr(argjson,"address")) != 0 ) + { + if ( strcmp(coinaddr,ptr->smartaddr) == 0 && bits256_nonz(G.LP_mypriv25519) != 0 ) + LP_privkey_init(-1,ptr,G.LP_mypriv25519,G.LP_mypub25519); + return(jprint(LP_address_utxos(ptr,coinaddr,1),1)); + } else return(clonestr("{\"error\":\"no address specified\"}")); + } else return(clonestr("{\"error\":\"cant find coind\"}")); } else if ( strcmp(method,"balance") == 0 ) { diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index d1a85727e..5faed5c43 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -269,7 +269,7 @@ struct basilisk_swap struct basilisk_swapmessage *messages; int32_t nummessages,sentflag; char Bdeposit[64],Bpayment[64]; uint64_t otherdeck[INSTANTDEX_DECKSIZE][2],deck[INSTANTDEX_DECKSIZE][2]; - uint8_t persistent_pubkey33[33],changermd160[20],pad[15],verifybuf[100000]; + uint8_t persistent_pubkey33[33],persistent_other33[33],changermd160[20],pad[15],verifybuf[100000]; }; diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 981a65e20..694901cf4 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -416,7 +416,7 @@ int32_t LP_utxos_sync(struct LP_peerinfo *peer) int32_t LP_mainloop_iter(void *ctx,char *myipaddr,struct LP_peerinfo *mypeer,int32_t pubsock,char *pushaddr,uint16_t myport) { static uint32_t counter,numpeers; - struct iguana_info *coin,*ctmp; char *retstr,*origipaddr; struct LP_peerinfo *peer,*tmp; uint32_t now; bits256 zero; int32_t needpings,height,nonz = 0; + struct iguana_info *coin,*ctmp; char *retstr,*origipaddr; struct LP_peerinfo *peer,*tmp; uint32_t now; bits256 zero; int32_t needpings,j,height,nonz = 0; now = (uint32_t)time(NULL); if ( (origipaddr= myipaddr) == 0 ) origipaddr = "127.0.0.1"; @@ -450,6 +450,7 @@ int32_t LP_mainloop_iter(void *ctx,char *myipaddr,struct LP_peerinfo *mypeer,int if ( peer->diduquery == 0 ) { LP_peer_pricesquery(peer); + LP_utxos_sync(peer); peer->diduquery = now; } if ( peer->needping != 0 ) @@ -511,12 +512,17 @@ int32_t LP_mainloop_iter(void *ctx,char *myipaddr,struct LP_peerinfo *mypeer,int } if ( (coin->lastscanht % 1000) == 0 ) printf("%s ref.%d scan.%d to %d, longest.%d\n",coin->symbol,coin->firstrefht,coin->firstscanht,coin->lastscanht,coin->longestchain); - if ( LP_blockinit(coin,coin->lastscanht) < 0 ) + for (j=0; j<100; j++) { - printf("blockinit.%s %d error\n",coin->symbol,coin->lastscanht); - continue; + if ( LP_blockinit(coin,coin->lastscanht) < 0 ) + { + printf("blockinit.%s %d error\n",coin->symbol,coin->lastscanht); + break; + } + coin->lastscanht++; } - coin->lastscanht++; + if ( j < 100 ) + continue; //LP_getestimatedrate(coin); break; } diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index e1754ffb4..c50a47853 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -152,7 +152,10 @@ void basilisk_dontforget(struct basilisk_swap *swap,struct basilisk_rawtx *rawtx fprintf(fp,",\"otherfee\":\"%s\"",bits256_str(str,swap->otherfee.I.actualtxid)); if ( bits256_nonz(swap->myfee.I.actualtxid) != 0 ) fprintf(fp,",\"myfee\":\"%s\"",bits256_str(str,swap->myfee.I.actualtxid)); - fprintf(fp,",\"dest33\":\""); + fprintf(fp,",\"other33\":\""); + for (i=0; i<33; i++) + fprintf(fp,"%02x",swap->persistent_other33[i]); + fprintf(fp,"\",\"dest33\":\""); for (i=0; i<33; i++) fprintf(fp,"%02x",swap->persistent_pubkey33[i]); fprintf(fp,"\"}\n"); @@ -244,7 +247,7 @@ bits256 basilisk_swap_privBn_extract(bits256 *bobrefundp,char *bobcoin,bits256 b return(privBn); } -bits256 basilisk_swap_spendupdate(char *symbol,char *spentaddr,int32_t *sentflags,bits256 *txids,int32_t utxoind,int32_t alicespent,int32_t bobspent,int32_t vout,char *aliceaddr,char *bobaddr) +bits256 basilisk_swap_spendupdate(char *symbol,char *spentaddr,int32_t *sentflags,bits256 *txids,int32_t utxoind,int32_t alicespent,int32_t bobspent,int32_t vout,char *aliceaddr,char *bobaddr,char *Adest,char *dest) { bits256 spendtxid,txid; char destaddr[64],str[65]; struct iguana_info *coin; cJSON *histobj; if ( (coin= LP_coinfind(symbol)) != 0 && coin->electrum != 0 ) @@ -265,14 +268,14 @@ bits256 basilisk_swap_spendupdate(char *symbol,char *spentaddr,int32_t *sentflag { sentflags[utxoind] = 1; printf("utxoind.%d Alice.(%s) Bob.(%s)\n",utxoind,aliceaddr,bobaddr); - if ( aliceaddr != 0 && strcmp(destaddr,aliceaddr) == 0 ) + if ( aliceaddr != 0 && (strcmp(destaddr,aliceaddr) == 0 || strcmp(Adest,destaddr) == 0) ) { printf("ALICE spent.(%s) -> %s\n",bits256_str(str,txid),destaddr); sentflags[alicespent] = 1; sentflags[bobspent] = 0; txids[alicespent] = spendtxid; } - else if ( bobaddr != 0 && strcmp(destaddr,bobaddr) == 0 ) + else if ( bobaddr != 0 && (strcmp(destaddr,bobaddr) == 0 || strcmp(dest,destaddr) == 0) ) { printf("BOB spent.(%s) -> %s\n",bits256_str(str,txid),destaddr); sentflags[bobspent] = 1; @@ -284,13 +287,13 @@ bits256 basilisk_swap_spendupdate(char *symbol,char *spentaddr,int32_t *sentflag printf("OTHER dest spent.(%s) -> %s\n",bits256_str(str,txid),destaddr); if ( aliceaddr != 0 ) { - sentflags[bobspent] = 1; + sentflags[bobspent] = 0; sentflags[alicespent] = 0; txids[bobspent] = spendtxid; } else if ( bobaddr != 0 ) { - sentflags[alicespent] = 1; + sentflags[alicespent] = 0; sentflags[bobspent] = 0; txids[alicespent] = spendtxid; } @@ -463,7 +466,7 @@ struct LP_swap_remember uint64_t Atxfee,Btxfee,srcamount,destamount; int64_t values[sizeof(txnames)/sizeof(*txnames)]; uint32_t requestid,quoteid,plocktime,dlocktime,expiration,state,otherstate; int32_t iambob,finishedflag,origfinishedflag,Predeemlen,Dredeemlen,sentflags[sizeof(txnames)/sizeof(*txnames)]; - uint8_t secretAm[20],secretAm256[32],secretBn[20],secretBn256[32],pubkey33[33],Predeemscript[1024],Dredeemscript[1024]; + uint8_t secretAm[20],secretAm256[32],secretBn[20],secretBn256[32],Predeemscript[1024],Dredeemscript[1024],pubkey33[33],other33[33]; char src[64],dest[64],destaddr[64],Adestaddr[64],alicepaymentaddr[64],bobpaymentaddr[64],bobdepositaddr[64],alicecoin[64],bobcoin[64],*txbytes[sizeof(txnames)/sizeof(*txnames)]; }; @@ -508,7 +511,7 @@ cJSON *LP_swap_json(struct LP_swap_remember *rswap) int32_t LP_rswap_init(struct LP_swap_remember *rswap,uint32_t requestid,uint32_t quoteid) { - char fname[1024],*fstr,*secretstr,*srcstr,*deststr,*dest33,*txname; long fsize; cJSON *item,*txobj,*array; bits256 privkey; uint32_t r,q; int32_t i,j,n; + char fname[1024],*fstr,*secretstr,*srcstr,*deststr,*dest33,*txname; long fsize; cJSON *item,*txobj,*array; bits256 privkey; uint32_t r,q; int32_t i,j,n; uint8_t other33[33]; memset(rswap,0,sizeof(*rswap)); rswap->requestid = requestid; rswap->quoteid = quoteid; @@ -537,6 +540,16 @@ int32_t LP_rswap_init(struct LP_swap_remember *rswap,uint32_t requestid,uint32_t // printf("%02x",pubkey33[i]); //printf(" <- %s dest33\n",dest33); } + if ( (dest33= jstr(item,"other33")) != 0 && strlen(dest33) == 66 ) + { + decode_hex(other33,33,dest33); + for (i=0; i<33; i++) + if ( other33[i] != 0 ) + break; + if ( i < 33 ) + memcpy(rswap->other33,other33,33); + //printf(" <- %s dest33\n",dest33); + } if ( (rswap->plocktime= juint(item,"plocktime")) == 0 ) rswap->plocktime = LP_extract(requestid,quoteid,fname,"plocktime"); if ( (rswap->dlocktime= juint(item,"dlocktime")) == 0 ) @@ -622,22 +635,28 @@ int32_t LP_rswap_init(struct LP_swap_remember *rswap,uint32_t requestid,uint32_t return(rswap->iambob); } -void LP_refht_update(char *symbol,bits256 txid) +int32_t _LP_refht_update(struct iguana_info *coin,bits256 txid,int32_t refht) { - int32_t ht; struct iguana_info *coin; - if ( (coin= LP_coinfind(symbol)) != 0 ) // && coin->electrum == 0 + if ( refht > 0 && (coin->firstrefht == 0 || refht < coin->firstrefht) ) { - if ( (ht= LP_txheight(coin,txid)) > 0 && ht > 0 ) - { - if ( coin->firstrefht == 0 || ht < coin->firstrefht ) - { - if ( coin->firstscanht == 0 || ht < coin->firstscanht ) - coin->firstscanht = coin->lastscanht = ht; - coin->firstrefht = ht; - char str[65]; printf(">>>>>>>>. 1st refht %s %s <- %d, scan %d %d\n",coin->symbol,bits256_str(str,txid),ht,coin->firstscanht,coin->lastscanht); - } - } + char str[65]; printf(">>>>>>>>. 1st refht %s %s <- %d, scan %d %d\n",coin->symbol,bits256_str(str,txid),refht,coin->firstscanht,coin->lastscanht); + if ( coin->firstscanht == 0 || refht < coin->firstscanht ) + coin->firstscanht = coin->lastscanht = refht; + coin->firstrefht = refht; + return(1); } + return(0); +} + +int32_t LP_refht_update(char *symbol,bits256 txid) +{ + int32_t refht; struct iguana_info *coin; + if ( (coin= LP_coinfind(symbol)) != 0 && coin->electrum == 0 ) + { + if ( (refht= LP_txheight(coin,txid)) > 0 && refht > 0 ) + return(_LP_refht_update(coin,txid,refht)); + } + return(0); } int32_t LP_swap_load(struct LP_swap_remember *rswap) @@ -712,7 +731,6 @@ int32_t LP_swap_load(struct LP_swap_remember *rswap) safecopy(rswap->alicecoin,symbol,sizeof(rswap->alicecoin)); if ( rswap->finishedflag == 0 ) { - LP_refht_update(symbol,txid); if ( (sentobj= LP_gettx(symbol,txid)) == 0 ) { char str2[65]; printf("%s %s ready to broadcast\n",symbol,bits256_str(str2,txid)); @@ -722,6 +740,7 @@ int32_t LP_swap_load(struct LP_swap_remember *rswap) checktxid = jbits256(sentobj,"txid"); if ( bits256_nonz(checktxid) == 0 ) checktxid = jbits256(sentobj,"hash"); + LP_refht_update(symbol,txid); if ( bits256_cmp(checktxid,txid) == 0 ) { //printf(">>>>>> %s txid %s\n",jprint(sentobj,0),bits256_str(str,txid)); @@ -767,19 +786,16 @@ void LP_txbytes_update(char *name,char *symbol,char *txbytes,bits256 *txidp,bits int32_t LP_rswap_checktx(struct LP_swap_remember *rswap,char *symbol,int32_t txi) { - cJSON *sentobj; char str[65]; + struct LP_transaction *tx; struct iguana_info *coin; char str[65]; if ( rswap->sentflags[txi] == 0 && bits256_nonz(rswap->txids[txi]) != 0 ) { - printf("[%s] txbytes.%p Apayment.%s\n",txnames[txi],rswap->txbytes[txi],bits256_str(str,rswap->txids[txi])); - if ( rswap->txbytes[txi] != 0 ) - rswap->sentflags[txi] = 1; - else if ( (sentobj= LP_gettx(symbol,rswap->txids[txi])) != 0 ) + coin = LP_coinfind(symbol); + printf("[%s] %s txbytes.%p %s\n",txnames[txi],txnames[txi],rswap->txbytes[txi],bits256_str(str,rswap->txids[txi])); + if ( coin != 0 && (tx= LP_transactionfind(coin,rswap->txids[txi])) != 0 && tx->height > 0 ) { rswap->sentflags[txi] = 1; - free_json(sentobj); - LP_refht_update(symbol,rswap->txids[txi]); - return(1); - } + _LP_refht_update(coin,rswap->txids[txi],tx->height); + } else LP_refht_update(symbol,rswap->txids[txi]); } return(0); } @@ -835,8 +851,8 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti printf("Bob.%p is null or Alice.%p is null\n",bob,alice); return(cJSON_Parse("{\"error\":\"null bob or alice coin\"}")); } - printf("ALICE 1st refht %s <- %d, scan %d %d\n",alice->symbol,alice->firstrefht,alice->firstscanht,alice->lastscanht); - printf("BOB 1st refht %s <- %d, scan %d %d\n",bob->symbol,bob->firstrefht,bob->firstscanht,bob->lastscanht); + printf("ALICE.(%s) 1st refht %s <- %d, scan %d %d\n",rswap.Adestaddr,alice->symbol,alice->firstrefht,alice->firstscanht,alice->lastscanht); + printf("BOB.(%s) 1st refht %s <- %d, scan %d %d\n",rswap.destaddr,bob->symbol,bob->firstrefht,bob->firstscanht,bob->lastscanht); //printf("iambob.%d finishedflag.%d %s %.8f txfee, %s %.8f txfee\n",rswap.iambob,rswap.finishedflag,rswap.alicecoin,dstr(rswap.Atxfee),rswap.bobcoin,dstr(rswap.Btxfee)); //printf("privAm.(%s) %p/%p\n",bits256_str(str,rswap.privAm),Adest,AAdest); //printf("privBn.(%s) %p/%p\n",bits256_str(str,rswap.privBn),Bdest,ABdest); @@ -850,9 +866,9 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti LP_rswap_checktx(&rswap,rswap.alicecoin,BASILISK_ALICEPAYMENT); LP_rswap_checktx(&rswap,rswap.bobcoin,BASILISK_BOBPAYMENT); LP_rswap_checktx(&rswap,rswap.bobcoin,BASILISK_BOBDEPOSIT); - rswap.paymentspent = basilisk_swap_spendupdate(rswap.bobcoin,rswap.bobpaymentaddr,rswap.sentflags,rswap.txids,BASILISK_BOBPAYMENT,BASILISK_ALICESPEND,BASILISK_BOBRECLAIM,0,Adest,Bdest); - rswap.Apaymentspent = basilisk_swap_spendupdate(rswap.alicecoin,rswap.alicepaymentaddr,rswap.sentflags,rswap.txids,BASILISK_ALICEPAYMENT,BASILISK_ALICERECLAIM,BASILISK_BOBSPEND,0,AAdest,ABdest); - rswap.depositspent = basilisk_swap_spendupdate(rswap.bobcoin,rswap.bobdepositaddr,rswap.sentflags,rswap.txids,BASILISK_BOBDEPOSIT,BASILISK_ALICECLAIM,BASILISK_BOBREFUND,0,Adest,Bdest); + rswap.paymentspent = basilisk_swap_spendupdate(rswap.bobcoin,rswap.bobpaymentaddr,rswap.sentflags,rswap.txids,BASILISK_BOBPAYMENT,BASILISK_ALICESPEND,BASILISK_BOBRECLAIM,0,Adest,Bdest,rswap.Adestaddr,rswap.destaddr); + rswap.Apaymentspent = basilisk_swap_spendupdate(rswap.alicecoin,rswap.alicepaymentaddr,rswap.sentflags,rswap.txids,BASILISK_ALICEPAYMENT,BASILISK_ALICERECLAIM,BASILISK_BOBSPEND,0,AAdest,ABdest,rswap.Adestaddr,rswap.destaddr); + rswap.depositspent = basilisk_swap_spendupdate(rswap.bobcoin,rswap.bobdepositaddr,rswap.sentflags,rswap.txids,BASILISK_BOBDEPOSIT,BASILISK_ALICECLAIM,BASILISK_BOBREFUND,0,Adest,Bdest,rswap.Adestaddr,rswap.destaddr); rswap.finishedflag = basilisk_swap_isfinished(rswap.iambob,rswap.txids,rswap.sentflags,rswap.paymentspent,rswap.Apaymentspent,rswap.depositspent); if ( rswap.iambob == 0 ) { diff --git a/iguana/exchanges/LP_rpc.c b/iguana/exchanges/LP_rpc.c index 8def0e8e3..aa6296325 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -131,9 +131,10 @@ cJSON *bitcoin_json(struct iguana_info *coin,char *method,char *params) if ( coin->electrum == 0 ) { retstr = bitcoind_passthru(coin->symbol,coin->serverport,coin->userpass,method,params); + if ( 0 && strcmp("KMD",coin->symbol) == 0 ) + printf("%s.(%s %s): %s.%s -> (%s)\n",coin->symbol,coin->serverport,coin->userpass,method,params,retstr); if ( retstr != 0 && retstr[0] != 0 ) { - //printf("%s: %s.%s -> (%s)\n",coin->symbol,method,params,retstr); retjson = cJSON_Parse(retstr); free(retstr); } @@ -255,7 +256,6 @@ cJSON *LP_gettx(char *symbol,bits256 txid) { sprintf(buf,"[\"%s\", 1]",bits256_str(str,txid)); retjson = bitcoin_json(coin,"getrawtransaction",buf); - printf("%s getrawtransaction %s -> %s\n",symbol,buf,jprint(retjson,0)); return(retjson); } else diff --git a/iguana/exchanges/LP_swap.c b/iguana/exchanges/LP_swap.c index 22bf882aa..79a495c59 100644 --- a/iguana/exchanges/LP_swap.c +++ b/iguana/exchanges/LP_swap.c @@ -177,6 +177,8 @@ uint32_t basilisk_requestid(struct basilisk_request *rp) int32_t LP_pubkeys_data(struct basilisk_swap *swap,uint8_t *data,int32_t maxlen) { int32_t i,datalen = 0; + for (i=0; i<33; i++) + data[datalen++] = swap->persistent_pubkey33[i]; for (i=0; ideck)/sizeof(swap->deck[0][0]); i++) datalen += iguana_rwnum(1,&data[datalen],sizeof(swap->deck[i>>1][i&1]),&swap->deck[i>>1][i&1]); return(datalen); @@ -184,9 +186,14 @@ int32_t LP_pubkeys_data(struct basilisk_swap *swap,uint8_t *data,int32_t maxlen) int32_t LP_pubkeys_verify(struct basilisk_swap *swap,uint8_t *data,int32_t datalen) { - int32_t i,len = 0; - if ( datalen == sizeof(swap->otherdeck) ) + int32_t i,nonz=0,len = 0; uint8_t other33[33]; + if ( datalen == sizeof(swap->otherdeck)+33 ) { + for (i=0; i<33; i++) + if ( (other33[i]= data[len++]) != 0 ) + nonz++; + if ( nonz > 8 ) + memcpy(swap->persistent_other33,other33,33); for (i=0; iotherdeck)/sizeof(swap->otherdeck[0][0]); i++) len += iguana_rwnum(0,&data[len],sizeof(swap->otherdeck[i>>1][i&1]),&swap->otherdeck[i>>1][i&1]); return(0); diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index d33889a7b..d9ad2b012 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -157,6 +157,7 @@ int32_t LP_address_utxo_ptrs(int32_t iambob,struct LP_address_utxo **utxos,int32 portable_mutex_lock(&LP_utxomutex); DL_FOREACH_SAFE(ap->utxos,up,tmp) { + char str[65]; printf("LP_address_utxo_ptrs %s n.%d %.8f %s v%d\n",ap->coinaddr,n,dstr(up->U.value),bits256_str(str,up->U.txid),up->U.vout); if ( up->spendheight <= 0 ) { if ( LP_allocated(up->U.txid,up->U.vout) == 0 ) @@ -433,8 +434,6 @@ int32_t LP_unspents_array(struct iguana_info *coin,char *coinaddr,cJSON *array) v = jint(item,"tx_pos"); height = jint(item,"height"); val = j64bits(item,"value"); - //if ( strcmp(coin->symbol,"LBC") == 0 ) - // printf("(%s)\n",jprint(item,0)); if ( coin->electrum == 0 && (txobj= LP_gettxout(coin->symbol,coinaddr,txid,v)) != 0 ) { value = LP_value_extract(txobj,0); @@ -671,7 +670,9 @@ int32_t LP_txheight(struct iguana_info *coin,bits256 txid) if ( bits256_nonz(blockhash) != 0 && (blockobj= LP_getblock(coin->symbol,blockhash)) != 0 ) { height = jint(blockobj,"height"); - char str[65]; printf("%s %s LP_txheight.%d\n",coin->symbol,bits256_str(str,txid),height); + //char str[65]; + //if ( strcmp(coin->symbol,"CHIPS") != 0 && strcmp(coin->symbol,"BTC") != 0 ) + // printf("%s %s LP_txheight.%d\n",coin->symbol,bits256_str(str,txid),height); free_json(blockobj); } // else printf("%s LP_txheight error (%s)\n",coin->symbol,jprint(txobj,0)); likely just unconfirmed free_json(txobj); diff --git a/iguana/exchanges/LP_utxos.c b/iguana/exchanges/LP_utxos.c index 35f8d2c1c..a651813b2 100644 --- a/iguana/exchanges/LP_utxos.c +++ b/iguana/exchanges/LP_utxos.c @@ -742,7 +742,7 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan userpub = curve25519(userpass,curve25519_basepoint9()); printf("userpass.(%s)\n",bits256_str(G.USERPASS,userpub)); } - if ( coin->electrum == 0 ) + if ( coin->electrum == 0 && coin->userpass[0] != 0 ) { LP_listunspent_issue(coin->symbol,coin->smartaddr); if ( (retjson= LP_importprivkey(coin->symbol,tmpstr,coin->smartaddr,-1)) != 0 )