]> git.bitcoin.ninja Git - rust-lightning/log
rust-lightning
4 years agoAdd TODOs
Matt Corallo [Mon, 17 Dec 2018 17:13:03 +0000 (12:13 -0500)]
Add TODOs

4 years agoTESTING
Matt Corallo [Thu, 7 Mar 2019 16:33:19 +0000 (11:33 -0500)]
TESTING

4 years agoTESTING
Matt Corallo [Fri, 1 Mar 2019 22:41:40 +0000 (17:41 -0500)]
TESTING

4 years agoMake full_stack_target more absurdly huge and check for funds loss
Matt Corallo [Fri, 17 Aug 2018 21:44:13 +0000 (17:44 -0400)]
Make full_stack_target more absurdly huge and check for funds loss

4 years agoConnect blocks at the end
Matt Corallo [Fri, 17 Aug 2018 21:42:28 +0000 (17:42 -0400)]
Connect blocks at the end

4 years agoAdditional asserts to include in fuzztesting (though may get hit?)
Matt Corallo [Tue, 5 Mar 2019 22:29:12 +0000 (17:29 -0500)]
Additional asserts to include in fuzztesting (though may get hit?)

4 years agoDemonstrate mutating functions which are not fully test-covered
Matt Corallo [Sun, 19 Jan 2020 05:13:13 +0000 (00:13 -0500)]
Demonstrate mutating functions which are not fully test-covered

4 years agoImpl ReadableArgs for Arc<ChannelManager>, not just ChannelManager.
Matt Corallo [Mon, 27 Jan 2020 15:38:13 +0000 (10:38 -0500)]
Impl ReadableArgs for Arc<ChannelManager>, not just ChannelManager.

This provides a simple wrapper for deserializing right into an
Arc<ChannelManager>, which improves UX a tiny bit when working with
SimpleArcChannelManager types.

4 years agoTest that we don't forget to track any outputs at monitor-load
Matt Corallo [Tue, 21 Jan 2020 03:13:44 +0000 (22:13 -0500)]
Test that we don't forget to track any outputs at monitor-load

This tests, after each functional test, that if we serialize and
reload all of our ChannelMonitors we end up tracking the same set
of outputs as before.

4 years agoTrack the full list of outpoints a chanmon wants monitoring for.
Matt Corallo [Tue, 21 Jan 2020 03:05:29 +0000 (22:05 -0500)]
Track the full list of outpoints a chanmon wants monitoring for.

Upon deserialization/reload we need to be able to register each
outpoint which spends the commitment txo which a channelmonitor
believes to be on chain. While our other internal tracking is
likely sufficient to regenerate these, its much easier to simply
track all outpouts we've ever generated, so we do that here.

4 years agoFix rustc nightly compiler error.
Matt Corallo [Sun, 19 Jan 2020 05:49:18 +0000 (00:49 -0500)]
Fix rustc nightly compiler error.

This works around a regression in nightly rustc that prevents type
inference from working properly.

4 years agoRun with mutagen on travis.
Matt Corallo [Wed, 15 Jan 2020 20:08:45 +0000 (15:08 -0500)]
Run with mutagen on travis.

Sadly our test coverage isn't very good and I had to hunt for
functions to mutate where we fail tests on every mutation mutagen
creates, but committing the framework is a start.

4 years agoRewrite lightning-net-tokio using async/await and tokio 0.2
Matt Corallo [Sat, 1 Feb 2020 17:27:30 +0000 (12:27 -0500)]
Rewrite lightning-net-tokio using async/await and tokio 0.2

This is a rather major rewrite, using async/await and tokio 0.2,
which cleans up the code a ton as well as adds significantly to
readability.

4 years agoSwap read_event read type for a slice isntead of a Vec
Matt Corallo [Sat, 1 Feb 2020 01:57:01 +0000 (20:57 -0500)]
Swap read_event read type for a slice isntead of a Vec

It looks like we don't currently use the Vec as a Vec, and can
happily take a slice, which makes things easier on the calling
side.

4 years agoOnly run lightning-net-tokio build on Rust 1.39.0+ on Travis.
Matt Corallo [Sat, 1 Feb 2020 17:37:50 +0000 (12:37 -0500)]
Only run lightning-net-tokio build on Rust 1.39.0+ on Travis.

