Browse Source

Merge branch 'master' into release/v0.1

release/v0.1
jl777 8 years ago
parent
commit
751dbe2d44
  1. 1
      OSlibs/win/mingw.h
  2. BIN
      OSlibs/win/x64/pthread_lib.lib
  3. 42
      basilisk/basilisk.h
  4. 52
      basilisk/basilisk_DEX.c
  5. 44
      basilisk/basilisk_bitcoin.c
  6. 1153
      basilisk/basilisk_swap.c
  7. 265
      basilisk/basilisk_tradebot.c
  8. 1
      crypto777/OS_portable.h
  9. 2
      gecko/gecko_miner.c
  10. 18
      iguana.vcxproj
  11. 9
      iguana.vcxproj.filters
  12. 2
      iguana/coins/genanc.json
  13. 2
      iguana/exchanges/bitcoin.c
  14. 1
      iguana/exchanges/poloniex.c
  15. 2
      iguana/iguana.sources
  16. 4
      iguana/iguana777.c
  17. 1
      iguana/iguana777.h
  18. 35
      iguana/iguana_interpreter.c
  19. 21
      iguana/iguana_notary.c
  20. 118
      iguana/iguana_payments.c
  21. 65
      iguana/iguana_sign.c
  22. 8
      iguana/iguana_unspents.c
  23. 16
      iguana/iguana_wallet.c
  24. 2
      iguana/tests/LPinit
  25. 47
      iguana/tests/addnotarys
  26. 47
      iguana/tests/addnotarys_7776
  27. 2
      iguana/tests/decoderawtransaction
  28. 2
      iguana/tests/listunspent
  29. 2
      iguana/tests/request
  30. 2
      iguana/tests/request2
  31. 1
      iguana/tests/splitfunds
  32. 1
      includes/iguana_apideclares.h
  33. 5
      includes/iguana_funcs.h
  34. 6
      includes/iguana_structs.h

1
OSlibs/win/mingw.h

@ -6,6 +6,7 @@
#define _USE_W32_SOCKETS 1
#include <windows.h>
#define PTW32_STATIC_LIB
#include "pthread.h"
#ifndef NATIVE_WINDOWS

BIN
OSlibs/win/x64/pthread_lib.lib

Binary file not shown.

42
basilisk/basilisk.h

