Commit graph

2883 commits

Author SHA1 Message Date
Matt Corallo
423f1b1803
Merge pull request #1064 from lightning-signer/2021-08-closing-tx-phase2 2021-09-09 19:31:47 +00:00
Devrandom
eebc0a921e Use ClosingTransaction in BaseSign 2021-09-09 20:49:24 +02:00
Devrandom
54907a0f4a Introduce ClosingTransaction 2021-09-09 20:49:24 +02:00
Matt Corallo
b3be420cfb
Merge pull request #1047 from TheBlueMatt/2021-08-985-followups 2021-09-09 09:23:08 +00:00
Matt Corallo
623da4da7a Add further comments around fee update handling in channel
These were suggested to clarify behavior in post-merge review of #985.
2021-09-09 08:37:59 +00:00
Matt Corallo
fc35aa745a Update docs for pending_update_fee and holding_cell_update_fee
The docs were left stale after the logic was updated in #985 as
pointed out in post-merge review.
2021-09-09 08:37:59 +00:00
Devrandom
3dd99ebda6 Factor out low-level build_closing_transaction 2021-09-03 13:57:21 +02:00
Matt Corallo
4c4d99b291
Merge pull request #1055 from lightning-signer/2021-08-anchor-tx 2021-09-02 21:54:11 +00:00
Devrandom
8275698f3a Add anchor outputs pair in CommitmentTransaction
The anchor ouputs pair is added if there are pending HTLCs. Or a
a per-party anchor is added if the party has a pending balance.
2021-09-02 09:13:46 +02:00
Matt Corallo
6bd1af4f9f
Merge pull request #1057 from TheBlueMatt/2021-08-invoice-fails
Fix and modernize lightning-invoice API
2021-08-31 22:11:22 +00:00
Matt Corallo
6879348530 Require payment secrets when building and reading invoices 2021-08-31 21:29:51 +00:00
Matt Corallo
a906c498fb Use new BOLT 11 test vectors with payment_secrets and feature flags
This pulls the BOLT 11 test vectors from
https://github.com/lightningnetwork/lightning-rfc/pull/898,
tweaking our tests to properly handle them.
2021-08-31 21:29:51 +00:00
Matt Corallo
c7cf5011be [invoice] Ignore InvalidLength fields
BOLT 11 states that a reader "MUST skip over...`p`, `h`, `s` or `n`
fields that do NOT have data_lengths of 52, 52, 52 or 53,
respectively." Here we do so by simply ignoring any invalid-length
field.
2021-08-31 21:29:51 +00:00
Matt Corallo
75f7af64f3 Implement core:#️⃣:Hash more incl invoice::RawTaggedField 2021-08-31 21:29:51 +00:00
Matt Corallo
a4a54ed9df Check if invoices contain unknown required features
This adds the final missing BOLT 11 failure test, checking for
unknown required feature flags before accepting an invoice.
2021-08-31 21:29:51 +00:00
Matt Corallo
0be428eeda Convert the invoice creation API to millisats and req it for parse
The BOLT 11 invalid invoice test vectors suggest failing to parse
invoices which have an amount which is not a whole number of
millisatoshis. lightning-invoice, however, happily parses such
invoices. While we could continue to parse them, failing them makes
for one less check on the user code side, so we might as well.

In order to keep the invoice creation less likely to fail, we also
switch the Builder amount-setting function to use millisatoshis.
2021-08-31 21:29:51 +00:00
Matt Corallo
181cb1103d [invoice] Fix non-recoverable sig handling and bogus SI prefix err
This adds two additional tests from the BOLT 11 invalid invoice
tests, fixing the two errors that broke them. It fixes a panic on
the "nonrecoverable signature" test and makes the error variant
more sensible on the bogus SI prefix test.
2021-08-31 21:29:51 +00:00
Matt Corallo
a80819c9c2 [invoice] Add the BOLT 11 failure unit tests that we already pass 2021-08-31 21:29:51 +00:00
Matt Corallo
a265f1e97a
Merge pull request #1040 from abhik-99/Issue#945
Multi-Hop Route Hint now considered. Added in unit tests for same.
2021-08-31 17:50:14 +00:00
abhik-99
fd4d3bf3b7 Multi-Hop Route Hint as per Bolt 12 now considered
Bolt 12 details the process of picking up route hints from payee
using the lightning invoice. This PR brings the changes to use
multiple route hints from payee picked from the invoice.

The route hints are processed in the following manner:-
 - `get_route()` receives the hints in `last_hops`.
 - Every `RouteHintHop` in `RouteHint` is processed based on
   feasiblity of channel capacity and fees.
 - If a `RouteHintHop` then preceeding `RouteHintHop`s are not
   processed.
 - A direct route is checked from `first_hops_targets` to the
   first `RouteHintHop` if the respective `RouteHint` is
   processed from the payee's end till the first `RouteHintHop`.

`partial_route_hint_test`, `ignores_empty_last_hops_test`,
`multi_hint_last_hops_test` and `last_hops_with_public_channel_test`
test usage of partial route hints for building optimal route,
processing empty route hint hops, complete usage of private route
hints and presence of public channels in route hints respectively.

Resolves: #945
2021-08-31 11:08:06 +05:30
Matt Corallo
731773cad2
Merge pull request #1039 from lightning-signer/2021-08-more-enforcement
Introduce EnforcementState, validate release of revocation secret
2021-08-30 02:43:01 +00:00
Antoine Riard
97c29cfd34 Add get_anchor_script
This is a script builder to generate anchor output ones. They can be
satisfied either by a signature for the committed funding pubkey or anyone
after CSV delay expiration.

This is used at anchor output addition while generating commitment transaction.
2021-08-28 11:09:42 +02:00
Devrandom
608ed12a5b Allow BaseSign validation functions to return an Err 2021-08-28 11:04:20 +02:00
Devrandom
a016bb1408 Improve documentation for validate_holder_commitment and sign_counterparty_commitment 2021-08-28 11:01:15 +02:00
Devrandom
181d319630 Always use KeysInterface.read_chan_signer for de-serializing EnforcingSigner in tests 2021-08-28 11:01:15 +02:00
Devrandom
285b3faf77 Enforce signing counterparty commitment only after revocation 2021-08-28 11:01:15 +02:00
Devrandom
241e448d37 Enforce that revocation can only occur after we validated a new commitment 2021-08-28 11:01:15 +02:00
Devrandom
50966e25ba Introduce EnforcementState for EnforcingSigner
as we add more enforcement state variables, we want to keep track of them under a single structure
2021-08-28 11:01:15 +02:00
Matt Corallo
4368b56eb6
Merge pull request #1060 from JosephGoulden/function_test_utils_logs
tests: use origin node logger instead of creating new TestLogger
2021-08-27 02:37:00 +00:00
Antoine Riard
ce479b671a Remove DynamicOutputP2WPKH ref in logger 2021-08-27 01:42:52 +00:00
Matt Corallo
45853b3a95
Merge pull request #1031 from p2pderivatives/dlc-version-generic
Dlc version generic
2021-08-25 17:22:20 +00:00
Jeffrey Czyz
eb46f477f4 Remove wire::MessageType in favor of u16
With custom messages, wire::Type was introduced. wire::MessageType is a
bit redundant, so use u16 instead and move is_even to wire::Message.
2021-08-25 13:22:09 +09:00
Tibo-lg
2e5e40e0b2 Add custom message handler to peer manager 2021-08-25 13:22:09 +09:00
Matt Corallo
d523b6e42b
Merge pull request #1037 from sr-gi/add-txid-convert
Adds Txid to lighting-block-sync::convert
2021-08-24 18:57:51 +00:00
Matt Corallo
efa579bc61 Don't initialise Vecs being read with VecReadWrapper explicitly
This simplifies the tlv serialization read macro somewhat by
allowing callsites to simply read into an `Option<Vec>` instead of
needing to read into an `Option<VecReadWrapper>` when using
`vec_type`.
2021-08-24 17:08:41 +00:00
Joseph Goulden
02c95eefd4 tests: use origin node logger instead of creating new TestLogger in functional_test_utils 2021-08-24 16:53:29 +01:00
Sergi Delgado Segura
f65d05c23d
Adds Txid to lighting-block-sync::convert 2021-08-24 10:52:22 +02:00
Matt Corallo
0cff1f7bb4 [invoice] Update doctest example invoices to real LDK invoices
This swaps out our doctest example invoices for real LDK-generated
invoices on a real LDK node.
2021-08-22 22:13:55 +00:00
Matt Corallo
2ced708b71
Merge pull request #1051 from JosephGoulden/fix_ping_disconnect
fix: peer is disconnected for not responding to ping
2021-08-20 18:06:58 +00:00
Joseph Goulden
af4eb23a1c test: increase ping timeout when running in debug mode 2021-08-20 15:48:40 +01:00
Matt Corallo
479ff9018c
Merge pull request #1049 from TheBlueMatt/2021-08-nightly-warnings
Fix trailing semicolon warnings on latest rustc nightly
2021-08-18 19:10:54 +00:00
Matt Corallo
cb7faf8951 Fix trailing semicolon warnings on latest rustc nightly
Latest rustc nightly compiles are filled with warnings like the
following, which we fix here:

