Skip to content

Commit

Permalink
Merge pull request #23 from MultiChain/1.0-dev
Browse files Browse the repository at this point in the history
1.0.1
  • Loading branch information
mike31 committed Sep 15, 2017
2 parents ba30b11 + 9820912 commit 1de5d44
Show file tree
Hide file tree
Showing 51 changed files with 3,584 additions and 823 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ src/bitcoin-tx
src/multichain-cli
src/multichain-util
src/multichaind
src/multichaind-cold
src/test/test_bitcoin
src/qt/test/test_bitcoin-qt

Expand Down
5 changes: 5 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ BITCOIN_WIN_INSTALLER=$(PACKAGE)-$(PACKAGE_VERSION)-win$(WINDOWS_BITS)-setup$(EX
# MCHN START

MULTICHAIND_BIN=$(top_builddir)/src/multichaind$(EXEEXT)
MULTICHAIND_COLD_BIN=$(top_builddir)/src/multichaind-cold$(EXEEXT)
MULTICHAIN_CLI_BIN=$(top_builddir)/src/multichain-cli$(EXEEXT)
MULTICHAIN_UTIL_BIN=$(top_builddir)/src/multichain-util$(EXEEXT)

Expand Down Expand Up @@ -62,6 +63,7 @@ $(BITCOIN_WIN_INSTALLER): all-recursive
STRIPPROG="$(STRIP)" $(INSTALL_STRIP_PROGRAM) $(BITCOIN_QT_BIN) $(top_builddir)/release
STRIPPROG="$(STRIP)" $(INSTALL_STRIP_PROGRAM) $(BITCOIN_CLI_BIN) $(top_builddir)/release
STRIPPROG="$(STRIP)" $(INSTALL_STRIP_PROGRAM) $(MULTICHAIND_BIN) $(top_builddir)/release # MCHN
STRIPPROG="$(STRIP)" $(INSTALL_STRIP_PROGRAM) $(MULTICHAIND_COLD_BIN) $(top_builddir)/release # MCHN
STRIPPROG="$(STRIP)" $(INSTALL_STRIP_PROGRAM) $(MULTICHAI_CLI_BIN) $(top_builddir)/release # MCHN
STRIPPROG="$(STRIP)" $(INSTALL_STRIP_PROGRAM) $(MULTICHAI_UTIL_BIN) $(top_builddir)/release # MCHN
@test -f $(MAKENSIS) && $(MAKENSIS) $(top_builddir)/share/setup.nsi || \
Expand Down Expand Up @@ -146,6 +148,9 @@ $(BITCOIN_CLI_BIN): FORCE
$(MULTICHAIND_BIN): FORCE
$(MAKE) -C src $(@F)

$(MULTICHAIND_COLD_BIN): FORCE
$(MAKE) -C src $(@F)

$(MULTICHAIN_CLI_BIN): FORCE
$(MAKE) -C src $(@F)

Expand Down
31 changes: 29 additions & 2 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ TESTS =

if BUILD_BITCOIND
# bin_PROGRAMS += bitcoind multichaind # MCHN
bin_PROGRAMS += multichaind # MCHN
bin_PROGRAMS += multichaind multichaind-cold # MCHN
endif

if BUILD_BITCOIN_UTILS
Expand Down Expand Up @@ -409,7 +409,7 @@ multichaind_LDADD = \
#if ENABLE_WALLET
#multichaind_LDADD += libbitcoin_wallet.a
#endif
multichaind_SOURCES = multichain/multichaind.cpp chainparams/buildgenesis.cpp
multichaind_SOURCES = multichain/multichaind.cpp rpc/rpclist.cpp chainparams/buildgenesis.cpp
#

if TARGET_WINDOWS
Expand All @@ -420,6 +420,33 @@ multichaind_LDADD += $(BOOST_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINI
multichaind_CPPFLAGS = $(BITCOIN_INCLUDES)
multichaind_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)

# multichaind-cold binary #
multichaind_cold_LDADD = \
$(LIBBITCOIN_SERVER) \
$(LIBBITCOIN_COMMON) \
$(LIBBITCOIN_UNIVALUE) \
$(LIBBITCOIN_WALLET) \
$(LIBBITCOIN_MULTICHAIN) \
$(LIBBITCOIN_UTIL) \
$(LIBBITCOIN_CRYPTO) \
$(LIBLEVELDB) \
$(LIBMEMENV) \
$(LIBSECP256K1)

#if ENABLE_WALLET
#multichaind_cold_LDADD += libbitcoin_wallet.a
#endif
multichaind_cold_SOURCES = multichain/multichaind-cold.cpp core/init-cold.cpp rpc/rpclist-cold.cpp chainparams/buildgenesis.cpp
#

if TARGET_WINDOWS
multichaind_cold_SOURCES += multichaind-cold-res.rc
endif

multichaind_cold_LDADD += $(BOOST_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS)
multichaind_cold_CPPFLAGS = $(BITCOIN_INCLUDES)
multichaind_cold_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)

