diff --git a/basilisk/basilisk_swap.c b/basilisk/basilisk_swap.c index 73f3f15ed..3bca35541 100755 --- a/basilisk/basilisk_swap.c +++ b/basilisk/basilisk_swap.c @@ -53,7 +53,7 @@ Alice timeout event is triggered if INSTANTDEX_LOCKTIME elapses from the start of a FSM instance. Bob timeout event is triggered after INSTANTDEX_LOCKTIME*2 */ -//#define BASILISK_DISABLETX +#define BASILISK_DISABLETX #define SCRIPT_OP_IF 0x63 #define SCRIPT_OP_ELSE 0x67 #define SCRIPT_OP_ENDIF 0x68 @@ -204,14 +204,16 @@ int32_t basilisk_rawtx_sign(struct supernet_info *myinfo,struct basilisk_swap *s V.suppress_pubkeys = dest->suppress_pubkeys; if ( dest->redeemlen != 0 ) memcpy(V.p2shscript,dest->redeemscript,dest->redeemlen), V.p2shlen = dest->redeemlen; + txobj = bitcoin_txcreate(rawtx->coin->chain->isPoS,locktime,rawtx->coin->chain->locktime_txversion); + vins = cJSON_CreateArray(); + item = cJSON_CreateObject(); if ( userdata != 0 && userdatalen > 0 ) { memcpy(V.userdata,userdata,userdatalen); V.userdatalen = userdatalen; + init_hexbytes_noT(hexstr,userdata,userdatalen); + jaddstr(item,"suffix",hexstr); } - txobj = bitcoin_txcreate(rawtx->coin->chain->isPoS,locktime,rawtx->coin->chain->locktime_txversion); - vins = cJSON_CreateArray(); - item = cJSON_CreateObject(); if ( bits256_nonz(rawtx->actualtxid) != 0 ) jaddbits256(item,"txid",rawtx->actualtxid); else jaddbits256(item,"txid",rawtx->signedtxid); diff --git a/iguana/iguana_realtime.c b/iguana/iguana_realtime.c index 9dbe829dc..390a65848 100755 --- a/iguana/iguana_realtime.c +++ b/iguana/iguana_realtime.c @@ -225,18 +225,21 @@ int32_t iguana_realtime_update(struct supernet_info *myinfo,struct iguana_info * usleep(100000); return(0); } + portable_mutex_lock(&coin->RTmutex); for (i=0; ibundlescount-1; i++) { if ( (bp= coin->bundles[i]) != 0 && (i > 0 && bp->utxofinish == 0) && bp != coin->current ) { if ( iguana_spendvectors(myinfo,coin,bp,&bp->ramchain,0,bp->n,0,0) < 0 ) { + portable_mutex_unlock(&coin->RTmutex); printf("error generating spendvectors.[%d], skipping\n",i); return(0); } // else printf("generated UTXO.[%d]\n",i); coin->spendvectorsaved = 1; } } + portable_mutex_unlock(&coin->RTmutex); bp = coin->current; if ( bp == 0 || iguana_validated(coin) < bp->hdrsi ) { @@ -347,7 +350,9 @@ int32_t iguana_realtime_update(struct supernet_info *myinfo,struct iguana_info * //printf("RTgenesis verified\n"); if ( (coin->RTheight % coin->chain->bundlesize) > 3 ) { + portable_mutex_lock(&coin->RTmutex); iguana_RTspendvectors(myinfo,coin,bp); + portable_mutex_unlock(&coin->RTmutex); coin->RTgenesis = (uint32_t)time(NULL); } } @@ -362,6 +367,8 @@ int32_t iguana_realtime_update(struct supernet_info *myinfo,struct iguana_info * if ( coin->RTdatabad != 0 ) { bits256 lastbundle; + portable_mutex_lock(&coin->RTmutex); + printf("START DATABAD fixing\n"); iguana_RTramchainfree(coin,bp); if ( coin->RTdatabad < 0 ) { @@ -379,6 +386,8 @@ int32_t iguana_realtime_update(struct supernet_info *myinfo,struct iguana_info * myfree(ptr,(bp->n+1)*sizeof(*bp->speculative)); } iguana_RTramchainalloc("RTbundle",coin,bp); + printf("DONE DATABAD fixing\n"); + portable_mutex_unlock(&coin->RTmutex); } return(flag); } diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index d1dffdaf9..a1db90b1f 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -1641,13 +1641,14 @@ int32_t iguana_processrecv(struct supernet_info *myinfo,struct iguana_info *coin { int32_t i,newhwm = 0,hwmheight,flag = 0; char str[2000]; hwmheight = coin->blocks.hwmchain.height; - portable_mutex_lock(&coin->RTmutex); coin->RTramchain_busy = 1; if ( coin->balanceflush != 0 ) { fprintf(stderr,"%s call balanceflush\n",coin->symbol); + portable_mutex_lock(&coin->RTmutex); if ( iguana_balanceflush(coin,coin->balanceflush) > 0 ) printf("balanceswritten.%d flushed coin->balanceflush %d vs %d coin->longestchain/coin->chain->bundlesize\n",coin->balanceswritten,coin->balanceflush,coin->longestchain/coin->chain->bundlesize); + portable_mutex_unlock(&coin->RTmutex); fprintf(stderr,"%s back balanceflush\n",coin->symbol); coin->balanceflush = 0; } @@ -1676,7 +1677,6 @@ int32_t iguana_processrecv(struct supernet_info *myinfo,struct iguana_info *coin } } coin->RTramchain_busy = 0;//(coin->RTgenesis == 0); - portable_mutex_unlock(&coin->RTmutex); flag += iguana_process_msgrequestQ(myinfo,coin); //if ( strcmp("BTCD",coin->symbol) == 0 ) // instantdex_update(SuperNET_MYINFO(0)); diff --git a/iguana/iguana_sign.c b/iguana/iguana_sign.c index 78ec82b4e..a62b75f65 100755 --- a/iguana/iguana_sign.c +++ b/iguana/iguana_sign.c @@ -120,6 +120,11 @@ cJSON *iguana_vinjson(struct iguana_info *coin,struct iguana_msgvin *vin,bits256 iguana_addscript(coin,json,vin->spendscript,vin->spendlen,"scriptPubKey"); if ( vin->p2shlen > 0 ) iguana_addscript(coin,json,vin->redeemscript,vin->p2shlen,"redeemScript"); + if ( vin->suffixlen > 0 ) + { + iguana_addscript(coin,json,&vin->redeemscript[vin->p2shlen],vin->suffixlen,"suffix"); + vin->p2shlen += vin->suffixlen; + } } return(json); }