Skip to content
Merged
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
54 changes: 54 additions & 0 deletions src/chainparams/params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2272,5 +2272,59 @@ int mc_Features::FixedJSDateFunctions()
return ret;
}

int mc_Features::DisabledJSDateParse()
{
int ret=0;
if(mc_gState->m_NetworkParams->IsProtocolMultichain() == 0)
{
return 0;
}
int protocol=mc_gState->m_NetworkParams->ProtocolVersion();

if(protocol)
{
if(protocol >= 20009)
{
ret=1;
}
else
{
if(Filters() == 0)
{
ret=1;
}
}
}

return ret;
}

int mc_Features::FixedLegacyPermissionRestrictionFlag()
{
int ret=0;
if(mc_gState->m_NetworkParams->IsProtocolMultichain() == 0)
{
return 0;
}
int protocol=mc_gState->m_NetworkParams->ProtocolVersion();

if(protocol)
{
if(protocol >= 20009)
{
ret=1;
}
else
{
if(Filters() == 0)
{
ret=1;
}
}
}

return ret;
}



2 changes: 2 additions & 0 deletions src/chainparams/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ typedef struct mc_Features
int ImplicitConnectPermission();
int LicenseTokens();
int FixedJSDateFunctions();
int DisabledJSDateParse();
int FixedLegacyPermissionRestrictionFlag();
} mc_Features;

typedef struct mc_BlockHeaderInfo
Expand Down
38 changes: 38 additions & 0 deletions src/community/community.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,21 @@ int mc_EnterpriseFeatures::STR_CreateSubscription(mc_TxEntity *entity,const std:
return MC_ERR_FOUND;
}

int mc_EnterpriseFeatures::STR_TrimSubscription(mc_TxEntity *entity,const std::string parameters)
{
return MC_ERR_NOERROR;
}

int mc_EnterpriseFeatures::STR_IsIndexSkipped(mc_TxImport *import,mc_TxEntity *parent_entity,mc_TxEntity *entity)
{
return 0;
}

int mc_EnterpriseFeatures::STR_NoRetrieve(mc_TxEntity *entity)
{
return 0;
}

int mc_EnterpriseFeatures::STR_IsOutOfSync(mc_TxEntity *entity)
{
return 0;
Expand All @@ -51,6 +61,28 @@ int mc_EnterpriseFeatures::STR_PutSubscriptions(mc_Buffer *subscriptions)
return MC_ERR_NOERROR;
}

Value mc_EnterpriseFeatures::STR_RPCRetrieveStreamItems(const Array& params)
{
return Value::null;
}

Value mc_EnterpriseFeatures::STR_RPCPurgeStreamItems(const Array& params)
{
return Value::null;
}

Value mc_EnterpriseFeatures::STR_RPCPurgePublishedItems(const Array& params)
{
return Value::null;
}


int mc_EnterpriseFeatures::STR_RemoveDataFromFile(int fHan, uint32_t from, uint32_t size, uint32_t mode)
{
return MC_ERR_NOERROR;
}


int mc_EnterpriseFeatures::WLT_CreateSubscription(mc_TxEntity *entity,uint32_t retrieve,uint32_t indexes,uint32_t *rescan_mode)
{
*rescan_mode=0;
Expand Down Expand Up @@ -107,6 +139,12 @@ std::string mc_EnterpriseFeatures::ENT_TextConstant(const char* name)
return "";
}

void mc_EnterpriseFeatures::ENT_InitRPCHelpMap()
{

}


void mc_EnterpriseFeatures::LIC_RPCVerifyFeature(uint64_t feature)
{
throw JSONRPCError(RPC_NOT_SUPPORTED, "This feature is available only in Enterprise edition of MultiChain, please call \"help enterprise\" for details");
Expand Down
7 changes: 7 additions & 0 deletions src/community/community.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,17 @@ typedef struct mc_EnterpriseFeatures
uint32_t mode); // Unused

