Browse Source

test

etomic
jl777 8 years ago
parent
commit
15a89494ef
  1. 2
      basilisk/basilisk_bitcoin.c
  2. 41
      iguana/dpow/dpow_network.c
  3. 3
      iguana/dpow/dpow_rpc.c
  4. 7
      iguana/iguana_payments.c

2
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"));

41
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));

3
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 )

7
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; i<n; i++)
{
item = jitem(vins,i);
interest += iguana_interest(myinfo,coin,jbits256(item,"txid"),jint(item,"vout"),jdouble(item,"value")*SATOSHIDEN);
if ( (value= jdouble(item,"value")*SATOSHIDEN) == 0 )
value = jdouble(item,"amount")*SATOSHIDEN;
interest += iguana_interest(myinfo,coin,jbits256(item,"txid"),jint(item,"vout"),value);
}
}
return(interest);
@ -725,6 +727,7 @@ HASH_AND_TWOINTS(bitcoinrpc,gettxout,txid,vout,mempool)
jaddnum(retjson,"height",height);
jaddnum(retjson,"confirmations",coin->blocks.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());

Loading…
Cancel
Save