# multichain-cli binary #
multichain_cli_LDADD = \
$(LIBBITCOIN_CLI) \
Expand Down
74 changes: 66 additions & 8 deletions src/chainparams/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,28 @@ class CMainParams : public CChainParams {
vSeeds.push_back(CDNSSeedData("bitcoinstats.com", "seed.bitcoinstats.com"));
vSeeds.push_back(CDNSSeedData("xf2.org", "bitseed.xf2.org"));

/*
base58Prefixes[PUBKEY_ADDRESS] = list_of(0);
base58Prefixes[SCRIPT_ADDRESS] = list_of(5);
base58Prefixes[SECRET_KEY] = list_of(128);
base58Prefixes[EXT_PUBLIC_KEY] = list_of(0x04)(0x88)(0xB2)(0x1E);
base58Prefixes[EXT_SECRET_KEY] = list_of(0x04)(0x88)(0xAD)(0xE4);

*/
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,0);
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,5);
base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,128);
base58Prefixes[EXT_PUBLIC_KEY].clear();
base58Prefixes[EXT_PUBLIC_KEY].push_back(0x04);
base58Prefixes[EXT_PUBLIC_KEY].push_back(0x88);
base58Prefixes[EXT_PUBLIC_KEY].push_back(0xB2);
base58Prefixes[EXT_PUBLIC_KEY].push_back(0x1E);
base58Prefixes[EXT_SECRET_KEY].clear();
base58Prefixes[EXT_SECRET_KEY].push_back(0x04);
base58Prefixes[EXT_SECRET_KEY].push_back(0x88);
base58Prefixes[EXT_SECRET_KEY].push_back(0xAD);
base58Prefixes[EXT_SECRET_KEY].push_back(0xE4);


convertSeed6(vFixedSeeds, pnSeed6_main, ARRAYLEN(pnSeed6_main));

fRequireRPCPassword = true;
Expand Down Expand Up @@ -234,11 +250,28 @@ class CTestNetParams : public CMainParams {
vSeeds.push_back(CDNSSeedData("bluematt.me", "testnet-seed.bluematt.me"));
vSeeds.push_back(CDNSSeedData("bitcoin.schildbach.de", "testnet-seed.bitcoin.schildbach.de"));

/*
base58Prefixes[PUBKEY_ADDRESS] = list_of(111);
base58Prefixes[SCRIPT_ADDRESS] = list_of(196);
base58Prefixes[SECRET_KEY] = list_of(239);
base58Prefixes[EXT_PUBLIC_KEY] = list_of(0x04)(0x35)(0x87)(0xCF);
base58Prefixes[EXT_SECRET_KEY] = list_of(0x04)(0x35)(0x83)(0x94);
*/

base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,111);
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,196);
base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,239);
base58Prefixes[EXT_PUBLIC_KEY].clear();
base58Prefixes[EXT_PUBLIC_KEY].push_back(0x04);
base58Prefixes[EXT_PUBLIC_KEY].push_back(0x35);
base58Prefixes[EXT_PUBLIC_KEY].push_back(0x87);
base58Prefixes[EXT_PUBLIC_KEY].push_back(0xCF);
base58Prefixes[EXT_SECRET_KEY].clear();
base58Prefixes[EXT_SECRET_KEY].push_back(0x04);
base58Prefixes[EXT_SECRET_KEY].push_back(0x35);
base58Prefixes[EXT_SECRET_KEY].push_back(0x83);
base58Prefixes[EXT_SECRET_KEY].push_back(0x94);


