Electron-cash: Offline transaction: sign button greyed out

Created on 2 Nov 2019  路  8Comments  路  Source: Electron-Cash/Electron-Cash

Two computers: One online and one offline, both using the latest version of Electron Cash: 4.0.10.

Online computer uses Windows 10 'Home' with Electron portable, while offline computer uses Linux (OpenSUSE Tumbleweed) with Electron AppImage

When I create a transaction in a watch-only wallet and copy it to my offline computer to sign it, the sign button appears as disabled after I load the transaction (on the offline computer)

This process is not new to me and works perfectly with the original Electrum (BTC) and Electrum-LTC wallets.

I think the problem is with legacy addresses - Both wallets (online and offline) are using legacy addresses in the Electron configuration.

bug

Most helpful comment

Thank you for the explanation. Gonna try the 'Export private key' method and report back
EDIT: Yeap, was able to sign the tx using the export private key method.

All 8 comments

It's probably not related to Legacy Addresses -- since internally they have the same representation (hash160 of a public key).

It's more likely related to the fact that the signing wallet that isn't on the network doesn't realize the addresses in the tx belong to it. This can happen if you ended up generating many new addresses in the online wallet, past the 20 address limit. The offline wallet has no way of realizing that new transactions have come in and that the funds are available.

Either that or it's a bug.

Do me a favor.. go in the ONLINE wallet, in the "Addresses" tab (you may have to do View -> Show Addresses to see it) and tell me how many addresses you see in both regular and "change" paths.

Then do the same in the offline wallet. Let me know if you see the same set of addresses in both.

If you see a number >20 in the ONLINE wallet, and a number <= 20 in the OFFLINE, likely the offline can't see your newest funds and addresses. Don't forget to also check the change path too as often funds can end up there.

See screenshot of a piece of my Addresses tab (rest is not shown for privacy).

Screen Shot 2019-11-02 at 12 49 01 PM

I have 'Use change addresses' deliberately disabled in both wallets. Also I have only one address added to the online (watch-only) wallet. Both wallets show the correct address (the one that is in the 'not signed' transaction) in the "Addresses" tab.

Also important to say that I use a SHA256 hash as seed (aka: 'old seed type')

Yep. I was able to reproduce the bug. It's kind of annoying that this happens but there's a bizarre reason for it. Your Watching-Only wallet is just watching address, right?

Whereas your offline wallet is from seed.

This is a known issue with Electron Cash which used to affect Electrum too.. but I guess Electrum has since fixed it. It's definitely a bug.

Basically the unsigned tx has no way to communicate to the offline wallet which "item" in the derivation path the address corresponds to (which key in the path). (And yes, the wallet should be able to figure this out but it can't very easily without some code to iterate over things).

There's no easy fix... but you can actually do a workaround to your setup to have it work.

How to work around this issue:

  1. Try creating the offline wallet using the private key only -- that is:
  2. "Export Private Key" on that address
  3. Import that private key for that address into a new offline wallet on that machine (File -> New -> Bitcoin Addresses or Private Keys).

Now that you have the new wallet that is "keyed" off the private key, rather than an HD derivation path.. You should be able to sign the tx.

OR

  1. Get the XPUB from the offline wallet (Wallet -> Information)
  2. Copy it over to the online machine
  3. Create a watching-only wallet on the XPUB (rather than on the address). File -> New -> Standard Wallet -> Use Public or Private Keys (Yes, I know it says public/private keys but it should be saying master keys here).
  4. Now your online machine has the same concept of "derivation path" as your offline machine and it will work. You can generate tx's with it and then bring them to the offline machine for signing and everything will match up.

Do either of the above two methods and it should work. Let me know if that fixes it.

FYI -- This is how you get the MASTER XPUB from the offline wallet (to bring to the online wallet to create a proper HD watching wallet):

Go to Wallet -> Information

You should see a window like this:

Screen Shot 2019-11-02 at 6 23 34 PM

Copy that key from the offline machine and paste it into the new wallet on the online machine. You will be watching the actual derivation path of addresses and then the online and offline machine will be "speaking the same language".

Thank you for the explanation. Gonna try the 'Export private key' method and report back
EDIT: Yeap, was able to sign the tx using the export private key method.

Awesome -- glad it worked. Yeah -- it took me a minute but this bug has been around for a while. I will leave this bug open and hopefully I can fix it when I get more time.

Yes this is a general architectural issue with offline HD wallets (and hardware wallets) -- if the unsigned transaction doesn't tell them the derivation path, they might not realize that this address belongs to them. I somewhat doubt electrum has fixed this, since it's a fairly fundamental issue.

So, the online watch-only wallet really always needs to have xpub.

From what I can see, only the bugfix is to nag users when they are making an imported address wallet: "Hey, if you use this to make offline transactions with an HD wallet, it will be unreliable!". Alternatively cold wallets can do a massive scan beyond the gap ...

In this particular case there was no gap actually.

It was one address at the start of the address list that was a-spendin'.

As you know, the unsigned tx format saves info for finding the right key for an input (x_pubkey or whatever it's called in the dict).. and that info differs from what an imported address wallet saves and what an offline signing HD wallet expects. So the offline wallet couldn't "realize" that one of the addresses in the inputs is_mine (well it knew it was mine, but it couldn't locate its private key because no deriv. info) -- even though it had that address at the very start of its address list and should have trivially been able to do so!

I imagine a workaround given our current code base would be: for the offline wallet to notice when addresses in an unsigned tx is_mine but lacks the proper "index" for finding the private key.. and take an alternate code path which is more costly which would involve scanning the keystore for private keys for those addresses missing derivation path info.. auto-insert the right derivation path info into the tx, so it can later sign. (Basically it would be slow but it would be a corner case not normally encountered in regular usage, just this usage case).

Was this page helpful?
0 / 5 - 0 ratings