@ -16,7 +16,7 @@
#ifndef H_BASILISK_H
#define H_BASILISK_H
#define BASILISK_DISABLESENDTX
//#define BASILISK_DISABLESENDTX
#define BASILISK_DISABLEWAITTX
#include "../iguana/iguana777.h"
@ -34,7 +34,7 @@
#define BASILISK_HDROFFSET ((int32_t)(sizeof(bits256)+sizeof(struct iguana_msghdr)+sizeof(uint32_t)))
#define INSTANTDEX_DECKSIZE 1000
#define INSTANTDEX_LOCKTIME (3600*2 + 300*2)
#define INSTANTDEX_LOCKTIME 300 //(3600*2 + 300*2)
#define INSTANTDEX_INSURANCEDIV 777
#define INSTANTDEX_PUBKEY "03bc2c7ba671bae4a6fc835244c9762b41647b9827d4780a89a949b984a8ddcc06"
#define INSTANTDEX_RMD160 "ca1e04745e8ca0c60d8c5881531d51bec470743f"
@ -42,26 +42,32 @@
#define INSTANTDEX_BTC "1KRhTPvoxyJmVALwHFXZdeeWFbcJSbkFPu"
#define INSTANTDEX_BTCD "RThtXup6Zo7LZAi8kRWgjAyi1s4u6U9Cpf"
struct basilisk_rawtx
struct basilisk_rawtxinfo
{
char destaddr[64];
bits256 txid,signedtxid,actualtxid;
struct iguana_msgtx msgtx;
struct iguana_info *coin;
cJSON *vins;
uint64_t amount,change,inputsum;
int32_t redeemlen,datalen,completed,vintype,vouttype,numconfirms,spendlen,secretstart,suppress_pubkeys;
uint32_t locktime,crcs[2];
char destaddr[64],name[32];
uint8_t addrtype,pubkey33[33],spendscript[512],redeemscript[1024],rmd160[20];
uint8_t *txbytes,extraspace[1024];
uint8_t addrtype,pubkey33[33],rmd160[20];
};
struct basilisk_swap
struct basilisk_rawtx
{
char name[32];
struct iguana_msgtx msgtx;
struct basilisk_rawtxinfo I;
struct iguana_info *coin;
cJSON *vins;
uint8_t *txbytes,spendscript[512],redeemscript[1024],extraspace[1024];
};
struct basilisk_swapinfo
{
struct basilisk_request req;
struct supernet_info *myinfo; bits256 myhash,otherhash,orderhash;
uint32_t statebits,otherstatebits,started,expiration,finished,dead,reftime,locktime;
struct iguana_info *bobcoin,*alicecoin; char bobstr[64],alicestr[64];
char bobstr[64],alicestr[64];
bits256 myhash,otherhash,orderhash;
uint32_t statebits,otherstatebits,started,expiration,finished,dead,reftime,putduration,callduration;
int32_t bobconfirms,aliceconfirms,iambob,reclaimed;
uint64_t alicesatoshis,bobsatoshis,bobinsurance,aliceinsurance;
@ -70,7 +76,12 @@ struct basilisk_swap
int32_t choosei,otherchoosei,cutverified,otherverifiedcut,numpubs,havestate,otherhavestate;
uint8_t secretAm[20],secretBn[20];
uint8_t secretAm256[32],secretBn256[32];
};
struct basilisk_swap
{
struct supernet_info *myinfo; struct iguana_info *bobcoin,*alicecoin;
struct basilisk_swapinfo I;
struct basilisk_rawtx bobdeposit,bobpayment,alicepayment,myfee,otherfee,aliceclaim,alicespend,bobreclaim,bobspend,bobrefund,alicereclaim;
bits256 privkeys[INSTANTDEX_DECKSIZE];
uint64_t otherdeck[INSTANTDEX_DECKSIZE][2],deck[INSTANTDEX_DECKSIZE][2];
@ -123,11 +134,12 @@ void basilisk_request_goodbye(struct supernet_info *myinfo);
int32_t basilisk_update(char *symbol,uint32_t reftimestamp);
void basilisk_seqresult(struct supernet_info *myinfo,char *retstr);
struct iguana_info *basilisk_geckochain(struct supernet_info *myinfo,char *symbol,char *chainname,cJSON *valsobj);
void basilisk_alicepayment(struct supernet_info *myinfo,struct iguana_info *coin,struct basilisk_rawtx *alicepayment,bits256 pubAm,bits256 pubBn);
void basilisk_alicepayment(struct supernet_info *myinfo,struct basilisk_swap *swap,struct iguana_info *coin,struct basilisk_rawtx *alicepayment,bits256 pubAm,bits256 pubBn);
void basilisk_rawtx_setparms(char *name,struct supernet_info *myinfo,struct basilisk_swap *swap,struct basilisk_rawtx *rawtx,struct iguana_info *coin,int32_t numconfirms,int32_t vintype,uint64_t satoshis,int32_t vouttype,uint8_t *pubkey33);
void basilisk_setmyid(struct supernet_info *myinfo);
int32_t basilisk_rwDEXquote(int32_t rwflag,uint8_t *serialized,struct basilisk_request *rp);
cJSON *basilisk_requestjson(struct basilisk_request *rp);
void basilisk_bobscripts_set(struct supernet_info *myinfo,struct basilisk_swap *swap,int32_t depositflag,int32_t genflag);
int32_t basilisk_bobscripts_set(struct supernet_info *myinfo,struct basilisk_swap *swap,int32_t depositflag,int32_t genflag);
void basilisk_txlog(struct supernet_info *myinfo,struct basilisk_swap *swap,struct basilisk_rawtx *rawtx,int32_t delay);
#endif

52
basilisk/basilisk_DEX.c

@ -100,7 +100,7 @@ int32_t basilisk_rwDEXquote(int32_t rwflag,uint8_t *serialized,struct basilisk_r
len += iguana_rwnum(rwflag,&serialized[len],sizeof(rp->timestamp),&rp->timestamp); // must be 2nd
len += iguana_rwnum(rwflag,&serialized[len],sizeof(rp->quoteid),&rp->quoteid);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(rp->quotetime),&rp->quotetime);
//len += iguana_rwnum(rwflag,&serialized[len],sizeof(rp->relaybits),&rp->relaybits);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(rp->optionhours),&rp->optionhours);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(rp->srcamount),&rp->srcamount);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(rp->minamount),&rp->minamount);
len += iguana_rwbignum(rwflag,&serialized[len],sizeof(rp->srchash),rp->srchash.bytes);
@ -163,6 +163,8 @@ cJSON *basilisk_requestjson(struct basilisk_request *rp)
jaddnum(item,"timestamp",rp->timestamp);
jaddnum(item,"requestid",rp->requestid);
jaddnum(item,"quoteid",rp->quoteid);
jaddnum(item,"optionhours",rp->optionhours);
jaddnum(item,"profit",(double)rp->profitmargin / 1000000.);
if ( rp->quoteid != 0 && basilisk_quoteid(rp) != rp->quoteid )
printf("quoteid mismatch %u vs %u\n",basilisk_quoteid(rp),rp->quoteid);
if ( basilisk_requestid(rp) != rp->requestid )
@ -171,7 +173,7 @@ cJSON *basilisk_requestjson(struct basilisk_request *rp)
int32_t i; struct basilisk_request R;
if ( basilisk_parsejson(&R,item) != 0 )
{
if ( memcmp(&R,rp,sizeof(*rp)) != 0 )
if ( memcmp(&R,rp,sizeof(*rp)-sizeof(uint32_t)) != 0 )
{
for (i=0; i<sizeof(*rp); i++)
printf("%02x",((uint8_t *)rp)[i]);
@ -207,6 +209,8 @@ int32_t basilisk_request_create(struct basilisk_request *rp,cJSON *valsobj,bits2
rp->minamount = j64bits(valsobj,"minamount");
rp->timestamp = timestamp;
rp->srchash = jbits256(valsobj,"srchash");
rp->optionhours = jint(valsobj,"optionhours");
rp->profitmargin = jdouble(valsobj,"profit") * 1000000;
strncpy(rp->src,src,sizeof(rp->src)-1);
strncpy(rp->dest,dest,sizeof(rp->dest)-1);
//if ( jstr(valsobj,"relay") != 0 )
@ -223,13 +227,13 @@ int32_t basilisk_request_create(struct basilisk_request *rp,cJSON *valsobj,bits2
return(-1);
}
char *basilisk_start(struct supernet_info *myinfo,struct basilisk_request *rp,uint32_t statebits)
char *basilisk_start(struct supernet_info *myinfo,struct basilisk_request *rp,uint32_t statebits,int32_t optionduration)
{
cJSON *retjson;
if ( (bits256_cmp(rp->srchash,myinfo->myaddr.persistent) == 0 || bits256_cmp(rp->desthash,myinfo->myaddr.persistent) == 0) )
{
printf("START thread to complete %u/%u for (%s %.8f) <-> (%s %.8f) q.%u\n",rp->requestid,rp->quoteid,rp->src,dstr(rp->srcamount),rp->dest,dstr(rp->destamount),rp->quoteid);
if ( basilisk_thread_start(myinfo,rp) != 0 )
if ( basilisk_thread_start(myinfo,rp,statebits,optionduration) != 0 )
{
basilisk_request_enqueue(myinfo,rp);
return(clonestr("{\"result\":\"started atomic swap thread\"}"));
@ -267,6 +271,7 @@ void basilisk_requests_poll(struct supernet_info *myinfo)
}
free(retstr);
} else printf("null incoming\n");
channel = 'D' + ((uint32_t)'E' << 8) + ((uint32_t)'X' << 16);
if ( hwm > 0. )
{
printf("hwm %f\n",hwm);
@ -275,8 +280,20 @@ void basilisk_requests_poll(struct supernet_info *myinfo)
printf("my req hwm %f\n",hwm);
if ( (retstr= InstantDEX_accept(myinfo,0,0,0,issueR.requestid,issueR.quoteid)) != 0 )
free(retstr);
if ( (retstr= basilisk_start(myinfo,&issueR,1)) != 0 )
basilisk_channelsend(myinfo,issueR.srchash,issueR.desthash,channel,0x4000000,(void *)&issueR.requestid,sizeof(issueR.requestid),60);
numiters = 0;
while ( numiters < 10 && (crc= basilisk_swapcrcsend(myinfo,buf,sizeof(buf),issueR.srchash,issueR.desthash,channel,0x4000000,(void *)&issueR.requestid,sizeof(issueR.requestid),crcs)) == 0 )
{
printf("didnt get back what was sent\n");
sleep(3);
basilisk_channelsend(myinfo,issueR.srchash,issueR.desthash,channel,0x4000000,(void *)&issueR.requestid,sizeof(issueR.requestid),60);
numiters++;
}
if ( crc != 0 )
{
if ( (retstr= basilisk_start(myinfo,&issueR,1,issueR.optionhours * 3600)) != 0 )
free(retstr);
} else printf("couldnt accept offer\n");
}
else //if ( issueR.quoteid == 0 )
{
@ -285,7 +302,6 @@ void basilisk_requests_poll(struct supernet_info *myinfo)
issueR.desthash = myinfo->myaddr.persistent;
datalen = basilisk_rwDEXquote(1,data,&issueR);
msgid = (uint32_t)time(NULL);
channel = 'D' + ((uint32_t)'E' << 8) + ((uint32_t)'X' << 16);
crcs[0] = crcs[1] = 0;
numiters = 0;
basilisk_channelsend(myinfo,issueR.desthash,issueR.srchash,channel,msgid,data,datalen,INSTANTDEX_LOCKTIME*2);
@ -299,7 +315,7 @@ void basilisk_requests_poll(struct supernet_info *myinfo)
if ( crc != 0 )
{
printf("crc.%08x -> basilisk_start\n",crc);
if ( (retstr= basilisk_start(myinfo,&issueR,0)) != 0 )
if ( (retstr= basilisk_start(myinfo,&issueR,0,issueR.optionhours * 3600)) != 0 )
free(retstr);
}
} //else printf("basilisk_requests_poll unexpected hwm issueR\n");
@ -424,7 +440,7 @@ char *basilisk_respond_accept(struct supernet_info *myinfo,uint32_t requestid,ui
if ( rp->requestid == requestid && rp->quoteid == quoteid )
{
printf("start from accept\n");
retstr = basilisk_start(myinfo,rp,1);
retstr = basilisk_start(myinfo,rp,1,0);
break;
}
}
@ -511,7 +527,7 @@ STRING_ARG(InstantDEX,available,source)
HASH_ARRAY_STRING(InstantDEX,request,hash,vals,hexstr)
{
uint8_t serialized[512]; struct basilisk_request R; cJSON *reqjson; uint32_t datalen=0,DEX_channel;
uint8_t serialized[512]; char buf[512]; struct basilisk_request R; int32_t iambob,optionhours; cJSON *reqjson; uint32_t datalen=0,DEX_channel; struct iguana_info *bobcoin,*alicecoin;
myinfo->DEXactive = (uint32_t)time(NULL) + 3*BASILISK_TIMEOUT + 60;
jadd64bits(vals,"minamount",jdouble(vals,"minprice") * jdouble(vals,"amount") * SATOSHIDEN);
if ( jobj(vals,"srchash") == 0 )
@ -526,7 +542,23 @@ HASH_ARRAY_STRING(InstantDEX,request,hash,vals,hexstr)
memset(&R,0,sizeof(R));
if ( basilisk_request_create(&R,vals,hash,juint(vals,"timestamp")) == 0 )
{
printf("R.requestid.%u vs calc %u, q.%u\n",R.requestid,basilisk_requestid(&R),R.quoteid);
iambob = bitcoin_coinptrs(myinfo,&bobcoin,&alicecoin,R.src,R.dest,myinfo->myaddr.persistent,GENESIS_PUBKEY);
if ( (optionhours= jint(vals,"optionhours")) != 0 )
{
printf("iambob.%d optionhours.%d R.requestid.%u vs calc %u, q.%u\n",iambob,R.optionhours,R.requestid,basilisk_requestid(&R),R.quoteid);
if ( iambob != 0 && optionhours > 0 )
{
sprintf(buf,"{\"error\":\"illegal call option request hours.%d when iambob.%d\"}",optionhours,iambob);
printf("ERROR.(%s)\n",buf);
return(clonestr(buf));
}
else if ( iambob == 0 && optionhours < 0 )
{
sprintf(buf,"{\"error\":\"illegal put option request hours.%d when iambob.%d\"}",optionhours,iambob);
printf("ERROR.(%s)\n",buf);
return(clonestr(buf));
}
}
//if ( myinfo->IAMNOTARY != 0 || myinfo->NOTARY.RELAYID >= 0 )
// R.relaybits = myinfo->myaddr.myipbits;
if ( (reqjson= basilisk_requestjson(&R)) != 0 )

44
basilisk/basilisk_bitcoin.c

@ -542,6 +542,46 @@ int32_t basilisk_vins_validate(struct supernet_info *myinfo,struct iguana_info *
return(retval);
}
char *iguana_utxoduplicates(struct supernet_info *myinfo,struct iguana_info *coin,bits256 privkey,uint64_t satoshis,int32_t duplicates,int32_t *completedp,bits256 *signedtxidp,int32_t sendflag)
{
uint8_t script[35],pubkey33[33]; int32_t i,spendlen; cJSON *txobj=0,*addresses=0,*vins=0; char *rawtx=0,*signedtx,changeaddr[64];
*completedp = 0;
if ( signedtxidp != 0 )
memset(signedtxidp,0,sizeof(*signedtxidp));
bitcoin_address(changeaddr,coin->chain->pubtype,myinfo->persistent_pubkey33,33);
if ( (txobj= bitcoin_txcreate(coin->chain->isPoS,0,1,0)) != 0 )
{
if ( duplicates <= 0 )
duplicates = 1;
bitcoin_pubkey33(myinfo->ctx,pubkey33,privkey);
spendlen = bitcoin_pubkeyspend(script,0,pubkey33);
for (i=0; i<duplicates; i++)
bitcoin_txoutput(txobj,script,spendlen,satoshis);
addresses = iguana_getaddressesbyaccount(myinfo,coin,"*");
rawtx = iguana_calcrawtx(myinfo,coin,&vins,txobj,satoshis * duplicates,changeaddr,coin->txfee + duplicates*coin->txfee/10,addresses,0,0,0,0,"127.0.0.1",0,1);
printf("duplicatesTX.(%s)\n",rawtx);
if ( signedtxidp != 0 )
{
if ( (signedtx= iguana_signrawtx(myinfo,coin,0,signedtxidp,completedp,vins,rawtx,0,0)) != 0 )
{
free(rawtx);
if ( *completedp != 0 && sendflag != 0 )
{
iguana_sendrawtransaction(myinfo,coin,signedtx);
}
rawtx = signedtx;
} else printf("error signing raw utxoduplicates tx\n");
}
}
if ( vins != 0 )
free_json(vins);
if ( txobj != 0 )
free_json(txobj);
if ( addresses != 0 )
free_json(addresses);
return(rawtx);
}
char *basilisk_bitcoinrawtx(struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,uint32_t basilisktag,int32_t timeoutmillis,cJSON *valsobj,struct vin_info *V)
{
uint8_t buf[4096]; int32_t oplen,offset,minconf,spendlen; cJSON *vins,*addresses,*txobj = 0; uint32_t locktime; char *opreturn,*spendscriptstr,*changeaddr,*rawtx = 0; int64_t amount,txfee,burnamount;
@ -571,7 +611,7 @@ char *basilisk_bitcoinrawtx(struct supernet_info *myinfo,struct iguana_info *coi
return(clonestr("{\"error\":\"invalid changeaddr or spendscript or addresses\"}"));
if ( coin != 0 )
{
if ( (txobj= bitcoin_txcreate(coin->chain->isPoS,locktime,locktime==0?coin->chain->normal_txversion:coin->chain->locktime_txversion)) != 0 )
if ( (txobj= bitcoin_txcreate(coin->chain->isPoS,locktime,locktime==0?coin->chain->normal_txversion:coin->chain->locktime_txversion,juint(valsobj,"timestamp"))) != 0 )
{
spendlen = (int32_t)strlen(spendscriptstr) >> 1;
decode_hex(buf,spendlen,spendscriptstr);
@ -593,7 +633,7 @@ char *basilisk_bitcoinrawtx(struct supernet_info *myinfo,struct iguana_info *coi
oplen = 0;
} else oplen = datachain_opreturnscript(coin,buf,opreturn,oplen);
}
rawtx = iguana_calcrawtx(myinfo,coin,&vins,txobj,amount,changeaddr,txfee,addresses,minconf,oplen!=0?buf:0,oplen+offset,burnamount,remoteaddr,V);
rawtx = iguana_calcrawtx(myinfo,coin,&vins,txobj,amount,changeaddr,txfee,addresses,minconf,oplen!=0?buf:0,oplen+offset,burnamount,remoteaddr,V,0);
//printf("generated.(%s) vins.(%s)\n",rawtx!=0?rawtx:"",vins!=0?jprint(vins,0):"");
}
if ( rawtx != 0 )

1153
basilisk/basilisk_swap.c

File diff suppressed because it is too large

265
basilisk/basilisk_tradebot.c

@ -14,13 +14,243 @@
******************************************************************************/
// included from basilisk.c
void basilisk_swap_balancingtrade(struct supernet_info *myinfo,struct basilisk_swap *swap,int32_t iambob)
{
// update balance, compare to target balance, issue balancing trade via central exchanges, if needed
double price,volume,srcamount,destamount,profitmargin,dir=0.,dotrade=1.; char base[64],rel[64];
srcamount = swap->I.req.srcamount;
destamount = swap->I.req.destamount;
profitmargin = (double)swap->I.req.profitmargin / 1000000.;
if ( srcamount <= SMALLVAL || destamount <= SMALLVAL )
{
printf("illegal amount for balancing %f %f\n",srcamount,destamount);
return;
}
strcpy(rel,"BTC");
if ( strcmp(swap->I.req.src,"BTC") == 0 )
{
strcpy(base,swap->I.req.dest);
price = (srcamount / destamount);
volume = destamount / SATOSHIDEN;
dir = -1.;
}
else if ( strcmp(swap->I.req.dest,"BTC") == 0 )
{
strcpy(base,swap->I.req.src);
price = (destamount / srcamount);
volume = srcamount / SATOSHIDEN;
dir = 1.;
}
else
{
printf("only BTC trades can be balanced, not (%s/%s)\n",swap->I.req.src,swap->I.req.dest);
return;
}
if ( iambob != 0 )
{
if ( myinfo->IAMLP != 0 )
{
printf("BOB: price %f * vol %f -> %s newprice %f margin %.2f%%\n",price,volume,dir < 0. ? "buy" : "sell",price + dir * price * profitmargin,100*profitmargin);
if ( dir < 0. )
InstantDEX_buy(myinfo,0,0,0,"poloniex",base,rel,price,volume,dotrade);
else InstantDEX_sell(myinfo,0,0,0,"poloniex",base,rel,price,volume,dotrade);
}
}
else
{
if ( myinfo->IAMLP != 0 )
{
printf("ALICE: price %f * vol %f -> %s newprice %f margin %.2f%%\n",price,volume,dir > 0. ? "buy" : "sell",price - dir * price * profitmargin,100*profitmargin);
if ( dir > 0. )
InstantDEX_buy(myinfo,0,0,0,"poloniex",base,rel,price,volume,dotrade);
else InstantDEX_sell(myinfo,0,0,0,"poloniex",base,rel,price,volume,dotrade);
}
}
}
cJSON *basilisk_rawtxobj(struct supernet_info *myinfo,struct basilisk_swap *swap,struct basilisk_rawtx *rawtx)
{
char hexstr[sizeof(rawtx->I)*2+1+4096]; cJSON *obj = cJSON_CreateObject();
jaddstr(obj,"name",rawtx->name);
init_hexbytes_noT(hexstr,(void *)&rawtx->I,sizeof(rawtx->I));
jaddstr(obj,"info",hexstr);
if ( rawtx->I.datalen < sizeof(hexstr)/2 )
{
init_hexbytes_noT(hexstr,(void *)rawtx->txbytes,rawtx->I.datalen);
jaddstr(obj,"txbytes",hexstr);
}
return(obj);
}
struct basilisk_rawtx *basilisk_nameconv(struct supernet_info *myinfo,struct basilisk_swap *swap,char *name)
{
if ( strcmp("myfee",name) == 0 )
return(&swap->myfee);
else if ( strcmp("otherfee",name) == 0 )
return(&swap->otherfee);
else if ( strcmp("bobdeposit",name) == 0 )
return(&swap->bobdeposit);
else if ( strcmp("bobrefund",name) == 0 )
return(&swap->bobrefund);
else if ( strcmp("aliceclaim",name) == 0 )
return(&swap->aliceclaim);
else if ( strcmp("bobpayment",name) == 0 )
return(&swap->bobpayment);
else if ( strcmp("alicespend",name) == 0 )
return(&swap->alicespend);
else if ( strcmp("bobreclaim",name) == 0 )
return(&swap->bobreclaim);
else if ( strcmp("alicepayment",name) == 0 )
return(&swap->alicepayment);
else if ( strcmp("bobspend",name) == 0 )
return(&swap->bobspend);
else if ( strcmp("alicereclaim",name) == 0 )
return(&swap->alicereclaim);
else return(0);
}
int32_t basilisk_txitem(struct supernet_info *myinfo,struct basilisk_swap *swap,cJSON *obj)
{
char *hexstr,*name; struct basilisk_rawtx *rawtx = 0;
if ( (name= jstr(obj,"name")) == 0 || (rawtx= basilisk_nameconv(myinfo,swap,name)) == 0 )
{
printf("basilisk_txitem illegal name.(%s)\n",name);
return(-1);
}
if ( rawtx != 0 && (hexstr= jstr(obj,"info")) != 0 && strlen(hexstr) == sizeof(rawtx->I)*2 )
{
decode_hex((void *)&rawtx->I,sizeof(rawtx->I),hexstr);
if ( (hexstr= jstr(obj,"txbytes")) != 0 && strlen(hexstr) == rawtx->I.datalen*2 )
{
if ( rawtx->txbytes == 0 )
{
printf("free (%s) txbytes\n",name);
free(rawtx->txbytes);
}
rawtx->txbytes = calloc(1,rawtx->I.datalen);
decode_hex((void *)rawtx->txbytes,rawtx->I.datalen,hexstr);
}
printf("PROCESS.(%s)\n",jprint(obj,0));
return(0);
}
return(-1);
}
cJSON *basilisk_swapobj(struct supernet_info *myinfo,struct basilisk_swap *swap)
{
char hexstr[sizeof(swap->I)*2+1]; cJSON *obj = cJSON_CreateObject();
init_hexbytes_noT(hexstr,(void *)&swap->I,sizeof(swap->I));
jaddstr(obj,"name","swap");
jaddnum(obj,"requestid",swap->I.req.requestid);
jaddnum(obj,"quoteid",swap->I.req.quoteid);
jadd(obj,"req",basilisk_requestjson(&swap->I.req));
jaddstr(obj,"info",hexstr);
return(obj);
}
int32_t basilisk_swapconv(struct supernet_info *myinfo,struct basilisk_swap *swap,cJSON *obj)
{
char *hexstr;
if ( (hexstr= jstr(obj,"info")) != 0 && strlen(hexstr) == sizeof(swap->I)*2 )
{
decode_hex((void *)&swap->I,sizeof(swap->I),hexstr);
if ( juint(obj,"requestid") == swap->I.req.requestid && juint(obj,"quoteid") == swap->I.req.quoteid )
return(0);
printf("swapconv mismatched req/quote %d %d, %d %d\n",juint(obj,"requestid"),swap->I.req.requestid,juint(obj,"quoteid"),swap->I.req.quoteid);
} else printf("no info field in swap obj\n");
return(-1);
}
struct basilisk_swap *basilisk_swapstore(struct supernet_info *myinfo,struct basilisk_swap *swap)
{
// save based on requestid/quoteid
return(swap);
}
struct basilisk_swap *basilisk_swapload(struct supernet_info *myinfo,struct basilisk_swap *swap,uint32_t requestid,uint32_t quoteid)
{
return(swap);
}
void basilisk_swapstart(struct supernet_info *myinfo) // scan saved tmpswap, purge if complete, else Q
{
}
void basilisk_txlog(struct supernet_info *myinfo,struct basilisk_swap *swap,struct basilisk_rawtx *rawtx,int32_t delay)
{
char fname[1024],*jsonstr; long filesize; cJSON *item,*dexobj = 0; int32_t i,n,pending; struct basilisk_swap tmpswap,*swapptr;
sprintf(fname,"%s/DEX.log",GLOBAL_DBDIR), OS_compatible_path(fname);
if ( myinfo->dexfp == 0 )
{
if ( (jsonstr= OS_filestr(&filesize,fname)) != 0 )
{
jsonstr[strlen(jsonstr)-1] = ']';
if ( jsonstr[strlen(jsonstr)-2] == ',' )
jsonstr[strlen(jsonstr)-2] = ' ';
if ( jsonstr[strlen(jsonstr)-3] == ',' )
jsonstr[strlen(jsonstr)-3] = ' ';
if ( (dexobj= cJSON_Parse(jsonstr)) != 0 )
{
if ( is_cJSON_Array(dexobj) != 0 && (n= cJSON_GetArraySize(dexobj)) > 0 )
{
pending = 0;
memset(&tmpswap,0,sizeof(tmpswap));
swapptr = 0;
for (i=0; i<n; i++)
{
item = jitem(dexobj,i);
if ( jstr(item,"name") != 0 && strcmp(jstr(item,"name"),"swap") == 0 )
{
if ( basilisk_swapconv(myinfo,&tmpswap,item) == 0 )
swapptr = basilisk_swapstore(myinfo,&tmpswap);
}
else if ( swapptr != 0 )
{
if ( swapptr->I.req.requestid == juint(item,"requestid") && swapptr->I.req.quoteid == juint(item,"quoteid") )
basilisk_txitem(myinfo,swapptr,item);
}
else if ( (swapptr= basilisk_swapload(myinfo,&tmpswap,juint(item,"requestid"),juint(item,"quoteid"))) != 0 )
basilisk_txitem(myinfo,swapptr,item);
}
basilisk_swapstart(myinfo);
}
free_json(dexobj);
dexobj = 0;
} else printf("basilisk_txlog error parsing.(%s)\n",jsonstr);
free(jsonstr);
}
if ( (myinfo->dexfp= fopen(fname,"rb+")) != 0 )
fseek(myinfo->dexfp,0,SEEK_END);
else if ( (myinfo->dexfp= fopen(fname,"wb")) != 0 )
fprintf(myinfo->dexfp,"[\n");
}
if ( rawtx != 0 )
{
// delay -1 -> dont issue, else submit after block timestamp is delay after swap->started
dexobj = basilisk_rawtxobj(myinfo,swap,rawtx);
}
else if ( swap != 0 )
dexobj = basilisk_swapobj(myinfo,swap);
if ( dexobj != 0 && (jsonstr= jprint(dexobj,1)) != 0 )
{
//printf("%s\n",jsonstr);
if ( myinfo->dexfp != 0 )
{
fprintf(myinfo->dexfp,"%s,\n",jsonstr);
fflush(myinfo->dexfp);
}
free(jsonstr);
}
}
uint32_t basilisk_requestid(struct basilisk_request *rp)
{
struct basilisk_request R;
R = *rp;
R.requestid = R.quoteid = R.quotetime = 0;
R.destamount = 0;
R.destamount = R.profitmargin = 0;
//R.relaybits = 0;
memset(R.desthash.bytes,0,sizeof(R.desthash.bytes));
if ( 0 )
@ -38,7 +268,7 @@ uint32_t basilisk_quoteid(struct basilisk_request *rp)
{
struct basilisk_request R;
R = *rp;
R.requestid = R.quoteid = 0; //R.relaybits =
R.requestid = R.quoteid = R.profitmargin = 0; //R.relaybits =
return(calc_crc32(0,(void *)&R,sizeof(R)));
}
@ -75,26 +305,12 @@ struct basilisk_request *basilisk_parsejson(struct basilisk_request *rp,cJSON *r
return(rp);
}
void basilisk_swap_balancingtrade(struct supernet_info *myinfo,struct basilisk_swap *swap,int32_t iambob)
{
// update balance, compare to target balance, issue balancing trade via central exchanges, if needed
if ( iambob != 0 )
{
}
else
{
}
}
struct basilisk_swap *basilisk_request_started(struct supernet_info *myinfo,uint32_t requestid)
{
int32_t i; struct basilisk_swap *active = 0;
portable_mutex_lock(&myinfo->DEX_swapmutex);
for (i=0; i<myinfo->numswaps; i++)
if ( myinfo->swaps[i]->req.requestid == requestid )
if ( myinfo->swaps[i]->I.req.requestid == requestid )
{
//printf("REQUEST STARTED.[%d] <- req.%u\n",i,requestid);
active = myinfo->swaps[i];
@ -160,12 +376,16 @@ double tradebot_liquidity_active(struct supernet_info *myinfo,double *refpricep,
double basilisk_request_listprocess(struct supernet_info *myinfo,struct basilisk_request *issueR,struct basilisk_request *list,int32_t n)
{
int32_t i,noquoteflag=0,havequoteflag=0,myrequest=0,maxi=-1; uint64_t balance=0,destamount,minamount = 0,maxamount = 0; uint32_t pendingid=0; struct basilisk_swap *active; double metric = 0.;
int32_t i,noquoteflag=0,havequoteflag=0,myrequest=0,maxi=-1; int64_t balance=0,destamount,minamount = 0,maxamount = 0; uint32_t pendingid=0; struct basilisk_swap *active; double metric = 0.;
memset(issueR,0,sizeof(*issueR));
minamount = list[0].minamount;
//printf("need to verify null quoteid is list[0] requestid.%u quoteid.%u\n",list[0].requestid,list[0].quoteid);
if ( (active= basilisk_request_started(myinfo,list[0].requestid)) != 0 )
pendingid = active->req.quoteid;
{
if ( active->I.req.quoteid != 0 )
return(0.);
pendingid = active->I.req.quoteid;
}
if ( bits256_cmp(myinfo->myaddr.persistent,list[0].srchash) == 0 ) // my request
myrequest = 1;
for (i=0; i<n; i++)
@ -198,7 +418,9 @@ double basilisk_request_listprocess(struct supernet_info *myinfo,struct basilisk
aveprice = refprice;
if ( fabs(aveprice) < SMALLVAL )
return(0);
destamount = (1.0 - profitmargin) * aveprice * list[0].srcamount;
printf("avebid %f bidvol %f, aveask %f askvol %f\n",retvals[0],retvals[1],retvals[2],retvals[3]);
//retvals[0] = avebid, retvals[1] = bidvol, retvals[2] = aveask, retvals[3] = askvol;
destamount = (1.0 - profitmargin) * retvals[0] * list[0].srcamount;
if ( (retstr= InstantDEX_available(myinfo,iguana_coinfind(list[0].dest),0,0,list[0].dest)) != 0 )
{
if ( (retjson= cJSON_Parse(retstr)) != 0 )
@ -210,13 +432,14 @@ double basilisk_request_listprocess(struct supernet_info *myinfo,struct basilisk
}
// BTC balance 0.00500000 destamount 0.00041951 aveprice 0.00421619 minamount 0.00020000
printf("%s balance %.8f destamount %.8f aveprice %.8f minamount %.8f\n",list[0].dest,dstr(balance),dstr(destamount),aveprice,dstr(minamount));
if ( balance > destamount && destamount > 0 && destamount >= maxamount && destamount >= minamount )
if ( balance > destamount && (int64_t)destamount > 0 && destamount >= maxamount && destamount >= minamount )
{
metric = 1.;
*issueR = list[0];
issueR->desthash = myinfo->myaddr.persistent;
issueR->destamount = destamount;
issueR->quotetime = (uint32_t)time(NULL);
issueR->profitmargin = (uint32_t)(profitmargin * 1000000);
printf("issueR set!\n");
}
}

1
crypto777/OS_portable.h

@ -44,6 +44,7 @@
#define sleep(x) Sleep(1000*(x))
#include "../OSlibs/win/mingw.h"
#include "../OSlibs/win/mman.h"
#define PTW32_STATIC_LIB
#include "../OSlibs/win/pthread.h"
#ifndef NATIVE_WINDOWS

2
gecko/gecko_miner.c

@ -302,7 +302,7 @@ cJSON *gecko_paymentsobj(struct supernet_info *myinfo,cJSON *txjson,cJSON *valso
if ( (txversion= juint(valsobj,"txversion")) == 0 )
txversion = (locktime == 0) ? IGUANA_NORMAL_TXVERSION : IGUANA_LOCKTIME_TXVERSION;
if ( txjson == 0 )
txjson = bitcoin_txcreate(1,locktime,txversion);
txjson = bitcoin_txcreate(1,locktime,txversion,juint(valsobj,"timestamp"));
if ( (array= jarray(&n,valsobj,"payments")) != 0 && n > 0 )
{
for (i=0; i<n; i++)

18
iguana.vcxproj

@ -51,6 +51,7 @@
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>Static</UseOfMfc>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
@ -81,6 +82,7 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<EmbedManifest>false</EmbedManifest>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@ -137,15 +139,16 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;NATIVE_WINDOWS;WIN32;_CONSOLE;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StructMemberAlignment>1Byte</StructMemberAlignment>
<PreprocessorDefinitions>WIN64;_WIN64;_CRT_SECURE_NO_WARNINGS;NATIVE_WINDOWS;WIN32;_CONSOLE;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StructMemberAlignment>8Bytes</StructMemberAlignment>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>Ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>Ws2_32.lib;Advapi32.lib;$(SolutionDir)OSlibs\win\x64\pthread_lib.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
@ -282,15 +285,6 @@
<ClCompile Include="iguana\SuperNET_keys.c" />
<ClCompile Include="OSlibs\win\mingw.c" />
</ItemGroup>
<ItemGroup>
<Library Include="pthreadVC2.lib" />
<Library Include="OSlibs\win\libpthreadGC2.a" />
<Library Include="OSlibs\win\libpthreadGC2_64.a" />
</ItemGroup>
<ItemGroup>
<None Include="pthreadvc2.dll" />
<None Include="ucrtbased.dll" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>

9
iguana.vcxproj.filters

@ -131,15 +131,6 @@
<ClInclude Include="OSlibs\win\pthread.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<Library Include="pthreadVC2.lib" />
<Library Include="OSlibs\win\libpthreadGC2.a" />
<Library Include="OSlibs\win\libpthreadGC2_64.a" />
</ItemGroup>
<ItemGroup>
<None Include="pthreadvc2.dll" />
<None Include="ucrtbased.dll" />
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>

2
iguana/coins/genanc.json

@ -1 +1 @@
{"RELAY":1,"VALIDATE":1,"prefetchlag":-1,"poll":10,"active":1,"agent":"iguana","method":"addcoin","maxpeers":256,"newcoin":"ANC","name":"AnonCoin","netmagic":"facabada","p2p":9377,"rpc":28332,"pubval":23,"p2shval":5,"wifval":151,"txfee_satoshis":"2000000","minconfirms":2,"genesishash":"00000be19c5a519257aa921349037d55548af7cabf112741eb905a26bb73e468","genesis":{"version":1,"timestamp":1370190760,"nBits":"1e0ffff0","nonce":347089008,"merkle_root":"7ce7004d764515f9b43cb9f07547c8e2e00d94c9348b3da33c8681d350f2c736"},"alertpubkey":"04c6db35c11724e526f6725cc5bd5293b4bc9382397856e1bcef7111fb44ce357fd12442b34c496d937a348c1dca1e36ae0c0e128905eb3d301433887e8f0b4536",\"protover\":70010}
{"RELAY":1,"VALIDATE":1,"prefetchlag":-1,"poll":10,"active":1,"agent":"iguana","method":"addcoin","maxpeers":256,"newcoin":"ANC","name":"AnonCoin","netmagic":"facabada","p2p":9377,"rpc":28332,"pubval":23,"p2shval":5,"wifval":151,"txfee_satoshis":"2000000","minconfirms":2,"genesishash":"00000be19c5a519257aa921349037d55548af7cabf112741eb905a26bb73e468","genesis":{"version":1,"timestamp":1370190760,"nBits":"1e0ffff0","nonce":347089008,"merkle_root":"7ce7004d764515f9b43cb9f07547c8e2e00d94c9348b3da33c8681d350f2c736"},"alertpubkey":"04c6db35c11724e526f6725cc5bd5293b4bc9382397856e1bcef7111fb44ce357fd12442b34c496d937a348c1dca1e36ae0c0e128905eb3d301433887e8f0b4536","protover":70010}

2
iguana/exchanges/bitcoin.c

@ -144,7 +144,6 @@ int32_t bitcoin_priv2wif(char *wifstr,bits256 privkey,uint8_t addrtype)
return((int32_t)strlen(wifstr));
}
#ifdef bitcoincancalulatebalances
uint64_t bitcoin_parseunspent(struct iguana_info *coin,struct bitcoin_unspent *unspent,double minconfirms,char *account,cJSON *item)
{
char *hexstr,coinaddr[64];
@ -385,7 +384,6 @@ char *bitcoin_calcrawtx(struct supernet_info *myinfo,struct iguana_info *coin,cJ
printf("need to patch locktime\n");
return(rawtx);
}
#endif
#define EXCHANGE_NAME "bitcoin"
#define UPDATE bitcoin ## _price

1
iguana/exchanges/poloniex.c

@ -160,6 +160,7 @@ uint64_t TRADE(int32_t dotrade,char **retstrp,struct exchange_info *exchange,cha
if ( CHECKBALANCE(retstrp,dotrade,exchange,dir,base,rel,price,volume,argjson) == 0 && (json= SIGNPOST(&exchange->cHandle,dotrade,retstrp,exchange,EXCHANGE_AUTHURL,payload)) != 0 )
{
txid = (get_API_nxt64bits(cJSON_GetObjectItem(json,"orderNumber")) << 32) | get_API_nxt64bits(cJSON_GetObjectItem(json,"tradeID"));
printf("poloniex.%llu (%s)\n",(long long)txid,jprint(json,0));
free_json(json);
}
return(txid);

2
iguana/iguana.sources

@ -1,2 +1,2 @@
SOURCES := iguana_bundles.c iguana_mofn.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 iguana_chains.c iguana_ramchain.c iguana_secp.c pangea_api.c peggy_ramkv.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_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 ../gecko/gecko.c ../basilisk/basilisk.c ../datachain/datachain.c secp256k1/src/secp256k1.c
SOURCES := iguana_notary.c iguana_bundles.c iguana_mofn.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 iguana_chains.c iguana_ramchain.c iguana_secp.c pangea_api.c peggy_ramkv.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_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 ../gecko/gecko.c ../basilisk/basilisk.c ../datachain/datachain.c secp256k1/src/secp256k1.c

4
iguana/iguana777.c

@ -1232,7 +1232,3 @@ char *busdata_sync(uint32_t *noncep,char *jsonstr,char *broadcastmode,char *dest
return(0);
}
// getnewaddress, setaccount, validate address, restart, validate address
// importprivkey, setaccount, validate, restart, validate

1
iguana/iguana777.h

@ -89,6 +89,7 @@ struct supernet_info
struct basilisk_message *messagetable; portable_mutex_t messagemutex; queue_t msgQ,p2pQ;
void *ctx;
uint8_t *pingbuf;
FILE *dexfp;
struct delayedPoW_info dPoW;
struct basilisk_spend *spends; int32_t numspends;
struct peggy_info *PEGS;

35
iguana/iguana_interpreter.c

@ -858,12 +858,21 @@ int32_t iguana_checklocktimeverify(struct iguana_info *coin,int64_t tx_lockval,u
{
int64_t nLockTime = iguana_num(Snum);
if ( nLockTime < 0 || tx_lockval < 0 )
{
printf("CLTV.0 nLockTime.%lld tx_lockval.%lld\n",(long long)nLockTime,(long long)tx_lockval);
return(-1);
}
else if ( ((tx_lockval < LOCKTIME_THRESHOLD && nLockTime < LOCKTIME_THRESHOLD) ||
(tx_lockval >= LOCKTIME_THRESHOLD && nLockTime >= LOCKTIME_THRESHOLD)) == 0 )
{
printf("CLTV.1 nLockTime.%lld tx_lockval.%lld\n",(long long)nLockTime,(long long)tx_lockval);
return(-1);
}
else if ( nLockTime > tx_lockval )
{
printf("CLTV.2 nLockTime.%lld tx_lockval.%lld\n",(long long)nLockTime,(long long)tx_lockval);
return(-1);
}
return(0);
}
@ -1233,7 +1242,7 @@ int32_t bitcoin_assembler(struct iguana_info *coin,cJSON *logarray,uint8_t scrip
errs++;
}
stacks->ifdepth--;
printf("OP_ENDIF status.%d depth.%d\n",stacks->lastpath[stacks->ifdepth],stacks->stackdepth);
//printf("OP_ENDIF status.%d depth.%d\n",stacks->lastpath[stacks->ifdepth],stacks->stackdepth);
break;
case IGUANA_OP_VERIFY:
break;
@ -1352,12 +1361,32 @@ int32_t bitcoin_assembler(struct iguana_info *coin,cJSON *logarray,uint8_t scrip
iguana_pushdata(stacks,0,rmd160,sizeof(rmd160));
break;
case IGUANA_OP_HASH160:
if ( datalen == 32 )
/*if ( datalen == 32 )
{
revcalc_rmd160_sha256(rmd160,*(bits256 *)databuf);
printf("SPECIAL CASE REVERSE\n");
} else
for (i=0; i<32; i++)
printf("%02x",databuf[i]);
printf(" <- databuf\n");
for (i=0; i<32; i++)
printf("%02x",revdatabuf[i]);
printf(" <- revdatabuf\n");
calc_rmd160_sha256(rmd160,revdatabuf,datalen);
for (i=0; i<20; i++)
printf("%02x",rmd160[i]);
printf(" <- rmd160 revdatabuf\n");
revcalc_rmd160_sha256(rmd160,*(bits256 *)databuf);
for (i=0; i<20; i++)
printf("%02x",rmd160[i]);
printf(" <- rmd160 special\n");
calc_rmd160_sha256(rmd160,databuf,datalen);
for (i=0; i<20; i++)
printf("%02x",rmd160[i]);
printf(" <- rmd160 databuf\n");*/
if ( datalen == 32 )
calc_rmd160_sha256(rmd160,revdatabuf,datalen);
else calc_rmd160_sha256(rmd160,databuf,datalen);
iguana_pushdata(stacks,0,rmd160,sizeof(rmd160));
break;
case IGUANA_OP_SHA256:
@ -1387,7 +1416,7 @@ int32_t bitcoin_assembler(struct iguana_info *coin,cJSON *logarray,uint8_t scrip
}
else if ( op->opcode == IGUANA_OP_CHECKLOCKTIMEVERIFY ) // former OP_NOP2
{
if ( iguana_checklocktimeverify(coin,nLockTime,V->sequence,args[0]) < 0 )
if ( V->ignore_cltverr == 0 && iguana_checklocktimeverify(coin,nLockTime,V->sequence,args[0]) < 0 )
{
iguana_stack(stacks,args,1,"0","");
errs++;

21
iguana/iguana_notary.c

@ -0,0 +1,21 @@
/******************************************************************************
* Copyright © 2014-2016 The SuperNET Developers. *
* *
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at *
* the top-level directory of this distribution for the individual copyright *
* holder information and the developer policies on copyright and licensing. *
* *
* Unless otherwise agreed in a custom licensing agreement, no part of the *
* SuperNET software, including this file may be copied, modified, propagated *
* or distributed except according to the terms contained in the LICENSE file *
* *
* Removal or modification of this copyright notice is prohibited. *
* *
******************************************************************************/
#include "iguana777.h"
#include "../includes/iguana_apidefs.h"
#include "../includes/iguana_apiundefs.h"

118
iguana/iguana_payments.c

@ -162,9 +162,9 @@ cJSON *iguana_scriptobj(struct iguana_info *coin,uint8_t rmd160[20],char *coinad
return(scriptobj);
}
int32_t iguana_RTbestunspent(struct supernet_info *myinfo,struct iguana_info *coin,int32_t *aboveip,int64_t *abovep,int32_t *belowip,int64_t *belowp,struct iguana_outpoint *unspents,int32_t numunspents,uint64_t value)
int32_t iguana_RTbestunspent(struct supernet_info *myinfo,struct iguana_info *coin,int32_t *aboveip,int64_t *abovep,int32_t *belowip,int64_t *belowp,struct iguana_outpoint *unspents,int32_t numunspents,uint64_t value,int32_t maxmode)
{
int32_t i,abovei,belowi; int64_t above,below,gap,atx_value;
int32_t i,abovei,belowi; int64_t above,below,gap,atx_value,maxvalue = 0;
abovei = belowi = -1;
for (above=below=i=0; i<numunspents; i++)
{
@ -175,6 +175,8 @@ int32_t iguana_RTbestunspent(struct supernet_info *myinfo,struct iguana_info *co
printf("(%d u%d) %.8f already used\n",unspents[i].hdrsi,unspents[i].unspentind,dstr(atx_value));
continue;
}
if ( maxmode == 0 )
{
//printf("(%.8f vs %.8f)\n",dstr(atx_value),dstr(value));
if ( atx_value == value )
{
@ -197,6 +199,17 @@ int32_t iguana_RTbestunspent(struct supernet_info *myinfo,struct iguana_info *co
belowi = i;
}
}
else
{
//printf("(%.8f vs %.8f)\n",dstr(atx_value),dstr(maxvalue));
if ( atx_value > maxvalue )
{
maxvalue = atx_value;
above = (atx_value - value);
abovei = i;
}
}
}
*aboveip = abovei;
*abovep = above;
*belowip = belowi;
@ -216,7 +229,7 @@ cJSON *iguana_inputjson(bits256 txid,int32_t vout,uint8_t *spendscript,int32_t s
return(item);
}
cJSON *iguana_RTinputsjson(struct supernet_info *myinfo,struct iguana_info *coin,uint64_t *totalp,uint64_t amount,struct iguana_outpoint *unspents,int32_t num)
cJSON *iguana_RTinputsjson(struct supernet_info *myinfo,struct iguana_info *coin,uint64_t *totalp,uint64_t amount,struct iguana_outpoint *unspents,int32_t num,int32_t maxmode)
{
struct iguana_outpoint outpt; cJSON *vins; int32_t abovei,belowi,i,ind; int64_t above,below,total = 0,remains = amount;
*totalp = 0;
@ -224,7 +237,7 @@ cJSON *iguana_RTinputsjson(struct supernet_info *myinfo,struct iguana_info *coin
for (i=0; i<num; i++)
{
below = above = 0;
if ( iguana_RTbestunspent(myinfo,coin,&abovei,&above,&belowi,&below,unspents,num,remains) < 0 )
if ( iguana_RTbestunspent(myinfo,coin,&abovei,&above,&belowi,&below,unspents,num,remains,maxmode) < 0 )
{
printf("error finding unspent i.%d of %d, %.8f vs %.8f\n",i,num,dstr(remains),dstr(amount));
free_json(vins);
@ -241,75 +254,6 @@ cJSON *iguana_RTinputsjson(struct supernet_info *myinfo,struct iguana_info *coin
//printf("%s value %.8f -> remains %.8f\n",coinaddr,dstr(value),dstr(remains));
if ( remains <= 0 )
break;
/*continue;
if ( coin->FULLNODE == 0 && coin->VALIDATENODE == 0 )
{
if ( (spendlen= basilisk_unspentfind(myinfo,coin,&txid,&vout,spendscript,outpt,outpt.value)) > 0 )
{
jaddi(vins,iguana_inputjson(txid,vout,spendscript,spendlen));
total += outpt.value;
remains -= outpt.value;
//printf("%s value %.8f -> remains %.8f\n",coinaddr,dstr(value),dstr(remains));
if ( remains <= 0 )
break;
}
continue;
}
if ( (spendlen= _iguana_RTunspentfind(myinfo,coin,&txid,&vout,spendscript,outpt,outpt.value)) > 0 )
{
jaddi(vins,iguana_inputjson(txid,vout,spendscript,spendlen));
total += outpt.value;
remains -= outpt.value;
//printf("%s value %.8f -> remains %.8f\n",coinaddr,dstr(value),dstr(remains));
if ( remains <= 0 )
break;
continue;
}
if ( (bp= coin->bundles[outpt.hdrsi]) == 0 )
{
printf("no bundle.[%d]\n",outpt.hdrsi);
free_json(vins);
return(0);
}
ramchain = &bp->ramchain;
if ( (rdata= ramchain->H.data) == 0 )
continue;
U = RAMCHAIN_PTR(rdata,Uoffset);
T = RAMCHAIN_PTR(rdata,Toffset);
if ( outpt.unspentind > 0 && outpt.unspentind < rdata->numunspents )
{
u = &U[outpt.unspentind];
if ( (txidind= u->txidind) > 0 && txidind < rdata->numtxids )
{
if ( iguana_RTunspentindfind(myinfo,coin,&outpt2,coinaddr,spendscript,&spendlen,&amount,&height,T[txidind].txid,u->vout,coin->bundlescount-1,0) == 0 && spendlen > 0 )
{
jaddi(vins,iguana_inputjson(T[txidind].txid,u->vout,spendscript,spendlen));
total += outpt.value;
remains -= outpt.value;
//printf("%s value %.8f -> remains %.8f\n",coinaddr,dstr(value),dstr(remains));
if ( remains <= 0 )
break;
}
else
{
char str[65];printf("couldnt get script for %s.%d\n",bits256_str(str,T[txidind].txid),u->vout);
free_json(vins);
return(0);
}
}
else
{
printf("illegal txidind.%d [%d]\n",txidind,outpt.hdrsi);
free_json(vins);
return(0);
}
}
else
{
printf("%s illegal unspentind.u%d [%d]\n",coin->symbol,outpt.unspentind,outpt.hdrsi);
free_json(vins);
return(0);
}*/
}
*totalp = total;
return(vins);
@ -369,7 +313,7 @@ bits256 iguana_sendrawtransaction(struct supernet_info *myinfo,struct iguana_inf
return(txid);
}
char *iguana_calcrawtx(struct supernet_info *myinfo,struct iguana_info *coin,cJSON **vinsp,cJSON *txobj,int64_t satoshis,char *changeaddr,int64_t txfee,cJSON *addresses,int32_t minconf,uint8_t *opreturn,int32_t oplen,int64_t burnamount,char *remoteaddr,struct vin_info *V)
char *iguana_calcrawtx(struct supernet_info *myinfo,struct iguana_info *coin,cJSON **vinsp,cJSON *txobj,int64_t satoshis,char *changeaddr,int64_t txfee,cJSON *addresses,int32_t minconf,uint8_t *opreturn,int32_t oplen,int64_t burnamount,char *remoteaddr,struct vin_info *V,int32_t maxmode)
{
uint8_t addrtype,rmd160[20],spendscript[IGUANA_MAXSCRIPTSIZE]; int32_t allocflag=0,max,num,spendlen; char *rawtx=0; bits256 txid; cJSON *vins=0; uint64_t avail,total,change; struct iguana_outpoint *unspents = 0;
*vinsp = 0;
@ -384,7 +328,7 @@ char *iguana_calcrawtx(struct supernet_info *myinfo,struct iguana_info *coin,cJS
printf("avail %.8f satoshis %.8f, txfee %.8f burnamount %.8f vin0.scriptlen %d\n",dstr(avail),dstr(satoshis),dstr(txfee),dstr(burnamount),unspents[0].spendlen);
if ( txobj != 0 && avail >= satoshis+txfee )
{
if ( (vins= iguana_RTinputsjson(myinfo,coin,&total,satoshis + txfee,unspents,num)) != 0 )
if ( (vins= iguana_RTinputsjson(myinfo,coin,&total,satoshis + txfee,unspents,num,maxmode)) != 0 )
{
if ( total < (satoshis + txfee) )
{
@ -423,7 +367,10 @@ char *iguana_calcrawtx(struct supernet_info *myinfo,struct iguana_info *coin,cJS
}
}
if ( vins != 0 && V == 0 )
{
V = calloc(cJSON_GetArraySize(vins),sizeof(*V)), allocflag = 1;
//iguana_vinprivkeys(myinfo,coin,V,vins);
}
rawtx = bitcoin_json2hex(myinfo,coin,&txid,txobj,V);
if ( allocflag != 0 )
free(V);
@ -1206,7 +1153,7 @@ ARRAY_OBJ_INT(bitcoinrpc,createrawtransaction,vins,vouts,locktime)
bits256 txid; int32_t offset,spendlen=0,n; uint8_t addrtype,rmd160[20],spendscript[IGUANA_MAXSCRIPTSIZE]; uint64_t satoshis; char *hexstr,*field,*txstr; cJSON *txobj,*item,*obj,*retjson = cJSON_CreateObject();
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
if ( coin != 0 && (txobj= bitcoin_txcreate(coin->chain->isPoS,locktime,locktime==0?coin->chain->normal_txversion:coin->chain->locktime_txversion)) != 0 )
if ( coin != 0 && (txobj= bitcoin_txcreate(coin->chain->isPoS,locktime,locktime==0?coin->chain->normal_txversion:coin->chain->locktime_txversion,0)) != 0 )
{
iguana_createvins(myinfo,coin,txobj,vins);
if ( (n= cJSON_GetArraySize(vouts)) > 0 )
@ -1425,6 +1372,7 @@ S_A_I_S(bitcoinrpc,sendmany,fromaccount,payments,minconf,comment)
//iguana_unspentset(myinfo,coin);
n = cJSON_GetArraySize(payments);
item = payments->child;
retjson = cJSON_CreateArray();
for (required=i=0; i<n; i++)
{
if ( item != 0 && (coinaddr= item->string) != 0 )
@ -1434,14 +1382,30 @@ S_A_I_S(bitcoinrpc,sendmany,fromaccount,payments,minconf,comment)
printf("(%s %.8f) ",coinaddr,dstr(val));
if ( (str= sendtoaddress(myinfo,coin,remoteaddr,coinaddr,val,coin->txfee,comment,"",minconf,fromaccount)) != 0 )
{
free(str);
jaddistr(retjson,str);
}
required += val;
}
item = item->next;
}
printf("required %.8f\n",dstr(required));
return(jprint(retjson,1));
}
THREE_INTS(iguana,splitfunds,satoshis,duplicates,sendflag)
{
char *rawtx; int32_t completed; cJSON *retjson; bits256 signedtxid;
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
if ( myinfo->expiration == 0 )
return(clonestr("{\"error\":\"need to unlock wallet\"}"));
retjson = cJSON_CreateObject();
if ( (rawtx= iguana_utxoduplicates(myinfo,coin,myinfo->persistent_priv,satoshis,duplicates,&completed,&signedtxid,sendflag)) != 0 )
{
jaddstr(retjson,"result",rawtx);
jaddbits256(retjson,"txid",signedtxid);
jadd(retjson,"completed",completed != 0 ? jtrue() : jfalse());
} else jaddstr(retjson,"error","couldnt create duplicates tx");
return(jprint(retjson,1));
}

65
iguana/iguana_sign.c

@ -22,6 +22,7 @@ int32_t iguana_vinparse(struct iguana_info *coin,int32_t rwflag,uint8_t *seriali
{
int32_t p2shlen,len = 0; uint32_t tmp;
len += iguana_rwbignum(rwflag,&serialized[len],sizeof(msg->prev_hash),msg->prev_hash.bytes);
//char str[65]; printf("prev_hash.(%s)\n",bits256_str(str,msg->prev_hash));
len += iguana_rwnum(rwflag,&serialized[len],sizeof(msg->prev_vout),&msg->prev_vout);
if ( rwflag == 1 )
{
@ -85,6 +86,7 @@ int32_t iguana_vinparse(struct iguana_info *coin,int32_t rwflag,uint8_t *seriali
serialized[len++] = ((p2shlen >> 8) & 0xff);
} else return(-1);
memcpy(&serialized[len],msg->redeemscript,p2shlen), len += p2shlen;
if ( 0 )
{
int32_t j;
for (j=0; j<p2shlen; j++)
@ -204,6 +206,7 @@ int32_t iguana_parsevinobj(struct supernet_info *myinfo,struct iguana_info *coin
if ( (hexstr= jstr(vinobj,"coinbase")) == 0 )
{
vin->prev_hash = jbits256(vinobj,"txid");
//char str[65]; printf("vin->prev_hash.(%s)\n",bits256_str(str,vin->prev_hash));
vin->prev_vout = jint(vinobj,"vout");
if ( (scriptjson= jobj(vinobj,"scriptSig")) != 0 )
hexstr = jstr(scriptjson,"hex");
@ -212,6 +215,8 @@ int32_t iguana_parsevinobj(struct supernet_info *myinfo,struct iguana_info *coin
if ( (obj= jobj(vinobj,"scriptPub")) != 0 || (obj= jobj(vinobj,"scriptPubKey")) != 0 )
{
spendstr = jstr(obj,"hex");
if ( spendstr[0] != 0 )
{
lastbyte = _decode_hex(&spendstr[strlen(spendstr)-2]);
//if ( lastbyte == SCRIPT_OP_CHECKMULTISIG )
// need_op0 = 1;
@ -222,6 +227,7 @@ int32_t iguana_parsevinobj(struct supernet_info *myinfo,struct iguana_info *coin
}
}
}
}
if ( (redeemstr= jstr(vinobj,"redeemScript")) == 0 || is_hexstr(redeemstr,(int32_t)strlen(redeemstr)) <= 0 )
{
if ( (obj= jobj(vinobj,"redeemScript")) != 0 )
@ -238,6 +244,7 @@ int32_t iguana_parsevinobj(struct supernet_info *myinfo,struct iguana_info *coin
userdata = jstr(obj,"hex");
}
}
//char str[65]; printf("rw.%d prevhash.(%s)\n",rwflag,bits256_str(str,vin->prev_hash));
len += iguana_rwbignum(rwflag,&serialized[len],sizeof(vin->prev_hash),vin->prev_hash.bytes);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(vin->prev_vout),&vin->prev_vout);
if ( V != 0 )
@ -299,14 +306,14 @@ int32_t iguana_parsevinobj(struct supernet_info *myinfo,struct iguana_info *coin
}
len += n;
} //else printf("iguana_parsevinobj: hex script missing (%s)\n",jprint(vinobj,0));
if ( (pubkeysjson= jarray(&n,vinobj,"pubkeys")) != 0 )
if ( (pubkeysjson= jarray(&n,vinobj,"pubkeys")) != 0 && vin->vinscript != 0 )
{
if ( vin->vinscript == 0 )
/*if ( vin->vinscript == 0 )
{
vin->vinscript = serialized;
vin->vinscript[0] = 0;
vin->scriptlen = 1;
}
}*/
for (i=0; i<n; i++)
{
if ( (pubkeystr= jstr(jitem(pubkeysjson,i),0)) != 0 && (plen= (int32_t)strlen(pubkeystr) >> 1) > 0 )
@ -503,11 +510,13 @@ bits256 bitcoin_sigtxid(struct iguana_info *coin,int32_t height,uint8_t *seriali
}
dest.vins[i].p2shlen = 0;
dest.vins[i].redeemscript = 0;
dest.vins[i].userdata = 0;
dest.vins[i].userdatalen = 0;
}
len = iguana_rwmsgtx(coin,height,1,0,serialized,maxlen,&dest,&txid,vpnstr,0,0,0,suppress_pubkeys);
//for (i=0; i<len; i++)
// printf("%02x",serialized[i]);
//printf(" <- sigtx\n");
//printf(" <- sigtx len.%d supp.%d user[0].%d\n",len,suppress_pubkeys,dest.vins[0].userdatalen);
if ( len > 0 ) // (dest.tx_in != 1 || bits256_nonz(dest.vins[0].prev_hash) != 0) && dest.vins[0].scriptlen > 0 &&
{
#ifdef BTC2_VERSION
@ -593,6 +602,7 @@ int32_t iguana_rwmsgtx(struct iguana_info *coin,int32_t height,int32_t rwflag,cJ
iguana_vinobjset(&msg->vins[i],jitem(vins,i),spendscript,sizeof(spendscript));
if ( (n= iguana_vinparse(coin,rwflag,&serialized[len],&msg->vins[i])) < 0 )
return(-1);
//printf("serialized vin.[%02x %02x %02x]\n",serialized[len],serialized[len+1],serialized[len+2]);
if ( msg->vins[i].spendscript == spendscript )
msg->vins[i].spendscript = 0;
//printf("vin.%d n.%d len.%d\n",i,n,len);
@ -694,7 +704,7 @@ int32_t iguana_rwmsgtx(struct iguana_info *coin,int32_t height,int32_t rwflag,cJ
bits256 iguana_parsetxobj(struct supernet_info *myinfo,struct iguana_info *coin,int32_t *txstartp,uint8_t *serialized,int32_t maxsize,struct iguana_msgtx *msg,cJSON *txobj,struct vin_info *V)
{
int32_t i,numvins,numvouts,len = 0,rwflag=1; cJSON *array=0; bits256 txid; char vpnstr[64];
int32_t i,n,numvins,numvouts,len = 0,rwflag=1; cJSON *array=0; bits256 txid; char vpnstr[64];
memset(&txid,0,sizeof(txid));
memset(msg,0,sizeof(*msg));
*txstartp = 0;
@ -723,8 +733,11 @@ bits256 iguana_parsetxobj(struct supernet_info *myinfo,struct iguana_info *coin,
{
for (i=0; i<msg->tx_in; i++)
{
//printf("parsetxobj vinobj.%d starts offset.%d\n",i,len);
len += iguana_parsevinobj(myinfo,coin,&serialized[len],maxsize,&msg->vins[i],jitem(array,i),V!=0?&V[i]:0);
n = iguana_parsevinobj(myinfo,coin,&serialized[len],maxsize,&msg->vins[i],jitem(array,i),V!=0?&V[i]:0);
//for (j=0; j<8; j++)
// printf("%02x",serialized[len+j]);
//char str[65]; printf(" <- vinobj.%d starts offset.%d %s\n",i,len,bits256_str(str,msg->vins[i].prev_hash));
len += n;
}
}
}
@ -937,7 +950,7 @@ int32_t bitcoin_verifyvins(struct iguana_info *coin,int32_t height,bits256 *sign
memset(signedtxidp,0,sizeof(*signedtxidp));
for (vini=0; vini<msgtx->tx_in; vini++)
{
if ( V->p2shscript != 0 && V->p2shlen != 0 )
if ( V->p2shscript[0] != 0 && V->p2shlen != 0 )
{
script = V->p2shscript;
scriptlen = V->p2shlen;
@ -964,13 +977,14 @@ int32_t bitcoin_verifyvins(struct iguana_info *coin,int32_t height,bits256 *sign
bitcoin_pubkey33(coin->ctx,vp->signers[j].pubkey,vp->signers[j].privkey);
sig[siglen++] = sighash;
vp->signers[j].siglen = siglen;
/*int32_t i; for (i=0; i<siglen; i++)
/*char str[65]; printf("SIGTXID.(%s) ",bits256_str(str,sigtxid));
int32_t i; for (i=0; i<siglen; i++)
printf("%02x",sig[i]);
printf(" sig, ");
for (i=0; i<plen; i++)
printf("%02x",vp->signers[j].pubkey[i]);
// s2 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1;
char str[65]; printf(" SIGNEDTX.[%02x] siglen.%d priv.%s\n",sig[siglen-1],siglen,bits256_str(str,vp->signers[j].privkey));*/
printf(" SIGNEDTX.[%02x] siglen.%d priv.%s\n",sig[siglen-1],siglen,bits256_str(str,vp->signers[j].privkey));*/
}
if ( sig == 0 || siglen == 0 )
{
@ -980,7 +994,7 @@ int32_t bitcoin_verifyvins(struct iguana_info *coin,int32_t height,bits256 *sign
if ( bitcoin_verify(coin->ctx,sig,siglen-1,sigtxid,vp->signers[j].pubkey,bitcoin_pubkeylen(vp->signers[j].pubkey)) < 0 )
{
//printf("SIG.%d.%d ERROR siglen.%d\n",vini,j,siglen);
printf("SIG.%d.%d ERROR siglen.%d\n",vini,j,siglen);
}
else
{
@ -989,10 +1003,10 @@ int32_t bitcoin_verifyvins(struct iguana_info *coin,int32_t height,bits256 *sign
/*int32_t z;
for (z=0; z<siglen-1; z++)
printf("%02x",sig[z]);
printf(" <- sig[%d]n\n",j);
printf(" <- sig[%d]\n",j);
for (z=0; z<33; z++)
printf("%02x",vp->signers[j].pubkey[z]);*/
//printf(" <- pub, SIG.%d.%d VERIFIED numsigs.%d vs M.%d\n",vini,j,numsigs,vp->M);
printf("%02x",vp->signers[j].pubkey[z]);
printf(" <- pub, SIG.%d.%d VERIFIED numsigs.%d vs M.%d\n",vini,j,numsigs,vp->M);*/
}
}
if ( numsigs >= vp->M )
@ -1221,13 +1235,13 @@ cJSON *bitcoin_txinput(struct iguana_info *coin,cJSON *txobj,bits256 txid,int32_
return(txobj);
}
cJSON *bitcoin_txcreate(int32_t isPoS,int64_t locktime,uint32_t txversion)
cJSON *bitcoin_txcreate(int32_t isPoS,int64_t locktime,uint32_t txversion,uint32_t timestamp)
{
cJSON *json = cJSON_CreateObject();
jaddnum(json,"version",txversion);
jaddnum(json,"locktime",locktime);
if ( isPoS != 0 )
jaddnum(json,"timestamp",time(NULL));
jaddnum(json,"timestamp",timestamp == 0 ? time(NULL) : timestamp);
jadd(json,"vin",cJSON_CreateArray());
jadd(json,"vout",cJSON_CreateArray());
return(json);
@ -1253,9 +1267,11 @@ cJSON *bitcoin_txoutput(cJSON *txobj,uint8_t *paymentscript,int32_t len,uint64_t
int32_t iguana_interpreter(struct iguana_info *coin,cJSON *logarray,int64_t nLockTime,struct vin_info *V,int32_t numvins)
{
uint8_t script[IGUANA_MAXSCRIPTSIZE],*activescript; char str[IGUANA_MAXSCRIPTSIZE*2+1]; int32_t vini,scriptlen,activescriptlen,errs = 0; cJSON *spendscript,*item;
uint8_t script[IGUANA_MAXSCRIPTSIZE],*activescript,savescript[IGUANA_MAXSCRIPTSIZE]; char str[IGUANA_MAXSCRIPTSIZE*2+1]; int32_t vini,scriptlen,activescriptlen,savelen,errs = 0; cJSON *spendscript,*item;
for (vini=0; vini<numvins; vini++)
{
savelen = V[vini].spendlen;
memcpy(savescript,V[vini].spendscript,savelen);
if ( V[vini].p2shlen > 0 )
{
activescript = V[vini].p2shscript;
@ -1266,12 +1282,15 @@ int32_t iguana_interpreter(struct iguana_info *coin,cJSON *logarray,int64_t nLoc
activescript = V[vini].spendscript;
activescriptlen = V[vini].spendlen;
}
memcpy(V[vini].spendscript,activescript,activescriptlen);
V[vini].spendlen = activescriptlen;
spendscript = iguana_spendasm(coin,activescript,activescriptlen);
if ( activescriptlen < 16 )
continue;
//printf("interpreter.(%s)\n",jprint(spendscript,0));
if ( (scriptlen= bitcoin_assembler(coin,logarray,script,spendscript,1,nLockTime,&V[vini])) < 0 )
{
printf("bitcoin_assembler error scriptlen.%d\n",scriptlen);
errs++;
}
else if ( scriptlen != activescriptlen || memcmp(script,activescript,scriptlen) != 0 )
@ -1280,14 +1299,22 @@ int32_t iguana_interpreter(struct iguana_info *coin,cJSON *logarray,int64_t nLoc
{
item = cJSON_CreateObject();
jaddstr(item,"error","script reconstruction failed");
}
init_hexbytes_noT(str,activescript,activescriptlen);
//printf("activescript.(%s)\n",str);
if ( logarray != 0 )
jaddstr(item,"original",str);
init_hexbytes_noT(str,script,scriptlen);
//printf("reconstructed.(%s)\n",str);
if ( logarray != 0 )
{
jaddstr(item,"reconstructed",str);
jaddi(logarray,item);
} else printf(" scriptlen mismatch.%d vs %d or miscompare\n",scriptlen,activescriptlen);
//errs++;
errs++;
}
memcpy(V[vini].spendscript,savescript,savelen);
V[vini].spendlen = savelen;
}
if ( errs != 0 )
return(-errs);
@ -1319,7 +1346,7 @@ P2SH_SPENDAPI(iguana,spendmsig,activecoin,vintxid,vinvout,destaddress,destamount
if ( M > N || N > 3 )
return(clonestr("{\"error\":\"illegal M or N\"}"));
memset(&V,0,sizeof(V));
txobj = bitcoin_txcreate(active->chain->isPoS,0,coin->chain->normal_txversion);
txobj = bitcoin_txcreate(active->chain->isPoS,0,coin->chain->normal_txversion,0);
if ( destaddress[0] != 0 && destamount > 0. )
bitcoin_txaddspend(active,txobj,destaddress,destamount * SATOSHIDEN);
if ( destaddress2[0] != 0 && destamount2 > 0. )

8
iguana/iguana_unspents.c

@ -517,7 +517,11 @@ int64_t iguana_RTpkhashbalance(struct supernet_info *myinfo,struct iguana_info *
printf("iguana_pkhashbalance.[%d] %d: unexpected null spents.%p or rdata.%p\n",ramchain->height,(coin->bundlescount-1)*coin->chain->bundlesize,ramchain->Uextras,rdata);
}
iguana_volatilesmap(myinfo,coin,ramchain);
//return(0);
if ( ramchain->Uextras == 0 || (rdata= ramchain->H.data) == 0 )
{
printf("couldnt map ramchain %d\n",ramchain->height);
return(0);
}
}
unspentind = lastpt.unspentind;
U = RAMCHAIN_PTR(rdata,Uoffset);
@ -573,7 +577,7 @@ int64_t iguana_RTpkhashbalance(struct supernet_info *myinfo,struct iguana_info *
}
unspentind = U2[unspentind].prevunspentind;
}
if ( 0 && llabs(spent - checkval - RTspend) > SMALLVAL )
if ( 0 && llabs((int64_t)spent - (int64_t)checkval - (int64_t)RTspend) > SMALLVAL )
printf("spend %s: [%d] deposits %.8f spent %.8f check %.8f (%.8f) vs A2[%u] %.8f\n",lastheight==IGUANA_MAXHEIGHT?"checkerr":"",lastpt.hdrsi,dstr(deposits),dstr(spent),dstr(checkval)+dstr(RTspend),dstr(*spentp),pkind,dstr(A2[pkind].total));
}
(*spentp) = spent;

16
iguana/iguana_wallet.c

@ -944,7 +944,7 @@ int64_t oldiguana_waccountbalance(struct supernet_info *myinfo,struct iguana_inf
cJSON *iguana_privkeysjson(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *vins)
{
int32_t i,j,n,numinputs,scriptlen; struct iguana_waddress *waddr; struct iguana_waccount *wacct; char *addresses,*address,*scripthexstr,coinaddr[64]; cJSON *scriptobj,*privkeys,*item; uint8_t spendscript[IGUANA_MAXSCRIPTSIZE];
int32_t i,n,numinputs,scriptlen; struct iguana_waddress *waddr; struct iguana_waccount *wacct; char *addresses,*address,*scripthexstr,coinaddr[64]; cJSON *scriptobj,*privkeys,*item; uint8_t spendscript[IGUANA_MAXSCRIPTSIZE];
privkeys = cJSON_CreateArray();
if ( (numinputs= cJSON_GetArraySize(vins)) > 0 )
{
@ -970,20 +970,18 @@ cJSON *iguana_privkeysjson(struct supernet_info *myinfo,struct iguana_info *coin
//if ( (address= iguana_RTinputaddress(myinfo,coin,coinaddr,&spentpt,jitem(vins,i))) != 0 )
if ( address != 0 )
{
for (j=0; j<n; j++)
{
if ( strcmp(&addresses[64 * j],address) == 0 )
break;
}
if ( j == n )
strcpy(&addresses[64 * n++],address);
} else printf("cant get address from.(%s)\n",jprint(item,0));
}
for (i=0; i<n; i++)
{
if ( (waddr= iguana_waddresssearch(myinfo,&wacct,&addresses[i * 64])) != 0 )
{
printf("%s ",waddr->wifstr);
jaddistr(privkeys,waddr->wifstr);
}
else printf("cant find waddr for %s\n",&addresses[i*64]);
}
free(addresses);
}
return(privkeys);
@ -1343,6 +1341,10 @@ TWOSTRINGS_AND_INT(bitcoinrpc,walletpassphrase,password,permanentfile,timeout)
retstr = SuperNET_login(IGUANA_CALLARGS,myinfo->handle,myinfo->secret,myinfo->permanentfile,myinfo->password);
myinfo->expiration = (uint32_t)time(NULL) + timeout;
iguana_walletinitcheck(myinfo,coin);
if ( coin != 0 )
{
bitcoin_address(coin->changeaddr,coin->chain->pubtype,myinfo->persistent_pubkey33,33);
}
//basilisk_unspents_update(myinfo,coin);
return(retstr);
}

2
iguana/tests/LPinit

@ -1 +1 @@
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"tradebot\",\"method\":\"liquidity\",\"targetcoin\":\"BTCD\",\"vals\":{\"profit\":0.005}}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"tradebot\",\"method\":\"liquidity\",\"targetcoin\":\"BTCD\",\"vals\":{\"profit\":0.01}}"

47
iguana/tests/addnotarys

@ -1,11 +1,42 @@
../coins/notary
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.248.160.237\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.248.160.238\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.248.160.239\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.248.160.240\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.248.160.241\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.248.160.242\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.248.160.243\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.248.160.244\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.40.125.53\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"94.177.224.130\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"94.177.227.203\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"94.177.228.245\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"94.177.229.250\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"31.14.140.189\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"188.213.170.78\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.36.208.190\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.36.211.238\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"188.213.166.206\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.46.79.88\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.46.78.206\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.46.79.99\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.46.78.56\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"5.249.155.123\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"85.255.2.118\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"85.255.0.237\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"85.255.2.167\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"85.255.9.234\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"85.255.9.239\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"94.177.242.116\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"94.177.242.43\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"94.177.242.55\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"94.177.242.142\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"94.177.242.240\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"185.58.224.204\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"185.58.225.164\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"185.58.226.204\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"94.177.253.143\"}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"94.177.253.144\"}"
#curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.248.160.237\"}"
#curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.248.160.238\"}"
#curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.248.160.239\"}"
#curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.248.160.240\"}"
#curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.248.160.241\"}"
#curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.248.160.242\"}"
#curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.248.160.243\"}"
#curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.248.160.244\"}"
sleep 3
./getinfoN

47
iguana/tests/addnotarys_7776

@ -1,8 +1,39 @@
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.248.160.237\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.248.160.238\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.248.160.239\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.248.160.240\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.248.160.241\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.248.160.242\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.248.160.243\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.248.160.244\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.40.125.53\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"94.177.224.130\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"94.177.227.203\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"94.177.228.245\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"94.177.229.250\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"31.14.140.189\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"188.213.170.78\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.36.208.190\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.36.211.238\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"188.213.166.206\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.46.79.88\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.46.78.206\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.46.79.99\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.46.78.56\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"5.249.155.123\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"85.255.2.118\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"85.255.0.237\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"85.255.2.167\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"85.255.9.234\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"85.255.9.239\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"94.177.242.116\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"94.177.242.43\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"94.177.242.55\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"94.177.242.142\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"94.177.242.240\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"185.58.224.204\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"185.58.225.164\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"185.58.226.204\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"94.177.253.143\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"94.177.253.144\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.248.160.237\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.248.160.238\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.248.160.239\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.248.160.240\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.248.160.241\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.248.160.242\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.248.160.243\"}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"NOTARY\",\"ipaddr\":\"89.248.160.244\"}"

2
iguana/tests/decoderawtransaction

@ -1 +1 @@
curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTC\",\"method\":\"decoderawtransaction\",\"params\":[\"010000000169c8bb9e30e3bfc57056198f74ebc2caed7381cba1055e21317ffe28e0c784b40100000069463043022078b5d3634221c1df0ef1f1e5f3eada08e0a16a75aaddfab58a1055debfe9b82f021f644253c88cdabb52c4cf926689828687c2773064491be6565b40a7fd02d72b012103b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828ffffffff028da300000000000017a914d9289297b235c7171c9f56d9d3f1d83c6c73619c87e36d0000000000001976a9148ee61a3161993f4f7b7081259bf5f3322d65d3f888ac5907e857\", 1]}"
curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"decoderawtransaction\",\"params\":[\"0100000039f0ef57012da7ff408b643b8c40d69eb1265a0dfc1055a2a1a0635c37abb10a03b44a37a00100000000ffffffff06e8030000000000002321020e0f6fe6e0fcdcac541eb728d6fe538a12adff20412b3c8a7fa892b223a47c2face8030000000000002321020e0f6fe6e0fcdcac541eb728d6fe538a12adff20412b3c8a7fa892b223a47c2face8030000000000002321020e0f6fe6e0fcdcac541eb728d6fe538a12adff20412b3c8a7fa892b223a47c2face8030000000000002321020e0f6fe6e0fcdcac541eb728d6fe538a12adff20412b3c8a7fa892b223a47c2face8030000000000002321020e0f6fe6e0fcdcac541eb728d6fe538a12adff20412b3c8a7fa892b223a47c2fac188e2903000000001976a914b7128d2ee837cf03e30a2c0e3e0181f7b9669bb688ac00000000\", 1]}"

2
iguana/tests/listunspent

@ -1 +1 @@
curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTC\",\"method\":\"listunspent\",\"params\":[1, 9999999, [\"1E2ac2gxeFR2ir1H3vqETTperWkiXkwy99\"]]}"
curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTC\",\"method\":\"listunspent\",\"params\":[1, 9999999, []]}"

2
iguana/tests/request

@ -1,2 +1,2 @@
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"InstantDEX\",\"method\":\"request\",\"vals\":{\"source\":\"BTCD\",\"amount\":0.1,\"dest\":\"BTC\",\"minprice\":0.002}}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"InstantDEX\",\"method\":\"request\",\"vals\":{\"source\":\"BTCD\",\"amount\":0.03,\"dest\":\"BTC\",\"minprice\":0.002}}"

2
iguana/tests/request2

@ -0,0 +1,2 @@
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"InstantDEX\",\"method\":\"request\",\"vals\":{\"source\":\"BTC\",\"amount\":0.0001,\"dest\":\"BTCD\",\"minprice\":240}}"

1
iguana/tests/splitfunds

@ -0,0 +1 @@
curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTC\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"1000\",\"sendflag\":1,\"duplicates\":10}"

1
includes/iguana_apideclares.h

@ -86,6 +86,7 @@ ARRAY_OBJ_INT(bitcoinrpc,createrawtransaction,vins,vouts,locktime);
ZERO_ARGS(iguana,makekeypair);
STRING_ARG(bitcoinrpc,validatepubkey,pubkey);
STRING_ARG(bitcoinrpc,validateaddress,address);
THREE_INTS(iguana,splitfunds,satoshis,duplicates,sendflag);
ZERO_ARGS(bitcoinrpc,walletlock);
TWOSTRINGS_AND_INT(bitcoinrpc,walletpassphrase,password,permanentfile,timeout);

5
includes/iguana_funcs.h

@ -306,7 +306,7 @@ cJSON *iguana_signtx(struct supernet_info *myinfo,struct iguana_info *coin,bits2
void iguana_addscript(struct iguana_info *coin,cJSON *dest,uint8_t *script,int32_t scriptlen,char *fieldname);
bits256 iguana_genesis(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_chain *chain);
cJSON *bitcoin_txcreate(int32_t isPoS,int64_t locktime,uint32_t txversion);
cJSON *bitcoin_txcreate(int32_t isPoS,int64_t locktime,uint32_t txversion,uint32_t timestamp);
cJSON *bitcoin_txoutput(cJSON *txobj,uint8_t *paymentscript,int32_t len,uint64_t satoshis);
cJSON *bitcoin_txinput(struct iguana_info *coin,cJSON *txobj,bits256 txid,int32_t vout,uint32_t sequenceid,uint8_t *spendscript,int32_t spendlen,uint8_t *redeemscript,int32_t p2shlen,uint8_t *pubkeys[],int32_t numpubkeys);
@ -495,9 +495,10 @@ struct exchange_info *exchange_create(char *exchangestr,cJSON *argjson);
int32_t iguana_inv2poll(struct supernet_info *myinfo,struct iguana_info *coin);
struct iguana_bundlereq *iguana_bundlereq(struct iguana_info *coin,struct iguana_peer *addr,int32_t type,uint8_t *data,int32_t datalen);
void instantdex_FSMinit();
char *iguana_utxoduplicates(struct supernet_info *myinfo,struct iguana_info *coin,bits256 privkey,uint64_t satoshis,int32_t duplicates,int32_t *completedp,bits256 *signedtxidp,int32_t sendflag);
int32_t bitcoin_p2shspend(uint8_t *script,int32_t n,uint8_t rmd160[20]);
void iguana_RTunspentslock(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *vins);
char *iguana_calcrawtx(struct supernet_info *myinfo,struct iguana_info *coin,cJSON **vinsp,cJSON *txobj,int64_t satoshis,char *changeaddr,int64_t txfee,cJSON *addresses,int32_t minconf,uint8_t *opreturn,int32_t oplen,int64_t burnamount,char *remoteaddr,struct vin_info *V);
char *iguana_calcrawtx(struct supernet_info *myinfo,struct iguana_info *coin,cJSON **vinsp,cJSON *txobj,int64_t satoshis,char *changeaddr,int64_t txfee,cJSON *addresses,int32_t minconf,uint8_t *opreturn,int32_t oplen,int64_t burnamount,char *remoteaddr,struct vin_info *V,int32_t maxmode);
int64_t datachain_update(struct supernet_info *myinfo,int32_t ordered,struct iguana_info *coin,uint32_t timestamp,struct iguana_bundle *bp,uint8_t rmd160[20],int64_t crypto777_payment,uint8_t type,int32_t height,uint64_t hdrsi_unspentind,int64_t burned,uint32_t fileid,uint64_t scriptpos,int32_t scriptlen,bits256 txid,int32_t vout);
void datachain_update_spend(struct supernet_info *myinfo,int32_t ordered,struct iguana_info *coin,uint32_t timestamp,struct iguana_bundle *bp,int32_t height,bits256 txid,int32_t vout,uint8_t rmd160[20],int64_t value);
cJSON *bitcoin_data2json(struct iguana_info *coin,int32_t height,bits256 *txidp,struct iguana_msgtx *msgtx,uint8_t *extraspace,int32_t extralen,uint8_t *serialized,int32_t len,cJSON *vins,int32_t suppress_pubkeys);

6
includes/iguana_structs.h

@ -517,7 +517,7 @@ struct vin_signer { bits256 privkey; char coinaddr[64]; uint8_t siglen,sig[80],r
struct vin_info
{
struct iguana_msgvin vin; uint64_t amount; cJSON *extras; bits256 sigtxid;
int32_t M,N,validmask,spendlen,type,p2shlen,numpubkeys,numsigs,height,hashtype,userdatalen,suppress_pubkeys;
int32_t M,N,validmask,spendlen,type,p2shlen,numpubkeys,numsigs,height,hashtype,userdatalen,suppress_pubkeys,ignore_cltverr;
uint32_t sequence,unspentind; struct vin_signer signers[16]; char coinaddr[65];
uint8_t rmd160[20],spendscript[IGUANA_MAXSCRIPTSIZE],p2shscript[IGUANA_MAXSCRIPTSIZE],userdata[IGUANA_MAXSCRIPTSIZE];
};
@ -563,8 +563,8 @@ struct basilisk_request
char src[8],dest[8];
//char volatile_start,message[43];
uint64_t destamount;
//uint32_t relaybits;
}; // __attribute__((packed))
int32_t optionhours,profitmargin;
} PACKEDSTRUCT;
struct basilisk_relaystatus
{

Loading…
Cancel
Save