Commit graph

2806 commits

Author SHA1 Message Date
Matt Corallo
fe4b0b86db
Merge pull request #1024 from TheBlueMatt/2021-07-always-connect-in-tests
Connect peers on startup in tests
2021-07-30 20:53:30 +00:00
Matt Corallo
2745bd5ac7 Connect peers on startup in tests
This avoids `ChannelManager` ever being confused by the fact that
it received a message from a peer which it didn't think it was
connected to.
2021-07-30 18:48:29 +00:00
Matt Corallo
e26c9b051a
Merge pull request #1021 from TheBlueMatt/2021-07-broken-beta
Disable fast-fail to let CI actually run even though beta is broken
2021-07-29 18:06:05 +00:00
Matt Corallo
6b0a97be21
Merge pull request #1007 from jkczyz/2021-07-stop-drop-shutem-down
Stop BackgroundProcessor's thread on drop
2021-07-29 17:49:05 +00:00
Matt Corallo
a7934d7ece Disable fast-fail to let CI actually run even though beta is broken 2021-07-29 17:40:42 +00:00
Matt Corallo
f3b63e4dab
Merge pull request #1020 from TheBlueMatt/2021-07-log-features-more
Macroize feature printing to ensure we don't miss new flags
2021-07-28 21:58:31 +00:00
Jeffrey Czyz
e260cfcd9b
Add join method to BackgroundProcessor
The previous commit wraps the background thread's JoinHandle in an
Option. Providing a dedicated method to join hides this implementation
detail from users.
2021-07-28 16:30:51 -05:00
Matt Corallo
1f013c9cc2 Macroize feature printing to ensure we don't miss new flags 2021-07-28 21:06:49 +00:00
Matt Corallo
f438778715 Test preimages are learned instantly in test_onchain_to_onchain_claim
test_onchain_to_onchain_claim was connecting additional blocks in
order to reach HTLC timeout and broadcast an HTLC-Timeout
transaction, resulting in it not testing whether HTLC preimages are
learned instantly in response to HTLC-Success transactions.
2021-07-28 17:35:09 +00:00
Matt Corallo
8ffc2d1742 Ignore unknown Events serialized with an odd type value.
This should provide some additional future extensibility, allowing
for new informational events which can be safely ignored to be
ignored by older versions.
2021-07-28 17:35:09 +00:00
Matt Corallo
49ab8c2f9a Drop single-use macro from check_spend_holder_transaction
The wait_threshold_conf!() macro in check_spend_holder_transaction
was only used once, making it a good candidate for inlining at the
callsite. Further, it incorrectly always logged that we were
failing HTLCs from the "latest" commitment transaction, when it is
sometimes actually failing HTLCs from the previous commitment
transaction.
2021-07-28 17:35:09 +00:00
Matt Corallo
1bb9e64ebc
Merge pull request #977 from TheBlueMatt/2021-06-fix-double-claim-close
Handle double-HTLC-claims without failing the backwards channel
2021-07-28 01:24:27 +00:00
Matt Corallo
f06f9d1136 Fail channel if we can't sign a new commitment tx during HTLC claim
Previously, we could fail to generate a new commitment transaction
but it simply indicated we had gone to doule-claim an HTLC. Now
that double-claims are returned instead as Ok(None), we should
handle the error case and fail the channel, as the only way to hit
the error case is if key derivation failed or the user refused to
sign the new commitment transaction.

This also resolves an issue where we wouldn't inform our
ChannelMonitor of the new payment preimage in case we failed to
fetch a signature for the new commitment transaction.
2021-07-28 00:34:53 +00:00
Matt Corallo
c09104f46e Simplify call graph of get_update_fulfill_htlc since it can't Err. 2021-07-28 00:34:53 +00:00
Matt Corallo
7e78fa660c Handle double-HTLC-claims without failing the backwards channel
When receiving an update_fulfill_htlc message, we immediately
forward the claim backwards along the payment path before waiting
for a full commitment_signed dance. This is great, but can cause
duplicative claims if a node sends an update_fulfill_htlc message,
disconnects, reconnects, and then has to re-send its
update_fulfill_htlc message again.

