diff --git a/basilisk/basilisk.c b/basilisk/basilisk.c index 59e4480b3..fb65f069a 100755 --- a/basilisk/basilisk.c +++ b/basilisk/basilisk.c @@ -1612,7 +1612,7 @@ STRING_ARRAY_OBJ_STRING(basilisk,utxorawtx,symbol,utxos,vals,ignore) if ( destaddr != 0 && changeaddr != 0 && symbol != 0 && (coin= iguana_coinfind(symbol)) != 0 ) { txfee = jdouble(vals,"txfee") * SATOSHIDEN; - return(iguana_utxorawtx(myinfo,coin,timelock,destaddr,changeaddr,&satoshis,1,txfee,&completed,sendflag,utxos)); + return(iguana_utxorawtx(myinfo,coin,timelock,destaddr,changeaddr,&satoshis,1,txfee,&completed,sendflag,utxos,0)); } return(clonestr("{\"error\":\"invalid coin or address specified\"}")); } diff --git a/basilisk/basilisk_bitcoin.c b/basilisk/basilisk_bitcoin.c index cbe759041..48fb97254 100755 --- a/basilisk/basilisk_bitcoin.c +++ b/basilisk/basilisk_bitcoin.c @@ -658,7 +658,7 @@ int64_t iguana_verifytimelock(struct supernet_info *myinfo,struct iguana_info *c } return(-2); } -char *iguana_utxorawtx(struct supernet_info *myinfo,struct iguana_info *coin,int32_t timelock,char *destaddr,char *changeaddr,int64_t *satoshis,int32_t numoutputs,uint64_t txfee,int32_t *completedp,int32_t sendflag,cJSON *utxos) +char *iguana_utxorawtx(struct supernet_info *myinfo,struct iguana_info *coin,int32_t timelock,char *destaddr,char *changeaddr,int64_t *satoshis,int32_t numoutputs,uint64_t txfee,int32_t *completedp,int32_t sendflag,cJSON *utxos,cJSON *privkeys) { uint8_t script[35],p2shscript[128],rmd160[20],addrtype; bits256 txid; int32_t i,p2shlen,iter,spendlen; cJSON *retjson,*txcopy,*txobj=0,*vins=0; char *rawtx=0,*signedtx=0; uint32_t timelocked = 0; *completedp = 0; @@ -697,7 +697,7 @@ char *iguana_utxorawtx(struct supernet_info *myinfo,struct iguana_info *coin,int { if ( iter == 1 || txfee != 0 ) jaddstr(retjson,"rawtx",rawtx); - if ( (signedtx= iguana_signrawtx(myinfo,coin,0,&txid,completedp,vins,rawtx,0,0)) != 0 ) + if ( (signedtx= iguana_signrawtx(myinfo,coin,0,&txid,completedp,vins,rawtx,privkeys,0)) != 0 ) { if ( (iter == 1 || txfee != 0) && *completedp != 0 ) { diff --git a/basilisk/jumblr.c b/basilisk/jumblr.c index 0933bf094..130ddad8d 100755 --- a/basilisk/jumblr.c +++ b/basilisk/jumblr.c @@ -380,7 +380,7 @@ bits256 jumblr_privkey(struct supernet_info *myinfo,char *coinaddr,uint8_t pubty return(privkey); } -int64_t jumblr_DEXsplit(struct supernet_info *myinfo,struct iguana_info *coin,bits256 *splittxidp,char *coinaddr,bits256 txid,int32_t vout,int64_t remaining,double bigprice,double middleprice,double smallprice,double fees[4]) +int64_t jumblr_DEXsplit(struct supernet_info *myinfo,struct iguana_info *coin,bits256 *splittxidp,char *coinaddr,bits256 txid,int32_t vout,int64_t remaining,double bigprice,double middleprice,double smallprice,double fees[4],cJSON *privkeys) { int64_t values[4],outputs[64],value,total,estfee = 150000; int32_t i,n,success=0,completed,sendflag,numoutputs = 0; char *retstr; cJSON *retjson,*utxo,*item; total = 0; @@ -424,7 +424,7 @@ int64_t jumblr_DEXsplit(struct supernet_info *myinfo,struct iguana_info *coin,bi utxo = cJSON_CreateArray(); jaddi(utxo,item); sendflag = 0; - if ( (retstr= iguana_utxorawtx(myinfo,coin,0,coinaddr,coinaddr,outputs,numoutputs,0,&completed,sendflag,utxo)) != 0 ) + if ( (retstr= iguana_utxorawtx(myinfo,coin,0,coinaddr,coinaddr,outputs,numoutputs,0,&completed,sendflag,utxo,privkeys)) != 0 ) { if ( completed != 0 ) { @@ -512,9 +512,9 @@ int32_t jumblr_DEXutxoind(int32_t *shouldsplitp,double targetvolB,double targetv } } -int64_t jumblr_DEXutxoupdate(struct supernet_info *myinfo,struct iguana_info *coin,bits256 *splittxidp,char *coinaddr,bits256 txid,int32_t vout,uint64_t value,int32_t isbob,double kmdprice) +int64_t jumblr_DEXutxoupdate(struct supernet_info *myinfo,struct iguana_info *coin,bits256 *splittxidp,char *coinaddr,bits256 privkey,bits256 txid,int32_t vout,uint64_t value,int32_t isbob,double kmdprice) { - double fees[4],targetvolB,amount,targetvolM,targetvolS,depositfactor,dexfeeratio,margin; int32_t ind,shouldsplit; + double fees[4],targetvolB,amount,targetvolM,targetvolS,depositfactor,dexfeeratio,margin; int32_t ind,shouldsplit; cJSON *privkeys; char wifstr[128]; int64_t retval = 0; margin = 1.1; depositfactor = (isbob == 0) ? 1. : 1.2; dexfeeratio = 500.; @@ -530,9 +530,15 @@ int64_t jumblr_DEXutxoupdate(struct supernet_info *myinfo,struct iguana_info *co { printf("shouldsplit.%d ind.%d\n",shouldsplit,ind); if ( shouldsplit != 0 ) - return(jumblr_DEXsplit(myinfo,coin,splittxidp,coinaddr,txid,vout,value,margin * targetvolB,margin * targetvolM,margin * targetvolS,fees)); + { + privkeys = cJSON_CreateArray(); + bitcoin_priv2wif(wifstr,privkey,coin->chain->wiftype); + jaddistr(privkeys,wifstr); + retval = jumblr_DEXsplit(myinfo,coin,splittxidp,coinaddr,txid,vout,value,margin * targetvolB,margin * targetvolM,margin * targetvolS,fees,privkeys); + free_json(privkeys); + } } else printf("negative ind\n"); - return(0); + return(retval); } /*struct DEXcoin_info @@ -575,7 +581,7 @@ void jumblr_utxotxidpendingadd(struct supernet_info *myinfo,struct iguana_info * coin->DEXinfo.pending[coin->DEXinfo.numpending++] = pend; } -void jumblr_utxoupdate(struct supernet_info *myinfo,struct iguana_info *coin,double price,char *coinaddr) +void jumblr_utxoupdate(struct supernet_info *myinfo,struct iguana_info *coin,double price,char *coinaddr,bits256 privkey) { char *retstr; cJSON *array,*item; int32_t i,n,vout; bits256 txid,splittxid; uint64_t value; if ( (retstr= jumblr_listunspent(myinfo,coin,coinaddr)) != 0 ) @@ -595,7 +601,7 @@ void jumblr_utxoupdate(struct supernet_info *myinfo,struct iguana_info *coin,dou if ( jumblr_utxotxidpending(myinfo,&splittxid,coin,txid,vout) < 0 ) { printf("call utxoupdate\n"); - jumblr_DEXutxoupdate(myinfo,coin,&splittxid,coinaddr,txid,vout,value,myinfo->IAMLP,price); + jumblr_DEXutxoupdate(myinfo,coin,&splittxid,coinaddr,privkey,txid,vout,value,myinfo->IAMLP,price); jumblr_utxotxidpendingadd(myinfo,coin,txid,vout,splittxid); } else printf("already have txid\n"); } @@ -638,14 +644,14 @@ void jumblr_DEXupdate(struct supernet_info *myinfo,struct iguana_info *coin,char ptr->kmdprice = 1.; ptr->KMDavail = ptr->avail; if ( (btccoin= iguana_coinfind("BTC")) != 0 ) - jumblr_utxoupdate(myinfo,btccoin,ptr->btcprice,ptr->depositaddr); - jumblr_utxoupdate(myinfo,kmdcoin,1.,ptr->KMDdepositaddr); + jumblr_utxoupdate(myinfo,btccoin,ptr->btcprice,ptr->depositaddr,ptr->deposit_privkey); + jumblr_utxoupdate(myinfo,kmdcoin,1.,ptr->KMDdepositaddr,ptr->deposit_privkey); } else if ( (ptr->BTC2KMD= BTC2KMD) > SMALLVAL ) { ptr->kmdprice = ptr->btcprice / BTC2KMD; ptr->KMDavail = KMDavail; - jumblr_utxoupdate(myinfo,ptr->coin,ptr->kmdprice,ptr->depositaddr); + jumblr_utxoupdate(myinfo,ptr->coin,ptr->kmdprice,ptr->depositaddr,ptr->deposit_privkey); } ptr->lasttime = (uint32_t)time(NULL); } else printf("skip\n"); diff --git a/includes/iguana_funcs.h b/includes/iguana_funcs.h index 215596380..6be0f931a 100755 --- a/includes/iguana_funcs.h +++ b/includes/iguana_funcs.h @@ -528,7 +528,7 @@ char *basilisk_bitcoinrawtx(struct supernet_info *myinfo,struct iguana_info *coi int32_t iguana_markedunspents_find(struct iguana_info *coin,int32_t *firstslotp,bits256 txid,int32_t vout); void jumblr_opidsupdate(struct supernet_info *myinfo,struct iguana_info *coin); -char *iguana_signrawtx(struct supernet_info *myinfo,struct iguana_info *coin,int32_t height,bits256 *signedtxidp,int32_t *completedp,cJSON *vins,char *rawtx,cJSON *privkey,struct vin_info *V); +char *iguana_signrawtx(struct supernet_info *myinfo,struct iguana_info *coin,int32_t height,bits256 *signedtxidp,int32_t *completedp,cJSON *vins,char *rawtx,cJSON *privkeys,struct vin_info *V); bits256 scrypt_blockhash(const void *input); bits256 iguana_calcblockhash(char *symbol,int32_t (*hashalgo)(uint8_t *blockhashp,uint8_t *serialized,int32_t len),uint8_t *serialized,int32_t len); struct bitcoin_eventitem *instantdex_event(char *cmdstr,cJSON *argjson,cJSON *newjson,uint8_t *serdata,int32_t serdatalen);