add Zcash code to plugins exclud. ledger/treror

This commit is contained in:
zebra-lucky 2018-03-11 12:15:20 +02:00
parent de2ef374c9
commit 8483acc9d5
26 changed files with 93 additions and 200 deletions

View File

@ -1,4 +1,4 @@
from electrum.i18n import _
from electrum_zcash.i18n import _
fullname = _('Audio MODEM')
description = _('Provides support for air-gapped transaction signing.')

View File

@ -5,10 +5,10 @@ from io import BytesIO
import sys
import platform
from electrum.plugins import BasePlugin, hook
from electrum_gui.qt.util import WaitingDialog, EnterButton, WindowModalDialog
from electrum.util import print_msg, print_error
from electrum.i18n import _
from electrum_zcash.plugins import BasePlugin, hook
from electrum_zcash_gui.qt.util import WaitingDialog, EnterButton, WindowModalDialog
from electrum_zcash.util import print_msg, print_error
from electrum_zcash.i18n import _
from PyQt5.QtGui import *
from PyQt5.QtCore import *

View File

@ -1,4 +1,4 @@
from electrum.i18n import _
from electrum_zcash.i18n import _
fullname = _('Cosigner Pool')
description = ' '.join([
_("This plugin facilitates the use of multi-signatures wallets."),

View File

@ -30,14 +30,14 @@ from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import QPushButton
from electrum import bitcoin, util
from electrum import transaction
from electrum.plugins import BasePlugin, hook
from electrum.i18n import _
from electrum.wallet import Multisig_Wallet
from electrum.util import bh2u, bfh
from electrum_zcash import bitcoin, util
from electrum_zcash import transaction
from electrum_zcash.plugins import BasePlugin, hook
from electrum_zcash.i18n import _
from electrum_zcash.wallet import Multisig_Wallet
from electrum_zcash.util import bh2u, bfh
from electrum_gui.qt.transaction_dialog import show_transaction
from electrum_zcash_gui.qt.transaction_dialog import show_transaction
import sys
import traceback
@ -162,7 +162,7 @@ class Plugin(BasePlugin):
d.cosigner_send_button.hide()
def cosigner_can_sign(self, tx, cosigner_xpub):
from electrum.keystore import is_xpubkey, parse_xpubkey
from electrum_zcash.keystore import is_xpubkey, parse_xpubkey
xpub_set = set([])
for txin in tx.inputs():
for x_pubkey in txin['x_pubkeys']:

View File

@ -1,4 +1,4 @@
from electrum.i18n import _
from electrum_zcash.i18n import _
fullname = 'Digital Bitbox'
description = _('Provides support for Digital Bitbox hardware wallet')

View File

@ -1,4 +1,4 @@
from electrum.plugins import hook
from electrum_zcash.plugins import hook
from .digitalbitbox import DigitalBitboxPlugin
from ..hw_wallet import CmdLineHandler

View File

@ -4,14 +4,14 @@
#
try:
import electrum
from electrum.bitcoin import TYPE_ADDRESS, push_script, var_int, msg_magic, Hash, verify_message, pubkey_from_signature, point_to_ser, public_key_to_p2pkh, EncodeAES, DecodeAES, MyVerifyingKey
from electrum.bitcoin import serialize_xpub, deserialize_xpub
from electrum.transaction import Transaction
from electrum.i18n import _
from electrum.keystore import Hardware_KeyStore
import electrum_zcash
from electrum_zcash.bitcoin import TYPE_ADDRESS, push_script, var_int, msg_magic, Hash, verify_message, pubkey_from_signature, point_to_ser, public_key_to_p2pkh, EncodeAES, DecodeAES, MyVerifyingKey
from electrum_zcash.bitcoin import serialize_xpub, deserialize_xpub
from electrum_zcash.transaction import Transaction
from electrum_zcash.i18n import _
from electrum_zcash.keystore import Hardware_KeyStore
from ..hw_wallet import HW_PluginBase
from electrum.util import print_error, to_string, UserCancelled
from electrum_zcash.util import print_error, to_string, UserCancelled
import time
import hid
@ -270,8 +270,8 @@ class DigitalBitbox_Client():
def dbb_generate_wallet(self):
key = self.stretch_key(self.password)
filename = ("Electrum-" + time.strftime("%Y-%m-%d-%H-%M-%S") + ".pdf").encode('utf8')
msg = b'{"seed":{"source": "create", "key": "%s", "filename": "%s", "entropy": "%s"}}' % (key, filename, b'Digital Bitbox Electrum Plugin')
filename = ("Electrum-Zcash-" + time.strftime("%Y-%m-%d-%H-%M-%S") + ".pdf").encode('utf8')
msg = b'{"seed":{"source": "create", "key": "%s", "filename": "%s", "entropy": "%s"}}' % (key, filename, b'Digital Bitbox Electrum-Zcash Plugin')
reply = self.hid_send_encrypt(msg)
if 'error' in reply:
raise Exception(reply['error']['message'])
@ -675,7 +675,7 @@ class DigitalBitboxPlugin(HW_PluginBase):
client = devmgr.client_by_id(device_id)
client.handler = self.create_handler(wizard)
client.setupRunning = True
client.get_xpub("m/44'/0'", 'standard')
client.get_xpub("m/44'/133'", 'standard')
def is_mobile_paired(self):

View File

@ -1,9 +1,9 @@
from ..hw_wallet.qt import QtHandlerBase, QtPluginBase
from .digitalbitbox import DigitalBitboxPlugin
from electrum.i18n import _
from electrum.plugins import hook
from electrum.wallet import Standard_Wallet
from electrum_zcash.i18n import _
from electrum_zcash.plugins import hook
from electrum_zcash.wallet import Standard_Wallet
class Plugin(DigitalBitboxPlugin, QtPluginBase):

View File

@ -1,4 +1,4 @@
from electrum.i18n import _
from electrum_zcash.i18n import _
fullname = _('Email')
description = _("Send and receive payment request with an email account")

View File

@ -40,11 +40,11 @@ from PyQt5.QtCore import *
import PyQt5.QtGui as QtGui
from PyQt5.QtWidgets import (QVBoxLayout, QLabel, QGridLayout, QLineEdit)
from electrum.plugins import BasePlugin, hook
from electrum.paymentrequest import PaymentRequest
from electrum.i18n import _
from electrum_gui.qt.util import EnterButton, Buttons, CloseButton
from electrum_gui.qt.util import OkButton, WindowModalDialog
from electrum_zcash.plugins import BasePlugin, hook
from electrum_zcash.paymentrequest import PaymentRequest
from electrum_zcash.i18n import _
from electrum_zcash_gui.qt.util import EnterButton, Buttons, CloseButton
from electrum_zcash_gui.qt.util import OkButton, WindowModalDialog
class Processor(threading.Thread):
@ -72,7 +72,7 @@ class Processor(threading.Thread):
p = [p]
continue
for item in p:
if item.get_content_type() == "application/bitcoin-paymentrequest":
if item.get_content_type() == "application/zcash-paymentrequest":
pr_str = item.get_payload()
pr_str = base64.b64decode(pr_str)
self.on_receive(pr_str)
@ -91,10 +91,10 @@ class Processor(threading.Thread):
msg['Subject'] = message
msg['To'] = recipient
msg['From'] = self.username
part = MIMEBase('application', "bitcoin-paymentrequest")
part = MIMEBase('application', "zcash-paymentrequest")
part.set_payload(payment_request)
encode_base64(part)
part.add_header('Content-Disposition', 'attachment; filename="payreq.btc"')
part.add_header('Content-Disposition', 'attachment; filename="payreq.zec"')
msg.attach(part)
s = smtplib.SMTP_SSL(self.imap_server, timeout=2)
s.login(self.username, self.password)
@ -143,7 +143,7 @@ class Plugin(BasePlugin):
menu.addAction(_("Send via e-mail"), lambda: self.send(window, addr))
def send(self, window, addr):
from electrum import paymentrequest
from electrum_zcash import paymentrequest
r = window.wallet.receive_requests.get(addr)
message = r.get('memo', '')
if r.get('signature'):

View File

@ -1,5 +0,0 @@
from electrum.i18n import _
fullname = 'GreenAddress instant'
description = _("Allows validating if your transactions have instant confirmations by GreenAddress")
available_for = ['qt']

View File

@ -1,102 +0,0 @@
#!/usr/bin/env python
#
# Electrum - lightweight Bitcoin client
# Copyright (C) 2014 Thomas Voegtlin
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
# (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge,
# publish, distribute, sublicense, and/or sell copies of the Software,
# and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import base64
import urllib.parse
import sys
import requests
from PyQt5.QtWidgets import QApplication, QPushButton
from electrum.plugins import BasePlugin, hook
from electrum.i18n import _
class Plugin(BasePlugin):
button_label = _("Verify GA instant")
@hook
def transaction_dialog(self, d):
d.verify_button = QPushButton(self.button_label)
d.verify_button.clicked.connect(lambda: self.do_verify(d))
d.buttons.insert(0, d.verify_button)
self.transaction_dialog_update(d)
def get_my_addr(self, d):
"""Returns the address for given tx which can be used to request
instant confirmation verification from GreenAddress"""
for addr, _ in d.tx.get_outputs():
if d.wallet.is_mine(addr):
return addr
return None
@hook
def transaction_dialog_update(self, d):
if d.tx.is_complete() and self.get_my_addr(d):
d.verify_button.show()
else:
d.verify_button.hide()
def do_verify(self, d):
tx = d.tx
wallet = d.wallet
window = d.main_window
# 1. get the password and sign the verification request
password = None
if wallet.has_password():
msg = _('GreenAddress requires your signature \n'
'to verify that transaction is instant.\n'
'Please enter your password to sign a\n'
'verification request.')
password = window.password_dialog(msg, parent=d)
if not password:
return
try:
d.verify_button.setText(_('Verifying...'))
QApplication.processEvents() # update the button label
addr = self.get_my_addr(d)
message = "Please verify if %s is GreenAddress instant confirmed" % tx.txid()
sig = wallet.sign_message(addr, message, password)
sig = base64.b64encode(sig).decode('ascii')
# 2. send the request
response = requests.request("GET", ("https://greenaddress.it/verify/?signature=%s&txhash=%s" % (urllib.parse.quote(sig), tx.txid())),
headers = {'User-Agent': 'Electrum'})
response = response.json()
# 3. display the result
if response.get('verified'):
d.show_message(_('%s is covered by GreenAddress instant confirmation') % (tx.txid()), title=_('Verification successful!'))
else:
d.show_critical(_('%s is not covered by GreenAddress instant confirmation') % (tx.txid()), title=_('Verification failed!'))
except BaseException as e:
import traceback
traceback.print_exc(file=sys.stdout)
d.show_error(str(e))
finally:
d.verify_button.setText(self.button_label)

View File

@ -1,4 +1,4 @@
from electrum.util import print_msg, print_error, raw_input
from electrum_zcash.util import print_msg, print_error, raw_input
class CmdLineHandler:

View File

@ -24,8 +24,8 @@
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
from electrum.plugins import BasePlugin, hook
from electrum.i18n import _
from electrum_zcash.plugins import BasePlugin, hook
from electrum_zcash.i18n import _
class HW_PluginBase(BasePlugin):

View File

@ -27,11 +27,11 @@
import threading
from PyQt5.Qt import QVBoxLayout, QLabel
from electrum_gui.qt.password_dialog import PasswordDialog, PW_PASSPHRASE
from electrum_gui.qt.util import *
from electrum_zcash_gui.qt.password_dialog import PasswordDialog, PW_PASSPHRASE
from electrum_zcash_gui.qt.util import *
from electrum.i18n import _
from electrum.util import PrintError
from electrum_zcash.i18n import _
from electrum_zcash.util import PrintError
# The trickiest thing about this handler was getting windows properly
# parented on MacOSX.
@ -171,9 +171,9 @@ class QtHandlerBase(QObject, PrintError):
from electrum.plugins import hook
from electrum.util import UserCancelled
from electrum_gui.qt.main_window import StatusBarButton
from electrum_zcash.plugins import hook
from electrum_zcash.util import UserCancelled
from electrum_zcash_gui.qt.main_window import StatusBarButton
class QtPluginBase(object):

View File

@ -1,4 +1,4 @@
from electrum.i18n import _
from electrum_zcash.i18n import _
fullname = 'KeepKey'
description = _('Provides support for KeepKey hardware wallet')

View File

@ -1,10 +1,10 @@
import time
from struct import pack
from electrum.i18n import _
from electrum.util import PrintError, UserCancelled
from electrum.keystore import bip39_normalize_passphrase
from electrum.bitcoin import serialize_xpub
from electrum_zcash.i18n import _
from electrum_zcash.util import PrintError, UserCancelled
from electrum_zcash.keystore import bip39_normalize_passphrase
from electrum_zcash.bitcoin import serialize_xpub
class GuiMixin(object):
@ -59,7 +59,7 @@ class GuiMixin(object):
msg = _("Enter a passphrase to generate this wallet. Each time "
"you use this wallet your %s will prompt you for the "
"passphrase. If you forget the passphrase you cannot "
"access the bitcoins in the wallet.") % self.device
"access the Zcash coins in the wallet.") % self.device
else:
msg = _("Enter the passphrase to unlock this wallet:")
passphrase = self.handler.get_passphrase(msg, self.creating_wallet)

View File

@ -1,4 +1,4 @@
from electrum.plugins import hook
from electrum_zcash.plugins import hook
from .keepkey import KeepKeyPlugin
from ..hw_wallet import CmdLineHandler

View File

@ -2,13 +2,13 @@ import threading
from binascii import hexlify, unhexlify
from electrum.util import bfh, bh2u
from electrum.bitcoin import (b58_address_to_hash160, xpub_from_pubkey,
from electrum_zcash.util import bfh, bh2u
from electrum_zcash.bitcoin import (b58_address_to_hash160, xpub_from_pubkey,
TYPE_ADDRESS, TYPE_SCRIPT, NetworkConstants)
from electrum.i18n import _
from electrum.plugins import BasePlugin
from electrum.transaction import deserialize
from electrum.keystore import Hardware_KeyStore, is_xpubkey, parse_xpubkey
from electrum_zcash.i18n import _
from electrum_zcash.plugins import BasePlugin
from electrum_zcash.transaction import deserialize
from electrum_zcash.keystore import Hardware_KeyStore, is_xpubkey, parse_xpubkey
from ..hw_wallet import HW_PluginBase
@ -134,7 +134,7 @@ class KeepKeyCompatiblePlugin(HW_PluginBase):
return client
def get_coin_name(self):
return "Testnet" if NetworkConstants.TESTNET else "Bitcoin"
return "Zcash Testnet" if NetworkConstants.TESTNET else "Zcash"
def initialize_device(self, device_id, wizard, handler):
# Initialization method

View File

@ -4,29 +4,29 @@ import threading
from PyQt5.Qt import Qt
from PyQt5.Qt import QGridLayout, QInputDialog, QPushButton
from PyQt5.Qt import QVBoxLayout, QLabel
from electrum_gui.qt.util import *
from electrum_zcash_gui.qt.util import *
from .plugin import TIM_NEW, TIM_RECOVER, TIM_MNEMONIC
from ..hw_wallet.qt import QtHandlerBase, QtPluginBase
from electrum.i18n import _
from electrum.plugins import hook, DeviceMgr
from electrum.util import PrintError, UserCancelled, bh2u
from electrum.wallet import Wallet, Standard_Wallet
from electrum_zcash.i18n import _
from electrum_zcash.plugins import hook, DeviceMgr
from electrum_zcash.util import PrintError, UserCancelled, bh2u
from electrum_zcash.wallet import Wallet, Standard_Wallet
PASSPHRASE_HELP_SHORT =_(
"Passphrases allow you to access new wallets, each "
"hidden behind a particular case-sensitive passphrase.")
PASSPHRASE_HELP = PASSPHRASE_HELP_SHORT + " " + _(
"You need to create a separate Electrum wallet for each passphrase "
"You need to create a separate Electrum-Zcash wallet for each passphrase "
"you use as they each generate different addresses. Changing "
"your passphrase does not lose other wallets, each is still "
"accessible behind its own passphrase.")
RECOMMEND_PIN = _(
"You should enable PIN protection. Your PIN is the only protection "
"for your bitcoins if your device is lost or stolen.")
"for your Zcash coins if your device is lost or stolen.")
PASSPHRASE_NOT_PIN = _(
"If you forget a passphrase you will be unable to access any "
"bitcoins in the wallet behind it. A passphrase is not a PIN. "
"Zcash coins in the wallet behind it. A passphrase is not a PIN. "
"Only change this if you are sure you understand it.")
CHARACTER_RECOVERY = (
"Use the recovery cipher shown on your device to input your seed words. "
@ -242,7 +242,7 @@ class QtPlugin(QtPluginBase):
else:
msg = _("Enter the master private key beginning with xprv:")
def set_enabled():
from electrum.keystore import is_xprv
from electrum_zcash.keystore import is_xprv
wizard.next_button.setEnabled(is_xprv(clean_text(text)))
text.textChanged.connect(set_enabled)
next_enabled = False
@ -359,13 +359,13 @@ class SettingsDialog(WindowModalDialog):
currently_enabled = self.features.passphrase_protection
if currently_enabled:
msg = _("After disabling passphrases, you can only pair this "
"Electrum wallet if it had an empty passphrase. "
"Electrum-Zcash wallet if it had an empty passphrase. "
"If its passphrase was not empty, you will need to "
"create a new wallet with the install wizard. You "
"can use this wallet again at any time by re-enabling "
"passphrases and entering its passphrase.")
else:
msg = _("Your current Electrum wallet can only be used with "
msg = _("Your current Electrum-Zcash wallet can only be used with "
"an empty passphrase. You must create a separate "
"wallet with the install wizard for other passphrases "
"as each one generates a new set of addresses.")
@ -406,7 +406,7 @@ class SettingsDialog(WindowModalDialog):
if wallet and sum(wallet.get_balance()):
title = _("Confirm Device Wipe")
msg = _("Are you SURE you want to wipe the device?\n"
"Your wallet still has bitcoins in it!")
"Your wallet still has Zcash coins in it!")
if not self.question(msg, title=title,
icon=QMessageBox.Critical):
return
@ -481,7 +481,7 @@ class SettingsDialog(WindowModalDialog):
settings_glayout.addWidget(pin_button, 2, 1)
pin_msg = QLabel(_("PIN protection is strongly recommended. "
"A PIN is your only protection against someone "
"stealing your bitcoins if they obtain physical "
"stealing your Zcash coins if they obtain physical "
"access to your %s.") % plugin.device)
pin_msg.setWordWrap(True)
pin_msg.setStyleSheet("color: red")
@ -541,7 +541,7 @@ class SettingsDialog(WindowModalDialog):
clear_pin_button.clicked.connect(clear_pin)
clear_pin_warning = QLabel(
_("If you disable your PIN, anyone with physical access to your "
"%s device can spend your bitcoins.") % plugin.device)
"%s device can spend your Zcash coins.") % plugin.device)
clear_pin_warning.setWordWrap(True)
clear_pin_warning.setStyleSheet("color: red")
advanced_glayout.addWidget(clear_pin_button, 0, 2)
@ -566,7 +566,7 @@ class SettingsDialog(WindowModalDialog):
wipe_device_msg.setWordWrap(True)
wipe_device_warning = QLabel(
_("Only wipe a device if you have the recovery seed written down "
"and the device wallet(s) are empty, otherwise the bitcoins "
"and the device wallet(s) are empty, otherwise the Zcash coins "
"will be lost forever."))
wipe_device_warning.setWordWrap(True)
wipe_device_warning.setStyleSheet("color: red")

