59 Commits

Author SHA1 Message Date
f321x 306cac192b lnaddr: rename LnAddr -> bolt11
The LnAddr, lndecode and lnencode naming didn't imply that it is
bolt 11 specific, making it confusing to work with, now that there are
also bolt 12 "lnaddr".
Renaming it to *bolt11* creates a clear separation to bolt 12 things and
reduces mental load.

This commit is pure renaming (using the PyCharm IDE refactor function),
except for the removal of the `object` inheritance of LnAddr/BOLT11Addr,
this is Python 2 legacy.
2026-04-27 16:28:19 +02:00
f321x a5f1a299e7 pi: don't match literal | char in regexes
The RE_EMAIL and RE_DOMAIN regexes matched the '|' character
which is probably not what they should do.
2026-04-13 09:30:37 +02:00
f321x ef702d74cd pi: handle lud-17 URI payment identifier
LNURL-W/P can also be encoded in lud-17 form instead of bech32.
https://github.com/lnurl/luds/blob/luds/17.md
e.g.
lnurlw://example.com/api/test123
lnurlp://example.com/api/test123
2026-04-13 09:30:28 +02:00
SomberNight 42ad18b216 rm bip70 support
- could not find a single project that still actually cares about bip70 [0]
    - well except maybe BitPay.
        - but I cannot test with BitPay:
            - they have a testnet3 staging environment on test.bitpay.com
                - but the SSL cert they use for bip70 has expired in 2021
                - the webUI probably also has not been updated since then...
                    - they claim to have added LN support in 2022 in a blog post,
                        but it's not there on test.bitpay.com
            - on mainnet, they require KYC before payment
                - < ... angry noises >
            - their loss then, I don't care.
- this is code that no one wants to maintain

- this does not yet delete the signed bip70 payment data for historical txs
    - but it is no longer possible to export it from the GUI

[0]: https://bitcoinops.org/en/topics/bip70-payment-protocol/
2026-03-20 18:12:55 +00:00
f321x dd1d98e37c pi: allow emaillike pi with 'lightning:' prefix
Lightning addresses with 'lightning:' do occur in the wild and make
sense (how else would e.g. the smartphone know to open a lightning
wallet instead of the e-mail client). So we should allow this.
2025-12-22 18:06:26 +01:00
f321x 2cd1de4f21 pi: fix incorrectly parsing emaillike with 'ln' prefix
Fixes a bug where we incorrectly parsed emaillike payment identifiers as
bech32 lightning payment identifier if they start with a 'ln' prefix.
2025-12-22 18:06:17 +01:00
SomberNight cdcac8cb09 openalias: always enforce DNSSEC validation succeeds 2025-12-05 17:06:41 +00:00
Sander van Grieken 0f2a41e078 simple_config: factor out self.decimal_point and self.get_decimal_point() in favor of self.BTC_AMOUNTS_DECIMAL_POINT 2025-11-27 12:38:49 +01:00
f321x fdeada3f51 lnurl: implement LNURL-withdraw
adds handling of lnurl-withdraw payment identifiers which allow users to
withdraw bitcoin from a service by scanning a qr code or pasting the
lnurl-w code as "sending" address.
2025-08-27 15:31:43 +02:00
f321x 40f11213df make openalias and lnaddress lookup concurrent 2025-05-20 10:08:36 +02:00
f321x 61492d361e Use async dnspython methods for openalias/dnssec 2025-05-16 17:09:41 +02:00
f321x b6e1e527c2 contacts: support lightning addressses as contact address
lightning addresses are useful and widely adopted, so it should be
possible to save them as payment identifier for a contact.
2025-05-15 17:55:23 +02:00
f321x 4e8db98d1b fix: SendTab not updating amount after text input change
When paying a 0 amount invoice, after clicking pay the entered amount
will get saved in
`PaymentIdentifier.boltPaymentIdentifier.bolt11.amount_msat`. However if
the user clicks cancel instead of pay, and then changes the amount,
amount_msat will not get updated, as it is not None anymore. If the user
clicks pay again, it will pay the previously entered wrong amount.
This checks the `LnAddr` amount instead of the `Invoice` amount.
2025-05-05 15:39:22 +02:00
Sander van Grieken c6a0018c52 payment_identifier: regard BIP21 without address and without bolt11 invalid 2024-10-08 10:33:08 +02:00
SomberNight 2f1095510c bitcoin.py/transaction.py: API changes: rm most hex usage
Instead of some functions operating with hex strings,
and others using bytes, this consolidates most things to use bytes.

