]> git.bitcoin.ninja Git - rust-lightning/log
rust-lightning
4 years agoMerge pull request #545 from TheBlueMatt/2020-03-fuzz-0-fee
Matt Corallo [Tue, 17 Mar 2020 18:01:06 +0000 (18:01 +0000)]
Merge pull request #545 from TheBlueMatt/2020-03-fuzz-0-fee

Don't return a feerate of 0 in full_stack_target fuzz on EOF

4 years agoMerge pull request #544 from TheBlueMatt/2020-03-fix-mon-ser
Matt Corallo [Tue, 17 Mar 2020 17:59:22 +0000 (17:59 +0000)]
Merge pull request #544 from TheBlueMatt/2020-03-fix-mon-ser

Fix ChannelMonitor round-trip introduced by 3d640da5c343111f538f006

4 years agoDon't return a feerate of 0 in full_stack_target fuzz on EOF 2020-03-fuzz-0-fee
Matt Corallo [Tue, 17 Mar 2020 02:05:57 +0000 (22:05 -0400)]
Don't return a feerate of 0 in full_stack_target fuzz on EOF

This triggered a (legitimate) panic in OnChainTxHandler that the
feerate in use was non-0, which is required by the feerate API.

4 years agoFix ChannelMonitor round-trip introduced by 3d640da5c343111f538f006 2020-03-fix-mon-ser
Matt Corallo [Mon, 16 Mar 2020 23:01:17 +0000 (19:01 -0400)]
Fix ChannelMonitor round-trip introduced by 3d640da5c343111f538f006

3d640da5c343111f538f006996c13c9a98e0d9e6 changed the indexes for
some enums in ChannelMonitor deserialization but not serialization.
Thus, the chanmon_deser_target fuzz target failed on travis on at
least one PR.

4 years agoMerge pull request #543 from TheBlueMatt/2020-03-513-warning
Matt Corallo [Mon, 16 Mar 2020 20:23:37 +0000 (20:23 +0000)]
Merge pull request #543 from TheBlueMatt/2020-03-513-warning

Add missing unwrap() in tests introduced in 4abfd515e554bef90c25dbe

4 years agoAdd missing unwrap() in tests introduced in 4abfd515e554bef90c25dbe 2020-03-513-warning
Matt Corallo [Wed, 11 Mar 2020 20:10:01 +0000 (16:10 -0400)]
Add missing unwrap() in tests introduced in 4abfd515e554bef90c25dbe

4 years agoMerge pull request #513 from ariard/2020-02-fix-zero-msat-htlc
Matt Corallo [Wed, 11 Mar 2020 19:57:38 +0000 (19:57 +0000)]
Merge pull request #513 from ariard/2020-02-fix-zero-msat-htlc

BOLT2: Check we don't send and accept 0-msat HTLC

4 years agoAdd test_override_0msat_htlc_minimum
Antoine Riard [Tue, 10 Mar 2020 23:29:56 +0000 (19:29 -0400)]
Add test_override_0msat_htlc_minimum

4 years agoMake htlc_minimum_msat configurable
Antoine Riard [Tue, 10 Mar 2020 17:03:10 +0000 (13:03 -0400)]
Make htlc_minimum_msat configurable

Enforce a minimum htlc_minimum_msat of 1.

Instead of computing dynamically htlc_minimum_msat based on feerate,
relies on user-provided configuration value. This let user compute
an economical-driven channel parameter according to network dynamics.

4 years agoMerge pull request #472 from TheBlueMatt/2020-01-net-async-await
Matt Corallo [Wed, 11 Mar 2020 17:41:57 +0000 (17:41 +0000)]
Merge pull request #472 from TheBlueMatt/2020-01-net-async-await

Rewrite lightning-net-tokio using async/await and tokio 0.2

4 years agoMerge pull request #541 from valentinewallace/fix-node-features
Matt Corallo [Wed, 11 Mar 2020 17:32:33 +0000 (17:32 +0000)]
Merge pull request #541 from valentinewallace/fix-node-features

Fix node `with_relevant_init_flags`

4 years agoAdd test cases for feature messages from other lightning clients.
Valentine Wallace [Tue, 10 Mar 2020 00:51:32 +0000 (20:51 -0400)]
Add test cases for feature messages from other lightning clients.

4 years agoFix blanking out non-node-context feature flags when pulling features from init context.
Valentine Wallace [Tue, 10 Mar 2020 00:50:41 +0000 (20:50 -0400)]
Fix blanking out non-node-context feature flags when pulling features from init context.