convertSeed6(vFixedSeeds, pnSeed6_test, ARRAYLEN(pnSeed6_test));

Expand Down Expand Up @@ -470,23 +503,32 @@ class CMultiChainParams : public CMainParams {
ucPtr=(const unsigned char*)mc_gState->m_NetworkParams->GetParam("addresspubkeyhashversion",&size);
if(ucPtr)
{
base58Prefixes[PUBKEY_ADDRESS] = list_of(ucPtr[0])(ucPtr[1])(ucPtr[2])(ucPtr[3]);
base58Prefixes[PUBKEY_ADDRESS].clear();
for(int i=0;i<size;i++)
{
base58Prefixes[PUBKEY_ADDRESS].push_back(ucPtr[i]);
}
}
base58Prefixes[PUBKEY_ADDRESS].resize(size);

ucPtr=(const unsigned char*)mc_gState->m_NetworkParams->GetParam("addressscripthashversion",&size);
if(ucPtr)
{
base58Prefixes[SCRIPT_ADDRESS] = list_of(ucPtr[0])(ucPtr[1])(ucPtr[2])(ucPtr[3]);
base58Prefixes[SCRIPT_ADDRESS].clear();
for(int i=0;i<size;i++)
{
base58Prefixes[SCRIPT_ADDRESS].push_back(ucPtr[i]);
}
}
base58Prefixes[SCRIPT_ADDRESS].resize(size);

ucPtr=(const unsigned char*)mc_gState->m_NetworkParams->GetParam("privatekeyversion",&size);
if(ucPtr)
{
base58Prefixes[SECRET_KEY] = list_of(ucPtr[0])(ucPtr[1])(ucPtr[2])(ucPtr[3]);
base58Prefixes[SECRET_KEY].clear();
for(int i=0;i<size;i++)
{
base58Prefixes[SECRET_KEY].push_back(ucPtr[i]);
}
}
base58Prefixes[SECRET_KEY].resize(size);

/* // MCHN-TODO currently copied from main, decide what to do with it later.
base58Prefixes[EXT_PUBLIC_KEY] = list_of(0x04)(0x35)(0x87)(0xCF);
Expand All @@ -495,12 +537,21 @@ class CMultiChainParams : public CMainParams {

// convertSeed6(vFixedSeeds, pnSeed6_test, ARRAYLEN(pnSeed6_test));

SetMultiChainParams();
SetMultiChainRuntimeParams();

fRequireStandard = (mc_gState->m_NetworkParams->GetInt64Param("onlyacceptstdtxs") != 0);
fRequireStandard=GetBoolArg("-requirestandard", fRequireStandard);
fTestnetToBeDeprecatedFieldRPC = (mc_gState->m_NetworkParams->GetInt64Param("chainistestnet") != 0);

}

void SetMultiChainParams()
{
fAllowMinDifficultyBlocks=false;
if(mc_gState->m_Features->FixedIn1000920001())
{
fAllowMinDifficultyBlocks = (mc_gState->m_NetworkParams->GetInt64Param("allowmindifficultyblocks") != 0);
}
}

void SetMultiChainRuntimeParams()
Expand Down Expand Up @@ -694,10 +745,12 @@ class CMultiChainParams : public CMainParams {

assert(strcmp(storedHash,hashGenesisBlock.GetHex().c_str()) == 0);

/*
mapCheckpointsMultichain =
boost::assign::map_list_of
( 0, uint256(storedHash))
;
*/
// assert(hashGenesisBlock == uint256("0x0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206"));

}
Expand All @@ -723,6 +776,11 @@ bool SelectMultiChainParams(const char *NetworkName)
return true;
}

