Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b179bd3
Fixed stack smasching on asset ref decoding
mike31 Jun 14, 2018
60780f3
Logging RPC request IDs
mike31 Jun 18, 2018
0257840
Fixed autosubscribe for offchain items
mike31 Jul 9, 2018
47cebfb
Fixed txcount in getwalletinfo
mike31 Jul 16, 2018
a4822f2
Fixed Mac compilation error
mike31 Jul 17, 2018
caa4d73
Fixed Mac compilation issue
mike31 Jul 17, 2018
473edb8
Fixed unicode representation of non-printable characters
mike31 Jul 18, 2018
d93d29b
Boolean rescan for importwallet
mike31 Jul 19, 2018
e9d4a5e
Fixed fdatasync for Mac compilation
mike31 Jul 19, 2018
2a1fc7a
Boolean verbose parameter for getrawtransaction
mike31 Jul 19, 2018
bef04be
Flushing offchain queue on subscribe/unsubscribe
mike31 Jul 26, 2018
7c9fbd0
Random seed, fixing Mac sempahore issue
mike31 Jul 31, 2018
4ec9a04
boost downgrading instructions for MacOS compilation
mike31 Jul 31, 2018
0168cea
Fixed help message for verbose parameter in getrawtransaction
mike31 Jul 31, 2018
a08285b
Avoiding followon scanning when unnecessary
mike31 Aug 2, 2018
61cb440
Fixed watch only flag in getbalance
mike31 Aug 2, 2018
4635a60
liststreamqueryitems preparations
mike31 Aug 2, 2018
32c6bc0
liststreamqueryitems
mike31 Aug 5, 2018
36c76df
liststreamqueryitems help
mike31 Aug 5, 2018
7096905
Multiple txs in liststreamtxitems
mike31 Aug 5, 2018
28f7960
Version 2.0 alpha 4
mike31 Aug 5, 2018
5579db0
maxqueryscanitems runtime parameter
mike31 Aug 6, 2018
4c1fe28
Fixed missing creator list in liststreams
mike31 Aug 6, 2018
d9dbe66
maxqueryscanitems in setruntimeparam
mike31 Aug 6, 2018
ff46bdb
Fixed possible crash when inserting new chunk
mike31 Aug 8, 2018
de34537
Fixed memory leak on our tx count
mike31 Aug 8, 2018
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
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ Install dependencies
Install brew (follow instructions on brew.sh)
brew install autoconf automake berkeley-db4 libtool boost openssl pkg-config rename

on MacOS High Sierra

brew uninstall boost
brew install boost@1.57
brew link boost@1.57 --force

