payment_identifier: factor out bip21 functions to bip21.py to break cyclic dependencies,
parse bolt11 only once, store invoice internally instead of bolt11 string add is_onchain method to indicate if payment identifier can be paid onchain
This commit is contained in:
@@ -87,7 +87,7 @@ Label.register(
|
||||
|
||||
|
||||
from electrum.util import NoDynamicFeeEstimates, NotEnoughFunds, UserFacingException
|
||||
from electrum.payment_identifier import BITCOIN_BIP21_URI_SCHEME, LIGHTNING_URI_SCHEME
|
||||
from electrum.bip21 import BITCOIN_BIP21_URI_SCHEME, LIGHTNING_URI_SCHEME
|
||||
|
||||
from .uix.dialogs.lightning_open_channel import LightningOpenChannelDialog
|
||||
from .uix.dialogs.lightning_channels import LightningChannelsDialog, SwapDialog
|
||||
|
||||
@@ -19,7 +19,8 @@ from electrum import bitcoin, constants
|
||||
from electrum import lnutil
|
||||
from electrum.transaction import tx_from_any, PartialTxOutput
|
||||
from electrum.util import TxMinedInfo, InvoiceError, format_time, parse_max_spend
|
||||
from electrum.payment_identifier import parse_bip21_URI, BITCOIN_BIP21_URI_SCHEME, maybe_extract_lightning_payment_identifier, InvalidBitcoinURI
|
||||
from electrum.bip21 import BITCOIN_BIP21_URI_SCHEME, parse_bip21_URI, InvalidBitcoinURI
|
||||
from electrum.payment_identifier import maybe_extract_lightning_payment_identifier
|
||||
from electrum.lnaddr import lndecode, LnInvoiceException
|
||||
from electrum.lnurl import decode_lnurl, request_lnurl, callback_lnurl, LNURLError, LNURL6Data
|
||||
from electrum.logging import Logger
|
||||
|
||||
@@ -16,7 +16,7 @@ from PyQt5.QtQml import qmlRegisterType, qmlRegisterUncreatableType, QQmlApplica
|
||||
from electrum import version, constants
|
||||
from electrum.i18n import _
|
||||
from electrum.logging import Logger, get_logger
|
||||
from electrum.payment_identifier import BITCOIN_BIP21_URI_SCHEME, LIGHTNING_URI_SCHEME
|
||||
from electrum.bip21 import BITCOIN_BIP21_URI_SCHEME, LIGHTNING_URI_SCHEME
|
||||
from electrum.base_crash_reporter import BaseCrashReporter, EarlyExceptionsQueue
|
||||
from electrum.network import Network
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@ from electrum.lnutil import format_short_channel_id, IncompatibleOrInsaneFeature
|
||||
from electrum.lnurl import decode_lnurl, request_lnurl, callback_lnurl
|
||||
from electrum.bitcoin import COIN
|
||||
from electrum.paymentrequest import PaymentRequest
|
||||
from electrum.payment_identifier import (parse_bip21_URI, InvalidBitcoinURI, maybe_extract_lightning_payment_identifier,
|
||||
from electrum.payment_identifier import (maybe_extract_lightning_payment_identifier,
|
||||
PaymentIdentifier, PaymentIdentifierState, PaymentIdentifierType)
|
||||
|
||||
from electrum.bip21 import parse_bip21_URI, InvalidBitcoinURI
|
||||
from .qetypes import QEAmount
|
||||
from .qewallet import QEWallet
|
||||
from .util import status_update_timer_interval, QtEventListener, event_listener
|
||||
@@ -526,7 +526,7 @@ class QEInvoiceParser(QEInvoice):
|
||||
self.validationSuccess.emit()
|
||||
return
|
||||
elif self._pi.type == PaymentIdentifierType.BOLT11:
|
||||
lninvoice = Invoice.from_bech32(self._pi.bolt11)
|
||||
lninvoice = self._pi.bolt11
|
||||
if not self._wallet.wallet.has_lightning() and not lninvoice.get_address():
|
||||
self.validationError.emit('no_lightning',
|
||||
_('Detected valid Lightning invoice, but Lightning not enabled for wallet and no fallback address found.'))
|
||||
@@ -539,7 +539,7 @@ class QEInvoiceParser(QEInvoice):
|
||||
self.validationSuccess.emit()
|
||||
elif self._pi.type == PaymentIdentifierType.BIP21:
|
||||
if self._wallet.wallet.has_lightning() and self._wallet.wallet.lnworker.channels and self._pi.bolt11:
|
||||
lninvoice = Invoice.from_bech32(self._pi.bolt11)
|
||||
lninvoice = self._pi.bolt11
|
||||
self.setValidLightningInvoice(lninvoice)
|
||||
self.validationSuccess.emit()
|
||||
else:
|
||||
|
||||
@@ -57,7 +57,8 @@ from electrum.i18n import _
|
||||
from electrum.util import (format_time, UserCancelled, profiler, bfh, InvalidPassword,
|
||||
UserFacingException, get_new_wallet_name, send_exception_to_crash_reporter,
|
||||
AddTransactionException, os_chmod)
|
||||
from electrum.payment_identifier import BITCOIN_BIP21_URI_SCHEME, PaymentIdentifier
|
||||
from electrum.bip21 import BITCOIN_BIP21_URI_SCHEME
|
||||
from electrum.payment_identifier import PaymentIdentifier
|
||||
from electrum.invoices import PR_PAID, Invoice
|
||||
from electrum.transaction import (Transaction, PartialTxInput,
|
||||
PartialTransaction, PartialTxOutput)
|
||||
|
||||
Reference in New Issue
Block a user