|
|
|
|
@ -11,12 +11,12 @@ from .contacts import AliasNotFoundException
|
|
|
|
|
from .i18n import _ |
|
|
|
|
from .invoices import Invoice |
|
|
|
|
from .logging import Logger |
|
|
|
|
from .util import parse_max_spend, format_satoshis_plain, InvoiceError |
|
|
|
|
from .util import parse_max_spend, InvoiceError |
|
|
|
|
from .util import get_asyncio_loop, log_exceptions |
|
|
|
|
from .transaction import PartialTxOutput |
|
|
|
|
from .lnurl import decode_lnurl, request_lnurl, callback_lnurl, LNURLError, lightning_address_to_url |
|
|
|
|
from .bitcoin import COIN, TOTAL_COIN_SUPPLY_LIMIT_IN_BTC, opcodes, construct_script |
|
|
|
|
from .lnaddr import lndecode, LnDecodeException, LnInvoiceException |
|
|
|
|
from .bitcoin import opcodes, construct_script |
|
|
|
|
from .lnaddr import LnInvoiceException |
|
|
|
|
from .lnutil import IncompatibleOrInsaneFeatures |
|
|
|
|
from .bip21 import parse_bip21_URI, InvalidBitcoinURI, LIGHTNING_URI_SCHEME, BITCOIN_BIP21_URI_SCHEME |
|
|
|
|
from . import paymentrequest |
|
|
|
|
@ -504,7 +504,7 @@ class PaymentIdentifier(Logger):
|
|
|
|
|
self.logger.debug(f'multiline: {outputs!r}, {self.error}') |
|
|
|
|
return outputs |
|
|
|
|
|
|
|
|
|
def parse_address_and_amount(self, line: str) -> 'PartialTxOutput': |
|
|
|
|
def parse_address_and_amount(self, line: str) -> PartialTxOutput: |
|
|
|
|
try: |
|
|
|
|
x, y = line.split(',') |
|
|
|
|
except ValueError: |
|
|
|
|
@ -515,7 +515,7 @@ class PaymentIdentifier(Logger):
|
|
|
|
|
amount = self.parse_amount(y) |
|
|
|
|
return PartialTxOutput(scriptpubkey=scriptpubkey, value=amount) |
|
|
|
|
|
|
|
|
|
def parse_output(self, x: str) -> Tuple[bytes, bool]: |
|
|
|
|
def parse_output(self, x: str) -> Tuple[Optional[bytes], bool]: |
|
|
|
|
try: |
|
|
|
|
address = self.parse_address(x) |
|
|
|
|
return bytes.fromhex(bitcoin.address_to_script(address)), True |
|
|
|
|
@ -530,7 +530,7 @@ class PaymentIdentifier(Logger):
|
|
|
|
|
|
|
|
|
|
return None, False |
|
|
|
|
|
|
|
|
|
def parse_script(self, x: str): |
|
|
|
|
def parse_script(self, x: str) -> str: |
|
|
|
|
script = '' |
|
|
|
|
for word in x.split(): |
|
|
|
|
if word[0:3] == 'OP_': |
|
|
|
|
@ -541,7 +541,7 @@ class PaymentIdentifier(Logger):
|
|
|
|
|
script += construct_script([word]) |
|
|
|
|
return script |
|
|
|
|
|
|
|
|
|
def parse_amount(self, x: str): |
|
|
|
|
def parse_amount(self, x: str) -> str | int: |
|
|
|
|
x = x.strip() |
|
|
|
|
if not x: |
|
|
|
|
raise Exception("Amount is empty") |
|
|
|
|
|