Post
Topic
Board Altcoin Discussion
Re: [CryptoNote] A complete forking guide to create your own CryptoNote currency
by
lemier
on 23/07/2014, 18:25:48 UTC
I was trying to find how to define address prefixes (like in XDN or Cryptonotecoin), but couldn't find any tools for that. Here's my solution. You may add the following code lines to any of existing Cryptonote coins (as Cryptonote forking repo won't compile due to empty constants).

1) Update CMakeList.txt:

Quote
+file(GLOB_RECURSE PREFIXGENERATOR prefixgenerator/*)
+add_executable(prefixgenerator ${PREFIXGENERATOR})
+target_link_libraries(prefixgenerator crypto common ${Boost_LIBRARIES})

2) Add a new file /src/prefixgenerator.cpp

Code:
#include
#include
#include "common/base58.h"

int main(int argc, char** argv) {

  if (argc > 1) {
    std::string s = argv[1];
    for (uint64_t i = 0; i < (uint64_t)(-1); i++) {
      std::string r = tools::base58::encode_addr(i, "test");
      if (s == r.substr(0, s.size()))
        std::cout << r << " 0x" << std::hex << i << std::dec << std::endl;
    }
  } else {
    for (uint64_t i = 0; i < (uint64_t)(-1); i++) {
      std::string r = tools::base58::encode_addr(i, "test");
      std::cout << r << " 0x" << std::hex << i << std::dec << std::endl;
    }
  }
  return 0;
}

3) Compile the updated repo

4) Run the util with the desired prefix:
Code:
./prefixgenerator PREFIX_YOU_WANT

or get all possible prefixes and grep the one you need:
Code:
./prefixgenerator | grep -E "REGEXP"


What the util does is trying every possible input to get you the prefix you wish to have. I hope this will help someone.