void SetMultiChainParams()
{
multiChainParams.SetMultiChainParams();
}

void SetMultiChainRuntimeParams()
{
multiChainParams.SetMultiChainRuntimeParams();
Expand Down
1 change: 1 addition & 0 deletions src/chainparams/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ bool SelectParamsFromCommandLine();

bool SelectMultiChainParams(const char *NetworkName);
bool InitializeMultiChainParams();
void SetMultiChainParams();
void SetMultiChainRuntimeParams();


Expand Down
1 change: 1 addition & 0 deletions src/chainparams/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ int MCP_ANYONE_CAN_SEND=0;
int MCP_ANYONE_CAN_RECEIVE=0;
int MCP_ANYONE_CAN_ACTIVATE=0;
int64_t MCP_MINIMUM_PER_OUTPUT=0;
int MCP_ALLOW_ARBITRARY_OUTPUTS=1;
int MCP_ALLOW_MULTISIG_OUTPUTS=0;
int MCP_ALLOW_P2SH_OUTPUTS=0;
int MCP_WITH_NATIVE_CURRENCY=0;
Expand Down
12 changes: 8 additions & 4 deletions src/chainparams/paramlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,20 @@ static const mc_OneMultichainParam MultichainParamArray[] =
"Anyone can grant or revoke all permissions."},
{ "supportminerprecheck" , "support-miner-precheck" ,
MC_PRM_BOOLEAN | MC_PRM_USER | MC_PRM_CLONE , -1, 1, 0, 0, 0.0, 10007, 0, "-mc-supportminerprecheck",
"allowp2shoutputs","",
"allowarbitraryoutputs","",
"Require special metadata output with cached scriptPubKey for input, to support advanced miner checks."},
{ "allowarbitraryoutputs" , "allow-arbitrary-outputs" ,
MC_PRM_BOOLEAN | MC_PRM_USER | MC_PRM_CLONE , -1, 0, 0, 0, 0.0, 10009, 0, "-mc-allowarbitraryoutputs",
"allowp2shoutputs","",
"Allow arbitrary (without clear destination) scripts."},
{ "allowp2shoutputs" , "allow-p2sh-outputs" ,
MC_PRM_BOOLEAN | MC_PRM_USER | MC_PRM_CLONE , -1, 1, 0, 0, 0.0, 10001, 0, "-mc-allowp2shoutputs",
"allowmultisigoutputs","",
"Allow pay-to-scripthash (P2SH) scripts, often used for multisig."},
"Allow pay-to-scripthash (P2SH) scripts, often used for multisig. Ignored if allow-arbitrary-outputs=true."},
{ "allowmultisigoutputs" , "allow-multisig-outputs" ,
MC_PRM_BOOLEAN | MC_PRM_USER | MC_PRM_CLONE , -1, 1, 0, 0, 0.0, 10001, 0, "-mc-allowmultisigoutputs",
"setupfirstblocks","",
"Allow bare multisignature scripts, rarely used but still supported."},
"Allow bare multisignature scripts, rarely used but still supported. Ignored if allow-arbitrary-outputs=true."},