While there was code to handle this, it treated it as a channel
error on the inbound channel, which is incorrect - this is an
expected, albeit incredibly rare, condition. Instead, we handle
these double-claims correctly, simply ignoring them.

With debug_assertions enabled, we also check that the previous
close of the same HTLC was a fulfill, and that we are not moving
from a HTLC failure to an HTLC claim after its too late.

A test is also added, which hits all three failure cases in
`Channel::get_update_fulfill_htlc`.

Found by the chanmon_consistency fuzzer.
2021-07-28 00:34:53 +00:00
Matt Corallo
0b4079df9a
Merge pull request #967 from valentinewallace/2021-06-keysend
Keysend
2021-07-28 00:32:27 +00:00
Valentine Wallace
6dd6289d38
Clarify decode_update_add_htlc_onion comment
Clearer phrasing
2021-07-27 15:18:25 -04:00
Valentine Wallace
47bcc1823b
tests: make PaymentSecret optional in pass_along path
and use it to make more keysend tests
2021-07-27 15:18:25 -04:00
Valentine Wallace
0328be32f7
Implement utilities for keysending to private nodes 2021-07-27 15:18:23 -04:00
Valentine Wallace
2d94401cca
Implement sending keysend payments (to public nodes) 2021-07-27 15:15:24 -04:00
Valentine Wallace
d32052fbf6
test utils: add optional PaymentPreimage param to pass_along_path
This will allow keysend tests to assert that the PaymentReceived payment preimage is
as expected in upcoming commits.
2021-07-27 15:15:24 -04:00
Valentine Wallace
5a42be07a0
Implement receiving keysend payments 2021-07-27 15:15:24 -04:00
Valentine Wallace
d1e8d9ced5
Refactor PaymentReceived event for keysend receives 2021-07-27 15:15:23 -04:00
Valentine Wallace
f60a65fec3
Add PendingHTLCRouting variant for receiving keysend payments 2021-07-27 15:15:23 -04:00
Valentine Wallace
a8d5c6e451
Fix indentation in decode_update_add_htlc_onion 2021-07-27 15:15:23 -04:00
Valentine Wallace
288b93b3da
Advertise keysend feature
C-Lightning requires us to advertise this feature before they'll
attempt a keysend payment to us.
2021-07-27 15:15:23 -04:00
Valentine Wallace
99b0e7e59a
Parse keysend TLV field in onion.
This doesn't yet use the field, but it will be used in upcoming commits.
2021-07-27 15:15:21 -04:00
Matt Corallo
d37b1dd673
Merge pull request #998 from TheBlueMatt/2021-07-fix-chan-reserve-msat-sat
Fix channel reserve calculation on the sending side
2021-07-26 16:03:22 +00:00
Matt Corallo
99ecd02f7d
Merge pull request #986 from TheBlueMatt/2021-07-route-lasthop-value
[router] Use the invoice value for last-hop hint channel capacity
2021-07-26 16:02:41 +00:00
Matt Corallo
41d8d4d6b2
Merge pull request #1008 from lightning-signer/2021-07-sync-no-std
Dummy sync implementation for no_std
2021-07-22 14:17:09 +00:00
Matt Corallo
ef4bfdca3c
Merge pull request #1010 from sr-gi/enforce_signature_length 2021-07-20 23:25:40 +00:00
Devrandom
2e8f4fef2f Test no_std instead of just hashbrown 2021-07-20 20:59:18 +02:00
Devrandom
a0a3a6b204 Implement dummy Mutex, Condvar and RwLock 2021-07-20 20:59:18 +02:00
Sergi Delgado Segura
8a1c538f88
Enforces sig_rec length in message_signing 2021-07-20 11:41:38 +02:00
Devrandom
002a5db5b0 Collect all lightning std::sync imports under crate::sync
in preparation for no-std sync dummies
2021-07-19 15:01:58 +02:00
Jeffrey Czyz
4f05db6af8
Stop BackgroundProcessor's thread on drop
Without stopping the thread when BackgroundProcessor is dropped, it will
run free. In the context of language bindings, it is difficult to know
how long references held by the thread should live. Implement Drop to
stop the thread just as is done when explicitly calling stop().
2021-07-18 13:11:01 -05:00
Jeffrey Czyz
d9fa8f1c38
Correctly assert BackgroundProcessor error
The specific error from the ChannelManager persister is not asserted for
in test_persist_error. Rather, any error will do. Update the test to use
BackgroundProcessor::stop and assert for the expected value.
2021-07-18 12:59:27 -05:00
Matt Corallo
1f1d7c6890
Merge pull request #1003 from jkczyz/2021-known-features-mask
Expand tests for Features::to_context
2021-07-15 20:14:35 +00:00
Matt Corallo
ccd7b6c554
Merge pull request #1002 from valentinewallace/2021-07-fix-features-index-bounds 2021-07-15 12:59:45 +00:00
Jeffrey Czyz
87233488cc
Test index-out-of-bounds in Features::to_context
When there are fewer known `from` feature bytes than known `to` feature
bytes, an index-out-of-bounds error can occur if the `from` features
have unknown features set in a byte past the greatest known `from`
feature byte.
2021-07-14 20:34:13 -05:00
Jeffrey Czyz
06ecbecd6d
Remove unnecessary feature test-only methods 2021-07-14 16:26:08 -07:00
Valentine Wallace
7497ed2402
Fix crash due to index-out-of-bounds in feature translation
This was reported by a user when trying to send a payment using the LDK
sample (specifically during route generation when translating a Features
from one context to another)

