Browse Source

Display the account xpub in QT interface

master
Wukong 4 years ago
parent
commit
d95e279d98
  1. 3
      jmclient/jmclient/__init__.py
  2. 11
      jmclient/jmclient/cryptoengine.py
  3. 21
      scripts/joinmarket-qt.py

3
jmclient/jmclient/__init__.py

@ -21,7 +21,8 @@ from .wallet import (Mnemonic, estimate_tx_fee, WalletError, BaseWallet, ImportW
from .storage import (Argon2Hash, Storage, StorageError, RetryableStorageError,
StoragePasswordError, VolatileStorage)
from .cryptoengine import (BTCEngine, BTC_P2PKH, BTC_P2SH_P2WPKH, BTC_P2WPKH, EngineError,
TYPE_P2PKH, TYPE_P2SH_P2WPKH, TYPE_P2WPKH, detect_script_type)
TYPE_P2PKH, TYPE_P2SH_P2WPKH, TYPE_P2WPKH, detect_script_type,
is_extended_public_key)
from .configure import (load_test_config, process_shutdown,
load_program_config, jm_single, get_network, update_persist_config,
validate_address, is_burn_destination, get_mchannels,

11
jmclient/jmclient/cryptoengine.py

@ -23,6 +23,11 @@ NET_MAP = {'mainnet': NET_MAINNET, 'testnet': NET_TESTNET,
WIF_PREFIX_MAP = {'mainnet': b'\x80', 'testnet': b'\xef', 'signet': b'\xef'}
BIP44_COIN_MAP = {'mainnet': 2**31, 'testnet': 2**31 + 1, 'signet': 2**31 + 1}
BIP32_PUB_PREFIX = "xpub"
BIP49_PUB_PREFIX = "ypub"
BIP84_PUB_PREFIX = "zpub"
TESTNET_PUB_PREFIX = "tpub"
def detect_script_type(script_str):
""" Given a scriptPubKey, decide which engine
to use, one of: p2pkh, p2sh-p2wpkh, p2wpkh.
@ -50,6 +55,12 @@ def detect_script_type(script_str):
raise EngineError("Unknown script type for script '{}'"
.format(bintohex(script_str)))
def is_extended_public_key(key_str):
return any([key_str.startswith(prefix) for prefix in [
BIP32_PUB_PREFIX, BIP49_PUB_PREFIX, BIP84_PUB_PREFIX, TESTNET_PUB_PREFIX]])
class classproperty(object):
"""
from https://stackoverflow.com/a/5192374

21
scripts/joinmarket-qt.py

@ -73,7 +73,7 @@ from jmclient import load_program_config, get_network, update_persist_config,\
parse_payjoin_setup, send_payjoin, JMBIP78ReceiverManager, \
detect_script_type, general_custom_change_warning, \
nonwallet_custom_change_warning, sweep_custom_change_warning, EngineError,\
TYPE_P2WPKH, check_and_start_tor
TYPE_P2WPKH, check_and_start_tor, is_extended_public_key
from jmclient.wallet import BaseWallet
from qtsupport import ScheduleWizard, TumbleRestartWizard, config_tips,\
@ -1462,10 +1462,11 @@ class JMWalletTab(QWidget):
txt = str(item.text(0))
if validate_address(txt)[0]:
address_valid = True
if "EXTERNAL" in txt:
parsed = txt.split()
if len(parsed) > 1:
xpub = parsed[1]
parsed = txt.split()
if len(parsed) > 1:
if is_extended_public_key(parsed[-1]):
xpub = parsed[-1]
xpub_exists = True
menu = QMenu()
@ -1549,8 +1550,10 @@ class JMWalletTab(QWidget):
for mixdepth in range(max_mixdepth_count):
mdbalance = mbalances[mixdepth]
account_xpub = xpubs[mixdepth][-1]
m_item = QTreeWidgetItem(["Mixdepth " + str(mixdepth) + " , balance: " +
mdbalance, '', '', '', ''])
mdbalance + ", " + account_xpub, '', '', '', ''])
self.walletTree.addChild(m_item)
# if expansion states existed, reinstate them:
@ -2332,6 +2335,12 @@ def get_wallet_printout(wallet_service):
entry.serialize_amounts(),
entry.serialize_status(),
entry.serialize_label()])
# Append the account xpub to the end of the list
FBONDS_PUBKEY_PREFIX = "fbonds-mpk-"
account_xpub = acct.xpub
if account_xpub.startswith(FBONDS_PUBKEY_PREFIX):
account_xpub = account_xpub[len(FBONDS_PUBKEY_PREFIX):]
xpubs[j].append(account_xpub)
# in case the wallet is not yet synced, don't return an incorrect
# 0 balance, but signal incompleteness:
total_bal = walletview.get_fmt_balance() if wallet_service.synced else None

Loading…
Cancel
Save