diff --git a/basilisk/basilisk.c b/basilisk/basilisk.c index c3d8af0e3..c15f7d086 100755 --- a/basilisk/basilisk.c +++ b/basilisk/basilisk.c @@ -588,7 +588,7 @@ void basilisk_msgprocess(struct supernet_info *myinfo,void *_addr,uint32_t sende { (void *)"END", &basilisk_respond_VPNlogout }, // logout // coin services - { (void *)"RAW", &basilisk_respond_rawtx }, + //{ (void *)"RAW", &basilisk_respond_rawtx }, { (void *)"VAL", &basilisk_respond_value }, { (void *)"BAL", &basilisk_respond_balances }, }; diff --git a/basilisk/basilisk.h b/basilisk/basilisk.h index 3cdf565f9..b570fdad9 100755 --- a/basilisk/basilisk.h +++ b/basilisk/basilisk.h @@ -130,5 +130,7 @@ void basilisk_request_goodbye(struct supernet_info *myinfo); int32_t basilisk_update(char *symbol,uint32_t reftimestamp); void basilisk_seqresult(struct supernet_info *myinfo,char *retstr); struct iguana_info *basilisk_geckochain(struct supernet_info *myinfo,char *symbol,char *chainname,cJSON *valsobj); +void basilisk_alicepayment(struct supernet_info *myinfo,struct iguana_info *coin,struct basilisk_rawtx *alicepayment,bits256 pubAm,bits256 pubBn); +void basilisk_rawtx_setparms(char *name,struct supernet_info *myinfo,struct basilisk_swap *swap,struct basilisk_rawtx *rawtx,struct iguana_info *coin,int32_t numconfirms,int32_t vintype,uint64_t satoshis,int32_t vouttype,uint8_t *pubkey33); #endif diff --git a/basilisk/basilisk_CMD.c b/basilisk/basilisk_CMD.c index 908a87308..69d8bf527 100755 --- a/basilisk/basilisk_CMD.c +++ b/basilisk/basilisk_CMD.c @@ -181,7 +181,7 @@ char *basilisk_respond_VPNmessage(struct supernet_info *myinfo,char *CMD,void *a return(retstr); } -char *basilisk_respond_rawtx(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash,int32_t from_basilisk) +/*char *basilisk_respond_rawtx(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash,int32_t from_basilisk) { char *symbol,*retstr=0; struct basilisk_item Lptr,*ptr; int32_t timeoutmillis; struct iguana_info *coin = 0; timeoutmillis = jint(valsobj,"timeout"); @@ -193,7 +193,7 @@ char *basilisk_respond_rawtx(struct supernet_info *myinfo,char *CMD,void *addr,c ptr->finished = (uint32_t)time(NULL); } else retstr = clonestr("{\"error\":\"no coin specified or error bitcoinrawtx\"}"); return(retstr); -} +}*/ char *basilisk_respond_value(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash,int32_t from_basilisk) { diff --git a/basilisk/basilisk_bitcoin.c b/basilisk/basilisk_bitcoin.c index b89d640a8..73860def6 100755 --- a/basilisk/basilisk_bitcoin.c +++ b/basilisk/basilisk_bitcoin.c @@ -477,9 +477,9 @@ int32_t basilisk_vins_validate(struct supernet_info *myinfo,struct iguana_info * return(retval); } -void *basilisk_bitcoinrawtx(struct basilisk_item *Lptr,struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,uint32_t basilisktag,int32_t timeoutmillis,cJSON *valsobj) +char *basilisk_bitcoinrawtx(struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,uint32_t basilisktag,int32_t timeoutmillis,cJSON *valsobj) { - uint8_t buf[4096]; int32_t oplen,offset,numsent,minconf,spendlen; cJSON *vins,*addresses,*txobj = 0; uint32_t locktime; char *opreturn,*spendscriptstr,*changeaddr,*rawtx = 0; int64_t amount,txfee,burnamount; + uint8_t buf[4096]; int32_t oplen,offset,minconf,spendlen; cJSON *vins,*addresses,*txobj = 0; uint32_t locktime; char *opreturn,*spendscriptstr,*changeaddr,*rawtx = 0; int64_t amount,txfee,burnamount; vins = 0; changeaddr = jstr(valsobj,"changeaddr"); if ( (amount= j64bits(valsobj,"satoshis")) == 0 ) @@ -498,43 +498,32 @@ void *basilisk_bitcoinrawtx(struct basilisk_item *Lptr,struct supernet_info *myi } //printf("use addresses.(%s)\n",jprint(addresses,0)); //printf("vals.(%s) change.(%s) spend.%s\n",jprint(valsobj,0),changeaddr,spendscriptstr); - if ( changeaddr == 0 || changeaddr[0] == 0 || spendscriptstr == 0 || spendscriptstr[0] == 0 )//|| amount == 0 || addresses == 0 ) - { - Lptr->retstr = clonestr("{\"error\":\"invalid changeaddr or spendscript or addresses\"}"); - return(Lptr); - } + if ( changeaddr == 0 || changeaddr[0] == 0 || spendscriptstr == 0 || spendscriptstr[0] == 0 ) + return(clonestr("{\"error\":\"invalid changeaddr or spendscript or addresses\"}")); if ( coin != 0 && basilisk_bitcoinavail(coin) != 0 ) { - //if ( coin->VALIDATENODE != 0 || coin->RELAYNODE != 0 ) + if ( (txobj= bitcoin_txcreate(coin->chain->isPoS,locktime,locktime==0?coin->chain->normal_txversion:coin->chain->locktime_txversion)) != 0 ) { - if ( (txobj= bitcoin_txcreate(coin->chain->isPoS,locktime,locktime==0?coin->chain->normal_txversion:coin->chain->locktime_txversion)) != 0 ) + spendlen = (int32_t)strlen(spendscriptstr) >> 1; + decode_hex(buf,spendlen,spendscriptstr); + bitcoin_txoutput(txobj,buf,spendlen,amount); + burnamount = offset = oplen = 0; + if ( (opreturn= jstr(valsobj,"opreturn")) != 0 && (oplen= is_hexstr(opreturn,0)) > 0 ) { - spendlen = (int32_t)strlen(spendscriptstr) >> 1; - decode_hex(buf,spendlen,spendscriptstr); - bitcoin_txoutput(txobj,buf,spendlen,amount); - burnamount = offset = oplen = 0; - if ( (opreturn= jstr(valsobj,"opreturn")) != 0 && (oplen= is_hexstr(opreturn,0)) > 0 ) + oplen >>= 1; + if ( (strcmp("BTC",coin->symbol) == 0 && oplen < 77) || coin->chain->do_opreturn == 0 ) { - oplen >>= 1; - if ( (strcmp("BTC",coin->symbol) == 0 && oplen < 77) || coin->chain->do_opreturn == 0 ) - { - decode_hex(&buf[sizeof(buf) - oplen],oplen,opreturn); - spendlen = datachain_datascript(coin,buf,&buf[sizeof(buf) - oplen],oplen); - if ( (burnamount= SATOSHIDEN * jdouble(valsobj,"burn")) < 10000 ) - burnamount = 10000; - bitcoin_txoutput(txobj,buf,spendlen,burnamount); - oplen = 0; - } else oplen = datachain_opreturnscript(coin,buf,opreturn,oplen); - } - rawtx = iguana_calcrawtx(myinfo,coin,&vins,txobj,amount,changeaddr,txfee,addresses,minconf,oplen!=0?buf:0,oplen+offset,burnamount,remoteaddr); - printf("generated.(%s) vins.(%s)\n",rawtx!=0?rawtx:"",vins!=0?jprint(vins,0):""); - } - else - { - Lptr->retstr = clonestr("{\"error\":\"couldnt create rawtx locally\"}"); - return(Lptr); + decode_hex(&buf[sizeof(buf) - oplen],oplen,opreturn); + spendlen = datachain_datascript(coin,buf,&buf[sizeof(buf) - oplen],oplen); + if ( (burnamount= SATOSHIDEN * jdouble(valsobj,"burn")) < 10000 ) + burnamount = 10000; + bitcoin_txoutput(txobj,buf,spendlen,burnamount); + oplen = 0; + } else oplen = datachain_opreturnscript(coin,buf,opreturn,oplen); } - } //else rawtx = bitcoin_calcrawtx(myinfo,coin,vinsp,satoshis,spendscriptstr,changeaddr,txfee,addresses,minconf,locktime); + rawtx = iguana_calcrawtx(myinfo,coin,&vins,txobj,amount,changeaddr,txfee,addresses,minconf,oplen!=0?buf:0,oplen+offset,burnamount,remoteaddr); + printf("generated.(%s) vins.(%s)\n",rawtx!=0?rawtx:"",vins!=0?jprint(vins,0):""); + } if ( rawtx != 0 ) { if ( vins != 0 ) @@ -545,18 +534,17 @@ void *basilisk_bitcoinrawtx(struct basilisk_item *Lptr,struct supernet_info *myi jaddstr(valsobj,"rawtx",rawtx); jaddstr(valsobj,"coin",coin->symbol); free(rawtx); - Lptr->retstr = jprint(valsobj,1); - return(Lptr); + return(jprint(valsobj,1)); } else free(rawtx); } if ( txobj != 0 ) free_json(txobj); if ( vins != 0 ) free_json(vins); - Lptr->retstr = clonestr("{\"error\":\"couldnt create rawtx\"}"); - return(Lptr); + return(clonestr("{\"error\":\"couldnt create rawtx\"}")); } - return(basilisk_issueremote(myinfo,0,&numsent,"RAW",coin->symbol,1,valsobj,juint(valsobj,"fanout"),juint(valsobj,"minresults"),basilisktag,timeoutmillis,0,0,0,0,BASILISK_DEFAULTDIFF)); + return(clonestr("{\"error\":\"dont have coin to create rawtx\"}")); + //return(basilisk_issueremote(myinfo,0,&numsent,"RAW",coin->symbol,1,valsobj,juint(valsobj,"fanout"),juint(valsobj,"minresults"),basilisktag,timeoutmillis,0,0,0,0,BASILISK_DEFAULTDIFF)); } /* @@ -810,7 +798,7 @@ HASH_ARRAY_STRING(basilisk,value,hash,vals,hexstr) return(basilisk_standardservice("VAL",myinfo,0,hash,vals,hexstr,1)); } -HASH_ARRAY_STRING(basilisk,rawtx,hash,vals,hexstr) +/*HASH_ARRAY_STRING(basilisk,rawtx,hash,vals,hexstr) { char *retstr=0,*symbol; uint32_t basilisktag; struct basilisk_item *ptr,Lptr; int32_t timeoutmillis,i,retval = -1; uint64_t amount,txfee; cJSON *retarray; //if ( coin == 0 ) @@ -867,7 +855,7 @@ HASH_ARRAY_STRING(basilisk,rawtx,hash,vals,hexstr) } } return(retstr); -} +}*/ HASH_ARRAY_STRING(basilisk,balances,hash,vals,hexstr) { @@ -1172,16 +1160,26 @@ void basilisk_unspents_update(struct supernet_info *myinfo,struct iguana_info *c portable_mutex_lock(&myinfo->bu_mutex); if ( (retarray= cJSON_Parse(retstr)) != 0 ) { + printf("%s UNSPENTS_UPDATE.(%s)\n",coin->symbol,retstr); if ( jobj(retarray,"error") == 0 ) { if ( (jstr(retarray,"ipaddr") == 0 || strcmp(jstr(retarray,"ipaddr"),myinfo->ipaddr) != 0) && (n= cJSON_GetArraySize(retarray)) > 0 ) { - printf("n.%d GOT.(%s)\n",n,jprint(retarray,0)); for (i=0; icoin,0,0,rawtx->coin->changeaddr,"change")) == 0 ) @@ -560,7 +560,7 @@ int32_t basilisk_rawtx_gen(char *str,struct supernet_info *myinfo,struct basilis jaddnum(valsobj,"timeout",30000); rawtx->locktime = locktime; printf("%s locktime.%u\n",rawtx->name,locktime); - if ( (retstr= basilisk_rawtx(myinfo,rawtx->coin,0,0,myinfo->myaddr.persistent,valsobj,"")) != 0 ) + if ( (retstr= basilisk_bitcoinrawtx(myinfo,rawtx->coin,"",basilisktag,jint(valsobj,"timeout"),valsobj)) != 0 ) { printf("%s got.(%s)\n",str,retstr); flag = 0; @@ -578,7 +578,7 @@ int32_t basilisk_rawtx_gen(char *str,struct supernet_info *myinfo,struct basilis free(retarray); } else printf("error parsing.(%s)\n",retstr); free(retstr); - } else printf("error creating %s feetx\n",swap->iambob != 0 ? "BOB" : "ALICE"); + } else printf("error creating %s feetx\n",iambob != 0 ? "BOB" : "ALICE"); free_json(privkeyarray); free_json(valsobj); printf("rawtx retval.%d\n",retval); @@ -915,8 +915,7 @@ void basilisk_swap01(struct supernet_info *myinfo,struct basilisk_swap *swap,uin void basilisk_swap02(struct supernet_info *myinfo,struct basilisk_swap *swap,uint8_t *data,int32_t maxlen) { - if ( (rand() % 100) == 0 ) - basilisk_swap01(myinfo,swap,data,maxlen); + basilisk_swap01(myinfo,swap,data,maxlen); printf("check for other deck\n"); if ( basilisk_swapget(myinfo,swap,0x02,data,maxlen,basilisk_verify_otherdeck) == 0 ) swap->statebits |= 0x02; @@ -925,7 +924,7 @@ void basilisk_swap02(struct supernet_info *myinfo,struct basilisk_swap *swap,uin void basilisk_swap04(struct supernet_info *myinfo,struct basilisk_swap *swap,uint8_t *data,int32_t maxlen) { int32_t i,datalen; char str[65]; - if ( (rand() % 10) == 0 ) + //if ( (rand() % 10) == 0 ) basilisk_swap02(myinfo,swap,data,maxlen); datalen = iguana_rwnum(1,data,sizeof(swap->choosei),&swap->choosei); if ( swap->iambob != 0 ) @@ -950,7 +949,7 @@ void basilisk_swap04(struct supernet_info *myinfo,struct basilisk_swap *swap,uin void basilisk_swap08(struct supernet_info *myinfo,struct basilisk_swap *swap,uint8_t *data,int32_t maxlen) { uint8_t pubkey33[33]; char str[65]; - if ( (rand() % 10) == 0 ) + //if ( (rand() % 10) == 0 ) basilisk_swap04(myinfo,swap,data,maxlen); printf("check otherchoosei\n"); if ( basilisk_swapget(myinfo,swap,0x08,data,maxlen,basilisk_verify_choosei) == 0 ) @@ -1010,6 +1009,12 @@ void basilisk_swap10(struct supernet_info *myinfo,struct basilisk_swap *swap,uin swap->statebits |= basilisk_swapsend(myinfo,swap,0x20,data,datalen,0x10); } +void basilisk_alicepayment(struct supernet_info *myinfo,struct iguana_info *coin,struct basilisk_rawtx *alicepayment,bits256 pubAm,bits256 pubBn) +{ + alicepayment->spendlen = basilisk_alicescript(alicepayment->spendscript,0,alicepayment->destaddr,coin->chain->p2shtype,pubAm,pubBn); + basilisk_rawtx_gen("alicepayment",myinfo,0,1,alicepayment,alicepayment->locktime,alicepayment->spendscript,alicepayment->spendlen,coin->chain->txfee,1); +} + void basilisk_swaploop(void *_swap) { uint8_t *data; int32_t i,j,maxlen,datalen; struct supernet_info *myinfo; struct basilisk_swap *swap = _swap; @@ -1067,8 +1072,8 @@ void basilisk_swaploop(void *_swap) { swap->bobpayment.spendlen = basilisk_bobscript(swap->bobpayment.spendscript,0,&swap->bobpayment.locktime,&swap->bobpayment.secretstart,swap,0); swap->bobdeposit.spendlen = basilisk_bobscript(swap->bobdeposit.spendscript,0,&swap->bobdeposit.locktime,&swap->bobdeposit.secretstart,swap,1); - basilisk_rawtx_gen("deposit",myinfo,swap,1,&swap->bobdeposit,swap->bobdeposit.locktime,swap->bobdeposit.spendscript,swap->bobdeposit.spendlen,swap->bobdeposit.coin->chain->txfee,1); - basilisk_rawtx_gen("payment",myinfo,swap,1,&swap->bobpayment,swap->bobpayment.locktime,swap->bobpayment.spendscript,swap->bobpayment.spendlen,swap->bobpayment.coin->chain->txfee,1); + basilisk_rawtx_gen("deposit",myinfo,1,1,&swap->bobdeposit,swap->bobdeposit.locktime,swap->bobdeposit.spendscript,swap->bobdeposit.spendlen,swap->bobdeposit.coin->chain->txfee,1); + basilisk_rawtx_gen("payment",myinfo,1,1,&swap->bobpayment,swap->bobpayment.locktime,swap->bobpayment.spendscript,swap->bobpayment.spendlen,swap->bobpayment.coin->chain->txfee,1); if ( swap->bobdeposit.txbytes == 0 || swap->bobdeposit.spendlen == 0 || swap->bobpayment.txbytes == 0 || swap->bobpayment.spendlen == 0 ) { printf("error bob generating deposit.%d or payment.%d\n",swap->bobdeposit.spendlen,swap->bobpayment.spendlen); @@ -1077,15 +1082,14 @@ void basilisk_swaploop(void *_swap) } else { - swap->alicepayment.spendlen = basilisk_alicescript(swap->alicepayment.spendscript,0,swap->alicepayment.destaddr,swap->alicepayment.coin->chain->p2shtype,swap->pubAm,swap->pubBn); - basilisk_rawtx_gen("alicepayment",myinfo,swap,1,&swap->alicepayment,swap->alicepayment.locktime,swap->alicepayment.spendscript,swap->alicepayment.spendlen,swap->alicepayment.coin->chain->txfee,1); + basilisk_alicepayment(myinfo,swap->alicepayment.coin,&swap->alicepayment,swap->pubAm,swap->pubBn); if ( swap->alicepayment.txbytes == 0 || swap->alicepayment.spendlen == 0 ) { printf("error alice generating payment.%d\n",swap->alicepayment.spendlen); break; } } - if ( basilisk_rawtx_gen("myfee",myinfo,swap,1,&swap->myfee,0,swap->myfee.spendscript,swap->myfee.spendlen,swap->myfee.coin->chain->txfee,1) == 0 ) + if ( basilisk_rawtx_gen("myfee",myinfo,swap->iambob,1,&swap->myfee,0,swap->myfee.spendscript,swap->myfee.spendlen,swap->myfee.coin->chain->txfee,1) == 0 ) swap->statebits |= basilisk_swapdata_rawtxsend(myinfo,swap,0x80,data,maxlen,&swap->myfee,0x40); else { diff --git a/iguana/iguana_payments.c b/iguana/iguana_payments.c index e4a072d5d..d8f4d4349 100755 --- a/iguana/iguana_payments.c +++ b/iguana/iguana_payments.c @@ -190,8 +190,7 @@ int32_t iguana_bestunspent(struct supernet_info *myinfo,struct iguana_info *coin above = gap; abovei = i; } - } - gap = (value - atx_value); + } else gap = (value - atx_value); if ( below == 0 || gap < below ) { below = gap; @@ -361,7 +360,7 @@ char *iguana_calcrawtx(struct supernet_info *myinfo,struct iguana_info *coin,cJS max = 10000; satoshis += burnamount; unspents = calloc(max,sizeof(*unspents)); - if ( (num= iguana_unspentslists(myinfo,coin,&avail,unspents,max,satoshis,minconf,addresses,remoteaddr)) <= 0 ) + if ( (num= iguana_unspentslists(myinfo,coin,&avail,unspents,max,satoshis+txfee,minconf,addresses,remoteaddr)) <= 0 ) { free(unspents); return(0); @@ -468,7 +467,7 @@ char *sendtoaddress(struct supernet_info *myinfo,struct iguana_info *coin,char * jaddnum(valsobj,"timeout",30000); if ( comment != 0 && is_hexstr(comment,0) > 0 ) jaddstr(valsobj,"opreturn",comment); - if ( (retstr= basilisk_rawtx(myinfo,coin,0,0,myinfo->myaddr.persistent,valsobj,"")) != 0 ) + if ( (retstr= basilisk_bitcoinrawtx(myinfo,coin,remoteaddr,basilisktag,jint(valsobj,"timeout"),valsobj)) != 0 ) { if ( (retjson= cJSON_Parse(retstr)) != 0 ) { diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index 1bd61eae5..6d7966279 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -23,14 +23,14 @@ int32_t iguana_unspentind2txid(struct supernet_info *myinfo,struct iguana_info *coin,int32_t *spentheightp,bits256 *txidp,int32_t *voutp,int16_t hdrsi,uint32_t unspentind) { - struct iguana_ramchaindata *rdata=0; struct iguana_bundle *bp; struct iguana_unspent *U,*u; struct iguana_txid *T,*t; + struct iguana_ramchaindata *rdata=0; struct iguana_bundle *bp=0; struct iguana_unspent *U,*u; struct iguana_txid *T,*t; *voutp = *spentheightp = -1; memset(txidp,0,sizeof(*txidp)); if ( hdrsi < coin->bundlescount-1 ) rdata = coin->RTramchain.H.data; else if ( (bp= coin->bundles[hdrsi]) != 0 ) rdata = bp->ramchain.H.data; - if ( rdata != 0 && unspentind > 0 && unspentind < rdata->numunspents ) + while ( rdata != 0 && unspentind > 0 && unspentind < rdata->numunspents ) { U = RAMCHAIN_PTR(rdata,Uoffset); u = &U[unspentind]; @@ -46,6 +46,9 @@ int32_t iguana_unspentind2txid(struct supernet_info *myinfo,struct iguana_info * return(0); } } + else if ( bp == 0 && (bp= coin->bundles[hdrsi]) != 0 ) + rdata = bp->ramchain.H.data; + else break; } return(-1); } diff --git a/includes/iguana_apideclares.h b/includes/iguana_apideclares.h index b1575aed9..d839e8025 100755 --- a/includes/iguana_apideclares.h +++ b/includes/iguana_apideclares.h @@ -28,7 +28,7 @@ HASH_ARRAY_STRING(basilisk,history,hash,vals,hexstr); HASH_ARRAY_STRING(basilisk,balances,hash,vals,hexstr); HASH_ARRAY_STRING(basilisk,value,hash,vals,hexstr); -HASH_ARRAY_STRING(basilisk,rawtx,hash,vals,hexstr); +//HASH_ARRAY_STRING(basilisk,rawtx,hash,vals,hexstr); HASH_ARRAY_STRING(basilisk,getmessage,hash,vals,hexstr); HASH_ARRAY_STRING(basilisk,sendmessage,hash,vals,hexstr); diff --git a/includes/iguana_funcs.h b/includes/iguana_funcs.h index 660c1bbda..ee7f2bcad 100755 --- a/includes/iguana_funcs.h +++ b/includes/iguana_funcs.h @@ -474,6 +474,7 @@ void datachain_update_spend(struct supernet_info *myinfo,int32_t ordered,struct cJSON *bitcoin_data2json(struct iguana_info *coin,bits256 *txidp,struct iguana_msgtx *msgtx,uint8_t *extraspace,int32_t extralen,uint8_t *serialized,int32_t len); int32_t iguana_unspentind2txid(struct supernet_info *myinfo,struct iguana_info *coin,int32_t *spentheightp,bits256 *txidp,int32_t *voutp,int16_t hdrsi,uint32_t unspentind); int32_t iguana_unspent_check(struct supernet_info *myinfo,struct iguana_info *coin,uint16_t hdrsi,uint32_t unspentind); +char *basilisk_bitcoinrawtx(struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,uint32_t basilisktag,int32_t timeoutmillis,cJSON *valsobj); char *iguana_signrawtx(struct supernet_info *myinfo,struct iguana_info *coin,bits256 *signedtxidp,int32_t *completedp,cJSON *vins,char *rawtx,cJSON *privkey,struct vin_info *V); bits256 scrypt_blockhash(const void *input);