Prepare for static linking
--------------------------
Apple does not support statically linked binaries as [documented here](https://developer.apple.com/library/content/qa/qa1118/_index.html), however, it is convenient for end-users to launch a binary without having to first install brew, a third-party system designed for developers.
Expand All @@ -111,6 +117,8 @@ The default brew cookbook for berkeley-db and boost builds static libraries, but
In 'def configure_args' change 'shared' to 'no-shared'
brew install openssl --force



Compile MultiChain for Mac (64-bit)
--------------------------

Expand Down
1 change: 1 addition & 0 deletions src/chainparams/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ int64_t MAX_MONEY = 21000000 * COIN;
unsigned int MAX_SCRIPT_ELEMENT_SIZE=520; // script.h
int MIN_BLOCKS_BETWEEN_UPGRADES = 100;
int MAX_OP_RETURN_SHOWN=16384;
int MAX_STREAM_QUERY_ITEMS=5000;
int MAX_FORMATTED_DATA_DEPTH=100;
unsigned int MAX_OP_RETURN_OP_DROP_COUNT=100000000;
uint32_t JSON_NO_DOUBLE_FORMATTING=0;
Expand Down
8 changes: 8 additions & 0 deletions src/chainparams/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ typedef struct mc_TmpBuffers
mc_Buffer *m_RpcABNoMapBuffer1;
mc_Buffer *m_RpcABNoMapBuffer2;
mc_Buffer *m_RpcEntityRows;
mc_Buffer *m_RpcEntityRowsToMerge;
mc_Buffer *m_RpcEntityRowsFull;
mc_SHA256 *m_RpcHasher1;
mc_Script *m_RpcChunkScript1;
mc_Script *m_RelayTmpBuffer;
Expand All @@ -197,6 +199,10 @@ typedef struct mc_TmpBuffers
mc_InitABufferDefault(m_RpcABNoMapBuffer2);
m_RpcEntityRows=new mc_Buffer;
m_RpcEntityRows->Initialize(MC_TDB_ENTITY_KEY_SIZE,MC_TDB_ROW_SIZE,MC_BUF_MODE_DEFAULT);
m_RpcEntityRowsToMerge=new mc_Buffer;
m_RpcEntityRowsToMerge->Initialize(MC_TDB_ENTITY_KEY_SIZE,MC_TDB_ROW_SIZE,MC_BUF_MODE_DEFAULT);
m_RpcEntityRowsFull=new mc_Buffer;
m_RpcEntityRowsFull->Initialize(MC_TDB_ENTITY_KEY_SIZE,MC_TDB_ROW_SIZE,MC_BUF_MODE_DEFAULT);
m_RpcHasher1=new mc_SHA256();
m_RpcChunkScript1=new mc_Script();
m_RelayTmpBuffer=new mc_Script();
Expand All @@ -214,6 +220,8 @@ typedef struct mc_TmpBuffers
delete m_RpcABNoMapBuffer1;
delete m_RpcABNoMapBuffer2;
delete m_RpcEntityRows;
delete m_RpcEntityRowsToMerge;
delete m_RpcEntityRowsFull;
delete m_RpcHasher1;
delete m_RpcChunkScript1;
delete m_RelayTmpBuffer;
Expand Down
5 changes: 3 additions & 2 deletions src/core/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,10 +502,11 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += " -flushsourcechunks=<n> " + _("Flush offchain items created by this node to disk immediately when created, default 1") + "\n";

strUsage += "\n" + _("MultiChain API response parameters") + "\n";
strUsage += " -hideknownopdrops=<n> " + strprintf(_("Remove recognized MultiChain OP_DROP metadata from the responses to JSON_RPC calls (default: %u)"), 0) + "\n";
strUsage += " -hideknownopdrops=<n> " + strprintf(_("Remove recognized MultiChain OP_DROP metadata from the responses to JSON-RPC calls (default: %u)"), 0) + "\n";
strUsage += " -maxshowndata=<n> " + strprintf(_("The maximum number of bytes to show in the data field of API responses. (default: %u)"), MAX_OP_RETURN_SHOWN) + "\n";
strUsage += " " + _("Pieces of data larger than this will be returned as an object with txid, vout and size fields, for use with the gettxoutdata command.") + "\n";
strUsage += " -v1apicompatible=<n> " + strprintf(_("JSON_RPC calls responses compatible with MultiChain 1.0 (default: %u)"), 0) + "\n";
strUsage += " -maxqueryscanitems=<n> " + strprintf(_("The maximum number of txs to be decoded during JSON-RPC querying commands. (default: %u)"), MAX_STREAM_QUERY_ITEMS) + "\n";
strUsage += " -v1apicompatible=<n> " + strprintf(_("JSON-RPC calls responses compatible with MultiChain 1.0 (default: %u)"), 0) + "\n";
// strUsage += " -apidecimaldigits=<n> " + _("maximal number of decimal digits in API output (default: auto)") + "\n";

strUsage += "\n" + _("Wallet optimization options:") + "\n";
Expand Down
1 change: 1 addition & 0 deletions src/core/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ static const unsigned int DEFAULT_MAX_ORPHAN_TRANSACTIONS = 50000;
static const unsigned int DEFAULT_MAX_SUCCESSORS_FROM_ONE_NODE = 10;
/* MCHN END */
extern int MAX_OP_RETURN_SHOWN;
extern int MAX_STREAM_QUERY_ITEMS;
extern int MAX_FORMATTED_DATA_DEPTH;
extern int MIN_BLOCKS_BETWEEN_UPGRADES;
extern unsigned int OFFCHAIN_MSG_PADDING;
Expand Down
23 changes: 15 additions & 8 deletions src/json/json_spirit_writer_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace json_spirit

inline unsigned int utf8_len_and_mask(unsigned char c,unsigned int *mask)
{
if(c<0x20){*mask=0x00;return 0;}
if(c<0x80){*mask=0x7F;return 1;}
if(c<0xC0){*mask=0x00;return 0;}
if(c<0xE0){*mask=0x1F;return 2;}
Expand Down Expand Up @@ -146,18 +147,24 @@ namespace json_spirit
}
else
{
if( end - i >= charlen)
if(charlen)
{
shift=6*(charlen-1);
codepoint |= ( unsigned_c & mask) << shift;
for(j=1;j<charlen;j++)
if( end - i >= charlen)
{
shift-=6;
codepoint |= ( *( ++i ) & 0x3F) << shift;
shift=6*(charlen-1);
codepoint |= ( unsigned_c & mask) << shift;
for(j=1;j<charlen;j++)
{
shift-=6;
codepoint |= ( *( ++i ) & 0x3F) << shift;
}
result += codepoint_to_string< String_type >( codepoint );
}
result += codepoint_to_string< String_type >( codepoint );
}
// result += non_printable_to_string< String_type >( unsigned_c );
else
{
result += non_printable_to_string< String_type >( unsigned_c );
}
}
}

