Browse Source

Lock UTXO code added for testing

patch-5
blackjok3r 6 years ago
parent
commit
3379129399
  1. 38
      iguana/dpow/dpow_fsm.c
  2. 37
      iguana/dpow/dpow_rpc.c

38
iguana/dpow/dpow_fsm.c

@ -265,6 +265,7 @@ void dpow_statemachinestart(void *ptr)
void **ptrs = ptr;
struct supernet_info *myinfo; struct dpow_info *dp; struct dpow_checkpoint checkpoint;
int32_t i,j,ht,extralen,destprevvout0,srcprevvout0,src_or_dest,numratified=0,kmdheight,myind = -1; uint8_t extras[10000],pubkeys[64][33]; cJSON *ratified=0,*item; struct iguana_info *src,*dest; char *jsonstr,*handle,*hexstr,str[65],str2[65],srcaddr[64],destaddr[64]; bits256 zero,MoM,merkleroot,srchash,destprevtxid0,srcprevtxid0; struct dpow_block *bp; struct dpow_entry *ep = 0; uint32_t MoMdepth,duration,minsigs,starttime,srctime;
char *destlockunspent,*srclockunspent,*destunlockunspent,*srcunlockunspent;
memset(&zero,0,sizeof(zero));
MoM = zero;
srcprevtxid0 = destprevtxid0 = zero;
@ -501,6 +502,29 @@ void dpow_statemachinestart(void *ptr)
bp->desttxid = bp->notaries[myind].src.prev_hash;
dpow_signedtxgen(myinfo,dp,src,bp,bp->myind,1LL<<bp->myind,bp->myind,DPOW_SIGCHANNEL,0,0);
}*/
if (strcmp("KMD",dest->symbol) == 0 )
{
// lock the dest utxo if destination coin is KMD.
destlockunspent = dpow_lockunspent(myinfo,bp->destcoin,destaddr,bits256_str(str2,ep->dest.prev_hash),ep->dest.prev_vout);
if (strncmp(destlockunspent,"true", 4) == 0 )
printf(">>>> LOCKED %s UTXO.(%s) vout.(%d)\n",dest->symbol,bits256_str(str2,ep->dest.prev_hash),ep->dest.prev_vout);
else
printf("<<<< FAILED TO LOCK %s UTXO.(%s) vout.(%d)\n",dest->symbol,bits256_str(str2,ep->dest.prev_hash),ep->dest.prev_vout);
free(destlockunspent);
}
if ( strcmp("BTC",dest->symbol) == 0 )
{
// lock the src coin selected utxo if the source coin is KMD.
srclockunspent = dpow_lockunspent(myinfo,bp->srccoin,srcaddr,bits256_str(str2,ep->src.prev_hash),ep->src.prev_vout);
if (strncmp(srclockunspent,"true", 4) == 0 )
printf(">>>> LOCKED %s UTXO.(%s) vout.(%d\n",src->symbol,bits256_str(str2,ep->src.prev_hash),ep->src.prev_vout);
else
printf("<<<< FAILED TO LOCK %s UTXO.(%s) vout.(%d)\n",src->symbol,bits256_str(str2,ep->src.prev_hash),ep->src.prev_vout);
free(srclockunspent);
}
bp->recvmask |= (1LL << myind);
bp->notaries[myind].othermask |= (1LL << myind);
dp->checkpoint = checkpoint;
@ -594,8 +618,20 @@ void dpow_statemachinestart(void *ptr)
printf("[%d] END isratify.%d:%d bestk.%d %llx sigs.%llx state.%x machine ht.%d completed state.%x %s.%s %s.%s recvmask.%llx paxwdcrc.%x %p %p\n",Numallocated,bp->isratify,dp->ratifying,bp->bestk,(long long)bp->bestmask,(long long)(bp->bestk>=0?bp->destsigsmasks[bp->bestk]:0),bp->state,bp->height,bp->state,dp->dest,bits256_str(str,bp->desttxid),dp->symbol,bits256_str(str2,bp->srctxid),(long long)bp->recvmask,bp->paxwdcrc,src,dest);
dp->lastrecvmask = bp->recvmask;
dp->ratifying -= bp->isratify;
// unlock the dest utxo regardless if it was locked or not it does not matter.
destunlockunspent = dpow_unlockunspent(myinfo,bp->destcoin,destaddr,bits256_str(str2,ep->dest.prev_hash),ep->dest.prev_vout);
if (strncmp(destunlockunspent,"true", 4) == 0 )
printf(">>>>UNLOCKED %s UTXO.(%s) vout.(%d)\n",dest->symbol,bits256_str(str2,ep->dest.prev_hash),ep->dest.prev_vout);
free(destunlockunspent);
// unlock the src selected utxo, if it was locked or not it does not matter.
srcunlockunspent = dpow_unlockunspent(myinfo,bp->srccoin,srcaddr,bits256_str(str2,ep->src.prev_hash),ep->src.prev_vout);
if (strncmp(srcunlockunspent,"true", 4) == 0 )
printf(">>>>UNLOCKED %s UTXO.(%s) vout.(%d)\n",src->symbol,bits256_str(str2,ep->src.prev_hash),ep->src.prev_vout);
free(srcunlockunspent);
// dp->blocks[bp->height] = 0;
bp->state = 0xffffffff;
free(ptr);
}

