Rebalancing lightning channels after a lightning liquidity swap

Well done, you have participated in a lightning liquidity swap and all channels are open (future post about how to actually do the swap and common problems).

Now you should see a new incoming channel and a new outgoing channel. The incoming channel will have all the liquidity remotely and your outgoing channel will have all the liquidity locally.

This means that no lightning payments can be routed via you. You have to balance those channels to have 50% local and 50% remote liquidity.

In summary your will pay yourself half of the channel capacity and route the payment through all the swap participants. This will result in all channels in the swap to become 50/50 balanced.

triangle swapCase 1: Now for a simple triangle swap, where there are only two other participants, you can use the plugin Thunderhub or Ride The Lightning (RTL) to perform this payment.

Select the node you connected to as Outgoing. You should see 100% blue bar, this means the balance is all on your side (local).

Select the node that connected to you as Incoming. You should see a 100% green bar, this means that the balance is all on the other side (remote).

Thunder Hub rebalance channel dialog

Set the fees to something you are comfortable with, perhaps 100 for each field.

 If your swap participants have done their job they have lowered all fees to 0 and the rebalance should be free.

Set the amount to Fixed and half the channel size (or slightly less if you get liquidity problems).

Hit rebalance!

Pentagram swapCase 2: For any more complicated swaps like a square (4 participants) or a pentagram (5 participants) you will have to build an exact payment route through all the participants to do the balancing correctly (and cheaply).

You still want to pay yourself half the channel size but it has to go out to the node you connected to, then via each participant in the correct order, and then back in via the node that connected to you.

You will have to use the lncli command after you SSH to your node to perform this more complicated payment.

Some swap sites like will prepare the correct route for you already. Please start by running the provided command to test whether the route works correctly:

lncli buildroute --amt [AMOUNT] --hops 1a613234234116def5de68...,7243578234df738...,87827ea233...,014aea43432244...,0a34324445...

Replace the example hops with the actual public keys of the nodes in your swap.

If all is well you will get a json output with a prebuilt route and the cost for this transfer:

"route": {
"total_time_lock": 715773,
"total_fees": "4",
"total_amt": "1250004",
"hops": [

If the fees seem too high then you should start a dialog with the other swap participants to lower their channel fees. Skill levels of the participants varies widely and you may need to assist them.

You can now prepare an invoice which will be the payment to yourself since the routing appears to be successful:

lncli addinvoice --amt [AMOUNT]

This command will return you a PAYMENT_ADDR and a R_HASH that you have to use in the below step.

You can now run the command provided by your service that will in a single line build the route using lncli buildroute, add a multi-payment record (mpp) using the jq utility and then send the payment using lncli sendtoroute:

lncli buildroute --amt [AMOUNT] --hops 1a613234234116def5de68…,7243578234df738…,87827ea233…,014aea43432244…,0a34324445… | jq -r '(.route.hops[-1] | .mpp_record) |= {payment_addr:"[PAYMENT_ADDR]", total_amt_msat: "[AMOUNT]"}' | lncli sendtoroute --payment_hash=[R_HASH] -

You can also construct the hops manually by hand by starting with the node you connected to, traverse the participants one by one and finishing with the public key of your own node.

If all goes well, you should get a SUCCESS result code and also information about the total fees paid.

Congratulations, you are now balanced!

Common problems with liquidity rebalancing

Not all channels have been set up.

The swap participants are reporting that they all have opened channels but how can you be sure? The lncli buildroute command is a quick way to test that the route is correctly set up.

Private channels

If a swap participant accidentally created a private channel instead of a public one then the liquidity swap will not work.

Not enough liquidity in existing channels

A participant can accidentally crate a smaller channel than specified.

I have also seen cases where participants already had existing channels with the other participants so they didn’t feel like creating additional ones.

This will however break the swap as the liquidity in the swap is less than was specified. Rebalancing will not work for example.

Remote node is down

You are unable to open the channel and you see errors like 503, 'FailedToSuccessfullyConnectToRemotePeer'.

This is likely due to the remote node being down, having TOR configuration issues or other resource problems. A restart of the remote node often helps.

Divide the channel opening process into two steps: 1) connect to the peer first and 2) open the channel with the existing peer

Node not accepting the specified channel size in the swap

A node can be misconfigured to only allow chanel size above a certain size… a size that is larger than the swap. Often this is due to am extra zero in the required channel size.

