Difference between revisions of "Command Line Wallet"

From Mochimo Wiki
Jump to: navigation, search
(The Mochimo Tag system)
(Create new installation script)
Line 20: Line 20:
 
export set CC='cc -DUNIXLIKE -DLONG64'
 
export set CC='cc -DUNIXLIKE -DLONG64'
 
echo Building wallet...
 
echo Building wallet...
$CC -c sha256.c 2>ccerror.log
+
$CC -c crypto/sha256.c 2>ccerror.log
$CC -c wots/wots.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
 
$CC -o wallet wallet.c wots.o sha256.o 2>>ccerror.log
 
echo Errors logged to ccerror.log
 
echo Errors logged to ccerror.log
Line 27: Line 27:
  
 
Now save and exit from nano by doig a <code>Ctrl-o</code> then <code>Enter</code> then <code>Ctrl-x</code>
 
Now save and exit from nano by doig a <code>Ctrl-o</code> then <code>Enter</code> then <code>Ctrl-x</code>
 +
 
===Now, run it!===
 
===Now, run it!===
 
Now we can run the script by typing <code>./makewal</code> at the terminal inside the <code>mochimo/src/</code> directory.</br>
 
Now we can run the script by typing <code>./makewal</code> at the terminal inside the <code>mochimo/src/</code> directory.</br>

Revision as of 11:34, 19 January 2019

The CLI wallet started life as a dev tool. And since it functions perfectly and fills it's purpose so well, it became the official wallet in the early days of the project.

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

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. cd ./mochimo/src touch makewal chmod +x ./makewal nano ./makewal 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

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. Let's make a bin directory, and move the binary over there...

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

We should now be in the bin directory.
That's it! program installed :)

Running for the first time

Create a new wallet

To start, from the mochimo/bin/ directory, invoke the wallet with the following command:

./wallet -p2095 -n
  1. You will be prompted to choose a name for your wallet.
  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.
  4. You will be asked to pick a filename. We recommend mochimo.wal.
  5. The wallet file is saved to disk and the wallet software exits.

Generate a mining address

To avoid getting a ***Balance check failed*** error, we may need a startnodes.lst file. 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.

  1. From the main menu, select option 4 to create an address. You will be prompted to name it. We suggest calling it "mining address".
    WARNING: YOU MUST *NOT* ADD A TAG TO A MINING ADDRESS.
  2. Select option 2, to display your address entries.
  3. 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."

Exporting your mining address

Now let's save this address to a file, 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!

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.

  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. If you have been following this guide, this would be 2.
  3. If you are using the most recent version of the wallet, you will be asked if you want to "tag" this address, for this part of the guide, let's say N
  4. 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.

Finding your address index

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.

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. Choose option 7 for Export address
  2. Now you must choose the index # for the address you wish to export. If you are not sure which is the correct index, then see the previous menu item in this wiki
  3. 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
  4. 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.
  5. If you answered the previous question in the affirmative, this will be the next question. If we answered in the negative, we will not get this question: Wite 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 answern.

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

Send your first transaction

For this part of the walk-through, we are going to pretend as if we are the miner friend who is paying our new friend some Mochimo. We have received the email with his address and placed that myStack.dat file in the same directory where we have our wallet, then we open our wallet. Now we need to import his address.

Importing a foreign address

  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 myStack.dat
  4. 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.
  5. 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. For demonstration purposes, let's say this is index 3.

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.
  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 1 which just happens to be our mining address. This is going to cause a small issue that we will take care of in the next section.

Selecting our imported address

  1. 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 is 3 so enter that here. (We could also choose 0 here if we wanted to send the entire amount from our Spend address.
  2. 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 5.1234 MCM. The easiest way to do this is to type out the amount in billions of Satochi (The wallet has a typo here. We use 9 decimal places and the correct unit for that is Satochi - not Satoshi) that looks like this: 5123400000 No decimal points!
  3. The wallet will show you what you entered in Chi with the decimal placed correctly. Send amount: 5.123400000 And now we have to elect a Change address.

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 mining address
  3. Answer n to Add tag (y/n)?
  4. The wallet will now attempt to display all of your designated change addresses, and now we should see our New mining address displayed. Let's select it's index which we will say is 4

Confirm the transaction

  1. Here we are asked to confirm our transaction. Looks good! Let's say y!

And we're off! Now we should wait for that block to clear by keeping an eye on www.mochimap.net

Replace your mining address

But, while we're waiting on the block to solve, we need to take care of our mining address. If you forget this step, and your miner solves a block, you will still get the mining reward in your old address and it will show up again in the wallet with a balance. Everything will be fine... But you have exposed a part of the secret for that address and you really should replace the file. Above we named the change address from the MCM spend to our friend as New mining address. Let's make that our - well, new mining address :) To do this, just follow the instructions from above in 2.2.1 for Exporting your mining address. When you are done with that, you should have a new maddr.dat file. To update our miner, we need to copy this file into the mochimo/bin/ directory and 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, I would suggest using the GUI wallet if you want to use tags :)