Commit Graph

68 Commits

Author SHA1 Message Date
SomberNight 9f1b8613d0 swaps: code style clean-up, add type hints, force kwargs
no intended functional changes
2023-11-22 17:50:29 +00: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
SomberNight abe700167f qt send tab: HelpLabel for "pay to" field: update text
- maybe make it more readable
- mention new syntax for raw scripts
  - see 3ff588049e
2023-10-24 16:47:05 +00: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
SomberNight 4c63d8729b add sanity checks we don't sign tx including dummy addr
Somewhat a follow-up to 649ce979ab.

This adds some safety belts so we don't accidentally sign a tx that
contains a dummy address.
Specifically we check that tx does not contain output for dummy addr:
- in wallet.sign_transaction
- in network.broadcast_transaction

The second one is perhaps redundant, but I think it does not hurt.
2023-09-16 04:36:08 +00:00
ThomasV 9df8bb61a5 Give users an option to cancel a submarine swap while awaiting HTLCs.
Note that HTLCs must not be cancelled after the funding transaction
has been broadcast. If one want to cancel a swap once the funding
transaction is in mempool, one should double spend the transaction.
2023-09-13 16:28:31 +02:00
ThomasV 649ce979ab send tx change to lightning 2023-09-09 14:14:43 +02: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
Sander van Grieken 0d96bc1dbd qt/send_tab: fix regressions paymentidentifier
Fix '!' amount expand while PaymentIdentifier not set due to editor pushback timer.
Fix '!' amount expand for BIP21 without a specified payment amount.
2023-09-04 15:55:23 +02:00
SomberNight 7245762922 qt: fix lnurl-pay
regression from https://github.com/spesmilo/electrum/pull/8462
2023-08-22 17:00:17 +00:00
Sander van Grieken 0d7ff92c43 send_tab: remove payment_identifier comments in send_tab 2023-07-11 19:54:07 +02:00
Sander van Grieken 40f15b158c payment_identifier: reconstruct PI for bip70 invoice in pay_onchain_dialog instead of taking the send_tab PI 2023-07-11 17:16:27 +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 bb8c73cabd qt: kind of fix bip70 notify_merchant logic by passing around PI
```
229.18 | E | gui.qt.main_window.[test_segwit_2] | on_error
Traceback (most recent call last):
  File "...\electrum\gui\qt\util.py", line 917, in run
    result = task.task()
  File "...\electrum\gui\qt\send_tab.py", line 681, in broadcast_thread
    if self.payto_e.payment_identifier.has_expired():
AttributeError: 'NoneType' object has no attribute 'has_expired'
```

In SendTab.broadcast_transaction.broadcast_thread, self.payto_e.payment_identifier was referenced -
but do_clear() has already cleared it by then.
E.g. consider SendTab.pay_onchain_dialog: it calls save_pending_invoice(), which calls do_clear(),
and later (in sign_done), it calls window.broadcast_or_show, which will call SendTab.broadcast_transaction().

As there might be multiple independent transaction dialogs open simultaneously, the single shared state
send_tab.payto_e.payment_identifier approach was problematic -- I think it is conceptually nicer to
pass around the payment_identifiers as needed, as done with this change.

However, this change is not a full proper fix, as it still somewhat relies on
send_tab.payto_e.payment_identifier (e.g. in pay_onchain_dialog). Hence, e.g. when using
the invoice_list context menu "Pay..." item, as payto_e.payment_identifier is not set,
payment_identifier will be None in broadcast_transaction.

