diff --git a/basilisk/basilisk.h b/basilisk/basilisk.h index a0318431a..b4153a51a 100755 --- a/basilisk/basilisk.h +++ b/basilisk/basilisk.h @@ -17,7 +17,7 @@ #define H_BASILISK_H #define BASILISK_DISABLEWAITTX -//#define BASILISK_DISABLETX +#define BASILISK_DISABLETX #include "../iguana/iguana777.h" diff --git a/basilisk/basilisk_MSG.c b/basilisk/basilisk_MSG.c index 7b78e3aa5..6033c114e 100755 --- a/basilisk/basilisk_MSG.c +++ b/basilisk/basilisk_MSG.c @@ -198,7 +198,7 @@ char *basilisk_respond_addmessage(struct supernet_info *myinfo,uint8_t *key,int3 { if ( memcmp(msg->data,data,datalen) != 0 ) { - printf("overwrite update of msg.[%d] <- datalen.%d\n",msg->datalen,datalen); + //printf("overwrite update of msg.[%d] <- datalen.%d\n",msg->datalen,datalen); memcpy(msg->data,data,datalen); if ( sendping != 0 ) queue_enqueue("basilisk_message",&myinfo->msgQ,&msg->DL,0); diff --git a/basilisk/basilisk_swap.c b/basilisk/basilisk_swap.c index c3f66571f..544b85bc4 100755 --- a/basilisk/basilisk_swap.c +++ b/basilisk/basilisk_swap.c @@ -190,34 +190,34 @@ bits256 basilisk_swap_broadcast(char *name,struct supernet_info *myinfo,struct b int32_t basilisk_rawtx_sign(struct supernet_info *myinfo,int32_t height,struct basilisk_swap *swap,struct basilisk_rawtx *dest,struct basilisk_rawtx *rawtx,bits256 privkey,bits256 *privkey2,uint8_t *userdata,int32_t userdatalen) { - char *rawtxbytes,*signedtx,hexstr[999],wifstr[128]; cJSON *txobj,*vins,*item,*sobj,*privkeys; int32_t retval = -1; struct vin_info V; uint32_t locktime=0; - memset(&V,0,sizeof(V)); + char *rawtxbytes,*signedtx,hexstr[999],wifstr[128]; cJSON *txobj,*vins,*item,*sobj,*privkeys; int32_t retval = -1; struct vin_info *V; uint32_t locktime=0; + V = calloc(16,sizeof(*V)); if ( dest == &swap->aliceclaim ) locktime = swap->locktime + INSTANTDEX_LOCKTIME; - V.signers[0].privkey = privkey; - bitcoin_pubkey33(myinfo->ctx,V.signers[0].pubkey,privkey); + V[0].signers[0].privkey = privkey; + bitcoin_pubkey33(myinfo->ctx,V[0].signers[0].pubkey,privkey); privkeys = cJSON_CreateArray(); bitcoin_priv2wif(wifstr,privkey,rawtx->coin->chain->wiftype); jaddistr(privkeys,wifstr); if ( privkey2 != 0 ) { - V.signers[1].privkey = *privkey2; - bitcoin_pubkey33(myinfo->ctx,V.signers[1].pubkey,*privkey2); + V[0].signers[1].privkey = *privkey2; + bitcoin_pubkey33(myinfo->ctx,V[0].signers[1].pubkey,*privkey2); bitcoin_priv2wif(wifstr,*privkey2,rawtx->coin->chain->wiftype); jaddistr(privkeys,wifstr); - V.N = V.M = 2; + V[0].N = V[0].M = 2; char str[65]; printf("add second privkey.(%s) %s\n",jprint(privkeys,0),bits256_str(str,*privkey2)); - } else V.N = V.M = 1; - V.suppress_pubkeys = dest->suppress_pubkeys; + } else V[0].N = V[0].M = 1; + V[0].suppress_pubkeys = dest->suppress_pubkeys; if ( dest->redeemlen != 0 ) - memcpy(V.p2shscript,dest->redeemscript,dest->redeemlen), V.p2shlen = dest->redeemlen; + memcpy(V[0].p2shscript,dest->redeemscript,dest->redeemlen), V[0].p2shlen = dest->redeemlen; txobj = bitcoin_txcreate(rawtx->coin->chain->isPoS,locktime,rawtx->coin->chain->locktime_txversion); vins = cJSON_CreateArray(); item = cJSON_CreateObject(); if ( userdata != 0 && userdatalen > 0 ) { - memcpy(V.userdata,userdata,userdatalen); - V.userdatalen = userdatalen; + memcpy(V[0].userdata,userdata,userdatalen); + V[0].userdatalen = userdatalen; init_hexbytes_noT(hexstr,userdata,userdatalen); jaddstr(item,"userdata",hexstr); } @@ -243,10 +243,10 @@ int32_t basilisk_rawtx_sign(struct supernet_info *myinfo,int32_t height,struct b jadd(txobj,"vin",vins); printf("basilisk_rawtx_sign locktime.%u/%u for %s spendscript.%s -> %s, suppress.%d\n",rawtx->locktime,dest->locktime,rawtx->name,hexstr,dest->name,dest->suppress_pubkeys); txobj = bitcoin_txoutput(txobj,dest->spendscript,dest->spendlen,dest->amount); - if ( (rawtxbytes= bitcoin_json2hex(myinfo,rawtx->coin,&dest->txid,txobj,&V)) != 0 ) + if ( (rawtxbytes= bitcoin_json2hex(myinfo,rawtx->coin,&dest->txid,txobj,V)) != 0 ) { printf("(%s) spend.%s rawtx.(%s) userdatalen.%d p2shlen.%d\n",jprint(txobj,0),rawtx->name,rawtxbytes,userdatalen,dest->redeemlen); - if ( (signedtx= iguana_signrawtx(myinfo,rawtx->coin,height,&dest->signedtxid,&dest->completed,vins,rawtxbytes,privkeys,&V)) != 0 ) + if ( (signedtx= iguana_signrawtx(myinfo,rawtx->coin,height,&dest->signedtxid,&dest->completed,vins,rawtxbytes,privkeys,V)) != 0 ) { printf("rawtx spend signedtx.(%s)\n",signedtx); dest->datalen = (int32_t)strlen(signedtx) >> 1; @@ -514,7 +514,9 @@ uint32_t basilisk_swaprecv(struct supernet_info *myinfo,uint8_t *verifybuf,int32 } free_json(retarray); if ( (crc= basilisk_majority32(datalenp,rawcrcs,datalens,numcrcs)) != 0 ) - printf("have majority crc.%08x\n",crc); + { + //printf("have majority crc.%08x\n",crc); + } //else printf("no majority from rawcrcs.%d\n",numcrcs); } return(crc); @@ -651,11 +653,51 @@ int32_t instantdex_pubkeyargs(struct supernet_info *myinfo,struct basilisk_swap return(n); } -int32_t basilisk_rawtx_return(struct supernet_info *myinfo,int32_t height,struct basilisk_rawtx *rawtx,cJSON *item,cJSON *privkeyarray,int32_t lockinputs,struct vin_info *V) +cJSON *basilisk_privkeyarray(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *vins) { - char *signedtx,*txbytes; cJSON *vins; int32_t i,n,retval = -1; + cJSON *privkeyarray,*item,*sobj; struct iguana_waddress *waddr; struct iguana_waccount *wacct; char coinaddr[64],account[128],wifstr[64],str[65],*hexstr; uint8_t script[1024]; int32_t i,n,len,vout; bits256 txid; + privkeyarray = cJSON_CreateArray(); + //printf("%s persistent.(%s) (%s) change.(%s) scriptstr.(%s)\n",coin->symbol,myinfo->myaddr.BTC,coinaddr,coin->changeaddr,scriptstr); + if ( (n= cJSON_GetArraySize(vins)) > 0 ) + { + for (i=0; i= 0 ) + { + iguana_txidcategory(myinfo,coin,account,coinaddr,txid,vout); + if ( coinaddr[0] == 0 && (sobj= jobj(item,"scriptPubKey")) != 0 && (hexstr= jstr(sobj,"hex")) != 0 && is_hexstr(hexstr,0) > 0 ) + { + len = (int32_t)strlen(hexstr) >> 1; + if ( len < (sizeof(script) << 1) ) + { + decode_hex(script,len,hexstr); + if ( len == 25 && script[0] == 0x76 && script[1] == 0xa9 && script[2] == 0x14 ) + bitcoin_address(coinaddr,coin->chain->pubtype,script+3,20); + } + } + if ( coinaddr[0] != 0 ) + { + if ( (waddr= iguana_waddresssearch(myinfo,&wacct,coinaddr)) != 0 ) + { + bitcoin_priv2wif(wifstr,waddr->privkey,coin->chain->wiftype); + jaddistr(privkeyarray,waddr->wifstr); + } else printf("cant find (%s) in wallet\n",coinaddr); + } else printf("cant coinaddr from (%s).v%d\n",bits256_str(str,txid),vout); + } else printf("invalid txid/vout %d of %d\n",i,n); + } + } + return(privkeyarray); +} + +int32_t basilisk_rawtx_return(struct supernet_info *myinfo,int32_t height,struct basilisk_rawtx *rawtx,cJSON *item,int32_t lockinputs,struct vin_info *V) +{ + char *signedtx,*txbytes; cJSON *vins,*privkeyarray; int32_t i,n,retval = -1; if ( (txbytes= jstr(item,"rawtx")) != 0 && (vins= jobj(item,"vins")) != 0 ) { + privkeyarray = basilisk_privkeyarray(myinfo,rawtx->coin,vins); if ( (signedtx= iguana_signrawtx(myinfo,rawtx->coin,height,&rawtx->signedtxid,&rawtx->completed,vins,txbytes,privkeyarray,V)) != 0 ) { if ( lockinputs != 0 ) @@ -679,33 +721,23 @@ int32_t basilisk_rawtx_return(struct supernet_info *myinfo,int32_t height,struct free(signedtx); retval = 0; } else printf("error signrawtx\n"); //do a very short timeout so it finishes via local poll + free_json(privkeyarray); } return(retval); } int32_t basilisk_rawtx_gen(char *str,struct supernet_info *myinfo,int32_t iambob,int32_t lockinputs,struct basilisk_rawtx *rawtx,uint32_t locktime,uint8_t *script,int32_t scriptlen,int64_t txfee,int32_t minconf) { - struct iguana_waddress *waddr; struct iguana_waccount *wacct; char coinaddr[64],wifstr[64],*retstr,scriptstr[1024]; uint32_t basilisktag; int32_t flag,i,n,retval = -1; cJSON *valsobj,*retarray=0,*privkeyarray,*addresses; struct vin_info *V; - //if ( (waddr= iguana_getaccountaddress(myinfo,rawtx->coin,0,0,rawtx->coin->changeaddr,"change")) == 0 ) + char *retstr,scriptstr[1024]; uint32_t basilisktag; int32_t flag,i,n,retval = -1; cJSON *valsobj,*retarray=0; struct vin_info *V; + //bitcoin_address(coinaddr,rawtx->coin->chain->pubtype,myinfo->persistent_pubkey33,33); if ( rawtx->coin->changeaddr[0] == 0 ) { bitcoin_address(rawtx->coin->changeaddr,rawtx->coin->chain->pubtype,myinfo->persistent_pubkey33,33); printf("set change address.(%s)\n",rawtx->coin->changeaddr); } init_hexbytes_noT(scriptstr,script,scriptlen); - privkeyarray = cJSON_CreateArray(); - addresses = cJSON_CreateArray(); - bitcoin_address(coinaddr,rawtx->coin->chain->pubtype,myinfo->persistent_pubkey33,33); - //printf("%s persistent.(%s) (%s) change.(%s) scriptstr.(%s)\n",coin->symbol,myinfo->myaddr.BTC,coinaddr,coin->changeaddr,scriptstr); - if ( (waddr= iguana_waddresssearch(myinfo,&wacct,coinaddr)) != 0 ) - { - bitcoin_priv2wif(wifstr,waddr->privkey,rawtx->coin->chain->wiftype); - jaddistr(privkeyarray,waddr->wifstr); - } basilisktag = (uint32_t)rand(); - jaddistr(addresses,coinaddr); valsobj = cJSON_CreateObject(); - //jadd(valsobj,"addresses",addresses); jaddstr(valsobj,"coin",rawtx->coin->symbol); jaddstr(valsobj,"spendscript",scriptstr); jaddstr(valsobj,"changeaddr",rawtx->coin->changeaddr); @@ -728,15 +760,14 @@ int32_t basilisk_rawtx_gen(char *str,struct supernet_info *myinfo,int32_t iambob n = cJSON_GetArraySize(retarray); for (i=0; icoin->blocks.hwmchain.height,rawtx,jitem(retarray,i),privkeyarray,lockinputs,V)) == 0 ) + if ( (retval= basilisk_rawtx_return(myinfo,rawtx->coin->blocks.hwmchain.height,rawtx,jitem(retarray,i),lockinputs,V)) == 0 ) break; } - } else retval = basilisk_rawtx_return(myinfo,rawtx->coin->blocks.hwmchain.height,rawtx,retarray,privkeyarray,lockinputs,V); + } else retval = basilisk_rawtx_return(myinfo,rawtx->coin->blocks.hwmchain.height,rawtx,retarray,lockinputs,V); free(retarray); } else printf("error parsing.(%s)\n",retstr); free(retstr); } else printf("error creating %s feetx\n",iambob != 0 ? "BOB" : "ALICE"); - free_json(privkeyarray); free_json(valsobj); free(V); return(retval); @@ -1044,13 +1075,16 @@ int32_t basilisk_verify_privkeys(struct supernet_info *myinfo,void *ptr,uint8_t uint32_t basilisk_swapdata_rawtxsend(struct supernet_info *myinfo,struct basilisk_swap *swap,uint32_t msgbits,uint8_t *data,int32_t maxlen,struct basilisk_rawtx *rawtx,uint32_t nextbits) { - if ( basilisk_swapdata_rawtx(myinfo,swap,data,maxlen,rawtx) != 0 && bits256_nonz(rawtx->signedtxid) != 0 && bits256_nonz(rawtx->actualtxid) == 0 ) + if ( basilisk_swapdata_rawtx(myinfo,swap,data,maxlen,rawtx) != 0 ) { - rawtx->actualtxid = basilisk_swap_broadcast(rawtx->name,myinfo,swap,rawtx->coin,rawtx->txbytes,rawtx->datalen); - char str[65],str2[65]; printf("rawtxsend %s vs %s\n",bits256_str(str,rawtx->signedtxid),bits256_str(str2,rawtx->actualtxid)); - if ( bits256_nonz(rawtx->actualtxid) != 0 && msgbits != 0 ) - return(basilisk_swapsend(myinfo,swap,msgbits,rawtx->txbytes,rawtx->datalen,nextbits,rawtx->crcs)); - else return(nextbits); + if ( bits256_nonz(rawtx->signedtxid) != 0 && bits256_nonz(rawtx->actualtxid) == 0 ) + { + rawtx->actualtxid = basilisk_swap_broadcast(rawtx->name,myinfo,swap,rawtx->coin,rawtx->txbytes,rawtx->datalen); + char str[65],str2[65]; printf("rawtxsend %s vs %s\n",bits256_str(str,rawtx->signedtxid),bits256_str(str2,rawtx->actualtxid)); + if ( bits256_nonz(rawtx->actualtxid) != 0 && msgbits != 0 ) + return(basilisk_swapsend(myinfo,swap,msgbits,rawtx->txbytes,rawtx->datalen,nextbits,rawtx->crcs)); + } + return(nextbits); } else printf("error from basilisk_swapdata_rawtx %p len.%d\n",rawtx->txbytes,rawtx->datalen); return(0); } diff --git a/iguana/iguana777.c b/iguana/iguana777.c index 7c2693584..bb13de595 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -880,7 +880,7 @@ void iguana_coinloop(void *arg) if ( coin->started == 0 && coin->active != 0 ) { iguana_callcoinstart(myinfo,coin); - if ( 1 && strcmp("BTC",coin->symbol) == 0 ) + if ( 0 && strcmp("BTC",coin->symbol) == 0 ) { char *txstr = "0100000001d378ebd1b0c230b4d078288cf95fe28d7b3032d28c47de22ed6140d845dcb01f00000000d147304402204dd322834ff15cf1526dae3940521bb504b365b194515725d9c0f81dfbeae68d02205fb8fd269e3f2ddf7d0a17b056d2904ce572b8f22edeb39cd4c209fcf5244645011d74c7e7d8a2041be600e74708276d79ff001e754269b6e868ccf517f87f3d004c674c6763040cd6e557b175210326af93b75917b4903d7acdf8e2a560357ce18b7615cc7de02ade4f62861a57dfac67a9149c41c06aac6a7fcfd29eef87c4a633b9126b8b09882102a9669e63ef1ab04913615c2f3887ea3584f81e5f08feee9535b19ab3739d8afdac68ffffffff01127b0000000000001976a914b7128d2ee837cf03e30a2c0e3e0181f7b9669bb688ac00000000"; cJSON *txobj = cJSON_Parse("{\"version\":1,\"locktime\":1474666158,\"vin\":[{\"userdata\":\"51\",\"txid\":\"fc97c3675c83c09723e0b14292ddec73820cb7352166ace4fe81ed62568315f2\",\"vout\":0,\"scriptPubKey\":{\"hex\":\"a914b7a2e599edb55d3f78ebcbfd49e82dd9a12adc2487\"},\"suppress\":1,\"sequence\":0,\"redeemScript\":\"6304ae9ee557b1752102a9669e63ef1ab04913615c2f3887ea3584f81e5f08feee9535b19ab3739d8afdac67a914adfad35d6646a0514011ba6ab53462319b651f96882103225046c9947222ab04acdefe2ed5dec4dcb593c5e6ae58e2c61c7ace14d81b70ac68\"}],\"vout\":[{\"satoshis\":\"36042\",\"scriptPubkey\":{\"hex\":\"76a914b7128d2ee837cf03e30a2c0e3e0181f7b9669bb688ac\"}}]}"); diff --git a/iguana/iguana_payments.c b/iguana/iguana_payments.c index d126ed352..4e89be337 100755 --- a/iguana/iguana_payments.c +++ b/iguana/iguana_payments.c @@ -489,7 +489,7 @@ char *sendtoaddress(struct supernet_info *myinfo,struct iguana_info *coin,char * { if ( (rawtx= jstr(retjson,"rawtx")) != 0 && (vins= jobj(retjson,"vins")) != 0 ) { - if ( (signedtx= iguana_signrawtx(myinfo,coin,coin->blocks.hwmchain.height,&signedtxid,&completed,vins,rawtx,0,0)) != 0 ) + if ( (signedtx= iguana_signrawtx(myinfo,coin,coin->blocks.hwmchain.height,&signedtxid,&completed,vins,rawtx,0,V)) != 0 ) { iguana_RTunspentslock(myinfo,coin,vins); retjson = cJSON_CreateObject(); @@ -1287,10 +1287,11 @@ ARRAY_OBJ_INT(bitcoinrpc,createrawtransaction,vins,vouts,locktime) cJSON *iguana_listunspents(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *array,int32_t minconf,int32_t maxconf,char *remoteaddr) { cJSON *retjson; int32_t flag = 0; - if ( array == 0 ) + if ( array == 0 || is_cJSON_Array(array) == 0 || cJSON_GetArraySize(array) <= 0 ) { array = iguana_getaddressesbyaccount(myinfo,coin,"*"); flag = 1; + //printf("listunspent.(%s)\n",jprint(array,0)); } if ( minconf == 0 ) minconf = 1; diff --git a/iguana/iguana_realtime.c b/iguana/iguana_realtime.c index 9b06d66a0..e23463266 100755 --- a/iguana/iguana_realtime.c +++ b/iguana/iguana_realtime.c @@ -511,6 +511,7 @@ int64_t iguana_txidamount(struct supernet_info *myinfo,struct iguana_info *coin, char *iguana_txidcategory(struct supernet_info *myinfo,struct iguana_info *coin,char *account,char *coinaddr,bits256 txid,int32_t vout) { struct iguana_outpoint outpt; struct iguana_waccount *wacct; struct iguana_waddress *waddr; int32_t ismine=0,spendlen,height = 0; uint64_t value; uint8_t spendscript[IGUANA_MAXSCRIPTSIZE]; + coinaddr[0] = 0; iguana_RTunspentindfind(myinfo,coin,&outpt,coinaddr,spendscript,&spendlen,&value,&height,txid,vout,(coin->firstRTheight/coin->chain->bundlesize) - 1,0); account[0] = 0; if ( coinaddr[0] != 0 ) diff --git a/iguana/iguana_sign.c b/iguana/iguana_sign.c index ac940699a..897af9930 100755 --- a/iguana/iguana_sign.c +++ b/iguana/iguana_sign.c @@ -53,7 +53,7 @@ int32_t iguana_vinparse(struct iguana_info *coin,int32_t rwflag,uint8_t *seriali printf("iguana_vinparse illegal scriptlen.%d\n",msg->scriptlen); return(-1); } - //printf("len.%d scriptlen.%d user.%d p2sh.%d\n",len,msg->scriptlen,msg->userdatalen,msg->p2shlen); + printf("len.%d scriptlen.%d user.%d p2sh.%d\n",len,msg->scriptlen,msg->userdatalen,msg->p2shlen); if ( rwflag == 0 ) { msg->vinscript = &serialized[len]; @@ -93,7 +93,7 @@ int32_t iguana_vinparse(struct iguana_info *coin,int32_t rwflag,uint8_t *seriali } } } - //printf("sequence starts.%d\n",len); + printf("sequence starts.%d %08x\n",len,*(int32_t *)&serialized[len]); len += iguana_rwnum(rwflag,&serialized[len],sizeof(msg->sequence),&msg->sequence); if ( 0 ) { @@ -358,22 +358,14 @@ int32_t iguana_parsevinobj(struct supernet_info *myinfo,struct iguana_info *coin } } tmp = (len - endi); - if ( tmp < 0x100 ) + if ( tmp < 0xfd ) { serialized[starti] = tmp; for (i=starti+1; i> 8) & 0xff); } - //printf("len.%d tmp.%d output sequence.[%d] <- %x\n",len,tmp,len,vin->sequence); + printf("len.%d tmp.%d output sequence.[%d] <- %x\n",len,tmp,len,vin->sequence); len += iguana_rwnum(rwflag,&serialized[len],sizeof(vin->sequence),&vin->sequence); if ( spendstr != 0 ) { @@ -585,14 +577,14 @@ int32_t iguana_rwmsgtx(struct iguana_info *coin,int32_t height,int32_t rwflag,cJ } for (i=0; itx_in; i++) { - //printf("vin.%d starts offset.%d\n",i,len); + printf("vin.%d starts offset.%d\n",i,len); if ( vins != 0 && jitem(vins,i) != 0 ) iguana_vinobjset(&msg->vins[i],jitem(vins,i),spendscript,sizeof(spendscript)); if ( (n= iguana_vinparse(coin,rwflag,&serialized[len],&msg->vins[i])) < 0 ) return(-1); if ( msg->vins[i].spendscript == spendscript ) msg->vins[i].spendscript = 0; - //printf("vin.%d n.%d len.%d\n",i,n,len); + printf("vin.%d n.%d len.%d\n",i,n,len); len += n; if ( len > maxsize ) { @@ -600,6 +592,9 @@ int32_t iguana_rwmsgtx(struct iguana_info *coin,int32_t height,int32_t rwflag,cJ return(-1); } } + for (i=0; i<4; i++) + printf("%02x",serialized[len+i]); + printf(" len.%d\n",len); len += iguana_rwvarint32(rwflag,&serialized[len],&msg->tx_out); if ( rwflag == 0 ) { @@ -657,6 +652,7 @@ int32_t iguana_rwmsgtx(struct iguana_info *coin,int32_t height,int32_t rwflag,cJ { for (i=0; itx_in; i++) { + memset(sigtxid.bytes,0,sizeof(sigtxid)); if ( vins != 0 && jitem(vins,i) != 0 ) { iguana_vinobjset(&msg->vins[i],jitem(vins,i),spendscript,sizeof(spendscript)); @@ -665,7 +661,7 @@ int32_t iguana_rwmsgtx(struct iguana_info *coin,int32_t height,int32_t rwflag,cJ jaddi(vinarray,iguana_vinjson(coin,&msg->vins[i],sigtxid)); if ( msg->vins[i].spendscript == spendscript ) msg->vins[i].spendscript = 0; - } + } else jaddi(vinarray,iguana_vinjson(coin,&msg->vins[i],sigtxid)); } free(sigser); jadd(json,"vin",vinarray); @@ -1395,10 +1391,16 @@ int32_t iguana_signrawtransaction(struct supernet_info *myinfo,struct iguana_inf privkeystr = jstr(item,0); privkey = iguana_str2priv(myinfo,coin,privkeystr); V->signers[i].privkey = privkey; + if ( i < numinputs ) + V[i].signers[0].privkey = privkey; if ( bits256_nonz(privkey) != 0 ) iguana_ensure_privkey(myinfo,coin,privkey); if ( V->suppress_pubkeys == 0 && bitcoin_pubkeylen(V->signers[i].pubkey) <= 0 ) + { bitcoin_pubkey33(myinfo->ctx,V->signers[i].pubkey,privkey); + if ( i < numinputs ) + memcpy(V[i].signers[0].pubkey,V->signers[i].pubkey,bitcoin_pubkeylen(V->signers[i].pubkey)); + } } } finalized = iguana_vininfo_create(myinfo,coin,serialized2,maxsize,msgtx,vins,numinputs,V); diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index 463fb2658..ea189f4ac 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -623,7 +623,7 @@ int32_t iguana_RTpkhasharray(struct supernet_info *myinfo,struct iguana_info *co p = (P == 0) ? &_p : &P[n]; if ( (netbalance= iguana_RTpkhashbalance(myinfo,coin,array,&spent,unspents != 0 ? &unspents[numunspents] : 0,&m,ramchain,p,lastpt,rmd160,coinaddr,pubkey33,lastheight,minconf,maxconf,remoteaddr,includespent)) != deposits-spent && lastheight == IGUANA_MAXHEIGHT && minconf == 1 && maxconf > coin->blocks.hwmchain.height ) { - printf("pkhash balance mismatch from m.%d check %.8f vs %.8f spent %.8f [%.8f]\n",m,dstr(netbalance),dstr(deposits),dstr(spent),dstr(deposits)-dstr(spent)); + printf("%s pkhash balance mismatch from m.%d check %.8f vs %.8f spent %.8f [%.8f]\n",coin->symbol,m,dstr(netbalance),dstr(deposits),dstr(spent),dstr(deposits)-dstr(spent)); } else { diff --git a/iguana/tests/decoderawtransaction b/iguana/tests/decoderawtransaction index db79d437c..2ff5c203a 100755 --- a/iguana/tests/decoderawtransaction +++ b/iguana/tests/decoderawtransaction @@ -1 +1 @@ -curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"decoderawtransaction\",\"params\":[\"0100000032b8e5570186712083e8eb8139eef3c559086847cf60e90505afb4531e750c535fa6c19e1100000000fd1e0100483045022100880a1e3eafade4d4a24dd0bde2f31178d43978beacd63da1ee54760e0651f3b2022061dd05a66b65dc40fb729d95d2205dbf054ceb0bc4eb55c42088d0684a4c5a6701483045022100b4498798fc3a61de0b6df83ea4f6b67f89c5683124c2a3a981bd070826d7d1590220121d73d362b796583baa73c8c78eb851f78dc8f1cc75cb5bb3dfb14d6b843742012102ed1e99e73093c70c6156bce5954cb3e04215405ac06aa525ff942b74b8416efc2103a013a5f01afb3f0f00a657bb76fb30fd38437c80b52d9248b50738c96902e78747522102ed1e99e73093c70c6156bce5954cb3e04215405ac06aa525ff942b74b8416efc2103a013a5f01afb3f0f00a657bb76fb30fd38437c80b52d9248b50738c96902e78752aeffffffff01706f9800000000001976a9148ee61a3161993f4f7b7081259bf5f3322d65d3f888ac00000000\", 1]}" +curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTC\",\"method\":\"decoderawtransaction\",\"params\":[\"010000000185631df219cbeda9f01d81d5b7726c11d07b2dd407dac1477954735200cbe39f00000000d147304402202d78b403de6fb436f101e71318d2936483a4d7ced347d8bf3e8e0b532595a77602203afdc33a494bffb9a0ed59c3620bc685103fcac870e22b769c1f29f637da56d70120030bd21a1c1b778d0b853ec0d6f66c42493ac70993c38ef4ebf7f1fddce3af4c004c67630462fde757b175210326af93b75917b4903d7acdf8e2a560357ce18b7615cc7de02ade4f62861a57dfac67a9144c73b3118e8f55b635d865ed6c3adc21640921a2882102a9669e63ef1ab04913615c2f3887ea3584f81e5f08feee9535b19ab3739d8afdac68ffffffff014f7c0000000000001976a914b7128d2ee837cf03e30a2c0e3e0181f7b9669bb688ac00000000\", 1]}" diff --git a/iguana/tests/decoderawtransactionB b/iguana/tests/decoderawtransactionB index 695f44691..d39eea7fc 100755 --- a/iguana/tests/decoderawtransactionB +++ b/iguana/tests/decoderawtransactionB @@ -1 +1 @@ -curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"decoderawtransaction\",\"params\":[\"01000000e37486570105cbd4d0058c3d7842966917456cbb4202ba90489abaa142dc093755b10a077d010000000100ffffffff0200e1f505000000004752210211a23a9bbbb43784b0b0198bab1cc6dbf2bab6cf3dd96a428ec6916267c80e70210372e08a8a353ba0190f513b3980d8229f4afecddbf014052199799875a924e56752ae50677235000000001976a914c210f6711e98fe9971757ede2b2dcb0507f3f25e88ac00000000\"]}" +curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"decoderawtransaction\",\"params\":[\"010000006ec3e757037d0cc86e035925e05cf9e74d617eee29bb27e104abd67eb1ef460e11b8168565010000006a47304402205c1e05feb6600b6aeb2d137732c68e7606c295753e789567e240e1fc0d612e7d0220311b1c4ede3875f03547c56601b252bcc312d3029352386d5386525e943d7bc00121020e0f6fe6e0fcdcac541eb728d6fe538a12adff20412b3c8a7fa892b223a47c2ffffffffff33b60bdf91eb44b591b8c1ddf34967cd44998c7b5998bac00c3836efc053e6b0100000000ffffffffd81462bcf9ae707b555a4d4c15cb3220536580533354b2e8a0e36cc25bf19d290100000000ffffffff02809698000000000017a914660c0752e834a73f50f9f0df3ebd7f720010037887e0ac4a05000000001976a914b7128d2ee837cf03e30a2c0e3e0181f7b9669bb688ac00000000\"]}" diff --git a/iguana/tests/listunspent2 b/iguana/tests/listunspent2 index 58c40a3ae..4d650562d 100755 --- a/iguana/tests/listunspent2 +++ b/iguana/tests/listunspent2 @@ -1 +1 @@ -curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"listunspent\",\"params\":[1, 9999999, [\"RDbGxL8QYdEp8sMULaVZS2E6XThcTKT9Jd\"]]}" +curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"listunspent\",\"params\":[1, 9999999, []]}"