Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
8e5db27835
  1. 2
      crypto777/crypto777.sources
  2. 2118
      iguana/confs/BTCD_hdrs.h
  3. 4
      iguana/exchanges777.h
  4. 2
      iguana/iguana.sources
  5. 4
      iguana/iguana_exchanges.c
  6. 17
      iguana/iguana_instantdex.c
  7. 2
      iguana/iguana_spendvectors.c
  8. 17
      iguana/swaps/iguana_BTCswap.c

2
crypto777/crypto777.sources

@ -42,5 +42,5 @@ NANOMSG = $(NANOMSG_CORE) $(NANOMSG_AIO) $(NANOMSG_UTILS) $(NANOMSG_DEVICES) $(N
JPEG_SRCS := ../crypto777/jpeg/jaricom.c ../crypto777/jpeg/jcapimin.c ../crypto777/jpeg/jcapistd.c ../crypto777/jpeg/jcarith.c ../crypto777/jpeg/jccoefct.c ../crypto777/jpeg/jccolor.c ../crypto777/jpeg/jcdctmgr.c ../crypto777/jpeg/jchuff.c ../crypto777/jpeg/jcinit.c ../crypto777/jpeg/jcmainct.c ../crypto777/jpeg/jcmarker.c ../crypto777/jpeg/jcmaster.c ../crypto777/jpeg/jcomapi.c ../crypto777/jpeg/jcparam.c ../crypto777/jpeg/jcprepct.c ../crypto777/jpeg/jcsample.c ../crypto777/jpeg/jctrans.c ../crypto777/jpeg/jdapimin.c ../crypto777/jpeg/jdapistd.c ../crypto777/jpeg/jdarith.c ../crypto777/jpeg/jdatadst.c ../crypto777/jpeg/jdatasrc.c ../crypto777/jpeg/jdcoefct.c ../crypto777/jpeg/jdcolor.c ../crypto777/jpeg/jddctmgr.c ../crypto777/jpeg/jdhuff.c ../crypto777/jpeg/jdinput.c ../crypto777/jpeg/jdmainct.c ../crypto777/jpeg/jdmarker.c ../crypto777/jpeg/jdmaster.c ../crypto777/jpeg/jdmerge.c ../crypto777/jpeg/jdpostct.c ../crypto777/jpeg/jdsample.c ../crypto777/jpeg/jdtrans.c ../crypto777/jpeg/jerror.c ../crypto777/jpeg/jfdctflt.c ../crypto777/jpeg/jfdctfst.c ../crypto777/jpeg/jfdctint.c ../crypto777/jpeg/jidctflt.c ../crypto777/jpeg/jidctfst.c ../crypto777/jpeg/jidctint.c ../crypto777/jpeg/jquant1.c ../crypto777/jpeg/jquant2.c ../crypto777/jpeg/jutils.c ../crypto777/jpeg/misc/jmemnobs.c ../crypto777/jpeg/jmemmgr.c
CRYPTO777_SRCS := ../crypto777/tweetnacl.c ../crypto777/bitcoind_RPC.c ../crypto777/cJSON.c ../crypto777/iguana_utils.c ../crypto777/OS_nonportable.c ../crypto777/curve25519-donna.c ../crypto777/inet.c ../crypto777/OS_portable.c ../crypto777/curve25519.c ../crypto777/OS_time.c ../crypto777/hmac_sha512.c ../crypto777/ramcoder.c ../crypto777/SaM.c ../crypto777/iguana_OS.c ../crypto777/iguana_serdes.c $(JPEG_SRCS) # $(NANOMSG)
CRYPTO777_SRCS := ../crypto777/tweetnacl.c ../crypto777/scrypt.c ../crypto777/bitcoind_RPC.c ../crypto777/cJSON.c ../crypto777/iguana_utils.c ../crypto777/OS_nonportable.c ../crypto777/curve25519-donna.c ../crypto777/inet.c ../crypto777/OS_portable.c ../crypto777/curve25519.c ../crypto777/OS_time.c ../crypto777/hmac_sha512.c ../crypto777/ramcoder.c ../crypto777/SaM.c ../crypto777/iguana_OS.c ../crypto777/iguana_serdes.c $(JPEG_SRCS) # $(NANOMSG)

2118
iguana/confs/BTCD_hdrs.h

File diff suppressed because it is too large

4
iguana/exchanges777.h

@ -153,9 +153,12 @@ struct instantdex_stateinfo
struct instantdex_event *events; int32_t numevents;
};
struct bitcoin_eventitem { struct queueitem DL; cJSON *argjson,*newjson; int32_t serdatalen; char cmd[16]; uint8_t serdata[]; };
struct bitcoin_swapinfo
{
//struct queueitem DL;
queue_t eventsQ;
struct bitcoin_swapinfo *next,*prev;
struct instantdex_accept mine,other;
bits256 privkeys[INSTANTDEX_DECKSIZE+2],mypubs[2],otherpubs[2],privAm,pubAm,privBn,pubBn;
@ -201,5 +204,6 @@ char *instantdex_checkoffer(struct supernet_info *myinfo,int32_t *addedp,uint64_
void tradebot_timeslices(struct exchange_info *exchange);
struct instantdex_stateinfo *BTC_initFSM(int32_t *n);
struct bitcoin_statetx *instantdex_feetx(struct supernet_info *myinfo,struct instantdex_accept *A,struct bitcoin_swapinfo *swap,struct iguana_info *coin);
void instantdex_statemachine_iter(struct supernet_info *myinfo,struct exchange_info *exchange,struct bitcoin_swapinfo *swap);
#endif

2
iguana/iguana.sources

@ -1,2 +1,2 @@
SOURCES := SuperNET.c iguana_bundles.c iguana_interpreter.c mini-gmp.c main.c iguana_payments.c iguana_spendvectors.c iguana_sign.c iguana_txidfind.c iguana_realtime.c iguana_volatiles.c peggy_price.c SuperNET_category.c iguana_chains.c iguana_ramchain.c iguana_secp.c pangea_api.c peggy_ramkv.c SuperNET_hexmsg.c iguana_exchanges.c iguana_recv.c pangea_bets.c peggy_serdes.c SuperNET_keys.c iguana_rpc.c pangea_hand.c peggy_tx.c cards777.c iguana_init.c iguana_scripts.c pangea_json.c peggy_txind.c iguana777.c iguana_instantdex.c iguana_tradebots.c pangea_summary.c peggy_update.c iguana_accept.c iguana_json.c iguana_tx.c peggy.c poker.c iguana_bitmap.c iguana_msg.c iguana_unspents.c peggy_accts.c ramchain_api.c iguana_blocks.c iguana_peers.c iguana_wallet.c peggy_consensus.c databases/iguana_DB.c secp256k1/src/secp256k1.c
SOURCES := SuperNET.c iguana_bundles.c iguana_stake.c iguana_interpreter.c mini-gmp.c main.c iguana_payments.c iguana_spendvectors.c iguana_sign.c iguana_txidfind.c iguana_realtime.c iguana_volatiles.c peggy_price.c SuperNET_category.c iguana_chains.c iguana_ramchain.c iguana_secp.c pangea_api.c peggy_ramkv.c SuperNET_hexmsg.c iguana_exchanges.c iguana_recv.c pangea_bets.c peggy_serdes.c SuperNET_keys.c iguana_rpc.c pangea_hand.c peggy_tx.c cards777.c iguana_init.c iguana_scripts.c pangea_json.c peggy_txind.c iguana777.c iguana_instantdex.c iguana_tradebots.c pangea_summary.c peggy_update.c iguana_accept.c iguana_json.c iguana_tx.c peggy.c poker.c iguana_bitmap.c iguana_msg.c iguana_unspents.c peggy_accts.c ramchain_api.c iguana_blocks.c iguana_peers.c iguana_wallet.c peggy_consensus.c databases/iguana_DB.c secp256k1/src/secp256k1.c

4
iguana/iguana_exchanges.c

@ -590,9 +590,7 @@ void iguana_statemachineupdate(struct supernet_info *myinfo,struct exchange_info
portable_mutex_lock(&exchange->mutex);
DL_FOREACH_SAFE(exchange->statemachines,swap,tmp)
{
if ( swap->myfee == 0 )
swap->myfee = instantdex_feetx(myinfo,&swap->mine,swap,iguana_coinfind("BTC"));
//printf("FSM.(%llu / %llu) (%s/%s) state.(%s)\n",(long long)swap->mine.orderid,(long long)swap->other.orderid,swap->mine.offer.base,swap->mine.offer.rel,swap->state->name);
instantdex_statemachine_iter(myinfo,exchange,swap);
}
portable_mutex_unlock(&exchange->mutex);
while ( (req= queue_dequeue(&exchange->recvQ,0)) != 0 )

17
iguana/iguana_instantdex.c

@ -1224,10 +1224,10 @@ char *instantdex_checkoffer(struct supernet_info *myinfo,int32_t *addedp,uint64_
//queue_enqueue("acceptableQ",&exchange->acceptableQ,&swap->DL,0);
//if ( isbob != 0 && (coin= iguana_coinfind("BTC")) != 0 )
// swap->myfee = instantdex_feetx(myinfo,&swap->mine,swap,coin);
instantdex_statemachineadd(exchange,swap);
*addedp = 1;
if ( (newjson= instantdex_parseargjson(myinfo,exchange,swap,argjson,1)) == 0 )
return(clonestr("{\"error\":\"instantdex_checkoffer null newjson\"}"));
instantdex_statemachineadd(exchange,swap);
return(instantdex_sendcmd(myinfo,&swap->mine.offer,newjson,"BTCoffer",GENESIS_PUBKEY,INSTANTDEX_HOPS,swap->deck,sizeof(swap->deck),0));
} else printf("error creating statemachine\n");
}
@ -1272,8 +1272,6 @@ char *instantdex_gotoffer(struct supernet_info *myinfo,struct exchange_info *exc
else //if ( (retstr= instantdex_addfeetx(myinfo,newjson,ap,swap,"BOB_gotoffer","ALICE_gotoffer")) == 0 )
{
printf("create statemachine isbob.%d\n",isbob);
if ( isbob != 0 && (coinbtc= iguana_coinfind("BTC")) != 0 )
swap->myfee = instantdex_feetx(myinfo,&swap->mine,swap,coinbtc);
//queue_enqueue("acceptableQ",&exchange->acceptableQ,&swap->DL,0);
instantdex_statemachineadd(exchange,swap);
if ( (retstr= instantdex_choosei(swap,newjson,argjson,serdata,serdatalen)) != 0 )
@ -1288,7 +1286,7 @@ char *instantdex_gotoffer(struct supernet_info *myinfo,struct exchange_info *exc
char *instantdex_parse(struct supernet_info *myinfo,struct instantdex_msghdr *msg,cJSON *argjson,char *remoteaddr,uint64_t signerbits,struct instantdex_offer *offer,bits256 orderhash,uint8_t *serdata,int32_t serdatalen)
{
char cmdstr[16],*retstr; struct exchange_info *exchange; struct instantdex_accept A,*ap = 0; bits256 traderpub; cJSON *newjson; struct bitcoin_swapinfo *swap;
char cmdstr[16],*retstr; struct exchange_info *exchange; struct instantdex_accept A,*ap = 0; bits256 traderpub; cJSON *newjson; struct bitcoin_swapinfo *swap; struct bitcoin_eventitem *ptr;
exchange = exchanges777_find("bitcoin");
memset(cmdstr,0,sizeof(cmdstr)), memcpy(cmdstr,msg->cmd,sizeof(msg->cmd));
if ( argjson != 0 )
@ -1314,9 +1312,18 @@ char *instantdex_parse(struct supernet_info *myinfo,struct instantdex_msghdr *ms
if ( serdatalen == sizeof(swap->otherdeck) && swap->choosei < 0 && (retstr= instantdex_choosei(swap,newjson,argjson,serdata,serdatalen)) != 0 )
{
printf("error choosei\n");
if ( newjson != 0 )
free_json(newjson);
return(retstr);
}
return(instantdex_statemachine(BTC_states,BTC_numstates,myinfo,exchange,swap,cmdstr,argjson,newjson,serdata,serdatalen));
ptr = calloc(1,sizeof(*ptr) + serdatalen);
strcpy(ptr->cmd,cmdstr);
ptr->newjson = newjson;
ptr->argjson = jduplicate(argjson);
memcpy(ptr->serdata,serdata,serdatalen);
queue_enqueue("eventQ",&swap->eventsQ,&ptr->DL,0);
return(clonestr("{\"result\":\"updated statemachine\"}"));
//return(instantdex_statemachine(BTC_states,BTC_numstates,myinfo,exchange,swap,cmdstr,argjson,newjson,serdata,serdatalen));
}
else if ( strcmp(cmdstr,"BTCoffer") == 0 ) // incoming
{

2
iguana/iguana_spendvectors.c

@ -1031,7 +1031,7 @@ int32_t iguana_convert(struct iguana_info *coin,int32_t helperid,struct iguana_b
total[helperid % max] += converted;
for (i=sum=0; i<max; i++)
sum += total[i];
if ( converted != 0 && bp != coin->current )
if ( 0 && converted != 0 && bp != coin->current )
printf("[%4d] millis %7.3f converted.%-7d balance calc.%-4d of %4d | total.%llu of %llu depth.%d\n",bp->hdrsi,OS_milliseconds()-startmillis,converted,m,n,(long long)sum,(long long)total_tmpspends,(int32_t)depth);
}
depth--;

17
iguana/swaps/iguana_BTCswap.c

@ -118,7 +118,7 @@ struct bitcoin_statetx *instantdex_signtx(struct supernet_info *myinfo,struct ig
bitcoin_address(coin->changeaddr,coin->chain->pubtype,waddr->rmd160,20);
bitcoin_pubkey33(myinfo->ctx,pubkey33,myinfo->persistent_priv);
bitcoin_address(coinaddr,coin->chain->pubtype,pubkey33,33);
printf("%s persistent.(%s) (%s) change.(%s) scriptstr.(%s)\n",coin->symbol,myinfo->myaddr.BTC,coinaddr,coin->changeaddr,scriptstr);
//printf("%s persistent.(%s) (%s) change.(%s) scriptstr.(%s)\n",coin->symbol,myinfo->myaddr.BTC,coinaddr,coin->changeaddr,scriptstr);
if ( (waddr= iguana_waddresssearch(myinfo,coin,&wacct,coinaddr)) != 0 )
{
bitcoin_priv2wif(wifstr,waddr->privkey,coin->chain->wiftype);
@ -1045,6 +1045,21 @@ char *instantdex_statemachine(struct instantdex_stateinfo *states,int32_t numsta
return(clonestr("{\"error\":\"instantdex_statemachine: unexpected state\"}"));
}
void instantdex_statemachine_iter(struct supernet_info *myinfo,struct exchange_info *exchange,struct bitcoin_swapinfo *swap)
{
char *str; struct bitcoin_eventitem *ptr;
if ( instantdex_isbob(swap) != 0 && swap->myfee == 0 )
swap->myfee = instantdex_feetx(myinfo,&swap->mine,swap,iguana_coinfind("BTC"));
while ( (ptr= queue_dequeue(&swap->eventsQ,0)) != 0 )
{
if ( (str= instantdex_statemachine(BTC_states,BTC_numstates,myinfo,exchange,swap,ptr->cmd,ptr->argjson,ptr->newjson,ptr->serdata,ptr->serdatalen)) != 0 )
free(str);
if ( ptr->argjson != 0 )
free_json(ptr->argjson);
free(ptr);
}
}
#ifdef oldway
// https://github.com/TierNolan/bips/blob/bip4x/bip-atom.mediawiki

Loading…
Cancel
Save