Commit Graph

62 Commits

Author SHA1 Message Date
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
ThomasV 9b41bcf992 setFrozen: use light blue, black text is difficult to read on a blue background 2023-07-07 17:05:08 +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 fbb37d6fae payment_identifier: add DOMAINLIKE payment identifier type, support domainlike -> openalias 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 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 7601726d29 payment_identifier: refactor round_2 to need_finalize/finalize 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
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 417423ecd7 qt: PayToEdit: fix input_qr_from_camera
closes https://github.com/spesmilo/electrum/issues/8342

probably regression from 1f4cedf56a
2023-04-24 00:58:41 +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 4fa192d9e7 follow-up c3e52bfafc 2023-03-20 11:09:18 +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 d166fa886e qt: fix paying to openalias
Probably got broken in https://github.com/spesmilo/electrum/pull/7839 ,
which got released in 4.3.0, ~7 months ago.
As no one complained, this really again raises the question of removing openalias...

related https://github.com/spesmilo/electrum/issues/6232
2023-03-14 17:21:33 +00:00
ThomasV 1f4cedf56a Rework PaytoEdit:
- show a QLineEdit by default, a QTextEdit only if paytomany is active.
   paytomany is a rare use case, it should not interfer with regular
   use (e.g. when a user inadvertently types enter).
 - this also fixes the visual appearance if the payto line
 - keep paytomany menu in sync with actual state
2023-03-14 15:37:20 +01:00
ThomasV b15387c89b Qt send tab: move payto_edit input buttons to toolbar 2023-03-13 08:55:45 +01:00
SomberNight abef454237 qt: better handle unparseable URIs
fixes https://github.com/spesmilo/electrum/issues/7941
2022-08-16 15:27:13 +00:00
SomberNight 2d68350900 qt: (refactor) split "send tab" out from main_window.py 2022-06-30 20:29:08 +02:00
SomberNight ed1567e841 lnurl: make requests async, don't block Qt GUI, rm LUD-16 support
- in lnurl.py, make request methods async
- in Qt GUI, lnurl network requests no longer block the GUI thread
  - but they still do in the kivy GUI
- "lightning address" (LUD-16) support is removed for now as the
  email addresses are indistinguishable from openalias email addresses
  (both protocols should have added and enforced a prefix, or similar,
   to remove this kind of ambiguity -- now we would need to make a
   network request just to identify what kind of ID we were given)
2022-06-29 16:56:04 +02:00
SomberNight df974c2384 qt paytoedit: evaluate text on textChanged(), but no network requests
- add param to _check_text to toggle if network requests are allowed ("full check")
- every 0.5 sec, if the textedit has no focus, do full check
- on textChanged()
  - detect if user copy-pasted by comparing current text against clipboard contents,
    if so, do full check
  - otherwise, do partial check
- on clicking ButtonsWidget btns (scan qr, paste, read file), do full check
2022-06-29 16:18:30 +02:00
SomberNight 649cad0122 lnurl: clean-up 2022-06-29 16:18:23 +02:00
bitromortac fe2fbbd9b1 add lnurl-pay and lightning address support
* bundles all payment identifiers into handle_payment_identifier
* adds lnurl decoding
* adds lightning address decoding
2022-06-29 16:18:15 +02:00
Axel Gembe 01d20cba49 qt PayToEdit: various fixes, incl icon size/pos, field size, scrollbar
this ports https://github.com/Electron-Cash/Electron-Cash/pull/1371

including commits:
---
https://github.com/Electron-Cash/Electron-Cash/commit/bab816e2c3ace1624f6e981e947bcf1440728852

Buttons Editor: Make background non-transparent and change to push button

There were some issues with transparent backgrounds with QToolButton on
Linux and as there is no real reason for them to be transparent we just
make them opaque.
---
https://github.com/Electron-Cash/Electron-Cash/commit/2cb698affc3ddf1049f1fdd5d55a842b9b7c192b
Pay to editor: Fix size computations to use the proper values

Previously this did not take into account the spacing between lines nor
the margins of the control and the document. There is also a sensible
minimum height of one line now and it expands to up to 10 lines before
we show the scroll bar. When the scroll bar is active, we move the buttons
so they do not obscure the scroll bar.
---
https://github.com/Electron-Cash/Electron-Cash/commit/1b7a70f4f5b9362ca83d4d35627135bbd0d19aec
Pay to editor: Increase height by one if cursor is under buttons
---
https://github.com/Electron-Cash/Electron-Cash/commit/abd42d9f664960210d0c2df29c6ff9dfd6d44015
 Buttons Editor: Always center if the document is just one line high
