diff --git a/src/cc/dapps/oraclefeed.c b/src/cc/dapps/oraclefeed.c index 68437d8fd..c427c0477 100644 --- a/src/cc/dapps/oraclefeed.c +++ b/src/cc/dapps/oraclefeed.c @@ -290,15 +290,23 @@ cJSON *get_urljson(char *url) return(json); } -int32_t main(int32_t argc,char **argv) +uint64_t get_btcusd() { - cJSON *pjson,*bpi,*usd; - printf("Powered by CoinDesk (%s)\n","https://www.coindesk.com/price/"); + cJSON *pjson,*bpi,*usd; uint64_t btcusd = 0; if ( (pjson= get_urljson("http://api.coindesk.com/v1/bpi/currentprice.json")) != 0 ) { if ( (bpi= jobj(pjson,"bpi")) != 0 && (usd= jobj(bpi,"USD")) != 0 ) - printf("BTC/USD %.4f\n",jdouble(usd,"rate_float")); + { + btcusd = jdouble(usd,"rate_float") * SATOSHIDEN; + printf("BTC/USD %.4f\n",dstr(btcusd)); + } free_json(pjson); } + return(btcusd); +} + +int32_t main(int32_t argc,char **argv) +{ + printf("Powered by CoinDesk (%s) %.8f\n","https://www.coindesk.com/price/",dstr(get_btcusd())); return(0); } diff --git a/src/cc/oracles.cpp b/src/cc/oracles.cpp index 95e5a5ddb..2e797a772 100644 --- a/src/cc/oracles.cpp +++ b/src/cc/oracles.cpp @@ -96,7 +96,7 @@ CScript EncodeOraclesCreateOpRet(uint8_t funcid,std::string name,std::string description,std::string format) { CScript opret; uint8_t evalcode = EVAL_ORACLES; - opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << name << description << format); + opret << OP_RETURN << E_MARSHAL(ss << evalcode << funcid << name << format << description); return(opret); } @@ -109,7 +109,7 @@ uint8_t DecodeOraclesCreateOpRet(const CScript &scriptPubKey,std::string &name,s { if ( script[1] == 'C' ) { - if ( E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> name; ss >> description; ss >> format) != 0 ) + if ( E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> name; ss >> format; ss >> description) != 0 ) { return(script[1]); } else fprintf(stderr,"DecodeOraclesCreateOpRet unmarshal error for C\n");