Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-schmidtke committed May 22, 2019
2 parents a8025cb + b81bfd2 commit df703b3
Show file tree
Hide file tree
Showing 60 changed files with 3,238 additions and 314 deletions.
2 changes: 2 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ libbitcoin_wallet_a_CPPFLAGS = $(BITCOIN_INCLUDES)
libbitcoin_wallet_a_SOURCES = \
wallet/dbflat.cpp \
wallet/crypter.cpp \
community/license.cpp \
rpc/rpcdump.cpp \
rpc/rpcwallet.cpp \
rpc/rpcwalletutils.cpp \
Expand All @@ -258,6 +259,7 @@ libbitcoin_wallet_a_SOURCES = \
rpc/rpcstreams.cpp \
rpc/rpcupgrades.cpp \
rpc/rpcfilters.cpp \
rpc/rpclicense.cpp \
wallet/wallet.cpp \
wallet/walletcoins.cpp \
wallet/wallettxs.cpp \
Expand Down
2 changes: 2 additions & 0 deletions src/chainparams/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ int JSON_DOUBLE_DECIMAL_DIGITS=-1;
int MAX_CHUNK_SIZE = 1048576;
int MAX_CHUNK_COUNT = 1024;
int MAX_NBITS_FOR_SIGNED_NONCE = 12;
uint32_t MIN_CHUNK_SALT_SIZE = 8;
uint32_t MAX_CHUNK_SALT_SIZE = 32;

int MCP_MAX_STD_OP_RETURN_COUNT=0;
int64_t MCP_INITIAL_BLOCK_REWARD=0;
Expand Down
107 changes: 107 additions & 0 deletions src/chainparams/params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2326,5 +2326,112 @@ int mc_Features::FixedLegacyPermissionRestrictionFlag()
return ret;
}

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

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

return ret;
}

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

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

return ret;
}

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

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

return ret;
}

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

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

return ret;
}


2 changes: 2 additions & 0 deletions src/chainparams/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ extern int MCP_TARGET_BLOCK_TIME;
extern int MAX_CHUNK_SIZE;
extern int MAX_CHUNK_COUNT;
extern int MAX_NBITS_FOR_SIGNED_NONCE;
extern uint32_t MIN_CHUNK_SALT_SIZE;
extern uint32_t MAX_CHUNK_SALT_SIZE;
extern int MCP_ANYONE_CAN_ADMIN;
extern int MCP_ANYONE_CAN_MINE;
extern int MCP_ANYONE_CAN_CONNECT;
Expand Down
9 changes: 9 additions & 0 deletions src/chainparams/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ typedef struct mc_Features
int FixedJSDateFunctions();
int DisabledJSDateParse();
int FixedLegacyPermissionRestrictionFlag();
int ReadPermissions();
int SaltedChunks();
int FixedIn20010();
int License20010();
} mc_Features;

typedef struct mc_BlockHeaderInfo
Expand Down Expand Up @@ -194,6 +198,7 @@ typedef struct mc_TmpBuffers
mc_SHA256 *m_RpcHasher1;
mc_Script *m_RpcChunkScript1;
mc_Script *m_RelayTmpBuffer;
mc_Script *m_LicenseTmpBuffer;

void Init()
{
Expand All @@ -219,6 +224,7 @@ typedef struct mc_TmpBuffers
m_RpcHasher1=new mc_SHA256();
m_RpcChunkScript1=new mc_Script();
m_RelayTmpBuffer=new mc_Script();
m_LicenseTmpBuffer=new mc_Script();
}

void Destroy()
Expand All @@ -238,6 +244,7 @@ typedef struct mc_TmpBuffers
delete m_RpcHasher1;
delete m_RpcChunkScript1;
delete m_RelayTmpBuffer;
delete m_LicenseTmpBuffer;
}

} mc_TmpBuffers;
Expand Down Expand Up @@ -268,6 +275,7 @@ typedef struct mc_State
uint32_t m_Compatibility;
uint32_t m_SessionFlags;
unsigned char m_BurnAddress[20];
int m_EnterpriseBuild;

mc_Script *m_TmpScript;
mc_Script *m_TmpScript1;
Expand All @@ -292,6 +300,7 @@ typedef struct mc_State
m_NodePausedState=MC_NPS_NONE;
m_ProtocolVersionToUpgrade=0;
m_SessionFlags=MC_SSF_DEFAULT;
m_EnterpriseBuild=0;
memset(m_BurnAddress,0,20);