but at least we handle PI being None gracefully -- before this change, broadcast_transaction
expected PI to be set, and it was never set to the correct thing (as do_clear() already ran by then):
depending on timing it was either None or a new empty PI. In the former case, producing the above
traceback and hard failing (not only for bip70 stuff!), and in the latter, silently ignoring the logic bug.
2023-07-10 18:16:56 +00:00
Sander van Grieken ae8c4f1281 payment_identifier: check if payment identifier is usable and enable/disable Send/Pay buttons 2023-07-08 12:19:37 +02:00
Sander van Grieken b6010aad0f paytoedit: promote to QWidget and encapsulate QLineEdit vs QTextEdit juggling 2023-07-03 16:33:07 +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 49dab82efa send_tab: add spinner for network lookup indication 2023-06-28 16:49:28 +02:00
Sander van Grieken febb2222d4 send_tab: simplify lock_max 2023-06-28 16:49:28 +02:00
Sander van Grieken 3df13b8ce4 qt: disallow save of LNURLp/LnAddr 2023-06-28 16:49:28 +02:00
Sander van Grieken 6b57743c3e send_tab: add LNURLp range as tooltip on amount field 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 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 915f66c0b8 payment_identifier: fix emaillike
qt: validate on pushback timer, buttons enable/disable, cleanup
2023-06-28 16:49:28 +02:00
Sander van Grieken bde066f9ce qt: refactor send_tab, paytoedit 2023-06-28 16:49:28 +02:00
Sander van Grieken d9a43fa6ed refactor last callback, signals. remove timered validate, don't add invalid address/amount to outputs 2023-06-28 16:49:28 +02:00
Sander van Grieken b1925f8747 payment_identifier: refactor round_3 to need_merchant_notify/notify_merchant 2023-06-28 16:49:28 +02:00
Sander van Grieken 7601726d29 payment_identifier: refactor round_2 to need_finalize/finalize stage 2023-06-28 16:49:28 +02:00
Sander van Grieken 508d1038d3 payment_identifier: define states, refactor round_1 into resolve stage 2023-06-28 16:49:28 +02:00
Sander van Grieken a2ca191de1 pass wallet to PaymentIdentifier instead of config and contacts 2023-06-28 16:49:28 +02:00
Sander van Grieken cbd388c297 fix flake8 issues (undefined references) 2023-06-28 16:49:28 +02:00
ThomasV 15eb765eac payment_identifiers:
- this separates GUI from core handling
 - the PaymentIdentifier class handles network requests
 - the GUI is agnostic about the type of PI
2023-06-28 16:49:28 +02:00
SomberNight 1a2d4494eb qt: fix sweeping
closes https://github.com/spesmilo/electrum/issues/8340

regression from 2f6d60c715
2023-04-23 15:10:38 +00:00
SomberNight 89b75f95d0 wallet.set_broadcasting: fix incorrect type-hint and rename arg 2023-04-19 16:29:54 +00:00
SomberNight e24f837fbf qt send tab: rm incorrect bare raise
follow-up bc3946d2f4

not sure what the raise was trying to do;
note that relevant exception handling is done at:
https://github.com/spesmilo/electrum/blob/bba8a272e78ae8961dffd37060801bf28b934dd9/electrum/gui/qt/main_window.py#L1213-L1217
although note the TODO in main_window.on_error: would be nice to propagate some of the exceptions to the crash reporter

closes https://github.com/spesmilo/electrum/issues/8312
2023-04-19 16:25:39 +00:00
SomberNight bba8a272e7 qt send tab: rm unused variable and add explanation 2023-04-19 16:18:57 +00:00
SomberNight e617dd07a0 qt send tab: fix payto_contacts
closes https://github.com/spesmilo/electrum/issues/8313
2023-04-19 16:08:24 +00:00
ThomasV f04e2e2e6f Add an extra state for invoices where our tx has been broadcast
successfully, but it is not in our history yet.

(follow-up 159646fe54)
2023-04-04 19:31:25 +02:00
ThomasV 159646fe54 Set status of onchain invoices to PR_INFLIGHT while tx is being broadcast 2023-04-04 18:22:30 +02:00
ThomasV 8e3a3cefcf qt: do not mutate already saved invoice after editing amount.
Also show empty an string for invoices that do not have an amount,
similar to the requests list.
2023-04-04 11:21:26 +02:00
ThomasV 545ee24f46 Qt: move new_channel_dialog to main_window and test available amount beforehand 2023-04-02 10:07:34 +02:00
ThomasV 3fb3e3b809 lnurl6: pay invoice directly 2023-03-21 17:08:36 +01:00
ThomasV 4fa192d9e7 follow-up c3e52bfafc 2023-03-20 11:09:18 +01:00
ThomasV 4243b250b1 qt send_tab: simplify method names.
when a method belongs to a class, there is no need to repeat the
class name in the method name.
2023-03-19 10:44:33 +01:00
ThomasV c3e52bfafc Qt: allow to save invoices that have no amount
(such invoices are already saved by the QML GUI.)
2023-03-19 09:52:47 +01:00
SomberNight a6c4069617 qt send_tab: allow saving bip70 payment requests
probably got disabled in or around https://github.com/spesmilo/electrum/pull/7839 by accident
2023-03-14 14:54:15 +00:00