int STR_CreateSubscription(mc_TxEntity *entity,const std::string parameters);
int STR_TrimSubscription(mc_TxEntity *entity,const std::string parameters);
int STR_IsIndexSkipped(mc_TxImport *import,mc_TxEntity *parent_entity,mc_TxEntity *entity);
int STR_NoRetrieve(mc_TxEntity *entity);
int STR_IsOutOfSync(mc_TxEntity *entity);
int STR_SetSyncFlag(mc_TxEntity *entity,bool confirm);
int STR_GetSubscriptions(mc_Buffer *subscriptions);
int STR_PutSubscriptions(mc_Buffer *subscriptions);
Value STR_RPCRetrieveStreamItems(const Array& params);
Value STR_RPCPurgeStreamItems(const Array& params);
Value STR_RPCPurgePublishedItems(const Array& params);
int STR_RemoveDataFromFile(int fHan, uint32_t from, uint32_t size, uint32_t mode);

int WLT_CreateSubscription(mc_TxEntity *entity,uint32_t retrieve,uint32_t indexes,uint32_t *rescan_mode);
int WLT_DeleteSubscription(mc_TxEntity *entity,uint32_t rescan_mode);
Expand All @@ -55,6 +61,7 @@ typedef struct mc_EnterpriseFeatures
int ENT_MinWalletDatVersion();
void ENT_RPCVerifyEdition();
std::string ENT_TextConstant(const char* name);
void ENT_InitRPCHelpMap();

void LIC_RPCVerifyFeature(uint64_t feature);
bool LIC_VerifyFeature(uint64_t feature,std::string& reason);
Expand Down
2 changes: 1 addition & 1 deletion src/core/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += " " + _("(more details and % substitutions online)") + "\n";
/* MCHN START */
strUsage += " -walletdbversion=2|3 " + _("Specify wallet version, 2 - Berkeley DB, 3 (default) - proprietary") + "\n";
strUsage += " -autosubscribe=streams|assets|\"streams,assets\"|\"assets,streams\" " + _("Automatically subscribe to new streams and/or assets") + "\n";
strUsage += " -autosubscribe=streams|assets|\"streams,assets\"|\"assets,streams\"|\"\" " + _("Automatically subscribe to new streams and/or assets") + "\n";
/* MCHN END */
strUsage += " -zapwallettxes=<mode> " + _("Delete all wallet transactions and only recover those parts of the blockchain through -rescan on startup") + "\n";
strUsage += " " + _("(1 = keep tx meta data e.g. account owner and payment request information, 2 = drop tx meta data)") + "\n";
Expand Down
24 changes: 12 additions & 12 deletions src/entities/asset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -661,26 +661,26 @@ void mc_EntityDetails::Set(mc_EntityLedgerRow* row)
value_offset=mc_FindSpecialParamInDetailsScript(m_LedgerRow.m_Script,m_LedgerRow.m_ScriptSize,MC_ENT_SPRM_PERMISSIONS,&value_size);
if(value_offset <= m_LedgerRow.m_ScriptSize)
{
/*
if(m_Permissions & MC_PTP_WRITE)
if( (value_offset != m_LedgerRow.m_ScriptSize) || (mc_gState->m_Features->FixedLegacyPermissionRestrictionFlag() == 0))
{
m_Permissions -= MC_PTP_WRITE;
}
*/
m_Permissions |= MC_PTP_SPECIFIED;
if((value_size>0) && (value_size<=4))
{
m_ScriptPermissions=(uint32_t)mc_GetLE(m_LedgerRow.m_Script+value_offset,value_size);
m_Permissions |= m_ScriptPermissions;
m_Permissions |= MC_PTP_SPECIFIED;
if((value_size>0) && (value_size<=4))
{
m_ScriptPermissions=(uint32_t)mc_GetLE(m_LedgerRow.m_Script+value_offset,value_size);
m_Permissions |= m_ScriptPermissions;
}
}
}