```
warning: trailing semicolon in macro used in expression position
   --> lightning/src/util/macro_logger.rs:163:114
    |
163 |         $logger.log(&$crate::util::logger::Record::new($lvl, format_args!($($arg)+), module_path!(), file!(), line!()));
    |                                                                                                                        ^
    |
   ::: lightning/src/chain/chainmonitor.rs:165:9
    |
165 |         log_debug!(self.logger, "New best block {} at height {} provided via block_connected", header.block_hash(), height);
    |         -------------------------------------------------------------------------------------------------------------------- in this macro invocation
    |
    = note: `#[warn(semicolon_in_expressions_from_macros)]` on by default
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #79813 <https://github.com/rust-lang/rust/issues/79813>
    = note: this warning originates in the macro `log_internal` (in Nightly builds, run with -Z macro-backtrace for more info)
```
2021-08-18 00:34:13 +00:00
Matt Corallo
803d8041f1
Merge pull request #1048 from TheBlueMatt/2021-08-no-net-print
Remove explicit print in lightning-net-tokio, reduce redundant block connection logging
2021-08-18 00:31:28 +00:00
Matt Corallo
35d0b7aae7 Clarify docs on ShutdownScript::new_witness_program somewhat
This is especially important for C or other language bindings
clients as the `version` field may be exported as a `u8`.
2021-08-17 21:12:06 +00:00
Matt Corallo
1e7d4798eb Log chain calls in ChainMonitor, reducing logs in ChannelMonitor
For users with many ChannelMonitors, we log a large volume per
block simply because each ChannelMonitor lots several times per
block. Instead, we move to log only once at the TRACE level per
block call in ChannelMonitors, relying instead on a DEBUG level
log in ChainMonitor before we call any ChannelMonitor functions.

For most users, this will reduce redundant logging and also log at
the DEBUG level for block events, which is appropriate.

Fixes #980.
2021-08-17 21:03:14 +00:00
Matt Corallo
ecf1d656ef Stop printing to stderr in lightning-net-tokio for disconnections
It isn't exactly a critical error situation when we disconnect a
socket, so we shouldn't be printing to stderr, entirely bypassing
user logging, when it happens. We do still print to stderr if we
fail to write the first message to the socket, but this should
never happen unless the user has a reasonably-configured system
with at least one packet in bytes available for the socket buffer.
2021-08-17 21:03:14 +00:00
Matt Corallo
2e02aa7dab Ensure we always at least log at TRACE when a peer disconnects 2021-08-17 21:03:14 +00:00
Matt Corallo
aacb7fb363
Merge pull request #1044 from TheBlueMatt/0.0.100
Cut 0.0.100
2021-08-17 18:55:26 +00:00
Matt Corallo
11f78798d3 Update versions to 0.0.100 and lightning-invoice to 0.8 2021-08-17 18:55:07 +00:00
Matt Corallo
547dfb5f5c Update CHANGELOG for 0.0.100 2021-08-17 18:55:07 +00:00