This mainly focuses on bitcoin.py and transaction.py,
and then adapts the API usages in other files.

Notably,
- scripts,
- pubkeys,
- signatures
should be bytes in almost all places now.
2024-04-29 17:10:26 +00:00
Sander van Grieken 6d37e464f3 payment_identifier: don't assume bip70_data exists in has_expired() 2024-04-08 13:58:55 +02:00
Sander van Grieken ef87fbd3e5 payment_identifier: return onchain invoice when GUI requests MAX amount (fixes #8900) 2024-02-19 10:35:55 +01:00
SomberNight 1736558e3d type hints: follow-up prevprev. "union types as X | Y" needs py3.10
https://peps.python.org/pep-0604/
2024-02-07 11:03:55 +00:00
Sander van Grieken f811db4ec8 payment_identifier: imports, typing declarations 2024-02-07 11:03:52 +01:00
xiaolou86 50e5b0efd1 electrum: fix typos 2023-12-04 14:15:39 +08:00
Sander van Grieken 6ce8a583fd qt: add missing case for on-chain fallback for BIP21 payment identfier containing lightning invoice 2023-11-02 10:24:37 +01:00
Sander van Grieken ec8500bd55 payment_identifier: if a bip21 uri contains a lightning invoice without fallback address,
and an address is present in the bip21 uri path, register the on-chain address in the
Invoice.outputs field to allow paying onchain from a saved Invoice later (when the PI
is unavailable). Fixes #8654
2023-11-01 12:47:28 +01:00
Sander van Grieken f7bf4e146d payment_identifier: move adding openalias to contacts out of _do_resolve.
This fixes "cannot pickle '_thread.RLock' object" when paying from Contacts tab
2023-10-03 11:42:12 +02:00
Sander van Grieken 3ff588049e payment_identifier: output is only considered a script if written as call-like 'script(<script>)' 2023-09-25 17:15:00 +02:00
SomberNight 64ba3bd017 (trivial) do not use old-style (%) formatting inside translations
see https://github.com/spesmilo/electrum/blob/f29cd810e3f1049fc19e1bf4760b571124607c6b/electrum/i18n.py#L48
2023-09-07 13:25:35 +00:00
Sander van Grieken 307cf25fd4 register distinction between address and script for SPK type payment identifiers and allow zero amount for
script destinations.

This is mainly to support OP_RETURN outputs, which typically have a zero amount output value,
but as we don't special case OP_RETURN, this is currently done for all non-address scripts

Also, it's probably good to add a warning popup for OP_RETURN outputs with a non-zero output value, but this
would also need special casing for OP_RETURN.

Saving of script output payment identifiers is disabled for now, as reading the script from the stored invoice
back into human-readable form is currently not implemented, and currently only lightning invoices or address output
is supported.
2023-09-04 20:00:40 +02:00
SomberNight ffa3acc013 invoices: don't modify .amount_msat directly 2023-08-22 18:12:15 +00:00
SomberNight 7245762922 qt: fix lnurl-pay
regression from https://github.com/spesmilo/electrum/pull/8462
2023-08-22 17:00:17 +00:00
SomberNight e38605c10a CLI: fix regression re handling "unknown command", re payment_identifiers
```
$ ./run_electrum sadasdasddsa
Traceback (most recent call last):
  File "/home/user/wspace/electrum/./run_electrum", line 532, in <module>
    main()
  File "/home/user/wspace/electrum/./run_electrum", line 398, in main
    if uri and not PaymentIdentifier(None, uri).is_valid():
  File "/home/user/wspace/electrum/electrum/payment_identifier.py", line 136, in __init__
    self.parse(text)
  File "/home/user/wspace/electrum/electrum/payment_identifier.py", line 265, in parse
    elif contact := self.contacts.by_name(text):
AttributeError: 'NoneType' object has no attribute 'by_name'
```
2023-08-09 14:52:37 +00:00
Sander van Grieken b1b2190f0a payment_identifier: add payment_identifier_from_invoice function to reconstruct a PI from bip70 invoice 2023-07-11 16:43:49 +02:00
Sander van Grieken ad4b431738 payment_identifier: fix setting self.bolt11 to invoice in bip21 LN alt case 2023-07-11 15:24:03 +02:00
Sander van Grieken 33acfd3d1c followup d15050a2bf 2023-07-11 14:24:43 +02:00
Sander van Grieken 78a741e4a3 actually remove the FIXME 2023-07-11 14:19:54 +02:00
Sander van Grieken d15050a2bf payment_identifier: fix _on_finalize params, fix lnurlp send comment instead of description,
refactor payment_identifier.get_invoice to standalone invoice_from_payment_identifier
2023-07-11 14:15:17 +02:00
SomberNight f2dbf47413 payment_identifier.py: add some type hints, trivial clean-up 2023-07-10 17:59:56 +00:00
SomberNight 612a8e6424 qt: fix: bip70 pay reqs need x509 verification
regression from https://github.com/spesmilo/electrum/pull/8462

- pr.verify() was called in qml, but not in qt gui
- we now call pr.verify() in get_payment_request(), to make the API less error-prone
- it is now ok to call pr.verify() multiple times, the result is cached
2023-07-10 17:50:53 +00:00
ThomasV 6bacd65a80 payment_identifter: add FIXME 2023-07-09 10:05:31 +02:00
Sander van Grieken f980bd97b5 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
2023-07-08 12:18:37 +02:00
Sander van Grieken 7f766f6dfb payment_identifiers: also match local contacts 2023-07-07 22:54:46 +02:00
Sander van Grieken eeda06e751 payment_identifier: fix error path for bip70 2023-06-30 11:44:13 +02:00
Sander van Grieken 81544fdaed send_tab: simplify lock_recipient check 2023-06-28 16:49:28 +02:00
Sander van Grieken 30abcad999 payment_identifier: move amount_range into payment_identifier 2023-06-28 16:49:28 +02:00
Sander van Grieken fbb37d6fae payment_identifier: add DOMAINLIKE payment identifier type, support domainlike -> openalias 2023-06-28 16:49:28 +02:00
Sander van Grieken 5cc7948eee fix bip70 potentially not returning gui fields tuple 2023-06-28 16:49:28 +02:00
Sander van Grieken 0cbf403f8b use NamedTuple for payment identifier gui fields 2023-06-28 16:49:28 +02:00
Sander van Grieken 3a1e5244b8 qt: fix enable/disable max button for openalias and restrict openalias to address only 2023-06-28 16:49:28 +02:00
Sander van Grieken eed016bd7e qt: move setting frozen styling to edit components themselves, fix re-enabling Clear button after finalize 2023-06-28 16:49:28 +02:00
Sander van Grieken 74a1f38a8b payment identifier types as enum 2023-06-28 16:49:28 +02:00
Sander van Grieken fc141c0182 payment_identfier: refactor qml and tests 2023-06-28 16:49:28 +02:00
Sander van Grieken 915f66c0b8 payment_identifier: fix emaillike
qt: validate on pushback timer, buttons enable/disable, cleanup
2023-06-28 16:49:28 +02:00