Teach oracles* RPC functions about CCerror and start populating it

This commit is contained in:
Jonathan "Duke" Leto
2018-11-20 13:22:16 -08:00
parent 5c3be4dfba
commit 8c66ce0a7f
2 changed files with 10 additions and 2 deletions

View File

@@ -794,12 +794,14 @@ std::string OracleData(int64_t txfee,uint256 oracletxid,std::vector <uint8_t> da
mypk = pubkey2pk(Mypubkey()); mypk = pubkey2pk(Mypubkey());
if ( data.size() > 8192 ) if ( data.size() > 8192 )
{ {
fprintf(stderr,"datasize %d is too big\n",(int32_t)data.size()); CCerror = strprintf("datasize %d is too big\n",(int32_t)data.size());
fprintf(stderr,"%s\n", CCerror.c_str() );
return(""); return("");
} }
if ( (datafee= OracleDatafee(pubKey,oracletxid,mypk)) <= 0 ) if ( (datafee= OracleDatafee(pubKey,oracletxid,mypk)) <= 0 )
{ {
fprintf(stderr,"datafee %.8f is illegal\n",(double)datafee/COIN); CCerror = strprintf("datafee %.8f is illegal\n",(double)datafee/COIN);
fprintf(stderr,"%s\n", CCerror.c_str() );
return(""); return("");
} }
if ( txfee == 0 ) if ( txfee == 0 )

View File

@@ -6157,6 +6157,7 @@ UniValue oraclesregister(const UniValue& params, bool fHelp)
if ( (datafee= atol((char *)params[1].get_str().c_str())) == 0 ) if ( (datafee= atol((char *)params[1].get_str().c_str())) == 0 )
datafee = atof((char *)params[1].get_str().c_str()) * COIN + 0.00000000499999; datafee = atof((char *)params[1].get_str().c_str()) * COIN + 0.00000000499999;
hex = OracleRegister(0,txid,datafee); hex = OracleRegister(0,txid,datafee);
RETURN_IF_ERROR(CCerror);
if ( hex.size() > 0 ) if ( hex.size() > 0 )
{ {
result.push_back(Pair("result", "success")); result.push_back(Pair("result", "success"));
@@ -6178,6 +6179,7 @@ UniValue oraclessubscribe(const UniValue& params, bool fHelp)
pubkey = ParseHex(params[1].get_str().c_str()); pubkey = ParseHex(params[1].get_str().c_str());
amount = atof((char *)params[2].get_str().c_str()) * COIN + 0.00000000499999; amount = atof((char *)params[2].get_str().c_str()) * COIN + 0.00000000499999;
hex = OracleSubscribe(0,txid,pubkey2pk(pubkey),amount); hex = OracleSubscribe(0,txid,pubkey2pk(pubkey),amount);
RETURN_IF_ERROR(CCerror);
if ( hex.size() > 0 ) if ( hex.size() > 0 )
{ {
result.push_back(Pair("result", "success")); result.push_back(Pair("result", "success"));
@@ -6211,6 +6213,9 @@ UniValue oraclesdata(const UniValue& params, bool fHelp)
txid = Parseuint256((char *)params[0].get_str().c_str()); txid = Parseuint256((char *)params[0].get_str().c_str());
data = ParseHex(params[1].get_str().c_str()); data = ParseHex(params[1].get_str().c_str());
hex = OracleData(0,txid,data); hex = OracleData(0,txid,data);
RETURN_IF_ERROR(CCerror);
if ( hex.size() > 0 ) if ( hex.size() > 0 )
{ {
result.push_back(Pair("result", "success")); result.push_back(Pair("result", "success"));
@@ -6265,6 +6270,7 @@ UniValue oraclescreate(const UniValue& params, bool fHelp)
return(result); return(result);
} }
hex = OracleCreate(0,name,description,format); hex = OracleCreate(0,name,description,format);
RETURN_IF_ERROR(CCerror);
if ( hex.size() > 0 ) if ( hex.size() > 0 )
{ {
result.push_back(Pair("result", "success")); result.push_back(Pair("result", "success"));