Expand Down
7 changes: 6 additions & 1 deletion src/multichain/multichain-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,12 @@ Object CallRPC(const string& strMethod, const Array& params)
mapRequestHeaders["Authorization"] = string("Basic ") + strUserPass64;
// Send request
// JSON_NO_DOUBLE_FORMATTING=1;
string strRequest = JSONRPCRequest(strMethod, params, 1);

int32_t id_nonce;
id_nonce=mc_RandomInRange(10000000,99999999);
Value req_id=strprintf("%08d-%u",id_nonce,mc_TimeNowAsUInt());

string strRequest = JSONRPCRequest(strMethod, params, req_id);
// JSON_NO_DOUBLE_FORMATTING=0;
JSON_DOUBLE_DECIMAL_DIGITS=GetArg("-apidecimaldigits",-1);
string strPost = HTTPPost(strRequest, mapRequestHeaders);
Expand Down
2 changes: 2 additions & 0 deletions src/multichain/multichaind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ bool AppInit(int argc, char* argv[])
mc_gState->m_Params->Parse(argc, argv, MC_ETP_DAEMON);
mc_CheckDataDirInConfFile();

mc_RandomSeed(mc_TimeNowAsUInt());

if(mc_gState->m_Params->NetworkName())
{
if(strlen(mc_gState->m_Params->NetworkName()) > MC_PRM_NETWORK_NAME_MAX_SIZE)
Expand Down
4 changes: 2 additions & 2 deletions src/protocol/relay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1546,7 +1546,7 @@ void mc_RelayManager::CheckTime()
}