The problem was we didn't check T::KNOWN_FEATURE_MASK vec length before
indexing into it, due likely to the assumption that known feature vec
lengths are the same across contexts, when they may not be
2021-07-14 18:55:17 -04:00
Matt Corallo
fecac81874 Support pending update_fail_htlcs in reconnect_nodes test util 2021-07-14 18:23:32 +00:00
Matt Corallo
306e9a5acf Fix channel reserve calculation on the sending side
As the variable name implies holder_selected_chan_reserve_msat is
intended to be in millisatoshis, but is instead calculated in
satoshis.

We fix that error here and update the relevant tests to more
accurately calculate the expected reserve value and test both
success and failure cases.

Bug discovered by chanmon_consistency fuzz target.
2021-07-13 17:13:58 +00:00
Matt Corallo
afae12ea1e
Merge pull request #990 from TheBlueMatt/2021-07-0.0.99
Cut 0.0.99
2021-07-09 17:29:38 +00:00
Matt Corallo
c9a8b26d58 Bump most crate versions to 0.0.99 and lightning-invoice to 0.7.0 2021-07-09 16:34:46 +00:00
Matt Corallo
230c72bd4c Add documentation for all PRs slated to land for 0.0.99 2021-07-09 16:34:46 +00:00
Matt Corallo
e04a1b3872
Merge pull request #975 from TheBlueMatt/2021-06-fix-fee-calc
Make the base fee configurable in ChannelConfig
2021-07-09 02:11:57 +00:00
Matt Corallo
4cc0d9dfe5 Change serialization backwards compat in Channel to use new version
Instead of interpreting the backwards compatibility data in Channel
serialization, use the serialization version bump present in 0.0.99
as the flag to indicate if a channel should be read in backwards
compatibility.
2021-07-09 01:33:44 +00:00
Matt Corallo
dbfccf045f Add a note clarifying the API guarantees of create_channel 2021-07-09 01:33:44 +00:00