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

(WIP) AuxPoW: Make wallet, qrcode, and BIP70 optional #182

Open
wants to merge 3 commits into
base: auxpow
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions electrum/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@
from .transaction import Transaction, multisig_script, TxOutput
from .paymentrequest import PR_PAID, PR_UNPAID, PR_UNKNOWN, PR_EXPIRED
from .synchronizer import Notifier
from .wallet import Abstract_Wallet, create_new_wallet, restore_wallet_from_text
from .address_synchronizer import TX_HEIGHT_LOCAL
from .mnemonic import Mnemonic
from .lnutil import SENT, RECEIVED
from .lnpeer import channel_id_from_funding_tx
Expand All @@ -57,6 +55,12 @@
from .simple_config import SimpleConfig


try:
from .wallet import Abstract_Wallet, create_new_wallet, restore_wallet_from_text
from .address_synchronizer import TX_HEIGHT_LOCAL
except ImportError:
pass

if TYPE_CHECKING:
from .network import Network
from .daemon import Daemon
Expand Down
11 changes: 5 additions & 6 deletions electrum/paymentrequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@
import certifi
import aiohttp


try:
from . import paymentrequest_pb2 as pb2
except ImportError:
sys.exit("Error: could not find paymentrequest_pb2.py. Create it with 'protoc --proto_path=electrum/ --python_out=electrum/ electrum/paymentrequest.proto'")

from . import bitcoin, ecc, util, transaction, x509, rsakey
from .util import bh2u, bfh, export_meta, import_meta, make_aiohttp_session
from .util import PR_UNPAID, PR_EXPIRED, PR_PAID, PR_UNKNOWN, PR_INFLIGHT
Expand All @@ -51,6 +45,11 @@
_logger = get_logger(__name__)


try:
from . import paymentrequest_pb2 as pb2
except ImportError:
_logger.error("Error: could not find paymentrequest_pb2.py. This is fine if BIP70 is unneeded. If you're using BIP70, create it with 'protoc --proto_path=electrum/ --python_out=electrum/ electrum/paymentrequest.proto'")

REQUEST_HEADERS = {'Accept': 'application/bitcoin-paymentrequest', 'User-Agent': 'Electrum'}
ACK_HEADERS = {'Content-Type':'application/bitcoin-payment','Accept':'application/bitcoin-paymentack','User-Agent':'Electrum'}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pass
1 change: 1 addition & 0 deletions electrum_nmc/electrum/null_impl/null_wallet/json_db.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pass
26 changes: 26 additions & 0 deletions electrum_nmc/electrum/null_impl/null_wallet/keystore.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from . import bitcoin
from .bitcoin import public_key_to_p2pkh
from .util import BitcoinException, bfh

def xpubkey_to_address(x_pubkey):
if x_pubkey[0:2] == 'fd':
address = bitcoin.script_to_address(x_pubkey[2:])
return x_pubkey, address
if x_pubkey[0:2] in ['02', '03', '04']:
pubkey = x_pubkey
elif x_pubkey[0:2] == 'ff':
xpub, s = BIP32_KeyStore.parse_xpubkey(x_pubkey)
pubkey = BIP32_KeyStore.get_pubkey_from_xpub(xpub, s)
elif x_pubkey[0:2] == 'fe':
mpk, s = Old_KeyStore.parse_xpubkey(x_pubkey)
pubkey = Old_KeyStore.get_pubkey_from_mpk(mpk, s[0], s[1])
else:
raise BitcoinException("Cannot parse pubkey. prefix: {}"
.format(x_pubkey[0:2]))
if pubkey:
address = public_key_to_p2pkh(bfh(pubkey))
return pubkey, address

def xpubkey_to_pubkey(x_pubkey):
pubkey, address = xpubkey_to_address(x_pubkey)
return pubkey
4 changes: 4 additions & 0 deletions electrum_nmc/electrum/null_impl/null_wallet/mnemonic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Mnemonic(object):
def __new__(self, lang=None):
return None

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pass
4 changes: 4 additions & 0 deletions electrum_nmc/electrum/null_impl/null_wallet/storage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class WalletStorage(object):
def __new__(self, path, *, manual_upgrades=False):
return None

9 changes: 9 additions & 0 deletions electrum_nmc/electrum/null_impl/null_wallet/wallet.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Abstract_Wallet(object):
def __new__(self, storage):
return None


class Wallet(object):
def __new__(self, storage):
return None

28 changes: 17 additions & 11 deletions run_electrum
Original file line number Diff line number Diff line change
Expand Up @@ -59,30 +59,32 @@ def check_imports():
import pyaes
import ecdsa
import certifi
import qrcode
import google.protobuf
import aiorpcx
except ImportError as e:
sys.exit(f"Error: {str(e)}. Try 'sudo python3 -m pip install <module-name>'")
try:
import qrcode
except ImportError as e:
_logger.error(f"Error: {str(e)}. This is fine for the daemon. If you're using the GUI, try 'sudo python3 -m pip install <module-name>'")
try:
import google.protobuf
from google.protobuf import descriptor
from google.protobuf import message
from google.protobuf import reflection
from google.protobuf import descriptor_pb2
except ImportError as e:
_logger.error(f"Error: {str(e)}. This is fine if BIP70 is unneeded. If you're using BIP70, try 'sudo python3 -m pip install <module-name>'")
# the following imports are for pyinstaller
from google.protobuf import descriptor
from google.protobuf import message
from google.protobuf import reflection
from google.protobuf import descriptor_pb2
# make sure that certificates are here
assert os.path.exists(certifi.where())


if not is_android:
check_imports()


from electrum.logging import get_logger, configure_logging
from electrum import util
from electrum import constants
from electrum import SimpleConfig
from electrum.wallet import Wallet
from electrum.storage import WalletStorage, get_derivation_used_for_hw_device_encryption
from electrum.storage import WalletStorage
from electrum.util import print_msg, print_stderr, json_encode, json_decode, UserCancelled
from electrum.util import InvalidPassword
from electrum.commands import get_parser, known_commands, Commands, config_variables
Expand All @@ -92,6 +94,9 @@ from electrum.util import create_and_start_event_loop

_logger = get_logger(__name__)

if not is_android:
check_imports()


# get password routine
def prompt_password(prompt, confirm=True):
Expand Down Expand Up @@ -189,6 +194,7 @@ def get_password_for_hw_device_encrypted_storage(plugins):
# FIXME we use the "first" device, in case of multiple ones
name, device_info = devices[0]
plugin = plugins.get_plugin(name)
from electrum.storage import get_derivation_used_for_hw_device_encryption
derivation = get_derivation_used_for_hw_device_encryption()
try:
xpub = plugin.get_xpub(device_info.device.id_, derivation, 'standard', plugin.handler)
Expand Down