From 5cec066a2605e334eb6f9a4e937b38b6fca4f0cf Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 9 Oct 2018 12:53:15 +0800 Subject: [PATCH] make changes to normal branch to fix crash --- iguana/dpow/dpow_fsm.c | 18 +++++++++--------- iguana/dpow/dpow_rpc.c | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index eefcddc0d..12b97d765 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -505,22 +505,22 @@ void dpow_statemachinestart(void *ptr) //printf("Use srcutxo.(%s) vout.(%d) destutxo.(%s) vout.(%d)\n",bits256_str(str,ep->src.prev_hash),ep->src.prev_vout,bits256_str(str2,ep->dest.prev_hash),ep->dest.prev_vout); - if (strcmp("KMD",dest->symbol) == 0 ) + if ( (strcmp("KMD",dest->symbol) == 0 ) && (ep->dest.prev_vout != -1) ) { // lock the dest utxo if destination coin is KMD.s destlockunspent = dpow_lockunspent(myinfo,bp->destcoin,destaddr,bits256_str(str2,ep->dest.prev_hash),ep->dest.prev_vout); - if (strncmp(destlockunspent,"true", 4) == 0 ) + if (strcmp(destlockunspent,"true") == 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 ) + if ( ( strcmp("KMD",src->symbol) == 0 ) && (ep->src.prev_vout != -1) ) { // 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 ) + if (strcmp(srclockunspent,"true") == 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); @@ -619,21 +619,21 @@ 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 on KMD. - if (strcmp("KMD",dest->symbol) == 0 ) + if ( (strcmp("KMD",dest->symbol) == 0 ) && (ep->dest.prev_vout != -1) ) { destunlockunspent = dpow_unlockunspent(myinfo,bp->destcoin,destaddr,bits256_str(str2,ep->dest.prev_hash),ep->dest.prev_vout); - if (strncmp(destunlockunspent,"true", 4) == 0 ) + if (strcmp(destunlockunspent,"true") == 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 on KMD, as those are the only ones we LOCK, and CHIPS does not like the lockunspent call. - if ( strcmp("BTC",dest->symbol) == 0 ) + if ( ( strcmp("KMD",src->symbol) == 0 ) && (ep->src.prev_vout != -1) ) { srcunlockunspent = dpow_unlockunspent(myinfo,bp->srccoin,srcaddr,bits256_str(str2,ep->src.prev_hash),ep->src.prev_vout); - if (strncmp(srcunlockunspent,"true", 4) == 0 ) + if (strcmp(srcunlockunspent,"true") == 0 ) printf(">>>>UNLOCKED %s UTXO.(%s) vout.(%d)\n",src->symbol,bits256_str(str2,ep->src.prev_hash),ep->src.prev_vout); free(srcunlockunspent); } diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index d7dc35014..6cdcf7e66 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -478,7 +478,7 @@ char *dpow_lockunspent(struct supernet_info *myinfo,struct iguana_info *coin,cha return(retstr); } else printf("%s null retstr from (%s)n",coin->symbol,buf); } - return(0); + return("false"); } char *dpow_unlockunspent(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr,char *txid,int32_t vout) @@ -493,7 +493,7 @@ char *dpow_unlockunspent(struct supernet_info *myinfo,struct iguana_info *coin,c return(retstr); } else printf("%s null retstr from (%s)n",coin->symbol,buf); } - return(0); + return("false"); } char *dpow_decoderawtransaction(struct supernet_info *myinfo,struct iguana_info *coin,char *rawtx)