Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
4ffc3f1588
  1. 3
      basilisk/basilisk.c
  2. 51
      basilisk/basilisk_CMD.c
  3. 28
      basilisk/basilisk_bitcoin.c
  4. 75
      gecko/gecko.c
  5. 12
      gecko/gecko.h
  6. 26
      iguana/iguana_payments.c
  7. 6
      iguana/iguana_unspents.c
  8. 6
      iguana/iguana_wallet.c
  9. 3
      iguana/main.c
  10. 2
      iguana/tests/DEX
  11. 2
      iguana/tests/DEXtx
  12. 2
      iguana/tests/createrawtransactionA
  13. 2
      iguana/tests/decoderawtransaction
  14. 1
      iguana/tests/genesis
  15. 2
      iguana/tests/getbalance
  16. 1
      iguana/tests/getbalanceall
  17. 2
      iguana/tests/listunspent
  18. 2
      iguana/tests/new
  19. 1
      iguana/tests/newtest
  20. 1
      includes/iguana_apideclares.h
  21. 2
      includes/iguana_funcs.h
  22. 8
      includes/iguana_globals.h

3
basilisk/basilisk.c

@ -326,7 +326,7 @@ struct basilisk_item *basilisk_issueremote(struct supernet_info *myinfo,int32_t
struct basilisk_item *basilisk_requestservice(struct supernet_info *myinfo,char *CMD,int32_t blockflag,cJSON *valsobj,bits256 hash,uint8_t *data,int32_t datalen,uint32_t nBits)
{
int32_t minresults,timeoutmillis,numsent,delaymillis,encryptflag,fanout; struct basilisk_item *ptr; char buf[4096],*symbol,*str = 0; struct iguana_info *virt,*btcd;
int32_t minresults,timeoutmillis,numsent,delaymillis,encryptflag,fanout; struct basilisk_item *ptr; char buf[4096],*symbol,*str = 0; struct iguana_info *virt;
//if ( (btcd= iguana_coinfind("BTCD")) != 0 && btcd->RELAYNODE != 0 )
// jaddnum(valsobj,"iamrelay",1);
basilisk_addhexstr(&str,valsobj,buf,sizeof(buf),data,datalen);
@ -384,6 +384,7 @@ char *basilisk_standardservice(char *CMD,struct supernet_info *myinfo,bits256 ha
}
ptr->finished = (uint32_t)time(NULL);
}
printf("%s.(%s) -> (%s)\n",CMD,jprint(valsobj,0),retstr!=0?retstr:"");
return(retstr);
}

51
basilisk/basilisk_CMD.c

