Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
e3a2766d35
  1. 20
      crypto777/curve25519.c
  2. 49
      deprecated/obsolete.h
  3. 16
      iguana/SuperNET.c
  4. 1
      iguana/SuperNET.h
  5. 15
      iguana/SuperNET_category.c
  6. 9
      iguana/iguana_json.c
  7. 4
      iguana/iguana_msg.c
  8. 1
      iguana/main.c
  9. 153
      iguana/pangea_api.c
  10. 30
      includes/iguana_apideclares.h
  11. 2
      includes/iguana_apidefs.h
  12. 1
      includes/iguana_apiundefs.h

20
crypto777/curve25519.c

@ -1714,6 +1714,13 @@ uint64_t acct777_nxt64bits(bits256 pubkey)
return(acct.txid); return(acct.txid);
} }
bits256 acct777_msgpubkey(uint8_t *data,int32_t datalen)
{
bits256 hash;
vcalc_sha256(0,hash.bytes,data,datalen);
return(acct777_pubkey(hash));
}
bits256 acct777_hashiter(bits256 privkey,bits256 pubkey,int32_t lockdays,uint8_t chainlen) bits256 acct777_hashiter(bits256 privkey,bits256 pubkey,int32_t lockdays,uint8_t chainlen)
{ {
uint16_t lockseed,signlen = 0; uint8_t signbuf[16]; bits256 shared,lockhash; uint16_t lockseed,signlen = 0; uint8_t signbuf[16]; bits256 shared,lockhash;
@ -1761,19 +1768,22 @@ uint64_t acct777_sign(struct acct777_sig *sig,bits256 privkey,bits256 otherpubke
uint64_t acct777_validate(struct acct777_sig *sig,uint32_t timestamp,uint8_t *data,int32_t datalen) uint64_t acct777_validate(struct acct777_sig *sig,uint32_t timestamp,uint8_t *data,int32_t datalen)
{ {
struct acct777_sig checksig; struct acct777_sig checksig; uint64_t signerbits;
acct777_sign(&checksig,GENESIS_PRIVKEY,sig->pubkey,timestamp,data,datalen); acct777_sign(&checksig,acct777_msgpubkey(data,datalen),sig->pubkey,timestamp,data,datalen);
if ( memcmp(checksig.sigbits.bytes,sig->sigbits.bytes,sizeof(checksig.sigbits)) != 0 ) if ( memcmp(checksig.sigbits.bytes,sig->sigbits.bytes,sizeof(checksig.sigbits)) != 0 )
{ {
printf("sig compare error using sig->pub from %llu\n",(long long)acct777_nxt64bits(sig->pubkey)); printf("sig compare error using sig->pub from %llu\n",(long long)acct777_nxt64bits(sig->pubkey));
return(0); return(0);
} }
return(acct777_nxt64bits(sig->pubkey)); signerbits = acct777_nxt64bits(sig->pubkey);
if ( signerbits == checksig.signer64bits )
return(signerbits);
else return(0);
} }
uint64_t acct777_signtx(struct acct777_sig *sig,bits256 privkey,uint32_t timestamp,uint8_t *data,int32_t datalen) uint64_t acct777_signtx(struct acct777_sig *sig,bits256 privkey,uint32_t timestamp,uint8_t *data,int32_t datalen)
{ {
return(acct777_sign(sig,privkey,GENESIS_PUBKEY,timestamp,data,datalen)); return(acct777_sign(sig,privkey,acct777_msgpubkey(data,datalen),timestamp,data,datalen));
} }
uint64_t acct777_swaptx(bits256 privkey,struct acct777_sig *sig,uint32_t timestamp,uint8_t *data,int32_t datalen) uint64_t acct777_swaptx(bits256 privkey,struct acct777_sig *sig,uint32_t timestamp,uint8_t *data,int32_t datalen)
@ -1781,7 +1791,7 @@ uint64_t acct777_swaptx(bits256 privkey,struct acct777_sig *sig,uint32_t timesta
uint64_t othernxt; uint64_t othernxt;
if ( (othernxt= acct777_validate(sig,timestamp,data,datalen)) != sig->signer64bits ) if ( (othernxt= acct777_validate(sig,timestamp,data,datalen)) != sig->signer64bits )
return(0); return(0);
return(acct777_sign(sig,privkey,GENESIS_PUBKEY,timestamp,data,datalen)); return(acct777_sign(sig,privkey,acct777_msgpubkey(data,datalen),timestamp,data,datalen));
} }
#undef force_inline #undef force_inline

49
deprecated/obsolete.h

@ -12331,5 +12331,54 @@ len = 0;
{ {
return(acct777_pubkey(testprivkey(selector))); return(acct777_pubkey(testprivkey(selector)));
} }
/*char *pangea_univ(uint8_t *mypriv,cJSON *json)
{
char *addrtypes[][3] = { {"BTC","0","80"}, {"LTC","48"}, {"BTCD","60","bc"}, {"DOGE","30"}, {"VRC","70"}, {"OPAL","115"}, {"BITS","25"} };
char *wipstr,*coin,*coinaddr,pubkeystr[67],rsaddr[64],destaddr[64],wifbuf[128]; uint8_t priv[32],pub[33],addrtype; int32_t i;
uint64_t nxt64bits; cJSON *retjson,*item;
PNACL_message("inside rosetta\n");
if ( (coin= jstr(json,"coin")) != 0 )
{
if ( (wipstr= jstr(json,"wif")) != 0 || (wipstr= jstr(json,"wip")) != 0 )
{
PNACL_message("got wip.(%s)\n",wipstr);
btc_wip2priv(priv,wipstr);
}
else if ( (coinaddr= jstr(json,"addr")) != 0 )
{
if ( getprivkey(priv,coin,coinaddr) < 0 )
return(clonestr("{\"error\":\"cant get privkey\"}"));
}
} else memcpy(priv,mypriv,sizeof(priv));
btc_priv2pub(pub,priv);
init_hexbytes_noT(pubkeystr,pub,33);
PNACL_message("pubkey.%s\n",pubkeystr);
retjson = cJSON_CreateObject();
jaddstr(retjson,"btcpubkey",pubkeystr);
for (i=0; i<sizeof(addrtypes)/sizeof(*addrtypes); i++)
{
if ( btc_coinaddr(destaddr,atoi(addrtypes[i][1]),pubkeystr) == 0 )
{
item = cJSON_CreateObject();
jaddstr(item,"addr",destaddr);
if ( addrtypes[i][2] != 0 )
{
decode_hex(&addrtype,1,addrtypes[i][2]);
btc_priv2wip(wifbuf,priv,addrtype);
jaddstr(item,"wif",wifbuf);
}
jadd(retjson,addrtypes[i][0],item);
}
}
nxt64bits = nxt_priv2addr(rsaddr,pubkeystr,priv);
item = cJSON_CreateObject();
jaddstr(item,"addressRS",rsaddr);
jadd64bits(item,"address",nxt64bits);
jaddstr(item,"pubkey",pubkeystr);
jadd(retjson,"NXT",item);
return(jprint(retjson,1));
}
*/
#endif #endif

16
iguana/SuperNET.c

@ -1084,16 +1084,14 @@ HASH_ARRAY_STRING(SuperNET,layer,mypriv,otherpubs,str)
return(clonestr("{\"result\":\"layer encrypt here\"}")); return(clonestr("{\"result\":\"layer encrypt here\"}"));
} }
bits256 calc_categoryhashes(bits256 *subhashp,char *category,char *subcategory) TWO_STRINGS(SuperNET,categoryhashes,category,subcategory)
{ {
bits256 categoryhash; bits256 categoryhash,subhash; cJSON *retjson = cJSON_CreateObject();
if ( category == 0 || category[0] == 0 || strcmp(category,"broadcast") == 0 ) categoryhash = calc_categoryhashes(&subhash,category,subcategory);
categoryhash = GENESIS_PUBKEY; jaddstr(retjson,"result","category hashes calculated");
else vcalc_sha256(0,categoryhash.bytes,(uint8_t *)category,(int32_t)strlen(category)); jaddbits256(retjson,"categoryhash",categoryhash);
if ( subcategory == 0 || subcategory[0] == 0 || strcmp(subcategory,"broadcast") == 0 ) jaddbits256(retjson,"subhash",subhash);
*subhashp = GENESIS_PUBKEY; return(jprint(retjson,1));
else vcalc_sha256(0,subhashp->bytes,(uint8_t *)subcategory,(int32_t)strlen(subcategory));
return(categoryhash);
} }
TWO_STRINGS(SuperNET,subscribe,category,subcategory) TWO_STRINGS(SuperNET,subscribe,category,subcategory)

