Brad Lucas

Programming, Clojure and other interests

Run A Command In Each Sub-Directory of a Directory

August 23, 2017

If you ever want to run the same command in each sub-directory of a directory consider the following example.

Replace the value for COMMAND with your own command.

$ COMMAND=pwd
$ for d in `find . -maxdepth 1 -type d`; do pushd > /dev/null $d; $COMMAND; popd > /dev/null; done

Or setup your own command by putting the following in your .bashrc file.

Continue reading →

Wait For An Ethereum Transaction To Be Mined

August 22, 2017

Working with testrpc hides you from one reality in particular when working with a blockchain. That is that sometimes the time to finish a transaction can take some time. The mining to fully realize the transaction not only has a cost in ether (for Ethereum) but a cost in time as you wait for your transaction to complete.

Moving your application to the testnet will show you this right away. Now, when you have this happen you'll start to wonder how to handle something like an update to your screen after the transaction is complete.

Here is a pattern that works using a function listed below that gets the promise of an Ethereum transaction when it is mined.

You call your sendTransaction then pass your transaction hash into getTransactionRecipteMined with a then in which you have your function to update your UI.

Continue reading →

Change Ethereum Account Password

August 21, 2017

If you need to change one of your Ethereum account passwords using Geth you'll find the account update command will work.

If you are running your node on the testnet make sure to pass in the --testnet flag.

Here is a sample session:

$ geth --testnet account list
Account #0: {634b8e79b0155e5ac1303c2fe4b1d30f2fc6b930} keystore:///Users/brad/Library/Ethereum/testnet/keystore/UTC--2017-03-13T18-48-40.744428053Z--634b8e79b0155e5ac1303c2fe4b1d30f2fc6b930

$ geth --testnet account update 634b8e79b0155e5ac1303c2fe4b1d30f2fc6b930
Unlocking account 634b8e79b0155e5ac1303c2fe4b1d30f2fc6b930 | Attempt 1/3
Passphrase: 
INFO [08-22|11:40:45] Unlocked account                         address=0x634b8e79b0155e5ac1303c2fe4b1d30f2fc6b930
Please give a new password. Do not forget this password.
Passphrase: 
Repeat passphrase: 
Continue reading →

Run Geth Node With Multiple Unlocked Accounts

August 20, 2017

There is a bit of a trick to run a Geth node with multiple unlocked accounts. It has to do with how to pass in the parameters.

There are two parameters to focus in on. The unlock and the password.

The first, the unlock accepts a list of accounts or a list of indexes into your account list. To keep you command line short you can, for example, pass in "0, 1" to unlock your first two accounts.

Next, you need to get your password passed in if you are starting geth from a script. The way to do this is to put your password in a file and pass that file in through the password command.

Continue reading →

Multiple Geth Instances Warning

August 19, 2017

A point to remember when developing using geth locally. If you end up with multiple geth instances running you will get confused. Here I was running a geth instance in the background under screen. Today, not remembering it was there I started testrpc and then got the following error.

Error: Error: could not unlock signer account

So as a suggestion do a ps aux | grep geth once in a while.

Continue reading →