value_offset=mc_FindSpecialParamInDetailsScript(m_LedgerRow.m_Script,m_LedgerRow.m_ScriptSize,MC_ENT_SPRM_RESTRICTIONS,&value_size);
if(value_offset <= m_LedgerRow.m_ScriptSize)
{
if((value_size>0) && (value_size<=4))
if( (value_offset != m_LedgerRow.m_ScriptSize) || (mc_gState->m_Features->FixedLegacyPermissionRestrictionFlag() == 0))
{
m_Restrictions |= (uint32_t)mc_GetLE(m_LedgerRow.m_Script+value_offset,value_size);
if((value_size>0) && (value_size<=4))
{
m_Restrictions |= (uint32_t)mc_GetLE(m_LedgerRow.m_Script+value_offset,value_size);
}
}
}

Expand Down
16 changes: 15 additions & 1 deletion src/filters/filter_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,22 @@ int mc_FilterEngine::CreateFilter(std::string script, std::string main_name, std
const char **callbackNames = vec2cstrs(callback_names, n_callbackNames);
auto v8filter = static_cast<V8Filter_t *>(filter->m_Impl);
char result[RESULT_SIZE];
uint32_t jsInjectionParams=0;
if(mc_gState->m_Features->FilterLimitedMathSet())
{
jsInjectionParams |= MC_V8W_JS_INJECTION_LIMITED_MATH_SET;
}
if(mc_gState->m_Features->FixedJSDateFunctions())
{
jsInjectionParams |= MC_V8W_JS_INJECTION_FIXED_DATE_FUNCTIONS;
}
if(mc_gState->m_Features->DisabledJSDateParse())
{
jsInjectionParams |= MC_V8W_JS_INJECTION_DISABLED_DATE_PARSE;
}

retval = V8Engine_CreateFilter(v8engine, script.c_str(), main_name.c_str(), callbackNames, n_callbackNames,
v8filter, mc_gState->m_Features->FilterLimitedMathSet(), mc_gState->m_Features->FixedJSDateFunctions(), result);
v8filter, jsInjectionParams, result);
delete [] callbackNames;
if (fDebug)
LogPrint("v8filter", "v8filter: retval=%d result=%s\n", retval, result);
Expand Down
23 changes: 13 additions & 10 deletions src/protocol/relay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,19 +163,22 @@ int MultichainProcessChunkResponse(const CRelayResponsePair *response_pair,map <
strError="Chunk data hash mismatch";
goto exitlbl;
}
chunk_err=pwalletTxsMain->m_ChunkDB->AddChunk(chunk->m_Hash,&(chunk->m_Entity),(unsigned char*)collect_row->m_TxID,collect_row->m_Vout,ptrOut,NULL,sizeOut,0,0);
if(chunk_err)
if( (collect_row->m_State.m_Status & MC_CCF_DELETED ) == 0 )
{
if(chunk_err != MC_ERR_FOUND)
chunk_err=pwalletTxsMain->m_ChunkDB->AddChunk(chunk->m_Hash,&(chunk->m_Entity),(unsigned char*)collect_row->m_TxID,collect_row->m_Vout,ptrOut,NULL,sizeOut,0,0);
if(chunk_err)
{
strError=strprintf("Internal chunk DB error: %d",chunk_err);
goto exitlbl;
if(chunk_err != MC_ERR_FOUND)
{
strError=strprintf("Internal chunk DB error: %d",chunk_err);
goto exitlbl;
}
}
else
{
for(int k=0;k<2;k++)collector->m_StatTotal[k].m_Delivered+=k ? collect_row->m_ChunkDef.m_Size : 1;
LogPrint("chunks","Retrieved chunk %s\n",(*(uint256*)(chunk->m_Hash)).ToString().c_str());
}
}
else
{
for(int k=0;k<2;k++)collector->m_StatTotal[k].m_Delivered+=k ? collect_row->m_ChunkDef.m_Size : 1;
LogPrint("chunks","Retrieved chunk %s\n",(*(uint256*)(chunk->m_Hash)).ToString().c_str());
}
collect_row->m_State.m_Status |= MC_CCF_DELETED;
}
Expand Down
12 changes: 12 additions & 0 deletions src/rpc/rpcclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,12 @@ static const std::string vAPINames[] =
"publishfrom",
"publishmulti",
"publishmultifrom",
"purgestreamitems",
"purgepublisheditems",
"reconsiderblock",
"resendwallettransactions",
"resume",
"retrievestreamitems",
"revoke",
"revokefrom",
"runstreamfilter",
Expand Down Expand Up @@ -210,6 +213,7 @@ static const std::string vAPINames[] =
"subscribe",
"teststreamfilter",
"testtxfilter",
"trimsubscribe",
"unsubscribe",
"validateaddress",
"verifychain",
Expand Down Expand Up @@ -381,6 +385,10 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "create", 3 },
{ "subscribe", 0 },
{ "subscribe", 1 },
{ "trimsubscribe", 0 },
{ "retrievestreamitems", 1 },
{ "purgestreamitems", 1 },
{ "purgepublisheditems", 0 },
{ "unsubscribe", 0 },
{ "unsubscribe", 1 },
{ "listassettransactions", 1 },
Expand Down Expand Up @@ -578,6 +586,10 @@ static const CRPCConvertParamMayBeString vRPCConvertParamsMayBeString[] =
{ "importaddress", 0 },
{ "importprivkey", 0 },
{ "subscribe", 0 },
{ "trimsubscribe", 0 },
{ "retrievestreamitems", 1 },
{ "purgestreamitems", 1 },
{ "purgepublisheditems", 0 },
{ "unsubscribe", 0 },
{ "liststreamkeys", 1 },
{ "liststreampublishers", 1 },
Expand Down
2 changes: 2 additions & 0 deletions src/rpc/rpchelp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4757,6 +4757,8 @@ void mc_InitRPCHelpMap()
mc_InitRPCHelpMap19();
mc_InitRPCHelpMap20();