Fixes bug introduced in 912f877

4 years agoFix typo in lightning-net-tokio crate description. 2020-01-net-async-await
Matt Corallo [Mon, 3 Feb 2020 23:47:38 +0000 (18:47 -0500)]
Fix typo in lightning-net-tokio crate description.

4 years agoFix (and test) net-tokio outbound conns without a threaded env
Matt Corallo [Fri, 28 Feb 2020 16:55:34 +0000 (11:55 -0500)]
Fix (and test) net-tokio outbound conns without a threaded env

4 years agoFix long-standing race in net-tokio reading after a disconnect event
Matt Corallo [Mon, 24 Feb 2020 19:17:04 +0000 (14:17 -0500)]
Fix long-standing race in net-tokio reading after a disconnect event

If rust-lightning tells us to disconnect a socket after we read
some bytes from the socket, but before we actually give those bytes
to rust-lightning, we may end up calling rust-lightning with a
Descriptor that isn't registered anymore.

Sadly, there really isn't a good way to solve this, and it should
be a pretty quick event, so we just busy-wait.

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 agoAdd test_update_add_htlc_bolt2_receiver_zero_value_msat
Antoine Riard [Wed, 26 Feb 2020 21:05:00 +0000 (16:05 -0500)]
Add test_update_add_htlc_bolt2_receiver_zero_value_msat

4 years agoBOLT2: Check we don't send and accept 0-msat HTLC
Antoine Riard [Fri, 21 Feb 2020 00:20:29 +0000 (19:20 -0500)]
BOLT2: Check we don't send and accept 0-msat HTLC

Failing this requirement at sending means a strict receiver would
fail our channel while processing a HTLC routed from a third-party.

Fix by enforcing check on both sender and receiver side.

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 agoMerge pull request #435 from TheBlueMatt/2020-01-node_announce
Matt Corallo [Mon, 9 Mar 2020 00:13:47 +0000 (00:13 +0000)]
Merge pull request #435 from TheBlueMatt/2020-01-node_announce

Add ability to broadcast our own node_announcement

4 years agoUse block timestamps as the min for generated update messages. 2020-01-node_announce
Matt Corallo [Thu, 5 Mar 2020 23:01:06 +0000 (18:01 -0500)]
Use block timestamps as the min for generated update messages.

Fixes issue #493 and should resolve some issues where other nodes
(incorrectly) reject channel_update/node_announcement messages
which have a serial number that is not a relatively recent
timestamp.

4 years agoFurther document the initial routing table send.
Matt Corallo [Wed, 12 Feb 2020 18:40:29 +0000 (13:40 -0500)]
Further document the initial routing table send.

As requested by Arik at https://github.com/rust-bitcoin/rust-lightning/pull/435#discussion_r378093821

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 more than one address per type in node_announcement messages
Matt Corallo [Thu, 5 Mar 2020 18:39:53 +0000 (13:39 -0500)]
Allow more than one address per type in node_announcement messages

lnd has been blatantly ignoring this line in the spec forever, so
its somewhat of a lost cause trying to enforce it.

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 agoMerge pull request #535 from TheBlueMatt/2020-03-462-nits
Matt Corallo [Thu, 5 Mar 2020 16:19:14 +0000 (16:19 +0000)]
Merge pull request #535 from TheBlueMatt/2020-03-462-nits

A few minor nits on #462

4 years agoTake multiple spent-txn to check_spends! in functional_tests 2020-03-462-nits
Matt Corallo [Wed, 4 Mar 2020 22:45:27 +0000 (17:45 -0500)]
Take multiple spent-txn to check_spends! in functional_tests

This reintroduces a check_spends!() removed in 3d640da5c343111f538f
due to check_spends not being able to check a transaction which
spends multiple other transactions.

It also simplifies a few calls in claim_htlc_outputs_single_tx by
using check_spends!().

4 years agoDrop redundant .clone() in check_spends calls.
Matt Corallo [Wed, 4 Mar 2020 22:36:12 +0000 (17:36 -0500)]
Drop redundant .clone() in check_spends calls.

The API to rust-bitcoin to check a transaction correctly spends
another changed some time ago, but we still have a lot of needless
.clone()s in our tests.

4 years agoCorrect comment in onchaintx.rs
Matt Corallo [Wed, 4 Mar 2020 22:53:16 +0000 (17:53 -0500)]
Correct comment in onchaintx.rs

