Bitcoin Forum

Alternate cryptocurrencies => Altcoin Discussion => Topic started by: joehop67 on May 16, 2013, 11:51:13 PM



Title: Altcoins and Checkpoins?
Post by: joehop67 on May 16, 2013, 11:51:13 PM
Okay so me and a friend have been developing an altcoin for personal use. Sort of like an in-house currency. We managed to create the genesis block but the checkpoints are stumping us. We are using the Smallchange source code and a quick look through the checkpoints.cpp file is confusing us to no end. Is this a necessary part to making a working altcoin or can we just leave it as is?

Also we are stummped on the irc.cpp file as well do we need to make our own irc channel or can we just leave it as is aswell? Can we make the channel using freenode?


Title: Re: Altcoins and Checkpoins?
Post by: jj9guy on May 17, 2013, 01:44:21 AM
You shouldnt need them if your coin is really in house unless you expect someone you know to rape your coin with their hashing power.


Title: Re: Altcoins and Checkpoins?
Post by: arjay45 on May 17, 2013, 02:21:56 AM
The irc is how it gets IP addresses for nodes, and it does this by looking at join messages in the IRC channel it's in. If you don't create a new channel then you will get peers from whatever other coin is in that channel. That's bad. You should have your own channel for your coin. Otherwise it will take forever for any new users of your coin to find peers, because all of the IP addresses it will try from IRC are not using your coin but someone else's.


Title: Re: Altcoins and Checkpoins?
Post by: shakezula on May 17, 2013, 02:25:27 AM
does your coin mine in test net?


Title: Re: Altcoins and Checkpoins?
Post by: joehop67 on May 17, 2013, 02:27:51 AM
does your coin mine in test net?

I don't think so... if it did mine in testnet I would put the -testnet command in terminal right?

The irc is how it gets IP addresses for nodes, and it does this by looking at join messages in the IRC channel it's in. If you don't create a new channel then you will get peers from whatever other coin is in that channel. That's bad. You should have your own channel for your coin. Otherwise it will take forever for any new users of your coin to find peers, because all of the IP addresses it will try from IRC are not using your coin but someone else's.

how would I go about setting up an irc channel? using freenode or would I have to set up my own server too?


Title: Re: Altcoins and Checkpoins?
Post by: arjay45 on May 17, 2013, 02:31:50 AM
how would I go about setting up an irc channel? using freenode or would I have to set up my own server too?

Keep the server the same. Just change the name in the string. If the channel doesn't exist on the server in question it will be created. Done. When all the clients leave the channel the IRC server will destroy the channel.

Just keep the IRC server the same. FreeNode would probably not appreciate bitcoin traffic. But I presume someone at some point asked the default IRC server admins if they could use it for bitcoin traffic.


Title: Re: Altcoins and Checkpoins?
Post by: joehop67 on May 17, 2013, 02:37:19 AM
Sorry I'm sure you got something better to do with your time then help a noob like me but I just have one more question (more like a few):

Should I change the ports? does it matter what I change them to?


Title: Re: Altcoins and Checkpoins?
Post by: shakezula on May 17, 2013, 02:57:46 AM
testnet doesn't neef checkpoints; that's why I wondered. do you have a valid genesis block?


Title: Re: Altcoins and Checkpoins?
Post by: arjay45 on May 17, 2013, 03:48:23 AM
Sorry I'm sure you got something better to do with your time then help a noob like me but I just have one more question (more like a few):

Should I change the ports? does it matter what I change them to?

Yes change the ports for the same reason. Otherwise other coins can connect to your client and attempt to send blocks and transactions to it. That's bad. IIRC there's also some magic numbers you need to change so if somehow another coin does connect to one of your clients, any blocks or transactions sent from it are invalid and will be dropped. And vice versa of course.

I don't know where these magic numbers are in the code. I haven't studied the code very closely because right now I don't intend to make an altcoin.


Title: Re: Altcoins and Checkpoins?
Post by: thisnewcoin on May 17, 2013, 04:04:28 AM
you don't need checkpoints if you don't care people use a longer block chain to replace yours


Title: Re: Altcoins and Checkpoins?
Post by: joehop67 on May 17, 2013, 04:48:39 AM
testnet doesn't neef checkpoints; that's why I wondered. do you have a valid genesis block?

yes I do... at least I think I do... I don't get any errors when I start up the client so I assume I have one.


Title: Re: Altcoins and Checkpoins?
Post by: joehop67 on May 17, 2013, 04:59:09 AM
Sorry I'm sure you got something better to do with your time then help a noob like me but I just have one more question (more like a few):

Should I change the ports? does it matter what I change them to?

Yes change the ports for the same reason. Otherwise other coins can connect to your client and attempt to send blocks and transactions to it. That's bad. IIRC there's also some magic numbers you need to change so if somehow another coin does connect to one of your clients, any blocks or transactions sent from it are invalid and will be dropped. And vice versa of course.

