Commit graph

369 commits

Author SHA1 Message Date
SomberNight
ec7473789e
lnhtlc: speed-up methods for recent ctns
we maintain a set of interesting htlc_ids
2020-03-06 21:54:05 +01:00
ThomasV
fbf6af5d07 fix test_lnpeer 2020-03-06 12:40:42 +01:00
ThomasV
584e0a38aa follow-up previous commit: fix test_lnpeer 2020-03-06 12:29:39 +01:00
ThomasV
8eaf0004e1 follow-up 17a893441a: fix regtest 2020-03-06 10:26:11 +01:00
SomberNight
2aebcc5e26
commands: gate get_channel_ctx behind --iknowwhatimdoing 2020-03-05 17:27:43 +01:00
ThomasV
dbd77b7d8e
Merge pull request #6014 from SomberNight/20200304_pycryptodomex
add 'cryptography' as optional dependency; clean README and sdist
2020-03-05 09:17:42 +01:00
ThomasV
8f3fcdd1a8 Fix detection of payments.
1. In lnhtlc, sent_in_ctn and failed_in_ctn need to look at the
remote ctx, and they need to be called when we receive a revocation,
not when we send one.

2. In lnchannel, we use 3 lnworker callbacks:
   - payment sent/payment failed (called when we receive a revocation)
   - payment received (called when we send a revocation)

3. Make revoke_current_commitment return a single value.
The second value was only used in tests, there is no need
to bloat the code with that
2020-03-05 07:03:09 +01:00
ThomasV
b9eaba3e85 replace await_local/remote 2020-03-05 07:03:09 +01:00
SomberNight
74a3faf803
crypto: add 'cryptography' as alt dependency for 'pycryptodomex' 2020-03-04 18:54:20 +01:00
SomberNight
dae842e2ad
tests: made TestLNTransport.test_loop more robust 2020-03-04 17:57:40 +01:00
SomberNight
cdb72509a7
lnrouter: change edge cost estimate (distance metric)
Old estimate was heavily biased towards simply minimising CLTV sum.
(fees had a too low weight; typically they were ~noise)
Now also take payment_amount into account.
2020-03-03 02:12:42 +01:00
ThomasV
f801307a08 move htlc_switch task to lnpeer 2020-03-02 15:41:50 +01:00
ThomasV
da67fda92a HTLC switch:
- fulfills/fails/forwards HTLCs
- onion_packets are saved when update_add_htlc is received
2020-03-02 11:19:04 +01:00
SomberNight
8560930bac
transaction: (fix) invalidate ser cache when changing locktime/version
we can keep the same API, using @property,
instead of introducing getters and setters
2020-03-01 09:57:59 +01:00
ThomasV
077f778632 Replace lightning_settle_delay with enable_htlc_settle (asyncio.Event) 2020-02-28 10:15:28 +01:00
SomberNight
ed234d3444
rename all TaskGroup() fields to "taskgroup"
for consistency
2020-02-27 19:13:56 +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
6703521f56
rm more cruft from test_lnchannel
follow-up e54c69b861
2020-02-27 02:53:03 +01:00
SomberNight
e54c69b861
add lnchannel.can_send_ctx_updates. just drop illegal updates for now 2020-02-26 20:35:46 +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
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
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
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
46d8080c76
ln gossip: don't put own channels into db; always pass them to fn calls
Previously we would put fake chan announcement and fake outgoing chan upd
for own channels into db (to make path finding work). See Peer.add_own_channel().
Now, instead of above, we pass a "my_channels" param to the relevant ChannelDB methods.
2020-02-17 20:38:41 +01:00
SomberNight
16626a3386
lnutil.split_host_port: fix for IPv6 connection string 2020-02-17 19:43:21 +01:00
ThomasV
36f32651cc Define network.try_broadcasting() method.
Use it when rebroadcasting a force-close tx,
because the channel state is already set.
2020-02-16 12:59:09 +01:00
ThomasV
88d5cdf87c fix test_lnpeer 2020-02-15 16:28:15 +01:00
SomberNight
ab4e2dd9f0
wallet: fix is_mine/can_sign. don't just rely on ks, also check script
Previously a standard (single-sig) wallet would consider a multisig txin as is_mine
(if the keystore found its pubkey in the txin).

fixes #5948
2020-02-12 18:14:07 +01:00
ThomasV
9734546fe9 test_lnpeer: use less side-effects 2020-02-12 10:32:55 +01:00
ThomasV
e3630d87b2 test_lnpeer: test_reestablish_with_old_state 2020-02-12 10:22:22 +01:00
ThomasV
69ef9aa3d7 channel_reestablish: assume that DLP is enabled, because we require it 2020-02-11 21:39:23 +01:00
ThomasV
ece75c3244 test_lnpeer: simple test of channel_reestablish 2020-02-11 19:53:21 +01:00
SomberNight
de1ca27d63
tests: rm "needs_test_with_all_ecc_implementations" decorator
now libsecp256k1 is the only implementation
2020-02-11 16:46:31 +01:00
SomberNight
0a5ad9fda4
ecc: small API clean-up 2020-02-11 16:42:02 +01:00
SomberNight
2cf2135528
ecc: abstract away some usage of python-ecdsa: bytes<->int conversions 2020-02-11 16:41:49 +01:00
SomberNight
004acb906d
ecc: abstract away some usage of python-ecdsa: randrange 2020-02-11 16:41:45 +01:00
ThomasV
e1ce3aace7 Separate db from storage
- storage is content-agnostic
 - db and storage are passed to wallet contructor
2020-02-10 17:45:23 +01:00
ThomasV
7bd29ed8fc regtest: wait_for_balance 2020-02-05 08:56:58 +01:00
ThomasV
dbceed2647 Restructure wallet storage:
- Perform json deserializations in wallet_db
 - use StoredDict class that keeps tracks of its modifications
2020-02-04 13:35:58 +01:00
ThomasV
73e656522e regests: organize tests in two classes 2020-02-03 15:16:15 +01:00
ThomasV
149cd9598a Separate JsonDB and WalletDB 2020-02-03 12:36:07 +01:00
ThomasV
4ec86d36a8 faster and improved regtests
- print the test name before each test
 - start only needed agents (alice, bob, carol)
 - set settle_delay using setconfig instead of restarting daemon
 - test the watchtower ctn in test_watchtower
2020-02-02 15:07:28 +01:00
ThomasV
757467782a Use attr.s instead of namedtuples for channel config 2020-01-31 12:19:26 +01:00
SomberNight
308517d473
python 3.8: adapt to breaking changes re asyncio.CancelledError
(and TimeoutError)

closes #5798
2019-12-11 23:07:47 +01:00
SomberNight
fcd9752f19
keystore: change derive_pubkey API to return bytes 2019-12-10 20:41:47 +01:00
SomberNight
5f6f7da2a1
bitcoin.py: base58 address: make sure all public methods test checksum
Note: the checksum was already being checked in practically all cases, by the caller.
Moved the check here, to the lower level (but still public) method for sanity.
2019-12-08 06:56:19 +01:00