---
https://github.com/Electron-Cash/Electron-Cash/commit/33bd0b82e0fac5bfd2447b06668889fa249213c9
Pay to editor: Make button movement on scrollbar change reliable
---
https://github.com/Electron-Cash/Electron-Cash/commit/94f8476c2e89584275280de280a93a18ad0194a3
Pay to editor: Use document lineCount instead of height
---
https://github.com/Electron-Cash/Electron-Cash/commit/5bedfce392a0aac0345a1c070c72d75d9449ea18
Buttons Editor: Improve vertical centering of the buttons, needs to take into account the frame width
---
https://github.com/Electron-Cash/Electron-Cash/commit/0cd0b490c45620a5700b0c1ccfad5d3593dbe6ff
Buttons Editor: Add transparent border which is somehow needed for correct macOS layout
2022-06-01 18:24:37 +02:00
Axel Gembe 2d1727520f qt ButtonsWidget: refactor into OverlayControlMixin; fix alignmt/hover
This ports the following:
https://github.com/Electron-Cash/Electron-Cash/commit/782f213bbd945bb4e74dc73116afdaac5ddc9d84
https://github.com/Electron-Cash/Electron-Cash/commit/2e5af27a7ce65c3da6632b4787c70ff8359a8d2c
https://github.com/Electron-Cash/Electron-Cash/commit/889fcbd26aa85dd0c0b8a9537071c816e996835e
https://github.com/Electron-Cash/Electron-Cash/commit/c07b0ad616f136dc6c9f52d825d5a2add59a5175
2022-06-01 17:27:32 +02:00
SomberNight 2e260bd602 qt PayToEdit: rm redundant code
This is already handled by `self.textChanged.connect(self.check_text)` in __init__.
2022-05-14 01:28:37 +02:00
SomberNight 433c6762c9 Qt Send tab: handle exc when "." is entered into amount_e
To reproduce: enter "." to amount_e in Send tab; then click "Save".

Traceback (most recent call last):
  File "/home/user/wspace/electrum/electrum/gui/qt/main_window.py", line 1638, in do_save_invoice
    self.pending_invoice = self.read_invoice()
  File "/home/user/wspace/electrum/electrum/gui/qt/main_window.py", line 1625, in read_invoice
    outputs = self.read_outputs()
  File "/home/user/wspace/electrum/electrum/gui/qt/main_window.py", line 1501, in read_outputs
    outputs = self.payto_e.get_outputs(self.max_button.isChecked())
  File "/home/user/wspace/electrum/electrum/gui/qt/paytoedit.py", line 235, in get_outputs
    self.outputs = [PartialTxOutput(scriptpubkey=self.payto_scriptpubkey, value=amount)]
  File "/home/user/wspace/electrum/electrum/transaction.py", line 1533, in __init__
    TxOutput.__init__(self, *args, **kwargs)
  File "/home/user/wspace/electrum/electrum/transaction.py", line 113, in __init__
    raise ValueError(f"bad txout value: {value!r}")