Blockchain reorg

Luckily this hasn’t happened to me but there is a theoretical scenario where the open channel has only one confirmation and due to blockchain reorg that transaction becomes void. Wait for a few confirmations before using a newly open channel!

You are using Umbrel and thus LND in a Docker container. You get the error “The input device is not a TTY”

Umbrel is popular Lightning node operating system. If uses docker container for many of the require services, such as lncli. This means you don’t have direct access to lcnli and linux “piping” between processes doesn’t work.

Split the routing command into two steps:

lncli buildroute --amt [AMOUNT] --hops 1a613234234116def5de68…,7243578234df738…,87827ea233…,014aea43432244…,0a34324445… | jq -r '(.route.hops[-1] | .mpp_record) |= {payment_addr:"[PAYMENT_ADDRESS]", total_amt_msat: "[AMOUNT]"}' > path.txt

lncli sendtoroute --payment_hash=[R_HASH] --routes="$(cat path.txt)"

“not enough witness outputs to create funding transaction”

You are opening a channel and you have enough funds in your on-chain wallet but you still get this error.

Some of your utxo are probably unconfirmed and you cannot spend them even though they are showing in your total balance.

You probably have some chennels pending. There are unconfirmed payments to yourself as part of it.

Wait until all channels are confirmed and all funds should be available again for new channel opening!

Extended attributes are required when transferring domain with NameCheap

Recently I tried transferring a domain that I owned to another NameCheap user.

The internal transfer of NameCheap domains is usually easy and instant but this time the other user was complaining that the transfer was failing. The error page suggested a few missing details in the user’s contact details:

Missing registration details

Fixing the missing State was easy enough but we couldn’t find extended attributes so we just tried again and got this:

Missing extended attributes

The exact error was “Extended Attributes: .UK domains – Company or Domain Registered for is required”.

NameCheap allows adding Extended attributes to various regional domains in “Profile > Tools > Domain Contacts Presets > Alternative Domain Contacts“.

However .UK is not one of them. There was no way for the receiving user to be complaint for a .UK domain.

After a few chats with the very responsive NameCheap Live Support the root cause became clear and a workaround was suggested.

First the initiating party had to cancel the domain transfer request.

Then rather than using the usually recommended “new user’s contact details” during the transfer, we had to use “existing contact details”. This allowed the transfer.

Then once the transfer was successful the user changed all details to theirs… including the “Company or Domain Registered for”.

You may be tempted to leave the contact details with the old information but I recommend against this to avoid confusion of ownership… and perhaps breaching .UK domain registration rules.

I wish NameCheap would enhance their Alternative Domain Contacts functionality by adding options for .UK domains!

Rescuing jackdaw chicks and being rewarded with love

The rescue

We found two jackdaw chicks in our garden and the parents were nowhere to be seen.

It was obvious that they were too young to fly and the nest nor parents were nowhere to be seen.

We could have left them to fight for themselves but our motherly instincts kicked in.

The feeding

After housing them in our cat’s old cage we tried feeding them but they were too distressed to be interested in anything.

After 2 days of no food we were getting very worried and researched what to feed them.

Peanut butter, worms, cat food… We tried everything.

I randomly made kissing sounds and they got very excited. They started crowing and opening their beaks fervently.

Finally it was possible to feed them. They seemed to prefer tuna flakes and were now feeding every hour throughout the day.

We also used a large plastic syringe to give them water.

After 5 days of feeding they had become very comfortable with us and had become very cuddly.

They enjoyed our presence and to walk around our arms.

By now they were cleaning their wings frequently.

Flight training

Flight training begins

We discovered that if we lowered our arm while they were sitting on it, they were flapping their wings. It was almost as if they were testing their strength.

Suddenly they took off and flew a few meters to sit on a ledge.

Our jackdaw flight training had officially started!

Over the next few days we continued with frequent feeding and flight training.

4 days later they were able to fly 100m and sit in a tree for a while.

They always came back to feed and to socialise with us.

Next step was to teach them how to feed themselves.

We took them to a flower garden with soft ground and dug around a little bit until we found worms. It took the jackdaws a few moments but they got the hang of finding the worms and to chomp on them.

Hunting food for the first time

This made us very proud jackdaw parents indeed!

It’s now day 10 and the daily routine is to take them out of their cage early in the morning, feed them, socialise and continue flight training. 16 hours a day!

Come back to hear the rest of our jackdaw adventure!

