Commit Graph

44 Commits

Author SHA1 Message Date
SomberNight
24980feab7 config: introduce ConfigVars
A new config API is introduced, and ~all of the codebase is adapted to it.
The old API is kept but mainly only for dynamic usage where its extra flexibility is needed.

Using examples, the old config API looked this:
```
>>> config.get("request_expiry", 86400)
604800
>>> config.set_key("request_expiry", 86400)
>>>
```

The new config API instead:
```
>>> config.WALLET_PAYREQ_EXPIRY_SECONDS
604800
>>> config.WALLET_PAYREQ_EXPIRY_SECONDS = 86400
>>>
```

The old API operated on arbitrary string keys, the new one uses
a static ~enum-like list of variables.

With the new API:
- there is a single centralised list of config variables, as opposed to
  these being scattered all over
- no more duplication of default values (in the getters)
- there is now some (minimal for now) type-validation/conversion for
  the config values

closes https://github.com/spesmilo/electrum/pull/5640
closes https://github.com/spesmilo/electrum/pull/5649

Note: there is yet a third API added here, for certain niche/abstract use-cases,
where we need a reference to the config variable itself.
It should only be used when needed:
```
>>> var = config.cv.WALLET_PAYREQ_EXPIRY_SECONDS
>>> var
<ConfigVarWithConfig key='request_expiry'>
>>> var.get()
604800
>>> var.set(3600)
>>> var.get_default_value()
86400
>>> var.is_set()
True
>>> var.is_modifiable()
True
```
2023-05-25 17:39:48 +00:00
SomberNight
03ab33f4b2 SimpleConfig: change API of set_key(): "save" is now kwarg-only 2023-05-25 17:37:16 +00:00
Sander van Grieken
a8a0b36fdb qml: code style, imports 2023-05-09 16:15:09 +02:00
Sander van Grieken
ab19ece4e0 qml: refactor TxOutput into reusable component 2023-05-09 15:50:29 +02:00
Sander van Grieken
9d11aae394 qml: take internal, external, billing address colors from desktop client and color output addresses
accordingly in ConfirmTxDialog, TxDetails, CpfpBumpFeeDialog, RbfBumpFeeDialog and RbfCancelDialog
2023-05-04 13:26:56 +02:00
Sander van Grieken
0d536b83ba qml: ignore update() when wallet not set yet. closes #8330 2023-04-22 12:18:02 +02:00
SomberNight
2ec4758a12 qml: follow-up fix for offline-signing pre-segwit tx
follow-up 3cec6cdcfb
2023-04-21 17:14:49 +00:00
SomberNight
ae8501e5be qml: small fix in qetxfinalizer.py
follow-up 3cec6cdcfb
2023-04-21 14:35:37 +00:00
Sander van Grieken
3cec6cdcfb qml: second part of partially signing tx while not having txid yet 2023-04-21 15:09:33 +02:00
Sander van Grieken
1aa14e749a qml: first part of partially signing tx while not having txid yet 2023-04-21 00:10:15 +02:00
ThomasV
d0947bc0a6 follow-up 48689ecc89 2023-04-01 15:47:32 +02:00
ThomasV
48689ecc89 qml tx details and rbf dialogs: use a single InfoTextArea, to the
top of each dialog.

Do not display 'cannot bump fee' as the first thing we see when we
enter the bump fee dialog; suggest to move the slider instead.
2023-04-01 15:10:44 +02:00
Sander van Grieken
c08ca94591 qml: support create & save transaction on watch-only wallet, refactor showExport and supply
relevant help text when sharing a transaction
2023-03-30 12:28:09 +02:00
SomberNight
81772faf6c wallet: add_input_info to no longer do network requests
- wallet.add_input_info() previously had a fallback to download parent
  prev txs from the network (after a lookup in wallet.db failed).
  wallet.add_input_info() is not async, so the network request cannot
  be done cleanly there and was really just a hack.
- tx.add_info_from_wallet() calls wallet.add_input_info() on each txin,
  in which case these network requests were done sequentially, not concurrently
- the network part of wallet.add_input_info() is now split out into new method:
  txin.add_info_from_network()
- in addition to tx.add_info_from_wallet(), there is now also tx.add_info_from_network()
  - callers of old tx.add_info_from_wallet() should now called either
    - tx.add_info_from_wallet(), then tx.add_info_from_network(), preferably in that order
    - tx.add_info_from_wallet() alone is sufficient if the tx is complete,
      or typically when not in a signing context
- callers of wallet.bump_fee and wallet.dscancel are now expected to have already
  called tx.add_info_from_network(), as it cannot be done in a non-async context
  (but for the common case of all-inputs-are-ismine, bump_fee/dscancel should work regardless)
