Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trezor shows different address than electrum-nmc #3

Closed
matso167 opened this issue Jun 1, 2018 · 22 comments · Fixed by #8
Closed

Trezor shows different address than electrum-nmc #3

matso167 opened this issue Jun 1, 2018 · 22 comments · Fixed by #8

Comments

@matso167
Copy link

matso167 commented Jun 1, 2018

On receive tab, when eye icon is clicked, Trezor shows different address on its screen than whats displayed in electrum-nmc.

electrum-nmc 3.1.3-beta1
MacOS
Trezor One

@JeremyRand
Copy link
Member

On receive tab, when eye icon is clicked, Trezor shows different address on its screen than whats displayed in electrum-nmc.

@matso167 Hi, thanks for the bug report. Debugging this will be Fun (TM) since I don't have a Trezor available to test this, but I suspect that this issue is either due to an incorrect prefix, or an incorrect HD wallet chaincode. Can you tell me whether the prefix is correct or incorrect on both the Trezor and in Electrum-NMC? (If you're not sure how to check this, this can be approximated by telling me the first character of each address.)

Cheers!

@matso167
Copy link
Author

matso167 commented Jun 1, 2018

Trezor displays "BTC Legacy Account" starting with 1 while electrum-nmc address starts with N.

@JeremyRand
Copy link
Member

Thanks @matso167. Do you happen to use any Bitcoin forks besides Namecoin with Electrum + your Trezor? If so, can you point me to the source code of one of them? I'd guess that it should be easy to diff the relevant areas of code to see what I missed.

@matso167
Copy link
Author

matso167 commented Jun 1, 2018

Sorry cant help with source codes.

@JeremyRand
Copy link
Member

@matso167 On a hunch, can you try changing the word "Bitcoin" to "Namecoin" in this line?

return "Testnet" if constants.net.TESTNET else "Bitcoin"
That line looks suspiciously like a mechanism to tell the Trezor what chain is being used.

@matso167
Copy link
Author

matso167 commented Jun 1, 2018

Nothing happens with that change

@JeremyRand
Copy link
Member

Hmm. I'll have to do some more digging; I'll see if I can track down the issue in the next few days.

@matso167
Copy link
Author

matso167 commented Jun 2, 2018

I did some more digging. I'm not very familiar with python environment, so I dindn't know I had to run
pip3 install .[full]
to activate changes in code.

Now when i changed that Bitcoin -> Namecoin, Trezor displays warning: "Wrong address path for selected coin. Continue at your own risk!"

Derivation path I'm using is:
m/44'/0'/0'

Not sure what derivation path is best supported on Namecoin.

After pressing Continue, I get same address as in electrum-nmc. Account name is still BTC legacy account.

@matso167
Copy link
Author

matso167 commented Jun 2, 2018

m/49'/0'/0' and m/84'/0'/0' derivation paths give error "cant encode address".

@JeremyRand
Copy link
Member

@matso167 Ah, excellent, that is progress. Where are you changing the derivation path? I'm not sure exactly where you are in the code.

On a hunch, can you try changing the 0 at the end of this line to 7 and tell me what happens?

coin = 1 if constants.net.TESTNET else 0

Thanks for your help so far on this!

@JeremyRand
Copy link
Member

JeremyRand commented Jun 2, 2018

so I dindn't know I had to run
pip3 install .[full]

FWIW, I usually run pip3 uninstall electrum-nmc before I run the line you listed. I don't know if it's actually necessary to trigger the update to take effect.

@matso167
Copy link
Author

matso167 commented Jun 2, 2018

Derivation path is asked in UI :)

@matso167
Copy link
Author

matso167 commented Jun 2, 2018

After changing that 0 to 7, it works! No more warning on Trezor.

@JeremyRand
Copy link
Member

After changing that 0 to 7, it works! No more warning on Trezor.

Excellent! And just to verify, the Trezor and Electrum-NMC GUI are still matching each other after you made that change? (I expect that that modification will change the addresses that are produced, but it should change in the same way on the Trezor and on Electrum-NMC.)

@matso167
Copy link
Author

matso167 commented Jun 2, 2018

Yes addresses match.

@JeremyRand
Copy link
Member

Yes addresses match.

Great! Thank you so much for helping debug this. I'll commit the relevant changes to the Git repo when I have a few minutes (sometime before the next release). Would you like me to credit you on the Namecoin.org news section when the fixes are released? If so, what name should I credit you as?

@matso167
Copy link
Author

matso167 commented Jun 2, 2018

Not necessary. Nice to get it working with Trezor :)

@curiosity81
Copy link

curiosity81 commented Jun 17, 2018

Hello,

this also works with a Trezor T. Both changes are necessary:

  1. line 177 in electrum-nmc/plugins/trezor/trezor.py: Bitcoin to Namecoin
  2. line 712 in electrum-nmc/lib/keystore.py: 0 to 7

Good work Jeremy. I will play around with some coins in the next few days and will report.

@curiosity81
Copy link

FYI, I sent some namecoins to an address generated by the Trezor T today and the transaction was recognized by electrum-nmc. Tomorrow or so, I will test, whether I can spent those coins too.

@curiosity81
Copy link

The more interesting part of the exercise also worked. I spent the coins. Worked like a charm. Transaction is already written to the namecoin blockchain.

However, I tried to sent the coins without fee. Electrum-nmc complained, that there were insufficient funds. So I pressed the max-button on the send pane, and it filled in some tiny fee. But I can see in the mempool, that there are also transactions without fee (https://bchain.info/NMC/). Maybe I used the software wrongly, since it was my second transaction with an electrum variant.

@JeremyRand
Copy link
Member

However, I tried to sent the coins without fee. Electrum-nmc complained, that there were insufficient funds. So I pressed the max-button on the send pane, and it filled in some tiny fee. But I can see in the mempool, that there are also transactions without fee (https://bchain.info/NMC/). Maybe I used the software wrongly, since it was my second transaction with an electrum variant.

@curiosity81 I wouldn't be surprised if Electrum doesn't let you send zero-fee transactions, since those haven't been allowed on Bitcoin's network for many years. (I have no idea why the Namecoin miners are willing to mine them; if I were mining Namecoin I'd be refusing to mine those.) I don't see much point in trying to patch Electrum-NMC to change Electrum's behavior on this.

@curiosity81
Copy link

Did it work for you? Because of the failed build (#3) in "Make Trezor work with Namecoin" ...

I could test the current code if needed.

JeremyRand added a commit that referenced this issue Jul 4, 2018
62cfe26 Namecoin: change BIP44 coin type from Bitcoin to Namecoin. (JeremyRand)
c50d2a1 Namecoin: Trezor: Use Namecoin as coin name instead of Bitcoin. (JeremyRand)
3e56419 Namecoin: rebrand Trezor UI. (JeremyRand)

Pull request description:

  Fixes #3

  I've successfully sent some NMC from Namecoin Core to Electrum-NMC and back with this PR.

  Note that testing this may be tricky, since master branch currently seems to have some breakage with blockchain validation (unrelated to Trezor).  If anyone really wants to test before the master branch is fixed, let me know and I'll try to assist.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants