Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved the coin parameters to a separate settings file so we can index…
… other chains too
- Loading branch information
Showing
23 changed files
with
1,926 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"magic" : "fabfb5da", | ||
"version_p2pkh" : "47", | ||
"version_p2sh" : "05", | ||
"prefix_bech32": "vtc" | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"magic" : "76657274", | ||
"version_p2pkh" : "4a", | ||
"version_p2sh" : "c4", | ||
"prefix_bech32": "tvtc" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#include "coinparams.h" | ||
/* VTC Blockindexer - A utility to build additional indexes to the | ||
Vertcoin blockchain by scanning and indexing the blockfiles | ||
downloaded by Vertcoin Core. | ||
Copyright (C) 2017 Gert-Jaap Glasbergen | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
|
||
#include <iostream> | ||
#include <fstream> | ||
#include "json.hpp" | ||
#include "utility.h" | ||
using json = nlohmann::json; | ||
using namespace std; | ||
|
||
vector<unsigned char> VtcBlockIndexer::CoinParams::magic; | ||
string VtcBlockIndexer::CoinParams::bech32Prefix; | ||
unsigned char VtcBlockIndexer::CoinParams::p2pkhVersion; | ||
unsigned char VtcBlockIndexer::CoinParams::p2shVersion; | ||
|
||
void VtcBlockIndexer::CoinParams::readFromFile(string fileName) | ||
{ | ||
ifstream i(fileName); | ||
json j; | ||
i >> j; | ||
|
||
assert(j["magic"].is_string()); | ||
assert(j["prefix_bech32"].is_string()); | ||
assert(j["version_p2sh"].is_string()); | ||
assert(j["version_p2pkh"].is_string()); | ||
|
||
magic = VtcBlockIndexer::Utility::hexToBytes(j["magic"].get<string>()); | ||
bech32Prefix = j["prefix_bech32"].get<string>(); | ||
p2shVersion = (unsigned char) strtol(j["version_p2sh"].get<string>().c_str(), NULL, 16); | ||
p2pkhVersion = (unsigned char) strtol(j["version_p2pkh"].get<string>().c_str(), NULL, 16); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* VTC Blockindexer - A utility to build additional indexes to the | ||
Vertcoin blockchain by scanning and indexing the blockfiles | ||
downloaded by Vertcoin Core. | ||
Copyright (C) 2017 Gert-Jaap Glasbergen | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include <vector> | ||
#include <string> | ||
|
||
using namespace std; | ||
|
||
namespace VtcBlockIndexer { | ||
|
||
/** | ||
* The CoinParms class provides static access to the coin parameters and a method | ||
* to read them from a JSON file | ||
*/ | ||
|
||
class CoinParams { | ||
public: | ||
static void readFromFile(string fileName); | ||
static vector<unsigned char> magic; | ||
static string bech32Prefix; | ||
static unsigned char p2pkhVersion; | ||
static unsigned char p2shVersion; | ||
~CoinParams(); | ||
|
||
private: | ||
CoinParams() {} | ||
}; | ||
} |
Oops, something went wrong.