1
0
Commit Graph

339 Commits

Author SHA1 Message Date
SomberNight
d35ed6935d commands: extend "importprivkey" to allow importing a list of keys
This is most useful if the user wants to import a significant number of keys,
as every invocation of `importprivkey` results in rewriting the wallet file to disk.

The API of "importprivkey" is left unchanged for the single privkey case.
2024-10-08 14:11:19 +02:00
SomberNight
1257f21b1b constants: rm set_testnet/set_mainnet fns with AbstractNet.set_as_network 2024-09-16 15:27:45 +00:00
ghost43
287cb9ebb6 Merge pull request #9152 from shangchenglumetro/master
chore: fix some comments
2024-08-13 03:32:51 +00:00
SomberNight
16d2f0f9d4 wallet.get_tx_status: fix incorrect feerate for partial txs
The history tab would show an incorrect feerate for partial/unsigned (local) txs,
if they had any p2sh/p2wsh txins. We would just guess the script is p2wpkh, and
use that for the size calc. Now with calling add_info_from_wallet, the correct
size is used to calculate the feerate.

(The gui tx dialogs call add_info_from_wallet independently, so the size/feerate
shown there were already correct.)
2024-08-13 03:20:32 +00:00
shangchenglumetro
4064686359 chore: fix some comments 2024-07-26 01:41:36 +08:00
SomberNight
bec78b4210 util.error_text_str_to_safe_str: truncate long errors
The messages are sometimes logged and sometimes shown to the user,
- for logging we might not want to truncate or have higher limits,
- but when shown to the user, we definitely want to truncate the error text.
It is simplest to just do the truncation here, at the lowest level.

Note that we usually prepend the error text with a header e.g. "[DO NOT TRUST THIS MESSAGE]"
and if the error text is too long, this header at the beginning might get "lost" in some way.
Hence we should truncate the error text.
2024-06-17 16:52:13 +00:00
ThomasV
2f3d89f415 prepare for separation of ecc module:
- move encrypt/sign functions elsewhere
- remove local dependencies in ecc.py, ecc_fast.py (except logging)
2024-06-17 13:05:57 +02:00
ThomasV
8409503788 Merge pull request #9082 from SomberNight/202404_tx_taproot
transaction.py: impl taproot key-spends
2024-06-17 12:49:32 +02:00
SomberNight
300b986782 soothe flake8
```
./tests/test_mnemonic.py:249:9: B017 `assertRaises(Exception)` and `pytest.raises(Exception)` should be considered evil. They can lead to your test passing even if the code being tested is never executed due to a typo. Assert for a more specific exception (builtin or custom), or use `assertRaisesRegex` (if using `assertRaises`), or add the `match` keyword argument (if using `pytest.raises`), or use the context manager form with a target.
        with self.assertRaises(Exception):
        ^
1     B017 `assertRaises(Exception)` and `pytest.raises(Exception)` should be considered evil. They can lead to your test passing even if the code being tested is never executed due to a typo. Assert for a more specific exception (builtin or custom), or use `assertRaisesRegex` (if using `assertRaises`), or add the `match` keyword argument (if using `pytest.raises`), or use the context manager form with a target.
```
2024-06-10 20:22:20 +00:00
SomberNight
a2d5e31838 mnemonic: rename seed_type() fn
Some functions have an argument named "seed_type" in which it was annoying to call the seed_type() fn.
(especially for functions inside the same module)
2024-06-10 20:00:52 +00:00
SomberNight
b95fbbb86f wizard: fix regression: allow passphrase for some '2fa' seeds
fixes https://github.com/spesmilo/electrum/issues/9088
2024-06-10 19:35:56 +00:00
SomberNight
4f7dcc98bd tests: wallet_vertical: re pre-2.7 "2fa" seeds, test both 24 and 25 len 2024-06-10 18:22:59 +00:00
SomberNight
3a305881cc transaction.py: impl taproot key-spends
Add support for key-path-spending taproot utxos into transaction.py.

- no wallet support yet
- add some psbt, and minimal descriptor support
- preliminary work towards script-path spends
2024-06-07 10:58:26 +00:00
SomberNight
0866581b2c daemon error-handling: fix traceback.format_exception() on old python
The new API for traceback.format_exception was only added in python 3.10 (91e93794d5).
2024-06-05 14:45:28 +00:00
Sander van Grieken
9674ffc8ee bip21: add testcases for amount bounds 2024-05-29 10:22:28 +02:00
SomberNight
07c80d2ca1 ecc: ecdsa_verify to enforce low-S rule
The low-S rule for ecdsa signatures is mandated by Bitcoin Core policy/standardness (though not by consensus). If we get signatures from untrusted sources, we should mandate they obey the policy rules. (e.g. from LN peers)

Note that we normalize the signatures in the sig format conversion methods (DER <-> (r,s) <-> sig64).

The BOLTs treat high-S signatures as invalid, and this changes our behaviour to that.
(previously we would silently normalize the S value)