Happy bird mom

404 errors from admin-ajax.php in WordPress

I am developing a dynamic website and when I stress some of the dynamic functionality I am getting occasional 404 errors from admin-ajax.php.

I am currently developing a minor dynamic website. Towards the end of the development I was stress-testing some of the dynamic functionality.

Unfortunately I am getting occasional 404 errors from admin-ajax.php.

The request seems to be sent and processed because on refresh of the page I can see the updates. However it is a bad user experience because the user’s page just stalls.

After a little troubleshooting, mainly with crude debug statements from admin-ajax.php into HTTP headers, I have noticed that admin-ajax.php is not even entered.

At the moment I am not sure whether the error is related to one of the WordPress plugins I am using or whether it is due to my webhost.

There are no visible errors in weblogs nor in error_log.

One thing I noticed that a new incognito browser window resolved the issue.

This made me suspicious of cookie issues. I manage to narrow it down to the PHPSESSID cookie. Clearing it resolved the issue. The 404 error from admin-ajax.php is gone… for a while at least.

I recommend using the excellent Eat This Cookie extension If you are using Chrome or Brave browser.

The search continues…

Presence or productivity… that is the question

I was born in a communistic country and was just about old enough to see how employment generally worked. The key attribute was presence at the workplace.

It did not matter how much you did, or if you did anything at all. The pay cheque was always there at the end of the month.

This was the first thing that came to my mind when a friend mentioned that her company had retracted her previous partial home office arrangement and required that she’d be at her desk full time.

I assumed that her performance had possibly been lower while working from a remote location. However she insisted that she had never been more productive. Instead it had been the other staff in her office that had complained.

They were upset that she had a special arrangement and wanted it too. Like the bullies at the school yard who saw someone with a shiny marble and if they could not have it then at least they would crush it.
It did not matter that my friend was working partially from home to be close to a family member who was ill, the other staff were just upset.

She had previously told me about the poor working conditions in the office. I suggested that maybe that was the main reason why other staff in the office also wanted to escape: not for the benefit of working from home but for the benefit of staying away from the office.

Finally my friend asked me what my advice would be and I told her the first thing that came to my mind.

Quit and find a real company that values results and is not run by second-tier staff who are first grade champions in office politics.

Photo by k2space.

Super efficient in-the-field SLR photography workflow

You are probably reading this because you take multiple photos of each scene and situation to make sure at least one will turn out sharp and well exposed…. Well I do!

Modern cameras have huge memory cards; 128GB isn’t uncommon. While this is very convenient it also creates massive amount of unnecessary data.

You end up with hundreds of photos (if not thousands) while “in the field” or any other situation without access to a computer to offload the photos.

This could be while on a holiday, on a multi-day shoot or if you simply don’t want to transfer all those photos only to delete them shortly afterwards.

100% zoom is your friend. Use it in combination with easy scrolling to weed out any obvious duds. Look for sharp eyes, open eyes, no unwanted motion blur, overcropping (a missing foot or arm), good composition and faces actually facing the camera.

Lock the good photos to narrow down to 1-2 photos for each subject/scene.

Delete all” to quickly weed out the unwanted shots. This will delete all unprotected photos leaving you with only the good ones. I aim to delete half of the photos in my first pass. I sometimes do a second pass to delete another half.

Do not use the format function as this will also delete the protected photos!

One downside with this workflow is the larger battery drain since the screen is on for a long period of time.

Well done! Now you only have a quarter of photos to transfer to your computer and further work on in Lightroom!

Quik using Google photos and resolving app crashes

I love the GoPro Quik mobile application to create video and photo compilations from trips and events.

First I tried downloading all the items from Google Photos to a computer but the desktop version of Quik is nothing like the mobile app so don’t even try it. I then uploaded all the items to the mobile but Quik has a display bug and only showed 40 or so items from the same day and I wasn’t able to select all the required items.

In the end I was able to figure out a workflow that makes it possible to use older and shared photos that aren’t on your device. The functionality is a bit buggy but I was able to find workarounds for everything.

1. Create an album with the photos and videos you would like to use for your compilation. Curate and select just the items you would like to be in your Quik compilation.

2. Optional step: The “+ create a new album” option will not be available if you are using photos added by others. Instead you will want to use the Share button so that a link to your new album is created (make sure to save the link!). The album is not visible in your albums so use the link in a browser and this should open the album in your Google Photos app. Edit the album and give it a name. Also select to “show in albums” to make it visible in your Google Photos albums.