View File

@ -1,4 +1,4 @@
from electrum.i18n import _
from electrum_zcash.i18n import _
fullname = _('LabelSync')
description = ' '.join([

View File

@ -1,5 +1,5 @@
from .labels import LabelsPlugin
from electrum.plugins import hook
from electrum_zcash.plugins import hook
class Plugin(LabelsPlugin):

View File

@ -7,9 +7,9 @@ import traceback
import base64
import electrum
from electrum.plugins import BasePlugin, hook
from electrum.i18n import _
import electrum_zcash
from electrum_zcash.plugins import BasePlugin, hook
from electrum_zcash.i18n import _
class LabelsPlugin(BasePlugin):
@ -21,14 +21,14 @@ class LabelsPlugin(BasePlugin):
def encode(self, wallet, msg):
password, iv, wallet_id = self.wallets[wallet]
encrypted = electrum.bitcoin.aes_encrypt_with_iv(password, iv,
encrypted = electrum_zcash.bitcoin.aes_encrypt_with_iv(password, iv,
msg.encode('utf8'))
return base64.b64encode(encrypted).decode()
def decode(self, wallet, message):
password, iv, wallet_id = self.wallets[wallet]
decoded = base64.b64decode(message)
decrypted = electrum.bitcoin.aes_decrypt_with_iv(password, iv, decoded)
decrypted = electrum_zcash.bitcoin.aes_decrypt_with_iv(password, iv, decoded)
return decrypted.decode('utf8')
def get_nonce(self, wallet):

View File

@ -4,11 +4,11 @@ from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import (QHBoxLayout, QLabel, QVBoxLayout)
from electrum.plugins import hook
from electrum.i18n import _
from electrum_gui.qt import EnterButton
from electrum_gui.qt.util import ThreadedButton, Buttons
from electrum_gui.qt.util import WindowModalDialog, OkButton
from electrum_zcash.plugins import hook
from electrum_zcash.i18n import _
from electrum_zcash_gui.qt import EnterButton
from electrum_zcash_gui.qt.util import ThreadedButton, Buttons
from electrum_zcash_gui.qt.util import WindowModalDialog, OkButton
from .labels import LabelsPlugin

View File

@ -1,4 +1,4 @@
from electrum.i18n import _
from electrum_zcash.i18n import _
fullname = 'Virtual Keyboard'
description = '%s\n%s' % (_("Add an optional virtual keyboard to the password dialog."), _("Warning: do not use this if it makes you pick a weaker password."))

View File

@ -1,7 +1,7 @@
from PyQt5.QtGui import *
from PyQt5.QtWidgets import (QVBoxLayout, QGridLayout, QPushButton)
from electrum.plugins import BasePlugin, hook
from electrum.i18n import _
from electrum_zcash.plugins import BasePlugin, hook
from electrum_zcash.i18n import _
import random