Lock();
for(map<mc_RelayRecordKey,mc_RelayRecordValue>::iterator it = m_RelayRecords.begin(); it != m_RelayRecords.end();)
for(map<const mc_RelayRecordKey,mc_RelayRecordValue>::iterator it = m_RelayRecords.begin(); it != m_RelayRecords.end();)
{
if(it->second.m_Timestamp < m_LastTime)
{
Expand Down Expand Up @@ -1623,7 +1623,7 @@ int mc_RelayManager::GetRelayRecord(CNode *pfrom,mc_OffchainMessageID msg_id,uin
}
// printf("getrr: %d, ts: %u, nc: %u\n",pfrom_id,timestamp,nonce);
const mc_RelayRecordKey key=mc_RelayRecordKey(msg_id,pfrom_id);
map<mc_RelayRecordKey, mc_RelayRecordValue>::iterator it = m_RelayRecords.find(key);
map<const mc_RelayRecordKey, mc_RelayRecordValue>::iterator it = m_RelayRecords.find(key);
if (it == m_RelayRecords.end())
{
return MC_ERR_NOT_FOUND;
Expand Down
4 changes: 4 additions & 0 deletions src/rpc/rpcclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "listassettransactions", 4 },
{ "getassettransaction", 2 },
{ "getstreamitem", 2 },
{ "liststreamtxitems", 1 },
{ "liststreamtxitems", 2 },
{ "liststreamitems", 1 },
{ "liststreamitems", 2 },
Expand All @@ -196,6 +197,8 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "liststreampublishers", 3 },
{ "liststreampublishers", 4 },
{ "liststreampublishers", 5 },
{ "liststreamqueryitems", 1 },
{ "liststreamqueryitems", 2 },
{ "liststreamkeyitems", 2 },
{ "liststreamkeyitems", 3 },
{ "liststreamkeyitems", 4 },
Expand Down Expand Up @@ -339,6 +342,7 @@ static const CRPCConvertParamMayBeString vRPCConvertParamsMayBeString[] =
{ "unsubscribe", 0 },
{ "liststreamkeys", 1 },
{ "liststreampublishers", 1 },
{ "liststreamtxitems", 1 },
{ "listassets", 0 },
{ "liststreams", 0 },
{ "listupgrades", 0 },
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/rpcdebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ Value debug(const Array& params, bool fHelp)
chunk_found=pwalletTxsMain->m_ChunkDB->GetChunk(&chunk_def,0,-1,&chunk_bytes);
if(chunk_found)
{
chunk_obj.push_back(Pair("size",chunk_bytes));
chunk_obj.push_back(Pair("size",(int)chunk_bytes));
chunk_obj.push_back(Pair("data",HexStr(chunk_found,chunk_found+chunk_bytes)));
}
else
Expand Down
26 changes: 14 additions & 12 deletions src/rpc/rpcdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,25 +408,27 @@ Value importwallet(const Array& params, bool fHelp)
pwalletMain->nTimeFirstKey = nTimeBegin;

/* MCHN START */
if(mc_gState->m_WalletMode & MC_WMD_ADDRESS_TXS)
if(fRescan)
{
if(start_block)
if(mc_gState->m_WalletMode & MC_WMD_ADDRESS_TXS)
{
LogPrintf("Rescanning last %i blocks\n", chainActive.Height()-start_block+1);
if(start_block)
{
LogPrintf("Rescanning last %i blocks\n", chainActive.Height()-start_block+1);
}
else
{
LogPrintf("Rescanning all %i blocks\n", chainActive.Height());
}
pwalletMain->ScanForWalletTransactions(chainActive[start_block],false,true);
}
else
{
LogPrintf("Rescanning all %i blocks\n", chainActive.Height());
LogPrintf("Rescanning last %i blocks\n", chainActive.Height() - pindex->nHeight + 1);
pwalletMain->ScanForWalletTransactions(pindex,false,true);
}
pwalletMain->ScanForWalletTransactions(chainActive[start_block],false,true);
pwalletMain->MarkDirty();
}
else
{
LogPrintf("Rescanning last %i blocks\n", chainActive.Height() - pindex->nHeight + 1);
pwalletMain->ScanForWalletTransactions(pindex,false,true);
pwalletMain->MarkDirty();
}
pwalletMain->MarkDirty();

if (!fGood)
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding some keys to wallet");
Expand Down
38 changes: 33 additions & 5 deletions src/rpc/rpchelp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ void mc_InitRPCHelpMap05()

"\nArguments:\n"
"1. \"txid\" (string, required) The transaction id\n"
"2. verbose (numeric, optional, default=0) If 0, return a string, other return a json object\n"
"2. verbose (numeric or boolean, optional, default=0(false)) If 0, return a string, other return a json object\n"

"\nResult (if verbose is not set or set to 0):\n"
"\"data\" (string) The serialized, hex-encoded data for 'txid'\n"
Expand Down Expand Up @@ -2244,7 +2244,8 @@ void mc_InitRPCHelpMap10()
"\nImports keys from a wallet dump file (see dumpwallet).\n"
"\nArguments:\n"
"1. \"filename\" (string, required) The wallet file\n"
"2. rescan (integer, optional, default=0) Rescan from block, if negative - from the end.\n"
"2. rescan (boolean or integer, optional, default=true) Rescan the wallet for transactions. \n"
" If integer rescan from block, if negative - from the end.\n"
"\nExamples:\n"
"\nDump the wallet\n"
+ HelpExampleCli("dumpwallet", "\"test\"") +
Expand Down Expand Up @@ -3549,6 +3550,7 @@ void mc_InitRPCHelpMap15()
" miningturnover,\n"
" lockadminminerounds,\n"
" maxshowndata, \n"
" maxqueryscanitems, \n"
" bantx,\n"
" lockblock,\n"
" autosubscribe,\n"
Expand Down Expand Up @@ -3708,11 +3710,13 @@ void mc_InitRPCHelpMap16()
));

mapHelpStrings.insert(std::make_pair("liststreamtxitems",
"liststreamtxitems \"stream-identifier\" \"txid\" ( verbose )\n"
"liststreamtxitems \"stream-identifier\" txids ( verbose )\n"
"\nReturns stream items.\n"
"\nArguments:\n"
"1. \"stream-identifier\" (string, required) Stream identifier - one of the following: stream txid, stream reference, stream name.\n"
"2. \"txid\" (string, required) The transaction id\n"
"2. \"txids\" (string, required) Transaction IDs, comma delimited\n"
" or\n"
"2. txids (array, required) Array of transaction IDs\n"
"3. verbose (boolean, optional, default=false) If true, returns information about item transaction \n"
"\nResult:\n"
"\"stream-items\" (array) Array of stream items.\n"
Expand Down Expand Up @@ -4117,7 +4121,31 @@ void mc_InitRPCHelpMap18()
));


