diff --git a/basilisk/basilisk_bitcoin.c b/basilisk/basilisk_bitcoin.c index 4e5ff17cc..b3bf8a9da 100755 --- a/basilisk/basilisk_bitcoin.c +++ b/basilisk/basilisk_bitcoin.c @@ -354,6 +354,7 @@ char *basilisk_valuestr(struct iguana_info *coin,char *coinaddr,uint64_t value,i jaddstr(retjson,"result","success"); jaddstr(retjson,"address",coinaddr); jadd64bits(retjson,"satoshis",value); + jaddnum(retjson,"amount",dstr(value)); jaddnum(retjson,"value",dstr(value)); jaddnum(retjson,"height",height); jaddnum(retjson,"numconfirms",coin->blocks.hwmchain.height - height + 1); @@ -909,6 +910,7 @@ HASH_ARRAY_STRING(basilisk,value,hash,vals,hexstr) jaddstr(retjson,"address",coinaddr); jadd64bits(retjson,"satoshis",value); jaddnum(retjson,"value",dstr(value)); + jaddnum(retjson,"amount",dstr(value)); height = dpow_getchaintip(myinfo,&blockhash,&blocktime,0,0,coin); jaddnum(retjson,"height",height); jaddnum(retjson,"numconfirms",jint(txoutjson,"confirmations")); diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index aa803d1e8..978f334f9 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -727,15 +727,50 @@ void dpow_bestconsensus(struct dpow_block *bp) void dpow_nanoutxoset(struct dpow_nanoutxo *np,struct dpow_block *bp,int32_t isratify) { - int32_t i; + int32_t i,err; cJSON *ujson; char coinaddr[64]; if ( bp->myind < 0 ) return; if ( isratify != 0 ) { np->srcutxo = bp->notaries[bp->myind].ratifysrcutxo; np->srcvout = bp->notaries[bp->myind].ratifysrcvout; + err = 0; + if ( (ujson= dpow_gettxout(myinfo,bp->srccoin,np->srcutxo,np->srcvout)) != 0 ) + { + if ( j64bits(ujson,"value") == 0 ) + err = 1; + free_json(ujson); + } else err = 1; + if ( err != 0 ) + { + bitcoin_address(coinaddr,bp->srccoin->chain->pubtype,dp->minerkey33,33); + if ( dpow_haveutxo(myinfo,bp->srccoin,&bp->notaries[bp->myind].ratifysrcutxo,&bp->notaries[bp->myind].ratifysrcvout,coinaddr) > 0 ) + { + printf("Replace UTXO.%s\n",bp->srccoin->symbol); + np->srcutxo = bp->notaries[bp->myind].ratifysrcutxo; + np->srcvout = bp->notaries[bp->myind].ratifysrcvout; + } + else printf("cant find utxo.%s\n",bp->srccoin->symbol); + } np->destutxo = bp->notaries[bp->myind].ratifydestutxo; np->destvout = bp->notaries[bp->myind].ratifydestvout; + err = 0; + if ( (ujson= dpow_gettxout(myinfo,bp->destcoin,np->destutxo,np->destvout)) != 0 ) + { + if ( j64bits(ujson,"value") == 0 ) + err = 1; + free_json(ujson); + } else err = 1; + if ( err != 0 ) + { + bitcoin_address(coinaddr,bp->destcoin->chain->pubtype,dp->minerkey33,33); + if ( dpow_haveutxo(myinfo,bp->destcoin,&bp->notaries[bp->myind].ratifydestutxo,&bp->notaries[bp->myind].ratifydestvout,coinaddr) > 0 ) + { + printf("Replace UTXO.%s\n",bp->destcoin->symbol); + np->destutxo = bp->notaries[bp->myind].ratifydestutxo; + np->destvout = bp->notaries[bp->myind].ratifydestvout; + } else printf("cant find utxo.%s\n",bp->destcoin->symbol); + } np->bestmask = bp->ratifybestmask; np->recvmask = bp->ratifyrecvmask; //printf("send ratify best.(%d %llx) siglens.(%d %d)\n", bp->ratifybestk,(long long)bp->ratifybestmask,bp->ratifysiglens[0],bp->ratifysiglens[1]); @@ -888,11 +923,11 @@ void dpow_ratify_update(struct supernet_info *myinfo,struct dpow_info *dp,struct } } //printf("crcval.%x numcrcs.%d bestmatches.%d matchesmask.%llx\n",crcval,numcrcs,bestmatches,(long long)matchesmask); - if ( bestmatches >= bp->minsigs ) + if ( bestmatches >= bp->minsigs && numcrcs >= bp->minsigs ) { if ( bp->pendingratifybestk != bp->ratifybestk || bp->pendingratifybestmask != bp->ratifybestmask ) { - printf("new PENDING RATIFY BESTK (%d %llx)\n",bp->ratifybestk,(long long)bp->ratifybestmask); + printf("new PENDING RATIFY BESTK (%d %llx) crcval.%08x num.%d\n",bp->ratifybestk,(long long)bp->ratifybestmask,crcval,numcrcs); bp->pendingratifybestk = bp->ratifybestk; bp->pendingratifybestmask = bp->ratifybestmask; memset(bp->notaries[bp->myind].ratifysigs,0,sizeof(bp->notaries[bp->myind].ratifysigs)); diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index 0238df031..166bfc463 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -562,7 +562,8 @@ int32_t dpow_haveutxo(struct supernet_info *myinfo,struct iguana_info *coin,bits item = jitem(unspents,i); if ( is_cJSON_False(jobj(item,"spendable")) != 0 ) continue; - satoshis = SATOSHIDEN * jdouble(item,"amount"); + if ( (satoshis= SATOSHIDEN * jdouble(item,"amount")) == 0 ) + satoshis= SATOSHIDEN * jdouble(item,"value"); if ( satoshis == DPOW_UTXOSIZE && (address= jstr(item,"address")) != 0 && strcmp(address,coinaddr) == 0 ) { if ( (str= jstr(item,"scriptPubKey")) != 0 && is_hexstr(str,0) == sizeof(script)*2 ) diff --git a/iguana/iguana_payments.c b/iguana/iguana_payments.c index 9aa807dc0..eaccdb2a0 100755 --- a/iguana/iguana_payments.c +++ b/iguana/iguana_payments.c @@ -379,13 +379,15 @@ uint64_t iguana_interest(struct supernet_info *myinfo,struct iguana_info *coin,b uint64_t iguana_interests(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *vins) { - int32_t i,n; cJSON *item; uint64_t interest = 0; + int32_t i,n; cJSON *item; uint64_t value,interest = 0; if ( is_cJSON_Array(vins) != 0 && (n= cJSON_GetArraySize(vins)) > 0 ) { for (i=0; iblocks.hwmchain.height - height + 1); jaddnum(retjson,"value",dstr(value)); + jaddnum(retjson,"amount",dstr(value)); if ( (height % coin->chain->bundlesize) == 0 && vout == 0 ) jadd(retjson,"coinbase",jtrue()); else jadd(retjson,"coinbase",jfalse());