1
iguana/SuperNET.h

@ -138,6 +138,7 @@ struct category_msg *category_gethexmsg(struct supernet_info *myinfo,bits256 cat
char *SuperNET_htmlstr(char *fname,char *htmlstr,int32_t maxsize,char *agentstr); char *SuperNET_htmlstr(char *fname,char *htmlstr,int32_t maxsize,char *agentstr);
char *SuperNET_categorymulticast(struct supernet_info *myinfo,int32_t surveyflag,bits256 categoryhash,bits256 subcategory,char *message,int32_t maxdelay,int32_t broadcastflag,int32_t plaintext); char *SuperNET_categorymulticast(struct supernet_info *myinfo,int32_t surveyflag,bits256 categoryhash,bits256 subcategory,char *message,int32_t maxdelay,int32_t broadcastflag,int32_t plaintext);
bits256 calc_categoryhashes(bits256 *subhashp,char *category,char *subcategory);
#endif #endif

15
iguana/SuperNET_category.c

@ -15,6 +15,21 @@
#include "iguana777.h" #include "iguana777.h"
bits256 calc_categoryhashes(bits256 *subhashp,char *category,char *subcategory)
{
bits256 categoryhash;
if ( category == 0 || category[0] == 0 || strcmp(category,"broadcast") == 0 )
categoryhash = GENESIS_PUBKEY;
else vcalc_sha256(0,categoryhash.bytes,(uint8_t *)category,(int32_t)strlen(category));
if ( subhashp != 0 )
{
if ( subcategory == 0 || subcategory[0] == 0 || strcmp(subcategory,"broadcast") == 0 )
*subhashp = GENESIS_PUBKEY;
else vcalc_sha256(0,subhashp->bytes,(uint8_t *)subcategory,(int32_t)strlen(subcategory));
}
return(categoryhash);
}
queue_t *category_Q(bits256 categoryhash,bits256 subhash) queue_t *category_Q(bits256 categoryhash,bits256 subhash)
{ {
struct category_info *cat,*sub; queue_t *Q = 0; struct category_info *cat,*sub; queue_t *Q = 0;

9
iguana/iguana_json.c

@ -107,6 +107,7 @@ cJSON *SuperNET_helpjson()
#define IGUANA_HELP_H(agent,name,hash) array = helpjson(IGUANA_ARGS,#agent,#name,helparray(cJSON_CreateArray(),helpitem(#hash,"hash"))) #define IGUANA_HELP_H(agent,name,hash) array = helpjson(IGUANA_ARGS,#agent,#name,helparray(cJSON_CreateArray(),helpitem(#hash,"hash")))
#define IGUANA_HELP_HI(agent,name,hash,val) array = helpjson(IGUANA_ARGS,#agent,#name,helparray2(cJSON_CreateArray(),helpitem(#hash,"hash"),helpitem(#val,"int"))) #define IGUANA_HELP_HI(agent,name,hash,val) array = helpjson(IGUANA_ARGS,#agent,#name,helparray2(cJSON_CreateArray(),helpitem(#hash,"hash"),helpitem(#val,"int")))
#define IGUANA_HELP_HH(agent,name,hash,hash2) array = helpjson(IGUANA_ARGS,#agent,#name,helparray2(cJSON_CreateArray(),helpitem(#hash,"hash"),helpitem(#hash2,"hash"))) #define IGUANA_HELP_HH(agent,name,hash,hash2) array = helpjson(IGUANA_ARGS,#agent,#name,helparray2(cJSON_CreateArray(),helpitem(#hash,"hash"),helpitem(#hash2,"hash")))
#define IGUANA_HELP_HA(agent,name,hash,obj) array = helpjson(IGUANA_ARGS,#agent,#name,helparray2(cJSON_CreateArray(),helpitem(#hash,"hash"),helpitem(#obj,"array")))
#define IGUANA_HELP_HS(agent,name,hash,str) array = helpjson(IGUANA_ARGS,#agent,#name,helparray2(cJSON_CreateArray(),helpitem(#hash,"hash"),helpitem(#str,"str"))) #define IGUANA_HELP_HS(agent,name,hash,str) array = helpjson(IGUANA_ARGS,#agent,#name,helparray2(cJSON_CreateArray(),helpitem(#hash,"hash"),helpitem(#str,"str")))
#define IGUANA_HELP_HII(agent,name,hash,val,val2) array = helpjson(IGUANA_ARGS,#agent,#name,helparray3(cJSON_CreateArray(),helpitem(#hash,"hash"),helpitem(#val,"int"),helpitem(#val2,"int"))) #define IGUANA_HELP_HII(agent,name,hash,val,val2) array = helpjson(IGUANA_ARGS,#agent,#name,helparray3(cJSON_CreateArray(),helpitem(#hash,"hash"),helpitem(#val,"int"),helpitem(#val2,"int")))
#define IGUANA_HELP_HHS(agent,name,hash,hash2,str) array = helpjson(IGUANA_ARGS,#agent,#name,helparray3(cJSON_CreateArray(),helpitem(#hash,"hash"),helpitem(#hash2,"hash"),helpitem(#str,"str"))) #define IGUANA_HELP_HHS(agent,name,hash,hash2,str) array = helpjson(IGUANA_ARGS,#agent,#name,helparray3(cJSON_CreateArray(),helpitem(#hash,"hash"),helpitem(#hash2,"hash"),helpitem(#str,"str")))
@ -151,6 +152,7 @@ cJSON *SuperNET_helpjson()
#define U64_AND_ARRAY IGUANA_HELP_64A #define U64_AND_ARRAY IGUANA_HELP_64A
#define HASH_ARG IGUANA_HELP_H #define HASH_ARG IGUANA_HELP_H
#define TWO_HASHES IGUANA_HELP_HH #define TWO_HASHES IGUANA_HELP_HH
#define HASH_AND_ARRAY IGUANA_HELP_HA
#include "../includes/iguana_apideclares.h" #include "../includes/iguana_apideclares.h"
@ -322,6 +324,7 @@ int32_t pretty_forms(char *fname,char *agentstr)
fprintf(fp,"%s\n",header); fprintf(fp,"%s\n",header);
if ( (helpjson= SuperNET_helpjson()) != 0 ) if ( (helpjson= SuperNET_helpjson()) != 0 )
{ {
printf("JSON.(%s)\n",jprint(helpjson,0));
if ( (array= jarray(&n,helpjson,"API")) != 0 ) if ( (array= jarray(&n,helpjson,"API")) != 0 )
{ {
for (i=0; i<n; i++) for (i=0; i<n; i++)
@ -332,6 +335,7 @@ int32_t pretty_forms(char *fname,char *agentstr)
{ {
len = pretty_form(fp,formheader,formfooter,field,str!=0?str:"agent",item); len = pretty_form(fp,formheader,formfooter,field,str!=0?str:"agent",item);
size += len; size += len;
printf("%s.%s\n",str,jstr(item,"method"));
} //else printf("agentstr.%p (%s) (%s) str.%p \n",agentstr,agentstr,str,str); } //else printf("agentstr.%p (%s) (%s) str.%p \n",agentstr,agentstr,str,str);
} }
} }
@ -376,7 +380,8 @@ char *SuperNET_htmlstr(char *fname,char *htmlstr,int32_t maxsize,char *agentstr)
} //else printf("agentstr.%p (%s) (%s) str.%p \n",agentstr,agentstr,str,str); } //else printf("agentstr.%p (%s) (%s) str.%p \n",agentstr,agentstr,str,str);
} }
} }
free_json(helpjson); //free_json(helpjson);
return(jprint(helpjson,1));
} }
strcat(htmlstr,"<br><br/></body></html><br><br/>"); strcat(htmlstr,"<br><br/></body></html><br><br/>");
printf("<br><br/></body></html><br><br/>\n"); printf("<br><br/></body></html><br><br/>\n");
@ -734,6 +739,7 @@ char *SuperNET_parser(struct supernet_info *myinfo,char *agent,char *method,cJSO
#define IGUANA_DISPATCH_H(agent,name,hash) else if ( strcmp(method,#name) == 0 ) return(agent ## _ ## name(IGUANA_ARGS,jbits256(json,#hash))) #define IGUANA_DISPATCH_H(agent,name,hash) else if ( strcmp(method,#name) == 0 ) return(agent ## _ ## name(IGUANA_ARGS,jbits256(json,#hash)))
#define IGUANA_DISPATCH_HI(agent,name,hash,val) else if ( strcmp(method,#name) == 0 ) return(agent ## _ ## name(IGUANA_ARGS,jbits256(json,#hash),juint(json,#val))) #define IGUANA_DISPATCH_HI(agent,name,hash,val) else if ( strcmp(method,#name) == 0 ) return(agent ## _ ## name(IGUANA_ARGS,jbits256(json,#hash),juint(json,#val)))
#define IGUANA_DISPATCH_HH(agent,name,hash,hash2) else if ( strcmp(method,#name) == 0 ) return(agent ## _ ## name(IGUANA_ARGS,jbits256(json,#hash),jbits256(json,#hash2))) #define IGUANA_DISPATCH_HH(agent,name,hash,hash2) else if ( strcmp(method,#name) == 0 ) return(agent ## _ ## name(IGUANA_ARGS,jbits256(json,#hash),jbits256(json,#hash2)))
#define IGUANA_DISPATCH_HA(agent,name,hash,array) else if ( strcmp(method,#name) == 0 ) return(agent ## _ ## name(IGUANA_ARGS,jbits256(json,#hash),jobj(json,#array)))
#define IGUANA_DISPATCH_HS(agent,name,hash,str) else if ( strcmp(method,#name) == 0 ) return(agent ## _ ## name(IGUANA_ARGS,jbits256(json,#hash),jstr(json,#str))) #define IGUANA_DISPATCH_HS(agent,name,hash,str) else if ( strcmp(method,#name) == 0 ) return(agent ## _ ## name(IGUANA_ARGS,jbits256(json,#hash),jstr(json,#str)))
#define IGUANA_DISPATCH_HII(agent,name,hash,val,val2) else if ( strcmp(method,#name) == 0 ) return(agent ## _ ## name(IGUANA_ARGS,jbits256(json,#hash),juint(json,#val),juint(json,#val2))) #define IGUANA_DISPATCH_HII(agent,name,hash,val,val2) else if ( strcmp(method,#name) == 0 ) return(agent ## _ ## name(IGUANA_ARGS,jbits256(json,#hash),juint(json,#val),juint(json,#val2)))
#define IGUANA_DISPATCH_HHS(agent,name,hash,hash2,str) else if ( strcmp(method,#name) == 0 ) return(agent ## _ ## name(IGUANA_ARGS,jbits256(json,#hash),jbits256(json,#hash2),jstr(json,#str))) #define IGUANA_DISPATCH_HHS(agent,name,hash,hash2,str) else if ( strcmp(method,#name) == 0 ) return(agent ## _ ## name(IGUANA_ARGS,jbits256(json,#hash),jbits256(json,#hash2),jstr(json,#str)))
@ -778,6 +784,7 @@ char *SuperNET_parser(struct supernet_info *myinfo,char *agent,char *method,cJSO
#define U64_AND_ARRAY IGUANA_DISPATCH_64A #define U64_AND_ARRAY IGUANA_DISPATCH_64A
#define HASH_ARG IGUANA_DISPATCH_H #define HASH_ARG IGUANA_DISPATCH_H
#define TWO_HASHES IGUANA_DISPATCH_HH #define TWO_HASHES IGUANA_DISPATCH_HH
#define HASH_AND_ARRAY IGUANA_DISPATCH_HA
#include "../includes/iguana_apideclares.h" #include "../includes/iguana_apideclares.h"
//#undef IGUANA_ARGS //#undef IGUANA_ARGS

4
iguana/iguana_msg.c

@ -45,8 +45,8 @@ int32_t iguana_rwversion(int32_t rwflag,uint8_t *serialized,struct iguana_msgver
len += iguana_rwnum(rwflag,&serialized[len],sizeof(msg->nStartingHeight),&msg->nStartingHeight); len += iguana_rwnum(rwflag,&serialized[len],sizeof(msg->nStartingHeight),&msg->nStartingHeight);
if ( msg->nVersion > 70000 ) if ( msg->nVersion > 70000 )
len += iguana_rwnum(rwflag,&serialized[len],sizeof(msg->relayflag),&msg->relayflag); len += iguana_rwnum(rwflag,&serialized[len],sizeof(msg->relayflag),&msg->relayflag);
if ( rwflag == 0 ) //if ( rwflag == 0 )
printf("%-15s v.%llu srv.%llx %u ht.%llu [%s].R%d nonce.%llx\n",ipaddr,(long long)msg->nVersion,(long long)msg->nServices,(uint32_t)msg->nTime,(long long)msg->nStartingHeight,msg->strSubVer,msg->relayflag,(long long)msg->nonce); // printf("%-15s v.%llu srv.%llx %u ht.%llu [%s].R%d nonce.%llx\n",ipaddr,(long long)msg->nVersion,(long long)msg->nServices,(uint32_t)msg->nTime,(long long)msg->nStartingHeight,msg->strSubVer,msg->relayflag,(long long)msg->nonce);
return(len); return(len);
} }

1
iguana/main.c

@ -452,6 +452,7 @@ void iguana_main(void *arg)
signal(SIGCONT,sigcontinue_func); signal(SIGCONT,sigcontinue_func);
if ( IGUANA_NUMHELPERS == 0 ) if ( IGUANA_NUMHELPERS == 0 )
IGUANA_NUMHELPERS = 1; IGUANA_NUMHELPERS = 1;
category_sub(&MYINFO,GENESIS_PUBKEY,GENESIS_PUBKEY);
for (i=0; i<IGUANA_NUMHELPERS; i++) for (i=0; i<IGUANA_NUMHELPERS; i++)
{ {
sprintf(helperstr,"{\"name\":\"helper.%d\"}",i); sprintf(helperstr,"{\"name\":\"helper.%d\"}",i);

153
iguana/pangea_api.c

@ -15,6 +15,75 @@
#include "pangea777.h" #include "pangea777.h"
//struct acct777_sig { bits256 sigbits,pubkey; uint64_t signer64bits; uint32_t timestamp; };
struct pangea_msghdr
{
struct acct777_sig sig __attribute__((packed));
int32_t allocsize __attribute__((packed));
bits256 tablehash __attribute__((packed));
uint32_t ipbits __attribute__((packed));
uint8_t data[];
} __attribute__((packed));
cJSON *pangea_lobbyjson(struct supernet_info *myinfo)
{
cJSON *retjson = cJSON_CreateObject();
return(retjson);
}
int32_t pangea_updatemsg(struct supernet_info *myinfo,struct pangea_msghdr *pm,int32_t len)
{
return(0);
}
int32_t pangea_validate(struct pangea_msghdr *pm,int32_t size)
{
uint64_t signerbits;
if ( size == pm->allocsize )
{
printf("pangea message size mismatch %d != %d\n",size,pm->allocsize);
return(-1);
}
if ( (signerbits = acct777_validate(&pm->sig,pm->sig.timestamp,&((uint8_t *)pm)[sizeof(pm->sig)],pm->allocsize-sizeof(pm->sig))) != 0 )
{
return(0);
}
return(-1);
}
struct pangea_msghdr *pangea_msgcreate(struct supernet_info *myinfo,uint8_t *space,bits256 tablehash,uint8_t *data,int32_t datalen)
{
struct pangea_msghdr *pm = (struct pangea_msghdr *)space;
memset(pm,0,sizeof(*pm));
pm->sig.pubkey = myinfo->myaddr.pubkey;
pm->sig.signer64bits = acct777_nxt64bits(pm->sig.pubkey);
pm->sig.timestamp = (uint32_t)time(NULL);
if ( datalen > 0 )
memcpy(pm->data,data,datalen);
pm->allocsize = (int32_t)(sizeof(*pm) + datalen);
pm->tablehash = tablehash;
pm->ipbits = myinfo->myaddr.myipbits;
acct777_sign(&pm->sig,myinfo->privkey,tablehash,pm->sig.timestamp,&space[sizeof(pm->sig)],pm->allocsize);
if ( pangea_validate(pm,pm->allocsize) == 0 )
return(pm);
else printf("error validating pangea msg\n");
return(0);
}
void pangea_update(struct supernet_info *myinfo)
{
struct category_msg *m; bits256 pangeahash;
pangeahash = calc_categoryhashes(0,"pangea",0);
while ( (m= category_gethexmsg(myinfo,pangeahash,GENESIS_PUBKEY)) != 0 )
{
if ( pangea_validate((struct pangea_msghdr *)m->msg,m->len) == 0 )
pangea_updatemsg(myinfo,(struct pangea_msghdr *)m->msg,m->len);
free(m);
}
}
void pangea_sendcmd(char *hex,union pangeanet777 *hn,char *cmdstr,int32_t destplayer,uint8_t *data,int32_t datalen,int32_t cardi,int32_t turni) void pangea_sendcmd(char *hex,union pangeanet777 *hn,char *cmdstr,int32_t destplayer,uint8_t *data,int32_t datalen,int32_t cardi,int32_t turni)
{ {
int32_t n,hexlen,blindflag = 0; uint64_t destbits; bits256 destpub; cJSON *json; char hoststr[1024]; struct pangea_info *sp; int32_t n,hexlen,blindflag = 0; uint64_t destbits; bits256 destpub; cJSON *json; char hoststr[1024]; struct pangea_info *sp;
@ -238,55 +307,6 @@ void _pangea_chat(uint64_t senderbits,void *buf,int32_t len,int32_t senderind)
PNACL_message(">>>>>>>>>>> CHAT FROM.%d %llu: (%s)\n",senderind,(long long)senderbits,(char *)buf); PNACL_message(">>>>>>>>>>> CHAT FROM.%d %llu: (%s)\n",senderind,(long long)senderbits,(char *)buf);
} }
/*char *pangea_univ(uint8_t *mypriv,cJSON *json)
{
char *addrtypes[][3] = { {"BTC","0","80"}, {"LTC","48"}, {"BTCD","60","bc"}, {"DOGE","30"}, {"VRC","70"}, {"OPAL","115"}, {"BITS","25"} };
char *wipstr,*coin,*coinaddr,pubkeystr[67],rsaddr[64],destaddr[64],wifbuf[128]; uint8_t priv[32],pub[33],addrtype; int32_t i;
uint64_t nxt64bits; cJSON *retjson,*item;
PNACL_message("inside rosetta\n");
if ( (coin= jstr(json,"coin")) != 0 )
{
if ( (wipstr= jstr(json,"wif")) != 0 || (wipstr= jstr(json,"wip")) != 0 )
{
PNACL_message("got wip.(%s)\n",wipstr);
btc_wip2priv(priv,wipstr);
}
else if ( (coinaddr= jstr(json,"addr")) != 0 )
{
if ( getprivkey(priv,coin,coinaddr) < 0 )
return(clonestr("{\"error\":\"cant get privkey\"}"));
}
} else memcpy(priv,mypriv,sizeof(priv));
btc_priv2pub(pub,priv);
init_hexbytes_noT(pubkeystr,pub,33);
PNACL_message("pubkey.%s\n",pubkeystr);
retjson = cJSON_CreateObject();
jaddstr(retjson,"btcpubkey",pubkeystr);
for (i=0; i<sizeof(addrtypes)/sizeof(*addrtypes); i++)
{
if ( btc_coinaddr(destaddr,atoi(addrtypes[i][1]),pubkeystr) == 0 )
{
item = cJSON_CreateObject();
jaddstr(item,"addr",destaddr);
if ( addrtypes[i][2] != 0 )
{
decode_hex(&addrtype,1,addrtypes[i][2]);
btc_priv2wip(wifbuf,priv,addrtype);
jaddstr(item,"wif",wifbuf);
}
jadd(retjson,addrtypes[i][0],item);
}
}
nxt64bits = nxt_priv2addr(rsaddr,pubkeystr,priv);
item = cJSON_CreateObject();
jaddstr(item,"addressRS",rsaddr);
jadd64bits(item,"address",nxt64bits);
jaddstr(item,"pubkey",pubkeystr);
jadd(retjson,"NXT",item);
return(jprint(retjson,1));
}
*/
/* /*
else if ( strcmp(methodstr,"newtable") == 0 ) else if ( strcmp(methodstr,"newtable") == 0 )
retstr = pangea_newtable(juint(json,"threadid"),json,plugin->nxt64bits,*(bits256 *)plugin->mypriv,*(bits256 *)plugin->mypub,plugin->transport,plugin->ipaddr,plugin->pangeaport,juint(json,"minbuyin"),juint(json,"maxbuyin"),juint(json,"rakemillis")); retstr = pangea_newtable(juint(json,"threadid"),json,plugin->nxt64bits,*(bits256 *)plugin->mypriv,*(bits256 *)plugin->mypub,plugin->transport,plugin->ipaddr,plugin->pangeaport,juint(json,"minbuyin"),juint(json,"maxbuyin"),juint(json,"rakemillis"));
@ -565,30 +585,55 @@ INT_AND_ARRAY(pangea,handsummary,senderind,args)
} }
//U64_AND_ARRAY(pangea,turn,tableid,args); HASH_AND_ARRAY(pangea,status,tablehash,args)
U64_AND_ARRAY(pangea,status,tableid,args)
{ {
cJSON *retjson = cJSON_CreateObject(); cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1)); return(jprint(retjson,1));
} }
U64_AND_ARRAY(pangea,mode,tableid,args) HASH_AND_ARRAY(pangea,mode,tablehash,args)
{ {
cJSON *retjson = cJSON_CreateObject(); cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1)); return(jprint(retjson,1));
} }
U64_AND_ARRAY(pangea,buyin,tableid,args) HASH_AND_ARRAY(pangea,buyin,tablehash,args)
{ {
cJSON *retjson = cJSON_CreateObject(); cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1)); return(jprint(retjson,1));
} }
U64_AND_ARRAY(pangea,history,tableid,args) HASH_AND_ARRAY(pangea,history,tablehash,args)
{ {
cJSON *retjson = cJSON_CreateObject(); cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1)); return(jprint(retjson,1));
} }
ZERO_ARGS(pangea,lobby)
{
pangea_update(myinfo);
return(jprint(pangea_lobbyjson(myinfo),1));
}
INT_AND_ARRAY(pangea,host,minplayers,args)
{
char *req = "{\"host\":\"table\"}";
bits256 pangeahash,tablehash; struct pangea_msghdr *pm; uint8_t space[sizeof(*pm) + 512];
pangeahash = calc_categoryhashes(0,"pangea",0);
OS_randombytes(tablehash.bytes,sizeof(tablehash));
pm = pangea_msgcreate(myinfo,space,tablehash,(void *)req,(int32_t)strlen(req));
return(SuperNET_categorymulticast(myinfo,0,pangeahash,tablehash,(void *)pm,0,1,1));
}
HASH_AND_ARRAY(pangea,join,tablehash,args)
{
char *req = "{\"lobby\":\"join\"}";
bits256 pangeahash; struct pangea_msghdr *pm; uint8_t space[sizeof(*pm) + 512];
pangeahash = calc_categoryhashes(0,"pangea",0);
pm = pangea_msgcreate(myinfo,space,tablehash,(void *)req,(int32_t)strlen(req));
return(SuperNET_categorymulticast(myinfo,0,pangeahash,tablehash,(void *)pm,0,1,1));
}
#undef IGUANA_ARGS #undef IGUANA_ARGS
#include "../includes/iguana_apiundefs.h" #include "../includes/iguana_apiundefs.h"

30
includes/iguana_apideclares.h

@ -14,16 +14,10 @@
******************************************************************************/ ******************************************************************************/
ZERO_ARGS(SuperNET,help); ZERO_ARGS(SuperNET,help);
TWO_STRINGS(SuperNET,html,agentform,htmlfile);
STRING_ARG(SuperNET,bitcoinrpc,setcoin); STRING_ARG(SuperNET,bitcoinrpc,setcoin);
TWOSTRINGS_AND_TWOHASHES_AND_TWOINTS(SuperNET,DHT,hexmsg,destip,categoryhash,subhash,maxdelay,broadcast);
STRING_AND_TWOINTS(mouse,image,name,x,y); TWO_STRINGS(SuperNET,html,agentform,htmlfile);
STRING_AND_TWOINTS(mouse,change,name,x,y); TWOSTRINGS_AND_TWOHASHES_AND_TWOINTS(SuperNET,DHT,hexmsg,destip,categoryhash,subhash,maxdelay,broadcast);
STRING_AND_TWOINTS(mouse,click,name,x,y);
STRING_ARG(mouse,close,name);
STRING_ARG(mouse,leave,name);
STRING_AND_INT(keyboard,key,name,c);
THREE_STRINGS(SuperNET,rosetta,passphrase,pin,showprivkey); THREE_STRINGS(SuperNET,rosetta,passphrase,pin,showprivkey);
ZERO_ARGS(SuperNET,keypair); ZERO_ARGS(SuperNET,keypair);
@ -43,6 +37,14 @@ TWO_STRINGS(SuperNET,gethexmsg,category,subcategory);
THREE_STRINGS(SuperNET,posthexmsg,category,subcategory,hexmsg); THREE_STRINGS(SuperNET,posthexmsg,category,subcategory,hexmsg);
THREE_STRINGS(SuperNET,announce,category,subcategory,message); THREE_STRINGS(SuperNET,announce,category,subcategory,message);
THREE_STRINGS(SuperNET,survey,category,subcategory,message); THREE_STRINGS(SuperNET,survey,category,subcategory,message);
TWO_STRINGS(SuperNET,categoryhashes,category,subcategory);
STRING_AND_TWOINTS(mouse,image,name,x,y);
STRING_AND_TWOINTS(mouse,change,name,x,y);
STRING_AND_TWOINTS(mouse,click,name,x,y);
STRING_ARG(mouse,close,name);
STRING_ARG(mouse,leave,name);
STRING_AND_INT(keyboard,key,name,c);
STRING_ARG(SuperNET,getpeers,activecoin); STRING_ARG(SuperNET,getpeers,activecoin);
TWO_ARRAYS(SuperNET,mypeers,supernet,rawpeers); TWO_ARRAYS(SuperNET,mypeers,supernet,rawpeers);
@ -69,10 +71,14 @@ INT_AND_ARRAY(pangea,action,senderind,args);
INT_AND_ARRAY(pangea,showdown,senderind,args); INT_AND_ARRAY(pangea,showdown,senderind,args);
INT_AND_ARRAY(pangea,handsummary,senderind,args); INT_AND_ARRAY(pangea,handsummary,senderind,args);
U64_AND_ARRAY(pangea,status,tableid,args); HASH_AND_ARRAY(pangea,status,tableid,args);
U64_AND_ARRAY(pangea,mode,tableid,args); HASH_AND_ARRAY(pangea,mode,tableid,args);
U64_AND_ARRAY(pangea,buyin,tableid,args); HASH_AND_ARRAY(pangea,buyin,tableid,args);
U64_AND_ARRAY(pangea,history,tableid,args); HASH_AND_ARRAY(pangea,history,tableid,args);
ZERO_ARGS(pangea,lobby);
INT_AND_ARRAY(pangea,host,minplayers,args);
HASH_AND_ARRAY(pangea,join,tablehash,args);
STRING_ARG(iguana,peers,activecoin); STRING_ARG(iguana,peers,activecoin);
STRING_AND_INT(iguana,maxpeers,activecoin,max); STRING_AND_INT(iguana,maxpeers,activecoin,max);

2
includes/iguana_apidefs.h

@ -29,6 +29,7 @@
#define IGUANA_CFUNC_HI(agent,name,hash,val) char *agent ## _ ## name(IGUANA_ARGS,bits256 hash,int32_t val) #define IGUANA_CFUNC_HI(agent,name,hash,val) char *agent ## _ ## name(IGUANA_ARGS,bits256 hash,int32_t val)
#define IGUANA_CFUNC_H(agent,name,hash) char *agent ## _ ## name(IGUANA_ARGS,bits256 hash) #define IGUANA_CFUNC_H(agent,name,hash) char *agent ## _ ## name(IGUANA_ARGS,bits256 hash)
#define IGUANA_CFUNC_HS(agent,name,hash,str) char *agent ## _ ## name(IGUANA_ARGS,bits256 hash,char *str) #define IGUANA_CFUNC_HS(agent,name,hash,str) char *agent ## _ ## name(IGUANA_ARGS,bits256 hash,char *str)
#define IGUANA_CFUNC_HA(agent,name,hash,array) char *agent ## _ ## name(IGUANA_ARGS,bits256 hash,cJSON *array)
#define IGUANA_CFUNC_HH(agent,name,hash,hash2) char *agent ## _ ## name(IGUANA_ARGS,bits256 hash,bits256 hash2) #define IGUANA_CFUNC_HH(agent,name,hash,hash2) char *agent ## _ ## name(IGUANA_ARGS,bits256 hash,bits256 hash2)
#define IGUANA_CFUNC_HHS(agent,name,hash,hash2,str) char *agent ## _ ## name(IGUANA_ARGS,bits256 hash,bits256 hash2,char *str) #define IGUANA_CFUNC_HHS(agent,name,hash,hash2,str) char *agent ## _ ## name(IGUANA_ARGS,bits256 hash,bits256 hash2,char *str)
#define IGUANA_CFUNC_HAS(agent,name,hash,array,str) char *agent ## _ ## name(IGUANA_ARGS,bits256 hash,cJSON *array,char *str) #define IGUANA_CFUNC_HAS(agent,name,hash,array,str) char *agent ## _ ## name(IGUANA_ARGS,bits256 hash,cJSON *array,char *str)
@ -72,4 +73,5 @@
#define HASH_ARRAY_STRING IGUANA_CFUNC_HAS #define HASH_ARRAY_STRING IGUANA_CFUNC_HAS
#define U64_AND_ARRAY IGUANA_CFUNC_64A #define U64_AND_ARRAY IGUANA_CFUNC_64A
#define HASH_ARG IGUANA_CFUNC_H #define HASH_ARG IGUANA_CFUNC_H
#define HASH_AND_ARRAY IGUANA_CFUNC_HA
#define TWO_HASHES IGUANA_CFUNC_HH #define TWO_HASHES IGUANA_CFUNC_HH

1
includes/iguana_apiundefs.h

@ -29,6 +29,7 @@
#undef TWOHASHES_AND_STRING #undef TWOHASHES_AND_STRING
#undef HASH_ARRAY_STRING #undef HASH_ARRAY_STRING
#undef U64_AND_ARRAY #undef U64_AND_ARRAY
#undef HASH_AND_ARRAY
#undef HASH_ARG #undef HASH_ARG
#undef TWO_HASHES #undef TWO_HASHES
#undef TWOSTRINGS_AND_TWOHASHES_AND_TWOINTS #undef TWOSTRINGS_AND_TWOHASHES_AND_TWOINTS

Loading…
Cancel
Save