This disables building the lightning-net-tokio crate on 1.34.2 on
Travis in anticiption of relying on async/await for
lightning-net-tokio, with the nice side-effect of reducing the
amount of work done on our slowest Travis job.

This also adds 1.39.0 to Travis as that is the new MSRV for
lightning-net-tokio.

4 years agoPanic on txn with value > 21mill in ChannelMonitor::block_connected
Matt Corallo [Sun, 19 Jan 2020 21:03:25 +0000 (16:03 -0500)]
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.

4 years agoDrop individual fuzz target duplicate_crash tests for file reader
Matt Corallo [Sun, 19 Jan 2020 20:38:34 +0000 (15:38 -0500)]
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].

4 years agoSilence new rustc warnings re: extra ()s, dyn, and unused params
Matt Corallo [Thu, 16 Jan 2020 18:54:38 +0000 (13:54 -0500)]
Silence new rustc warnings re: extra ()s, dyn, and unused params

4 years agoOnly expose constants exposed for testing in cfg(test)
Matt Corallo [Fri, 17 Jan 2020 19:15:07 +0000 (14:15 -0500)]
Only expose constants exposed for testing in cfg(test)

4 years agoFix deadlock in handle_error!() when we have HTLCs to fail-back.
Matt Corallo [Mon, 13 Jan 2020 21:10:30 +0000 (16:10 -0500)]
Fix deadlock in handle_error!() when we have HTLCs to fail-back.

This partially reverts 933ae3470309f21ef7537ffbcdc42070d60e1e74,
though note that 933ae3470309f21ef7537ffbcdc42070d60e1e74 fixed a
similar deadlock while introducing this one.

If we have HTLCs to fail backwards, handle_error!() will call
finish_force_close() which will attempt to lock channel_state while
it is locked at the original caller.

4 years agoTest that EnforcingChannelKeys doesn't panic on duplicate RAAs
Matt Corallo [Thu, 16 Jan 2020 23:53:32 +0000 (18:53 -0500)]
Test that EnforcingChannelKeys doesn't panic on duplicate RAAs

4 years agoFix EnforcingChannelKeys panic when our counterparty burns their $.
Matt Corallo [Sun, 12 Jan 2020 23:04:40 +0000 (18:04 -0500)]
Fix EnforcingChannelKeys panic when our counterparty burns their $.

If our counterparty burns their funds by revoking their current
commitment transaction before we've sent them a new one, we'll step
forward the remote commitment number. This would be otherwise fine
(and may even encourage them to broadcast their revoked state(s) on
chain), except that our new EnforcingChannelKeys expects us to not
jump forward in time. Since it isn't too important that we punish
our counterparty in such a corner-case, we opt to just close the
channel in such a case and move on.

4 years agoTest basic AMP payments in chanmon_consistency
Matt Corallo [Fri, 10 Jan 2020 22:24:33 +0000 (17:24 -0500)]
Test basic AMP payments in chanmon_consistency

4 years agoTime out AwatingRemoteRAA outgoing HTLCs when we reach cltv_expiry
Antoine Riard [Sat, 8 Dec 2018 03:09:58 +0000 (22:09 -0500)]
Time out AwatingRemoteRAA outgoing HTLCs when we reach cltv_expiry

In case of committing out-of-time outgoing HTLCs, we force
ourselves to close the channel to avoid remote peer claims on a
non-backed HTLC

4 years agoTime out incoming HTLCs when we reach cltv_expiry (+ test)
Matt Corallo [Thu, 9 Jan 2020 19:09:25 +0000 (14:09 -0500)]
Time out incoming HTLCs when we reach cltv_expiry (+ test)

We only do this for incoming HTLCs directly as we rely on channel
closure and HTLC-Timeout broadcast to fail any HTLCs which we
relayed onwards where our next-hop doesn't update_fail in time.

4 years agoRefactor test utils and add a simple MPP send/claim test.
Matt Corallo [Tue, 7 Jan 2020 01:30:08 +0000 (20:30 -0500)]
Refactor test utils and add a simple MPP send/claim test.

4 years agoImplement multipath sends using payment_secret.
Matt Corallo [Tue, 7 Jan 2020 01:29:33 +0000 (20:29 -0500)]
Implement multipath sends using payment_secret.

This rather dramatically changes the return type of send_payment
making it much clearer when resending is safe and allowing us to
return a list of Results since different paths may have different
return values.

