Commit graph

1143 commits

Author SHA1 Message Date
Matt Corallo
d2ba7caf47 Pass peer's Init message through to ChannelManager 2020-01-19 22:47:08 -05:00
Matt Corallo
f263b3793f
Merge pull request #451 from lightning-signer/txkeys
Provide remote channel public keys to signer
2020-01-20 03:46:00 +00:00
Devrandom
b2064927cb Use ChannelPublicKeys in Channel 2020-01-19 18:55:57 -08:00
Devrandom
b65035f5e9 Hide derived fields in TxCreationKeys 2020-01-19 20:40:49 -05:00
Devrandom
42d7738234 Provide remote channel public keys to signer 2020-01-19 20:40:49 -05:00
Matt Corallo
04215c4658 Panic on txn with value > 21mill in ChannelMonitor::block_connected
full_stack_target found a crash where we may overflow ruring fee
calculation if a transaction appears on-chain with massive value
available for us to claim. Since these transactions are clearly
bogus, we shouldn't allow full_stack_target to connect them, but
we also improve the error generated by explicitly panicing on them.
2020-01-19 16:13:47 -05:00
Matt Corallo
a343cf9436 Drop individual fuzz target duplicate_crash tests for file reader
Previously, in each of our fuzz tests we had a dummy test which
had a hard-coded hex string which it passed into the fuzz target
so that when a failing test case was found, its hex could be
copied into the test and you could run cargo test to analyze the
failure. However, this was somewhat unwieldy as converting large
tests back and forth between hex and raw files is quite annoying.

Instead, we replace each of those tests with a test in each target
that looks for files in fuzz/test_cases and runs each file it finds.

Since we're editing every bin target anyway, we also automate adding
no_main to libfuzzer builds with #![cfg_attr].
2020-01-19 16:13:47 -05:00
Matt Corallo
0b5b2828f9
Merge pull request #447 from ariard/2020-01-fix-weight-computation
Bound incoming HTLC witnessScript to min/max limits
2020-01-17 22:32:29 +00:00
Antoine Riard
fbc7885a97 Bound incoming HTLC witnessScript to min/max limits
Fix a crash where previously we weren't able to detect any accepted
HTLC if its witness-encoded cltv expiry was different from expected
ACCEPTED_HTLC_SCRIPT_WEIGHT. This should work for any cltv expiry
included between 0 and 16777216 on mainnet, testnet and regtest.
2020-01-17 16:39:31 -05:00
Matt Corallo
1a870fe8aa Fix crash when a claim tx has some non-witness inputs.
The logger which decides what to refer to an on-chain claim tx was
assuming that all inputs would have a witness. While this was fine
for the one-input case, it broke the fuzzer which was connecting a
consensus-invalid transaction. Further, in the case we have multiple
inputs, some may not have a witness, which we shouldn't crash on.

This fixes 9df0250dbb.
2020-01-17 16:26:48 -05:00
Matt Corallo
f605eb3819
Merge pull request #450 from ariard/2020-01-fix-fst-blk-disconnection
Fix full_stack_target block disconnection
2020-01-17 20:13:46 +00:00
Antoine Riard
865267ac68 Fix full_stack_target mishandling of block disconnection 2020-01-17 14:21:02 -05:00
Antoine Riard
5aa95baa8d Log block disconnection in ChannelMonitor 2020-01-17 14:20:23 -05:00
Matt Corallo
09d2a71352
Merge pull request #448 from lightning-signer/visibility-for-test
Increase visibility for external integration tests
2020-01-16 23:54:09 +00:00
Devrandom
481e221187 increase visibility for external integration tests 2020-01-16 15:07:45 -08:00
Matt Corallo
b59efadb74
Merge pull request #444 from lightning-signer/funding-script
Construct funding redeem script in signer
2020-01-16 22:02:20 +00:00
Devrandom
6200302dc7 construct funding redeem script in signer 2020-01-16 13:18:23 -08:00
Matt Corallo
9c572a98fb
Merge pull request #449 from jkczyz/2020-01-remove-borrow-parts
Remove unnecessary borrow_parts() methods
2020-01-16 20:18:13 +00:00
Jeffrey Czyz
e58440fe45 Remove unnecessary borrow_parts() methods
Accessing a struct through an std::syn::MutexGuard using implicit
dereferencing can confuse the borrow checker. This situation arises when
obtaining mutable references to more than one field of the struct, which
is normally allowed.

https://doc.rust-lang.org/nomicon/borrow-splitting.html

However, when using implicit dereferencing, a mutable reference to the
the entire struct is taken. Thus, attempting to access another field in
this manner will lead to a compilation error.

https://doc.rust-lang.org/error-index.html#E0499

A simple way to avoid this is to first obtain a mutable reference to the
struct using explicit dereferencing.
2020-01-16 10:48:16 -08:00
Matt Corallo
a252f81477
Merge pull request #428 from TheBlueMatt/2019-12-flat-features
Implement Flat Features
2020-01-13 22:53:54 +00:00
Matt Corallo
49f88eca28 Seal the features contexts 2020-01-13 13:53:20 -05:00
Matt Corallo
cd5a11fe0d Move features into a separate module out of msgs. 2020-01-13 13:53:20 -05:00
Matt Corallo
7ec52c6ecb Refactor features a bit more to describe what the constructors do
The Features::new() method is nonsense and doesn't describe what
features were being set - we introduce an empty() and supported()
constructors instead.
2020-01-13 13:52:23 -05:00
Matt Corallo
96d3de5cde Fix Feature endianness by swapping bytes on read/write.
The spec is a bit mum on feature endianness, so I suppose it falls
under the "everything is big endian unless otherwise specified"
clause, but we were treating it as little.
2020-01-13 13:50:29 -05:00
Matt Corallo
0ad8fde0d6 Relay/store channel/node announces w/ unknown req'd feature bits
This change was made in the flat features BOLT PR, as if a channel
requires some unknown feature bits we should still rumor it, we just
shouldn't route through it.
2020-01-12 18:16:21 -05:00
Matt Corallo
31cc243e6f Implement Flat Features
This merges local and global features into one struct, which is
parameterized by where it appers. The parameterization restricts
which queries can be made and which features can be set, in line
with the latest BOLT 9.