This comment was stale and referred to a previous implementation
of #462, which changed before it was merged.

4 years agoFlatten Vec passed from channelmonitor to onchaintx block_connected
Matt Corallo [Wed, 4 Mar 2020 22:27:03 +0000 (17:27 -0500)]
Flatten Vec passed from channelmonitor to onchaintx block_connected

Instead of passing a Vec of Vecs drop them into one as we go in
ChannelMonitor, hopefully avoiding a bit of memory fragmentation
and improving readability.

4 years agoMerge pull request #462 from ariard/2020-01-refactor-chan
Matt Corallo [Wed, 4 Mar 2020 22:23:28 +0000 (22:23 +0000)]
Merge pull request #462 from ariard/2020-01-refactor-chan

Introduce OnchainTxHandler, move bumping and tracking logic

4 years agoRename InputMaterial script to witness_script
Antoine Riard [Mon, 2 Mar 2020 23:12:18 +0000 (18:12 -0500)]
Rename InputMaterial script to witness_script

4 years agoComment better get_height_timer logic.
Antoine Riard [Tue, 18 Feb 2020 18:11:56 +0000 (13:11 -0500)]
Comment better get_height_timer logic.

Height timer as an important component of a more-secure, fee-sensitive
claiming of time-constrained LN outputs, therefore document assumptions.

4 years agoRemove TestBroadcaster temporary dedup buffer
Antoine Riard [Fri, 24 Jan 2020 22:48:27 +0000 (17:48 -0500)]
Remove TestBroadcaster temporary dedup buffer

4 years agoStructurify claim request handed between detection/reaction
Antoine Riard [Wed, 12 Feb 2020 18:00:29 +0000 (13:00 -0500)]
Structurify claim request handed between detection/reaction

4 years agoIntroduce OnchainTxHandler, move bumping and tracking logic
Antoine Riard [Fri, 24 Jan 2020 16:57:52 +0000 (11:57 -0500)]
Introduce OnchainTxHandler, move bumping and tracking logic

Encapsulates tracking and bumping of in-flight transactions in
its own component. This component may be latter abstracted
to reuse tracking and RBF for new features (e.g dual-funding,
splicing)

Build all transactions generation in one place. Also as fees
and signatures are closely tied, what keys do you have determine
what bumping mode you can use.

4 years agoMerge pull request #523 from TheBlueMatt/2020-02-router-ser-fix
Matt Corallo [Wed, 4 Mar 2020 20:37:58 +0000 (20:37 +0000)]
Merge pull request #523 from TheBlueMatt/2020-02-router-ser-fix

Fix Router Serialization Roundtrip

4 years agoTest Router serialization round-trip in functional_tests. 2020-02-router-ser-fix
Matt Corallo [Mon, 24 Feb 2020 04:26:10 +0000 (23:26 -0500)]
Test Router serialization round-trip in functional_tests.

This tests Router serialization round-trip at the end of each
functional test in the same way we do ChannelMonitors and
ChannelManagers to catch any cases where we were able to get into
a state which would have prevented reading a Router back off disk.

We further walk all of the announcements which both the original
and deserialized Routers would send to peers requesting initial
sync to ensure they match.

4 years agoChange Option<T> serialization format to include length
Matt Corallo [Mon, 24 Feb 2020 04:25:43 +0000 (23:25 -0500)]
Change Option<T> serialization format to include length

This is a cheap way to fix an error in Router serialization
roundtrip due to us calling read_to_end during the read of
channel/node announcement/updates. During normal message reading,
we only have limited bytes to read (specifically the message buffer)
so this is fine, however when we read them inside Router, we have
more data from other fields of the Router available as well. Thus,
we end up reading the entire rest of the Router into one message
field, and failing to deserialize.

Because such fields are always stored in Option<>s, we can simply
use a LengthLimitingStream in the Option<> serialization format and
make only the correct number of bytes available.

By using a variable-length integer for the new field, we avoid
wasting space compared to the existing serialization format.

4 years agoMake Readable::read a templated on the stream, not Readable itself
Matt Corallo [Mon, 24 Feb 2020 04:12:19 +0000 (23:12 -0500)]
Make Readable::read a templated on the stream, not Readable itself

This makes Readable symmetric with Writeable and makes sense -
something which is Readable should be Readable for any stream which
implements std::io::Read, not only for a stream type it decides on.

