new account creation method (gui)
This commit is contained in:
parent
f74aa9ed3a
commit
3a894725ae
|
@ -136,8 +136,7 @@ class ElectrumWindow(QMainWindow):
|
||||||
|
|
||||||
self._close_electrum = False
|
self._close_electrum = False
|
||||||
self.lite = None
|
self.lite = None
|
||||||
self.current_account = self.config.get("current_account", None)
|
|
||||||
|
|
||||||
self.icon = QIcon(':icons/electrum.png')
|
self.icon = QIcon(':icons/electrum.png')
|
||||||
self.tray = QSystemTrayIcon(self.icon, self)
|
self.tray = QSystemTrayIcon(self.icon, self)
|
||||||
self.tray.setToolTip('Electrum')
|
self.tray.setToolTip('Electrum')
|
||||||
|
@ -257,6 +256,8 @@ class ElectrumWindow(QMainWindow):
|
||||||
import electrum
|
import electrum
|
||||||
self.wallet = wallet
|
self.wallet = wallet
|
||||||
self.accounts_expanded = self.wallet.storage.get('accounts_expanded',{})
|
self.accounts_expanded = self.wallet.storage.get('accounts_expanded',{})
|
||||||
|
self.current_account = self.wallet.storage.get("current_account", None)
|
||||||
|
self.pending_accounts = self.wallet.storage.get('pending_accounts',{})
|
||||||
|
|
||||||
title = 'Electrum ' + self.wallet.electrum_version + ' - ' + self.wallet.storage.path
|
title = 'Electrum ' + self.wallet.electrum_version + ' - ' + self.wallet.storage.path
|
||||||
if self.wallet.is_watching_only(): title += ' [%s]' % (_('watching only'))
|
if self.wallet.is_watching_only(): title += ' [%s]' % (_('watching only'))
|
||||||
|
@ -1090,8 +1091,15 @@ class ElectrumWindow(QMainWindow):
|
||||||
menu.addAction(_("Maximize"), lambda: self.account_set_expanded(item, k, True))
|
menu.addAction(_("Maximize"), lambda: self.account_set_expanded(item, k, True))
|
||||||
menu.addAction(_("Rename"), lambda: self.edit_account_label(k))
|
menu.addAction(_("Rename"), lambda: self.edit_account_label(k))
|
||||||
menu.addAction(_("View details"), lambda: self.show_account_details(k))
|
menu.addAction(_("View details"), lambda: self.show_account_details(k))
|
||||||
|
if k in self.pending_accounts:
|
||||||
|
menu.addAction(_("Delete"), lambda: self.delete_pending_account(k))
|
||||||
menu.exec_(self.receive_list.viewport().mapToGlobal(position))
|
menu.exec_(self.receive_list.viewport().mapToGlobal(position))
|
||||||
|
|
||||||
|
def delete_pending_account(self, k):
|
||||||
|
self.pending_accounts.pop(k)
|
||||||
|
self.wallet.storage.put('pending_accounts', self.pending_accounts)
|
||||||
|
self.update_receive_tab()
|
||||||
|
|
||||||
def create_receive_menu(self, position):
|
def create_receive_menu(self, position):
|
||||||
# fixme: this function apparently has a side effect.
|
# fixme: this function apparently has a side effect.
|
||||||
# if it is not called the menu pops up several times
|
# if it is not called the menu pops up several times
|
||||||
|
@ -1172,7 +1180,9 @@ class ElectrumWindow(QMainWindow):
|
||||||
item.setData(0,32, True) # is editable
|
item.setData(0,32, True) # is editable
|
||||||
|
|
||||||
run_hook('update_receive_item', address, item)
|
run_hook('update_receive_item', address, item)
|
||||||
|
|
||||||
|
if not self.wallet.is_mine(address): return
|
||||||
|
|
||||||
c, u = self.wallet.get_addr_balance(address)
|
c, u = self.wallet.get_addr_balance(address)
|
||||||
balance = self.format_amount(c + u)
|
balance = self.format_amount(c + u)
|
||||||
item.setData(2,0,balance)
|
item.setData(2,0,balance)
|
||||||
|
@ -1238,6 +1248,21 @@ class ElectrumWindow(QMainWindow):
|
||||||
seq_item.addChild(item)
|
seq_item.addChild(item)
|
||||||
|
|
||||||
|
|
||||||
|
for k, addr in self.pending_accounts.items():
|
||||||
|
if k in self.wallet.accounts:
|
||||||
|
self.pending_accounts.pop(k)
|
||||||
|
self.wallet.storage.put('pending_accounts', self.pending_accounts)
|
||||||
|
name = self.wallet.labels.get(k,'')
|
||||||
|
account_item = QTreeWidgetItem( [ name + " [ "+_('pending account')+" ]", '', '', ''] )
|
||||||
|
self.update_receive_item(item)
|
||||||
|
l.addTopLevelItem(account_item)
|
||||||
|
account_item.setExpanded(True)
|
||||||
|
account_item.setData(0, 32, k)
|
||||||
|
item = QTreeWidgetItem( [ addr, '', '', '', ''] )
|
||||||
|
account_item.addChild(item)
|
||||||
|
self.update_receive_item(item)
|
||||||
|
|
||||||
|
|
||||||
if self.wallet.imported_keys and (self.current_account is None or self.current_account == -1):
|
if self.wallet.imported_keys and (self.current_account is None or self.current_account == -1):
|
||||||
c,u = self.wallet.get_imported_balance()
|
c,u = self.wallet.get_imported_balance()
|
||||||
account_item = QTreeWidgetItem( [ _('Imported'), '', self.format_amount(c+u), ''] )
|
account_item = QTreeWidgetItem( [ _('Imported'), '', self.format_amount(c+u), ''] )
|
||||||
|
@ -1386,23 +1411,31 @@ class ElectrumWindow(QMainWindow):
|
||||||
dialog.setModal(1)
|
dialog.setModal(1)
|
||||||
dialog.setWindowTitle(_("New Account"))
|
dialog.setWindowTitle(_("New Account"))
|
||||||
|
|
||||||
addr = self.wallet.new_account_address()
|
|
||||||
vbox = QVBoxLayout()
|
vbox = QVBoxLayout()
|
||||||
msg = _("Electrum considers that an account exists only if it contains bitcoins.") + '\n' \
|
vbox.addWidget(QLabel(_('Account name')+':'))
|
||||||
+ _("To create a new account, please send coins to the first address of that account.") + '\n' \
|
e = QLineEdit()
|
||||||
+ _("Note: you will need to wait for 2 confirmations before the account is created.")
|
|
||||||
vbox.addWidget(QLabel(msg))
|
|
||||||
vbox.addWidget(QLabel(_('Address')+':'))
|
|
||||||
e = QLineEdit(addr)
|
|
||||||
e.setReadOnly(True)
|
|
||||||
vbox.addWidget(e)
|
vbox.addWidget(e)
|
||||||
|
msg = _("Note: Newly created accounts are 'pending' until they receive bitcoins.") + " " \
|
||||||
|
+ _("You will need to wait for 2 confirmations until the correct balance is displayed and more addresses are created for that account.")
|
||||||
|
l = QLabel(msg)
|
||||||
|
l.setWordWrap(True)
|
||||||
|
vbox.addWidget(l)
|
||||||
|
|
||||||
vbox.addLayout(ok_cancel_buttons(dialog))
|
vbox.addLayout(ok_cancel_buttons(dialog))
|
||||||
dialog.setLayout(vbox)
|
dialog.setLayout(vbox)
|
||||||
r = dialog.exec_()
|
r = dialog.exec_()
|
||||||
if r:
|
if not r: return
|
||||||
self.payto(addr)
|
|
||||||
|
|
||||||
|
name = str(e.text())
|
||||||
|
if not name: return
|
||||||
|
|
||||||
|
k, addr = self.wallet.new_account_address()
|
||||||
|
self.wallet.set_label(k, name)
|
||||||
|
self.pending_accounts[k] = addr
|
||||||
|
self.wallet.storage.put('pending_accounts', self.pending_accounts)
|
||||||
|
self.update_receive_tab()
|
||||||
|
self.tabs.setCurrentIndex(2)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def show_master_public_key_old(self):
|
def show_master_public_key_old(self):
|
||||||
|
|
|
@ -370,7 +370,7 @@ class Wallet:
|
||||||
self.next_addresses[k] = addr
|
self.next_addresses[k] = addr
|
||||||
self.storage.put('next_addresses',self.next_addresses)
|
self.storage.put('next_addresses',self.next_addresses)
|
||||||
|
|
||||||
return addr
|
return k, addr
|
||||||
|
|
||||||
|
|
||||||
def next_account(self, account_type = '1'):
|
def next_account(self, account_type = '1'):
|
||||||
|
@ -769,7 +769,7 @@ class Wallet:
|
||||||
for account_type in ['1','2of2','2of3']:
|
for account_type in ['1','2of2','2of3']:
|
||||||
if not self.has_master_public_keys(account_type):
|
if not self.has_master_public_keys(account_type):
|
||||||
continue
|
continue
|
||||||
a = self.new_account_address(account_type)
|
k, a = self.new_account_address(account_type)
|
||||||
if self.address_is_old(a):
|
if self.address_is_old(a):
|
||||||
print_error( "creating account", a )
|
print_error( "creating account", a )
|
||||||
self.create_account(account_type)
|
self.create_account(account_type)
|
||||||
|
|
Loading…
Reference in New Issue