1
0
Commit Graph

77 Commits

Author SHA1 Message Date
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
SomberNight
ba670cc9dc wallet: add struct PiechartBalance 2025-06-29 22:25:56 +00:00
ThomasV
9e225d1269 Replace config GUI_LAST_WALLET with CURRENT_WALLET
- CURRENT_WALLET is set when a single wallet is loaded in memory, and it
   remains set after Electrum stops running.
 - If several wallets are loaded at the same time, CURRENT_WALLET is unset,
   and RPCs must specify the wallet explicitly (using --wallet for the CLI)
 - The fallback to 'default_wallet' essentially only applies when
   creating a new wallet file
2025-06-02 14:05:53 +02:00
Sander van Grieken
de30c6139c text: fix _ string 2025-05-21 11:55:44 +02:00
f321x
5bfddad67c use daemon.load_wallet instead of constructing manually 2025-05-12 10:53:12 +02:00
f321x
6e21dac387 fix: tui contacts edit label and delete button
the edit label button did crash the application because get_string
returned bytes instead of a string. The delete button was not
implemented but shown in the tui.
2025-05-12 10:51:19 +02:00
f321x
bfe895fc3e remove unused imports, fix type hint 2025-05-12 10:17:30 +02:00
f321x
b0fd126e1b fix: exception if payment amount is not set
if payment amount is not set and the user tried to pay, the application
would crash. This shows a message instead. Also uses show_message
instead of show_error, as show_error doesn't exist.
2025-05-12 10:08:52 +02:00
f321x
02232b227e fix IndexError if self.channel_ids is empty 2025-05-12 10:00:38 +02:00
ThomasV
26910ef81d Merge pull request #9620 from accumulator/lightning_pass_invoice_not_bolt11
refactor lnworker.pay_invoice to accept Invoice object instead of bolt11 string
2025-03-18 20:09:01 +01:00
SomberNight
977d8b1dd6 wallet: kill create_transaction 2025-03-14 17:19:41 +00:00
SomberNight
3c3778db9c wallet: towards killing create_transaction: rm "sign" arg 2025-03-14 16:44:46 +00:00
SomberNight
3f327eea07 wallet: fix wallet.make_unsigned_transaction method signature
- "fee_policy" arg is actually mandatory
- and fix test/stdio guis following fee_policy/config split

follow-up 840243e029
2025-03-11 16:15:17 +00:00
Sander van Grieken
6fdb6c93f7 refactor lnworker.pay_invoice to accept Invoice object instead of bolt11 string
rename lnworker._check_invoice to lnworker._check_bolt11_invoice
2025-03-09 14:47:34 +01:00
SomberNight
2aa427b4bf Merge branch 'pr/9507': qt: refactor NetworkChoiceLayout to ProxyWidget+ServerWidget
ref https://github.com/spesmilo/electrum/pull/9507
2025-03-05 15:01:05 +00:00
ThomasV
840243e029 separate fee policy from config
- Wallet.make_unsigned_transaction takes a FeePolicy parameter
 - fee sliders act on a FeePolicy instead of config
 - different fee policies may be used for different purposes
 - do not detect dust outputs in lnsweep, delegate that to lnwatcher
2025-03-05 10:29:26 +01:00
Sander van Grieken
fea598cfbe network: create ProxySettings class replacing dict and encapsulating proxy related funcs,
allow enable/disable proxy without nuking proxy mode, host and port (explicit enable_proxy config setting),
move tor probe from frontend to backend code, add probe buttons for Qt and QML
2025-03-04 14:23:33 +01:00
ThomasV
a371102a4c update text gui for lightning invoices 2025-02-25 11:28:07 +01: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
SomberNight
06db7d74ff dependencies: vendor "pyperclip" pkg, used by text gui
commit 43ab4a779a introduced "pyperclip" as a dependency for the prototype "text" gui.

pyperclip is small enough for us to vendor it, and looks mature/stable enough so that it would ~never need updating.
This makes it easier to try out the text gui when running from source, or using the AppImage.
2024-01-24 00:14:30 +00:00
SomberNight
522e9485c1 text gui: rm some magic numbers (ascii key codes), and small clean-up 2024-01-23 23:43:08 +00:00
Sander van Grieken
667485b17e network: split off proxy_user and proxy_pass from serialized proxy string and add separate cmdline params and config keys for them.
support parsing both old style mode:host:port:user:pass and new mode:host:port, where new form also accepts IPv6 addresses
2023-11-30 14:27:31 +01:00
SomberNight
57d2efc88d wallet: merge mktx and create_transaction 2023-10-10 17:45:26 +00:00
SomberNight
63143307f1 config: follow-up rename of FEE_EST_STATIC_FEERATE
follow-up 455167136d
2023-10-10 12:11:45 +00:00
ThomasV
9ebae958dc text gui: fix WalletDB 2023-09-30 09:34:34 +02:00
Alef Farah
cf4590bee3 fix recv for text gui 2023-09-29 17:35:42 -03:00
ThomasV
d03c77837f Let the GUI compute the balance displayed in history.
Since Qt groups swap transactions, the displayed balance
was sometimes incorrect.
2023-09-14 15:58:58 +02:00
SomberNight
ffa3acc013 invoices: don't modify .amount_msat directly 2023-08-22 18:12:15 +00:00
ThomasV
b96cc82333 Make storage a field of db
This comes from the jsonpatch_new branch.
I rather have in master now, because it touches a lot of filese.
2023-08-18 08:08:31 +02:00
Sander van Grieken
6dd630cf3b followup f5a8cc7076 2023-07-10 11:39:16 +02:00
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