37
iguana/dpow/dpow_rpc.c

@ -236,7 +236,7 @@ bits256 dpow_getbestblockhash(struct supernet_info *myinfo,struct iguana_info *c
}
else
{
}
if ( bits256_nonz(blockhash) != 0 )
{
@ -370,6 +370,36 @@ bits256 dpow_getblockhash(struct supernet_info *myinfo,struct iguana_info *coin,
return(blockhash);
}
char *dpow_lockunspent(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr,char *txid,int32_t vout)
{
char buf[128],*retstr;
if ( coin->FULLNODE < 0 )
{
sprintf(buf,"false, [{\"txid\":\"%s\",\"vout\":%d}]", txid, vout);
if ( (retstr= bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"lockunspent",buf)) != 0 )
{
//printf("RESULT.(%s)\n",retstr);
return(retstr);
} else printf("%s null retstr from (%s)n",coin->symbol,buf);
}
return(0);
}
char *dpow_unlockunspent(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr,char *txid,int32_t vout)
{
char buf[128],*retstr;
if ( coin->FULLNODE < 0 )
{
sprintf(buf,"true, [{\"txid\":\"%s\",\"vout\":%d}]", txid, vout);
if ( (retstr= bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"lockunspent",buf)) != 0 )
{
//printf("RESULT.(%s)\n",retstr);
return(retstr);
} else printf("%s null retstr from (%s)n",coin->symbol,buf);
}
return(0);
}
cJSON *dpow_getblock(struct supernet_info *myinfo,struct iguana_info *coin,bits256 blockhash)
{
char buf[128],str[65],*retstr=0; cJSON *json = 0;
@ -399,7 +429,7 @@ cJSON *dpow_getblock(struct supernet_info *myinfo,struct iguana_info *coin,bits2
int32_t dpow_is015(char *symbol)
{
if ( strcmp("CHIPS",symbol) == 0 || strcmp("GAME",symbol) == 0 ) //strcmp("BTC",symbol) == 0 ||
if ( strcmp("CHIPS",symbol) == 0 || strcmp("GAME",symbol) == 0 ) //strcmp("BTC",symbol) == 0 ||
return(1);
else return(0);
}
@ -1254,7 +1284,7 @@ void dpow_issuer_voutupdate(struct dpow_info *dp,char *symbol,int32_t isspecial,
printf(" opret[%c] fiatoshis %.8f vs check %.8f\n",script[0],dstr(fiatoshis),dstr(checktoshis));
if ( seed == 0 || fiatoshis < checktoshis )
{
}*/
}
}
@ -1424,4 +1454,3 @@ int32_t dpow_issuer_iteration(struct dpow_info *dp,struct iguana_info *coin,int3
//printf("[%s -> %s] %s ht.%d current.%d\n",dp->symbol,dp->dest,coin->symbol,height,currentheight);
return(height);
}

Loading…
Cancel
Save