@ -302,11 +302,28 @@ HASH_ARRAY_STRING(basilisk,value,hash,vals,hexstr)
HASH_ARRAY_STRING(basilisk,rawtx,hash,vals,hexstr)
{
//char *retstr; struct basilisk_item *ptr,Lptr; int32_t timeoutmillis;
//if ( (retstr= basilisk_checkrawtx(&timeoutmillis,(uint32_t *)&basilisktag,activecoin,vals)) == 0 )
char *retstr=0,*symbol; uint32_t basilisktag; struct basilisk_item *ptr,Lptr; int32_t timeoutmillis;
if ( (symbol= jstr(vals,"symbol")) != 0 || (symbol= jstr(vals,"coin")) != 0 )
{
if ( (coin= iguana_coinfind(symbol)) != 0 )
{
basilisktag = juint(vals,"basilisktag");
if ( (timeoutmillis= juint(vals,"timeout")) <= 0 )
timeoutmillis = BASILISK_TIMEOUT;
if ( (ptr= basilisk_bitcoinrawtx(&Lptr,myinfo,coin,remoteaddr,basilisktag,timeoutmillis,vals)) != 0 )
{
retstr = ptr->retstr;
}
if ( ptr != &Lptr )
free(ptr);
}
}
return(retstr);
/*if ( (retstr= basilisk_checkrawtx(&timeoutmillis,(uint32_t *)&basilisktag,activecoin,vals)) == 0 )
{
return(basilisk_standardservice("RAW",myinfo,hash,vals,hexstr,1));
/*coin = iguana_coinfind(activecoin);
coin = iguana_coinfind(activecoin);
if ( coin != 0 && (ptr= basilisk_issuecmd(&Lptr,coin->basilisk_rawtx,coin->basilisk_rawtxmetric,myinfo,remoteaddr,basilisktag,activecoin,timeoutmillis,vals)) != 0 )
{
if ( (ptr->numrequired= juint(vals,"numrequired")) == 0 )
@ -314,8 +331,8 @@ HASH_ARRAY_STRING(basilisk,rawtx,hash,vals,hexstr)
//ptr->uniqueflag = 1;
//ptr->metricdir = -1;
return(basilisk_waitresponse(myinfo,"RAW",coin->symbol,remoteaddr,&Lptr,vals,ptr));
} else return(clonestr("{\"error\":\"error issuing basilisk rawtx\"}"));*/
} //else return(retstr);
} else return(clonestr("{\"error\":\"error issuing basilisk rawtx\"}"));
} //else return(retstr);*/
}
HASH_ARRAY_STRING(basilisk,addrelay,hash,vals,hexstr)
@ -383,5 +400,29 @@ HASH_ARRAY_STRING(basilisk,VPNlogout,hash,vals,hexstr)
return(basilisk_standardservice("END",myinfo,hash,vals,hexstr,0));
}
HASH_ARRAY_STRING(basilisk,genesis_opreturn,hash,vals,hexstr)
{
int32_t len; uint16_t blocktime; uint8_t p2shval,wifval; uint8_t serialized[4096],tmp[4]; char hex[8192],*symbol,*name,*destaddr; uint64_t PoSvalue; uint32_t nBits;
symbol = jstr(vals,"symbol");
name = jstr(vals,"name");
destaddr = jstr(vals,"issuer");
PoSvalue = jdouble(vals,"stake") * SATOSHIDEN;
if ( (blocktime= juint(vals,"blocktime")) == 0 )
blocktime = 1;
p2shval = juint(vals,"p2sh");
wifval = juint(vals,"wif");
if ( jstr(vals,"nBits") != 0 )
{
decode_hex((void *)&tmp,sizeof(tmp),jstr(vals,"nBits"));
((uint8_t *)&nBits)[0] = tmp[3];
((uint8_t *)&nBits)[1] = tmp[2];
((uint8_t *)&nBits)[2] = tmp[1];
((uint8_t *)&nBits)[3] = tmp[0];
} else nBits = 0x1e00ffff;
len = gecko_opreturn_create(serialized,symbol,name,destaddr,PoSvalue,nBits,blocktime,p2shval,wifval);
init_hexbytes_noT(hex,serialized,len);
return(clonestr(hex));
}
#include "../includes/iguana_apiundefs.h"

28
basilisk/basilisk_bitcoin.c