Closes #427.
2020-01-12 18:15:25 -05:00
Matt Corallo
f8b06ec82c
Merge pull request #439 from TheBlueMatt/2020-01-398-fixups
398 with nits fixed.
2020-01-06 03:59:03 +00:00
Antoine Riard
933ae34703 Drop Result for ChannelMessageHandler methods
Simplify interfaces between ChannelMessageHandler and PeerManager,
by switching all ChannelMessageHandler errors to HandleError sent
internally instead of being return. With further refactors in Router
and PeerChannelEncryptor, errors management on the PeerManager-side
won't be splitted between try_potential_handleerror and HandleError
processing.

Inside ChannelManager, we now log MsgHandleErrInternal and send
ErrorAction to PeerManager.

On a high-level, it should allow client using API to be more flexible
by polling events instead of waiting function call returns.

We also update handle_error macro to take channel_state_lock from
caller which should avoid some deadlock potential for some edges
cases.

Filter out IgnoreError in handle_error macro, update test in
consequence.
2020-01-05 20:50:07 -05:00
Antoine Riard
29ace598de Add assert_log method to TestLogger to harden test
Extend mock Node with logger.
2020-01-05 17:23:32 -05:00
Matt Corallo
a3064d9937
Merge pull request #437 from Aleru/new-api-ping
New API for ping generation
2020-01-05 17:49:12 +00:00
Aleru
43a42586ef New API for ping generation
New API for generating pings
2020-01-05 00:06:48 -05:00
Matt Corallo
9310813e98
Merge pull request #420 from TheBlueMatt/2019-12-chan-ext-signer
Remove signing from Channel
2019-12-28 17:50:09 +00:00
Matt Corallo
e2e1628680 Sign local HTLC transactions at broadcast-time, instead of generate 2019-12-24 12:14:20 -05:00
Matt Corallo
eb97a7534d Make ChannelMonitor sign local transactions (at broadcast time) 2019-12-24 12:14:20 -05:00
Matt Corallo
200e8983ad Set basic channel info in chanmon all at once, add a bit more info 2019-12-24 12:14:09 -05:00
Matt Corallo
33810eddb5 Drop duplicative current-local-tx storage in channel.
We now have current-local-tx broadcast ability in channel monitors
directly (for ChannelManager deserialization), so we can just use
that instead of always having the Channel store signed ready-to-go
copies of the latest local commitment transaction.

This is further kinda nice since ChannelMonitor is live and can, eg
broadcast HTLC-Success transactions immediately as they will be
generated at broadcast time instead of in advance.

Finally, this lets us clean up a tiny bit in Channel.
2019-12-24 12:14:09 -05:00
Matt Corallo
eeac6c9695 Fix parameter name incorrectly changed in 4ebe64fafd 2019-12-24 12:13:29 -05:00
Matt Corallo
f755ae5bba
Merge pull request #426 from TheBlueMatt/2019-12-bad-lifetimes
Remove unused lifetimes.
2019-12-21 00:35:10 +00:00
Matt Corallo
d6382f5ed4 Remove unused lifetimes.
f71518365f added a series of lifetimes
which were required for an earlier version of the patch but not the
final version. They can be freely removed.
2019-12-20 14:54:23 -05:00
Matt Corallo
3b76c77d8c
Merge pull request #419 from TheBlueMatt/2019-12-simple-signer-api-step
Few more simple signer API additions
2019-12-13 22:04:53 +00:00
Matt Corallo
4ebe64fafd Use external key signer to generate closing transaction signatures 2019-12-13 16:16:33 -05:00
Matt Corallo
b1ed0ee033 Sign channel_announcements via a new ChannelKeys API 2019-12-12 14:36:41 -05:00
Matt Corallo
ae16c5ca34 Use EnforcingChannelKeys in fuzz targets to get more coverage 2019-12-12 13:37:07 -05:00
Matt Corallo
edab29e8d8
Merge pull request #404 from TheBlueMatt/2019-11-signer-api
Replace keys API with Signer API to support hardware wallets eventually
2019-12-12 18:01:46 +00:00
Matt Corallo
71e6995086
Merge pull request #417 from TheBlueMatt/2019-12-ver-bump
Bump to 0.0.10
2019-12-12 16:45:18 +00:00
Matt Corallo
1e52786e1c Bump versions to 0.0.10 2019-12-11 18:17:54 -05:00
Matt Corallo
6fc775da45 Bump bitcoin dep to 0.21 2019-12-11 18:17:54 -05:00
Matt Corallo
ccd4f12078 Pre-build fuzz targets at once in travis instead of as we need them 2019-12-11 18:17:54 -05:00
Antoine Riard
35814b653f Document more current security assumption of KeysInterface
Improve some comments of interface methods.
2019-12-11 17:29:42 -05:00
Matt Corallo
262666ad7f Make commitment transaction signing a part of ChannelKeys.
This adds a new fn to ChannelKeys which is called when we generte
a new remote commitment transaction for signing. While it may be
theoretically possible to unwind state updates by disconnecting and
reconnecting as well as making appropriate state machine changes,
the effort required to get it correct likely outweighs the UX cost
of "preflighting" the requests to hardwre wallets.
2019-12-11 17:29:42 -05:00