Show BIP32 path for BIP32_HD_Wallet classes

from right-click Show Public Keys menu.

Fixes #1598
This commit is contained in:
Neil Booth 2016-01-10 14:53:00 +09:00
parent d5c3c09bbc
commit 81d641a13f
2 changed files with 18 additions and 14 deletions

View File

@ -42,8 +42,8 @@ from electrum.util import format_satoshis, format_satoshis_plain, format_time
from electrum.util import PrintError, NotEnoughFunds, StoreDict from electrum.util import PrintError, NotEnoughFunds, StoreDict
from electrum import Transaction, mnemonic from electrum import Transaction, mnemonic
from electrum import util, bitcoin, commands from electrum import util, bitcoin, commands
from electrum import SimpleConfig, COIN_CHOOSERS from electrum import SimpleConfig, COIN_CHOOSERS, paymentrequest
from electrum import Wallet, paymentrequest from electrum.wallet import Wallet, BIP32_HD_Wallet
from amountedit import BTCAmountEdit, MyLineEdit, BTCkBEdit from amountedit import BTCAmountEdit, MyLineEdit, BTCkBEdit
from network_dialog import NetworkDialog from network_dialog import NetworkDialog
@ -2030,7 +2030,10 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
d.setMinimumSize(600, 200) d.setMinimumSize(600, 200)
vbox = QVBoxLayout() vbox = QVBoxLayout()
vbox.addWidget( QLabel(_("Address") + ': ' + address)) vbox.addWidget( QLabel(_("Address") + ': ' + address))
vbox.addWidget( QLabel(_("Public key") + ':')) if isinstance(self.wallet, BIP32_HD_Wallet):
derivation = self.wallet.address_id(address)
vbox.addWidget(QLabel(_("Derivation") + ': ' + derivation))
vbox.addWidget(QLabel(_("Public key") + ':'))
keys_e = ShowQRTextEdit(text='\n'.join(pubkey_list)) keys_e = ShowQRTextEdit(text='\n'.join(pubkey_list))
keys_e.addCopyButton(self.app) keys_e.addCopyButton(self.app)
vbox.addWidget(keys_e) vbox.addWidget(keys_e)

View File

@ -1725,17 +1725,6 @@ class BIP32_HD_Wallet(BIP32_Wallet):
def accounts_all_used(self): def accounts_all_used(self):
return all(self.account_is_used(acc_id) for acc_id in self.accounts) return all(self.account_is_used(acc_id) for acc_id in self.accounts)
class BIP44_Wallet(BIP32_HD_Wallet):
root_derivation = "m/44'/0'"
wallet_type = 'bip44'
def can_sign_xpubkey(self, x_pubkey):
xpub, sequence = BIP32_Account.parse_xpubkey(x_pubkey)
return xpub in self.master_public_keys.values()
def can_create_accounts(self):
return not self.is_watching_only()
@classmethod @classmethod
def prefix(self): def prefix(self):
return "/".join(self.root_derivation.split("/")[1:]) return "/".join(self.root_derivation.split("/")[1:])
@ -1753,6 +1742,18 @@ class BIP44_Wallet(BIP32_HD_Wallet):
acc_id, (change, address_index) = self.get_address_index(address) acc_id, (change, address_index) = self.get_address_index(address)
return self.address_derivation(acc_id, change, address_index) return self.address_derivation(acc_id, change, address_index)
class BIP44_Wallet(BIP32_HD_Wallet):
root_derivation = "m/44'/0'"
wallet_type = 'bip44'
def can_sign_xpubkey(self, x_pubkey):
xpub, sequence = BIP32_Account.parse_xpubkey(x_pubkey)
return xpub in self.master_public_keys.values()
def can_create_accounts(self):
return not self.is_watching_only()
@staticmethod @staticmethod
def normalize_passphrase(passphrase): def normalize_passphrase(passphrase):
return normalize('NFKD', unicode(passphrase or '')) return normalize('NFKD', unicode(passphrase or ''))