@ -573,7 +573,7 @@ double basilisk_bitcoin_rawtxmetric(struct supernet_info *myinfo,struct basilisk
void *basilisk_bitcoinrawtx(struct basilisk_item *Lptr,struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,uint32_t basilisktag,int32_t timeoutmillis,cJSON *valsobj)
{
uint8_t buf[IGUANA_MAXSCRIPTSIZE]; int32_t numsent,minconf,spendlen; cJSON *vins,*addresses,*txobj = 0; uint32_t locktime; char *spendscriptstr,*changeaddr,*rawtx = 0; int64_t amount,txfee;
uint8_t buf[IGUANA_MAXSCRIPTSIZE]; int32_t oplen,offset,numsent,minconf,spendlen; cJSON *vins,*addresses,*txobj = 0; uint32_t locktime; char *opreturn,*spendscriptstr,*changeaddr,*rawtx = 0; int64_t amount,txfee,burnamount;
vins = 0;
changeaddr = jstr(valsobj,"changeaddr");
spendscriptstr = jstr(valsobj,"spendscript");
@ -600,7 +600,31 @@ void *basilisk_bitcoinrawtx(struct basilisk_item *Lptr,struct supernet_info *myi
spendlen = (int32_t)strlen(spendscriptstr) >> 1;
decode_hex(buf,spendlen,spendscriptstr);
bitcoin_txoutput(txobj,buf,spendlen,amount);
rawtx = iguana_calcrawtx(myinfo,coin,&vins,txobj,amount,changeaddr,txfee,addresses,minconf);
burnamount = offset = oplen = 0;
if ( (opreturn= jstr(valsobj,"opreturn")) != 0 && (oplen= is_hexstr(opreturn,0)) > 0 )
{
oplen >>= 1;
offset = 0;
buf[offset++] = 0x6a;
if ( oplen >= 0x4c )
{
if ( oplen > 0xff )
{
buf[offset++] = 0x4d;
buf[offset++] = oplen & 0xff;
buf[offset++] = (oplen >> 8) & 0xff;
}
else
{
buf[offset++] = 0x4c;
buf[offset++] = oplen;
}
} else buf[offset++] = oplen;
decode_hex(&buf[offset],oplen,opreturn);
burnamount = SATOSHIDEN * jdouble(valsobj,"burn");
bitcoin_txoutput(txobj,buf,oplen+offset,burnamount);
}
rawtx = iguana_calcrawtx(myinfo,coin,&vins,txobj,amount,changeaddr,txfee,addresses,minconf,oplen!=0?buf:0,oplen+offset,burnamount);
//printf("generated.(%s) vins.(%s)\n",rawtx,vins!=0?jprint(vins,0):"");
}
else

75
gecko/gecko.c

@ -228,7 +228,7 @@ cJSON *gecko_genesisargs(char *symbol,char *chainname,char *chain,char *keystr,c
if ( blocktime == 0 )
blocktime = 1;
jaddnum(argvals,"blocktime",blocktime);
if ( blocktime != 0 )
if ( blocktime != 0 && 0 )
{
if ( blocktime == 0xffff )
targetspacing = 24 * 60 * 60; // one day
@ -339,6 +339,77 @@ struct iguana_info *basilisk_geckochain(struct supernet_info *myinfo,char *symbo
return(virt);
}
int32_t gecko_rwgenesis(int32_t rwflag,uint8_t *serialized,struct gecko_genesis_opreturn *opret)
{
int32_t len = 0;
len += iguana_rwnum(rwflag,&serialized[len],sizeof(opret->PoSvalue),&opret->PoSvalue);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(opret->netmagic),&opret->netmagic);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(opret->timestamp),&opret->timestamp);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(opret->nBits),&opret->nBits);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(opret->nonce),&opret->nonce);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(opret->blocktime),&opret->blocktime);
if ( rwflag == 0 )
{
opret->version = serialized[len++];
opret->pubval = serialized[len++];
opret->p2shval = serialized[len++];
opret->wifval = serialized[len++];
memcpy(opret->rmd160,&serialized[len],20), len += 20;
memcpy(opret->symbol,&serialized[len],6), len += 6;
memcpy(opret->name,&serialized[len],18), len += 18;
}
else
{
serialized[len++] = opret->version;
serialized[len++] = opret->pubval;
serialized[len++] = opret->p2shval;
serialized[len++] = opret->wifval;
memcpy(&serialized[len],opret->rmd160,20), len += 20;
memcpy(&serialized[len],opret->symbol,6), len += 6;
memcpy(&serialized[len],opret->name,18), len += 18;
}
return(len);
}
int32_t gecko_opreturn_create(uint8_t *serialized,char *symbol,char *name,char *coinaddr,int64_t PoSvalue,uint32_t nBits,uint16_t blocktime,uint8_t p2shval,uint8_t wifval)
{
uint8_t txidbytes[1024],minerpayment[512]; int32_t i,datalen,minerpaymentlen=0,txlen; struct gecko_genesis_opreturn opret; bits256 txid,zero,threshold,hash2; struct iguana_info *btcd; char coinbasestr[512]; struct iguana_msgblock msg;
btcd = iguana_coinfind("BTCD");
memset(&opret,0,sizeof(opret));
strncpy(opret.symbol,symbol,sizeof(opret.symbol));
strncpy(opret.name,name,sizeof(opret.name));
opret.version = 1;
opret.PoSvalue = PoSvalue;
opret.nBits = nBits;
opret.p2shval = p2shval;
opret.wifval = wifval;
opret.blocktime = blocktime;
opret.timestamp = (uint32_t)time(NULL);
OS_randombytes((void *)&opret.netmagic,sizeof(opret.netmagic));
bitcoin_addr2rmd160(&opret.pubval,opret.rmd160,coinaddr);
if ( PoSvalue > 0 )
minerpaymentlen = bitcoin_standardspend(minerpayment,0,opret.rmd160);
memset(zero.bytes,0,sizeof(zero));
sprintf(coinbasestr,"%s_%s",symbol,name);
txlen = iguana_coinbase(btcd,txidbytes,opret.timestamp,zero,(uint8_t *)coinbasestr,(int32_t)strlen(coinbasestr)+1,minerpayment,minerpaymentlen,PoSvalue,&txid);
memset(&msg,0,sizeof(msg));
msg.H.version = opret.version;
msg.H.merkle_root = txid;
msg.H.timestamp = opret.timestamp;
msg.H.bits = opret.nBits;
threshold = bits256_from_compact(nBits);
for (i=0; i<100000000; i++)
{
msg.H.nonce = i;
datalen = iguana_rwblockhdr(1,0,serialized,&msg);
hash2 = iguana_calcblockhash(symbol,btcd->chain->hashalgo,serialized,datalen);
if ( bits256_cmp(threshold,hash2) > 0 )
break;
}
printf("gecko nonce.%d\n",i);
return(gecko_rwgenesis(1,serialized,&opret));
}
char *basilisk_respond_newgeckochain(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 prevhash,int32_t from_basilisk)
{
struct iguana_info *virt,*btcd; struct gecko_chain *chain; char fname[512],*symbol,*retstr,*chainstr,chainname[GECKO_MAXNAMELEN],*genesises; cJSON *chainjson,*retjson,*genesisjson; long filesize; FILE *fp;
@ -417,6 +488,7 @@ int32_t gecko_genesises(struct supernet_info *myinfo,cJSON *array)
}
if ( (virt= basilisk_geckochain(myinfo,symbol,chainname,valsobj)) != 0 )
{
myinfo->genesisresults++;
chain->info = virt;
num++;
}
@ -597,7 +669,6 @@ HASH_ARRAY_STRING(basilisk,geckogenesis,hash,vals,hexstr)
{
if ( (retstr= basilisk_standardservice("GEN",myinfo,hash,vals,hexstr,1)) != 0 )
{
myinfo->genesisresults++;
arrayB = cJSON_Parse(retstr);
free(retstr);
}

12
gecko/gecko.h

@ -37,6 +37,17 @@ struct iguana_peer;
struct gecko_sequence { struct hashstamp *stamps; int32_t lastupdate,maxstamps,numstamps,lasti,longestchain; };
struct gecko_sequences { struct gecko_sequence BTC,BTCD; };*/
//{"genesishash":"633edf349442dea79aa308b286f5368d34f887c898e3c1b4c728679891160000","genesisblock":"010000000000000000000000000000000000000000000000000000000000000000000000413d9e3a8f530415b548973af6545e7a8902d005782478d061295d795f29d68054766a57ffff001f091c070b010100000054766a57011be5d2440c9fb34410947ed9e378478b66d9809f60d17c8d89301ad321ec5912ffffffff050000000000ffffffff0000000000","netmagic":"a1faaa90","symbol":"DEX","name":"InstantDEX","pubval":"00","p2shval":"05","wifval":"80","nBits":"1f00ffff","chain":"InstantDEX","isPoS":1,"geckochain":"InstantDEX","services":128,"blocktime":10,"targetspacing":10,"targettimespan":2450,"result":"success","tag":"10215666446676071864"}
struct gecko_genesis_opreturn
{
char symbol[6],name[16];
uint64_t PoSvalue;
uint32_t netmagic,timestamp,nBits,nonce;
uint16_t blocktime;
uint8_t version,pubval,p2shval,wifval,rmd160[20];
};
struct gecko_memtx
{
double feeperkb;
@ -82,5 +93,6 @@ char *gecko_sendrawtransaction(struct supernet_info *myinfo,char *symbol,uint8_t
struct gecko_mempool *gecko_mempoolfind(struct supernet_info *myinfo,struct iguana_info *virt,int32_t *numotherp,uint32_t ipbits);
void gecko_iteration(struct supernet_info *myinfo,struct iguana_info *btcd,struct iguana_info *virt,int32_t maxmillis);
int32_t gecko_opreturn_create(uint8_t *serialized,char *symbol,char *name,char *coinaddr,int64_t PoSvalue,uint32_t nBits,uint16_t blocktime,uint8_t p2shval,uint8_t wifval);
#endif

26
iguana/iguana_payments.c

@ -325,11 +325,12 @@ 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)
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)
{
uint8_t addrtype,rmd160[20],spendscript[IGUANA_MAXSCRIPTSIZE]; int32_t max,num,spendlen; char *rawtx=0; bits256 txid; cJSON *vins=0; int64_t avail,total,change,*unspents = 0; struct vin_info *V=0;
*vinsp = 0;
max = 10000;
satoshis += burnamount;
unspents = calloc(max,sizeof(*unspents));
if ( (num= iguana_unspentslists(myinfo,coin,&avail,unspents,max,satoshis,minconf,addresses)) <= 0 )
{
@ -367,6 +368,8 @@ char *iguana_calcrawtx(struct supernet_info *myinfo,struct iguana_info *coin,cJS
bitcoin_addr2rmd160(&addrtype,rmd160,changeaddr);
spendlen = bitcoin_standardspend(spendscript,0,rmd160);
bitcoin_txoutput(txobj,spendscript,spendlen,change);
if ( opreturn != 0 )
bitcoin_txoutput(txobj,opreturn,oplen,burnamount);
}
if ( vins != 0 )
V = calloc(cJSON_GetArraySize(vins),sizeof(*V));
@ -398,6 +401,8 @@ char *sendtoaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *
{
uint8_t addrtype,spendscript[1024],rmd160[20]; int32_t completed; char *retstr,spendscriptstr[4096],*rawtx=0,*signedtx = 0; bits256 signedtxid,senttxid; cJSON *retjson,*vins,*addresses,*valsobj; uint32_t spendlen,locktime = 0; struct iguana_waddress *waddr; uint32_t basilisktag;
//sendtoaddress <bitcoinaddress> <amount> [comment] [comment-to] <amount> is a real and is rounded to 8 decimal places. Returns the transaction ID <txid> if successful. Y
if ( account == 0 || account[0] == 0 )
account = "*";
addresses = iguana_getaddressesbyaccount(myinfo,coin,account);
if ( coin->changeaddr[0] == 0 )
{
@ -417,17 +422,20 @@ char *sendtoaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *
jadd(valsobj,"addresses",addresses);
jaddstr(valsobj,"coin",coin->symbol);
jaddstr(valsobj,"changeaddr",coin->changeaddr);
jadd64bits(valsobj,"amount",satoshis);
jaddstr(valsobj,"spendscript",spendscriptstr);
jadd64bits(valsobj,"satoshis",satoshis);
jadd64bits(valsobj,"txfee",txfee);
jaddnum(valsobj,"minconf",minconf);
jaddnum(valsobj,"basilisktag",basilisktag);
jaddnum(valsobj,"locktime",locktime);
jaddnum(valsobj,"timeout",30000);
if ( comment != 0 && is_hexstr(comment,0) > 0 )
jaddstr(valsobj,"opreturn",comment);
if ( (retstr= basilisk_rawtx(myinfo,coin,0,0,myinfo->myaddr.persistent,valsobj,"")) != 0 )
{
if ( (retjson= cJSON_Parse(retstr)) != 0 )
{
if ( (rawtx= jstr(retjson,"result")) != 0 && (vins= jobj(retjson,"vins")) != 0 )
if ( (rawtx= jstr(retjson,"rawtx")) != 0 && (vins= jobj(retjson,"vins")) != 0 )
{
if ( (signedtx= iguana_signrawtx(myinfo,coin,&signedtxid,&completed,vins,rawtx,0)) != 0 )
{
@ -444,14 +452,12 @@ char *sendtoaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *
else jaddbits256(retjson,"senderror",senttxid);
}
free_json(vins);
free(rawtx);
free(signedtx);
return(jprint(retjson,1));
}
else
{
free_json(vins);
free(rawtx);
return(clonestr("{\"error\":\"couldnt sign rawtx\"}"));
}
}
@ -1009,9 +1015,9 @@ ARRAY_OBJ_INT(bitcoinrpc,createrawtransaction,vins,vouts,locktime)
iguana_createvins(myinfo,coin,txobj,vins);
if ( (n= cJSON_GetArraySize(vouts)) > 0 )
{
if ( vouts->child != 0 && n == 1 )
item = vouts->child;
else item = vouts;
if ( is_cJSON_Array(vouts) != 0 && n == 1 && (item= jitem(vouts,0)) != 0 )
item = item->child;
else item = vouts->child;
while ( item != 0 )
{
if ( (field= jfieldname(item)) != 0 )
@ -1090,9 +1096,9 @@ TWOINTS_AND_ARRAY(bitcoinrpc,listunspent,minconf,maxconf,array)
if ( minconf == 0 )
minconf = 1;
if ( maxconf == 0 )
maxconf = 9999999;
maxconf = (1 << 30);
rmdarray = iguana_rmdarray(myinfo,coin,&numrmds,array,0);
iguana_unspents(myinfo,coin,retjson,minconf,maxconf,rmdarray,numrmds,0,0,&numunspents);
iguana_unspents(myinfo,coin,retjson,minconf,maxconf,rmdarray,numrmds,(1 << 30),0,&numunspents);
if ( rmdarray != 0 )
free(rmdarray);
return(jprint(retjson,1));

6
iguana/iguana_unspents.c

@ -307,7 +307,7 @@ int32_t iguana_pkhasharray(struct supernet_info *myinfo,struct iguana_info *coin
}
else
{
//printf("%s pkhash balance.[%d] from m.%d check %.8f vs %.8f spent %.8f [%.8f]\n",coinaddr,i,m,dstr(netbalance),dstr(deposits),dstr(spent),dstr(deposits)-dstr(spent));
printf("%s pkhash balance.[%d] from m.%d check %.8f vs %.8f spent %.8f [%.8f]\n",coinaddr,i,m,dstr(netbalance),dstr(deposits),dstr(spent),dstr(deposits)-dstr(spent));
total += netbalance;
n++;
}
@ -349,7 +349,7 @@ int64_t iguana_unspents(struct supernet_info *myinfo,struct iguana_info *coin,cJ
bitcoin_address(coinaddr,addrtypes[i],&rmdarray[i * 20],20);
*numunspentsp = 0;
iguana_pkhasharray(myinfo,coin,array,minconf,maxconf,&total,P,coin->bundlescount,&rmdarray[i * 20],coinaddr,&pubkeys[33*i],lastheight,&unspents[numunspents << 1],numunspentsp,maxunspents);
//printf("iguana_unspents: i.%d of %d: %s %.8f numunspents.%d\n",i,numrmds,coinaddr,dstr(total),*numunspentsp);
printf("iguana_unspents: i.%d of %d: %s %.8f numunspents.%d\n",i,numrmds,coinaddr,dstr(total),*numunspentsp);
maxunspents -= *numunspentsp;
numunspents += *numunspentsp;
sum += total;
@ -367,7 +367,7 @@ uint8_t *iguana_rmdarray(struct supernet_info *myinfo,struct iguana_info *coin,i
{
int32_t i,n,flag=0,j=0; char *coinaddr,rmdstr[41]; uint8_t *addrtypes,*rmdarray = 0;
*numrmdsp = 0;
if ( array == 0 )
if ( array == 0 || cJSON_GetArraySize(array) == 0 )
array = iguana_getaddressesbyaccount(myinfo,coin,"*");
if ( array != 0 && (n= cJSON_GetArraySize(array)) > 0 )
{

6
iguana/iguana_wallet.c

@ -71,7 +71,7 @@ struct iguana_waccount *iguana_waccountcreate(struct supernet_info *myinfo,struc
wacct = mycalloc('w',1,sizeof(*wacct));
strcpy(wacct->account,account);
HASH_ADD_KEYPTR(hh,myinfo->wallet,wacct->account,len,wacct);
//printf("waccountcreate.(%s) -> wacct.%p\n",account,wacct);
printf("waccountcreate.(%s) -> wacct.%p\n",account,wacct);
myinfo->dirty = (uint32_t)time(NULL);
if ( (ptr= iguana_waccountfind(myinfo,coin,account)) != wacct )
printf("iguana_waccountcreate verify error %p vs %p\n",ptr,wacct);
@ -151,7 +151,7 @@ struct iguana_waddress *iguana_waddressadd(struct supernet_info *myinfo,struct i
{
HASH_ADD_KEYPTR(hh,wacct->waddr,waddr->rmd160,sizeof(waddr->rmd160),waddr);
myinfo->dirty = (uint32_t)time(NULL);
//printf("add (%s).%d scriptlen.%d -> (%s) wif.(%s)\n",waddr->coinaddr,len,waddr->scriptlen,wacct->account,waddr->wifstr);
printf("add (%s) scriptlen.%d -> (%s) wif.(%s)\n",waddr->coinaddr,waddr->scriptlen,wacct->account,waddr->wifstr);
}
if ( waddr != 0 && waddr->symbol[0] == 0 )
strcpy(waddr->symbol,coin->symbol);
@ -1345,7 +1345,7 @@ STRING_AND_THREEINTS(bitcoinrpc,getbalance,account,minconf,includeempty,lastheig
account = "*";
if ( minconf == 0 )
minconf = 1;
if ( strcmp(account,"*") != 0 )
//if ( strcmp(account,"*") != 0 )
rmdarray = iguana_rmdarray(myinfo,coin,&numrmds,iguana_getaddressesbyaccount(myinfo,coin,account),0);
numunspents = 0;
balance = iguana_unspents(myinfo,coin,0,minconf,(1 << 30),rmdarray,numrmds,lastheight,0,&numunspents);

3
iguana/main.c

@ -1433,7 +1433,8 @@ void iguana_main(void *arg)
printf("LITTLE ENDIAN arg.%p\n",arg);
else printf("ENDIAN ERROR\n");
mycalloc(0,0,0);
decode_hex(CRYPTO777_RMD160,20,"");
decode_hex(CRYPTO777_RMD160,20,CRYPTO777_RMD160STR);
decode_hex(CRYPTO777_PUBSECP33,33,CRYPTO777_PUBSECPSTR);
if ( 0 )
iguana_signalsinit();
if ( 0 )

2
iguana/tests/DEX

@ -0,0 +1,2 @@
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"basilisk\",\"method\":\"genesis_opreturn\",\"vals\":{\"issuer\":\"\",\"stake\":1000000,\"blocktime\":1,\"name\":\"InstantDEX\",\"symbol\":\"DEX\",\"p2sh\":5,\"wif\":128,\"nBits\":\"1effffff\"}}"

2
iguana/tests/DEXtx

@ -0,0 +1,2 @@
curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"sendtoaddress\",\"params\":[\"RXL3YXG2ceaB6C5hfJcN4fvmLH2C34knhA\", 0.0001, \"00407a10f35a00007ed8874d63a66a57ffffff1e000000000100010005800000000000000000000000000000000000000000444558000000496e7374616e744445580000000000000000\", \"sendcomment\"]}"

2
iguana/tests/createrawtransactionA

@ -0,0 +1,2 @@
curl --url "http://127.0.0.1:7778" --data "{\"method\":\"createrawtransaction\",\"params\":[[{\"txid\":\"e8a0cc971e769de1fcf9d4abb734acb9ab4ab7f44d9eb7d9cd96707b847dd1f6\",\"vout\":0}], [{\"RAoMou7euzvDwa9dQwjrNB5A41hrAWgvBt\":0.01,\"RV37MfeBD1QTeoLHteab3j4mFVrsSaGMJx\":0.0093}]] }"

2
iguana/tests/decoderawtransaction

@ -1 +1 @@
curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTC\",\"method\":\"decoderawtransaction\",\"params\":[\"01000000016def80687bd97e9b932827a9fa8ce20d7e0c9032b3bc3a211a830e80ac0f5d560100000000ffffffff02bb280000000000002308d7019f135580dfb27576a914ca1e04745e8ca0c60d8c5881531d51bec470743f88acb5469800000000001976a9145513ce20df70c082324da1781c222a4d68dfe87988ac00000000\"]}"
curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"decoderawtransaction\",\"params\":[\"01000000f7c56a57010252b9534fe0186625e3075606f9b547e223830af04b3fb9dab2aaadc7cad530010000006a4730440220766730766796d2182bf8acd563ba0d594646de179394a657729a133dad9c845702204cb317220cea9d3cdc0ee418ee3b7e3b3387d0850e106e55971f949dc3ebfc730121020e0f6fe6e0fcdcac541eb728d6fe538a12adff20412b3c8a7fa892b223a47c2fffffffff0410270000000000001976a914f1dce4182fce875748c4986b240ff7d7bc3fffb088ac00000000000000004c6a4a00407a10f35a00007ed8874d63a66a57ffffff1e000000000100010005800000000000000000000000000000000000000000444558000000496e7374616e744445580000000000000000e07b9a3b000000001976a914c210f6711e98fe9971757ede2b2dcb0507f3f25e88ac00000000000000004c6a4a00407a10f35a00007ed8874d63a66a57ffffff1e000000000100010005800000000000000000000000000000000000000000444558000000496e7374616e74444558000000000000000000000000\"]}"

1
iguana/tests/genesis

@ -0,0 +1 @@
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"basilisk\",\"method\":\"geckogenesis\"}"

2
iguana/tests/getbalance

@ -1 +1 @@
curl --url "http://127.0.0.1:7778" --data "{\"method\":\"getbalance\",\"params\":[\"default\"]}"
curl --url "http://127.0.0.1:7778" --data "{\"method\":\"getbalance\",\"params\":[\"RSyKVKNxrSDc1Vwvh4guYb9ZDEpvMFz2rm\"]}"

1
iguana/tests/getbalanceall

@ -0,0 +1 @@
curl --url "http://127.0.0.1:7778" --data "{\"method\":\"getbalance\",\"params\":[\"*\"]}"

2
iguana/tests/listunspent

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

2
iguana/tests/new

@ -1 +1 @@
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"basilisk\",\"method\":\"newgeckochain\",\"vals\":{\"RELAY\":1,\"blocktime\":10,\"chain\":\"testchain\",\"symbol\":\"test\"}}"
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"basilisk\",\"method\":\"newgeckochain\",\"vals\":{\"RELAY\":1,\"blocktime\":10,\"chain\":\"InstantDEX\",\"symbol\":\"DEX\"}}"

1
iguana/tests/newtest

@ -0,0 +1 @@
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"basilisk\",\"method\":\"newgeckochain\",\"vals\":{\"RELAY\":1,\"blocktime\":10,\"chain\":\"testchain\",\"symbol\":\"test\"}}"

1
includes/iguana_apideclares.h

@ -13,6 +13,7 @@
* *
******************************************************************************/
HASH_ARRAY_STRING(basilisk,genesis_opreturn,hash,vals,hexstr);
HASH_ARRAY_STRING(basilisk,balances,hash,vals,hexstr);
HASH_ARRAY_STRING(basilisk,value,hash,vals,hexstr);

2
includes/iguana_funcs.h

@ -463,7 +463,7 @@ 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();
void iguana_unspentslock(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);
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 *iguana_signrawtx(struct supernet_info *myinfo,struct iguana_info *coin,bits256 *signedtxidp,int32_t *completedp,cJSON *vins,char *rawtx,cJSON *privkey);
bits256 scrypt_blockhash(const void *input);
bits256 iguana_calcblockhash(char *symbol,int32_t (*hashalgo)(uint8_t *blockhashp,uint8_t *serialized,int32_t len),uint8_t *serialized,int32_t len);

8
includes/iguana_globals.h

@ -74,7 +74,13 @@ CONDEXTERN char GLOBAL_HELPDIR[512];
CONDEXTERN char GLOBAL_VALIDATEDIR[512];
CONDEXTERN char GLOBAL_CONFSDIR[512];
CONDEXTERN int32_t IGUANA_NUMHELPERS;
CONDEXTERN uint8_t CRYPTO777_RMD160[20];
#define CRYPTO777_PUBSECPSTR "020e46e79a2a8d12b9b5d12c7a91adb4e454edfae43c0a0cb805427d2ac7613fd9"
#define CRYPTO777_RMD160STR "f1dce4182fce875748c4986b240ff7d7bc3fffb0"
#define CRYPTO777_BTCADDR "1P3rU1Nk1pmc2BiWC8dEy9bZa1ZbMp5jfg"
#define CRYPTO777_BTCDADDR "RXL3YXG2ceaB6C5hfJcN4fvmLH2C34knhA"
CONDEXTERN uint8_t CRYPTO777_RMD160[20],CRYPTO777_PUBSECP33[33];
#endif

Loading…
Cancel
Save