User Tools

Site Tools


Accessing encrypted wallet

If your wallet is encrypted, before you can make any transactions, you have to unlock you wallet. Unlocking of the wallet happens for a given amount of seconds. Once the time expires, the wallet locks automatically.

Unlocking the wallet:

litecoin.walletPassPhrase('mypassphrase', 60 * 10, function(err) {
        return console.error("Error:",err);

Locking the wallet:

litecoin.walletLock(function(err) {
        return console.error("Error:",err);

If you want the wallet to be unlocked for the duration of your program execution, I suppose you could do something like this:

function unlock_wallet() {
    litecoin.walletPassPhrase('mypassphrase', 60, function(err) {
            return console.error("Error:",err);
        setTimeout(unlock_wallet, 50); // 10 sec less then wallet unlock time

The above function will reschedule it's execution with a timeout less then the wallet unlock, keeping it unlocked for a period of a minute. If your program stops, the wallet will lock itself automatically within a minute.

Best security practices

I am not an expert on security, so I will say only the following. If your wallet is unlocked and a hacked get possession of it, your funds are gone. If your wallet is locked, but the attacker gets a hold of your software, your funds are gone (because he will be able to unlock the wallet).

There is just no escape! :)

I personally prefer to design systems in a modular fashion, so that the module that does transaction processing is located on another system, maybe even behind NAT / firewall. This module can connect to your front-end server and react to it by receiving JSON RPC commands from it.

Another approach, if your system requires only reception of funds, is to re-send these funds once you receive them. You wait for 1 confirmation and send send the funds to another address that resides in the wallet off-site.

Exchanges usually keep funds in cold storage - in the wallet that resides on an external storage device or a computer that is powered off. When the system reaches an upper threshold, funds can be forwarded to these addresses. When they see that they require additional funds, they activate the offline wallet and forward funds back to the main address used to send funds to users.

This practice has saved BTC-E during the hack in 2012, when a hacker was able to compromise Liberty Reserve connection, sending himself millions of fake USD, with which he bought up almost all BTC on the exchange and then sent these BTC to himself. Two things happened, exchange limits kicked in, limiting the amount of funds that could be sent, and the main wallet quickly ran out of funds.. because most of the exchange funds were stored in cold storage…

Do not ignore this. Crypto currency transactions are irreversible. Crypto currency algorithms can not be compromised, but computers can. Your system is only secure as you make it.


test120.144.182.203, 2013/04/15 00:45

Hi, i recently bought some LTC's from, and i then sent them to my encrypted litecoin wallet.

Now every time i load my wallet, it shows a zero balance. I tracked the transactions on the website, and i can see they are still there, but how do i access them? I tried my back up wallet that i had set up earlier and still nothing. Its like the wallet is no longer loading the block chains needed. Your help would be greatly appreciated, thank you.

Regards, Garth Williams.

aspect, 2013/04/15 14:24


It sounds like your problem belongs to #litecoin on IRC, litecoin forums, or /r/litecoin on Reddit as it is not really related to development.

I can only recommend to try the following.\\1. Make sure you have disk space and that your entire blockchain is completely synced.\\2. Run litecoind -rescan to rescan the blockchain against your wallet. If due to some problem litecoin wallet is not up to date, rescan will analyze the entire blockchain and update the wallet if there are any transactions against it's addresses.

Wallet encryption ONLY encrypts your private key - which means that to see transactions and balance encryption does not matter. Encryption only kicks in when you need to send funds (as this is when the private key is needed).

Enter your comment. Wiki syntax is allowed:
tutorials/accessing_encrypted_wallet.txt · Last modified: 2013/04/11 23:24 by aspect