3. Open the Quik app and select to use Google Photos. Your new album should be listed. You may get errors such as “Google Photos is not available”. If you do, close the Quik app and try again… and again.

4. Select all photos by ticking all the days. Since you have already curated your items you can just select everything.

5. Hit the blue arrow and Quik will start downloading everything to your device.

6. The Quik app will then crash continuously when it tries to edit the compilation.

7. Delete the project (Quik will crash again), start a new project and select all items again from the Google Photos album. This time the download will be almost instant and editing of the compilation will work.
8. Once done, export and upload your compilation back to Google Photos so that you can easily share it with friends and also so that you will never lose it if/when you lose your phone

Other tips for Quick:
  • Select “high quality” to produce 1080p videos that look great on a TV.
  • Crop tall videos to include the important areas, for example people’s faces.
  • Use the focus point option to select what to show in photos
  • Duplicate any tall photos and use different focal points to show everything in tall photos.
  • If you have many items in your compilation then modify the duration of the compilation to the maximum of your selected music to have more time on each item.
  • If a photo that you like just flashes by you can change the duration to longer to see more of the photo (or to shorter if you want to see less of it).
  • Trim videos and select “manual” to choose what parts of a video you want included. Split the video if you want to show multiple bits from it.
  • Using “Highlights” can work better on longer action videos
  • You can mute your video sound if it doesn’t mix well with your selected music
  • Turn Outro off to remove the Quik logo at the end of your compilation (it gets old quickly).

Enabling new Google photo face and people search in UK, Europe, Germany

gp_logo.pngGoogle Photos was re-launched recently during a slick presentation at Google I/O 2015.
Besides the unlimited storage for 16MP photos and 1080p videos what caught my interest the most was the demo of the face and people search.
The new product was not only able associate photos of the same person, it was also able to do it across a large age span of the person.
google_photos_people_face_searchSome reported examples are “it associated photos of my niece starting with her current age of 6 years and all the way back to 3 months old” and “it was able to discern our twin daughters”.
So imagine my disappointment after upgrading to this latest Google Photos version, backing up my entire photo catalog (30,000+ 16MP photos) and not being able to find the face/people search.
I suspected some European or UK privacy laws being the root cause why Google hasn’t enabled it in the UK and a few searches later my suspicion was confirmed.
Since it seemed to be geographically restricted I was curious to see what would happen if I tried the application from another location.
Virtual Private Networks, a.k.a. VPN, are very handy to make your internet traffic to appear from a different location than you are.
All your traffic is tunneled to an exit point of your choosing, for example a data center in New York City. To Google Photos service you then seem to be located in New York City, USA.
tunnelbear.jpgOne such easy to use VPN service for android is Tunnelbear but there are many others. Tunnelbear offers 500 MB of free traffic and you don’t need much more than 20MB to get this set-up.
It worked, I got face/people search in my Goole Photos android app and this is how I did it:
In summary you want to delete the Google Photos application data and re-start the application while being connected to the VPN. This will trick Google Photos into believing you are located in US and the feature will be switched on.
Once the feature is switched on you don’t have to re-connect to the VPN; the feature will remain on!
Detailed instructions: delete the data from Google Photos, turn on airplane mode, turn off location services, connect via Tunnelbear, start up Google photos, go through the introductory 4 steps, go into settings and turn on “Group Similar Faces”. Success, you now have your photos organised by many, many different people present in them.
The face categorisation appeared as soon as I connected via VPN. There was no initial time for google to build up a face database for my photos.
This really seems to suggest that all photos added to Google Photos are categorised by face. The search feature is just hidden in certain geographical locations to comply with local laws.
Is this really in the spirit of the law or just cheat? You decide!

Securing your bitcoins in offline storage

