electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 3076eb75eae2725c88e23dc6b0131998f43ec62f
parent 31a18f83f1190bb586ca8c142f43af9e48932020
Author: ThomasV <thomasv@electrum.org>
Date:   Tue, 27 Aug 2019 17:12:43 +0200

make parsing lightning qr codes more robust

Diffstat:
Melectrum/gui/kivy/uix/screens.py | 9++++++---
Melectrum/gui/qt/paytoedit.py | 12++++++------
2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/electrum/gui/kivy/uix/screens.py b/electrum/gui/kivy/uix/screens.py @@ -253,7 +253,7 @@ class SendScreen(CScreen): self.payment_request = None def do_paste(self): - data = self.app._clipboard.paste() + data = self.app._clipboard.paste().strip() if not data: self.app.show_info(_("Clipboard is empty")) return @@ -267,9 +267,12 @@ class SendScreen(CScreen): if tx: self.app.tx_dialog(tx) return + lower = data.lower() + if lower.startswith('lightning:ln'): + lower = lower[10:] # try to decode as URI/address - if data.startswith('ln'): - self.set_ln_invoice(data.rstrip()) + if lower.startswith('ln'): + self.set_ln_invoice(lower) else: self.set_URI(data) # save automatically diff --git a/electrum/gui/qt/paytoedit.py b/electrum/gui/qt/paytoedit.py @@ -131,12 +131,12 @@ class PayToEdit(CompletionTextEdit, ScanQRTextEdit, Logger): if data.startswith("bitcoin:"): self.win.pay_to_URI(data) return - l = data.lower() - if l.startswith("lightning:"): - data = l[10:] - if data.startswith("ln"): - self.win.parse_lightning_invoice(data) - self.lightning_invoice = data + lower = data.lower() + if lower.startswith("lightning:ln"): + lower = lower[10:] + if lower.startswith("ln"): + self.win.parse_lightning_invoice(lower) + self.lightning_invoice = lower return try: self.payto_address = self.parse_output(data)