mapHelpStrings.insert(std::make_pair("AAAAAAA",
mapHelpStrings.insert(std::make_pair("liststreamqueryitems",
"liststreamqueryitems \"stream-identifier\" query ( verbose )\n"
"\nReturns stream items for specific query.\n"
"\nArguments:\n"
"1. \"stream-identifier\" (string, required) Stream identifier - one of the following: stream txid, stream reference, stream name.\n"
"2. query (object, required) Query\n"
" {\n"
" \"key\" : \"key\" (string, optional, default: \"\") Item key\n"
" or\n"
" \"keys\" : keys (array, optional) Item keys, array of strings\n"
" and/or\n"
" \"publisher\" : \"publisher\" (string, optional, default: \"\") Publisher\n"
" or\n"
" \"publishers\" : publishers (array, optional) Publishers, array of strings\n"
" }\n"
"3. verbose (boolean, optional, default=false) If true, returns information about item transaction \n"
"\nResult:\n"
"\"stream-items\" (array) List of stream items for specific query.\n"
"\nExamples:\n"
+ HelpExampleCli("liststreamqueryitems", "\"test-stream\" \"{\\\"keys\\\":[\\\"key01\\\",\"key02\"]}\"")
+ HelpExampleCli("liststreamqueryitems", "\"test-stream\" \"{\\\"keys\\\":[\\\"key01\\\",\"key02\"],\\\"publisher\\\":\\\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XZ\\\"}\" true ")
+ HelpExampleRpc("liststreamqueryitems", "\"test-stream\", \"{\\\"keys\\\":[\\\"key01\\\",\"key02\"],\\\"publisher\\\":\\\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XZ\\\"}\", false")
));

mapHelpStrings.insert(std::make_pair("AAAAAAA",
""
));

Expand Down
1 change: 1 addition & 0 deletions src/rpc/rpclist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ static const CRPCCommand vRPCCommands[] =
{ "wallet", "getstreamitem", &getstreamitem, false, false, true },
{ "wallet", "liststreamtxitems", &liststreamtxitems, false, false, true },
{ "wallet", "liststreamitems", &liststreamitems, false, false, true },
{ "wallet", "liststreamqueryitems", &liststreamqueryitems, false, false, true },
{ "wallet", "liststreamkeyitems", &liststreamkeyitems, false, false, true },
{ "wallet", "liststreampublisheritems",&liststreampublisheritems,false, false, true },
{ "wallet", "liststreamkeys", &liststreamkeys, false, false, true },
Expand Down
2 changes: 2 additions & 0 deletions src/rpc/rpcmisc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ Value getruntimeparams(const json_spirit::Array& params, bool fHelp)
obj.push_back(Pair("lockblock",GetArg("-lockblock","")));
obj.push_back(Pair("hideknownopdrops",GetBoolArg("-hideknownopdrops",false)));
obj.push_back(Pair("maxshowndata",GetArg("-maxshowndata",MAX_OP_RETURN_SHOWN)));
obj.push_back(Pair("maxqueryscanitems",GetArg("-maxqueryscanitems",MAX_STREAM_QUERY_ITEMS)));
obj.push_back(Pair("v1apicompatible",GetBoolArg("-v1apicompatible",false)));
obj.push_back(Pair("miningrequirespeers",Params().MiningRequiresPeers()));
obj.push_back(Pair("mineemptyrounds",Params().MineEmptyRounds()));
Expand Down Expand Up @@ -360,6 +361,7 @@ Value setruntimeparam(const json_spirit::Array& params, bool fHelp)
}
if( (param_name == "lockadminminerounds") ||
(param_name == "maxshowndata") ||
(param_name == "maxqueryscanitems") ||
(param_name == "dropmessagestest") )
{
if( (params[1].type() == int_type) || (params[1].type() == str_type) )
Expand Down
3 changes: 2 additions & 1 deletion src/rpc/rpcrawtransaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,8 @@ Value getrawtransaction(const Array& params, bool fHelp)

bool fVerbose = false;
if (params.size() > 1)
fVerbose = (params[1].get_int() != 0);
fVerbose=paramtobool(params[1],false);
// fVerbose = (params[1].get_int() != 0);

CTransaction tx;
uint256 hashBlock = 0;
Expand Down
Loading