Bitcoin Forum
May 30, 2024, 04:30:17 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Bitcoin Address Generation Emulator? NEED FEEDBACK!  (Read 358 times)
MehdiBmm (OP)
Sr. Member
****
Offline Offline

Activity: 336
Merit: 250


View Profile
August 19, 2016, 01:32:01 PM
 #1

Hi pals,

As I've told in a recent post, I'm starting out as a self-taught C++ programmer.

Yesterday (actually today at a VERY early hour, like 4 AM) I was playing around with my Atom and I made something very simple.

Basically, It's not really like Bitcoin Addresses (as they seem to have a length of 34 characters), mine generates random potential addresses with 35 characters.

Check out the screen.



It's been generating random potential addresses for like 10 hours now and It stills do It, I made It so that It makes like 1000000000 addresses before finishing. I also made a condition that IF EVER two addresses are the same, the program should stop and It didn't (so every address made Is unique so far Tongue).

I'm posting the code too! I want some feedback please.

Code:
#include <iostream>
#include <string>
#include <random>
#include <ctime>
#include <vector>

using namespace std;

class Hash
{
  public:

    Hash()
 {
     m_letters = "abcdefghijklmnopqrstvwxyzABCDEFGHIJKLMNOPQRSTVWXYZ0123456789:;";
     m_hash = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
     m_same = false;
     m_hashes = 1000000000;
 }

 void generate()
 {
   default_random_engine engine(time(0));
   uniform_int_distribution<int> random(0, 61);

   for(int i = 0; i < 35; i++)
   {
     m_random = random(engine);
     m_hash[i] = m_letters[m_random];
   }

   cout << m_hash << endl;
 }

 void abortThis()
 {
   cout << "FOUND TWO HASHES WITH 100\% SAME DATA" << endl;
   while(1)
   {

   }
 }

 void massGenerate()
 {
   default_random_engine engine(time(0));
   uniform_int_distribution<int> random(0, 61);
   for(int i = 0; i < m_hashes; i++)
   {
    for(int i = 0; i < 35; i++)
      {
        m_random = random(engine);
        m_hash[i] = m_letters[m_random];
      }

      for(auto c : m_massVerify)
      {
        if(m_hash == c)
          abortThis();
      }

      m_list.push_back(m_hash);
      m_massVerify.push_back(m_hash);
      cout << m_hash << endl;


    }

    cout << "GENERATED " << m_hashes << " DIFFERENT HASHES SUCCESFULLY." << endl;
 }

 void show_all()
 {
   for(auto m_data : m_list)
    cout << m_data << endl;
 }





  private:
    int m_random;
    unsigned int m_hashes;
    string m_letters;
    string m_hash;
    string m_current;
    bool m_same;
    vector<string> m_massVerify;
    vector<string> m_list;

};



int main()
{
  Hash test;
  test.massGenerate();
}
Specially SEE the default constructor of Hash class, and the function massGenerate.
YOU CAN ALSO FIND THE CODE HERE BUT IT WON'T COMPILE ON ONLINE IDE. http://cpp.sh/7g7o

PLEASE,
Don't comment about that using namespace std; I know It's bad.
Don't comment about me using one file instead of a .cpp & .hpp, I know It's bad too.
Don't comment about variables name, I know It's good Cheesy

What I would REALLY BE INTERESTED IN, Is to find the piece of code that generates BITCOIN ADDRESSES in BITCOIN CORE!
I'm COMPLETELY aware that the generated addresses doesn't start with 1 or 3. It has been done ON PURPOSE! Cheesy
BilalHIMITE
Full Member
***
Offline Offline

Activity: 159
Merit: 100


View Profile
August 19, 2016, 03:02:10 PM
 #2

Vanitygen is a command-line tool that can be used to generate random bitcoin addresses. It also has OpenCL-compatible GPU version called oclvanitygen. Both can be built from source, GitHub.
MehdiBmm (OP)
Sr. Member
****
Offline Offline

Activity: 336
Merit: 250


View Profile
August 19, 2016, 03:30:57 PM
 #3

Vanitygen is a command-line tool that can be used to generate random bitcoin addresses. It also has OpenCL-compatible GPU version called oclvanitygen. Both can be built from source, GitHub.

Oh I know that one but I never thought about looking at the sources, going to check this, thankx mate!
odolvlobo
Legendary
*
Offline Offline

Activity: 4326
Merit: 3247



View Profile
August 19, 2016, 04:04:28 PM
 #4

This tells you how to make a valid address: https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses

If you don't care about the private key, start at step 4 with a 160-bit (20 bytes) value.

Join an anti-signature campaign: Click ignore on the members of signature campaigns.
PGP Fingerprint: 6B6BC26599EC24EF7E29A405EAF050539D0B2925 Signing address: 13GAVJo8YaAuenj6keiEykwxWUZ7jMoSLt
MehdiBmm (OP)
Sr. Member
****
Offline Offline

Activity: 336
Merit: 250


View Profile
August 19, 2016, 04:25:06 PM
 #5

This tells you how to make a valid address: https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses

If you don't care about the private key, start at step 4 with a 160-bit (20 bytes) value.


I'm going to check this one, thank you!

I'm no expert, but i'm sure it needs more resources to generate a bitcoin than your random 35 characters because there's more steps when you generate a bitcoin address.
Also, bitcoin core is open source, so you can look at the source code anytime you want Smiley

Exact, there's too many steps but I just wanted to implement the "random strings" step.

I know that It's Open source and I've made a small look at the files, I was completely lost Sad If someone could've told me the name of the file that contains the address generation that would have made things more easier.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!