m_IPv4Address=0;
Expand Down
89 changes: 84 additions & 5 deletions src/community/community.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,63 @@ int mc_EnterpriseFeatures::STR_RemoveDataFromFile(int fHan, uint32_t from, uint3
return MC_ERR_NOERROR;
}

bool mc_EnterpriseFeatures::OFF_ProcessChunkRequest(unsigned char *ptrStart,unsigned char *ptrEnd,vector<unsigned char>* payload_response,vector<unsigned char>* payload_relay,
map<uint160,int>& mapReadPermissionedStreams,string& strError)
{
return false;
}

bool mc_EnterpriseFeatures::OFF_GetScriptsToVerify(map<uint160,int>& mapReadPermissionedStreams,vector<CScript>& vSigScriptsIn,vector<CScript>& vSigScriptsToVerify,string& strError)
{
return true;
}

bool mc_EnterpriseFeatures::OFF_VerifySignatureScripts(uint32_t msg_type,mc_OffchainMessageID& msg_id,mc_OffchainMessageID& msg_id_to_respond,uint32_t flags,
vector<unsigned char>& vPayload,vector<CScript>& vSigScriptsToVerify,string& strError,int& dos_score)
{
return true;
}

bool mc_EnterpriseFeatures::OFF_CreateSignatureScripts(uint32_t msg_type,mc_OffchainMessageID& msg_id,mc_OffchainMessageID& msg_id_to_respond,uint32_t flags,
vector<unsigned char>& vPayload,set<CPubKey>& vAddresses,vector<CScript>& vSigScripts,string& strError)
{
return true;
}

bool mc_EnterpriseFeatures::OFF_GetPayloadForReadPermissioned(vector<unsigned char>* payload,int *ef_cache_id,string& strError)
{
*ef_cache_id=-1;
return true;
}

void mc_EnterpriseFeatures::OFF_FreeEFCache(int ef_cache_id)
{

}

bool mc_EnterpriseFeatures::OFF_ProcessChunkResponse(mc_RelayRequest *request,mc_RelayResponse *response,map <int,int>* request_pairs,mc_ChunkCollector* collector,string& strError)
{
return true;
}

unsigned char* mc_EnterpriseFeatures::OFF_SupportedEnterpriseFeatures(unsigned char* min_ef,int min_ef_size,int *ef_size)
{
if(ef_size)
{
*ef_size=0;
}
return NULL;
}


CPubKey mc_EnterpriseFeatures::WLT_FindReadPermissionedAddress(mc_EntityDetails* entity)
{
CPubKey result;

return result;
}



int mc_EnterpriseFeatures::WLT_CreateSubscription(mc_TxEntity *entity,uint32_t retrieve,uint32_t indexes,uint32_t *rescan_mode)
{
Expand Down Expand Up @@ -119,6 +176,11 @@ string mc_EnterpriseFeatures::ENT_Edition()
return "Community";
}

int mc_EnterpriseFeatures::ENT_BuildVersion()
{
return 0;
}

int mc_EnterpriseFeatures::ENT_EditionNumeric()
{
return 0;
Expand All @@ -129,30 +191,47 @@ int mc_EnterpriseFeatures::ENT_MinWalletDatVersion()
return 2;
}

void mc_EnterpriseFeatures::ENT_RPCVerifyEdition()
void mc_EnterpriseFeatures::ENT_RPCVerifyEdition(string message)
{
throw JSONRPCError(RPC_NOT_SUPPORTED, "This feature is available only in Enterprise edition of MultiChain, please call \"help enterprise\" for details");
string error="This feature is only available in MultiChain Enterprise";
if(message.size())
{
error += ": ";
error += message;
}
throw JSONRPCError(RPC_NOT_SUPPORTED, error);
}

std::string mc_EnterpriseFeatures::ENT_TextConstant(const char* name)
{
return "";
}

void mc_EnterpriseFeatures::ENT_MaybeStop()
{

}

void mc_EnterpriseFeatures::ENT_InitRPCHelpMap()
{

}


void mc_EnterpriseFeatures::LIC_RPCVerifyFeature(uint64_t feature)
void mc_EnterpriseFeatures::LIC_RPCVerifyFeature(uint64_t feature,string message)
{
throw JSONRPCError(RPC_NOT_SUPPORTED, "This feature is available only in Enterprise edition of MultiChain, please call \"help enterprise\" for details");
string error="This feature is only available in MultiChain Enterprise";
if(message.size())
{
error += ": ";
error += message;
}
throw JSONRPCError(RPC_NOT_SUPPORTED, error);
}

