Command Line Wallet

From Mochimo Wiki
Revision as of 04:52, 8 March 2019 by Yoyao (talk | contribs)
Jump to: navigation, search

This is a guide on how to use the CLI Wallet. It was created for developers by developers and is directed towards our miner community. If you’re not familiar with Linux and the command line or not interested in learning then try out the Mojo wallet.

Installation

There are some instances where you might want to compile the wallet separate from any mining capability. All it takes is a slight modification of the git repo to do this, so we will start by cloning the git repo:

Clone Git

git clone https://github.com/mochimodev/mochimo

Clone Git.gif

Create new installation script

Next we need to create and make executable a makewal file so that we can compile just the wallet software and not the Cuda code for mining. The set of four commands to run:

cd ./mochimo/src
touch makewal
chmod +x ./makewal
nano ./makewal

02a-createNewInstallScript.gif

You should now be in the nano editor, and we want to place the following code into that file:

#!/bin/sh
# Change the set CC line for your compiler:

export set CC='cc -DUNIXLIKE -DLONG64'
echo Building wallet...
$CC -c crypto/sha256.c 2>ccerror.log
$CC -c crypto/wots/wots.c  2>>ccerror.log
$CC -o wallet wallet.c wots.o sha256.o 2>>ccerror.log
echo Errors logged to ccerror.log
ls -l ccerror.log

Now save and exit from nano by doig a Ctrl-o then Enter then Ctrl-x

02b-createNewInstallScript.gif

Now, run it!

Now we can run the script by typing ./makewal at the terminal inside the mochimo/src/ directory.
If we have done everything right, we should have a wallet program in src/ directory. Confirm the wallet program is there with a ls command to list the directory’s contents.

03a-runIt.gif

Let's make a bin directory, and move the binary over there by using these commands:

mkdir ../bin/
cp ./wallet ../bin
cd ../bin

We should now be in the bin directory.
Confirm the wallet program is there with a ls command to list the directory’s contents.

03b-runIt.gif

That's it! program installed :)

Running for the first time

Create a new wallet

Start from the mochimo/bin/ directory and invoke the wallet with the following command:

./wallet -p2095 -n

(Note: port 2095 is required to be open on your network for mining to function, but not required for the wallet to run. You still need though, to enter the command exactly as above.)

  1. You will be prompted to choose a name for your wallet. We’ll call it My Wallet in our example.
  2. You will be prompted for a password. Your wallet will be encrypted 100% of the time. This password will be used to decrypt the wallet - don't lose it.
  3. You will be asked to enter some random text to help randomize your wallet seed. You do not need to memorize this information.
    1. If this is a NEW installation of Linux, say on a cloud server, you may get stuck here. This means that your box doesn't have enough entropy to create the randomness needed for this step. Here is the proposed solution to that problem:
      1. You will have to open a new terminal window and do the following
      2. sudo apt-get install rng-tools
      3. sudo rngd -r /dev/urandom
      4. This should solve your problem, if not check in the Diccord group to see if there might be a newer solution.
  4. You will be asked to pick a filename. We recommend mochimo.wal.
  5. The wallet file is saved to the disk and the wallet software exits.
  6. Confirm mochimo.wal was successfully created with a ls command to list the directory’s contents.

04-createWallet.gif

Download a list of network nodes and start the wallet

Let's download a startnodes.lst file, so the wallet has multiple nodes to grab network information from. It will also help to avoid getting a ***Balance check failed*** error. The easiest way to do that in Linux is:

wget https://www.mochimap.net/startnodes.lst

If you named your wallet mochimo.wal, then open the wallet with the following command:

./wallet -p2095 mochimo.wal

You will be prompted to enter your password. If you enter this incorrectly, the system will not tell you, but the name at the top of the wallet when you open it be some garbled gibberish. The reason for this is the password is a decryption key and is not stored in the wallet itself. If you enter it wrong, the wallet will still decrypt using the wrong key, and the result will be garbage. You know you entered it correctly if the wallet name you chose displays at the top of the screen. In our case, we’ll see My Wallet at the top.

05-startnodes-StartWallet.gif

Create a new non-mining address

We are going to play out the scenario that you are NOT a miner, but you would like to buy Mochimo from your friend who is. In order to do this you will have to have a Mochimo address to which he can send your coins. There are two ways of doing this. We are going to address the old-school original way here, since this is the old-school original wallet. The new school way is with our cross-platform Mojo wallet.

  1. First, create a new address with option 4.
  2. You must give it a name here, let's use Mo Money. This address will be assigned an index sequentially higher than your last address. If you don't have any addresses yet, this would be index 1.
  3. If you are using the most recent version of the wallet, you will be asked if you want to "Tag" this address (Learn about Tags here), for this part of the guide, let's say N

06-createAddress.gif

Finding your address index

  1. After returning to the main menu, it is a good idea to hit 6 Check Balances every time. If you don't have an addresses with a balance, then you will see No entries.

