This commit is contained in:
jl777
2019-03-27 06:02:13 -11:00
parent 05b91ae063
commit dbb8f0acc2
2 changed files with 15 additions and 6 deletions

View File

@@ -123,7 +123,7 @@ void *gamesiterate(struct games_state *rs)
#ifdef STANDALONE
#include <ncurses.h>
#include "dapps/dappstd.c"
int64_t Net_change,Betsize;
int64_t Net_change,Betsize = SATOSHIDEN;
char *send_curl(char *url,char *fname)
{
@@ -159,7 +159,7 @@ uint64_t get_btcusd()
mult = 10000 + Net_change*10;
newprice = (btcusd * mult) / 10000;
x = ((uint64_t)time(NULL) << 32) | ((newprice / 10000) & 0xffffffff);
sprintf(str,"BTC/USD %.4f Net_change %lld * 0.001 -> Betsize %.8f %.4f\n",dstr(btcusd),(long long)Net_change,dstr(Betsize),dstr(newprice));
sprintf(str,"BTC/USD %.4f -> Betsize %.8f (^ / to change) && %.4f [+ - to change]\n",dstr(btcusd),dstr(Betsize),dstr(newprice));
mvaddstr(0, 0, str);
clrtoeol();
doupdate();
@@ -241,7 +241,7 @@ int32_t issue_bet(struct games_state *rs,int64_t x,int64_t betsize)
if ( (resobj= jobj(retjson,(char *)"result")) != 0 )
{
retval = 0;
fprintf(stderr,"%s\n",jprint(resobj,0));
//fprintf(stderr,"%s\n",jprint(resobj,0));
}
free_json(retjson);
}

View File

@@ -15,11 +15,18 @@
******************************************************************************/
UniValue games_rawtxresult(UniValue &result,std::string rawtx,int32_t broadcastflag);
extern uint8_t ASSETCHAINS_OVERRIDE_PUBKEY33[33];
UniValue games_bet(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
{
CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight());
UniValue result(UniValue::VOBJ); std::string rawtx; int64_t amount,inputsum,price; CPubKey gamespk,mypk;
UniValue result(UniValue::VOBJ); std::string rawtx; int64_t amount,inputsum,price; CPubKey gamespk,mypk,acpk;
if ( ASSETCHAINS_OVERRIDE_PUBKEY33[0] == 0 )
{
result.push_back(Pair("result","error"));
result.push_back(Pair("error"," no -ac_pubkey for price reference"));
}
acpk = buf2pk(ASSETCHAINS_OVERRIDE_PUBKEY33);
if ( params != 0 && cJSON_GetArraySize(params) == 2 )
{
amount = jdouble(jitem(params,0),0) * COIN + 0.0000000049;
@@ -28,7 +35,9 @@ UniValue games_bet(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
result.push_back(Pair("result","error"));
result.push_back(Pair("error","couldnt parsehash"));
}
fprintf(stderr,"amount %llu price %llx\n",(long long)amount,(long long)price);
if ( mypk == acpk )
amount = 0; // i am the reference price feed
//fprintf(stderr,"amount %llu price %llx\n",(long long)amount,(long long)price);
mypk = pubkey2pk(Mypubkey());
gamespk = GetUnspendable(cp,0);
if ( (inputsum= AddNormalinputs(mtx,mypk,amount+GAMES_TXFEE,64)) >= amount+GAMES_TXFEE )
@@ -53,7 +62,7 @@ UniValue games_bet(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
void prices_update(uint32_t timestamp,uint32_t uprice,int32_t ismine)
{
fprintf(stderr,"%s t%u %.4f %16llx\n",ismine!=0?"mine":"ext ",timestamp,(double)uprice/10000,(long long)((uint64_t)timestamp<<32) | uprice);
//fprintf(stderr,"%s t%u %.4f %16llx\n",ismine!=0?"mine":"ext ",timestamp,(double)uprice/10000,(long long)((uint64_t)timestamp<<32) | uprice);
}
// game specific code for daemon