From add12fb9159a6c500da790808451916b000e81bc Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Jan 2016 23:14:33 -0300 Subject: [PATCH] test --- crypto777/OS_portable.h | 4 +- crypto777/iguana_serdes.c | 10 +-- iguana/iguana_msg.c | 2 +- iguana/iguana_rpc.c | 133 +++++++++++++++++++------------------- iguana/main.c | 7 ++ 5 files changed, 80 insertions(+), 76 deletions(-) diff --git a/crypto777/OS_portable.h b/crypto777/OS_portable.h index 447465e4c..83e503e59 100755 --- a/crypto777/OS_portable.h +++ b/crypto777/OS_portable.h @@ -149,7 +149,6 @@ void *OS_portable_mapfile(char *fname,long *filesizep,int32_t enablewrite); int32_t OS_portable_syncmap(struct OS_mappedptr *mp,long len); void *OS_portable_tmpalloc(char *dirname,char *name,struct OS_memspace *mem,long origsize); - int32_t is_DST(int32_t datenum); int32_t extract_datenum(int32_t *yearp,int32_t *monthp,int32_t *dayp,int32_t datenum); int32_t expand_datenum(char *date,int32_t datenum); @@ -206,7 +205,6 @@ void *iguana_meminit(struct OS_memspace *mem,char *name,void *ptr,int64_t totals void *iguana_memalloc(struct OS_memspace *mem,long size,int32_t clearflag); int64_t iguana_memfree(struct OS_memspace *mem,void *ptr,int32_t size); - // generic functions int32_t unhex(char c); void touppercase(char *str); @@ -313,5 +311,7 @@ bits256 bits256_from_compact(uint32_t c); int32_t btc_priv2pub(uint8_t pubkey[33],uint8_t privkey[32]); +extern char *Iguana_validcommands[]; + #endif diff --git a/crypto777/iguana_serdes.c b/crypto777/iguana_serdes.c index c3de4cf1b..6e4628e0c 100755 --- a/crypto777/iguana_serdes.c +++ b/crypto777/iguana_serdes.c @@ -54,13 +54,9 @@ int32_t iguana_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endian int32_t iguana_validatehdr(struct iguana_msghdr *H) { - int32_t i,len; char *validcommands[] = - { - "SuperNET", "version", "verack", "getaddr", "addr", "inv", "getdata", "notfound", "getblocks", "getheaders", - "headers", "tx", "block", "mempool", "ping", "pong", "reject", "filterload", "filteradd", "filterclear", "merkleblock", "alert" - }; - for (i=0; icommand,validcommands[i]) == 0 ) + int32_t i,len; + for (i=0; Iguana_validcommands[i]!=0&&Iguana_validcommands[i][0]!=0; i++) + if ( strcmp(H->command,Iguana_validcommands[i]) == 0 ) { iguana_rwnum(0,H->serdatalen,sizeof(H->serdatalen),(uint32_t *)&len); if ( len > IGUANA_MAXPACKETSIZE ) diff --git a/iguana/iguana_msg.c b/iguana/iguana_msg.c index aed4d80a3..bc77e06d7 100755 --- a/iguana/iguana_msg.c +++ b/iguana/iguana_msg.c @@ -429,7 +429,7 @@ int32_t iguana_msgparser(struct iguana_info *coin,struct iguana_peer *addr,struc strcpy(addr->lastcommand,H->command); } retval = 0; - //printf("iguana_msgparser %s parse.(%s)\n",addr->ipaddr,H->command); + printf("iguana_msgparser %s parse.(%s)\n",addr->ipaddr,H->command); if ( strncmp(H->command,"SuperNET",strlen("SuperNET")) == 0 ) { addr->supernet = 1; diff --git a/iguana/iguana_rpc.c b/iguana/iguana_rpc.c index f9edfb8a1..d9e0d4c03 100755 --- a/iguana/iguana_rpc.c +++ b/iguana/iguana_rpc.c @@ -471,72 +471,73 @@ static char *getrawchangeaddress(RPCARGS) #define false 0 struct RPC_info { char *name; char *(*rpcfunc)(RPCARGS); int32_t flag0,remoteflag; } RPCcalls[] = { - { "help", &help, true, false }, - { "stop", &stop, true, true }, - { "getbestblockhash", &getbestblockhash, true, true }, - { "getblockcount", &getblockcount, true, true }, - { "getconnectioncount", &getconnectioncount, true, true }, - { "getpeerinfo", &getpeerinfo, true, true }, - { "getinfo", &getinfo, true, true }, - { "getnewaddress", &getnewaddress, true, false }, - { "getnewpubkey", &makekeypair, true, false }, - { "getaccountaddress", &getaccountaddress, true, false }, - { "setaccount", &setaccount, true, false }, - { "getaccount", &getaccount, false, false }, - { "getaddressesbyaccount", &getaddressesbyaccount, true, false }, - { "sendtoaddress", &sendtoaddress, false, false }, - { "getreceivedbyaddress", &getreceivedbyaddress, false, false }, - { "getreceivedbyaccount", &getreceivedbyaccount, false, false }, - { "listreceivedbyaddress", &listreceivedbyaddress, false, false }, - { "listreceivedbyaccount", &listreceivedbyaccount, false, false }, - { "backupwallet", &backupwallet, true, false }, - { "walletpassphrase", &walletpassphrase, true, false }, - { "walletpassphrasechange", &walletpassphrasechange, false, false }, - { "walletlock", &walletlock, true, false }, - { "encryptwallet", &encryptwallet, false, false }, - { "validateaddress", &validateaddress, true, true }, - { "validatepubkey", &validatepubkey, true, true }, - { "getbalance", &getbalance, false, false }, - { "move", &movecmd, false, false }, - { "sendfrom", &sendfrom, false, false }, - { "sendmany", &sendmany, false, false }, - { "addmultisigaddress", &addmultisigaddress, false, false }, - { "getblock", &getblock, false, true }, - { "getblockhash", &getblockhash, false, true }, - { "gettransaction", &gettransaction, false, true }, - { "listtransactions", &listtransactions, false, false }, - { "listaddressgroupings", &listaddressgroupings, false, false }, - { "signmessage", &signmessage, false, false }, - { "verifymessage", &verifymessage, false, false }, - { "listaccounts", &listaccounts, false, false }, - { "settxfee", &settxfee, false, false }, - { "listsinceblock", &listsinceblock, false, false }, - { "dumpprivkey", &dumpprivkey, false, false }, - { "SuperNET", &SuperNET, false, true }, - { "dumpwallet", &dumpwallet, true, false }, - { "importwallet", &importwallet, false, false }, - { "importprivkey", &importprivkey, false, false }, - { "listunspent", &listunspent, false, false }, - { "getrawtransaction", &getrawtransaction, false, false }, - { "createrawtransaction", &createrawtransaction, false, false }, - { "decoderawtransaction", &decoderawtransaction, false, true }, - { "decodescript", &decodescript, false, true }, - { "signrawtransaction", &signrawtransaction, false, false }, - { "sendrawtransaction", &sendrawtransaction, false, true }, - { "checkwallet", &checkwallet, false, false }, - { "repairwallet", &repairwallet, false, false }, - { "makekeypair", &makekeypair, false, false }, - { "sendalert", &sendalert, false, false }, - // - { "createmultisig", &createmultisig, false, false }, - { "addnode", &addnode, false, false }, - { "getrawmempool", &getrawmempool, false, true }, - { "getrawchangeaddress", &getrawchangeaddress, false, false }, - { "listlockunspent", &listlockunspent, false, false }, - { "lockunspent", &lockunspent, false, false }, - { "gettxout", &gettxout, false, true }, - { "gettxoutsetinfo", &gettxoutsetinfo, false, true }, - { "vanitygen", &vanitygen, false, false } + { "SuperNET", &SuperNET, false, true }, + //{ "SuperNETb", &SuperNET, false, true }, + { "help", &help, true, false }, + { "stop", &stop, true, true }, + { "getbestblockhash", &getbestblockhash, true, true }, + { "getblockcount", &getblockcount, true, true }, + { "getconnectioncount", &getconnectioncount, true, true }, + { "getpeerinfo", &getpeerinfo, true, true }, + { "getinfo", &getinfo, true, true }, + { "getnewaddress", &getnewaddress, true, false }, + { "getnewpubkey", &makekeypair, true, false }, + { "getaccountaddress", &getaccountaddress, true, false }, + { "setaccount", &setaccount, true, false }, + { "getaccount", &getaccount, false, false }, + { "getaddressesbyaccount", &getaddressesbyaccount, true, false }, + { "sendtoaddress", &sendtoaddress, false, false }, + { "getreceivedbyaddress", &getreceivedbyaddress, false, false }, + { "getreceivedbyaccount", &getreceivedbyaccount, false, false }, + { "listreceivedbyaddress", &listreceivedbyaddress, false, false }, + { "listreceivedbyaccount", &listreceivedbyaccount, false, false }, + { "backupwallet", &backupwallet, true, false }, + { "walletpassphrase", &walletpassphrase, true, false }, + { "walletpassphrasechange", &walletpassphrasechange, false, false }, + { "walletlock", &walletlock, true, false }, + { "encryptwallet", &encryptwallet, false, false }, + { "validateaddress", &validateaddress, true, true }, + { "validatepubkey", &validatepubkey, true, true }, + { "getbalance", &getbalance, false, false }, + { "move", &movecmd, false, false }, + { "sendfrom", &sendfrom, false, false }, + { "sendmany", &sendmany, false, false }, + { "addmultisigaddress", &addmultisigaddress, false, false }, + { "getblock", &getblock, false, true }, + { "getblockhash", &getblockhash, false, true }, + { "gettransaction", &gettransaction, false, true }, + { "listtransactions", &listtransactions, false, false }, + { "listaddressgroupings", &listaddressgroupings, false, false }, + { "signmessage", &signmessage, false, false }, + { "verifymessage", &verifymessage, false, false }, + { "listaccounts", &listaccounts, false, false }, + { "settxfee", &settxfee, false, false }, + { "listsinceblock", &listsinceblock, false, false }, + { "dumpprivkey", &dumpprivkey, false, false }, + { "dumpwallet", &dumpwallet, true, false }, + { "importwallet", &importwallet, false, false }, + { "importprivkey", &importprivkey, false, false }, + { "listunspent", &listunspent, false, false }, + { "getrawtransaction", &getrawtransaction, false, false }, + { "createrawtransaction", &createrawtransaction, false, false }, + { "decoderawtransaction", &decoderawtransaction, false, true }, + { "decodescript", &decodescript, false, true }, + { "signrawtransaction", &signrawtransaction, false, false }, + { "sendrawtransaction", &sendrawtransaction, false, true }, + { "checkwallet", &checkwallet, false, false }, + { "repairwallet", &repairwallet, false, false }, + { "makekeypair", &makekeypair, false, false }, + { "sendalert", &sendalert, false, false }, + // + { "createmultisig", &createmultisig, false, false }, + { "addnode", &addnode, false, false }, + { "getrawmempool", &getrawmempool, false, true }, + { "getrawchangeaddress", &getrawchangeaddress, false, false }, + { "listlockunspent", &listlockunspent, false, false }, + { "lockunspent", &lockunspent, false, false }, + { "gettxout", &gettxout, false, true }, + { "gettxoutsetinfo", &gettxoutsetinfo, false, true }, + { "vanitygen", &vanitygen, false, false } #ifdef PEGGY //{ "peggytx", &peggytx, true, false }, //{ "peggypayments", &peggypayments, true, false }, diff --git a/iguana/main.c b/iguana/main.c index 40732def1..41fb129cc 100644 --- a/iguana/main.c +++ b/iguana/main.c @@ -25,6 +25,13 @@ #include "SuperNET.h" // ALL globals must be here! +char *Iguana_validcommands[] = +{ + "SuperNET", "SuperNETb", + "version", "verack", "getaddr", "addr", "inv", "getdata", "notfound", "getblocks", "getheaders", "headers", "tx", "block", "mempool", "ping", "pong", + "reject", "filterload", "filteradd", "filterclear", "merkleblock", "alert", "" +}; + struct iguana_info *Coins[IGUANA_MAXCOINS]; int32_t USE_JAY,FIRST_EXTERNAL,IGUANA_disableNXT,Debuglevel; uint32_t prices777_NXTBLOCK,MAX_DEPTH = 100;