This solves some lifetime-compatibility issues in trying to read()
from a LengthLimitingReader in arbitrary Readable impls.

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 agoMerge pull request #534 from TheBlueMatt/2020-02-fuzz-on-stable
Matt Corallo [Wed, 4 Mar 2020 19:28:23 +0000 (19:28 +0000)]
Merge pull request #534 from TheBlueMatt/2020-02-fuzz-on-stable

[travis] Build lightning-net-tokio on Rust 1.39.0+, fuzz on stable

4 years ago[travis] Build lightning-net-tokio on Rust 1.39.0+, fuzz on stable 2020-02-fuzz-on-stable
Matt Corallo [Sat, 1 Feb 2020 17:37:50 +0000 (12:37 -0500)]
[travis] Build lightning-net-tokio on Rust 1.39.0+, fuzz on stable

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 and uses that for codecov generation.

This also moves fuzzing to Rust stable, as honggfuzz broke its MSRV
and it seems likely it will again in the future.

4 years agoMerge pull request #517 from ccdle12/2020-02-per-channel-config
Matt Corallo [Sat, 29 Feb 2020 03:10:54 +0000 (03:10 +0000)]
Merge pull request #517 from ccdle12/2020-02-per-channel-config

Add an override optional UserConfig per new outbound channel

4 years agoMerge pull request #507 from moneyball/patch-2
Matt Corallo [Sat, 29 Feb 2020 02:59:34 +0000 (02:59 +0000)]
Merge pull request #507 from moneyball/patch-2

Add project tracking and conventions we want to adopt

4 years agomade fixes per val and matt feedback
Steve Lee [Sat, 29 Feb 2020 01:01:16 +0000 (17:01 -0800)]
made fixes per val and matt feedback

4 years agoAdd an override optional UserConfig per new outbound channel
Christopher Coverdale [Tue, 25 Feb 2020 12:03:25 +0000 (12:03 +0000)]
Add an override optional UserConfig per new outbound channel

4 years agoMerge pull request #520 from TheBlueMatt/2020-02-events-in-monitors
Matt Corallo [Fri, 28 Feb 2020 20:10:38 +0000 (20:10 +0000)]
Merge pull request #520 from TheBlueMatt/2020-02-events-in-monitors

Move events into ChannelMonitor from ManyChannelMonitor

4 years agoAdd comment noting that ChannelMonitor events are serialized 2020-02-events-in-monitors
Matt Corallo [Fri, 28 Feb 2020 19:35:34 +0000 (14:35 -0500)]
Add comment noting that ChannelMonitor events are serialized

4 years agoDrop stale doc comment + TODO describing MessageSendEvents
Matt Corallo [Fri, 28 Feb 2020 19:28:13 +0000 (14:28 -0500)]
Drop stale doc comment + TODO describing MessageSendEvents

4 years agoMove events into ChannelMonitor from ManyChannelMonitor
Matt Corallo [Wed, 12 Feb 2020 21:55:04 +0000 (16:55 -0500)]
Move events into ChannelMonitor from ManyChannelMonitor

This is the next step after "Move pending-HTLC-updated ChannelMonitor
from ManyChannelMonitor", moving our events into ChannelMonitor as
well and leaving only new-outputs-to-watch in the return value for
ChannelMonitor::block_connected (which is fine as those are
duplicatively tracked in the ChannelMonitor directly, so
losing/replaying them is acceptable).

4 years agoImplement Readable/Writeable for Events
Matt Corallo [Wed, 12 Feb 2020 22:02:03 +0000 (17:02 -0500)]
Implement Readable/Writeable for Events

As noted in the docs, Events don't round-trip fully, but round-trip
in a way that is useful for ChannelManagers, specifically some events
don't make sense anymore after a restart.

4 years agoMerge pull request #522 from valentinewallace/chanmgr-fee-est-arc-to-deref
Matt Corallo [Fri, 28 Feb 2020 19:08:43 +0000 (19:08 +0000)]
Merge pull request #522 from valentinewallace/chanmgr-fee-est-arc-to-deref

Update ChannelManager's FeeEstimator from Arc to Deref.

4 years agoMerge pull request #521 from TheBlueMatt/2020-02-ping-connection-possible
Matt Corallo [Thu, 27 Feb 2020 21:12:23 +0000 (21:12 +0000)]
Merge pull request #521 from TheBlueMatt/2020-02-ping-connection-possible

Dont treat a timer tick as no_connection_possible

