I use ElectronCash 2.9.3 in Ubuntu 16.04 LTS together with a Ledger hardware wallet. I got everything installed, the USB drivers set up and I am able to connect and see the account.
But when I try to send a transaction the program aborts with:
File ".../Electron Cash-2.9.3/plugins/ledger/ledger.py", line 365, in sign_transaction
self.get_client().enableAlternate2fa(False)
AttributeError: btchip instance has no attribute 'enableAlternate2fa'
I use a basic transaction, no 2FA, no fancy things.
I'm not a Python programmer but it looks like there are some incompatible software modules. Any idea what is going wrong here and how to fix it?
Meanwhile I found the Github repository of btchipat Ledger. There exists a version of btchip.py which contains enableAlternate2fa. But due to my restricted knowledge of Python I just can not figure out how to replace the installed one with the new one.
Using sudo apt-get install python-btchip tells me that the actual version 0.1.16-1 is already installed, no change needed.
Every other "solution" I find in the web results in endless error messages. It is a big mess ...
I finally just replaced the whole btchip folder manually. Now the error disappears. But I still am not able to generate a transaction. I get a Invalid status 6a80 when trying to generate a transaction message now. I'm not sure whether it is related to my change, but I don't think so. Will file this as a separate issue.
Nevertheless I would still be interested in a solution which allows a clean installation of 'electroncash' on Ubuntu.
@SteffenIvanhoe lets check with others who might know better, i'm not sure Ledger can sign the BCH tx
Ledger can sign BCH tx, there is no doubt about that. They have a special firmware "app" to do that.
I expect the invalid status 6a80 error to be a minor incompatibility. But who can check and repair that?
It would be wonderful to have ElectronCash available for BCH on one of the most used hardware wallet platforms!
I found my hw.1 btchip device, but I have to update the firmware (the one I have is not supported any more) before I can help here.
Are you able to repair this issue on the software?
Or do you just want to check whether you get the same error?
Are you able to repair this issue on the software? Or do you just want to check whether you get the same error?
when trying to repair software, you need to first reproduce the problem. So the answer is: both. The latter one first.
If you can repair this and the only thing holding you back is the availability of an actual Ledger device, you might be able to get a new Nano S from Ledger for testing. They have expressed to me that they would sponsor a device for cases where someone adds a new UI and they see the advantages of ElectronCash because they know Electrum wallet.
thanks for the hint, @SteffenIvanhoe. after trying to help me (unsucessfully) to flash my hw.1, btchip offered to send some device to me and I took the offer. I'll be on vacation for a good week now and hopefully when I come back the device will have arrived and I can move this forward.
Good news!
I really appreciate your work on this client!
@molecular Have you got the Ledger wallet device? Any chance to look at the problems related to the use of ElectrumCash?
I have a device, yes, one of these very simple ones without display. Thanks btchip! They sent some of those to me for free. It works like a charm to sign Bitcoin Cash transactions with ElectronCash. <- turns out to be false, don't know what I tested back then
@SteffenIvanhoe thanks for installing a newer version of python-btchip, that clearly fixed the "btchip instance has no attribute 'enableAlternate2fa'" problem.
Ubuntu maintainers will have to update the package for a "clean ubuntu install" of electron-cash to work with btchip devices, unfortunately.
On archlinux, for example, the newest version for python2-btchip is 0.1.20-2.
Invalid status 6a80 when trying to generate a transaction
anything on the console (an exception) when you run electron-cash with the "-v" flag?
I found 6a80 in the ledger plugin code (in electron-cash repo):
def is_pin_validated(self, client):
try:
# Invalid SET OPERATION MODE to verify the PIN status
client.dongle.exchange(bytearray([0xe0, 0x26, 0x00, 0x00, 0x01, 0xAB]))
except BTChipException, e:
if (e.sw == 0x6982):
return False
if (e.sw == 0x6A80):
return True
raise e
This looks to me like a strange, hacky way to verify the PIN status by trying to set an invalid operation mode on the device, thereby triggering a BTChipException. Probably 6982 means "PIN not validated" and 6a80 means "invalid operation". I doubt this is the code that generates your problem, though. Now to find out where your error actually happens, we'd need to look at the "-v" output. Likely there's a stacktrace that will tell us. @SteffenIvanhoe, do you think you can start electron-cash from a terminal using
#> electron-cash -v
and copy/paste the output?
@SteffenIvanhoe, Oh, an please check if your device needs a firmware upgrade (old firmware is my best guess as to what's happening). There are different ways to do that. One is to use the "Ledger Wallet Bitcoin" chrome extension.
What ledger device do you have exactly (not that it really matters, just interested)
@molecular Firmware seems to be up-to-date. I have 2.0 on my Ledger Blue. Have also tried to sign a transaction with the Nano S. It makes no difference with respect to the error.
I have used
./electron-cash -v
option and tried to sign a send. As soon as I acknowledge the signing on the device the wallet software fails. This is the stack frame of the exception:
Traceback (most recent call last):
File "/home/steffen/Desktop/Electron Cash-2.9.3/plugins/ledger/ledger.py", line 411, in sign_transaction
inputSignature = self.get_client().untrustedHashSign(inputsPaths[inputIndex], pin, lockTime=tx.locktime)
File "/usr/lib/python2.7/dist-packages/btchip/btchip.py", line 387, in untrustedHashSign
result = self.dongle.exchange(bytearray(apdu))
File "/usr/lib/python2.7/dist-packages/btchip/btchipComm.py", line 119, in exchange
raise BTChipException("Invalid status %04x" % sw, sw)
BTChipException: Exception : Invalid status 6a80
Exception : Invalid status 6a80
Traceback (most recent call last):
File "/home/steffen/Desktop/Electron Cash-2.9.3/gui/qt/util.py", line 582, in run
result = task.task()
File "/home/steffen/Desktop/Electron Cash-2.9.3/lib/wallet.py", line 1104, in sign_transaction
k.sign_transaction(tx, password)
File "/home/steffen/Desktop/Electron Cash-2.9.3/plugins/ledger/ledger.py", line 422, in sign_transaction
self.give_error(e, True)
File "/home/steffen/Desktop/Electron Cash-2.9.3/plugins/ledger/ledger.py", line 201, in give_error
raise Exception(message)
Exception: Exception : Invalid status 6a80
[profiler] on_update 0.0207
Not sure whether that helps? Can you sign transactions with your Ledger device w/o getting an error?
Yes, I can sign without problems with my little usb-stick style btchip device. EDIT: this turned out to be false info
that output is very helpful, thank you.
However I'm not familiar enough with the signing process to be able to figure out what's going wrong, so I escalated the issue to ledger: LedgerHQ/btchip-python#25
@SteffenIvanhoe you said earlier about the 6a80 problem: "Will file this as a separate issue." Did you do this? I can't find any such issue. If not: no problem, we'll just use this issue. Maybe you can change the title of this issue?
I did not because you had responded here. Have now chosen your title.
I would like to test the same thing on a Windows PC to make sure it is not an Ubuntu specific thing. But the downloaded wallet is not complete on Windows. It lacks some libraries and I cannot even connect to the Ledger device. Unfortunately I'm not a Python guy and I have no idea how to install the missing libraries, e.g. phyton-ledger on a Windows computer. Any idea where I can find out about it?
@SteffenIvanhoe regarding windows: see #149. btchip library is not included in the python environment embedded into the .exe (will probably be in next release, @fyookball ?), so you'll have to "run from source". As to how to do this, I don't know. Probably start with installing cygwin, then use cygwin installer to install python2.7, then the required python dependencies and then get the sources from github (here) and try to run.
Ok, sounds like it is not doable. For non-Python people it is almost impossible to deal with the extremely messy Python software installation system. Having all parts build into the .exe would be great!
so btcchip says: "if the signature has already been patched then I have no idea".
I retried signing again with my hw.1 device and it didn't work, but with a different problem (signing worked, but node rejecte the tx with "invalid SIGHASH_FORK_ID", which would mean we don't sign correctly using BIP 143 / FORK_ID.
@SteffenIvanhoe I may have given false info when I said I can successfully sign using my ledger device ;-(. I was very sure I had tested this successfully, but apparently I remembered incorrectly. Sorry 'bout that. So I guess we'll have to dig in to find out if we "patched" the signing process for cash or not. It seems this wasn't done...
@SteffenIvanhoe: It'd be interesting to know, can you sign a message using your ledger devices?
I tried to sign a message. The result was an immediate crash of the wallet software just after the acknowledgement on the hardware device. All of this is in urgent need of being debugged by someone who owns a Ledger Nano S or Ledger Blue.
@SteffenIvanhoe
All of this is in urgent need of being debugged
we're all volunteers here. If you want to help, please send the output of the crash. The more info that is here, the more likely it is someone will solve the problem.
we will include the btchip python module in the next exe. What else do I need to do here?
@fyookball In Ubuntu I did install it separately and got this 6a80 error. Not sure it will work out in Windows when btchip python gets included. Probably needs an adaption to the new BCH signing procedure as well. See https://github.com/LedgerHQ/btchip-python/issues/25.
@fyookball looks like we need to implement bitcoin cash signing scheme in ledger plugin (part of electron-cash code)
I can confirm the exact behavior that @SteffenIvanhoe reported on ubuntu.
I have the same setup and also get the Invalid Status 6a80 error when I try to confirm the TX on my nano s.
Is there any workaround available? I need to send some BCH from my nano but because of this bug I cannot. Any ideas?
Cheers
Here's my log:
Traceback (most recent call last):
File "/home/nobody/Documents/electroncash/Electron Cash-2.9.3/plugins/ledger/ledger.py", line 411, in sign_transaction
inputSignature = self.get_client().untrustedHashSign(inputsPaths[inputIndex], pin, lockTime=tx.locktime)
File "/home/nobody/.local/lib/python2.7/site-packages/btchip/btchip.py", line 387, in untrustedHashSign
result = self.dongle.exchange(bytearray(apdu))
File "/home/nobody/.local/lib/python2.7/site-packages/btchip/btchipComm.py", line 127, in exchange
raise BTChipException("Invalid status %04x" % sw, sw)
BTChipException: Exception : Invalid status 6a80
Traceback (most recent call last):
File "/home/nobody/Documents/electroncash/Electron Cash-2.9.3/gui/qt/util.py", line 582, in run
result = task.task()
File "/home/nobody/Documents/electroncash/Electron Cash-2.9.3/lib/wallet.py", line 1104, in sign_transaction
k.sign_transaction(tx, password)
File "/home/nobody/Documents/electroncash/Electron Cash-2.9.3/plugins/ledger/ledger.py", line 422, in sign_transaction
self.give_error(e, True)
File "/home/nobody/Documents/electroncash/Electron Cash-2.9.3/plugins/ledger/ledger.py", line 201, in give_error
raise Exception(message)
Exception: Exception : Invalid status 6a80
There's no workaround. We need to implement cash signing in the ledger plugin.
Gotcha. Thanks
Signing a message works just fine on Electron Cash 3.0 (Ubuntu 16.04). Creating a transaction does not work. As btchip has said "the library itself works fine with Electrum and should also work fine with Electrum Cash once called with the right flow".
The btchip-python library needs to be called the right way due to the differences in transaction signing in BCH vs BTC.
You should be able to use the ledger wallet now on fd5a080, granted you use the Bitcoin Cash app, not the Bitcoin Core or Bitcoin Gold app. @SteffenIvanhoe if you could test that it works on your Ledger Wallet Blue that would be great!
Most helpful comment
You should be able to use the ledger wallet now on
fd5a080, granted you use the Bitcoin Cash app, not the Bitcoin Core or Bitcoin Gold app. @SteffenIvanhoe if you could test that it works on your Ledger Wallet Blue that would be great!