Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
f5314d6f79
  1. 2
      iguana/iguana_exchanges.c
  2. 11
      iguana/iguana_realtime.c
  3. 28
      iguana/swaps/iguana_BTCswap.c

2
iguana/iguana_exchanges.c

@ -585,7 +585,7 @@ char *exchanges777_process(struct exchange_info *exchange,int32_t *retvalp,struc
void iguana_statemachineupdate(struct supernet_info *myinfo,struct exchange_info *exchange) void iguana_statemachineupdate(struct supernet_info *myinfo,struct exchange_info *exchange)
{ {
int32_t timemod,modwidth = 3; struct iguana_info *coin; struct bitcoin_swapinfo *swap,*tmp; struct iguana_bundlereq *req; int32_t timemod,modwidth = 1; struct iguana_info *coin; struct bitcoin_swapinfo *swap,*tmp; struct iguana_bundlereq *req;
timemod = time(NULL) % modwidth; timemod = time(NULL) % modwidth;
coin = iguana_coinfind("BTCD"); coin = iguana_coinfind("BTCD");
portable_mutex_lock(&exchange->mutexS); portable_mutex_lock(&exchange->mutexS);

11
iguana/iguana_realtime.c

@ -189,7 +189,10 @@ void iguana_RTspendvectors(struct iguana_info *coin,struct iguana_bundle *bp)
printf("RTspendvectors converted.%d to %d\n",num,coin->RTheight); printf("RTspendvectors converted.%d to %d\n",num,coin->RTheight);
bp->converted = (uint32_t)time(NULL); bp->converted = (uint32_t)time(NULL);
if ( iguana_balancegen(coin,1,bp,coin->RTstarti,coin->RTheight > 0 ? coin->RTheight-1 : bp->n-1,orignumemit) < 0 ) if ( iguana_balancegen(coin,1,bp,coin->RTstarti,coin->RTheight > 0 ? coin->RTheight-1 : bp->n-1,orignumemit) < 0 )
{
printf("balancegen error\n");
coin->RTdatabad = 1; coin->RTdatabad = 1;
}
else if ( coin->RTgenesis == 0 && coin->firstRTgenesis == 0 ) else if ( coin->RTgenesis == 0 && coin->firstRTgenesis == 0 )
coin->firstRTgenesis++, printf(">>>>>> IGUANA %s READY FOR REALTIME RPC <<<<<<\n",coin->symbol); coin->firstRTgenesis++, printf(">>>>>> IGUANA %s READY FOR REALTIME RPC <<<<<<\n",coin->symbol);
//printf("iguana_balancegen [%d] (%d to %d)\n",bp->hdrsi,coin->RTstarti,(coin->RTheight-1)%bp->n); //printf("iguana_balancegen [%d] (%d to %d)\n",bp->hdrsi,coin->RTstarti,(coin->RTheight-1)%bp->n);
@ -339,13 +342,19 @@ int32_t iguana_realtime_update(struct iguana_info *coin)
iguana_RTspendvectors(coin,bp); iguana_RTspendvectors(coin,bp);
coin->RTgenesis = (uint32_t)time(NULL); coin->RTgenesis = (uint32_t)time(NULL);
} }
} else coin->RTdatabad = 1; }
else
{
printf("walkchain error n.%d != %d\n",n,coin->RTheight-1);
coin->RTdatabad = 1;
}
} }
if ( dest != 0 && flag != 0 ) if ( dest != 0 && flag != 0 )
printf("<<<< flag.%d RT.%d:%d hwm.%d L.%d T.%d U.%d S.%d P.%d X.%d -> size.%ld\n",flag,coin->RTheight,n,coin->blocks.hwmchain.height,coin->longestchain,dest->H.txidind,dest->H.unspentind,dest->H.spendind,dest->pkind,dest->externalind,dest->H.data!=0?(long)dest->H.data->allocsize:-1); printf("<<<< flag.%d RT.%d:%d hwm.%d L.%d T.%d U.%d S.%d P.%d X.%d -> size.%ld\n",flag,coin->RTheight,n,coin->blocks.hwmchain.height,coin->longestchain,dest->H.txidind,dest->H.unspentind,dest->H.spendind,dest->pkind,dest->externalind,dest->H.data!=0?(long)dest->H.data->allocsize:-1);
if ( coin->RTdatabad != 0 ) if ( coin->RTdatabad != 0 )
{ {
iguana_RTramchainfree(coin,bp); iguana_RTramchainfree(coin,bp);
coin->RTdatabad = 0;
//memset(bp->hashes,0,sizeof(bp->hashes)); //memset(bp->hashes,0,sizeof(bp->hashes));
memset(bp->blocks,0,sizeof(bp->blocks)); memset(bp->blocks,0,sizeof(bp->blocks));
if ( 0 && bp->speculative != 0 ) if ( 0 && bp->speculative != 0 )

28
iguana/swaps/iguana_BTCswap.c

@ -510,16 +510,16 @@ void instantdex_privkeyextract(struct supernet_info *myinfo,struct bitcoin_swapi
{ {
if ( otherpubkey[0] == 3 ) if ( otherpubkey[0] == 3 )
{ {
swap->privBn = swap->privkeys[i]; //swap->privBn = swap->privkeys[i];
swap->pubBn = bitcoin_pubkey33(myinfo->ctx,pubkey,swap->privBn); swap->pubBn = bitcoin_pubkey33(myinfo->ctx,pubkey,swap->privkeys[i]);
} else printf("wrong first byte.%02x\n",otherpubkey[0]); } else printf("wrong first byte.%02x\n",otherpubkey[0]);
} }
else else
{ {
if ( otherpubkey[0] == 2 ) if ( otherpubkey[0] == 2 )
{ {
swap->privAm = swap->privkeys[i]; //swap->privAm = swap->privkeys[i];
swap->pubAm = bitcoin_pubkey33(myinfo->ctx,pubkey,swap->privAm); swap->pubAm = bitcoin_pubkey33(myinfo->ctx,pubkey,swap->privkeys[i]);
} else printf("wrong first byte.%02x\n",otherpubkey[0]); } else printf("wrong first byte.%02x\n",otherpubkey[0]);
} }
continue; continue;
@ -638,6 +638,8 @@ void instantdex_newjson(struct supernet_info *myinfo,struct bitcoin_swapinfo *sw
} }
if ( bits256_nonz(swap->pubAm) != 0 ) if ( bits256_nonz(swap->pubAm) != 0 )
jaddbits256(newjson,"pubAm",swap->pubAm); jaddbits256(newjson,"pubAm",swap->pubAm);
if ( bits256_nonz(swap->privAm) != 0 )
jaddbits256(newjson,"privAm",swap->privAm);
if ( bits256_nonz(swap->pubBn) != 0 ) if ( bits256_nonz(swap->pubBn) != 0 )
jaddbits256(newjson,"pubBn",swap->pubBn); jaddbits256(newjson,"pubBn",swap->pubBn);
} }
@ -950,18 +952,32 @@ cJSON *BTC_waitpaymentfunc(struct supernet_info *myinfo,struct exchange_info *ex
cJSON *BTC_makeclaimfunc(struct supernet_info *myinfo,struct exchange_info *exchange,struct bitcoin_swapinfo *swap,cJSON *argjson,cJSON *newjson,uint8_t **serdatap,int32_t *serdatalenp) cJSON *BTC_makeclaimfunc(struct supernet_info *myinfo,struct exchange_info *exchange,struct bitcoin_swapinfo *swap,cJSON *argjson,cJSON *newjson,uint8_t **serdatap,int32_t *serdatalenp)
{ {
struct iguana_info *coinbtc,*altcoin; struct iguana_info *coinbtc,*altcoin; int32_t got_payment=1,bob_reclaimed=0;
coinbtc = iguana_coinfind("BTC"); coinbtc = iguana_coinfind("BTC");
altcoin = iguana_coinfind(swap->mine.offer.base); altcoin = iguana_coinfind(swap->mine.offer.base);
strcpy(swap->waitfortx,"dep"); strcpy(swap->waitfortx,"dep");
*serdatap = 0, *serdatalenp = 0; *serdatap = 0, *serdatalenp = 0;
if ( instantdex_isbob(swap) == 0 ) if ( instantdex_isbob(swap) == 0 )
{ {
// [BLOCKING: payfound] now Alice's turn to make sure payment is confrmed and send in claim or see bob's reclaim and reclaim
if ( got_payment != 0 )
{
swap->privAm = swap->privkeys[swap->otherchoosei];
// sign if/else payment
} }
else else if ( bob_reclaimed != 0 )
{ {
} }
}
else
{
// [BLOCKING: privM] Bob waits for privM either from Alice or alt blockchain
if ( bits256_nonz(swap->privAm) != 0 )
{
// a multisig tx for altcoin
}
}
return(newjson); return(newjson);
} }

Loading…
Cancel
Save