mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-02 18:25:21 +00:00
transactions: reading QR codes: clean-up and accept all encodings
This commit is contained in:
parent
29a6e3c019
commit
27df235c26
3 changed files with 7 additions and 13 deletions
|
@ -397,12 +397,9 @@ class ElectrumWindow(App):
|
||||||
self.set_ln_invoice(data)
|
self.set_ln_invoice(data)
|
||||||
return
|
return
|
||||||
# try to decode transaction
|
# try to decode transaction
|
||||||
from electrum.transaction import Transaction
|
from electrum.transaction import tx_from_any
|
||||||
from electrum.util import bh2u
|
|
||||||
try:
|
try:
|
||||||
text = bh2u(base_decode(data, None, base=43))
|
tx = tx_from_any(data)
|
||||||
tx = Transaction(text)
|
|
||||||
tx.deserialize()
|
|
||||||
except:
|
except:
|
||||||
tx = None
|
tx = None
|
||||||
if tx:
|
if tx:
|
||||||
|
|
|
@ -2723,10 +2723,10 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
||||||
d = PasswordDialog(parent, msg)
|
d = PasswordDialog(parent, msg)
|
||||||
return d.run()
|
return d.run()
|
||||||
|
|
||||||
def tx_from_text(self, txt: Union[str, bytes]) -> Union[None, 'PartialTransaction', 'Transaction']:
|
def tx_from_text(self, data: Union[str, bytes]) -> Union[None, 'PartialTransaction', 'Transaction']:
|
||||||
from electrum.transaction import tx_from_any
|
from electrum.transaction import tx_from_any
|
||||||
try:
|
try:
|
||||||
return tx_from_any(txt)
|
return tx_from_any(data)
|
||||||
except BaseException as e:
|
except BaseException as e:
|
||||||
self.show_critical(_("Electrum was unable to parse your transaction") + ":\n" + repr(e))
|
self.show_critical(_("Electrum was unable to parse your transaction") + ":\n" + repr(e))
|
||||||
return
|
return
|
||||||
|
@ -2745,11 +2745,6 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
||||||
self.pay_to_URI(data)
|
self.pay_to_URI(data)
|
||||||
return
|
return
|
||||||
# else if the user scanned an offline signed tx
|
# else if the user scanned an offline signed tx
|
||||||
try:
|
|
||||||
data = bh2u(bitcoin.base_decode(data, length=None, base=43))
|
|
||||||
except BaseException as e:
|
|
||||||
self.show_error((_('Could not decode QR code')+':\n{}').format(repr(e)))
|
|
||||||
return
|
|
||||||
tx = self.tx_from_text(data)
|
tx = self.tx_from_text(data)
|
||||||
if not tx:
|
if not tx:
|
||||||
return
|
return
|
||||||
|
|
|
@ -914,7 +914,9 @@ def tx_from_any(raw: Union[str, bytes]) -> Union['PartialTransaction', 'Transact
|
||||||
return PartialTransaction.from_raw_psbt(raw)
|
return PartialTransaction.from_raw_psbt(raw)
|
||||||
except BadHeaderMagic:
|
except BadHeaderMagic:
|
||||||
pass
|
pass
|
||||||
return Transaction(raw)
|
tx = Transaction(raw)
|
||||||
|
tx.deserialize()
|
||||||
|
return tx
|
||||||
|
|
||||||
|
|
||||||
class PSBTGlobalType(IntEnum):
|
class PSBTGlobalType(IntEnum):
|
||||||
|
|
Loading…
Add table
Reference in a new issue