There are various levels of security that you can apply to your bitcoins. A specific level of security should be applied depending on the size of the stash.
A mobile or online wallet is often sufficient for smaller sums that you intend to be using for online trading or online purchases. I would still recommend enabling 2 factor authentication for any online wallets and avoiding rooting or jailbreaking your mobile when using mobile wallet.
However the ultimate security for your bitcoins is a wallet that is completely disconnected from the internet and as such unreachable by hackers.
Such wallets are commonly called offline wallets or cold storage and some concrete examples are paper wallets, other physical media, USB hard drives and upcoming dedicated hardware devices.
I’d like to talk about encrypted paper wallets because they appeal to me the most as a cold storage due to their simplicity and the low cost of creating them.
The common theme when creating offline wallets is that any device used to create them has to be offline and the wallet itself can never be connected to an online device until you plan to spend the bitcoins it contains.
An offline wallet will prevent any money to be spent but you are still able to send bitcoins to it and to view the balance easily. Just import the public key into your favourite wallet client.
(Remember that a bitcoin wallet consists of two parts: the public key is like an account number that you give out for people to send money to and you can also use to check the balance. The private key is like a PIN code that is used to spend the bitcoins. If anyone finds your private key your wallet will be emptied and this is irreversible).
When combined with the very strong encryption standard BIP0038, the paper wallet can even be publicly shared without risk of being compromised (as long as the password is kept secret). They can also be packed up online!
What you need: a live linux cd, source code for, one or more usb drives, a printer.

  • Download the code to your freshly formatted USB stick
  • Download Tails linux ISO and burn it to a DVD.
  • Boot up your computer using the DVD and load up html from the USB stick.
  • Generate one or more encrypted paper wallets and scan the public address so that you can send coins to it later.
  • Save the paper wallets as PDF to the USB stick(s)
  • Print multiple copies of the paper wallets or write down the private key manually using pen/paper.
  • You are done

If you find creating and booting from the DVD complicated you can use the online versions of but be aware that your are then exposed to any man-in-the-middle attacks or if your computer has been compromised an attacker could get hold of all your paper wallets.
Additional steps depend on the sum you are planning to store. Put the paper wallets in waterproof bags. Leave a copy with a friend you can trust. Consider storing a copy in a safe. Split up your stash between multiple wallets to lower the risk and to allow for spending in increments.
A recent version of the Android mobile wallet Mycelium has added import of BIP0038 encrypted private keys. This makes it very easy to scan the encrypted wallet and start spending the bitcoins on it.

How do I get Bitcoins in the UK

bitcoinBitCoin is taking the world with storm and with it the price of BitCoin is skyrocketing.
In the last 6 months there have been a flood of new and innovative services that use BitCoin. Enough to justify a long term life for bitcoin and to justify an ever increasing price due to a physical limit on how many bitcoins that can be created.
ATMs that convert cash to bitcoins, online and high street shops that accept bitcoins as payments, high street brokers that convert money to BTC and back, payment gateways and even Subway that accept bitcoins and are just some of the examples.
You may have been interested in getting in on the action; be it for investment purposes or just to experiment.
Unfortunately BitCoin (and all crypto-currencies in general) is a complicated concept and the barrier to entry is quite high.
You have to consider how to get your money, be it USD or GBP or EUR, across to a person that is willing to part with their bitcoins (BTC).
You also have to consider security: how to avoid losing your cash, how to transfer the bitcoins to yourself and how to keep your bitcoins safe.
Bitcoin exchanges are a place where sellers meet buyers and the bitcoin exchange provides a service to match these people up. There are several established bitcoin exchanges but instead of discussing them all I’d like to mention the one that has allowed me to instantly purchase bitcoins (and litecoins, LTC) in the UK on several occasions. is using UK bank transfers, also known as Faster Payments.
This allows for near instant and free transfers between buyers and sellers. I cannot stress enough how much this facilitates bitcoin trading in the UK.
The downside is that the purchase prices on Bitbargain are a bit higher than on an exchange so this favours sellers but not buyers. The markup seems to be 8-10%. However if you want to get in on Bitcoins quickly then this is still the best option.
Once you have your bitcoins, you have to consider security. Bitbargain charge a small fee to leave your bitcoins with them which is an incentive to move them away. This is a smart move because exchanges with a lot of bitcoins have been target of hackers that have stolen millions worth of bitcoins.
Bitcoin paper WalletTo purchase bitcoins and tucking them away my preferred method is a “paper wallet”. The concept is to print out the cryptographic secret that secures your bitcoins and store the physical paper in a safe place (or multiple places).
You can still use you your wallets public address to send bitcoins to but you (nor anybody else) is able to spend those bitcoins without having access to the printed secret.
To keep smaller amounts I can recommend a mobile bitcoin wallet, for example Bitcoin Wallet for android devices and Blockchain for iOS devices. Keep it to small amounts only!
Good luck, have fun and please avoid purchasing at the top of a cycle!