4 years agoDont treat a timer tick as no_connection_possible and log 2020-02-ping-connection-possible
Matt Corallo [Mon, 24 Feb 2020 23:47:38 +0000 (18:47 -0500)]
Dont treat a timer tick as no_connection_possible and log

In testing, due to other patches, I managed to flood the send queue
with messages and cause us not to be able to send pings, thus
getting a peer disconnected for ping timeout. To my surprise, this
also force-closed all of my channels with that peeer.

Obviously a ping timeout does not indicate that no future connection
with said peer will be possible, and we shouldn't be force-closing
channels as a result.

This also logs when a peer is disconnected to ping timeout to make
debug easier.

4 years agoAdd logging on receipt of unknown message types.
Matt Corallo [Mon, 24 Feb 2020 23:38:55 +0000 (18:38 -0500)]
Add logging on receipt of unknown message types.

This should make peer disconnection easier to debug.

4 years agoUpdate ChannelManager's FeeEstimator from Arc to Deref.
Valentine Wallace [Thu, 27 Feb 2020 16:33:03 +0000 (11:33 -0500)]
Update ChannelManager's FeeEstimator from Arc to Deref.

4 years agoMerge pull request #518 from valentinewallace/chanmgr-keysmgr-arc-to-deref
Matt Corallo [Thu, 27 Feb 2020 19:29:35 +0000 (19:29 +0000)]
Merge pull request #518 from valentinewallace/chanmgr-keysmgr-arc-to-deref

multi: update ChannelManager's keys manager from Arc to Deref

4 years agomulti: update ChannelManager's keys manager from Arc to Deref
Valentine Wallace [Wed, 26 Feb 2020 21:00:26 +0000 (16:00 -0500)]
multi: update ChannelManager's keys manager from Arc to Deref

4 years agoMerge pull request #489 from TheBlueMatt/2020-02-chan-updates
Matt Corallo [Thu, 27 Feb 2020 01:03:28 +0000 (01:03 +0000)]
Merge pull request #489 from TheBlueMatt/2020-02-chan-updates

Move to a Monitor-Update return from copying around ChannelMonitors

4 years agoDrop TODO which was implemented long ago 2020-02-chan-updates
Matt Corallo [Fri, 21 Feb 2020 22:10:03 +0000 (17:10 -0500)]
Drop TODO which was implemented long ago

4 years agoDrop Clone from ChannelMonitor.
Matt Corallo [Wed, 12 Feb 2020 20:47:04 +0000 (15:47 -0500)]
Drop Clone from ChannelMonitor.

This removes the somewhat-easy-to-misuse Clone from ChannelMonitors,
opening us up to being able to track Events in ChannelMonitors with
less risk of misuse.

Sadly it doesn't remove the Clone requirement for ChannelKeys,
though gets us much closer - we now just need to request a second
copy once when we go to create the ChannelMonitors.

4 years agoRm ChannelMonitor merge capabilities in favor of explicit add/update
Matt Corallo [Tue, 11 Feb 2020 23:34:29 +0000 (18:34 -0500)]
Rm ChannelMonitor merge capabilities in favor of explicit add/update

This removes the ability to merge ChannelMonitors in favor of
explicit ChannelMonitorUpdates. It further removes
ChannelManager::test_restore_channel_monitor in favor of the new
ChannelManager::channel_monitor_updated method, which explicitly
confirms a set of updates instead of providing the latest copy of
each ChannelMonitor to the user.

This removes almost all need for Channels to have the latest
channel_monitor, except for broadcasting the latest local state.

4 years agoCreate ChannelMonitors with basic_channel_info and funding_info set
Matt Corallo [Sat, 8 Feb 2020 22:45:40 +0000 (17:45 -0500)]
Create ChannelMonitors with basic_channel_info and funding_info set

This removes most of the reliance on ChannelMonitor Clone, creating
them in Channel only at the time when we need to start monitoring
the chain.

4 years agoUse ChannelMonitorUpdate in fallen-behind handling during reestablish
Matt Corallo [Sat, 8 Feb 2020 22:22:58 +0000 (17:22 -0500)]
Use ChannelMonitorUpdate in fallen-behind handling during reestablish

This is a rather huge diff, almost entirely due to removing the
type parameter from ChannelError which was added in
c20e930b31e973e0fb290322c9ac425002e3b672 due to holding the
ChannelKeys in ChannelMonitors.

4 years agoSet ChannelMonitor basic_channel_info on funding, not on accept
Matt Corallo [Sat, 8 Feb 2020 21:17:59 +0000 (16:17 -0500)]
Set ChannelMonitor basic_channel_info on funding, not on accept