4 years agoExpand the Route object to include multiple paths.
Matt Corallo [Sat, 4 Jan 2020 00:31:40 +0000 (19:31 -0500)]
Expand the Route object to include multiple paths.

Rather big diff, but its all mechanical and doesn't introduce any
new features.

4 years agoAdd/announce features for payment_secret and basic_mpp
Matt Corallo [Wed, 15 Jan 2020 04:31:21 +0000 (23:31 -0500)]
Add/announce features for payment_secret and basic_mpp

4 years agoImpl Base AMP in the receive pipeline and expose payment_secret
Matt Corallo [Thu, 2 Jan 2020 06:23:48 +0000 (01:23 -0500)]
Impl Base AMP in the receive pipeline and expose payment_secret

Sadly a huge diff here, but almost all of it is changing the method
signatures for sending/receiving/failing HTLCs and the
PaymentReceived event, which all now need to expose an
Option<[u8; 32]> for the payment_secret.

It doesn't yet properly fail back pending HTLCs when the full AMP
payment is never received (which should result in accidental
channel force-closures). Further, as sending AMP payments is not
yet supported, the only test here is a simple single-path payment
with a payment_secret in it.

4 years agoRefuse to deserialize OnionHopDatas with values > 21 million
Matt Corallo [Thu, 2 Jan 2020 02:13:48 +0000 (21:13 -0500)]
Refuse to deserialize OnionHopDatas with values > 21 million

We should probably do this for all values (and define a newtype
for msat values), but this will do for now.

4 years agoSupport (de)serializing payment_data in onion TLVs and track them
Matt Corallo [Thu, 2 Jan 2020 01:20:42 +0000 (20:20 -0500)]
Support (de)serializing payment_data in onion TLVs and track them

This is the first step in Base AMP support, just tracking the
relevant data in internal datastructures.

4 years agoSplit only-receive/forward data out of PendingHTLCInfo into an enum
Matt Corallo [Wed, 1 Jan 2020 22:39:51 +0000 (17:39 -0500)]
Split only-receive/forward data out of PendingHTLCInfo into an enum

This should avoid blowing up the size of the struct when we add
additional data that is only relevant for receive.

4 years agoClarify the in-flight HTLC state-tracking structs a bit.
Matt Corallo [Wed, 1 Jan 2020 20:56:03 +0000 (15:56 -0500)]
Clarify the in-flight HTLC state-tracking structs a bit.

This also renames PendingForwardHTLCInfo to PendingHTLCInfo since
it now also encompasses Pending *Received* HTLCs.

4 years agoAdd some basic sanity tests for feature flags
Matt Corallo [Tue, 7 Jan 2020 18:58:50 +0000 (13:58 -0500)]
Add some basic sanity tests for feature flags

4 years agoAvoid treating option_upfront_shutdown (req) as unknown_required.
Matt Corallo [Tue, 7 Jan 2020 02:50:55 +0000 (21:50 -0500)]
Avoid treating option_upfront_shutdown (req) as unknown_required.

This fixes the bitmask in requires_unknown_bits.

4 years agoAdd ability to broadcast our own node_announcement.
Matt Corallo [Fri, 3 Jan 2020 01:32:37 +0000 (20:32 -0500)]
Add ability to broadcast our own node_announcement.

This is a somewhat-obvious oversight in the capabilities of
rust-lightning, though not a particularly interesting one until we
start relying on node_features (eg for variable-length-onions and
Base AMP).

Sadly its not fully automated as we don't really want to store the
list of available addresses from the user. However, with a simple
call to ChannelManager::broadcast_node_announcement and a sensible
peer_handler, the announcement is made.

4 years agoAllow node_announcement timestamps of 0 in accordance with BOLT 7
Matt Corallo [Fri, 3 Jan 2020 19:03:46 +0000 (14:03 -0500)]
Allow node_announcement timestamps of 0 in accordance with BOLT 7

Unlike channel_update messages, node_announcement messages have no
requirement that the timestamp is greater than 0.

4 years agoAdd a helper struct to allow a user to safely pass in an addr list
Matt Corallo [Fri, 3 Jan 2020 01:05:17 +0000 (20:05 -0500)]
Add a helper struct to allow a user to safely pass in an addr list

4 years agoUse RouteHop's new node_features to send TLV-encoded onion hops
Matt Corallo [Sat, 28 Dec 2019 18:44:47 +0000 (13:44 -0500)]
Use RouteHop's new node_features to send TLV-encoded onion hops