{ "setupfirstblocks" , "setup-first-blocks" ,
MC_PRM_UINT32 | MC_PRM_USER | MC_PRM_CLONE , -1, 60, 1, 31536000, 0.0, 10001, 0, "-mc-setupfirstblocks",
Expand Down Expand Up @@ -173,7 +177,7 @@ static const mc_OneMultichainParam MultichainParamArray[] =
{ "minimumrelayfee" , "minimum-relay-fee" ,
MC_PRM_INT64 | MC_PRM_USER | MC_PRM_CLONE , -1, 0, 0,1000000000, 0.0, 10001, 0, "-mc-minimumrelayfee",
"nativecurrencymultiple","",
"Minimum transaction fee, in raw units of native currency."},
"Minimum transaction fee, per 1000 bytes, in raw units of native currency."},
{ "nativecurrencymultiple" , "native-currency-multiple" ,
MC_PRM_INT64 | MC_PRM_USER | MC_PRM_CLONE , -1, 100000000, 0,1000000000, 0.0, 10001, 0, "-mc-nativecurrencymultiple",
"skippowcheck","",
Expand Down
45 changes: 44 additions & 1 deletion src/chainparams/params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ int64_t mc_MultichainParams::GetInt64Param(const char *param)
int index=m_lpIndex->Get(param);
if(index<0)
{
printf("Parameter not found: %s\n",param);
return -1;
}

Expand Down Expand Up @@ -1860,4 +1859,48 @@ int mc_Features::FixedIn10008()
return ret;
}

int mc_Features::FixedDestinationExtraction()
{
int ret=0;
if(mc_gState->m_NetworkParams->IsProtocolMultichain() == 0)
{
return 1;
}

int protocol=mc_gState->m_NetworkParams->ProtocolVersion();

if(protocol)
{
if(protocol >= 10009)
{
ret=1;
}
}

return ret;
}

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

if(protocol)
{
if(protocol >= 10009)
{
ret=1;
}
}

return ret;
}





1 change: 1 addition & 0 deletions src/chainparams/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ extern int MCP_ANYONE_CAN_SEND;
extern int MCP_ANYONE_CAN_RECEIVE;
extern int MCP_ANYONE_CAN_ACTIVATE;
extern int64_t MCP_MINIMUM_PER_OUTPUT;
extern int MCP_ALLOW_ARBITRARY_OUTPUTS;
extern int MCP_ALLOW_MULTISIG_OUTPUTS;
extern int MCP_ALLOW_P2SH_OUTPUTS;
extern int MCP_WITH_NATIVE_CURRENCY;
Expand Down
14 changes: 13 additions & 1 deletion src/chainparams/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
#define MC_FAT_NETWORK 3
#define MC_FAT_NETWORKSEED 4

#define MC_ETP_DAEMON 1
#define MC_ETP_UTIL 2
#define MC_ETP_CLI 3

#define MC_SSF_DEFAULT 0x00000000
#define MC_SSF_COLD 0x00000001

#define MC_NTS_UNCONNECTED 0
#define MC_NTS_WAITING_FOR_SEED 1
#define MC_NTS_SEED_READY 2
Expand Down Expand Up @@ -82,7 +89,7 @@ typedef struct mc_Params
}
}

void Parse(int argc, const char* const argv[]);
void Parse(int argc, const char* const argv[], int exe_type);
int ReadConfig(const char *network_name);
const char* GetOption(const char* strArg,const char* strDefault);
int64_t GetOption(const char* strArg,int64_t nDefault);
Expand Down Expand Up @@ -115,6 +122,8 @@ typedef struct mc_Features
int FixedIn10007();
int Upgrades();
int FixedIn10008();
int FixedDestinationExtraction();
int FixedIn1000920001();
} mc_Features;

typedef struct mc_BlockHeaderInfo
Expand Down Expand Up @@ -148,6 +157,7 @@ typedef struct mc_State
uint32_t m_WalletMode;
int m_ProtocolVersionToUpgrade;
void *m_pSeedNode;
uint32_t m_SessionFlags;

mc_Script *m_TmpScript;
mc_Script *m_TmpScript1;
Expand All @@ -168,6 +178,8 @@ typedef struct mc_State
m_NetworkState=MC_NTS_UNCONNECTED;
m_NodePausedState=MC_NPS_NONE;
m_ProtocolVersionToUpgrade=0;
m_SessionFlags=MC_SSF_DEFAULT;

m_IPv4Address=0;
m_WalletMode=0;
m_TmpAssetsOut=new mc_Buffer;
Expand Down
Loading

0 comments on commit 1de5d44

Please sign in to comment.