diff --git a/iguana/iguana777.h b/iguana/iguana777.h index 61bd7ce88..0c097f9ba 100755 --- a/iguana/iguana777.h +++ b/iguana/iguana777.h @@ -960,6 +960,7 @@ int32_t iguana_signrawtransaction(struct supernet_info *myinfo,struct iguana_inf cJSON *iguana_privkeysjson(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *vins); char *iguana_inputaddress(struct iguana_info *coin,char *coinaddr,cJSON *vinobj); struct iguana_waddress *iguana_getaccountaddress(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *json,char *remoteaddr,char *coinaddr,char *account); +int32_t iguana_uvaltxid(struct supernet_info *myinfo,bits256 *txidp,struct iguana_info *coin,int16_t hdrsi,uint32_t unspentind); extern int32_t HDRnet,netBLOCKS; diff --git a/iguana/iguana_payments.c b/iguana/iguana_payments.c index 9201a6c88..e8a6bfbcb 100755 --- a/iguana/iguana_payments.c +++ b/iguana/iguana_payments.c @@ -940,19 +940,64 @@ TWOINTS_AND_ARRAY(bitcoinrpc,listunspent,minconf,maxconf,array) return(jprint(retjson,1)); } -INT_AND_ARRAY(bitcoinrpc,lockunspent,flag,array) +ZERO_ARGS(bitcoinrpc,getrawchangeaddress) { if ( remoteaddr != 0 ) return(clonestr("{\"error\":\"no remote\"}")); cJSON *retjson = cJSON_CreateObject(); + jaddstr(retjson,"result",coin->changeaddr); + return(jprint(retjson,1)); +} + +INT_AND_ARRAY(bitcoinrpc,lockunspent,flag,array) +{ + int32_t RTspendflag,vout,hdrsi,i,n,height; cJSON *item,*retjson; bits256 txid; uint32_t unspentind; + if ( remoteaddr != 0 ) + return(clonestr("{\"error\":\"no remote\"}")); + retjson = cJSON_CreateObject(); + if ( array != 0 && (n= cJSON_GetArraySize(array)) > 0 ) + { + for (i=0; ibundlescount-1)) != 0 ) + { + hdrsi = height / coin->chain->bundlesize; + iguana_utxofind(coin,hdrsi,unspentind,&RTspendflag,!flag); + } + } + } + } return(jprint(retjson,1)); } ZERO_ARGS(bitcoinrpc,listlockunspent) { + cJSON *array,*item,*retjson; bits256 txid; struct iguana_hhutxo *hhutxo,*tmputxo; int32_t hdrsi,vout; uint32_t unspentind; if ( remoteaddr != 0 ) return(clonestr("{\"error\":\"no remote\"}")); - cJSON *retjson = cJSON_CreateObject(); + array = cJSON_CreateArray(); + retjson = cJSON_CreateObject(); + if ( coin->utxotable != 0 ) + { + HASH_ITER(hh,coin->utxotable,hhutxo,tmputxo) + { + item = cJSON_CreateObject(); + hdrsi = (int32_t)(hhutxo->uval >> 32); + unspentind = (uint32_t)hhutxo->uval; + if ( (vout= iguana_uvaltxid(myinfo,&txid,coin,hdrsi,unspentind)) >= 0 ) + { + jaddbits256(item,"txid",txid); + jaddnum(item,"vout",vout); + jaddi(array,item); + } + } + } + jadd(retjson,"result",array); return(jprint(retjson,1)); } diff --git a/iguana/iguana_sign.c b/iguana/iguana_sign.c index 41a000453..e5354f5ab 100755 --- a/iguana/iguana_sign.c +++ b/iguana/iguana_sign.c @@ -1172,9 +1172,13 @@ int32_t iguana_signrawtransaction(struct supernet_info *myinfo,struct iguana_inf } } iguana_vininfo_create(myinfo,coin,serialized2,maxsize,msgtx,vins,numinputs,V); - if ( (complete= bitcoin_verifyvins(coin,signedtxidp,&signedtx,msgtx,serialized3,maxsize,V,SIGHASH_ALL)) > 0 ) + if ( (complete= bitcoin_verifyvins(coin,signedtxidp,&signedtx,msgtx,serialized3,maxsize,V,SIGHASH_ALL)) > 0 && signedtx != 0 ) { - iguana_interpreter(coin,j64bits(txobj,"locktime"),V,numinputs); + if ( iguana_interpreter(coin,j64bits(txobj,"locktime"),V,numinputs) < 0 ) + { + printf("iguana_interpreter error.(%s)\n",signedtx); + complete = 0; + } } } } diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index 99bf14630..32a2229e9 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -402,6 +402,26 @@ int32_t iguana_unspentslists(struct supernet_info *myinfo,struct iguana_info *co return(num); } +int32_t iguana_uvaltxid(struct supernet_info *myinfo,bits256 *txidp,struct iguana_info *coin,int16_t hdrsi,uint32_t unspentind) +{ + struct iguana_bundle *bp; struct iguana_unspent *U,*u; struct iguana_txid *T; struct iguana_ramchain *ramchain; + if ( (bp= coin->bundles[hdrsi]) == 0 ) + return(-1); + ramchain = (bp == coin->current) ? &coin->RTramchain : &bp->ramchain; + U = RAMCHAIN_PTR(ramchain->H.data,Uoffset); + T = RAMCHAIN_PTR(ramchain->H.data,Toffset); + if ( unspentind > 0 && unspentind < ramchain->H.data->numunspents ) + { + u = &U[unspentind]; + if ( u->txidind > 0 && u->txidind < ramchain->H.data->numtxids ) + { + *txidp = T[u->txidind].txid; + return(unspentind - T[u->txidind].firstvout); + } + } + return(-1); +} + int64_t iguana_unspentavail(struct iguana_info *coin,uint64_t hdrsi_unspentind,int32_t minconf,int32_t maxconf) { struct iguana_ramchain *ramchain; struct iguana_bundle *bp; int64_t RTspend; int32_t hdrsi,spentheight,spentflag; struct iguana_unspent *U,*u; uint32_t unspentind; diff --git a/iguana/iguana_volatiles.c b/iguana/iguana_volatiles.c index 1f524e089..4e8de60ca 100755 --- a/iguana/iguana_volatiles.c +++ b/iguana/iguana_volatiles.c @@ -122,7 +122,7 @@ struct iguana_utxo iguana_utxofind(struct iguana_info *coin,int16_t spent_hdrsi, if ( hhutxo->u.lockedflag == 0 ) hhutxo->u.lockedflag = 1; else printf("iguana_hhutxofind warning: locking already locked [%d].%u\n",spent_hdrsi,spent_unspentind); - } + } else hhutxo->u.lockedflag = 0; utxo = hhutxo->u; if ( utxo.spentflag != 0 || utxo.lockedflag != 0 ) *RTspendflagp = 1; diff --git a/iguana/ramchain_api.c b/iguana/ramchain_api.c index 5f851a69e..7150cdf82 100755 --- a/iguana/ramchain_api.c +++ b/iguana/ramchain_api.c @@ -228,12 +228,14 @@ HASH_AND_TWOINTS(bitcoinrpc,listsinceblock,blockhash,target,flag) "timereceived" : 1418924714 },*/ cJSON *retjson = cJSON_CreateObject(); + jaddstr(retjson,"error","low priority RPC not implemented"); return(jprint(retjson,1)); } ZERO_ARGS(bitcoinrpc,gettxoutsetinfo) { cJSON *retjson = cJSON_CreateObject(); + jaddstr(retjson,"error","low priority RPC not implemented"); return(jprint(retjson,1)); } @@ -241,13 +243,7 @@ ZERO_ARGS(bitcoinrpc,listaddressgroupings) { if ( remoteaddr != 0 ) return(clonestr("{\"error\":\"no remote\"}")); - return(clonestr("{\"result\":\"success\"}")); -} - -ZERO_ARGS(bitcoinrpc,getrawchangeaddress) -{ - cJSON *retjson = cJSON_CreateObject(); - return(jprint(retjson,1)); + return(clonestr("{\"error\":\"low priority RPC not implemented\"}")); } SS_D_I_S(bitcoinrpc,move,fromaccount,toaccount,amount,minconf,comment) diff --git a/includes/iguana_apideclares.h b/includes/iguana_apideclares.h index 66464ad10..a8a64a0ec 100755 --- a/includes/iguana_apideclares.h +++ b/includes/iguana_apideclares.h @@ -67,14 +67,14 @@ ZERO_ARGS(bitcoinrpc,repairwallet); STRING_ARRAY_OBJ_STRING(bitcoinrpc,signrawtransaction,rawtx,vins,privkeys,sighash); TWO_STRINGS(bitcoinrpc,signmessage,address,message); THREE_STRINGS(bitcoinrpc,verifymessage,address,sig,message); -STRING_AND_INT(bitcoinrpc,sendrawtransaction,rawtx,allowhighfees); // -STRING_ARG(bitcoinrpc,submitblock,rawbytes); // +STRING_AND_INT(bitcoinrpc,sendrawtransaction,rawtx,allowhighfees); -SS_D_I_SS(bitcoinrpc,sendfrom,fromaccount,toaddress,amount,minconf,comment,comment2); // -S_A_I_S(bitcoinrpc,sendmany,fromaccount,payments,minconf,comment); // -S_D_SS(bitcoinrpc,sendtoaddress,address,amount,comment,comment2); // +SS_D_I_SS(bitcoinrpc,sendfrom,fromaccount,toaddress,amount,minconf,comment,comment2); +S_A_I_S(bitcoinrpc,sendmany,fromaccount,payments,minconf,comment); +S_D_SS(bitcoinrpc,sendtoaddress,address,amount,comment,comment2); INT_AND_ARRAY(bitcoinrpc,lockunspent,flag,array); // ZERO_ARGS(bitcoinrpc,listlockunspent); // +STRING_ARG(bitcoinrpc,submitblock,rawbytes); // // maybe later HASH_AND_TWOINTS(bitcoinrpc,listsinceblock,blockhash,target,flag);