This implements the new TLV variable-length encoding for onion hop
data, opting to send it if the RouteHop's node_features indicates
support. It also uses the new process_inline method in ChaCha20 to
optimize a few things (though it grows a new TODO for a
probably-important optimization).

4 years agoAdd support for variable-length onion payload reads using TLV
Matt Corallo [Fri, 27 Dec 2019 22:44:46 +0000 (17:44 -0500)]
Add support for variable-length onion payload reads using TLV

4 years agoAdd macros for building TLV (de)serializers.
Matt Corallo [Mon, 3 Feb 2020 01:44:54 +0000 (20:44 -0500)]
Add macros for building TLV (de)serializers.

There's quite a bit of machinery included here, but it neatly
avoids any dynamic allocation during TLV deserialization, and the
calling side looks nice and simple. The macro-generated code is
pretty nice, though has some redundant if statements (I haven't
checked if they get optimized out yet, but I can't imagine they
don't).

4 years agoExpose VecWriter outside of util::ser since peer_handler uses it
Matt Corallo [Mon, 3 Feb 2020 02:25:33 +0000 (21:25 -0500)]
Expose VecWriter outside of util::ser since peer_handler uses it

4 years agoAdd new streams and serialization wrappers for TLV types.
Matt Corallo [Mon, 3 Feb 2020 01:42:40 +0000 (20:42 -0500)]
Add new streams and serialization wrappers for TLV types.

This adds a number of new stream adapters to track and/or calculate
the number of bytes read/written to an underlying stream, as well
as wrappers for the two (?!) variable-length integer types that TLV
introduces.

4 years agoAdd a ChaChaReader adapter to read an encrypted stream & use it
Matt Corallo [Fri, 27 Dec 2019 22:38:15 +0000 (17:38 -0500)]
Add a ChaChaReader adapter to read an encrypted stream & use it

This prepares for variable-length per-hop-data by wrapping the full
hop_data field in a decrypting stream, with a few minor
optimizations and redundant allocations to boot.

4 years agoMove BogusHopData generation into test instead of OnionHopData.
Matt Corallo [Thu, 26 Dec 2019 18:45:44 +0000 (13:45 -0500)]
Move BogusHopData generation into test instead of OnionHopData.

This, as it should be, restricts OnionHopData to only being able to
represent valid states, while still allowing for tests to generate
bogus hop data fields to test deserialization.

4 years agoPull hmac out of OnionHopData.
Matt Corallo [Thu, 26 Dec 2019 18:43:43 +0000 (13:43 -0500)]
Pull hmac out of OnionHopData.

Its a bit awkward to have an hmac field covering the struct that
its in, and there is little difference in removing it, so just pull
it out and use a [u8; 32] where we care about the hmac.

4 years agoFlatten OnionHopData struct with the Realm0 struct.
Matt Corallo [Tue, 24 Dec 2019 20:52:47 +0000 (15:52 -0500)]
Flatten OnionHopData struct with the Realm0 struct.

Previously OnionHopData contained a OnionRealm0HopData field however
instead of bumping the realm number, it has been replaced with a
length, used to indicte the length of a TLV-formatted object.

Because a TLV-formatted hop data can contain the same information as
a realm-0 hop data, we flatten the field and simply keep track of
what format it was in.

4 years agoBetter document msg fuzz target behavior and be slightly more strict
Matt Corallo [Fri, 27 Dec 2019 22:29:51 +0000 (17:29 -0500)]
Better document msg fuzz target behavior and be slightly more strict

4 years agoMerge pull request #459 from ariard/2020-01-fix-htlc-height-timer
Matt Corallo [Sat, 25 Jan 2020 22:11:27 +0000 (22:11 +0000)]
Merge pull request #459 from ariard/2020-01-fix-htlc-height-timer

Fix bumping timer for claiming revoked HTLC outputs

4 years agoMerge pull request #460 from lightning-signer/channel-value
Matt Corallo [Sat, 25 Jan 2020 21:17:12 +0000 (21:17 +0000)]
Merge pull request #460 from lightning-signer/channel-value

Channel value to ChannelKeys constructor

4 years agoMerge pull request #458 from TheBlueMatt/2020-01-spendable-docs
Matt Corallo [Sat, 25 Jan 2020 20:50:10 +0000 (20:50 +0000)]
Merge pull request #458 from TheBlueMatt/2020-01-spendable-docs

Clean up documentation around spendable outputs significantly.

4 years agoMerge pull request #443 from valentinewallace/channelmgr-arcs-to-derefs
Matt Corallo [Sat, 25 Jan 2020 20:41:10 +0000 (20:41 +0000)]
Merge pull request #443 from valentinewallace/channelmgr-arcs-to-derefs

Drop ChannelManager's ChannelMonitor Arc for Deref

4 years agoClean up documentation around spendable outputs significantly. 2020-01-spendable-docs
Matt Corallo [Wed, 22 Jan 2020 23:31:57 +0000 (18:31 -0500)]
Clean up documentation around spendable outputs significantly.

 * Fixed a number of grammar issues
 * Clarified the docs for users who are intimately farmiliar with
   arbitrary lines of text copied from the BOLTs
 * Added a bit more text so that things are easier to read and less
   disjoint.
 * Clarified exactly how the witness stack should look since I had
   to go dig for it.

4 years agoUpdate ChannelManager's ChannelMonitor Arc to be a Deref 2020-01-443-final-nits
Valentine Wallace [Thu, 16 Jan 2020 18:26:38 +0000 (13:26 -0500)]
Update ChannelManager's ChannelMonitor Arc to be a Deref

Additional changes:
* Update fuzz crate to match ChannelManager's new API
* Update lightning-net-tokio library to match ChannelManager's new ChannelMonitor Deref API
* Update tests to match ChannelManager's new ChannelMonitor Deref API

4 years agoRemove unnecessary sign_closing_transaction arg
Devrandom [Thu, 23 Jan 2020 22:32:29 +0000 (14:32 -0800)]
Remove unnecessary sign_closing_transaction arg

4 years agochannel value to ChannelKeys constructor
Devrandom [Thu, 23 Jan 2020 21:33:31 +0000 (13:33 -0800)]
channel value to ChannelKeys constructor

4 years agoFix bumping timer for claiming revoked HTLC outputs
Antoine Riard [Thu, 23 Jan 2020 00:51:19 +0000 (19:51 -0500)]
Fix bumping timer for claiming revoked HTLC outputs

Previously, we were using their_to_self_delay instead of
our_to_self_delay which was falsifying test.

4 years agoMerge pull request #457 from ariard/2020-01-fix-append-onchain
Matt Corallo [Wed, 22 Jan 2020 20:57:36 +0000 (20:57 +0000)]
Merge pull request #457 from ariard/2020-01-fix-append-onchain

Fix spurious calls of broadcast_by_local_state

4 years agoMerge pull request #433 from TheBlueMatt/2019-12-features-in-routes
Matt Corallo [Wed, 22 Jan 2020 20:18:30 +0000 (20:18 +0000)]
Merge pull request #433 from TheBlueMatt/2019-12-features-in-routes

Plumb Features through into Routes

4 years agoFix spurious calls of broadcast_by_local_state
Antoine Riard [Wed, 22 Jan 2020 18:53:12 +0000 (13:53 -0500)]
Fix spurious calls of broadcast_by_local_state

4 years agoDRY-up list_channels by having a common lister that takes a filter 2019-12-features-in-routes
Matt Corallo [Fri, 17 Jan 2020 22:36:46 +0000 (17:36 -0500)]
DRY-up list_channels by having a common lister that takes a filter

4 years agoPass node features through to RouteHops
Matt Corallo [Sat, 28 Dec 2019 06:10:14 +0000 (01:10 -0500)]
Pass node features through to RouteHops

This exposes the latest Init-context features in the ChannelDetails
passed to the Router during route calculation, which combines those
with the Node-context features tracked from node_announcements to
provide the latest Node-context features in RouteHop structs.

Fields are also added for Channel-context features, though those are
only partially used since no such features are defined today anyway.

These will be useful when determining whether to use new
TLV-formatted onion hop datas when generating onions for peers.

4 years agoKeep track of the Init Features for every connected/channel'd peer
Matt Corallo [Sun, 29 Dec 2019 19:22:43 +0000 (14:22 -0500)]
Keep track of the Init Features for every connected/channel'd peer

Since we want to keep track of the Init-context features for every
peer we have channels with, we have to keep them for as long as the
peer is connected (since we may open a channel with them at any
point).

We go ahead and take this opportunity to create a new per-peer-state
struct which has two levels of mutexes which is appropriate for
moving channel storage to.

Since we can't process messages from a given peer in parallel, the
inner lock is a regular mutex, but the outer lock is RW so that we
can process for different peers at the same time with an outer read
lock.

4 years agoPass peer's Init message through to ChannelManager
Matt Corallo [Sat, 28 Dec 2019 03:50:42 +0000 (22:50 -0500)]
Pass peer's Init message through to ChannelManager

4 years agoMerge pull request #451 from lightning-signer/txkeys
Matt Corallo [Mon, 20 Jan 2020 03:46:00 +0000 (03:46 +0000)]
Merge pull request #451 from lightning-signer/txkeys

Provide remote channel public keys to signer

4 years agoUse ChannelPublicKeys in Channel
Devrandom [Fri, 17 Jan 2020 22:31:29 +0000 (14:31 -0800)]
Use ChannelPublicKeys in Channel

4 years agoHide derived fields in TxCreationKeys
Devrandom [Fri, 17 Jan 2020 20:46:54 +0000 (12:46 -0800)]
Hide derived fields in TxCreationKeys

4 years agoProvide remote channel public keys to signer
Devrandom [Fri, 17 Jan 2020 00:51:15 +0000 (16:51 -0800)]
Provide remote channel public keys to signer

4 years agoMerge pull request #447 from ariard/2020-01-fix-weight-computation
Matt Corallo [Fri, 17 Jan 2020 22:32:29 +0000 (22:32 +0000)]
Merge pull request #447 from ariard/2020-01-fix-weight-computation

Bound incoming HTLC witnessScript to min/max limits

4 years agoBound incoming HTLC witnessScript to min/max limits
Antoine Riard [Tue, 14 Jan 2020 18:47:01 +0000 (13:47 -0500)]
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.

4 years agoFix crash when a claim tx has some non-witness inputs.
Matt Corallo [Mon, 13 Jan 2020 18:43:54 +0000 (13:43 -0500)]
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 9df0250dbbad7449e3ec8f90532ce9197eb31997.

4 years agoMerge pull request #450 from ariard/2020-01-fix-fst-blk-disconnection
Matt Corallo [Fri, 17 Jan 2020 20:13:46 +0000 (20:13 +0000)]
Merge pull request #450 from ariard/2020-01-fix-fst-blk-disconnection

Fix full_stack_target block disconnection

4 years agoFix full_stack_target mishandling of block disconnection
Antoine Riard [Fri, 17 Jan 2020 19:21:02 +0000 (14:21 -0500)]
Fix full_stack_target mishandling of block disconnection

4 years agoLog block disconnection in ChannelMonitor
Antoine Riard [Fri, 17 Jan 2020 19:20:23 +0000 (14:20 -0500)]
Log block disconnection in ChannelMonitor

4 years agoMerge pull request #448 from lightning-signer/visibility-for-test
Matt Corallo [Thu, 16 Jan 2020 23:54:09 +0000 (23:54 +0000)]
Merge pull request #448 from lightning-signer/visibility-for-test

Increase visibility for external integration tests

4 years agoincrease visibility for external integration tests
Devrandom [Wed, 15 Jan 2020 21:59:23 +0000 (13:59 -0800)]
increase visibility for external integration tests

4 years agoMerge pull request #444 from lightning-signer/funding-script
Matt Corallo [Thu, 16 Jan 2020 22:02:20 +0000 (22:02 +0000)]
Merge pull request #444 from lightning-signer/funding-script

Construct funding redeem script in signer

4 years agoconstruct funding redeem script in signer
Devrandom [Fri, 10 Jan 2020 01:28:48 +0000 (17:28 -0800)]
construct funding redeem script in signer

4 years agoMerge pull request #449 from jkczyz/2020-01-remove-borrow-parts
Matt Corallo [Thu, 16 Jan 2020 20:18:13 +0000 (20:18 +0000)]
Merge pull request #449 from jkczyz/2020-01-remove-borrow-parts

Remove unnecessary borrow_parts() methods

4 years agoRemove unnecessary borrow_parts() methods
Jeffrey Czyz [Thu, 16 Jan 2020 18:48:16 +0000 (10:48 -0800)]
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.

4 years agoMerge pull request #428 from TheBlueMatt/2019-12-flat-features
Matt Corallo [Mon, 13 Jan 2020 22:53:54 +0000 (22:53 +0000)]
Merge pull request #428 from TheBlueMatt/2019-12-flat-features

Implement Flat Features

4 years agoSeal the features contexts 2019-12-flat-features
Matt Corallo [Wed, 8 Jan 2020 00:21:17 +0000 (19:21 -0500)]
Seal the features contexts

4 years agoMove features into a separate module out of msgs.
Matt Corallo [Mon, 6 Jan 2020 22:54:02 +0000 (17:54 -0500)]
Move features into a separate module out of msgs.

4 years agoRefactor features a bit more to describe what the constructors do
Matt Corallo [Mon, 13 Jan 2020 18:52:23 +0000 (13:52 -0500)]
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.

4 years agoFix Feature endianness by swapping bytes on read/write.
Matt Corallo [Mon, 13 Jan 2020 18:50:29 +0000 (13:50 -0500)]
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.

4 years agoRelay/store channel/node announces w/ unknown req'd feature bits
Matt Corallo [Tue, 24 Dec 2019 18:08:33 +0000 (13:08 -0500)]
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.

4 years agoImplement Flat Features
Matt Corallo [Mon, 23 Dec 2019 22:52:58 +0000 (17:52 -0500)]
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.

4 years agoMerge pull request #439 from TheBlueMatt/2020-01-398-fixups
Matt Corallo [Mon, 6 Jan 2020 03:59:03 +0000 (03:59 +0000)]
Merge pull request #439 from TheBlueMatt/2020-01-398-fixups

398 with nits fixed.

4 years agoDrop Result for ChannelMessageHandler methods 2020-01-398-fixups
Antoine Riard [Tue, 5 Nov 2019 23:51:05 +0000 (18:51 -0500)]
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.

4 years agoAdd assert_log method to TestLogger to harden test
Antoine Riard [Mon, 30 Dec 2019 22:30:27 +0000 (17:30 -0500)]
Add assert_log method to TestLogger to harden test

Extend mock Node with logger.

4 years agoMerge pull request #437 from Aleru/new-api-ping
Matt Corallo [Sun, 5 Jan 2020 17:49:12 +0000 (17:49 +0000)]
Merge pull request #437 from Aleru/new-api-ping

New API for ping generation

4 years agoNew API for ping generation
Aleru [Fri, 20 Sep 2019 15:16:45 +0000 (11:16 -0400)]
New API for ping generation

New API for generating pings

4 years agoMerge pull request #420 from TheBlueMatt/2019-12-chan-ext-signer
Matt Corallo [Sat, 28 Dec 2019 17:50:09 +0000 (17:50 +0000)]
Merge pull request #420 from TheBlueMatt/2019-12-chan-ext-signer

Remove signing from Channel

4 years agoSign local HTLC transactions at broadcast-time, instead of generate 2019-12-chan-ext-signer
Matt Corallo [Fri, 13 Dec 2019 19:56:57 +0000 (14:56 -0500)]
Sign local HTLC transactions at broadcast-time, instead of generate

4 years agoMake ChannelMonitor sign local transactions (at broadcast time)
Matt Corallo [Fri, 13 Dec 2019 06:58:08 +0000 (01:58 -0500)]
Make ChannelMonitor sign local transactions (at broadcast time)

4 years agoSet basic channel info in chanmon all at once, add a bit more info
Matt Corallo [Thu, 12 Dec 2019 19:56:28 +0000 (14:56 -0500)]
Set basic channel info in chanmon all at once, add a bit more info

4 years agoDrop duplicative current-local-tx storage in channel.
Matt Corallo [Fri, 13 Dec 2019 03:42:08 +0000 (22:42 -0500)]
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.

4 years agoFix parameter name incorrectly changed in 4ebe64fafd2ca0e17aab31fb0
Matt Corallo [Tue, 24 Dec 2019 17:01:26 +0000 (12:01 -0500)]
Fix parameter name incorrectly changed in 4ebe64fafd2ca0e17aab31fb0

4 years agoMerge pull request #426 from TheBlueMatt/2019-12-bad-lifetimes
Matt Corallo [Sat, 21 Dec 2019 00:35:10 +0000 (00:35 +0000)]
Merge pull request #426 from TheBlueMatt/2019-12-bad-lifetimes

Remove unused lifetimes.