see https://github.com/bitcoin/bitcoin/pull/6769
see https://github.com/lightning/bolts/pull/807
2024-05-27 17:12:33 +00:00
SomberNight
d61c6037ea ecc: add test that verify_usermessage does not enforce low-S rule 2024-05-27 17:09:45 +00:00
SomberNight
bafd52ec6d lnsweep: rm one usage of Transaction.get_preimage_script()
get_preimage_script should really have been private API...
looks like everywhere it is used outside of transaction.py, it is actually abused :/
Other existing usages in plugin code I don't dare to touch without lots of manual testing...
2024-05-24 13:40:48 +00:00
Ondřej Vejpustek
70f0ed992f slip39: implement extendable backups 2024-05-20 16:57:11 +02:00
SomberNight
67d373357b lnworker: make PaymentFeeBudget defaults configurable
- make PaymentFeeBudget proportional fee and flat cutoff fee configurable
  - closes https://github.com/spesmilo/electrum/issues/7622
- increase flat cutoff fee default to 10 sat
  - closes https://github.com/spesmilo/electrum/issues/7669
- rm RouteEdge.is_sane_to_use() (per edge limit) and just rely on budgets (per route limit)
2024-05-08 15:53:22 +00:00
SomberNight
13d9677e53 transaction: tx.sign API change: rm hex usage 2024-04-29 17:10:30 +00: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
cf2ed509b4 dependencies: remove bitstring
- `bitstring` started depending on `bitarray` in version 4.1 [0]
  - that would mean one additional dependency for us (from yet another maintainer), which is not even pure python
- we only use bitstring for bolt11-parsing
- hence this PR rewrites the bolt11-parsing and removes `bitstring` as dependency
- note: I benchmarked lndecode using [1], and the new code performs better,
  taking around 80% time needed for old code (when using bitstring 3.1.9, pure python).
  Though the variance is quite large in both cases.

[0]: 95ee533ee4/release_notes.txt (L108)
[1]: d7597d96d0
2024-04-24 14:14:31 +00:00
ThomasV
9a7195d5ab test_lnpeer: fix node_id in storage of created peers 2024-04-18 10:34:48 +02:00
momantech
2b6090429c Fix some comments
Signed-off-by: momantech <cuimoman@qq.com>
2024-04-17 18:46:05 +08:00
ThomasV
8759928ec0 Merge pull request #9000 from SomberNight/202404_ecc_schnorr
ecc: add bindings for schnorr sign/verify, and refactor
2024-04-15 11:57:29 +02:00
ThomasV
3e7d4749cf turn classmethod 'find_all_plugins' into an instance method.
change 'use_' prefix to 'enable_plugin_'
2024-04-13 11:35:49 +02:00
SomberNight
52f1a2ce25 ecc: add method "bip340_tagged_hash"
I decided to use the stdlib (hashlib) instead of libsecp for this,
as it is simple enough, and the former is faster on my PC.

Added a unit test that compares the two.
2024-04-12 14:20:45 +00:00
SomberNight
bd9d0ccc33 ecc: refactor/clean-up sign/verify APIs 2024-04-11 15:25:45 +00:00
SomberNight
44e27ac8b5 ecc: add bindings for schnorr sign/verify
and require "schnorrsig" and "extrakeys" modules of libsecp256k1
2024-04-11 13:09:57 +00:00
SomberNight
30c9f5b6b1 walletdb: chan dict: small clean-up (incl db upgrade)
- "fail_htlc_reasons" was removed in 9b1c40e396
- "unfulfilled_htlcs": rm 2 dead items from the 4-tuple,
   and convert False value of forwarding_key
2024-03-01 16:28:46 +00:00
ThomasV
94a8754bdd regtest: test swapserver with trampoline onions 2024-03-01 12:00:24 +01:00
SomberNight
51b7fc04ef walletdb: fix convert_version_58 for partial local txs
The transaction dict can also contain PSBTs (in addition to complete raw hex txs).
This is the case if the user has saved a partial (e.g. unsigned) tx as local into the history.

fixes https://github.com/spesmilo/electrum/issues/8913
2024-02-26 18:54:21 +00:00
SomberNight
d01582d58c fix tests (follow-up)
follow-up 197979063a
2024-02-22 12:26:25 +00:00
ThomasV
32775c1b5d regtest: fix varname in wait_until_htlcs_settled
(this was not affecting the tests)
2024-02-22 09:40:59 +01:00
SomberNight
8ab3dcce5d keystore: API changes for from_seed/from_bip43_rootseed/bip39_to_seed
- force kwargs
- add type hints
2024-02-21 15:08:19 +00:00
Sander van Grieken
6ecbb8eb3f tests: add test for payment_identifier.invoice_from_payment_identifier() 2024-02-19 11:54:32 +01:00
Sander van Grieken
0faf6928c0 tests: explicit sync on self.app instance ready and make sure _testcase_event is cleared before
QMetaObject.invokeMethod as that can race if it gets inadvertently executed synchronously.
2024-02-16 16:56:14 +01:00
Sander van Grieken
73fee69f5c tests: move /electrum/tests to /tests 2024-02-16 15:40:45 +01:00