If you are making an address to export that doesn't yet have a balance, it may be difficult to find that address' index. Here is the right way:

  1. From the main menu, choose option 9 for the 2nd page menu
  2. Then choose option 2 for Display change addresses. This will show all of your 0 balance addresses. You can find the correct address index here.
  3. If you'd like to see your hex address, choose option 4 Display address in hex

07-checkAddressHex.gif

Receive Mochimo

Export address

In order for our friend to send us Mochimo, we are going to have to send him an address file. The reason this is slightly different than other crypto-currencies is part of what makes us a quantum secure coin. Our addresses are over 2000 bytes in length. Not something you can easily type into a field on the web. The easy way around this is to export the entire file and send it to your friend via email which is what we will be doing here. However, there is a "tagging" feature which is our long-term solution to this problem and will be explained later.

  1. Start from the wallet's Main Menu
  2. Choose option 7 for Export address
  3. Now you must choose the index number for the address you wish to export. If you are not sure which is the correct index, then see the previous Finding your address section
  4. After selecting the index of the address you wish to export, the wallet will ask you to name the file it is about to write. Let's say: myStack.dat
  5. The next question is Write balance (y/n)?. If we answer yes here, our friend will be able to see our balance when he opens his wallet, if we answer no, it is still possible for our friend to find our balance, but it might take an extra step.
  6. If you answered y in the previous question, this will be the next question. If we answered in the negative, we will not get this question: Write secret (y/n)? In this scenario, we DO NOT want to export the file with it's secret attached. If we did so, our friend would have access to whatever funds he sent us, so we will answer n.

08a-exportAddressReceiveMCM.gif

The exported myStack.dat file will be located in the same /mochimo/bin/ directory as your mochimo.wal wallet file (screenshot below of our working example).

The exported file will need to be transferred from the server to your local computer. There are many ways to do this and we suggest secure transfers through encrypted channels for security.

From here we just need to email our friend and attach this file to that email. Then - we wait :)

08bdatFile.png

Send Mochimo

Importing a foreign address

For this part of the walk-through, we are going to pretend as if we are the friend who is paying our new friend some Mochimo. We preloaded our Mo Money address with MCM, to be able to send to our friend.

We have received the email with his address and placed that JohnStack.dat file in the same directory where we have our wallet, then we open our wallet. Now we need to import his “foreign” address. “Foreign” address simply means any address you did not create in your own wallet.

  1. From the main menu in the wallet we choose option 3.
  2. For now, we answer n to the Import foreign tag (y/n)? question. This will be addressed later.
  3. In our scenario, the answer to the next question of Import file name: is JohnStack.dat
  4. Enter a name for the Enter address name field, so you recognize what the address refers to. We will name it the same as the imported file: JohnStack
  5. This should import the foreign address into our wallet and give it the next index number in order. To find what index number was assigned and to see if we can see the balance of the address, we go to the second page of the menu with option 9, and choose 3 for Display foreign addresses.
  6. If our friend answered yes to the Write balance question earlier, we should be able to see that here, but more importantly for our purposes - we now know the index that was assigned to the new address we just imported. In our example, the index number is 2.

09-importAddress.gif

Sending MCM to our friend

  1. Now we are going to send our friend his payment! We go back to the main menu by choosing option 9 in Menu 2.
  2. We choose option 5 which is Spend address
  3. Next we choose an address index with a balance to spend from. In our example, we are going to choose index 4 which is the Mo Money address we setup initially and has been funded with some MCM
  4. After choosing the address we will spend from, we are asked to choose a destination address, and the wallet automatically will display your foreign addresses here in case you didn't remember the address you wanted to send to. We already know the index we want as our destination address (JohnStack) is 5, so enter that here. (We could also choose 0 here if we wanted to send the entire amount from our Spend address to a Change address that would go to yourself. For now, we will always choose a destination address.)
  5. Now we have to enter the amount to send. Careful here. The prompt says Enter send amount in Satoshi (or append c for Chi): and we want to send our friend 1.5 MCM. The easiest way to do this is to type out the amount in billions of Satochi that looks like this: 1500000000 No decimal points!
    1. (The wallet has a typo here. We use 9 decimal places and the correct unit for that is Satochi - not Satoshi)
      1. Helpful Conversion Table

Conversion-table.png

  1. The wallet will show you what you entered in Chi with the decimal placed correctly. Send amount: 1.500000000 And now we have to select a Change address, explained in the following section.
Error creating thumbnail: convert: memory allocation failed `/tmp/transform_b75afd3a7b9b.gif' @ error/quantize.c/QuantizeImage/2743. convert: memory allocation failed `/tmp/transform_b75afd3a7b9b.gif' @ error/gif.c/WriteGIFImage/1642. Error code: 1

Selecting an address for the Change