bool mc_EnterpriseFeatures::LIC_VerifyFeature(uint64_t feature,std::string& reason)
{
reason="Not available in Community efition";
reason="Not available in Community edition";
return false;
}

Expand Down
28 changes: 24 additions & 4 deletions src/community/community.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@

#define MC_EFT_NONE 0x0000000000000000
#define MC_EFT_LICENSE_TRANSFER 0x0000000000000002
#define MC_EFT_STREAM_CONDITIONAL_INDEXING 0x0000000000000100
#define MC_EFT_STREAM_SUBSCRIPTION_CONTROL 0x0000000000000100
#define MC_EFT_STREAM_MANUAL_RETRIEVAL 0x0000000000000200
#define MC_EFT_STREAM_READ_PERMISSIONS 0x0000000000001000
#define MC_EFT_STREAM_MANUAL_PURGING 0x0000000000000400
#define MC_EFT_STREAM_READ_RESTRICTED_READ 0x0000000000001000
#define MC_EFT_STREAM_READ_RESTRICTED_WRITE 0x0000000000002000
#define MC_EFT_STREAM_READ_RESTRICTED_GIVE 0x0000000000004000
#define MC_EFT_OFFCHAIN_AUTHENTICATION_VERIFY 0x0000000000010000
#define MC_EFT_OFFCHAIN_AUTHENTICATION_SIGN 0x0000000000020000
#define MC_EFT_ALL 0xFFFFFFFFFFFFFFFF


Expand Down Expand Up @@ -49,6 +54,19 @@ typedef struct mc_EnterpriseFeatures
Value STR_RPCPurgePublishedItems(const Array& params);
int STR_RemoveDataFromFile(int fHan, uint32_t from, uint32_t size, uint32_t mode);

bool OFF_ProcessChunkRequest(unsigned char *ptrStart,unsigned char *ptrEnd,vector<unsigned char>* payload_response,vector<unsigned char>* payload_relay,
map<uint160,int>& mapReadPermissionedStreams,string& strError);
bool OFF_ProcessChunkResponse(mc_RelayRequest *request,mc_RelayResponse *response,map <int,int>* request_pairs,mc_ChunkCollector* collector,string& strError);
bool OFF_GetScriptsToVerify(map<uint160,int>& mapReadPermissionedStreams,vector<CScript>& vSigScriptsIn,vector<CScript>& vSigScriptsToVerify,string& strError);
bool OFF_VerifySignatureScripts(uint32_t msg_type,mc_OffchainMessageID& msg_id,mc_OffchainMessageID& msg_id_to_respond,uint32_t flags,
vector<unsigned char>& vPayload,vector<CScript>& vSigScriptsToVerify,string& strError,int& dos_score);
bool OFF_CreateSignatureScripts(uint32_t msg_type,mc_OffchainMessageID& msg_id,mc_OffchainMessageID& msg_id_to_respond,uint32_t flags,
vector<unsigned char>& vPayload,set<CPubKey>& vAddresses,vector<CScript>& vSigScripts,string& strError);
bool OFF_GetPayloadForReadPermissioned(vector<unsigned char>* payload,int *ef_cache_id,string& strError);
void OFF_FreeEFCache(int ef_cache_id);
unsigned char* OFF_SupportedEnterpriseFeatures(unsigned char* min_ef,int min_ef_size,int *ef_size);

CPubKey WLT_FindReadPermissionedAddress(mc_EntityDetails* entity);
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);
int WLT_StartImport();
Expand All @@ -58,12 +76,14 @@ typedef struct mc_EnterpriseFeatures

std::string ENT_Edition();
int ENT_EditionNumeric();
int ENT_BuildVersion();
int ENT_MinWalletDatVersion();
void ENT_RPCVerifyEdition();
void ENT_RPCVerifyEdition(std::string message);
std::string ENT_TextConstant(const char* name);
void ENT_InitRPCHelpMap();
void ENT_MaybeStop();

void LIC_RPCVerifyFeature(uint64_t feature);
void LIC_RPCVerifyFeature(uint64_t feature,std::string message);
bool LIC_VerifyFeature(uint64_t feature,std::string& reason);
// bool LIC_VerifyConfirmation(uint160 address,void *confirmation, size_t size,std::string& reason);
// string LIC_LicenseName(void *confirmation, size_t size);
Expand Down
Loading

0 comments on commit df703b3

Please sign in to comment.