def _is_onchain_invoice_paid(self, invoice: BaseInvoice) -> Tuple[bool, Optional[int], Sequence[str]]:
        """Returns whether on-chain invoice/request is satisfied, num confs required txs have,
        and list of relevant TXIDs.
        """
        outputs = invoice.get_outputs()
        if not outputs:  # e.g. lightning-only
            return False, None, []
        invoice_amounts = defaultdict(int)  # type: Dict[bytes, int]  # scriptpubkey -> value_sats
        for txo in outputs:  # type: PartialTxOutput
            invoice_amounts[txo.scriptpubkey] += 1 if parse_max_spend(txo.value) else txo.value
        relevant_txs = set()
        is_paid = True
        conf_needed = None  # type: Optional[int]
        with self.lock:
            for invoice_scriptpubkey, invoice_amt in invoice_amounts.items():
                scripthash = bitcoin.script_to_scripthash(invoice_scriptpubkey)
                prevouts_and_values = self.db.get_prevouts_by_scripthash(scripthash)
                confs_and_values = []
                for prevout, v in prevouts_and_values:
                    relevant_txs.add(prevout.txid.hex())
                    tx_height = self.adb.get_tx_height(prevout.txid.hex())
                    if 0 < tx_height.height <= invoice.height:  # exclude txs older than invoice
                        continue
                    confs_and_values.append((tx_height.conf or 0, v))
                # check that there is at least one TXO, and that they pay enough.
                # note: "at least one TXO" check is needed for zero amount invoice (e.g. OP_RETURN)
                vsum = 0
                for conf, v in reversed(sorted(confs_and_values)):
                    vsum += v
                    if vsum >= invoice_amt:
                        conf_needed = min(conf_needed, conf) if conf_needed is not None else conf
                        break
                else:
                    is_paid = False
        return is_paid, conf_needed, list(relevant_txs)
Returns whether on-chain invoice/request is satisfied, num confs required txs have,
        and list of relevant TXIDs.
        
electrum/wallet.py