Note: Mochimo uses Winternitz One-Time-Spend (WOTS+) addresses. Each time you spend from an address, a portion of that address' secret is leaked to the public. For this reason, the wallet requires that you choose a Change address to send your change to. You should never re-use a spend address, and since we are about to spend from our mining address, that means we will have to create a new one...

  1. The wallet automatically shows you all available Change addresses here and gives you the option to Create another change address (y/n)? For this walk-through we are going to create a Change address on the fly by answering y to this question.
  2. Now we need to name our new Change address. Let's say: New Money
  3. Answer n to Add tag (y/n)?
  4. The New Money address will be created and it will give you an index number, for our example, it’s 6.
  5. It will ask you again if you want to Create another change address (y/n)? We’ll answer n here, because we’ve already created the one change address we need.
  6. It will now ask for the Change address index number, which is 6 for us (New Money Address).
  7. Here we are shown the fixed transaction fee of 0.000000500 MCM and asked to confirm our transaction. Everything looks good! Let's say y!
  8. If everything was successful, you will now see Sent!

10b ChangeAddress.gif

Confirm the transaction was sent

  1. We now wait for a block to clear and the MCM to be sent to our friend. You can keep an eye on the current block on www.mochimap.net (image below). At the top, you will see Best Block. Wait for that to update to the next block. Alternatively, you can also go to the Mochimo Explorer https://bx.mochimo.org.

Mochimap.png

  1. After the next block clears and assuming our friend shared the balance with us, we can go back to Foreign addresses to confirm the JohnStack address received 1.5 MCM.
  2. From Menu 2, select option 3 for Display foreign addresses and look at the JohnStack address balance.
  3. Everything looks good!

11b-ConfirmSent.gif

Additional Information for Miners

Miners will have mostly the same process with creating wallets, addresses, and sending/receiving. The main difference for miners will be in generating addresses for their miners to mine to.

Prerequisites:

Mining requires CUDA to be installed on the machine and port forwarding to be enabled on port 2095. Link to Mining Rig Guide | Link to Port Forwarding instructions

Generate a mining address

Follow the same steps in the 2.1 Create a new wallet and 2.2 Download a list of network nodes and start the wallet sections.

Let’s create a new wallet following the steps in 2.1 Create a new wallet and naming the wallet file mining.wal instead. Then open the wallet with the following command:

./wallet -p2095 mining.wal

You will be prompted to enter your password. If you enter this incorrectly, the system will not tell you, but the name at the top of the wallet when you open it be some garbled gibberish. The reason for this is the password is a decryption key and is not stored in the wallet itself. If you enter it wrong, the wallet will still decrypt using the wrong key, and the result will be garbage. You know you entered it correctly if the wallet name you chose displays at the top of the screen. In our case, we’ll see My Wallet at the top.

  1. First, create a new address with option 4.
  2. You must give it a name here, let's use mining address.
  3. You will be asked if you want to "tag" this address, say N.

WARNING: YOU MUST *NOT* ADD A TAG TO A MINING ADDRESS.

  1. If you are using the most recent version of the wallet, you will be asked if you want to "Tag" this address (Learn about Tags here), for this part of the guide, let's say N
  2. This address will be assigned an index sequentially higher than your last address. If you don't have any addresses yet, this would be index 1.

M01-minerAddress.gif

  1. Let’s check to make sure the address was successfully created. Select option 2, to display your address entries. If you don’t have any coins yet, “My addresses:” will read “No entries.”
  2. Select option 6 to check the balance on this new address. If you don't have any coins yet, the wallet will read No entries.
  3. To check that the address was created, select option 9 to go to Menu 2. Then select option 2 to display change addresses and you should now see mining address.

Exporting your mining address

Now let's save this address to a maddr.dat file the miner uses, so that we can start mining and have our block rewards go to this address.

  1. Select option 7, to export. You will be prompted to select the index number of the address you want to export. In this case it will be index 1, since it's the only address you have. Type 1 and hit enter.
  2. You will be prompted to select a file name. The file has to be named: maddr.dat
  3. You will be asked where to save the Balance. Please select N.
  4. If you are replacing a mining address, you will be told that maddr.dat file already exists. If you are asked, enter Y to overwrite the old mining address with your new mining address.
  5. Now type 0 to exit, and go invoke your miner.

You are ready to mine!

M02 createmaddrdat.gif

Replace your mining address

If you plan to spend from your mining address, when you create your change address in the 4.3 Selecting an address for the Change section, you will need to set the change address as your new maddr.dat mining address following the steps in the 5.2 Exporting your mining address section. When you are done with that, you should have a new maddr.dat file in the mochimo/bin/ directory. You will also need to copy the new maddr.dat file to the mochimo/bin/d/ directory on our miner.

The Mochimo Tag system

Do not Tag a mining address
The method described above to send you address to your friend so that he can send you Mochimo is less than ideal. Thankfully, the WOTS+ addressing contains space for a 12 byte address that can be transferred from one address to another. The way we have this implemented, all you should really have to do is remember your tag. Then you can just drop your 24 character tag to your friend via text or Discord and they can import that foreign (to them) tag into their wallet, and then send to it. Easy!

For the moment, we would suggest using the GUI Mojo wallet if you want to use tags. Check out the Mojo Quick Start Guide on the Mochimo Wiki. :)