This prepares for only creating the ChannelMonitor on funding by
removing any channel_monitor calls from Channel open/accept-time to
funding-signed time.

4 years agoUse ChannelMonitorUpdates in commitment signing fns in Channel
Matt Corallo [Sat, 8 Feb 2020 01:08:31 +0000 (20:08 -0500)]
Use ChannelMonitorUpdates in commitment signing fns in Channel

This is a rather big step towards using the new ChannelMonitorUpdate
flow, using it in the various commitment signing and commitment
update message processing functions in Channel. Becase they all
often call each other, they all have to be updated as a group,
resulting in the somewhat large diff in this commit.

In order to keep the update_ids strictly increasing by one for
ease of use on the user end, we have to play some games with the
latest_monitor_update_id field, though its generally still pretty
readable, and the pattern of "get an update_id at the start, and
use the one we got at the start when returning, irrespective of
what other calls into the Channel during that time did" is
relatively straightforward.

4 years agoImpl (de)serialization for bitcoin::Transaction.
Matt Corallo [Sat, 8 Feb 2020 01:05:37 +0000 (20:05 -0500)]
Impl (de)serialization for bitcoin::Transaction.

There is little risk of misusing this as there's not much in the
way of other ways you may want to serialize bitcoin::Transaction

4 years agoUpdate Channel::funding_signed to use ChannelMonitorUpdate
Matt Corallo [Thu, 6 Feb 2020 18:53:56 +0000 (13:53 -0500)]
Update Channel::funding_signed to use ChannelMonitorUpdate

This is the first of several steps to update ChannelMonitor updates
to use the new ChannelMonitorUpdate objects, demonstrating how the
new flow works in Channel.

4 years agoAdd types for updating ChannelMonitors without copying them.
Matt Corallo [Thu, 6 Feb 2020 00:39:31 +0000 (19:39 -0500)]
Add types for updating ChannelMonitors without copying them.

This is the first step in migrating ChannelMonitor updating logic
to use incremental Update objects instead of copying the
ChannelMonitors themselves and insert_combine()ing them.

This adds most of the scaffolding and updates relevant comments to
refer to the new architecture, without changing how any actual
updates occur.

4 years agoUse Channel::funding_txo instead of its channel_monitor.funding_txo
Matt Corallo [Thu, 6 Feb 2020 05:03:32 +0000 (00:03 -0500)]
Use Channel::funding_txo instead of its channel_monitor.funding_txo

Currently Channel relies on its own internal channel_monitor copy
to keep track of funding_txo information, which is both a bit
awkward and not ideal if we want to get rid of the ChannelMonitor
copy in Channel.

Instead, just duplicate it (its small) and keep it directly in
Channel, allowing us to remove the (super awkward)
ChannelMonitor::unset_funding_txo().

4 years agoTrack counterparty's commitment secrets in Channel directly.
Matt Corallo [Fri, 7 Feb 2020 22:48:46 +0000 (17:48 -0500)]
Track counterparty's commitment secrets in Channel directly.

In the process of removing a local ChannelMonitor in each Channel,
we need to track our counterpartys' commitment secrets so that we
can check them locally instead of calling our channel monitor to
do that work for us.

4 years agoSwap out ChannelMonitor remote secret tracking for a struct.
Matt Corallo [Fri, 7 Feb 2020 21:05:24 +0000 (16:05 -0500)]
Swap out ChannelMonitor remote secret tracking for a struct.

In order to drop the ChannelMonitor from Channel, we need to track
remote per_commitment_secrets outside of the monitor to validate new
ones as they come in.

This just moves the current code from ChannelMonitor into a new
CounterpartyCommitmentSecrets struct in chan_utils.

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 agoMerge pull request #509 from valentinewallace/chanmgr-tx-broadcaster-to-deref
Matt Corallo [Wed, 26 Feb 2020 03:13:16 +0000 (03:13 +0000)]
Merge pull request #509 from valentinewallace/chanmgr-tx-broadcaster-to-deref

multi: update ChannelManager tx broadcaster from Arc to Deref

4 years agomulti: update ChannelManager tx broadcaster from Arc to Deref
Valentine Wallace [Thu, 20 Feb 2020 19:14:12 +0000 (14:14 -0500)]
multi: update ChannelManager tx broadcaster from Arc to Deref

4 years agoMerge pull request #515 from TheBlueMatt/2020-02-further-peer-docs
Matt Corallo [Mon, 24 Feb 2020 19:57:42 +0000 (19:57 +0000)]
Merge pull request #515 from TheBlueMatt/2020-02-further-peer-docs

Further clean up some comments wrt the peer socket handling API

4 years agoFurther clean up some comments wrt the peer socket handling API 2020-02-further-peer-docs
Matt Corallo [Mon, 24 Feb 2020 16:54:15 +0000 (11:54 -0500)]
Further clean up some comments wrt the peer socket handling API

4 years agoMerge pull request #512 from TheBlueMatt/2020-02-peer_handler-docs
Matt Corallo [Fri, 21 Feb 2020 19:02:21 +0000 (19:02 +0000)]
Merge pull request #512 from TheBlueMatt/2020-02-peer_handler-docs

Fix incorrect docs/disconnect handling in peer_handler

4 years agoMerge pull request #474 from TheBlueMatt/2020-02-htlc-updated-in-monitors
Matt Corallo [Fri, 21 Feb 2020 18:50:45 +0000 (18:50 +0000)]
Merge pull request #474 from TheBlueMatt/2020-02-htlc-updated-in-monitors

Move pending-HTLC-updated ChannelMonitor from ManyChannelMonitor

4 years agoFix incorrect docs around disconnect in peer_handler + rename fns 2020-02-peer_handler-docs
Matt Corallo [Thu, 20 Feb 2020 20:12:42 +0000 (15:12 -0500)]
Fix incorrect docs around disconnect in peer_handler + rename fns

The way PeerHandler was written, it was supposed to remove from
self.peers iff the API docs indicate that disconnect_event should
NOT be called (and otherwise rely on disconnect_event to do so).

Sadly, the implementation was way out of whack with reality - in
the implementation, essentially anywhere where PeerHandler
originated the disconnection, the peer was removed and no
disconnect_event was expected. The docs, however, indicated that
disconnect_event should nearly only be called, only not doing so
when the initial handshake message never completed.

We opt to change the docs, mostly, as well as clean up the
ping/pong handling somewhat and rename a few functions to clarify
what they actually do.

4 years agoTest basic HTLC claim behavior from monitor -> manager on reorg 2020-02-htlc-updated-in-monitors
Matt Corallo [Tue, 18 Feb 2020 22:57:15 +0000 (17:57 -0500)]
Test basic HTLC claim behavior from monitor -> manager on reorg

4 years agoMove pending-HTLC-updated ChannelMonitor from ManyChannelMonitor
Matt Corallo [Tue, 4 Feb 2020 04:46:29 +0000 (23:46 -0500)]
Move pending-HTLC-updated ChannelMonitor from ManyChannelMonitor

This is important for a number of reasons:
 * Firstly, I hit this trying to implement rescan in the demo
   bitcoinrpc client - if individual ChannelMonitors are out of
   sync with each other, we cannot add them all into a
   ManyChannelMonitor together and then rescan, but need to rescan
   them individually without having to do a bunch of manual work.
   Of the three return values in ChannelMonitor::block_connected,
   only the HTLCsource stuff that is moved here makes no sense to
   be exposed to the user.
 * Secondly, the logic currently in ManyChannelMonitor cannot be
   reproduced by the user! HTLCSource is deliberately an opaque
   type but we use its data to decide which things to keep when
   inserting into the HashMap. This would prevent a user from
   properly implementing a replacement ManyChannelMonitor, which is
   unacceptable.
 * Finally, by moving the tracking into ChannelMonitor, we can
   serialize them out, which prevents us from forgetting them when
   loading from disk, though there are still other races which need
   to be handled to make this fully safe (see TODOs in
   ChannelManager).

This is safe as no two entries can have the same HTLCSource across
different channels (or, if they did, it would be a rather serious
bug), though note that, IIRC, when this code was added, the
HTLCSource field in the values was not present.

We also take this opportunity to rename the fetch function to match
our other event interfaces, makaing it clear that by calling the
function the set of HTLCUpdates will also be cleared.

4 years agoMerge pull request #514 from TheBlueMatt/2020-02-no-lto-travis-fuzz
Matt Corallo [Fri, 21 Feb 2020 01:30:17 +0000 (01:30 +0000)]
Merge pull request #514 from TheBlueMatt/2020-02-no-lto-travis-fuzz

Skip lto on travis when building fuzz targets as it takes 30 min

4 years agoSkip lto on travis when building fuzz targets as it takes 30 min 2020-02-no-lto-travis-fuzz
Matt Corallo [Fri, 21 Feb 2020 01:02:26 +0000 (20:02 -0500)]
Skip lto on travis when building fuzz targets as it takes 30 min

4 years agoMerge pull request #510 from TheBlueMatt/2020-02-fewer-fuzz-rustc-warns
Matt Corallo [Thu, 20 Feb 2020 22:29:10 +0000 (22:29 +0000)]
Merge pull request #510 from TheBlueMatt/2020-02-fewer-fuzz-rustc-warns

Silence new rustc warnings re: extra ()s, dyn, and unused params

4 years agoMerge pull request #511 from TheBlueMatt/2020-02-test-pub-in-test-only
Matt Corallo [Thu, 20 Feb 2020 21:12:10 +0000 (21:12 +0000)]
Merge pull request #511 from TheBlueMatt/2020-02-test-pub-in-test-only

Only expose constants exposed for testing in cfg(test)

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

4 years agoSilence new rustc warnings re: extra ()s, dyn, and unused params 2020-02-fewer-fuzz-rustc-warns
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 agoMerge pull request #506 from arik-so/ping_encryption_fix
Matt Corallo [Thu, 20 Feb 2020 19:50:20 +0000 (19:50 +0000)]
Merge pull request #506 from arik-so/ping_encryption_fix

Encrypt ping messages before sending them

4 years agoRemove unused code in peer handler test utility method.
Arik Sosman [Thu, 20 Feb 2020 01:57:03 +0000 (17:57 -0800)]
Remove unused code in peer handler test utility method.

4 years agoMerge pull request #508 from maxgiraldo/2020-02-sp-grammar
Matt Corallo [Thu, 20 Feb 2020 00:10:15 +0000 (00:10 +0000)]
Merge pull request #508 from maxgiraldo/2020-02-sp-grammar

docs(CONTRIBUTING): fix spelling and grammar

4 years agoFix ping message sent on timer ticks to be encrypted so the peer can decrypt it inste...
Arik Sosman [Tue, 18 Feb 2020 22:16:33 +0000 (14:16 -0800)]
Fix ping message sent on timer ticks to be encrypted so the peer can decrypt it instead of shutting down the connection.

4 years agodocs(CONTRIBUTING): fix spelling and grammar
Max Giraldo [Wed, 19 Feb 2020 21:56:43 +0000 (16:56 -0500)]
docs(CONTRIBUTING): fix spelling and grammar

Fix some minor spelling and grammar mistakes.

4 years agoMerge pull request #502 from rloomba/rloomba/add_unregister_listener
Matt Corallo [Wed, 19 Feb 2020 19:02:47 +0000 (19:02 +0000)]
Merge pull request #502 from rloomba/rloomba/add_unregister_listener

[chaininterface] Add ability for BlockNotifier to unregister listeners

4 years agoAdd project tracking and conventions we want to adopt
Steve Lee [Wed, 19 Feb 2020 01:04:55 +0000 (17:04 -0800)]
Add project tracking and conventions we want to adopt

4 years agoMerge pull request #503 from TheBlueMatt/2020-02-chanmon-ser-roundtrip
Matt Corallo [Wed, 19 Feb 2020 00:26:47 +0000 (00:26 +0000)]
Merge pull request #503 from TheBlueMatt/2020-02-chanmon-ser-roundtrip

Fix Two Bugs around ChannelManager serialization round-trip

4 years agoMerge pull request #455 from TheBlueMatt/2020-01-monitor-reload-watch
Matt Corallo [Wed, 19 Feb 2020 00:06:26 +0000 (00:06 +0000)]
Merge pull request #455 from TheBlueMatt/2020-01-monitor-reload-watch

Track the full list of outpoints a chanmon wants monitoring for

4 years agoAllow deserialization of new Channels before we've seen a block 2020-02-chanmon-ser-roundtrip
Matt Corallo [Sat, 15 Feb 2020 17:12:50 +0000 (12:12 -0500)]
Allow deserialization of new Channels before we've seen a block

Previously, if we have a live ChannelManager (that has seen blocks)
and we open a new Channel, if we serialize that ChannelManager
before a new block comes in, we'll fail to deserialize it. This is
the result of an overly-ambigious last_block_connected check which
would see 0s for the new channel but the previous block for the
ChannelManager as a whole.

We add a new test which catches this error as well as hopefully
getting some test coverage for other similar issues in the future.