You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

630 lines
25 KiB

9 years ago
/******************************************************************************
* 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. *
* *
******************************************************************************/
9 years ago
#include "bitcoin.h"
9 years ago
cJSON *instantdex_statemachinejson(struct bitcoin_swapinfo *swap);
9 years ago
char *bitcoind_passthru(char *coinstr,char *serverport,char *userpass,char *method,char *params)
{
return(bitcoind_RPC(0,coinstr,serverport,userpass,method,params));
}
9 years ago
int32_t bitcoin_addr2rmd160(uint8_t *addrtypep,uint8_t rmd160[20],char *coinaddr)
{
bits256 hash; uint8_t *buf,_buf[25]; int32_t len;
memset(rmd160,0,20);
*addrtypep = 0;
buf = _buf;
if ( (len= bitcoin_base58decode(buf,coinaddr)) >= 4 )
{
// validate with trailing hash, then remove hash
9 years ago
hash = bits256_doublesha256(0,buf,21);
9 years ago
*addrtypep = *buf;
memcpy(rmd160,buf+1,20);
9 years ago
if ( (buf[21]&0xff) == hash.bytes[31] && (buf[22]&0xff) == hash.bytes[30] &&(buf[23]&0xff) == hash.bytes[29] && (buf[24]&0xff) == hash.bytes[28] )
9 years ago
{
9 years ago
//printf("coinaddr.(%s) valid checksum addrtype.%02x\n",coinaddr,*addrtypep);
9 years ago
return(20);
}
else
{
9 years ago
int32_t i;
9 years ago
if ( len > 20 )
{
hash = bits256_doublesha256(0,buf,len);
}
9 years ago
for (i=0; i<len; i++)
printf("%02x ",buf[i]);
9 years ago
char str[65]; printf("\nhex checkhash.(%s) len.%d mismatch %02x %02x %02x %02x vs %02x %02x %02x %02x (%s)\n",coinaddr,len,buf[len-1]&0xff,buf[len-2]&0xff,buf[len-3]&0xff,buf[len-4]&0xff,hash.bytes[31],hash.bytes[30],hash.bytes[29],hash.bytes[28],bits256_str(str,hash));
9 years ago
}
}
return(0);
}
char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160,int32_t len)
9 years ago
{
int32_t i; uint8_t data[25]; bits256 hash;// char checkaddr[65];
if ( len != 20 )
calc_rmd160_sha256(data+1,pubkey_or_rmd160,len);
else memcpy(data+1,pubkey_or_rmd160,20);
9 years ago
//btc_convrmd160(checkaddr,addrtype,data+1);
data[0] = addrtype;
hash = bits256_doublesha256(0,data,21);
for (i=0; i<4; i++)
data[21+i] = hash.bytes[31-i];
if ( (coinaddr= bitcoin_base58encode(coinaddr,data,25)) != 0 )
{
//uint8_t checktype,rmd160[20];
//bitcoin_addr2rmd160(&checktype,rmd160,coinaddr);
//if ( strcmp(checkaddr,coinaddr) != 0 )
// printf("checkaddr.(%s) vs coinaddr.(%s) %02x vs [%02x] memcmp.%d\n",checkaddr,coinaddr,addrtype,checktype,memcmp(rmd160,data+1,20));
}
return(coinaddr);
}
int32_t bitcoin_validaddress(struct iguana_info *coin,char *coinaddr)
{
uint8_t rmd160[20],addrtype; char checkaddr[128];
if ( coin == 0 || coinaddr == 0 || coinaddr[0] == 0 )
return(-1);
else if ( bitcoin_addr2rmd160(&addrtype,rmd160,coinaddr) < 0 )
return(-1);
else if ( addrtype != coin->chain->pubtype && addrtype != coin->chain->p2shtype )
return(-1);
else if ( bitcoin_address(checkaddr,addrtype,rmd160,sizeof(rmd160)) != checkaddr || strcmp(checkaddr,coinaddr) != 0 )
return(-1);
return(0);
}
9 years ago
int32_t base58encode_checkbuf(uint8_t addrtype,uint8_t *data,int32_t data_len)
{
uint8_t i; bits256 hash;
9 years ago
data[0] = addrtype;
9 years ago
//for (i=0; i<data_len+1; i++)
// printf("%02x",data[i]);
//printf(" extpriv -> ");
9 years ago
hash = bits256_doublesha256(0,data,(int32_t)data_len+1);
9 years ago
//for (i=0; i<32; i++)
// printf("%02x",hash.bytes[i]);
//printf(" checkhash\n");
9 years ago
for (i=0; i<4; i++)
9 years ago
data[data_len+i+1] = hash.bytes[31-i];
return(data_len + 5);
9 years ago
}
int32_t bitcoin_wif2priv(uint8_t *addrtypep,bits256 *privkeyp,char *wifstr)
{
int32_t len = -1; bits256 hash; uint8_t buf[64];
if ( (len= bitcoin_base58decode(buf,wifstr)) >= 4 )
{
// validate with trailing hash, then remove hash
hash = bits256_doublesha256(0,buf,len - 4);
*addrtypep = *buf;
memcpy(privkeyp,buf+1,32);
if ( (buf[len - 4]&0xff) == hash.bytes[31] && (buf[len - 3]&0xff) == hash.bytes[30] &&(buf[len - 2]&0xff) == hash.bytes[29] &&(buf[len - 1]&0xff) == hash.bytes[28] )
{
//printf("coinaddr.(%s) valid checksum\n",coinaddr);
return(32);
}
}
return(-1);
}
9 years ago
int32_t bitcoin_priv2wif(char *wifstr,bits256 privkey,uint8_t addrtype)
{
uint8_t data[128]; int32_t len;
memcpy(data+1,privkey.bytes,sizeof(privkey));
data[33] = 1;
len = base58encode_checkbuf(addrtype,data,33);
9 years ago
9 years ago
if ( bitcoin_base58encode(wifstr,data,len) == 0 )
return(-1);
if ( 1 )
{
uint8_t checktype; bits256 checkpriv; char str[65],str2[65];
if ( bitcoin_wif2priv(&checktype,&checkpriv,wifstr) == sizeof(bits256) )
{
if ( checktype != addrtype || bits256_cmp(checkpriv,privkey) != 0 )
printf("(%s) -> wif.(%s) addrtype.%02x -> %02x (%s)\n",bits256_str(str,privkey),wifstr,addrtype,checktype,bits256_str(str2,checkpriv));
}
}
return((int32_t)strlen(wifstr));
}
9 years ago
int32_t iguana_validatesigs(struct iguana_info *coin,struct iguana_msgvin *vin)
9 years ago
{
9 years ago
// multiple coins
// ro -> vouts collision, purgeable
//
return(0);
9 years ago
}
9 years ago
#ifdef bitcoincancalulatebalances
9 years ago
uint64_t bitcoin_parseunspent(struct iguana_info *coin,struct bitcoin_unspent *unspent,double minconfirms,char *account,cJSON *item)
9 years ago
{
9 years ago
char *hexstr,coinaddr[64];
9 years ago
memset(unspent,0,sizeof(*unspent));
if ( jstr(item,"address") != 0 )
9 years ago
{
9 years ago
safecopy(coinaddr,jstr(item,"address"),sizeof(coinaddr));
bitcoin_addr2rmd160(&unspent->addrtype,unspent->rmd160,coinaddr);
9 years ago
/*sprintf(args,"[\"%s\"]",coinaddr);
9 years ago
wifstr = bitcoind_RPC(0,coin->symbol,coin->chain->serverport,coin->chain->userpass,"dumpprivkey",args);
if ( wifstr != 0 )
9 years ago
{
9 years ago
bitcoin_wif2priv(&addrtype,&unspent->privkeys[0],wifstr);
//printf("wifstr.(%s) -> %s\n",wifstr,bits256_str(str,unspent->privkeys[0]));
free(wifstr);
9 years ago
} else fprintf(stderr,"error (%s) cant find privkey\n",coinaddr);*/
9 years ago
}
9 years ago
if ( (account == 0 || jstr(item,"account") == 0 || strcmp(account,jstr(item,"account")) == 0) && (minconfirms <= 0 || juint(item,"confirmations") >= minconfirms-SMALLVAL) )
9 years ago
{
9 years ago
if ( (hexstr= jstr(item,"scriptPubKey")) != 0 )
9 years ago
{
9 years ago
unspent->spendlen = (int32_t)strlen(hexstr) >> 1;
if ( unspent->spendlen < sizeof(unspent->spendscript) )
decode_hex(unspent->spendscript,unspent->spendlen,hexstr);
9 years ago
}
9 years ago
unspent->txid = jbits256(item,"txid");
unspent->value = SATOSHIDEN * jdouble(item,"amount");
unspent->vout = jint(item,"vout");
//char str[65]; printf("(%s) -> %s %.8f scriptlen.%d\n",jprint(item,0),bits256_str(str,unspent->txid),dstr(unspent->value),unspent->scriptlen);
} else printf("skip.(%s) minconfirms.%f\n",jprint(item,0),minconfirms);
return(unspent->value);
9 years ago
}
9 years ago
struct bitcoin_unspent *iguana_unspentsget(struct supernet_info *myinfo,struct iguana_info *coin,char **retstrp,double *balancep,int32_t *numunspentsp,double minconfirms,char *address)
9 years ago
{
9 years ago
char params[128],*retstr; uint64_t value,total = 0; struct bitcoin_unspent *unspents=0; cJSON *utxo; int32_t i,n;
*numunspentsp = 0;
if ( retstrp != 0 )
*retstrp = 0;
9 years ago
if ( address == 0 )
sprintf(params,"%.0f, 99999999",minconfirms);
else sprintf(params,"%.0f, 99999999, [\"%s\"]",minconfirms,address);
9 years ago
if ( (retstr= bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"listunspent",params)) != 0 )
9 years ago
{
9 years ago
printf("sss unspents.(%s)\n",retstr);
9 years ago
if ( (utxo= cJSON_Parse(retstr)) != 0 )
9 years ago
{
9 years ago
n = 0;
if ( (*numunspentsp= cJSON_GetArraySize(utxo)) > 0 )
9 years ago
{
9 years ago
unspents = calloc(*numunspentsp,sizeof(*unspents));
for (i=0; i<*numunspentsp; i++)
{
9 years ago
value = bitcoin_parseunspent(coin,&unspents[n],minconfirms,0,jitem(utxo,i));
9 years ago
printf("i.%d n.%d value %.8f\n",i,n,dstr(value));
9 years ago
if ( value != 0 )
{
9 years ago
total += value;
n++;
}
}
9 years ago
}
9 years ago
printf("numunspents.%d -> %d total %.8f\n",*numunspentsp,n,dstr(total));
9 years ago
*numunspentsp = n;
free_json(utxo);
} else printf("error parsing.(%s)\n",retstr);
if ( retstrp != 0 )
*retstrp = retstr;
else free(retstr);
9 years ago
}
9 years ago
*balancep = dstr(total);
return(unspents);
}
struct bitcoin_unspent *iguana_bestfit(struct iguana_info *coin,struct bitcoin_unspent *unspents,int32_t numunspents,uint64_t value,int32_t mode)
{
int32_t i; uint64_t above,below,gap,atx_value; struct bitcoin_unspent *vin,*abovevin,*belowvin;
abovevin = belowvin = 0;
for (above=below=i=0; i<numunspents; i++)
{
vin = &unspents[i];
atx_value = vin->value;
//printf("(%.8f vs %.8f)\n",dstr(atx_value),dstr(value));
if ( atx_value == value )
return(vin);
else if ( atx_value > value )
{
gap = (atx_value - value);
if ( above == 0 || gap < above )
{
above = gap;
abovevin = vin;
}
}
else if ( mode == 0 )
{
gap = (value - atx_value);
if ( below == 0 || gap < below )
{
below = gap;
belowvin = vin;
}
}
}
if ( (vin= (abovevin != 0) ? abovevin : belowvin) == 0 && mode == 1 )
vin = unspents;
return(vin);
}
9 years ago
struct bitcoin_spend *iguana_spendset(struct supernet_info *myinfo,struct iguana_info *coin,int64_t amount,int64_t txfee,cJSON *addresses,int32_t minconf)
{
9 years ago
int32_t i,n,mode,maxinputs,numunspents,totalunspents = 0; struct bitcoin_unspent *ptr,*up,*ups=0,*u;
struct bitcoin_spend *spend; double balance; int64_t remains;
if ( (n= cJSON_GetArraySize(addresses)) > 0 )
{
for (i=0; i<n; i++)
{
if ( (u= iguana_unspentsget(myinfo,coin,0,&balance,&numunspents,minconf,jstri(addresses,i))) != 0 )
{
if ( ups == 0 )
{
ups = u;
totalunspents = numunspents;
}
else
{
ups = realloc(ups,sizeof(*ups) * (numunspents + totalunspents));
memcpy(&ups[totalunspents],u,sizeof(*ups) * totalunspents);
totalunspents += numunspents;
free(u);
}
}
}
}
else if ( (ups= iguana_unspentsget(myinfo,coin,0,&balance,&totalunspents,minconf,0)) == 0 )
return(0);
9 years ago
if ( totalunspents == 0 )
return(0);
maxinputs = totalunspents;
spend = calloc(1,sizeof(*spend) + sizeof(*spend->inputs) * totalunspents);
spend->txfee = txfee;
remains = txfee + amount;
spend->satoshis = remains;
ptr = spend->inputs;
for (i=0; i<maxinputs; i++,ptr++)
{
for (mode=1; mode>=0; mode--)
9 years ago
if ( (up= iguana_bestfit(coin,ups,totalunspents,remains,mode)) != 0 )
break;
if ( up != 0 )
{
spend->input_satoshis += up->value;
spend->inputs[spend->numinputs++] = *up;
9 years ago
// todo: update a vins array
if ( spend->input_satoshis >= spend->satoshis )
{
9 years ago
spend->change = (spend->input_satoshis - spend->satoshis) - txfee;
printf("numinputs %d -> (%.8f - spend %.8f) = change %.8f -> txfee %.8f vs chainfee %.8f\n",spend->numinputs,dstr(spend->input_satoshis),dstr(spend->satoshis),dstr(spend->change),dstr(spend->input_satoshis - spend->change - spend->satoshis),dstr(txfee));
break;
}
9 years ago
memset(up,0,sizeof(*up));
remains -= up->value;
} else break;
}
if ( spend->input_satoshis >= spend->satoshis )
{
spend = realloc(spend,sizeof(*spend) + sizeof(*spend->inputs) * spend->numinputs);
9 years ago
free(ups);
return(spend);
}
else
{
free(spend);
9 years ago
free(ups);
return(0);
}
}
9 years ago
cJSON *bitcoin_vout(uint64_t satoshis,char *paymentscriptstr)
{
cJSON *item,*skey;
item = cJSON_CreateObject();
jadd64bits(item,"satoshis",satoshis);
skey = cJSON_CreateObject();
jaddstr(skey,"hex",paymentscriptstr);
//printf("addoutput.(%s %s)\n",hexstr,jprint(skey,0));
jadd(item,"scriptPubkey",skey);
return(item);
}
char *bitcoin_calcrawtx(struct supernet_info *myinfo,struct iguana_info *coin,cJSON **vinsp,int64_t satoshis,char *paymentscriptstr,char *changeaddr,int64_t txfee,cJSON *addresses,int32_t minconf,uint32_t locktime)
{
uint8_t addrtype,rmd160[20],script[512]; int32_t i,scriptlen; char *params,*rawtx=0; cJSON *item,*array,*vins=0,*vouts=0; struct bitcoin_spend *spend; char scriptstr[512],*voutstr;
*vinsp = 0;
if ( (spend= iguana_spendset(myinfo,coin,satoshis,txfee*2,addresses,minconf)) == 0 )
return(0);
if ( spend->input_satoshis >= satoshis+txfee*2 )
{
vins = cJSON_CreateArray();
for (i=0; i<spend->numinputs; i++)
{
item = cJSON_CreateObject();
jaddbits256(item,"txid",spend->inputs[i].txid);
jaddnum(item,"vout",spend->inputs[i].vout);
jaddi(vins,item);
}
vouts = cJSON_CreateArray();
jaddi(vouts,bitcoin_vout(satoshis,paymentscriptstr));
if ( spend->change > 0 )
{
if ( iguana_addressvalidate(coin,&addrtype,changeaddr) < 0 )
{
free(spend);
printf("illegal destination address.(%s)\n",changeaddr);
return(0);
}
bitcoin_addr2rmd160(&addrtype,rmd160,changeaddr);
scriptlen = bitcoin_standardspend(script,0,rmd160);
init_hexbytes_noT(scriptstr,script,scriptlen);
jaddi(vouts,bitcoin_vout(satoshis,scriptstr));
}
bitcoin_addr2rmd160(&addrtype,rmd160,myinfo->myaddr.BTC);
scriptlen = bitcoin_standardspend(script,0,rmd160);
jaddi(vouts,bitcoin_vout(satoshis,scriptstr));
voutstr = jprint(vouts,1);
voutstr[0] = '{', voutstr[strlen(voutstr)-1] = '}';
array = cJSON_CreateArray();
jaddi(array,jduplicate(vins));
jaddi(array,cJSON_Parse(voutstr)), free(voutstr);
params = jprint(array,1);
rawtx = bitcoind_passthru(coin->name,coin->chain->serverport,coin->chain->userpass,"createrawtransaction",params);
free(params);
}
*vinsp = vins;
free(spend);
// add sigtxid to vins
if ( locktime != 0 )
printf("need to patch locktime\n");
return(rawtx);
}
#endif
many changes blockexplorer tab: needs to allow to input height, blockhash or txid. also please display images/BTC_blocks.jpg below the text as a w800 x h400 bitmap, which is active using the mouse api for coin management, below the active coins have a form that arbitrary json can be input with an add button to the right that will call &#34;addcoin&#34; API. this way I can test adding new coins dynamically. dont worry if it doesnt work, just as long as it submits the json to the C code. I am pretty sure I need to do some debugging of this peers management is not working for me at all. maybe it is due to bad internet. On initialization you need to read in the confs/BTCD_peers.txt from the native filesystem and save it into the chrome app filesystem. same thing for confs/BTCD_hdrs.txt. But this is only to be done if there isnt already such a file inside chrome. if there is, only do it upon a button invoked by the user. the reason is that the pexe is updating this file with the latest. Maybe it is nice to have an &#34;extract&#34; button that will copy out from the chrome storage into the native filesystem. There is also the manifest issue about localstorage vs chrome.localstorage. not sure what is needed to be done, but certainly a priority to get it so everything works as a chrome app. I know before it was making ramchain files inside the chrome filesystem, so it is probably things the GUI is doing. maybe in the settings tab, which has obsolete stuff that can be removed. anyway, the issue about files existing in the native filesystem -&gt; chrome and optionally extracting them is an issue for the confs files and .html template files used to autogenerate the port7778, maybe other files are affected. i think we need a way to have a list of hardcoded files that are just copied into chrome on startup if they dont exist already (or if possible copy over if the native version is bigger?) and buttons to extract them for debug tab: THREE_STRINGS(SuperNET,encryptjson,passphrase,permanentfile,anything); TWO_STRINGS(SuperNET,decryptjson,passphrase,permanentfile); at the top of page a way to put in passphrase and optional permanentfile along with arbitrary json. The standard form template has no easy way to describe to pass in everything as it is oriented to specific fields. but the encryptjson API saves all the fields, so the arbitrary json from the form needs to be combined at the same level as the &#34;agent&#34;, &#34;method&#34;, etc. I know, not the best, but internally it makes it easier. so {&#34;agent&#34;:&#34;SuperNET&#34;,&#34;method&#34;:&#34;encryptjson&#34;,&#34;passphrase&#34;:&#34;&lt;passphrase&gt;&#34;,&#34; permanentfile&#34;:&#34;&lt;filename&gt;&#34;,&#34;fromform&#34;:&#34;valuefromform&#34;,&#34;fromform2&#34;:&#34;valu efromform2&#34;,...rest of form at top level} then this will save it into a file with crazy number (it is a hash like txid) but given the same passphrase and filename, it will regenerate this hash so you dont actually have to store it, but it helps during debugging. for the filename, we must warn quite strongly to the user that if the file is ever lost or even changed in any way that the data will not be recoverable. also best to not allow the user to specify a file that does not exist. I think at this point chrome app version gets a bit tricky. we could simply push the native file into the chrome storage, but then an attacker who gets access to the computer could just get a list of these files and it really wont be much protection. So that means if a filename is specified, it needs to be copied into the chrome space, then immediately deleted... ok, this seems like not a good approach. let us make it so that the permanentfile option is not available from the chrome app, but only if the native version is running. that way we sidestep the issue of the pexe not having access to the specified file. Speaking of native vs pexe, on the startup page we should have a radio button that allows the user to select which the GUI will talk to. It should default based on a self test to the more likely value, but it is possible that the user wants to use the native version, even if the pexe is running. another thing to have on the startup page is a simple login: THREE_STRINGS(SuperNET,login,passphrase,permanentfile,handle); ZERO_ARGS(SuperNET,logout); ZERO_ARGS(SuperNET,activehandle); the handle is a human readable name that is associated with the passphrase/permanentfile. There can only be one active account (though it will be possible to associate different accounts with tradebots). use the activehandle API to find out who is logged in and the associated addresses and pubkeys The above is not yet tested so if it doesnt work, dont fret, just let me know. Once set the handle can be displayed in various places to let the user know which account is logged in. The standard 12 dictionary word passphrases should be used, but any string can be sent in as the password for Pangea: INT_AND_ARRAY(pangea,host,minplayers,params); ZERO_ARGS(pangea,lobby); HASH_AND_STRING(pangea,join,tablehash,handle); HASH_AND_INT(pangea,buyin,tablehash,numchips); HASH_ARG(pangea,start,tablehash); // by host only HASH_ARG(pangea,status,tablehash); HASH_ARG(pangea,call,tablehash); HASH_ARG(pangea,check,tablehash); HASH_AND_INT(pangea,raise,tablehash,numchips); HASH_AND_INT(pangea,bet,tablehash,numchips); HASH_ARG(pangea,fold,tablehash); HASH_AND_STRING(pangea,mode,tablehash,modestr); HASH_ARG(pangea,history,tablehash); HASH_AND_INT(pangea,handhistory,tablehash,hand); The first thing that is done is a &#34;host&#34; by any node. the &#34;params&#34; should be an arbitrary json (like encryptjson) as it needs to be at the top level and it has quite a few different parameters still subject to change. The lobby API will just display all the hosted tables. once a table exists, players can join and then buyin. the buyin is denominated in chips, each chip&#39;s value is determined by the host&#39;s initial parameters. once there are enough players joined with adequate buyin&#39;s verified, the host will be able to do a start. if done before it will (eventually) give an error. for now it will just proceed. The host and players that have joined a tablehash, need to do regular status calls to see if the game has started. Probably just once per 5 or even 10 seconds is fine before the start. Once the game starts (the status will have this info) then once per second polling is needed. Then when it is your turn (as indicated by status) you need to do one of the 5 actions (fold, call, check, raise, bet). do not worry if you dont understand what all these do, just allow the user to do any of these. I guess it is possible to submit it ahead of time. I will support internally remembering the most recent action done prior to it being your turn. once it is your turn and an action is sent to the table, it is too late to change. The last API calls are for getting handhistory where hand is 0 to N-1, being the numbering of the hands played at that table. if just history, all the history for all hands at the table is coming back, so it could be quite big. probably I will make it a summary, but for the GUI just display the returned values. the mode is to change some poker specific modes, so just allow there to be a string entered. do not worry about understanding the pokerness of the API, just the overall flow: host -&gt; creates, join/buyin -&gt; fills up player slots, start -&gt; starts the game status -&gt; to determine when the game starts (or if it is cancelled) and once started actions -&gt; game specific but basically just (button + arg) that is the user input results are via status for current game and history for past ones please try to do the above logic in a generic way so it can be reused for other games. The basic flow should be the same for almost all multiplayer turn based games and even for multiplayer realtime games For InstantDEX: on the apikeypair/userid there needs to be two modes. one for when there is no stored apikey and the current form is fine, just need to make it wider as most apikeys are quite long. Now once there is an apikey saved all that is needed is the passphrase to unlock it. So here is where the encrptjson/decryptjson is used. When saving the apikey for the first time, it can be: a) not saved -&gt; nothing extra to do b) saved without password -&gt; you can just save to a file and use it to load it back in. use confs dir confs/instantdex.exchange.api or something like that c) saved with password (optional filename for native) -&gt; probably best to save in the confs dir to indicate that there is an encrypted file for this, so just that and not the actual passphrase in the file with the above, when the exchange is selected, you can see if the confs file exists and if it has the plaintext, just populate the field, if not, then indicate that a passphrase is needed. if the user provides the passphrase, then decryptjson and populate the fields and autosubmit. A special case is to encrypt the apikeys with the passphrase used when logging in. This is only available if the checkbox to &#34;remember passphrase during session&#34; is set on the main iguana login screen. (i forgot to mention that checkbox!) So the login passphrase is stored in memory, then the GUI simply uses that + encryptjson for storing/decrypting. I would imagine that storing in the confs file that it is encrypted using &#34;handle&#34;&#39;s account login might be a good way to differentiate between this mode of password usage. OK, so we now have the insecure plaintext, the decent using handle&#39;s passphrase and paranoid different passphrase for each exchange (with additional permanentfile for native versions) &#34;SUPPORT&#34; -&gt; &#34;SUPPORTS&#34; just a typo and &#34;allpairs&#34; API is missing from the selection Might as well add a &#34;tradebots&#34; tab: THREE_STRINGS_AND_DOUBLE(tradebot,monitor,exchange,base,rel,commission); STRING_AND_DOUBLE(tradebot,monitorall,exchange,commission); THREE_STRINGS(tradebot,unmonitor,exchange,base,rel); THREE_STRINGS_AND_THREE_DOUBLES(tradebot,accumulate,exchange,base,rel,pr ice,volume,duration); THREE_STRINGS_AND_THREE_DOUBLES(tradebot,divest,exchange,base,rel,price, volume,duration); STRING_ARG(tradebot,activebots,exchange); TWO_STRINGS(tradebot,status,exchange,botid); TWO_STRINGS(tradebot,pause,exchange,botid); TWO_STRINGS(tradebot,stop,exchange,botid); TWO_STRINGS(tradebot,resume,exchange,botid); the above are API for exchange specific bots, most should be self-explanatory. bots are created via &#34;accumulate&#34; or &#34;divest&#34; API call. it returns botid. once created, you can do status, pause, stop, resume to a botid. and an activebots API call lists all the active bots for an exchange. duration is in seconds the &#34;monitor&#34; API starts background monitoring of a specific base/rel, &#34;unmonitor&#34; stops this. &#34;monitorall&#34; just does a monitor to the entire list of &#34;allpairs&#34; for that exchange. Keep in mind that doing a monitorall will not add load to an exchange as the request to each exchange is governed by pollgap, but if you have 3 things monitored, it will take 3*pollgap + time each one takes to execute. and if N are monitored it is N*pollgap + time of each, with the &#34;time of each&#34; possibly taking a very long time. And one final request for today: Bitmap tab. It should be an active bitmap using mouse api. either a dropdown to select the bitmap or a form entry. then the rest of the page (resize the bitmap to the page size) being the active bitmap. So on a small screen the bitmap is smaller x/y dimensions and larger on larger screens. plz make sure the proper dimensions are communicated to the pexe via API if it ever is changed. @vineet.bhargav86: I changed the &#34;passphrase&#34; fieldname to &#34;password&#34; for the encryptjson/decryptjson related API. The reason is that the password is like a wallet password and is only local, so it doesnt need to be as high entropy as passphrase. I also added a field to the login API as I realized that the 12 word &#34;passphrase&#34; is the payload and usually wont be sent in: FOUR_STRINGS(SuperNET,login,handle,password,permanentfile,passphrase); using &#34;abiglongpassword&#34; for the passphrase -&gt; {&#34;pubkey&#34;:&#34;6c469ba10b40b3eb9d1dba569d7f929d55a29d8f97cd5425907ef2f38f906 209&#34;,&#34;RS&#34;:&#34;NXT-KGV9-DXX8-TM86-DXR96&#34;,&#34;NXT&#34;:&#34;12834974574569896807&#34;,&#34;btcpu bkey&#34;:&#34;024e7641dc947b211bc30fe3339765258902794687b227121fc217284f9d8503c 8&#34;,&#34;rmd160&#34;:&#34;33453c24914db7b77069b7ea24df44f6be145938&#34;,&#34;BTC&#34;:&#34;15g6QK2dSd iW9ZTQEnnJxKrSph6uP7uU23&#34;,&#34;BTCD&#34;:&#34;RDxHUpuv3TX5DZpbhxmS3rBeaxZW1fvYvC&#34;,&#34;r esult&#34;:&#34;success&#34;,&#34;handle&#34;:&#34;test&#34;,&#34;tag&#34;:&#34;14805226009240621255&#34;} and if you use that to log into NXT, it gives the same address. The BTC and BTCD addresses are all derived from the same privkey so they are all interchangeable with the NXT address. The user can therefore select which coin&#39;s addressing they are most comfortable with I also added an &#34;allin&#34; action API for pangea. all the action API will autocalculate the number of chips if passed in 0 for numchips ***************** security issue ******** please dont use the GET URL method when dealing with passphrase!!! Those URL&#39;s tend to get logged and available in browser histories. so anything dealing with the actual passphrase needs to use the postCall form or POST
9 years ago
#define EXCHANGE_NAME "bitcoin"
#define UPDATE bitcoin ## _price
#define SUPPORTS bitcoin ## _supports
#define SIGNPOST bitcoin ## _signpost
#define TRADE bitcoin ## _trade
#define ORDERSTATUS bitcoin ## _orderstatus
#define CANCELORDER bitcoin ## _cancelorder
#define OPENORDERS bitcoin ## _openorders
#define TRADEHISTORY bitcoin ## _tradehistory
#define BALANCES bitcoin ## _balances
#define PARSEBALANCE bitcoin ## _parsebalance
#define WITHDRAW bitcoin ## _withdraw
#define CHECKBALANCE bitcoin ## _checkbalance
#define ALLPAIRS bitcoin ## _allpairs
#define FUNCS bitcoin ## _funcs
#define BASERELS bitcoin ## _baserels
9 years ago
9 years ago
static char *BASERELS[][2] = { {"btcd","btc"}, {"nxt","btc"}, {"asset","btc"} };
9 years ago
#include "exchange_supports.h"
9 years ago
double UPDATE(struct exchange_info *exchange,char *base,char *rel,struct exchange_quote *bidasks,int32_t maxdepth,double commission,cJSON *argjson,int32_t invert)
9 years ago
{
9 years ago
cJSON *retjson,*bids,*asks; double hbla; struct supernet_info *myinfo;
9 years ago
myinfo = SuperNET_MYINFO(0);
9 years ago
bids = cJSON_CreateArray();
asks = cJSON_CreateArray();
9 years ago
//instantdex_offerfind(myinfo,exchange,bids,asks,0,base,rel,0);
9 years ago
//printf("bids.(%s) asks.(%s)\n",jprint(bids,0),jprint(asks,0));
9 years ago
retjson = cJSON_CreateObject();
cJSON_AddItemToObject(retjson,"bids",bids);
cJSON_AddItemToObject(retjson,"asks",asks);
hbla = exchanges777_json_orderbook(exchange,commission,base,rel,bidasks,maxdepth,retjson,0,"bids","asks",0,0,invert);
free_json(retjson);
return(hbla);
9 years ago
}
char *PARSEBALANCE(struct exchange_info *exchange,double *balancep,char *coinstr,cJSON *argjson)
{
cJSON *item;
*balancep = 0;
if ( (item= jobj(argjson,coinstr)) != 0 )
{
*balancep = jdouble(item,"balance");
return(jprint(item,0));
}
return(clonestr("{\"error\":\"no item for specified coin\"}"));
9 years ago
}
cJSON *BALANCES(struct exchange_info *exchange,cJSON *argjson)
{
8 years ago
double balance; int32_t i,minconfirms,numunspents,max; struct iguana_info *coin,*tmp; struct supernet_info *myinfo; cJSON *retjson,*array,*item,*addresses=0; int64_t avail; struct iguana_outpoint outpt,*unspents=0;
retjson = cJSON_CreateArray();
myinfo = SuperNET_accountfind(argjson);
9 years ago
//portable_mutex_lock(&myinfo->allcoins_mutex);
HASH_ITER(hh,myinfo->allcoins,coin,tmp)
{
balance = 0.;
minconfirms = juint(argjson,"minconfirms");
if ( minconfirms < coin->minconfirms )
minconfirms = coin->minconfirms;
max = 100000;
unspents = calloc(max,sizeof(*unspents));
8 years ago
if ( (numunspents= iguana_RTunspentslists(myinfo,coin,&avail,unspents,max,((uint64_t)1 << 62),minconfirms,addresses,0)) > 0 )
{
array = cJSON_CreateArray();
for (i=0; i<numunspents; i++)
{
item = cJSON_CreateArray();
8 years ago
outpt = unspents[i];
jaddinum(item,outpt.hdrsi);
jaddinum(item,outpt.unspentind);
jaddinum(item,dstr(outpt.value));
jaddi(array,item);
}
item = cJSON_CreateObject();
jadd(item,"unspents",array);
jaddnum(item,"numunspents",numunspents);
jaddnum(item,"balance",dstr(avail));
jadd(retjson,coin->symbol,item);
}
if ( unspents != 0 )
free(unspents);
}
9 years ago
//portable_mutex_unlock(&myinfo->allcoins_mutex);
return(retjson);
9 years ago
}
9 years ago
int32_t is_valid_BTCother(char *other)
{
if ( iguana_coinfind(other) != 0 )
return(1);
else if ( strcmp(other,"NXT") == 0 || strcmp(other,"nxt") == 0 )
return(1);
else if ( is_decimalstr(other) > 0 )
return(1);
else return(0);
}
9 years ago
uint64_t TRADE(int32_t dotrade,char **retstrp,struct exchange_info *exchange,char *base,char *rel,int32_t dir,double price,double volume,cJSON *argjson)
{
9 years ago
//char *str,*retstr,coinaddr[64]; int32_t added; uint64_t txid = 0; cJSON *json=0; struct instantdex_accept *ap; struct supernet_info *myinfo; struct iguana_info *other;
//myinfo = SuperNET_MYINFO(0);//SuperNET_accountfind(argjson);
9 years ago
//printf("TRADE with myinfo.%p\n",myinfo);
9 years ago
if ( retstrp != 0 )
*retstrp = 0;
9 years ago
/*if ( strcmp(base,"BTC") == 0 || strcmp(base,"btc") == 0 )
9 years ago
{
base = rel;
rel = "BTC";
dir = -dir;
volume *= price;
price = 1. / price;
}
if ( is_valid_BTCother(base) != 0 && (strcmp(rel,"BTC") == 0 || strcmp(rel,"btc") == 0) )
{
if ( dotrade == 0 )
{
if ( retstrp != 0 )
9 years ago
*retstrp = clonestr("{\"result\":\"would issue new trade\"}");
9 years ago
}
else
{
9 years ago
if ( (other= iguana_coinfind(base)) != 0 )
9 years ago
{
//bitcoin_pubkey33(0,pubkey,myinfo->persistent_priv);
bitcoin_address(coinaddr,other->chain->pubtype,myinfo->persistent_pubkey33,33);
9 years ago
jaddstr(argjson,base,coinaddr);
9 years ago
}
9 years ago
else if ( strcmp(base,"NXT") == 0 || (is_decimalstr(base) > 0 && strlen(base) > 13) )
9 years ago
{
9 years ago
printf("NXT is not yet\n");
9 years ago
return(0);
}
9 years ago
else return(0);
json = cJSON_CreateObject();
jaddstr(json,"base",base);
jaddstr(json,"rel","BTC");
jaddnum(json,dir > 0 ? "maxprice" : "minprice",price);
jaddnum(json,"volume",volume);
jaddstr(json,"BTC",myinfo->myaddr.BTC);
9 years ago
jaddnum(json,"minperc",jdouble(argjson,"minperc"));
printf("trade dir.%d (%s/%s) %.6f vol %.8f\n",dir,base,"BTC",price,volume);
9 years ago
if ( (str= instantdex_createaccept(myinfo,&ap,exchange,base,"BTC",price,volume,-dir,dir > 0 ? "BTC" : base,INSTANTDEX_OFFERDURATION,myinfo->myaddr.nxt64bits,jdouble(argjson,"minperc"))) != 0 && ap != 0 )
{
retstr = instantdex_checkoffer(myinfo,&added,&txid,exchange,ap,json);
free(str);
if ( added == 0 )
free(ap);
} else printf("null return queueaccept\n");
9 years ago
if ( retstrp != 0 )
9 years ago
*retstrp = retstr;
9 years ago
}
}
9 years ago
return(txid);*/
return(0);
9 years ago
}
9 years ago
char *ORDERSTATUS(struct exchange_info *exchange,uint64_t orderid,cJSON *argjson)
9 years ago
{
9 years ago
//struct instantdex_accept *ap; struct bitcoin_swapinfo *swap;
cJSON *retjson;
9 years ago
retjson = cJSON_CreateObject();
9 years ago
struct supernet_info *myinfo;// = SuperNET_accountfind(argjson);
myinfo = SuperNET_MYINFO(0);//SuperNET_accountfind(argjson);
9 years ago
/*if ( (swap= instantdex_statemachinefind(myinfo,exchange,orderid)) != 0 )
9 years ago
jadd(retjson,"result",instantdex_statemachinejson(swap));
9 years ago
else if ( (ap= instantdex_offerfind(myinfo,exchange,0,0,orderid,"*","*",0)) != 0 )
9 years ago
jadd(retjson,"result",instantdex_acceptjson(ap));
9 years ago
else if ( (swap= instantdex_historyfind(myinfo,exchange,orderid)) != 0 )
jadd(retjson,"result",instantdex_historyjson(swap));
9 years ago
else jaddstr(retjson,"error","couldnt find orderid");*/
return(jprint(retjson,1));
9 years ago
}
9 years ago
char *CANCELORDER(struct exchange_info *exchange,uint64_t orderid,cJSON *argjson)
9 years ago
{
9 years ago
//struct instantdex_accept *ap = 0; struct bitcoin_swapinfo *swap=0;
cJSON *retjson;
//struct supernet_info *myinfo;// = SuperNET_accountfind(argjson);
//myinfo = SuperNET_MYINFO(0);//SuperNET_accountfind(argjson);
retjson = cJSON_CreateObject();
9 years ago
/*if ( (ap= instantdex_offerfind(myinfo,exchange,0,0,orderid,"*","*",0)) != 0 )
9 years ago
{
ap->dead = (uint32_t)time(NULL);
9 years ago
jadd(retjson,"orderid",instantdex_acceptjson(ap));
9 years ago
jaddstr(retjson,"result","killed orderid, but might have pending");
9 years ago
}
9 years ago
else if ( (swap= instantdex_statemachinefind(myinfo,exchange,orderid)) != 0 )
9 years ago
{
jadd(retjson,"orderid",instantdex_statemachinejson(swap));
jaddstr(retjson,"result","killed statemachine orderid, but might have pending");
9 years ago
}*/
return(jprint(retjson,1));
9 years ago
}
char *OPENORDERS(struct exchange_info *exchange,cJSON *argjson)
{
9 years ago
cJSON *retjson,*bids,*asks; struct supernet_info *myinfo;// = SuperNET_accountfind(argjson);
myinfo = SuperNET_MYINFO(0);//SuperNET_accountfind(argjson);
9 years ago
bids = cJSON_CreateArray();
asks = cJSON_CreateArray();
9 years ago
//instantdex_offerfind(myinfo,exchange,bids,asks,0,"*","*",0);
9 years ago
retjson = cJSON_CreateObject();
9 years ago
jaddstr(retjson,"result","success");
jadd(retjson,"bids",bids);
jadd(retjson,"asks",asks);
9 years ago
return(jprint(retjson,1));
9 years ago
}
char *TRADEHISTORY(struct exchange_info *exchange,cJSON *argjson)
{
9 years ago
struct bitcoin_swapinfo *swap,*tmp; cJSON *retjson = cJSON_CreateArray();
9 years ago
portable_mutex_lock(&exchange->mutexH);
9 years ago
DL_FOREACH_SAFE(exchange->history,swap,tmp)
{
9 years ago
//jaddi(retjson,instantdex_historyjson(swap));
}
9 years ago
portable_mutex_unlock(&exchange->mutexH);
return(jprint(retjson,1));
9 years ago
}
char *WITHDRAW(struct exchange_info *exchange,char *base,double amount,char *destaddr,cJSON *argjson)
{
9 years ago
//struct supernet_info *myinfo = SuperNET_accountfind(argjson);
// invoke conversion or transfer!
return(clonestr("{\"error\":\"what does it mean to withdraw bitcoins that are in your wallet\"}"));
9 years ago
}
many changes blockexplorer tab: needs to allow to input height, blockhash or txid. also please display images/BTC_blocks.jpg below the text as a w800 x h400 bitmap, which is active using the mouse api for coin management, below the active coins have a form that arbitrary json can be input with an add button to the right that will call &#34;addcoin&#34; API. this way I can test adding new coins dynamically. dont worry if it doesnt work, just as long as it submits the json to the C code. I am pretty sure I need to do some debugging of this peers management is not working for me at all. maybe it is due to bad internet. On initialization you need to read in the confs/BTCD_peers.txt from the native filesystem and save it into the chrome app filesystem. same thing for confs/BTCD_hdrs.txt. But this is only to be done if there isnt already such a file inside chrome. if there is, only do it upon a button invoked by the user. the reason is that the pexe is updating this file with the latest. Maybe it is nice to have an &#34;extract&#34; button that will copy out from the chrome storage into the native filesystem. There is also the manifest issue about localstorage vs chrome.localstorage. not sure what is needed to be done, but certainly a priority to get it so everything works as a chrome app. I know before it was making ramchain files inside the chrome filesystem, so it is probably things the GUI is doing. maybe in the settings tab, which has obsolete stuff that can be removed. anyway, the issue about files existing in the native filesystem -&gt; chrome and optionally extracting them is an issue for the confs files and .html template files used to autogenerate the port7778, maybe other files are affected. i think we need a way to have a list of hardcoded files that are just copied into chrome on startup if they dont exist already (or if possible copy over if the native version is bigger?) and buttons to extract them for debug tab: THREE_STRINGS(SuperNET,encryptjson,passphrase,permanentfile,anything); TWO_STRINGS(SuperNET,decryptjson,passphrase,permanentfile); at the top of page a way to put in passphrase and optional permanentfile along with arbitrary json. The standard form template has no easy way to describe to pass in everything as it is oriented to specific fields. but the encryptjson API saves all the fields, so the arbitrary json from the form needs to be combined at the same level as the &#34;agent&#34;, &#34;method&#34;, etc. I know, not the best, but internally it makes it easier. so {&#34;agent&#34;:&#34;SuperNET&#34;,&#34;method&#34;:&#34;encryptjson&#34;,&#34;passphrase&#34;:&#34;&lt;passphrase&gt;&#34;,&#34; permanentfile&#34;:&#34;&lt;filename&gt;&#34;,&#34;fromform&#34;:&#34;valuefromform&#34;,&#34;fromform2&#34;:&#34;valu efromform2&#34;,...rest of form at top level} then this will save it into a file with crazy number (it is a hash like txid) but given the same passphrase and filename, it will regenerate this hash so you dont actually have to store it, but it helps during debugging. for the filename, we must warn quite strongly to the user that if the file is ever lost or even changed in any way that the data will not be recoverable. also best to not allow the user to specify a file that does not exist. I think at this point chrome app version gets a bit tricky. we could simply push the native file into the chrome storage, but then an attacker who gets access to the computer could just get a list of these files and it really wont be much protection. So that means if a filename is specified, it needs to be copied into the chrome space, then immediately deleted... ok, this seems like not a good approach. let us make it so that the permanentfile option is not available from the chrome app, but only if the native version is running. that way we sidestep the issue of the pexe not having access to the specified file. Speaking of native vs pexe, on the startup page we should have a radio button that allows the user to select which the GUI will talk to. It should default based on a self test to the more likely value, but it is possible that the user wants to use the native version, even if the pexe is running. another thing to have on the startup page is a simple login: THREE_STRINGS(SuperNET,login,passphrase,permanentfile,handle); ZERO_ARGS(SuperNET,logout); ZERO_ARGS(SuperNET,activehandle); the handle is a human readable name that is associated with the passphrase/permanentfile. There can only be one active account (though it will be possible to associate different accounts with tradebots). use the activehandle API to find out who is logged in and the associated addresses and pubkeys The above is not yet tested so if it doesnt work, dont fret, just let me know. Once set the handle can be displayed in various places to let the user know which account is logged in. The standard 12 dictionary word passphrases should be used, but any string can be sent in as the password for Pangea: INT_AND_ARRAY(pangea,host,minplayers,params); ZERO_ARGS(pangea,lobby); HASH_AND_STRING(pangea,join,tablehash,handle); HASH_AND_INT(pangea,buyin,tablehash,numchips); HASH_ARG(pangea,start,tablehash); // by host only HASH_ARG(pangea,status,tablehash); HASH_ARG(pangea,call,tablehash); HASH_ARG(pangea,check,tablehash); HASH_AND_INT(pangea,raise,tablehash,numchips); HASH_AND_INT(pangea,bet,tablehash,numchips); HASH_ARG(pangea,fold,tablehash); HASH_AND_STRING(pangea,mode,tablehash,modestr); HASH_ARG(pangea,history,tablehash); HASH_AND_INT(pangea,handhistory,tablehash,hand); The first thing that is done is a &#34;host&#34; by any node. the &#34;params&#34; should be an arbitrary json (like encryptjson) as it needs to be at the top level and it has quite a few different parameters still subject to change. The lobby API will just display all the hosted tables. once a table exists, players can join and then buyin. the buyin is denominated in chips, each chip&#39;s value is determined by the host&#39;s initial parameters. once there are enough players joined with adequate buyin&#39;s verified, the host will be able to do a start. if done before it will (eventually) give an error. for now it will just proceed. The host and players that have joined a tablehash, need to do regular status calls to see if the game has started. Probably just once per 5 or even 10 seconds is fine before the start. Once the game starts (the status will have this info) then once per second polling is needed. Then when it is your turn (as indicated by status) you need to do one of the 5 actions (fold, call, check, raise, bet). do not worry if you dont understand what all these do, just allow the user to do any of these. I guess it is possible to submit it ahead of time. I will support internally remembering the most recent action done prior to it being your turn. once it is your turn and an action is sent to the table, it is too late to change. The last API calls are for getting handhistory where hand is 0 to N-1, being the numbering of the hands played at that table. if just history, all the history for all hands at the table is coming back, so it could be quite big. probably I will make it a summary, but for the GUI just display the returned values. the mode is to change some poker specific modes, so just allow there to be a string entered. do not worry about understanding the pokerness of the API, just the overall flow: host -&gt; creates, join/buyin -&gt; fills up player slots, start -&gt; starts the game status -&gt; to determine when the game starts (or if it is cancelled) and once started actions -&gt; game specific but basically just (button + arg) that is the user input results are via status for current game and history for past ones please try to do the above logic in a generic way so it can be reused for other games. The basic flow should be the same for almost all multiplayer turn based games and even for multiplayer realtime games For InstantDEX: on the apikeypair/userid there needs to be two modes. one for when there is no stored apikey and the current form is fine, just need to make it wider as most apikeys are quite long. Now once there is an apikey saved all that is needed is the passphrase to unlock it. So here is where the encrptjson/decryptjson is used. When saving the apikey for the first time, it can be: a) not saved -&gt; nothing extra to do b) saved without password -&gt; you can just save to a file and use it to load it back in. use confs dir confs/instantdex.exchange.api or something like that c) saved with password (optional filename for native) -&gt; probably best to save in the confs dir to indicate that there is an encrypted file for this, so just that and not the actual passphrase in the file with the above, when the exchange is selected, you can see if the confs file exists and if it has the plaintext, just populate the field, if not, then indicate that a passphrase is needed. if the user provides the passphrase, then decryptjson and populate the fields and autosubmit. A special case is to encrypt the apikeys with the passphrase used when logging in. This is only available if the checkbox to &#34;remember passphrase during session&#34; is set on the main iguana login screen. (i forgot to mention that checkbox!) So the login passphrase is stored in memory, then the GUI simply uses that + encryptjson for storing/decrypting. I would imagine that storing in the confs file that it is encrypted using &#34;handle&#34;&#39;s account login might be a good way to differentiate between this mode of password usage. OK, so we now have the insecure plaintext, the decent using handle&#39;s passphrase and paranoid different passphrase for each exchange (with additional permanentfile for native versions) &#34;SUPPORT&#34; -&gt; &#34;SUPPORTS&#34; just a typo and &#34;allpairs&#34; API is missing from the selection Might as well add a &#34;tradebots&#34; tab: THREE_STRINGS_AND_DOUBLE(tradebot,monitor,exchange,base,rel,commission); STRING_AND_DOUBLE(tradebot,monitorall,exchange,commission); THREE_STRINGS(tradebot,unmonitor,exchange,base,rel); THREE_STRINGS_AND_THREE_DOUBLES(tradebot,accumulate,exchange,base,rel,pr ice,volume,duration); THREE_STRINGS_AND_THREE_DOUBLES(tradebot,divest,exchange,base,rel,price, volume,duration); STRING_ARG(tradebot,activebots,exchange); TWO_STRINGS(tradebot,status,exchange,botid); TWO_STRINGS(tradebot,pause,exchange,botid); TWO_STRINGS(tradebot,stop,exchange,botid); TWO_STRINGS(tradebot,resume,exchange,botid); the above are API for exchange specific bots, most should be self-explanatory. bots are created via &#34;accumulate&#34; or &#34;divest&#34; API call. it returns botid. once created, you can do status, pause, stop, resume to a botid. and an activebots API call lists all the active bots for an exchange. duration is in seconds the &#34;monitor&#34; API starts background monitoring of a specific base/rel, &#34;unmonitor&#34; stops this. &#34;monitorall&#34; just does a monitor to the entire list of &#34;allpairs&#34; for that exchange. Keep in mind that doing a monitorall will not add load to an exchange as the request to each exchange is governed by pollgap, but if you have 3 things monitored, it will take 3*pollgap + time each one takes to execute. and if N are monitored it is N*pollgap + time of each, with the &#34;time of each&#34; possibly taking a very long time. And one final request for today: Bitmap tab. It should be an active bitmap using mouse api. either a dropdown to select the bitmap or a form entry. then the rest of the page (resize the bitmap to the page size) being the active bitmap. So on a small screen the bitmap is smaller x/y dimensions and larger on larger screens. plz make sure the proper dimensions are communicated to the pexe via API if it ever is changed. @vineet.bhargav86: I changed the &#34;passphrase&#34; fieldname to &#34;password&#34; for the encryptjson/decryptjson related API. The reason is that the password is like a wallet password and is only local, so it doesnt need to be as high entropy as passphrase. I also added a field to the login API as I realized that the 12 word &#34;passphrase&#34; is the payload and usually wont be sent in: FOUR_STRINGS(SuperNET,login,handle,password,permanentfile,passphrase); using &#34;abiglongpassword&#34; for the passphrase -&gt; {&#34;pubkey&#34;:&#34;6c469ba10b40b3eb9d1dba569d7f929d55a29d8f97cd5425907ef2f38f906 209&#34;,&#34;RS&#34;:&#34;NXT-KGV9-DXX8-TM86-DXR96&#34;,&#34;NXT&#34;:&#34;12834974574569896807&#34;,&#34;btcpu bkey&#34;:&#34;024e7641dc947b211bc30fe3339765258902794687b227121fc217284f9d8503c 8&#34;,&#34;rmd160&#34;:&#34;33453c24914db7b77069b7ea24df44f6be145938&#34;,&#34;BTC&#34;:&#34;15g6QK2dSd iW9ZTQEnnJxKrSph6uP7uU23&#34;,&#34;BTCD&#34;:&#34;RDxHUpuv3TX5DZpbhxmS3rBeaxZW1fvYvC&#34;,&#34;r esult&#34;:&#34;success&#34;,&#34;handle&#34;:&#34;test&#34;,&#34;tag&#34;:&#34;14805226009240621255&#34;} and if you use that to log into NXT, it gives the same address. The BTC and BTCD addresses are all derived from the same privkey so they are all interchangeable with the NXT address. The user can therefore select which coin&#39;s addressing they are most comfortable with I also added an &#34;allin&#34; action API for pangea. all the action API will autocalculate the number of chips if passed in 0 for numchips ***************** security issue ******** please dont use the GET URL method when dealing with passphrase!!! Those URL&#39;s tend to get logged and available in browser histories. so anything dealing with the actual passphrase needs to use the postCall form or POST
9 years ago
struct exchange_funcs bitcoin_funcs = EXCHANGE_FUNCS(bitcoin,EXCHANGE_NAME);
9 years ago
#include "exchange_undefs.h"
9 years ago