Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/bitcoin-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include <event2/buffer.h>
#include <event2/keyvalq_struct.h>
#include "support/events.h"
uint16_t BITCOIND_RPCPORT = 7771;
char ASSETCHAINS_SYMBOL[65];

#include <univalue.h>
Expand Down Expand Up @@ -213,7 +212,6 @@ UniValue CallRPC(const std::string& strMethod, const UniValue& params)
{
std::string host = GetArg("-rpcconnect", "127.0.0.1");
int port = GetArg("-rpcport", BaseParams().RPCPort());
BITCOIND_RPCPORT = port;
// Obtain event base
raii_event_base base = obtain_event_base();

Expand Down
12 changes: 9 additions & 3 deletions src/bitcoind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
#include "util.h"
#include "httpserver.h"
#include "httprpc.h"
#include "komodo_defs.h"
#include "komodo_utils.h"
#include "komodo_jumblr.h"
#include "komodo_extern_globals.h"

#include <boost/algorithm/string/predicate.hpp>
#include <boost/filesystem.hpp>
Expand Down Expand Up @@ -56,10 +60,10 @@
*/

static bool fDaemon;
#include "komodo_defs.h"
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
extern int32_t ASSETCHAINS_BLOCKTIME;
extern uint64_t ASSETCHAINS_CBOPRET;
extern std::shared_ptr<Jumblr> jumblr;
void komodo_passport_iteration();
uint64_t komodo_interestsum();
int32_t komodo_longestchain();
Expand Down Expand Up @@ -155,8 +159,8 @@ bool AppInit(int argc, char* argv[])
fprintf(stderr, "Error: Invalid combination of -regtest and -testnet.\n");
return false;
}
void komodo_args(char *argv0);
komodo_args(argv[0]);
int16_t bitcoind_rpcport;
komodo_args(argv[0], bitcoind_rpcport);
void chainparams_commandline();
chainparams_commandline();

