Commit graph

966 commits

Author SHA1 Message Date
Matt Corallo
bfd1128213 [peer_handler] Take the peers lock before getting messages to send
Previously, if a user simultaneously called
`PeerHandler::process_events()` from two threads, we'd race, which
ended up sending messages out-of-order in the real world.
Specifically, we first called `get_and_clear_pending_msg_events`,
then take the `peers` lock and push the messages we got into the
sending queue. Two threads may both get some set of messages to
send, but then race each other into the `peers` lock and send the
messages in random order.

Because we already hold the `peers` lock when calling most message
handler functions, we can simply take the lock before calling
`get_and_clear_pending_msg_events`, solving the race.
2021-04-21 22:03:45 +00:00
Matt Corallo
f40e47c1ef
Merge pull request #887 from valentinewallace/invoice-use-RL-routehint
invoice: swap RouteHop for RouteHint
2021-04-21 15:21:39 +00:00
Valentine Wallace
ad900658ce
Rename RouteHint to RouteHintHop (which is more accurate) 2021-04-20 16:26:56 -04:00
Valentine Wallace
21cb8db1b6
invoice: swap RouteHop for RouteHint
To prevent naming conflicts in bindings
2021-04-20 16:26:52 -04:00
Matt Corallo
e6c922803f
Merge pull request #844 from sr-gi/843-ln-signing
Adds lightning message signing/verification/pk_recovery
2021-04-20 00:45:30 +00:00
Sergi Delgado Segura
7bcf5a1731
Changes zbase32 crate from pub to pub(crate) 2021-04-16 07:35:04 +02:00
Matt Corallo
f13e38c3f7
Correct license header in zbase32 to match original work
The original work is licensed dual MIT+Apache-2 just like us, so
the license header should not only mention MIT.
2021-04-16 07:35:04 +02:00
Matt Corallo
d8716455b3
Replace spaces with tabs in zbase32.rs 2021-04-16 07:35:04 +02:00
Matt Corallo
7c9302f6a7
Fix a number of bugs in zbase32 and add a fuzzer which caught them. 2021-04-16 07:35:03 +02:00
Sergi Delgado Segura
6f7a2bcdd1
Adds lightning message signing/verification/pk_recovery 2021-04-16 07:34:51 +02:00
Matt Corallo
ffedc055b5 Make the used-in-pub-interfaces TransactionOutputs type alias pub 2021-04-15 16:10:21 -04:00
Jeffrey Czyz
524c532d40
Rename onchain_events_waiting_threshold_conf 2021-04-14 13:00:16 -07:00
Jeffrey Czyz
5e8b683333
Parameterize test_htlc_on_chain_timeout
This test failed when ConnectionStyle was set to a SkippingBlocks
variant because of a bug in ChannelMonitor::update_best_block.
Parameterize the test with these styles to catch any regressions.
2021-04-14 13:00:16 -07:00
Jeffrey Czyz
d45b38f43f
Test ChainMonitor's Electrum interface 2021-04-14 12:57:06 -07:00
Jeffrey Czyz
87f74fd451
Reuse txdata in functional_test_utils.rs 2021-04-14 12:57:06 -07:00
Jeffrey Czyz
1c72489e52
Add an internal typedef for transaction outputs 2021-04-14 12:57:06 -07:00
Jeffrey Czyz
34792d0f1a
Remove unnecessary script_pubkey clones 2021-04-14 12:57:05 -07:00
Jeffrey Czyz
f57c8856b5
Electrum interface for ChainMonitor
Add an interface to ChainMonitor for Electrum users, delegating to the
corresponding methods in each ChannelMonitor.
2021-04-14 12:57:05 -07:00
Jeffrey Czyz
c57bf73a02
Add ChannelMonitor::get_relevant_txids
Define an Electrum-friendly interface for ChannelMonitor where txids of
relevant transactions can be obtained. For any of these transactions
that are re-orged out of the chain, users must call
transaction_unconfirmed.
2021-04-14 12:57:05 -07:00
Jeffrey Czyz
65e588fd92
Add ChannelMonitor::transaction_unconfirmed
Define an Electrum-friendly interface for ChannelMonitor where
transactions are unconfirmed independently from updating the latest
block.
2021-04-14 12:57:05 -07:00
Jeffrey Czyz
8e3744813a
Add ChannelMonitor::update_best_block
Expose a way for Electrum users to update the best block on a
ChannelMonitor independently of confirming transactions.
2021-04-14 12:57:05 -07:00
Jeffrey Czyz
13a33409b5
Add ChannelMonitor::transactions_confirmed
Define an Electrum-friendly interface for ChannelMonitor where
transactions are confirmed independently of updating the last connected
block.
2021-04-14 12:57:05 -07:00
Jeffrey Czyz
2db1f1f656
Track block height in ChannelMonitor 2021-04-14 12:57:05 -07:00
Jeffrey Czyz
5610ca193d
Combine ChannelManager's block hash and height
There is a possible race condition when both the latest block hash and
height are needed. Combine these in one struct and place them behind a
single lock.
2021-04-14 12:57:04 -07:00
Jeffrey Czyz
24351f5868
Add txid to on-chain event tracking
When using Electrum, transactions are individually unconfirmed during a
reorg rather than by block. Store the txid of the transaction creating
the on-chain event so that it can be used to determine which events need
to be removed when a transaction is unconfirmed.
2021-04-14 12:57:04 -07:00
Jeffrey Czyz
561ddc0b44
Check for duplicate HTLC events having matured 2021-04-14 12:57:04 -07:00
Jeffrey Czyz
a89996564c
Flatten onchain_events_waiting_threshold_conf
Rather than mapping height to a vector of events, use a single vector
for all events. This allows for easily processing events by either
height or transaction. The latter will be used for an interface suitable
for Electrum.
2021-04-14 12:57:04 -07:00
Matt Corallo
6982434c58 Test new transactions_unconfirmed 2021-04-14 14:26:31 -04:00
Matt Corallo
46ac4c796a Expose ChannelManager's current config and use it in reload in tests 2021-04-14 14:26:18 -04:00
Matt Corallo
bdbba5e98f Add method to note transaction unconfirmed/reorged-out 2021-04-14 14:26:17 -04:00
Matt Corallo
9577928557
Merge pull request #885 from p2pderivatives/use-secp256k1-consts-in-ser
Fix size check in Vec<Signature> serialization + use consts
2021-04-14 02:20:27 +00:00
Matt Corallo
eee1c30ea6
Merge pull request #875 from TheBlueMatt/2021-04-fix-bench
Fix benchmark compile warnings and errors
2021-04-14 01:51:33 +00:00
Tibo-lg
2e49758127 Fix size check in Vec<Signature> serialization + use consts 2021-04-14 10:37:49 +09:00
Matt Corallo
daa1979aae Fix compile warning with --cfg require_route_graph_test 2021-04-12 23:35:44 -04:00
Valentine Wallace
5b4c3c603c
Rename timer_chan_freshness_every_min for uniformity with PeerManager 2021-04-12 20:42:09 -04:00
Matt Corallo
7e39f8735a Fix benchmark compile warnings and errors
Hopefully soon once a few more PRs get merged we can require this
in CI so we won't have any more regressions here.
2021-04-12 18:04:55 -04:00
Matt Corallo
8088e4ba15
Merge pull request #856 from TheBlueMatt/2021-03-check-tx
Take the full funding transaction from the user on generation
2021-04-10 20:27:24 +00:00
Matt Corallo
ba3ef0a3ba
Merge pull request #873 from TheBlueMatt/2021-861-missing-eof-eol
Add missing EOF newline
2021-04-10 20:26:36 +00:00
Matt Corallo
3f2efcdfa7 Take the full funding transaction from the user on generation
Instead of relying on the user to ensure the funding transaction is
correct (and panicing when it is confirmed), we should check it is
correct when it is generated. By taking the full funding transaciton
from the user on generation, we can also handle broadcasting for
them instead of doing so via an event.
2021-04-09 19:59:06 -04:00
Matt Corallo
dba0709b08
Merge pull request #861 from lightning-signer/degenerify
De-generify Sign methods
2021-04-09 23:57:20 +00:00
Matt Corallo
32a9a82396 Add missing EOF newline 2021-04-09 19:57:12 -04:00
Matt Corallo
021959f822
Merge pull request #866 from TheBlueMatt/2021-04-log-err-node
Log the node generating an onion error
2021-04-09 22:23:14 +00:00
Devrandom
0821fb3de0 Test that BaseSign can have a vtable 2021-04-09 11:20:58 +02:00
Devrandom
14e094adc1 Move Writeable from BaseSign to Sign 2021-04-09 11:20:58 +02:00
Devrandom
db0287137f Separate Clone from Sign
Clone requires Sized, which prevents Sign from being a dyn object.
2021-04-09 11:19:22 +02:00
Devrandom
b69ae07c11 Eliminate unnecessary generics from Sign
The generic methods prevent Sign from being a dyn object.

Use Secp256k1<All> as part of removing generics from Secp256k1 contexts passed into Sign methods.
2021-04-09 11:19:22 +02:00
Matt Corallo
d3231a2391
Merge pull request #815 from TheBlueMatt/2021-03-router-fuzzzzzzzz
Track full-path htlc-minimum-msat while routing
2021-04-08 02:06:13 +00:00
Matt Corallo
5f5bc41201 [router] Add and clarify comments describing router internals 2021-04-06 21:41:45 -04:00
Matt Corallo
bb62420b0f Drop unreachable underflow-handling block in route calculation
See comment in the removed block, note that the subsequent
subtraction will underflow if the block would otherwise have been
reached.
2021-04-06 21:41:45 -04:00
Matt Corallo
4c75437262 Don't clone Features during Dijkstras graph walk
We currently copy the features objects in each channel as we walk
the graph during route calculation. This implies a significant
amount of malloc traffic as the features flags object are stored
on the heap.

Instead, because they features being referenced are in the network
graph which we hold a reference to, we can simply store references
to them.

This nontrivially improves our get_route benchmark by around 5%.
2021-04-06 21:41:45 -04:00