Commit graph

12148 commits

Author SHA1 Message Date
SomberNight
1ca6f6f306
Qt address list speedup: wallet.is_beyond_limit was slow 2020-02-29 07:28:13 +01:00
SomberNight
a0b096dcb2
mnemonic: implement Wordlist class
Wordlist subclasses 'tuple' so it can be transparently used.
'in' and '.index()' are fast.
Use Wordlist in bip39_is_checksum_valid, which makes that faster.
2020-02-29 00:20:11 +01:00
SomberNight
e1dcdde272
Qt tx dialog: fix file extension when exporting (on MacOS...)
closes #5954

We are now giving every(?) hint possible to the MacOS file dialog...
The extension is put in the filename as before (which turned out not to be enough).
It is also set using QFileDialog.setDefaultSuffix, which again, turns out not to be enough.
In desperation, the file extension filter-list now contains *.psbt and *.txn as separate filters,
and the one with the expected extension is pre-selected. This seems enough...
2020-02-28 21:59:09 +01:00
SomberNight
a32af44ff9
trivial clean-up (typing/imports) 2020-02-28 20:27:35 +01:00
SomberNight
02fcc6f570
wallet_db.get_transaction: tolerate if tx_hash is None
Traceback (most recent call last):
  File "...\electrum\electrum\gui\qt\main_window.py", line 1503, in do_pay
    self.do_pay_invoice(invoice)
  File "...\electrum\electrum\gui\qt\main_window.py", line 1516, in do_pay_invoice
    self.pay_onchain_dialog(self.get_coins(), outputs)
  File "...\electrum\electrum\gui\qt\main_window.py", line 1570, in pay_onchain_dialog
    self.preview_tx_dialog(make_tx=make_tx,
  File "...\electrum\electrum\gui\qt\main_window.py", line 1574, in preview_tx_dialog
    d = PreviewTxDialog(make_tx=make_tx, external_keypairs=external_keypairs,
  File "...\electrum\electrum\gui\qt\transaction_dialog.py", line 654, in __init__
    self.update()
  File "...\electrum\electrum\gui\qt\transaction_dialog.py", line 392, in update
    tx_details = self.wallet.get_tx_info(self.tx)
  File "...\electrum\electrum\wallet.py", line 486, in get_tx_info
    tx_we_already_have_in_db = self.db.get_transaction(tx_hash)
  File "...\electrum\electrum\json_db.py", line 44, in wrapper
    return func(self, *args, **kwargs)
  File "...\electrum\electrum\wallet_db.py", line 822, in get_transaction
    assert isinstance(tx_hash, str)
AssertionError

Traceback (most recent call last):
  File "...\electrum\electrum\gui\qt\confirm_tx_dialog.py", line 65, in timer_actions
    self.update()
  File "...\electrum\electrum\gui\qt\transaction_dialog.py", line 392, in update
    tx_details = self.wallet.get_tx_info(self.tx)
  File "...\electrum\electrum\wallet.py", line 486, in get_tx_info
    tx_we_already_have_in_db = self.db.get_transaction(tx_hash)
  File "...\electrum\electrum\json_db.py", line 44, in wrapper
    return func(self, *args, **kwargs)
  File "...\electrum\electrum\wallet_db.py", line 822, in get_transaction
    if tx_hash is None:
AssertionError
2020-02-28 20:23:50 +01:00
SomberNight
f8ba660583
clean-up hw-wallet "get_password_for_storage_encryption"-related code 2020-02-28 19:47:56 +01:00
SomberNight
88650ed8d6
network UntrustedServerReturnedError: add "DO NOT TRUST..." tag 2020-02-28 18:47:12 +01:00
ThomasV
55a0043ab7 follow-up previous commit (fix tests) 2020-02-28 10:34:04 +01:00
ThomasV
97900c0985 store raw messages in gossip_db. Fixes #5960 2020-02-28 10:22:49 +01:00
ThomasV
077f778632 Replace lightning_settle_delay with enable_htlc_settle (asyncio.Event) 2020-02-28 10:15:28 +01:00
SomberNight
ce81957d25
blockchain: move init_headers_file from network.py to blockchain.py
and don't run it every time the network restarts
2020-02-27 20:45:29 +01:00
SomberNight
b21bcf5977
taskgroups: don't log CancelledError 2020-02-27 20:22:49 +01:00
ThomasV
15e91169c5 lnpeer: fix json serialization of funding_inputs 2020-02-27 19:51:16 +01:00
ThomasV
8f6fc5917a make sure we can send shutdown 2020-02-27 19:19:10 +01:00
SomberNight
ed234d3444
rename all TaskGroup() fields to "taskgroup"
for consistency
2020-02-27 19:13:56 +01:00
SomberNight
c8260249b0
lnworker: add own taskgroup (run in daemon.taskgroup) 2020-02-27 19:13:53 +01:00
ThomasV
0bf09d14a0 fix regression in shutdown (from 1c5dc79298) 2020-02-27 19:01:06 +01:00
ThomasV
34400c0710 Set channel state to OPENING as soon as we receive 'funding_signed',
instead of when the funding transaction has been broadcast, because
we have no reliable way to know when it will be broadcast.
2020-02-27 18:12:20 +01:00
ThomasV
d04b8c05e2 (minor) fix typo in comment 2020-02-27 14:48:08 +01:00
ThomasV
f5053cc242 follow-up e54c69b861: we must settle HTCLs after during shutdown 2020-02-27 14:40:58 +01:00
ThomasV
e159b1d468 test_close: add unsettled htlc (fails with the current code) 2020-02-27 13:41:40 +01:00
SomberNight
c744fc4e3d
follow-up prev: do all checks, and add tests 2020-02-27 05:13:31 +01:00
SomberNight
a987a2bbbe
keystore: make add_key_origin "API-user-friendly"
Power-users that know what they are doing can use this method
to populate key origin information for keystore (bip32 root fingerprint
and derivation path prefix).
Try to make method hard to misuse.

Qt console can now be used as e.g.:
```
wallet.get_keystores()[2].add_key_origin(derivation_prefix="m/48h/1h/0h/2h", root_fingerprint="deadbeef")
```

related #5715
related #5955
related #5969
2020-02-27 04:18:27 +01:00
SomberNight
bea038ea6b
Qt tx dialog: warn if user asked for full bip32 paths but info missing
related: https://github.com/spesmilo/electrum/issues/5969#issuecomment-591441399

Instead of a log line, maybe it should warn as part of the GUI.. but this is a start.
2020-02-27 03:31:14 +01:00
SomberNight
22861b70ee
Qt tx dialog: make "export with xpubs" option always available
not just if one of the keystores is a coldcard

related: https://github.com/spesmilo/electrum/issues/5969#issuecomment-591441399
2020-02-27 03:14:13 +01:00
SomberNight
6703521f56
rm more cruft from test_lnchannel
follow-up e54c69b861
2020-02-27 02:53:03 +01:00
SomberNight
6161853941
lnpeer: reduce log spam due to incompatible feature bits 2020-02-26 21:10:33 +01:00
SomberNight
e54c69b861
add lnchannel.can_send_ctx_updates. just drop illegal updates for now 2020-02-26 20:35:46 +01:00
SomberNight
9d1fa4cc99
(trivial) lnworker: move LNGossip.peer_closed to parent class 2020-02-26 20:31:51 +01:00
ThomasV
3d0c1dbd5c restore log lines for send_commitment, on_commitment_signed 2020-02-26 19:14:49 +01:00
ThomasV
87fe2c7d7a define channel.has_pending_changes method 2020-02-26 19:08:48 +01:00
ThomasV
1c5dc79298 shutdown:
- resend shutdown on reestablish
 - wait until no more pending updates before sending shutdown
2020-02-26 16:06:28 +01:00
ThomasV
9b97469598 (minor) follow-up previous commit 2020-02-26 15:49:55 +01:00
ThomasV
6833adf8b6 simplify previous commit (revert changes on transaction.py) 2020-02-26 14:16:21 +01:00
ThomasV
e85fb25146 lnpeer: verify signature in closing_signed 2020-02-26 12:58:40 +01:00
ThomasV
0848aa259d (minor) simplification 2020-02-26 11:30:19 +01:00
ThomasV
d5c03307c3 the funder sends the first 'closing_signed' message 2020-02-26 11:15:03 +01:00
SomberNight
9ab18ea6c9
transaction.deserialize: more sanity checks
this is mandated by consensus
99813a9745/src/consensus/tx_check.cpp (L13)
2020-02-25 21:14:41 +01:00
ghost43
28572197fb
Merge pull request #5992 from zebra-lucky/fix_spv_hash_merkle_root
fix SPV.hash_merkle_root, add tests/test_verifier.py
2020-02-25 19:56:27 +00:00
SomberNight
4f5f949979
follow-up prev
Clean up tests a bit, and rm some of them.
It's overkill to test with SPV._raise_if_valid_tx mocked out.
2020-02-25 20:45:17 +01:00
SomberNight
e9251c8e59
lnpeer: add "DO NOT TRUST..." remark to errors sent by remote
potential phishing...
2020-02-25 20:09:33 +01:00
SomberNight
6937b87a7c
transaction.BCDataStream: minor fixes
- fix read/write_boolean (though unused...)
- sanity check in read_bytes
2020-02-25 20:05:46 +01:00
zebra-lucky
c0be0471f2
fix BCDataStream.read_bytes (#5991)
* fix BCDataStream.read_bytes

* followup fix BCDataStream.read_bytes: fix TestBCDataStream.test_bytes
2020-02-25 18:58:03 +00:00
zebra-lucky
d4f7c207a7 fix SPV.hash_merkle_root, add tests/test_verifier.py 2020-02-25 20:06:11 +02:00
SomberNight
aaf174ef3e
lnpeer: cooperative close: verify scriptpubkey matches templates 2020-02-25 17:54:49 +01:00
Jakub Łukasiewicz
c121230706
Added ELECTRUMDIR env variable (#5543)
Simple way for allowing users to change localization of Electrum directory
from ~/.electrum to somewhere else
2020-02-25 15:28:53 +00:00
ThomasV
2927478192 lnpeer: closing fee negociation:
- use fee_rate from config
 - set upper bound on fee
 - add test_close to test_lnpeer
2020-02-25 15:23:15 +01:00
SomberNight
e7ab9e4054
lnpeer: await_remote/await_local now more restrictive, and docstring
Previously it was not so clear what these methods were doing.
2020-02-24 21:23:13 +01:00
SomberNight
5fda2cbb42
fix test: test_reestablish_with_old_state
Messages sent as part of the payment were getting interleaved with the channel_reestablish.
It does not actually make sense to do a payment and then reestablish the channel in the same transport -- the channel is supposed to already have been reestablished to do a payment in the first place.
So, after payment, strip down the transport, and set up a new transport before reestablishing.

Traceback (most recent call last):
  File "...\Python\Python38\lib\unittest\case.py", line 60, in testPartExecutor
    yield
  File "...\Python\Python38\lib\unittest\case.py", line 676, in run
    self._callTestMethod(testMethod)
  File "...\Python\Python38\lib\unittest\case.py", line 633, in _callTestMethod
    method()
  File "...\electrum\electrum\tests\test_lnpeer.py", line 262, in test_reestablish_with_old_state
    run(f())
  File "...\electrum\electrum\tests\test_lnpeer.py", line 302, in run
    return asyncio.run_coroutine_threadsafe(coro, loop=asyncio.get_event_loop()).result()
  File "...\Python\Python38\lib\concurrent\futures\_base.py", line 439, in result
    return self.__get_result()
  File "...\Python\Python38\lib\concurrent\futures\_base.py", line 388, in __get_result
    raise self._exception
  File "...\electrum\electrum\tests\test_lnpeer.py", line 260, in f
    await gath
  File "...\electrum\electrum\lnpeer.py", line 439, in _message_loop
    self.process_message(msg)
  File "...\electrum\electrum\lnpeer.py", line 159, in process_message
    execution_result = f(payload)
  File "...\electrum\electrum\lnpeer.py", line 1308, in on_revoke_and_ack
    chan.receive_revocation(rev)
  File "...\electrum\electrum\lnchannel.py", line 556, in receive_revocation
    raise Exception('revoked secret not for current point')
Exception: revoked secret not for current point
2020-02-24 21:09:34 +01:00
SomberNight
4a8ee1818a
follow-up prev
E/W | lnwatcher.LNWalletWatcher | Exception in on_network_update: AssertionError('None')
Traceback (most recent call last):
  File "...\electrum\electrum\util.py", line 1035, in wrapper
    return await func(*args, **kwargs)
  File "...\electrum\electrum\lnwatcher.py", line 174, in on_network_update
    await self.check_onchain_situation(address, outpoint)
  File "...\electrum\electrum\lnwatcher.py", line 184, in check_onchain_situation
    closing_height = self.get_tx_height(closing_txid)
  File "...\electrum\electrum\address_synchronizer.py", line 597, in get_tx_height
    verified_tx_mined_info = self.db.get_verified_tx(tx_hash)
  File "...\electrum\electrum\json_db.py", line 44, in wrapper
    return func(self, *args, **kwargs)
  File "...\electrum\electrum\wallet_db.py", line 859, in get_verified_tx
    assert isinstance(txid, str), f"{repr(txid)}"
AssertionError: None
2020-02-24 18:52:33 +01:00