Expand All @@ -170,6 +174,8 @@ bool AppInit(int argc, char* argv[])
try
{
ReadConfigFile(mapArgs, mapMultiArgs);
bitcoind_rpcport = GetArg("-rpcport",bitcoind_rpcport); // let command line override config file
jumblr = std::make_shared<Jumblr>(KMDUSERPASS, bitcoind_rpcport);
} catch (const missing_zcash_conf& e) {
fprintf(stderr,
(_("Before starting komodod, you need to create a configuration file:\n"
Expand Down
47 changes: 27 additions & 20 deletions src/cc/dapps/dappstd.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ size_t accumulatebytes(void *ptr,size_t size,size_t nmemb,struct return_string *
*
************************************************************************/

char *post_process_bitcoind_RPC(char *debugstr,char *command,char *rpcstr,char *params)
char *post_process_bitcoind_RPC(const char *debugstr,const char *command,char *rpcstr,const char *params)
{
long i,j,len; char *retstr = 0; cJSON *json,*result,*error;
//printf("<<<<<<<<<<< bitcoind_RPC: %s post_process_bitcoind_RPC.%s.[%s]\n",debugstr,command,rpcstr);
Expand Down Expand Up @@ -303,12 +303,17 @@ char *post_process_bitcoind_RPC(char *debugstr,char *command,char *rpcstr,char *
#endif

/************************************************************************
*
* perform the query
*
* @brief perform an RPC call
* @param retstrp where the results are put
* @param debugstr
* @param url
* @param userpass
* @param command
* @param params
* @returns
************************************************************************/

char *bitcoind_RPC(char **retstrp,char *debugstr,char *url,char *userpass,char *command,char *params)
char *bitcoind_RPC(char **retstrp,const char *debugstr,const char *url,const char *userpass,
const char *command,const char *params)
{
static int didinit,count,count2; static double elapsedsum,elapsedsum2;
struct curl_slist *headers = NULL; struct return_string s; CURLcode res; CURL *curl_handle;
Expand Down Expand Up @@ -563,21 +568,23 @@ uint16_t komodo_userpass(char *userpass,char *symbol)

#define is_cJSON_True(json) ((json) != 0 && ((json)->type & 0xff) == cJSON_True)

char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port)
/****
* @brief issue an RPC call
* @param userpass RPC credentials
* @param method the method to call
* @param params the method parameters ( limit ~8k chars )
* @param port the IP port
* @returns the results (can be NULL on error)
*/
char *komodo_issuemethod(const char *userpass,const char *method,const char *params, uint16_t port)
{
//static void *cHandle;
char url[512],*retstr=0,*retstr2=0,postdata[8192];
if ( params == 0 || params[0] == 0 )
params = (char *)"[]";
if ( strlen(params) < sizeof(postdata)-128 )
{
sprintf(url,(char *)"http://%s:%u",IPADDRESS,port);
sprintf(postdata,"{\"method\":\"%s\",\"params\":%s}",method,params);
//printf("[%s] (%s) postdata.(%s) params.(%s) USERPASS.(%s)\n",ASSETCHAINS_SYMBOL,url,postdata,params,USERPASS);
retstr2 = bitcoind_RPC(&retstr,(char *)"debug",url,userpass,method,params);
//retstr = curl_post(&cHandle,url,USERPASS,postdata,0,0,0,0);
}
return(retstr2);
if ( params != NULL && strlen(params) < 8192-128)
return NULL;

char url[512];
sprintf(url,(char *)"http://%s:%u",IPADDRESS,port);
char *retstr=0;
return bitcoind_RPC(&retstr,(char *)"debug",url,userpass,method,params);
}

int32_t games_sendrawtransaction(char *rawtx)
Expand Down
1 change: 0 additions & 1 deletion src/cc/includes/cJSON.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ extern "C"
char *get_cJSON_fieldname(cJSON *obj);
void ensure_jsonitem(cJSON *json,char *field,char *value);
int32_t in_jsonarray(cJSON *array,char *value);
char *bitcoind_RPC(char **retstrp,char *debugstr,char *url,char *userpass,char *command,char *params,int32_t timeout);
uint64_t calc_nxt64bits(const char *str);
int32_t expand_nxt64bits(char *str,uint64_t nxt64bits);
char *nxt64str(uint64_t nxt64bits);
Expand Down
47 changes: 27 additions & 20 deletions src/cc/rogue/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ size_t accumulatebytes(void *ptr,size_t size,size_t nmemb,struct return_string *
*
************************************************************************/

char *post_process_bitcoind_RPC(char *debugstr,char *command,char *rpcstr,char *params)
char *post_process_bitcoind_RPC(const char *debugstr,const char *command,char *rpcstr,const char *params)
{
long i,j,len; char *retstr = 0; cJSON *json,*result,*error;
//printf("<<<<<<<<<<< bitcoind_RPC: %s post_process_bitcoind_RPC.%s.[%s]\n",debugstr,command,rpcstr);
Expand Down Expand Up @@ -314,12 +314,17 @@ char *post_process_bitcoind_RPC(char *debugstr,char *command,char *rpcstr,char *
#endif

/************************************************************************
*
* perform the query
*
* @brief perform an RPC call
* @param retstrp where the results are put
* @param debugstr
* @param url
* @param userpass
* @param command
* @param params
* @returns
************************************************************************/

char *bitcoind_RPC(char **retstrp,char *debugstr,char *url,char *userpass,char *command,char *params)
char *bitcoind_RPC(char **retstrp,const char *debugstr,const char *url,const char *userpass,
const char *command,const char *params)
{
static int didinit,count,count2; static double elapsedsum,elapsedsum2;
struct curl_slist *headers = NULL; struct return_string s; CURLcode res; CURL *curl_handle;
Expand Down Expand Up @@ -611,21 +616,23 @@ uint16_t komodo_userpass(char *userpass,char *symbol)

#define is_cJSON_True(json) ((json) != 0 && ((json)->type & 0xff) == cJSON_True)

char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port)
/****
* @brief issue an RPC call
* @param userpass RPC credentials
* @param method the method to call
* @param params the method parameters (NULL ok)
* @param port the IP port
* @returns the results (can be NULL on error)
*/
char *komodo_issuemethod(const char *userpass,const char *method,const char *params, uint16_t port)
{
//static void *cHandle;
char url[512],*retstr=0,*retstr2=0,postdata[8192];
if ( params == 0 || params[0] == 0 )
params = (char *)"[]";
if ( strlen(params) < sizeof(postdata)-128 )
{
sprintf(url,(char *)"http://%s:%u",IPADDRESS,port);
sprintf(postdata,"{\"method\":\"%s\",\"params\":%s}",method,params);
//printf("[%s] (%s) postdata.(%s) params.(%s) USERPASS.(%s)\n",ASSETCHAINS_SYMBOL,url,postdata,params,USERPASS);
retstr2 = bitcoind_RPC(&retstr,(char *)"debug",url,userpass,method,params);
//retstr = curl_post(&cHandle,url,USERPASS,postdata,0,0,0,0);
}
return(retstr2);
if ( params != NULL && strlen(params) < 8192-128)
return NULL;

char url[512];
sprintf(url,(char *)"http://%s:%u",IPADDRESS,port);
char *retstr=0;
return bitcoind_RPC(&retstr,(char *)"debug",url,userpass,method,params);
}

#include "rogue.h"
Expand Down
57 changes: 30 additions & 27 deletions src/komodo_bitcoind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ size_t accumulatebytes(void *ptr,size_t size,size_t nmemb,struct return_string *
*
************************************************************************/

char *post_process_bitcoind_RPC(char *debugstr,char *command,char *rpcstr,char *params)
char *post_process_bitcoind_RPC(const char *debugstr,const char *command,char *rpcstr,const char *params)
{
long i,j,len; char *retstr = 0; cJSON *json,*result,*error;
//printf("<<<<<<<<<<< bitcoind_RPC: %s post_process_bitcoind_RPC.%s.[%s]\n",debugstr,command,rpcstr);
Expand Down Expand Up @@ -137,12 +137,17 @@ char *post_process_bitcoind_RPC(char *debugstr,char *command,char *rpcstr,char *
#endif

/************************************************************************
*
* perform the query
*
* @brief perform an RPC call
* @param retstrp where the results are put
* @param debugstr
* @param url
* @param userpass
* @param command
* @param params
* @returns
************************************************************************/

char *bitcoind_RPC(char **retstrp,char *debugstr,char *url,char *userpass,char *command,char *params)
char *bitcoind_RPC(char **retstrp,const char *debugstr,const char *url,const char *userpass,
const char *command,const char *params)
{
static int didinit,count,count2; static double elapsedsum,elapsedsum2;
struct curl_slist *headers = NULL; struct return_string s; CURLcode res; CURL *curl_handle;
Expand All @@ -155,9 +160,8 @@ char *bitcoind_RPC(char **retstrp,char *debugstr,char *url,char *userpass,char *
numretries = 0;
if ( debugstr != 0 && strcmp(debugstr,"BTCD") == 0 && command != 0 && strcmp(command,"SuperNET") == 0 )
specialcase = 1;
else specialcase = 0;
if ( url[0] == 0 )
strcpy(url,"http://127.0.0.1:7876/nxt");
else
specialcase = 0;
if ( specialcase != 0 && 0 )
printf("<<<<<<<<<<< bitcoind_RPC: debug.(%s) url.(%s) command.(%s) params.(%s)\n",debugstr,url,command,params);
try_again:
Expand Down Expand Up @@ -338,22 +342,23 @@ char *curl_post(CURL **cHandlep,char *url,char *userpass,char *postfields,char *
return(chunk.memory);
}

char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port)
/****
* @brief issue an RPC call
* @param userpass RPC credentials
* @param method the method to call
* @param params the method parameters ( limit ~8k chars )
* @param port the IP port
* @returns the results (can be NULL on error)
*/
char *komodo_issuemethod(const char *userpass,const char *method,const char *params, uint16_t port)
{
//static void *cHandle;
char url[512],*retstr=0,*retstr2=0,postdata[8192];
if ( params == 0 || params[0] == 0 )
params = (char *)"[]";
if ( strlen(params) < sizeof(postdata)-128 )
{
sprintf(url,(char *)"http://127.0.0.1:%u",port);
sprintf(postdata,"{\"method\":\"%s\",\"params\":%s}",method,params);
// printf("[%s] (%s) postdata.(%s) params.(%s) USERPASS.(%s)\n",ASSETCHAINS_SYMBOL,url,postdata,params,KMDUSERPASS);
retstr2 = bitcoind_RPC(&retstr,(char *)"debug",url,userpass,method,params);
//retstr = curl_post(&cHandle,url,USERPASS,postdata,0,0,0,0);
}
// fprintf(stderr, "RPC RESP: %s\n", retstr2);
return(retstr2);
if ( params != NULL && strlen(params) < 8192-128)
return NULL;

char url[512];
sprintf(url,(char *)"http://127.0.0.1:%u",port);
char *retstr=0;
return bitcoind_RPC(&retstr,(char *)"debug",url,userpass,method,params);
}

int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp)
Expand Down Expand Up @@ -477,9 +482,8 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t
if ( ASSETCHAINS_SYMBOL[0] != 0 )
{
jsonstr = komodo_issuemethod(KMDUSERPASS,(char *)"getrawtransaction",params,KMD_PORT);
//printf("userpass.(%s) got (%s)\n",KMDUSERPASS,jsonstr);
}
}//else jsonstr = _dex_getrawtransaction();
}
else return(0); // need universal way to issue DEX* API, since notaries mine most blocks, this ok
}
else if ( strcmp(dest,"BTC") == 0 )
Expand All @@ -488,7 +492,6 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t
{
jsonstr = komodo_issuemethod(BTCUSERPASS,(char *)"getrawtransaction",params,DEST_PORT);
}
//else jsonstr = _dex_getrawtransaction();
else return(0);
}
else
Expand Down
27 changes: 20 additions & 7 deletions src/komodo_bitcoind.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,35 @@ size_t accumulatebytes(void *ptr,size_t size,size_t nmemb,struct return_string *
*
************************************************************************/

char *post_process_bitcoind_RPC(char *debugstr,char *command,char *rpcstr,char *params);
char *post_process_bitcoind_RPC(const char *debugstr,const char *command,char *rpcstr,const char *params);
#endif

/************************************************************************
*
* perform the query
*
* @brief perform an RPC call
* @param retstrp where the results are put
* @param debugstr
* @param url
* @param userpass
* @param command
* @param params
* @returns
************************************************************************/

char *bitcoind_RPC(char **retstrp,char *debugstr,char *url,char *userpass,char *command,char *params);
char *bitcoind_RPC(char **retstrp,const char *debugstr,const char *url,const char *userpass,
const char *command,const char *params);

static size_t WriteMemoryCallback(void *ptr,size_t size,size_t nmemb,void *data);

char *curl_post(CURL **cHandlep,char *url,char *userpass,char *postfields,char *hdr0,char *hdr1,char *hdr2,char *hdr3);

char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port);
/****
* @brief issue an RPC call
* @param userpass RPC credentials
* @param method the method to call
* @param params the method parameters ( limit ~8k chars )
* @param port the IP port
* @returns the results (can be NULL on error)
*/
char *komodo_issuemethod(const char *userpass,const char *method,const char *params, uint16_t port);

int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp);

Expand Down
1 change: 0 additions & 1 deletion src/komodo_cJSON.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ extern "C"
char *get_cJSON_fieldname(cJSON *obj);
void ensure_jsonitem(cJSON *json,char *field,char *value);
int32_t in_jsonarray(cJSON *array,char *value);
char *bitcoind_RPC(char **retstrp,char *debugstr,char *url,char *userpass,char *command,char *params);
uint64_t calc_nxt64bits(const char *str);
int32_t expand_nxt64bits(char *str,uint64_t nxt64bits);
char *nxt64str(uint64_t nxt64bits);
Expand Down
6 changes: 4 additions & 2 deletions src/komodo_extern_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
* Please think twice before adding to this list. Can it be done with a better scope?
*/
#include "komodo_structs.h"
#include "komodo_jumblr.h"
#include <mutex>
#include <cstdint>
#include <memory>

extern std::shared_ptr<Jumblr> jumblr;

extern bool IS_KOMODO_NOTARY;
extern bool IS_KOMODO_DEALERNODE;
Expand All @@ -34,7 +38,6 @@ extern uint8_t ASSETCHAINS_PUBLIC;
extern uint8_t ASSETCHAINS_PRIVATE;
extern uint8_t ASSETCHAINS_TXPOW;
extern uint16_t KMD_PORT;
extern uint16_t BITCOIND_RPCPORT;
extern uint16_t DEST_PORT;
extern uint16_t ASSETCHAINS_P2PPORT;
extern uint16_t ASSETCHAINS_RPCPORT;
Expand All @@ -44,7 +47,6 @@ extern int32_t KOMODO_INSYNC;
extern int32_t KOMODO_LASTMINED;
extern int32_t prevKOMODO_LASTMINED;
extern int32_t KOMODO_CCACTIVATE;
extern int32_t JUMBLR_PAUSE;
extern int32_t NUM_PRICES;
extern int32_t KOMODO_MININGTHREADS;
extern int32_t STAKED_NOTARY_ID;
Expand Down
2 changes: 1 addition & 1 deletion src/komodo_gateway.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1443,7 +1443,7 @@ void komodo_passport_iteration()
{
refid = 33;
limit = 10000000;
jumblr_iteration();
jumblr->iteration();
}
else
{
Expand Down
Loading