pEF->ENT_InitRPCHelpMap();

mc_InitRPCLogParamCountMap();
mc_InitRPCAllowedWhenWaitingForUpgradeSet();
mc_InitRPCAllowedWhenOffline();
Expand Down
4 changes: 4 additions & 0 deletions src/rpc/rpclist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,10 @@ static const CRPCCommand vRPCCommands[] =
{ "wallet", "publishmultifrom", &publishmultifrom, false, false, true },
{ "wallet", "subscribe", &subscribe, false, false, true },
{ "wallet", "unsubscribe", &unsubscribe, false, false, true },
{ "wallet", "trimsubscribe", &trimsubscribe, false, false, true },
{ "wallet", "retrievestreamitems", &retrievestreamitems, false, false, true },
{ "wallet", "purgestreamitems", &purgestreamitems, false, false, true },
{ "wallet", "purgepublisheditems", &purgepublisheditems, false, false, true },
{ "wallet", "listassettransactions", &listassettransactions, false, false, true },
{ "wallet", "getassettransaction", &getassettransaction, false, false, true },
{ "wallet", "getstreamitem", &getstreamitem, false, false, true },
Expand Down
6 changes: 5 additions & 1 deletion src/rpc/rpcmisc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,11 @@ Value setruntimeparam(const json_spirit::Array& params, bool fHelp)
mode |= MC_WMD_AUTOSUBSCRIBE_STREAMS;
mode |= MC_WMD_AUTOSUBSCRIBE_ASSETS;
found=true;
}
}
if( autosubscribe=="" )
{
found=true;
}
if(!found)
{
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter value");
Expand Down
5 changes: 4 additions & 1 deletion src/rpc/rpcserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,10 @@ string CRPCTable::help(string strCommand) const
}
catch (std::exception& e)
{
strHelp = string(e.what());
if(strCommand != "")
{
strHelp = string(e.what());
}
}
}
else
Expand Down
4 changes: 4 additions & 0 deletions src/rpc/rpcserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,10 @@ extern json_spirit::Value publishmulti(const json_spirit::Array& params, bool fH
extern json_spirit::Value publishmultifrom(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value subscribe(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value unsubscribe(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value trimsubscribe(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value retrievestreamitems(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value purgestreamitems(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value purgepublisheditems(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value listassettransactions(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value getassettransaction(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value getstreamitem(const json_spirit::Array& params, bool fHelp);
Expand Down
Loading