I don't know where these magic numbers are in the code. I haven't studied the code very closely because right now I don't intend to make an altcoin.

Does it matter what port # I change it to? Does it have to be specific or can I just change like the last number in the sequence and it will work?


Title: Re: Altcoins and Checkpoins?
Post by: shakezula on May 17, 2013, 02:12:26 PM
testnet doesn't neef checkpoints; that's why I wondered. do you have a valid genesis block?

yes I do... at least I think I do... I don't get any errors when I start up the client so I assume I have one.

Ok, then if you have a valid genesis block, use the hash of it in your checkpoints.cpp as checkpoint 0 (it likely won't be in there, if you used SMC, block 1 is the root checkpoint, just change this to 0) rebuild your client and bob's your uncle.


Title: Re: Altcoins and Checkpoins?
Post by: joehop67 on May 17, 2013, 05:35:13 PM
Okay so I did that and managed to execute without any errors so that fine. I just seem to have problems actually connecting to the network. The IRC (fond in the debug.log file) keeps telling me that the connection timed out. Is there anything wrong or is this normal?

Also when I try and start my program with the -daemon to start the server and get my client to connect to it it doesn't actually do anything. It writes in the terminal "Neucoin server starting" and then quickly changes back to the normal terminal. Is this normal? Do I need to change anything? My client says that there are no active connections to the Neucoin network so it can't be working right?


Title: Re: Altcoins and Checkpoins?
Post by: shakezula on May 17, 2013, 05:41:23 PM
To get the first 2 nodes to connect, you'll have to do it manually. Once two nodes connect you'll be able to mine. It takes a few more than 2 connections before peerdiscovery starts via IRC or at least that's my experience. Just add -connect=x.x.x.x using the ip of the other machine to the start up line on 2 or more machines. You can also do -addnode= or add addnode= to your .conf.


Title: Re: Altcoins and Checkpoins?
Post by: joehop67 on May 17, 2013, 05:49:56 PM
Do I have to put the port # after the ip?


Title: Re: Altcoins and Checkpoins?
Post by: shakezula on May 17, 2013, 05:57:59 PM
I'd do this, assuming I have 2 computers on 2 IPs, lets say 1.1.1.1 (pc1) and 2.2.2.2 (pc2):

pc1: ~/coin/src$ coind -connect 2.2.2.2 &

pc2: ~/coin/src$ coind -connect 1.1.1.1 &

now you can do:

pc1: ~/coin/src$  coind getinfo

and you should see 1 connection, do it from the other pc and make sure they see each other. Once you have a listed connection do:

pc1: ~/coin/src$ coind setgenerate true 4

and then

pc1: ~/coin/src$ coind showmininginfo

and you should see it begin generating coins. At this point, you can now edit your .conf to have rpcallow=2.2.2.2 or whatever, and point cgminer/minerd at that ip.


Title: Re: Altcoins and Checkpoins?
Post by: joehop67 on May 17, 2013, 06:26:27 PM
Do I have to have separate computers or will it work with different VM's?


Title: Re: Altcoins and Checkpoins?
Post by: arjay45 on May 17, 2013, 06:26:55 PM
Does it matter what port # I change it to? Does it have to be specific or can I just change like the last number in the sequence and it will work?

Do enough research to be reasonably sure you're not using a port number from any other coin. If you're not sure pick a random one between 10000 and 20000 -- only two coins I'm aware of have used numbers in that range (worldcoin and one other coin I forget the name of), so if you pick it randomly you probably won't pick the same one. Testnet would be that port plus 10000. RPC port is that port plus one.


Title: Re: Altcoins and Checkpoins?
Post by: joehop67 on May 17, 2013, 06:36:01 PM
The port #'s are specified in the init.cpp file correct?


Title: Re: Altcoins and Checkpoins?
Post by: joehop67 on May 17, 2013, 08:19:18 PM
I'm going to be honest with you I thought the hardest part of making an altcoin was finding the genesis block.


Title: Re: Altcoins and Checkpoins?
Post by: arjay45 on May 17, 2013, 10:49:10 PM
Well I am a professional software developer. I do this for a living. I wouldn't be worth much if I couldn't take something as well written as the bitcoin client and figure out how to modify it.

The main protocol port is in protocol.h in a function called GetDefaultPort. You should also change init.cpp so the help message matches the port you choose in the GetDefaultPort. That's for the protocol port.

The default RPC port is found twice in bitcoinrpc.cpp in calls to GetArg("-rpcport", ####) where #### is the default port of whatever coin you're using as the original source. Like the protocol port, it's mentioned in the help strings in init.cpp so should be changed there too.


Title: Re: Altcoins and Checkpoins?
Post by: arjay45 on May 17, 2013, 11:11:00 PM
I also found where the magic number is in the code. main.cpp pchMessageStart defined around line 2439 or so just before the definition of ProcessMessage. You should change that to be different than any existing coins or bad things.

Basically this number will allow your coin to ignore protocol messages from other coins thus ensuring your coin's chain won't become infected with transactions and/or blocks from other chains by accident.

You should choose values that are extremely unlikely to occur in normal valid messages. It suggests values above 0x80 since values below 0x80 are valid ascii.

Choosing random values between 0x80 and 0xfe would probably be okay. It's very unlikely two coins will choose the same random numbers. I suggest the first number be between 0xf0 and 0xfe but it doesn't have to be.

The testnet magic number should be different from the normal net. The testnet magic number is set in LoadBlockIndex at the top I think. Also main.cpp.


Title: Re: Altcoins and Checkpoins?
Post by: joehop67 on May 18, 2013, 12:25:30 AM
I'd do this, assuming I have 2 computers on 2 IPs, lets say 1.1.1.1 (pc1) and 2.2.2.2 (pc2):

pc1: ~/coin/src$ coind -connect 2.2.2.2 &

pc2: ~/coin/src$ coind -connect 1.1.1.1 &

now you can do:

pc1: ~/coin/src$  coind getinfo

and you should see 1 connection, do it from the other pc and make sure they see each other. Once you have a listed connection do:

pc1: ~/coin/src$ coind setgenerate true 4

and then

pc1: ~/coin/src$ coind showmininginfo

and you should see it begin generating coins. At this point, you can now edit your .conf to have rpcallow=2.2.2.2 or whatever, and point cgminer/minerd at that ip.

I tried this. All I got was a "could not connect to server" error.


Title: Re: Altcoins and Checkpoins?
Post by: arjay45 on May 18, 2013, 12:45:28 AM
put an equals sign between -connect and the IP. so -connect=1.1.1.1 -- also make sure the IP is actually the IP of the machine in question.


Title: Re: Altcoins and Checkpoins?
Post by: joehop67 on May 18, 2013, 04:29:55 AM
I did this and everything ran fine. But I cannot enter any commands... I enter neucoind -connect=#.#.#.# and nothing happens. Well not nothing but it just turns into a blinking cursor and it does not let me enter any commands.


Title: Re: Altcoins and Checkpoins?
Post by: coinerd on May 18, 2013, 05:20:26 AM
If you're in windows that's normal for a *coind.exe

You need to leave one command prompt running the daemon, then you can open a separate command prompt to interact with it.

Once you have browsed to the same directory where the executable is then you can execute it with an RPC command and it will query the daemon.

So if you have that blinking cursor at one prompt you just open another and run it with the command "neucoind getinfo"

Or "neucoind help" for a list of other commands.


if you type neucoind help while the daemon is running you get a different response from when you type neucoind --help for information on how to run the program.  If the daemon is not in the expected state you should see an error.

also I think you have to add the -connect=*.*.*.* to eother the initial command or the .conf file, it's not something you can tell the daemon to do "on the fly".


Title: Re: Altcoins and Checkpoins?
Post by: joehop67 on May 18, 2013, 05:35:12 AM
put an equals sign between -connect and the IP. so -connect=1.1.1.1 -- also make sure the IP is actually the IP of the machine in question.

Alright so I did this (in two VM's though... with different IP's) and it seemed to run fine but when I run neucoin getinfo it tells me that I have zero connections? Did I do something wrong? Do I have to have two different computers?


Title: Re: Altcoins and Checkpoins?
Post by: shakezula on May 18, 2013, 02:23:35 PM
I haven't tried it in 2 VMs, but I'd think that it should work if the VMs can ping and route to each other. Make sure you can ping them and the ports you assigned your coin are open (i.e.: turn off ufw if you're using Ubuntu).


Title: Re: Altcoins and Checkpoins?
Post by: joehop67 on May 18, 2013, 07:39:00 PM
I haven't tried it in 2 VMs, but I'd think that it should work if the VMs can ping and route to each other. Make sure you can ping them and the ports you assigned your coin are open (i.e.: turn off ufw if you're using Ubuntu).

The two VM's can ping each other but I do not think they can route to each other.


Title: Re: Altcoins and Checkpoins?
Post by: joehop67 on May 18, 2013, 11:46:29 PM
So is there any way to check and make sure they can route to each other? If they can't how can I make them route / connect to each other?


Title: Re: Altcoins and Checkpoins?
Post by: joehop67 on May 19, 2013, 08:31:16 PM
Alright so I got it to work and everything is fine (except I cannot mine any of my coins but thats another question for another day.) I just have two more questions:

How many connects will I have to force until my client automatically connects to the network?
and
How can I force the connections without having to type -addnode after my client in the terminal?