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

Wrong public key shown on version 3.3.3 #5115

Closed
otaviobonder-deel opened this issue Feb 13, 2019 · 12 comments
Closed

Wrong public key shown on version 3.3.3 #5115

otaviobonder-deel opened this issue Feb 13, 2019 · 12 comments

Comments

@otaviobonder-deel
Copy link

otaviobonder-deel commented Feb 13, 2019

I have four electrum wallets. Three of them are HW p2wsh wallets that were imported to electrum, and one of them is a p2pkh wallet created by electrum. Two of the three HW wallets are multisig wallets. All of them work fine.

In version 3.3.3, I was checking my pubkey from my two multisig HW wallets, but something strange happened. Electrum showed the same pubkey for both wallets (one is 1/2 and the other 2/2). They are different wallets, with different transactions, but the same pubkey was shown to both.

Another bug happened when I tried to see my cosigner pubkey. I had to switch between both cosigners radio buttons multiple times, because the same pubkey was being shown for both:

Wallet 1/2:

screen shot 2019-02-13 at 11 26 19

screen shot 2019-02-13 at 11 26 33

Wallet 2/2:

screen shot 2019-02-13 at 11 32 31

After switching from cosigner 1 and 2 multiple times, another pubkey was shown (probably mine from the 2/2 wallet), but the same pubkey was shown for both cosigners:

screen shot 2019-02-13 at 11 34 29

screen shot 2019-02-13 at 11 35 06

The expected behavior would be electrum showing a different pubkey for each wallet and each cosigner

Edit: I'm running version 3.3.3 on Mac
Edit2: I downgraded to version 3.3.2 and the same bug happened

@SomberNight
Copy link
Member

Can you please see #4777 and say if you think it's the same issue?
That issue is about the text not refreshing when you switch the radio button state.

@otaviobonder-deel
Copy link
Author

Part of. If you click multiple times, it refreshes the pubkey. But the same pubkey is being shown in two different wallets. They were supposed to have different pubkeys. No matter what I try, I can't view the pubkey of the 1/2 wallet

@SomberNight
Copy link
Member

Try in console:

>> wallet.get_keystores()[0].xpub
>> wallet.get_keystores()[1].xpub
...

Do you see expected xpubs then?

@otaviobonder-deel
Copy link
Author

I see different xpubs for the same wallet (cosigner 1 and 2 pubkeys), but they are the same for both wallets (they should be different)

@SomberNight
Copy link
Member

Ok, so that is a separate issue from the Qt display bug of course.

I think I understand now.

Electrum showed the same pubkey for both wallets (one is 1/2 and the other 2/2). They are different wallets, with different transactions, but the same pubkey was shown to both.

