1
0
Commit Graph

30 Commits

Author SHA1 Message Date
ThomasV
649ce979ab send tx change to lightning 2023-09-09 14:14:43 +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
4219022c2e fix flake8-bugbear B023
B023 Function definition does not bind loop variable 'already_selected_buckets_value_sum'

in keepkey/qt.py, looks like this was an actual bug
(fixed in trezor plugin already: 52a4810752 )
2023-04-24 13:00:07 +00:00
SomberNight
01b5e3f8e0 flake8: enable more mandatory tests 2022-10-31 16:13:22 +00:00
SomberNight
9ed5b092e4 coinchooser: (trivial) add some type hints 2022-09-23 16:37:35 +00:00
SomberNight
67c6f0e1bd wallet: make sure we don't create zero input txs
fixes #7207
2021-04-14 19:08:04 +02:00
Benoit Verret
f731c38293 Minor style changes 2021-03-21 00:36:23 -04:00
SomberNight
058d9ab6bb wallet.bump_fee: add new strategy: decrease payment amounts
- Rename bump_fee "methods" to "strategies".
- Refactor strategies so that bump_fee can use any subset of them in any permutation.
- Adds a new strategy which decreases the payment outputs (instead of change).
2021-02-25 15:32:07 +01:00
SomberNight
eefb68c82b transaction: change Transaction.is_segwit_input(txin) to txin.is_segwit() 2020-10-24 08:03:13 +02:00
SomberNight
154b9cab50 coinchooser: change "enable_output_value_rounding" default to True
see diff for rationale
2020-06-03 18:18:56 +02:00
SomberNight
5958fa8b2d coinchooser: small clean-up re enable_output_value_rounding 2020-06-03 18:14:05 +02:00
SomberNight
04d018cd0f test_lnpeer: some clean-up, make it easier to add "num_node>2" tests 2020-05-06 11:06:33 +02:00
SomberNight
5549f3adbe CoinChooser: avoid NotEnoughFunds if zero buckets are sufficient
closes #5752

Adapted from @JeremyRand's fix
2019-11-11 15:15:04 +01:00
SomberNight
bafe8a2fff integrate PSBT support natively. WIP 2019-11-04 22:24:36 +01:00
SomberNight
d9b5ab3086 wallet: fix bump_fee when there are only change outputs
closes #5718
closes #5603
2019-10-22 17:12:23 +02:00
SomberNight
94b721baa4 wallet: fix type error in _bump_fee_through_decreasing_outputs
fixes #5483
2019-07-04 17:23:34 +02:00
SomberNight
4f51308eab coinchooser: clarify docs for make_tx 2019-06-29 16:21:07 +02:00
SomberNight
fd5d1dab4f coinchooser: clear up what "fee_estimator" expects 2019-06-20 22:46:22 +02:00
SomberNight
cb69aa80f7 coinchooser: don't spend buckets with negative effective value
Calculate the effective value of buckets, and filter <0 out.
Note that the filtering is done on the buckets, not per-coin.
This should better preserve the user's privacy in certain cases.

When the user "sends Max", as before, all UTXOs are selected,
even if they are not economical to spend.

see #5433
2019-06-20 22:42:50 +02:00
SomberNight
e864fa5088 coinchooser: tweak heuristic scoring.
transactions without any change now get better scores.
transactions with really small change get worse scores.
2019-06-20 22:42:47 +02:00
SomberNight
f409b5da40 coinchooser: refactor so that penalty_func has access to change outputs 2019-06-20 22:42:47 +02:00
SomberNight
cb204dd969 coinchooser: better account for fees in penalty_func 2019-06-17 19:55:39 +02:00
SomberNight
3385a94753 logging: basics 2019-05-02 15:19:03 +02:00
SomberNight
d56917f4b1 coinchooser: improve performance significantly
existing code was n^2 in number of UTXOs
this is now mostly linear
(linear if shortcut is hit; otherwise in rare cases still quadratic)

tested using wallet with 800 UTXOs, most of which were needed to make payment
coinchooser.make_tx() went from 18 sec to 0.8 sec
2019-05-02 03:07:34 +02:00
SomberNight
71ac3bb305 RBF batching: some fixes 2018-11-09 17:56:42 +01:00
ThomasV
2b8d801b36 if possible, batch new transaction with existing rbf transaction 2018-11-09 16:33:29 +01:00
SomberNight
9037f25da1 kill old-style namedtuples 2018-10-28 00:28:29 +02:00
SomberNight
b7178f2d21 coinchooser: small clean-up (use TxOutput.value) 2018-08-14 21:50:59 +02:00
SomberNight
2eb72d496f transaction: introduce TxOutput namedtuple 2018-08-01 19:10:08 +02:00
Janus
097ac144d9 file reorganization with top-level module 2018-07-13 14:01:37 +02:00