1
0
Commit Graph

47 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
SomberNight
312f2641e7 don't use bare except
use "except Exception", or if really needed explicitly "except BaseException"
2023-04-24 12:58:01 +00:00
SomberNight
1530668960 qt/qml: delay starting network until after first-start-network-setup
The qt, qml, and kivy GUIs have a first-start network-setup screen
that allows the user customising the network settings before creating a wallet.
Previously the daemon used to create the network and start it, before this screen,
before the GUI even starts. If the user changed network settings, those would
be set on the already running network, potentially including restarting the network.

Now it becomes the responsibility of the GUI to start the network, allowing this
first-start customisation to take place before starting the network at all.
The qt and the qml GUIs are adapted to make use of this. Kivy, and the other
prototype GUIs are not adapted and just start the network right away, as before.
2023-03-30 00:59:02 +00:00
Sander van Grieken
c5883c7cdb text guis low hanging fruit 2023-02-08 12:51:24 +01:00
ThomasV
14e96f4d53 Index request by ID instead of receiving address.
Replace get_key_for_outgoing_invoice, get_key_for_incoming_request
with Invoice.get_id()

When a new request is created, reuse addresses of expired requests (fixes #7927)

The API is changed for the following commands:
 get_request, get_invoice,
 list_requests, list_invoices,
 delete_request, delete_invoice
2022-09-02 10:58:11 +02:00
ThomasV
d9f77a50e8 wallet API: remove get_request_status, it is redundant with get_invoice_status 2022-08-29 09:48:08 +02:00
SomberNight
659d6890d9 wallet.get_request_URI: rm code duplication 2022-08-11 13:07:56 +00:00
SomberNight
7b095158bf wallet: add get_label_for_address, and make get_label private
fixes https://github.com/spesmilo/electrum/issues/7919

In the past, when creating payment requests, we keyed them by on-chain address,
and set/saved the msg of the request as label for the address.
Many places in the code were calling wallet.get_label(addr) with the expectation that
relevant payment requests are found and their message/description (if any) is considered.

wallet.get_label(key) is now made private, and instead the explicit non-polymorphic
wallet.get_label_for_{address,rhash,txid} alternatives should be used.
2022-08-09 17:21:14 +02:00
ThomasV
eb9d211378 text GUI: add proper stop method 2022-07-27 12:08:50 +02:00
ThomasV
725c70bc4a text GUI: simplify show_request 2022-07-26 13:16:06 +02:00
ThomasV
43ab4a779a various updates for the text GUI 2022-07-24 14:48:21 +02:00
ghost43
c3093ded21 Merge pull request #7858 from spesmilo/event_listener
EventListener class to handle callbacks
2022-06-22 00:12:34 +00:00
ThomasV
dbf055de9a EventListener class to handle callbacks
and QtEventListener for Qt
2022-06-22 02:07:46 +02:00
ThomasV
034bd42d9c text guii: display full history 2022-06-17 12:59:35 +02:00
ThomasV
55f46fb61e adb fixes for text and stdio GUIs 2022-06-17 10:04:28 +02:00
SomberNight
30650c524c address_sync: "up_to_date" now waits for SPV 2022-04-08 20:35:23 +02:00
SomberNight
837fc1606c address_sync: change up_to_date to be private; no lock needed to read
After some consideration I am fairly certain there is no need to take
wallet.lock in `is_up_to_date()`. Any caller that might want some kind
of guarantees re the value returned by is_up_to_date() would need to
enforce them itself by e.g. taking wallet.lock around its critical code
block. That is, even if is_up_to_date() itself takes the lock, between
the call returning and the caller reading the value there could still
have been a race.
Also, the GUI was directly accessing the field already.
2022-04-08 20:33:13 +02:00
SomberNight
ca9b48e2d6 gui: add BaseElectrumGui base class for guis 2021-11-05 20:21:50 +01:00
SomberNight
9a38c4d2a1 logging: don't lose log messages during early startup
Previously, during early-startup (until configure_logging(config) is
called in run_electrum),
- the stderr log handler lost all log messages below warning level, and
- the file log handler lost all log messages regardless of log level

We now instead start buffering log messages in memory as soon as
electrum.logging is imported. The buffer is dumped into the
stderr and file log handlers when they are fully set up, and then
the buffer is discarded (and the temporary log handler is removed).

Note that messages are not logged until configure_logging() is called.
Previously WARNING/ERROR messages would get logged immediately to stderr,
but not anymore. This was changed so that the order of the log messages
can be kept intact. (if we log WARNINGs immediately, but need to delay
INFOs until the config is available, messages would either be out of order
or alternatively there would be duplicates)

Relatedly, we now follow the recommendation of the python docs re
logging for libraries [0]: we try to only configure logging if running via
run_electrum (the main script) and not when e.g. a 3rd party script
imports electrum.

[0]: https://docs.python.org/3/howto/logging.html#configuring-logging-for-a-library
2021-04-14 19:14:26 +02:00
Benoit Verret
2fce31c5ec Show txid in text GUI 2021-04-03 23:59:11 -04:00
Benoit Verret
f731c38293 Minor style changes 2021-03-21 00:36:23 -04:00
SomberNight
4b6c86ecbe wallet: make labels private, and access to need lock
e.g. labels plugin iterated over wallet.labels on asyncio thread while user could trigger an edit from Qt thread
2020-10-13 18:57:55 +02:00
Henrik Grimler
48a7e5cc2b gui: update stdio and text after db and storage separation (#6567)
e1ce3aace7 updated the qt and kivy guis, but not stdio or text one.
2020-09-09 15:54:42 +00:00
SomberNight
b2cfaddff2 network.NetworkParameters: merge host+port+protocol into "server" field 2020-04-16 21:19:45 +02:00
SomberNight
cf1f2ba4dc network: replace "server" strings with ServerAddr objects 2020-04-15 17:23:47 +02:00
ThomasV
9224404108 Move callback manager out of Network class 2020-04-14 18:29:51 +02:00
ThomasV
c61e5db6a9 fixes for text interface 2020-02-08 12:35:07 +01:00
SomberNight
bafe8a2fff integrate PSBT support natively. WIP 2019-11-04 22:24:36 +01:00
SomberNight
04edad9984 config: no longer singleton. it is passed to Wallet.__init__
The few other cases that used SimpleConfig.get_instance() now
either get passed a config instance, or they try to get a reference
to something else that has a reference to a config.
(see lnsweep, qt/qrcodewidget, qt/qrtextedit)
2019-09-22 20:46:01 +02:00
SomberNight
241873f0a4 address_synchronizer.get_history now returns HistoryItem(NamedTuple)s 2019-09-12 04:06:51 +02:00
SomberNight
f60f690ca9 change many str(e) to repr(e) as some exceptions were cryptic
it's often valuable to see the type of the exception
(especially as for some exceptions str(e) == '')
2019-07-17 20:12:52 +02:00
SomberNight
6940c424d1 logging: cli options to filter for modules using -v
old style "-v" still works

filtering examples:
-v=debug,network=error,interface=error      // effectively blacklists network and interface
-v=warning,network=debug,interface=debug    // effectively whitelists network and interface
2019-05-02 15:19:10 +02:00
SomberNight
5403ae7687 network: sanitize tx broadcast response 2019-01-18 20:25:21 +01:00
SomberNight
5248613e9d gui: prepend broadcast_transaction errors with explanatory message 2018-12-21 20:44:38 +01:00
SomberNight
ed22f968f9 text gui: fix network event handler 2018-11-30 17:18:06 +01:00
SomberNight
87b05e1c9e network: change broadcast_transaction api
raise exceptions instead of weird return values
closes #4433
2018-10-10 15:56:41 +02:00
SomberNight
33d14e4238 some import clean-up in qt 2018-09-25 18:15:28 +02:00
SomberNight
952e9b87e1 network: clean-up. make external API clear. rm interface_lock (mostly). 2018-09-25 16:44:39 +02:00
SomberNight
af63913189 network triggers: rm 'updated'; more fine-grained instead
rm 'interfaces'
add 'wallet_updated', add 'network_updated'
2018-09-18 16:49:48 +02:00
SomberNight
43664d5f11 fixes for stdio/text gui 2018-09-13 15:11:28 +02:00
SomberNight
e829d6bbcf wallet: put Sync and Verifier in their own TaskGroup, and that into interface.group 2018-09-11 20:24:01 +02:00
SomberNight
e2338581eb broadcast_transaction: introduce async variant 2018-09-10 18:39:10 +02:00
SomberNight
3d424077fd introduce NetworkParameters namedtuple 2018-09-10 00:59:53 +02:00
SomberNight
2eb72d496f transaction: introduce TxOutput namedtuple 2018-08-01 19:10:08 +02:00
SomberNight
a29e2218c8 wallet: introduce namedtuples TxMinedStatus and VerifiedTxInfo 2018-07-31 17:10:15 +02:00
Janus
097ac144d9 file reorganization with top-level module 2018-07-13 14:01:37 +02:00