From ec91bd35a07502136f956903605ed616a97ca498 Mon Sep 17 00:00:00 2001 From: Perry Woodin Date: Sat, 24 Jan 2015 10:42:48 -0500 Subject: [PATCH 1/5] Guide to help people setup a start-many capable wallet --- doc/guide-startmany.md | 151 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 doc/guide-startmany.md diff --git a/doc/guide-startmany.md b/doc/guide-startmany.md new file mode 100644 index 0000000000..54dadee6ad --- /dev/null +++ b/doc/guide-startmany.md @@ -0,0 +1,151 @@ +#start-many Setup Guide + +## Two Options for Setting up your Wallet +There are many ways to setup a wallet to support start-many. This guide will walk through two of them. + +1. Importing an existing wallet (recommended if you are consolidating wallets). +2. Sending 1,000 DRK to new wallet addresses. + +## Option 1. Importing an existing wallet + +This is the way to go if you are consolidating multiple wallets into one that supports start-many. + +### From your single-instance MasterNode Wallet + +Open your QT Wallet and go to console (from the menu select Tools => Debug Console) + +Dump the private key from your MasterNode's pulic key. + +``` +walletpassphrase [your_wallet_passphrase] 600 +dumpprivkey [mn_public_key] +``` + +Copy the resulting priviate key. You'll use it in the next step. + +### From your multi-instance MasterNode Wallet + +Open your QT Wallet and go to console (from the menu select Tools => Debug Console) + +Import the private key from the step above. + +``` +walletpassphrase [your_wallet_passphrase] 600 +importprivkey [single_instance_private_key] +``` + +The wallet will re-scan and you will see your available balance increase by the amount that was in the imported wallet. + +Skip Option 2. and go to Create masternode.conf file + +## Option 2. Starting with a new wallet + +If you used Option 1 above, then you can skip down to Create masternode.conf file. + +### Create New Wallet Addresses + +1. Open the QT Wallet. +2. Click the Receive tab. +3. Fill in the form to request a payment. + * Label: mn01 + * Amount: 1000 (optional) + * Click *Request payment* +5. Click the *Copy Address* button + +Create a new wallet address for each MasterNode. + +Close your QT Wallet. + +### Send 1,000 DRK to New Addresses + +Just like setting up a standard MN. Send exactly 1,000 DRK to each new address created above. + +### Create New Keys + +Open your QT Wallet and go to console (from the menu select Tools => Debug Console) + +Issue the following: + +```masternode genkey``` + +Close your QT Wallet. + +## Create masternode.conf file + +Remember... this is local. Make sure your QT is not running. + +Create the masternode.conf file in the same directory as your wallet.dat. + +Copy the private key and correspondig collateral output transaction that holds the 1K DRK. + +The private key may be an existing key from Option 1, or a newly generated key from Option 2. + +### Get the collateral output + +Open your QT Wallet and go to console (from the menu select Tools => Debug Console) + +Issue the following: + +```masternode outputs``` + +Make note of the hash (which is your collaterla_output) and index. + +### Enter your MasterNode details into your masternode.conf file +[From the darkcoin github repo](https://github.com/darkcoin/darkcoin/blob/master/doc/masternode_conf.md) + +The new masternode.conf format consists of a space seperated text file. Each line consisting of an alias, IP address followed by port, masternode private key, collateral output transaction id and collateral output index. + +``` +alias ipaddress:port masternode_private_key collateral_output collateral_output_index +``` + +Example: + +``` +mn01 127.0.0.1:9999 93HaYBVUCYjEMeeH1Y4sBGLALQZE1Yc1K64xiqgX37tGBDQL8Xg 2bcd3c84c84f87eaa86e4e56834c92927a07f9e18718810b92e0d0324456a67c 0 +mn02 127.0.0.2:9999 93WaAb3htPJEV8E9aQcN23Jt97bPex7YvWfgMDTUdWJvzmrMqey aa9f1034d973377a5e733272c3d0eced1de22555ad45d6b24abadff8087948d4 0 +``` + +## What about the darkcoin.conf file? + +If you are using a masternode.conf file you no longer need the darkcoin.conf file. The exception is if you need custom settings (thanks oblox). + +## Update darkcoin.conf on server + +If you generated a new private key, you will need to update the remote darkcoin.conf files. + +Shut down the daemon and then edit the file. + +```sudo nano .darkcoin/darkcoin.conf``` + +### Edit the masternodeprivkey +If you generated a new private key, you will need to update the masternodeprivkey value in your remote darkcoin.conf file. + +## Start your MasterNodes + +### Remote + +If your remote server is not running, start your remote daemon as you normally would. + +I usually confirm that remote is on the correct block by issuing: + +```darkcoind getinfo``` + +And compare with the official explorer at http://explorer.darkcoin.io/chain/Darkcoin + +### Local + +Finally... time to start from local. + +#### Open up your QT Wallet + +From the menu select Tools => Debug Console + +If you want to review your masternode.conf setting before starting the MasterNodes, issue the following in the Debug Console: + +```masternode list-conf``` + +Give it the eye-ball test. If satisfied, you can start your nodes one of two ways. + +1. masternode start-alias [alias_from_masternode.conf]. Example ```masternode start-alias mn01``` +2. masternode start-many From aa544887d7f0006dc67c76f90865418e8ed5854c Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Sat, 24 Jan 2015 20:31:19 +0300 Subject: [PATCH 2/5] ported from https://github.com/bitcoin/bitcoin/commit/13cdce4336818d0f6cefe6b3e61c45762d97d7c6 --- src/init.cpp | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/init.cpp b/src/init.cpp index 7c9e548c1a..269853e88e 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -106,7 +106,28 @@ bool ShutdownRequested() return fRequestShutdown; } +class CCoinsViewErrorCatcher : public CCoinsViewBacked +{ +public: + CCoinsViewErrorCatcher(CCoinsView& view) : CCoinsViewBacked(view) {} + bool GetCoins(const uint256 &txid, CCoins &coins) { + try { + return CCoinsViewBacked::GetCoins(txid, coins); + } catch(const std::runtime_error& e) { + uiInterface.ThreadSafeMessageBox(_("Error reading from database, shutting down."), "", CClientUIInterface::MSG_ERROR); + LogPrintf("Error reading from database: %s\n", e.what()); + // Starting the shutdown sequence and returning false to the caller would be + // interpreted as 'entry not found' (as opposed to unable to read data), and + // could lead to invalid interpration. Just exit immediately, as we can't + // continue anyway, and all writes should be atomic. + abort(); + } + } + // Writes do not need similar protection, as failure to write is handled by the caller. +}; + static CCoinsViewDB *pcoinsdbview; +static CCoinsViewErrorCatcher *pcoinscatcher = NULL; void Shutdown() { @@ -137,6 +158,7 @@ void Shutdown() if (pcoinsTip) pcoinsTip->Flush(); delete pcoinsTip; pcoinsTip = NULL; + delete pcoinscatcher; pcoinscatcher = NULL; delete pcoinsdbview; pcoinsdbview = NULL; delete pblocktree; pblocktree = NULL; } @@ -888,11 +910,13 @@ bool AppInit2(boost::thread_group& threadGroup) UnloadBlockIndex(); delete pcoinsTip; delete pcoinsdbview; + delete pcoinscatcher; delete pblocktree; pblocktree = new CBlockTreeDB(nBlockTreeDBCache, false, fReindex); pcoinsdbview = new CCoinsViewDB(nCoinDBCache, false, fReindex); - pcoinsTip = new CCoinsViewCache(*pcoinsdbview); + pcoinscatcher = new CCoinsViewErrorCatcher(*pcoinsdbview); + pcoinsTip = new CCoinsViewCache(*pcoinscatcher); if (fReindex) pblocktree->WriteReindexing(true); From ce6dd29f9c7d1b029844275f1d1b934146dfeff2 Mon Sep 17 00:00:00 2001 From: Perry Woodin Date: Sun, 25 Jan 2015 09:27:54 -0500 Subject: [PATCH 3/5] Made the distinction between masternode private key and wallet private key more clear. --- doc/guide-startmany.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/doc/guide-startmany.md b/doc/guide-startmany.md index 54dadee6ad..40226b524c 100644 --- a/doc/guide-startmany.md +++ b/doc/guide-startmany.md @@ -36,11 +36,11 @@ importprivkey [single_instance_private_key] The wallet will re-scan and you will see your available balance increase by the amount that was in the imported wallet. -Skip Option 2. and go to Create masternode.conf file +[Skip Option 2. and go to Create masternode.conf file](#masternodeconf) ## Option 2. Starting with a new wallet -If you used Option 1 above, then you can skip down to Create masternode.conf file. +[If you used Option 1 above, then you can skip down to Create masternode.conf file.](#masternodeconf) ### Create New Wallet Addresses @@ -60,7 +60,9 @@ Close your QT Wallet. Just like setting up a standard MN. Send exactly 1,000 DRK to each new address created above. -### Create New Keys +### Create New Masternode Private Keys + +*Please note, the masternode priviate key is not the same as a wallet private key. Never put your wallet private key in the masternode.conf file. That is equivalent to putting your 1,000 DRK on the remote server and defeats the purpose of a hot/cold setup.* Open your QT Wallet and go to console (from the menu select Tools => Debug Console) @@ -70,15 +72,15 @@ Issue the following: Close your QT Wallet. -## Create masternode.conf file +## Create masternode.conf file Remember... this is local. Make sure your QT is not running. Create the masternode.conf file in the same directory as your wallet.dat. -Copy the private key and correspondig collateral output transaction that holds the 1K DRK. +Copy the masternode private key and correspondig collateral output transaction that holds the 1K DRK. -The private key may be an existing key from Option 1, or a newly generated key from Option 2. +The masternode private key may be an existing key from Option 1, or a newly generated key from Option 2. ### Get the collateral output @@ -112,14 +114,14 @@ If you are using a masternode.conf file you no longer need the darkcoin.conf fil ## Update darkcoin.conf on server -If you generated a new private key, you will need to update the remote darkcoin.conf files. +If you generated a new masternode private key, you will need to update the remote darkcoin.conf files. Shut down the daemon and then edit the file. ```sudo nano .darkcoin/darkcoin.conf``` ### Edit the masternodeprivkey -If you generated a new private key, you will need to update the masternodeprivkey value in your remote darkcoin.conf file. +If you generated a new masternode private key, you will need to update the masternodeprivkey value in your remote darkcoin.conf file. ## Start your MasterNodes From 2cdaaeac2519cd04c7e11bef02591d2c94c3fa1f Mon Sep 17 00:00:00 2001 From: Perry Woodin Date: Sun, 25 Jan 2015 09:34:08 -0500 Subject: [PATCH 4/5] Moved the note about masternode private keys. --- doc/guide-startmany.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/guide-startmany.md b/doc/guide-startmany.md index 40226b524c..6c3a4a33f9 100644 --- a/doc/guide-startmany.md +++ b/doc/guide-startmany.md @@ -3,10 +3,10 @@ ## Two Options for Setting up your Wallet There are many ways to setup a wallet to support start-many. This guide will walk through two of them. -1. Importing an existing wallet (recommended if you are consolidating wallets). -2. Sending 1,000 DRK to new wallet addresses. +1. [Importing an existing wallet (recommended if you are consolidating wallets).](#option1) +2. [Sending 1,000 DRK to new wallet addresses.](#option2) -## Option 1. Importing an existing wallet +## Option 1. Importing an existing wallet This is the way to go if you are consolidating multiple wallets into one that supports start-many. @@ -38,7 +38,7 @@ The wallet will re-scan and you will see your available balance increase by the [Skip Option 2. and go to Create masternode.conf file](#masternodeconf) -## Option 2. Starting with a new wallet +## Option 2. Starting with a new wallet [If you used Option 1 above, then you can skip down to Create masternode.conf file.](#masternodeconf) @@ -62,8 +62,6 @@ Just like setting up a standard MN. Send exactly 1,000 DRK to each new address c ### Create New Masternode Private Keys -*Please note, the masternode priviate key is not the same as a wallet private key. Never put your wallet private key in the masternode.conf file. That is equivalent to putting your 1,000 DRK on the remote server and defeats the purpose of a hot/cold setup.* - Open your QT Wallet and go to console (from the menu select Tools => Debug Console) Issue the following: @@ -80,7 +78,9 @@ Create the masternode.conf file in the same directory as your wallet.dat. Copy the masternode private key and correspondig collateral output transaction that holds the 1K DRK. -The masternode private key may be an existing key from Option 1, or a newly generated key from Option 2. +The masternode private key may be an existing key from [Option 1](#option1), or a newly generated key from [Option 2](#option2). + +*Please note, the masternode priviate key is not the same as a wallet private key. Never put your wallet private key in the masternode.conf file. That is equivalent to putting your 1,000 DRK on the remote server and defeats the purpose of a hot/cold setup.* ### Get the collateral output From 48979217ba26eee2f4213077990983d401d64154 Mon Sep 17 00:00:00 2001 From: Perry Woodin Date: Sun, 25 Jan 2015 11:58:43 -0500 Subject: [PATCH 5/5] Added note making it clear that a masternode private key needs to be created for each MN. --- doc/guide-startmany.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/guide-startmany.md b/doc/guide-startmany.md index 6c3a4a33f9..65fa39f526 100644 --- a/doc/guide-startmany.md +++ b/doc/guide-startmany.md @@ -68,6 +68,8 @@ Issue the following: ```masternode genkey``` +*Note: A masternode private key will need to be created for each MasterNode you run. You should not use the same masternode private key for multiple MasterNodes.* + Close your QT Wallet. ## Create masternode.conf file