ValueError: bad txout value: None
2021-09-19 16:53:58 +02:00
Siddhant Chawla 65c3a892cf Multiple max spends functionality added (#7492)
this implements https://github.com/spesmilo/electrum/issues/7054
2021-09-15 14:35:15 +00:00
bitromortac c65caf6c68 qt+android: add lightning URI support 2021-07-30 08:44:15 +02:00
SomberNight c1dbcab9bb qt: new qrreader using QtMultimedia; drop CalinsQRReader(mac)
This commit ports the work of EchterAgo and cculianu from Electron-Cash,
to implement a new toolchain to scan qr codes.

Previously, on Linux and Win, we have been using zbar to access the camera
and read qrcodes; and on macOS we used CalinsQRReader (an objective-C
project by cculianu).

The new toolchain added here can use QtMultimedia to access the camera,
and then feed that image into zbar. When used this way, zbar needs
fewer dependencies and is easier to compile, in particular it can be
compiled for macOS.

The new toolchain works on all three platforms, with some caveats
(see code comments in related commits) -- so we also keep the end-to-end
zbar toolchain; but at least we can drop CalinsQRReader.

The related changes in Electron-Cash are spread over 50+ commits (several PRs and direct
pushes to master), but see in particular:
https://github.com/Electron-Cash/Electron-Cash/pull/1376

some other interesting links:
https://github.com/Electron-Cash/Electron-Cash/commit/b2b737001c8cc41a38fa580ea252a6d24e08f5d5
https://github.com/Electron-Cash/Electron-Cash/commit/163224cf1fad3af63f2d3cbe68a34fb8ff279af6
https://github.com/Electron-Cash/Electron-Cash/commit/3b31e0fcb13f67646228ff42c0dd39d2a0912291
https://github.com/Electron-Cash/Electron-Cash/commit/eda015908e9d6ea9a0adfbda9db55b929c0926ba
https://github.com/Electron-Cash/Electron-Cash/pull/1545
https://github.com/Electron-Cash/Electron-Cash/commit/052aa06c23b939adcea07c701f70ae28ebcf9e0a
2021-06-25 16:51:58 +02:00
zebra-lucky 12c9de6bf9 qt: fix PayToEdit.parse_amount (#6951)
nicer error messages for malformed inputs
2021-01-18 22:07:29 +00:00
SomberNight 096d853482 qt: rm some usages of get_parent_main_window
instead, pass around the main window or config (whichever is actually needed)

fixes #6342
2020-12-20 15:25:31 +01:00
SomberNight d40bedb2ac also support uppercase bip21 URIs
related https://github.com/btcpayserver/btcpayserver/issues/2110
2020-12-09 16:09:12 +01:00
SomberNight 4bd4fc7697 qt send tab: (regression) fix handling multiline fmt for single line
fixes #6761
2020-11-25 00:03:38 +01:00
SomberNight b95525896f qt send tab: show friendlier error on mistyped bitcoin address 2020-10-25 04:24:31 +01:00
SomberNight 4c7a92f39c bitcoin: implement construct_script and use it 2020-10-24 07:49:06 +02:00
SomberNight cb41a0fe89 qt send tab paytoedit: use monospace font 2020-01-21 14:32:18 +01:00
SomberNight b16164da4f qt paytoedit: fixes for pay-to-many (when including "!") 2020-01-18 04:15:26 +01:00
SomberNight d08ed6410a python3.8: fix DeprecationWarning in qt/paytoedit
.../electrum/electrum/gui/qt/paytoedit.py:221: DeprecationWarning: an integer is required (got type float).  Implicit conversion to integers using __int__ is deprecated, and may be removed in a future version of Python.
  self.setMinimumHeight(h)
2019-12-10 23:01:01 +01:00
SomberNight 4057140e6a lightning qr codes: more robust parsing
kivy qr code handling did not accept "lightning:" prefix or uppercase
2019-11-20 03:21:59 +01:00
SomberNight bafe8a2fff integrate PSBT support natively. WIP 2019-11-04 22:24:36 +01:00
SomberNight 8dabdf8bfb qt send tab: handle invalid ln invoice; and ln invoice with ln disabled
fixes #5639
fixes #5662
2019-10-01 19:15:26 +02:00
ThomasV aaed594772 Simplify invoices and requests.
- We need only two types: PR_TYPE_ONCHAIN and PR_TYPE_LN
 - BIP70 is no longer a type, but an optional field in the dict
 - Invoices in the wallet are indexed by a hash of their serialized list of outputs.
 - Requests are still indexed by address, because we never generate Paytomany requests.
 - Add 'clear_invoices' command to CLI
 - Add 'save invoice' button to Qt
2019-09-12 20:11:20 +02:00
ThomasV 3076eb75ea make parsing lightning qr codes more robust 2019-08-27 17:12:43 +02:00
ThomasV a5ab431b4b parse invoices with lightning: prefix 2019-08-20 09:03:10 +02:00
ThomasV f2b40c69fc do not set background in frozen_style, it does not look good with dark theme 2019-08-20 09:03:10 +02:00
ThomasV 34d5f1b2e3 lightning: connect send button 2019-08-20 09:03:10 +02:00
ThomasV 12d3877873 lightning GUI: use existing receive and send tabs with lightning invoices 2019-08-20 09:03:10 +02:00
SomberNight aac9826e1b qt paytoedit: better height adjustment
was sometimes weird...
e.g. pasting several lines of outputs would leave the textedit single line
2019-05-04 04:39:59 +02:00