From e4f249ad4b329a1454f63bb1b029e0789661d9bd Mon Sep 17 00:00:00 2001 From: Wukong Date: Tue, 10 May 2022 22:27:18 -0700 Subject: [PATCH] Show QR code for xpub Show QR code for xpub so that mobile client can easily create a watch-only wallet by scanning the QR code --- scripts/joinmarket-qt.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/joinmarket-qt.py b/scripts/joinmarket-qt.py index bb8c755..357e1cf 100755 --- a/scripts/joinmarket-qt.py +++ b/scripts/joinmarket-qt.py @@ -1479,11 +1479,13 @@ class JMWalletTab(QWidget): # Show QR code option only for new addresses to avoid address reuse if item.text(3) == "new": menu.addAction("Show QR code", - lambda: self.openQRCodePopup(txt)) + lambda: self.openAddressQRCodePopup(txt)) if xpub_exists: menu.addAction("Copy extended public key to clipboard", lambda: app.clipboard().setText(xpub), shortcut=QKeySequence(QKeySequence.Copy)) + menu.addAction("Show QR code", + lambda: self.openQRCodePopup(xpub, xpub)) menu.addAction("Refresh wallet", lambda: mainWindow.updateWalletInfo(None, "all"), shortcut=QKeySequence(QKeySequence.Refresh)) @@ -1491,7 +1493,11 @@ class JMWalletTab(QWidget): #TODO add more items to context menu menu.exec_(self.walletTree.viewport().mapToGlobal(position)) - def openQRCodePopup(self, address): + def openQRCodePopup(self, title, data): + popup = QRCodePopup(self, title, data) + popup.show() + + def openAddressQRCodePopup(self, address): bip21_uri = btc.encode_bip21_uri(address, {}) # From BIP173 (bech32) spec: # For presentation, lowercase is usually preferable, but inside @@ -1502,8 +1508,7 @@ class JMWalletTab(QWidget): # encoded in QR code to uppercase, if possible. if detect_script_type(mainWindow.wallet_service.addr_to_script(address)) == TYPE_P2WPKH: bip21_uri = bip21_uri.upper() - popup = QRCodePopup(self, address, bip21_uri) - popup.show() + self.openQRCodePopup(address, bip21_uri) def updateWalletInfo(self, walletinfo=None): max_mixdepth_count = jm_single().config.getint("GUI", "max_mix_depth")