They are correctly the same master public keys, derived from the same seeds, but you are reusing them for two different wallets. The generated addresses between the wallets are different because the wallets use different scriptPubKey templates (output scripts). (well because of segwit witness stuff, it's a bit more complicated, but nevermind that)
So e.g. for a 1 of 2 multisig, the script is 1 <pubkey1> <pubkey2> 2 CHECKMULTISIG
While for 2 of 2 multisig, the script is 2 <pubkey3> <pubkey4> 2 CHECKMULTISIG
In your case, pubkey1==pubkey3, and pubkey2==pubkey4.
The two scripts result in different addresses, but they reuse pubkeys.

For privacy reasons, this setup is not ideal, but otherwise it's fine.

@otaviobonder-deel
Copy link
Author

Oh I see. I didn't know electrum worked like this. Both multisig wallets were generated by electrum, but I'm implementing my electrum personal server and I'm not getting luck on make it work with my 1/2 wallet. I get This means Electrum is requesting information about addresses that are missing from Electrum Personal Server's configuration file. from the server.
What's the best way to fix it? Create another 1/2 multisig wallet? If so, how can I force electrum to generate a new pubkey?

@SomberNight
Copy link
Member

Can you paste/upload you EPS config? Just mask/mock out private stuff.

@SomberNight
Copy link
Member

SomberNight commented Feb 13, 2019

If so, how can I force electrum to generate a new pubkey?

Well the issue is with bip39/bip44 really. Given a mnemonic, and derivation path, you get a bip32 node. The script type does not enter the calculation, so if you want to reuse the mnemonic (seed words), but get different pubkeys, the only thing you can do is change the derivation path.
Which is why bip49/bip84 was made, to use different derivation path and standardise them for p2sh-segwit single signing, and native segwit single signing respectively. There are no standard paths for "m of n" multisig. (and note that the paths would need to be dependent on m and n)

@otaviobonder-deel
Copy link
Author

## Electrum Personal Server configuration file
## Comments start with #

[master-public-keys]
## Add electrum master public keys to this section
## Create a wallet in electrum then go Wallet -> Information to get the mpk

TE_Giro = 2 (pubkey1) (pubkey2)
PSW = (pubkey)
TE_Cold = 2 (pubkey1) (pubkey2)
TE_Recebe = (pubkey)
#any_name_works = xpub661MyMwAqRbcFseXCwRdRVkhVuzEiskg4QUp5XpUdNf2uGXvQmnD4zcofZ1MN6Fo8PjqQ5cemJQ39f7RTwDVVputHMFjPUn8VRp2pJQMgEF

# Multiple master public keys maybe added by simply adding another line
#my_second_wallet = xpubanotherkey

# Multisig wallets use format `required-signatures [list of master pub keys]`
#multisig_wallet = 2 xpub661MyMwAqRbcFseXCwRdRVkhVuzEiskg4QUp5XpUdNf2uGXvQmnD4zcofZ1MN6Fo8PjqQ5cemJQ39f7RTwDVVputHMFjPUn8VRp2pJQMgEF xpub661MyMwAqRbcFseXCwRdRVkhVuzEiskg4QUp5XpUdNf$

[watch-only-addresses]
## Add addresses to this section

#addr = 1DuqpoeTB9zLvVCXQG53VbMxvMkijk494n
# A space separated list is accepted
#my_test_addresses = 3Hh7QujVLqz11tiQsnUE5CSL16WEHBmiyR 1PXRLo1FQoZyF1Jhnz4qbG5x8Bo3pFpybz bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq

# multiple addresses may also be added in separate lines (like master public keys above)
#addr2 = 3anotheraddress

[bitcoin-rpc]
host = 127.0.0.1
port = 18332
#empty means look in the default location
datadir = /media/bitcoin/bitcoin
#if you dont want to use the .cookie method, uncomment to config u/p here
rpc_user = user
rpc_password = pass

#to be used with the multi-wallet feature
# see https://github.com/bitcoin/bitcoin/blob/master/doc/release-notes/release-notes-0.15.0.md#multi-wallet-support
# empty means default file, for when using a single wallet file
wallet_filename =

# how often in seconds to poll for new transactions when electrum not connected
poll_interval_listening = 30
# how often in seconds to poll for new transactions when electrum is connected
poll_interval_connected = 5

# Parameters for dealing with deterministic wallets
# how many addresses to import first time, should be big because if you import too little you may have to rescan again
initial_import_count = 1000
# number of unused addresses kept at the head of the wallet
gap_limit = 25


[electrum-server]
# 0.0.0.0 to accept connections from any IP
#127.0.0.1 to accept from only localhost
host = 127.0.0.1
port = 50002

# space-separated whitelist of IP addresses
# accepts CIDR notation eg 192.168.0.0/16 or 2a01:4f8:1f1::/120
# star (*) means all are accepted
# generally requires host binding (above) to be 0.0.0.0
ip_whitelist = *

#uses the default one, which is fine because by default nobody should be
# allowed to connect to your server or scan your packets
#to generate another certificate see https://github.com/spesmilo/electrum-server/blob/ce1b11d7f5f7a70a3b6cc7ec1d3e552436e54ffe/HOWTO.md#step-8-create-a-self-signed-ssl-cert
certfile = certs/cert.crt
keyfile = certs/cert.key

@SomberNight
Copy link
Member

SomberNight commented Feb 13, 2019

TE_Giro = 2 (pubkey1) (pubkey2)
PSW = (pubkey)
TE_Cold = 2 (pubkey1) (pubkey2)

What does the 2 mean? shouldn't it maybe be 1 for one of those wallets to make it "1 of 2"?

@chris-belcher


EDIT: yes, looks like that

Multisig wallets use format required-signatures [list of master pub keys]

@otaviobonder-deel
Copy link
Author

You are right. I edited it and now I'm rescanning. I'll close this issue if this solves the problem with electrum. Thanks!

@otaviobonder-deel
Copy link
Author

Perfect, that was the problem. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants