Commit graph

2519 commits

Author SHA1 Message Date
Matt Corallo
90e984e797 Track the blocks a node has connected in the TestBroadcaster 2021-05-28 23:56:44 +00:00
Matt Corallo
29a780e9e0 Delay broadcast of PackageTemplate packages until their locktime
This stores transaction templates temporarily until their locktime
is reached, avoiding broadcasting (or RBF bumping) transactions
prior to their locktime. For those broadcasting transactions
(potentially indirectly) via Bitcoin Core RPC, this ensures no
automated rebroadcast of transactions on the client side is
required to get transactions confirmed.
2021-05-28 23:56:44 +00:00
Matt Corallo
79ffc5eac9 Always pass height to OnchainTxHandler::update_claims_view
This simplifies logic somewhat and avoids duplicating the storage
of the current height in OnchainTxHandler.
2021-05-28 23:56:44 +00:00
Matt Corallo
9bd87e9c9d Expose the timelock of transaction packages 2021-05-28 23:56:44 +00:00
Matt Corallo
7d6938a43a Simplify tx checks in functional tests to make later commits simpler
This cleans up some of the transaction format verification and docs
to make it easier when we delay CLTV-locked transactions to update
the tests.
2021-05-28 23:56:44 +00:00
Matt Corallo
56491d91bb Simplify HolderHTLCOutput constructor and track CLTV expiry
This allows us to interrogate a PackageTemplate for the CLTV
timelock of the resulting transaction.
2021-05-28 23:56:44 +00:00
Matt Corallo
f492a192ff Add assertions to ensure we don't use an invalid package_amount
This somewhat cleans up the public API of PackageSolvingData to
make it harder to get an invalid amount and use it, adding further
debug assertion to check it at test-time.
2021-05-28 23:56:44 +00:00
Matt Corallo
df829a8526
Merge pull request #928 from TheBlueMatt/2021-05-really-tlv-ser
Migrate some inner structs to TLVs
2021-05-27 23:05:47 +00:00
Matt Corallo
ad20bc7f5a Update net_graph used for benchmarks to use new ser format. 2021-05-27 21:46:38 +00:00
Matt Corallo
45d86ead64 Migrate packages sub-fields to TLV serialization 2021-05-27 21:41:24 +00:00
Matt Corallo
c8bc1b6d3d Use TLV serialization for Commitment transaction structures 2021-05-27 21:41:24 +00:00
Matt Corallo
a7494228c9 Add TLV suffix to PackageTemplate 2021-05-27 21:41:07 +00:00
Matt Corallo
321b19c4d9 Move NetworkGraph inner structs to TLV storage 2021-05-27 21:41:07 +00:00
Matt Corallo
9ec0f04b74 Move ChannelManager-inner structs to TLV storage
Note that enums are left alone as we can use the type byte already
present for future compatibility.
2021-05-27 21:41:07 +00:00
Matt Corallo
557aa81619 Add dummy OutPoint constructor to be used when reading it in a TLV 2021-05-27 21:41:07 +00:00
Matt Corallo
cf430029c4 Add a macro which implements Readable/Writeable using TLVs only
This also includes a `VecWriteWrapper` and `VecReadWrapper` which
implements serialization for any `Readable`/`Writeable` type that is
in a Vec. We do this instead of implementing `Readable`/`Writeable`
directly as there isn't always a univerally-defined way to serialize
a Vec and this makes things more explicit.

Finally, this tweaks existing macros (and in the new macros) to
support a trailing `,` after a list, eg
`write_tlv_fields!(stream, {(0, a),}, {});` whereas previously the
trailing `,` after the `(0, a)` would be a compile-error.
2021-05-27 21:41:07 +00:00
Matt Corallo
f30694bd8c
Merge pull request #924 from GeneFerneau/alloc
Use alloc for no_std builds
2021-05-27 19:08:00 +00:00
Gene Ferneau
12461fcba1
Use alloc for no_std builds
Replace std structs with alloc equivalents to support no_std builds

f use prelude::* credit @devrandom
2021-05-27 17:35:20 +00:00
Jeffrey Czyz
4a12d7656e
Cache socket address in HttpClient for reconnect
If the HttpClient attempts to reconnect to bitcoind that is no longer
running, the client fails to get the address from the stream. Cache the
address when connecting to prevent this.
2021-05-27 08:53:14 -07:00
Matt Corallo
c9f6a35756 Fix compile warnings reading type-0 TLVs 2021-05-27 01:05:26 +00:00
Matt Corallo
8e7b5905fd
Merge pull request #929 from jkczyz/2021-05-json-rpc-error
Parse RPC errors as JSON content
2021-05-27 00:20:08 +00:00
Jeffrey Czyz
b2f16ad821
Parse RPC errors as JSON content
Bitcoin Core's JSON RPC server returns errors as HTTP error responses
with JSON content in the body. Parse this content as JSON to give a more
meaningful error. Otherwise, "binary" is given because the content
contains ASCII control characters.
2021-05-26 10:57:39 -07:00
Jeffrey Czyz
61648fc804
Define an HttpError for returning error contents
Return an HTTP error response as a status code and contents. This allows
clients to interpret the response as desired (e.g., the contents as a
JSON-formatted error).
2021-05-26 10:51:16 -07:00
Matt Corallo
f0743433e7
Merge pull request #642 from ariard/2020-06-anchor-backend-refacto
Anchor-outputs (1/3): Refactoring chain backend to extract PackageTemplate
2021-05-26 15:50:25 +00:00
Antoine Riard
c40ebf18e5 Add package template unit tests 2021-05-25 23:18:56 -04:00
Antoine Riard
881c0f58e1 Move compute_output_value as part of package member functions 2021-05-25 19:59:40 -04:00
Antoine Riard
bb0e33f383 Move get_height_timer out of OnchainTxHandler 2021-05-25 19:59:40 -04:00
Antoine Riard
4363f965d6 Move onchain* to chain/ 2021-05-25 19:59:40 -04:00
Antoine Riard
5ccb07554b Integrate PackageTemplate
This commit replaces InputMaterial in both ChannelMonitor/
OnchainTxHandler.

This doesn't change behavior.
2021-05-25 19:59:40 -04:00
Antoine Riard
2d451b8622 Duplicate fee computation utilities out of OnchainTxHandler
Duplicated code in onchain.rs is removed in next commits.
2021-05-25 19:54:57 -04:00
Antoine Riard
c9bd7b3f2d Introduce PackageTemplae, a replacement of InputMaterial
PackageTemplate aims to replace InputMaterial, introducing a clean
interface to manipulate a wide range of claim types without
OnchainTxHandler aware of special content of each.

This is used in next commits.
2021-05-25 19:54:57 -04:00
Antoine Riard
0ea7dd8bfc Add package.rs file
Package.rs aims to gather interfaces to communicate between
onchain channel transactions parser (ChannelMonitor) and outputs
claiming logic (OnchainTxHandler). These interfaces are data
structures, generated per-case by ChannelMonitor and consumed
blindly by OnchainTxHandler.
2021-05-25 19:54:57 -04:00
Matt Corallo
499d84c165 Merge pull request #920 from TheBlueMatt/2021-05-tlv-ser
Rebroadcast channel_announcements when we broadcast a node_announce
2021-05-25 20:07:07 +00:00
Matt Corallo
bdb2d220e8 Add note in CONTRIBUTING.md that some structs need prefix/suffixes 2021-05-25 20:06:45 +00:00
Matt Corallo
02c57f5940 Rebroadcast channel_announcements when we broadcast a node_announce 2021-05-25 20:06:45 +00:00
Matt Corallo
a87053a16e Process announcement_signatures messages in Channel and store sigs
Previously we handled most of the logic of announcement_signatures
in ChannelManager, rather than Channel. This is somewhat unique as
far as our message processing goes, but it also avoided having to
pass the node_secret in to the Channel.

Eventually, we'll move the node_secret behind the signer anyway, so
there isn't much reason for this, and storing the
announcement_signatures-provided signatures in the Channel allows
us to recreate the channel_announcement later for rebroadcast,
which may be useful.
2021-05-25 20:06:45 +00:00
Matt Corallo
3d1c72e73f Update net graph copy used in tests and bench for new format 2021-05-25 20:06:45 +00:00
Matt Corallo
5b59178f89 Add version and TLV suffix for more user-facing "major" structs 2021-05-25 20:06:45 +00:00
Matt Corallo
8ee7d841b6 Support serializing TLV fields which may or may not be present 2021-05-25 20:06:45 +00:00
Matt Corallo
a515eb3ba6 Append backwards-compat TLVs to serialization of larger structs
Currently our serialization is very compact, and contains version
numbers to indicate which versions the code can read a given
serialized struct. However, if you want to add a new field without
needlessly breaking the ability of previous versions of the code to
read the struct, there is not a good way to do so.

This adds dummy, currently empty, TLVs to the major structs we
serialize out for users, providing an easy place to put new
optional fields without breaking previous versions.
2021-05-25 20:06:45 +00:00
Matt Corallo
f8450a7c2c
Merge pull request #920 from jkczyz/2021-05-event-processing
Background processing of ChannelManager and ChannelMonitor events
2021-05-25 15:55:50 +00:00
Jeffrey Czyz
a1f95de734
Remove event channel from lightning-net-tokio
It is unnecessary since ChannelManager has a notification interface as
of 12c735ab3a.
2021-05-25 00:28:59 -07:00
Jeffrey Czyz
f63fd83fd6
Process ChainMonitor events in the background 2021-05-25 00:28:59 -07:00
Jeffrey Czyz
501b54300c
Process ChannelManager events in the background 2021-05-25 00:28:58 -07:00
Jeffrey Czyz
86ce44677f
f - Persist when check_free_holding_cells has updates 2021-05-25 00:28:58 -07:00
Jeffrey Czyz
248a107e3d
Guard get_and_clear_pending_msg_events 2021-05-24 14:19:56 -07:00
Jeffrey Czyz
282d092bb1
Remove unnecessary scope from ChannelManager 2021-05-24 14:16:16 -07:00
Jeffrey Czyz
7c465d69dc
Refactor EventsProvider to take an EventHandler 2021-05-24 14:16:16 -07:00
Matt Corallo
3a0356fe30
Merge pull request #851 from TheBlueMatt/2021-03-holding-cell-clear-msg-get
Clean up and more liberally free holding cell HTLCs (without re-entrancy)
2021-05-24 21:02:50 +00:00
Matt Corallo
c7e198e6fc
Merge pull request #926 from GeneFerneau/core
Use core replacements for std members
2021-05-24 17:49:54 +00:00