- PartialTxInput.utxo was moved to the baseclass, TxInput.utxo
2023-03-12 00:21:57 +00:00
ThomasV
74718e9085 confirm_tx_dialog: separate messages from warnings. add warnings about tx batching and spending unconfirmed coins 2023-03-06 19:25:46 +01:00
Sander van Grieken
fa45e1b7ba qml: fix name clash QML vs registered QObjects NewWalletWizard and ServerConnectWizard 2023-02-16 13:22:24 +01:00
Sander van Grieken
d3d66e7248 qml: RbF: do not decrease payment when payment is a swap
ref f617887509
2023-02-14 16:26:04 +01:00
Sander van Grieken
a986e61047 qml: implement RbF bump methods Decrease payment/Preserve payment
extend FormattedAmount to wrap alt to next line, or show as empty when invalid
2023-01-16 13:15:24 +01:00
Sander van Grieken
b7106fd746 qml: show QR when finalized and saved 2023-01-13 22:39:01 +01:00
Sander van Grieken
3b7a09a307 qml: fix tx not saved when PIN active 2023-01-13 21:31:08 +01:00
Sander van Grieken
0bc8460005 qml: don't initialize instance variables on class scope for non-singletons
(this somehow escaped attention before, as most objects usually don't have multiple instances,
unless multiple wallets are open at the same time.)
Also, move all signal declarations, class constants and variables to the top of class definitions.
2023-01-12 13:09:21 +01:00
Sander van Grieken
02dce339cc qml: fix regressions after can_rbf removal, remove RbF checkboxes 2023-01-03 22:52:09 +01:00
Sander van Grieken
96af21faeb qml: show extra fee in ConfirmTxDialog (2fa) 2022-12-02 13:50:31 +01:00
Sander van Grieken
b7dcc1277c qml: listen for verified callbacks in fee bumpers, tx canceller and txdetails.
TxDetails updates the page, Rbf adn Cpfp fee bump dialogs and RbfCancelDialog auto-close.
2022-11-28 15:45:06 +01:00
Sander van Grieken
535754363e qml: fix imports 2022-11-25 20:53:30 +01:00
Sander van Grieken
78df722419 qml: add initial logic and UI for CPFP 2022-11-25 18:43:05 +01:00
Sander van Grieken
8fbfe87e78 qml: rename QETxFeeBumper -> QETxRbfFeeBumper, BumpFeeDialog.qml -> RbfBumpFeeDialog.qml 2022-11-23 17:10:34 +01:00
Sander van Grieken
990ec311d2 qml: implement cancel rbf tx 2022-11-22 13:37:46 +01:00
Sander van Grieken
57ec81cad0 qml: multisig implement finalize tx not complete result 2022-11-15 17:11:08 +01:00
Sander van Grieken
a2d1d5e288 qml: missing import 2022-10-25 16:27:15 +02:00
Sander van Grieken
902f16204c qml: initial RbF bump fee feature 2022-10-25 15:13:57 +02:00
Sander van Grieken
090706bfd6 qml: fix crashes on tx finalizing 2022-10-04 21:51:55 +02:00
Sander van Grieken
e582ae0486 qml: add QEAmount.copyFrom(QEAmount) so we can take a new amount object without changing the instance.
This avoids crashes when a QEAmount is already referenced in QML, and then replaced with another instance (e.g. in qetxfinalizer.py)
2022-08-26 11:57:00 +02:00
Sander van Grieken
1e375ae9e1 qml: allow separate data for clipboard/share and QR code in GenericShareDialog 2022-08-23 20:21:18 +02:00
Sander van Grieken
d76726836d qml: fixes 2022-08-17 11:49:41 +02:00
Sander van Grieken
46d3aa4515 qml: enable send for watch-only wallets, show raw tx dialog after finalizing
also use QEAMount setters in qetxfinalizer instead of re-instantiating
2022-08-16 10:04:28 +02:00
Sander van Grieken
7298dd0ab7 clean up list of outputs in ConfirmTxDialog 2022-07-07 18:30:20 +02:00
Sander van Grieken
cbd4d2a2ae make rbf selection allowed configurable 2022-07-07 18:30:20 +02:00
Sander van Grieken
2907698c17 support for MAX amounts 2022-07-07 18:29:02 +02:00
Sander van Grieken
81b1f774e2 expose more trampoline boilerplate
allow delegation of make_tx and accept/send
2022-07-07 18:29:01 +02:00
Sander van Grieken
81435f431c use rbf flag, show tx outputs, actually send tx in confirmpaymentdialog 2022-07-07 18:29:01 +02:00
Sander van Grieken
bf072b037c hook up invoice confirm to payment flow (onchain only)
fix some leftover QEAmount issues
2022-07-07 18:29:01 +02:00
Sander van Grieken
a163268d79 more QEAmount refactoring 2022-07-07 18:29:01 +02:00
Sander van Grieken
34ef93b2b5 add confirm payment dialog/feepicker and qobject backing 2022-07-07 18:29:01 +02:00