Saturday 28 February 2015

Bitcoin Cold Wallet for ∼ $30 in less than 5 minutes

Project duration: 30 minutes
Components cost: $30

Required Components: Raspberry Pi, USB keyboard and mouse, HDMI connection to display, 4GB+ microSD.


Intro


I had spent recently some hours finding a way to install Bitcoin Core to my Raspberry Pi 2 B+ but I was unable to achieve it due to dependency on a lot of packages, that I couldn't figure out. I decided to start from scratch and build from raw source to find out which packages are missing. Somehow I got to the point, where the error of missing package was not really clear and the .log file didn't provided more enough information. And to be honest, I am not Linux OS ninja at all.

For those who are interested in installing Bitcoin Core, here is the list of packages needed to successfully install bitcoind command line. 

  • Autoconf - for automatically configuring packages. 
  • GNU M4 - version 1.4.6 is recommended
  • Automake - for automatically generating Makefile
  • Libtool 
  • Any C++ compiler - I recommend build essential that would install all necessary dependencies.
Remeber: Do not forget that Raspibian OS is based on Debian Wheezy, so any time you are downloading package, look for wheezy version.

Fortunately, there is more elegant way to turn your Raspberry Pi to bitcoin cold storage, that does not require any command-line skills.

Those, who would like to build Secure Bitcoin Cold Storage and do not have enough Linux skills may follow the guide.

Start


I assume that you already have your Raspberry Pi ready and can have access GUI of Raspbian. For those who need help with first boot, follow the tutorial from raspberrypi.org.

Bitcoin Armory is a Open Source Bitcoin Wallet Management software that we will be using for purpose of building cold wallet.

First step you need to do is go to bitcoinarmory.com/download and get the latest version of [Offline Bundle] for RaspberryPi

Once you download this file, transfer it to USB stick and plug it into your raspi. Copy the armory_0.93_rpi_bundle.tar.gz to /home/pi.

Right-click the file and select Extract here, you should notice that new folder OfflineBundle was created.

One command line and execute the following:

cd OfflineBundle  
sudo dpkg -i *.deb

and wait until the installation of required packages finishes.

If you enounter: dpkg: error: requested operation requires superuuser privilege you are missing the sudo command

Note: It might finish with several dependencies that were not installed such as python-twisted, python-twisted-mail, this does not affect the wallet generator.

In File Manager navigate back to OfflineBundle folder and double-click Install_DblClick_RunInTermina.py and select Execute in Terminal. Several pop-ups notifying you about Granted permissions will appear and you may Close them.

New icon will appear on Desktop. Next step is to start the Armory and create new wallet with Passphrase and a key-pairs.

Create paper backup of key pairs and root key: Wallet Properties>Backup this wallet>See other backup options>Export Key Lists

Remember: For safety purposes, you shouldn't connect your Raspberry Pi to Internet connection while wallet data are stored, in order to prevent access breach!

Once you have the paper bacup, you may format the SD card and continue using Raspberry Pi with Ethernet cable.

Tuesday 22 April 2014

Auto-update clients .NET applications

Project duration: 2 – 3 hours
Requirements: FTP server/Cloud storage

Recently I got bored of copying all the exe files through remote desktop to that few clients of mine that own my applications. I thought that it might be a smart idea to let them know about new version of their application that was just published. So they can directly upgrade without any sign of communication just as professional software does.

In my mind I already had mind model of the little window that will pop up each time new version is available to annoy hell out of them until they finally upgrade. With details what is being upgraded, fixed or extended in new version. Yes, great but how to do that - what are the options?

ClickOnce


Fully automatized tool from Microsoft as a build-in extension in Visual Studio 2012, pretty handy tool, in which you don’t need to take care about a lot of code. Basically what you do is set the path to your FTP or normal server, configure rest of the conditions and let the ClickOnce do the magic with deleting and replacing.

I would truly like to use this tool but not this time I need also to update my database structure – add/edit column properties, create stored procedures, a lot of work around SQL.

NetSparkle

          NetSparkle is a opensource software that has been reviewed by 4 people and downloaded by 6425 (by the time of writing).

No support for DropBox or other Cloud storage – This way I won’t need any FTP servers to download the file(s) from – potentially the best way for people who don’t have a domain with FTP server registered. (Can be mixed also with DO IT MYSELF solution). 

Do it myself

Guide that helped me so much to realize my vision was published on YouTube as a series named C# Auto Updater Library by guy who calls himself BetterCode. It would be stupid from me to just copy his work here with my explanations so here is the link.

Basic algorithm:
  1. Store an XML file on FTP server with information about new version, details of current version, MD5 hash, link to exe download.
  2. Download XML and check whether node “version” is newer than currently running application.
  3. If so follow the node “download link” to get exe as temporary file into client’s computer.
  4. Use background worker and cmd to do the replace and turn app on again work for you.


Project implementing/coding:
  1.  You need to have 2 separate projects in your .NET solution. First represents your main application distributed the clients second is an extension and library for auto updating that would contain mostly classes, interface and forms.
  2. Place XML containing newest version file on FTP server.
  3. Check current client’s app version versus FTP version.
  4. Download the exe file from link embedded in node of XML file, store it as temporary file.
  5. Get other child nodes containing SQL Database scripts e.g.
  6. When having everything downloaded from XML/FTP you will run this amazing code in cmd which is the only one that I will mention here from BetterCode and explain
/C Choice /C Y /N /D Y /T 4 & Del /F /Q \"{0}\" & Choice /C Y /N /D Y /T 2 & Move /Y \"{1}\" \"{2}\" & Start \"\" /D \"{3}\" \"{4}\"


  • Choice - accepts keyboard input to a batch file
  • deletes the old file in specified path {0}
  • waits 4 seconds
  • copies file from temporary files {1} to the specified path {2} 
  • waits 2 seconds
  • runs the file {4} in specified directory {3}
Parameters:

  • {0} - currentPath
  • {1} - tempFilePath 
  • {2} - newPath 
  • {3} - Path.GetDirectoryName(newPath) 
  • {4} - Path.GetFileName(newPath)


Visit http://ss64.com/nt/ for command line arguments information.


Setting the scene

In the time you are reading this blog you probably have gone through all of the boring parts of learning the syntax and very basics of programming and if not and you are a beginner that is looking for guide/tutorials for programming in this case I would recommend you to just keep searching on through the internet until you find tutorials that are comprehensible and friendly for your style of learning. There are several ways how to start learning programming.

  • books
  • tutorials/videos
  • learn by observing the code

I will try to post here as many articles as I can to let you know what I'm currently working on - with snippets of latest codes, explanations, short guides. I will be mentioning ideas that amazed me and current trends. 

What I find fascinating about programming?


For me programming means thinking with consequences - realizing aftermaths of your acts, thinking deep into the particular issue - analyzing the requirements, understanding the problem, finding its solutions and the Know What You Are Doing attitude really drives me. 

Or in some cases we just write few lines of code then hit the Debug button, cross fingers and start guessing what would happen when the debugger finishes building of our late night thoughts, Will it work? Do I need to ask this on SO? Usually it ends up with - oh no! just another missing ; syntax error..

Honestly now, mostly I like programming because it challenges me. It pushes me to the edges it tells me - "hey you moron, you cannot code this part without knowing how sockets and the network programming works". Programming knowledge never ends but it could end you when you become too lazy to read and study about new trends. 

Programming gave me the lifelong attitude not to sacrifice myself with only the nice shell of a thing I like or I promote. I just love to know what is inside the shell how and why it works this way - to understand the whole issue not just the cover.