Matt Corallo [Thu, 6 May 2021 21:08:08 +0000 (21:08 +0000)]
Merge pull request #914 from TheBlueMatt/2021-05-log-txids
Always log_info when we broadcast a transaction, including the txid
Matt Corallo [Thu, 6 May 2021 16:21:44 +0000 (16:21 +0000)]
Always log_info when we broadcast a transaction, including the txid
Matt Corallo [Thu, 6 May 2021 01:25:44 +0000 (01:25 +0000)]
Merge pull request #910 from TheBlueMatt/2021-05-sort-addrs
By default sort network addrs before inclusion in node_announcements
Matt Corallo [Wed, 5 May 2021 00:19:11 +0000 (00:19 +0000)]
By default sort network addrs before inclusion in node_announcements
In #797, we stopped enforcing that read/sent node_announcements
had their addresses sorted. While this is fine in practice, we
should still make a best-effort to sort them to comply with the
spec's forward-compatibility requirements, which we do here in the
ChannelManager.
Matt Corallo [Tue, 4 May 2021 02:14:03 +0000 (02:14 +0000)]
Merge pull request #909 from TheBlueMatt/2021-04-0.0.14
Bump versions to 0.0.14, lightning-invoice 0.5
Matt Corallo [Tue, 4 May 2021 02:00:52 +0000 (02:00 +0000)]
Merge pull request #901 from jkczyz/2021-04-invoice-feature-semantics
Hide InvoiceFeatures behind InvoiceBuilder API
Matt Corallo [Tue, 4 May 2021 01:44:18 +0000 (01:44 +0000)]
Merge pull request #845 from ariard/2021-03-hardcode-dust
Switch to a max counterparty's `dust_limit_satoshis` constant
Jeffrey Czyz [Fri, 30 Apr 2021 21:30:58 +0000 (14:30 -0700)]
Test feature bit semantics in Invoice::from_signed
Jeffrey Czyz [Fri, 30 Apr 2021 20:11:34 +0000 (13:11 -0700)]
Test feature bits in InvoiceBuilder
Jeffrey Czyz [Wed, 28 Apr 2021 16:29:23 +0000 (09:29 -0700)]
Add basic_mpp support to InvoiceBuilder
Since InvoiceFeatures are an implementation detail of InvoiceBuilder, an
explicit call is needed to support the basic_mpp feature. Since it is
dependent on the payment_secret feature, conditionally define the
builder's method only when payment_secret has been set.
Jeffrey Czyz [Wed, 28 Apr 2021 16:22:02 +0000 (09:22 -0700)]
Hide InvoiceFeatures behind InvoiceBuilder API
Instead of relying on users to set an invoice's features correctly,
enforce the semantics inside InvoiceBuilder. For instance, if the user
sets a PaymentSecret then InvoiceBuilder should ensure the appropriate
feature bits are set. Thus, for this example, the TaggedField
abstraction can be retained while still ensuring BOLT 11 semantics at
the builder abstraction.
Matt Corallo [Mon, 3 May 2021 23:03:00 +0000 (23:03 +0000)]
Make third HTLC non-dust again in the full_stack_target demo seed
Antoine Riard [Wed, 8 Apr 2020 01:51:50 +0000 (21:51 -0400)]
Add bolt2_open_channel_sane_dust_limit
Antoine Riard [Tue, 16 Mar 2021 22:07:22 +0000 (18:07 -0400)]
Replace config max counterpary `dust_limit_satoshis` by a constant.
Current Bitcoin Core's policy will reject a p2wsh as a dust if it's
under 330 satoshis. A typical p2wsh output is 43 bytes big to which
Core's `GetDustThreshold()` sums up a minimal spend of 67 bytes (even
if a p2wsh witnessScript might be smaller). `dustRelayFee` is set
to 3000 sat/kb, thus 110 * 3000 / 1000 = 330. As all time-sensitive
outputs are p2wsh, a value of 330 sat is the lower bound desired
to ensure good propagation of transactions. We give a bit margin to
our counterparty and pick up 660 satoshis as an accepted
`dust_limit_satoshis` upper bound.
As this reasoning is tricky and error-prone we hardcode it instead of
letting the user picking up a non-sense value.
Further, this lower bound of 330 sats is also hardcoded as another constant
(MIN_DUST_LIMIT_SATOSHIS) instead of being dynamically computed on
feerate (derive_holder_dust_limit_satoshis`). Reducing risks of
non-propagating transactions in casee of failing fee festimation.
Matt Corallo [Sat, 1 May 2021 00:50:25 +0000 (00:50 +0000)]
Merge pull request #908 from TheBlueMatt/2021-04-invoice-real-bindings
Minor Tweaks to lightning-invoice for C bindings
Matt Corallo [Sat, 1 May 2021 00:43:15 +0000 (00:43 +0000)]
Bump versions to 0.0.14, lightning-invoice 0.5
Matt Corallo [Fri, 30 Apr 2021 23:16:33 +0000 (23:16 +0000)]
Add a not-exported tag to the Display implementation for RawHrp
RawHrp is already not-exported, so implementations for it should be
as well.
Matt Corallo [Fri, 30 Apr 2021 04:19:51 +0000 (04:19 +0000)]
Use explicit import lists instead of glob imports in invoice
While this is less readable, I spent way too long trying to adapt
the bindings generation code to handle glob imports and concluded
it would take refactoring almost the entire import-resolution
logic. While this may be a good refactor to do eventually, its
probably not worth it today.
Jeffrey Czyz [Fri, 30 Apr 2021 16:58:07 +0000 (09:58 -0700)]
Sanity test InvoiceFeatures
Jeffrey Czyz [Fri, 30 Apr 2021 16:41:46 +0000 (09:41 -0700)]
Require feature var_onion_optin
Feature payment_secret is required and depends on var_onion_optin, so
the latter must also be required.
Matt Corallo [Thu, 29 Apr 2021 16:41:23 +0000 (16:41 +0000)]
Skip TaggedField for now as `enum { A(A) }` is broken in Java
... due to A and A aliasing each other.
Matt Corallo [Fri, 30 Apr 2021 18:45:51 +0000 (18:45 +0000)]
Set default error type for SignOrCreationError for bindings
The C bindings generator now looks to default generic types as the
way to map a struct or enum parameter. Because SignOrCreationError
is only used directly with an error type of `()`, we set that to
the default and assume no other error types are needed.
Matt Corallo [Fri, 30 Apr 2021 19:00:35 +0000 (19:00 +0000)]
Merge pull request #907 from TheBlueMatt/2021-04-merge-conflicts
Fix merge conflicts between #898 and #895.
Matt Corallo [Fri, 30 Apr 2021 17:33:05 +0000 (17:33 +0000)]
Deny broken doc links in lightning-invoice as well
Matt Corallo [Fri, 30 Apr 2021 17:32:36 +0000 (17:32 +0000)]
Fix merge conflicts between #898 and #895.
Matt Corallo [Fri, 30 Apr 2021 17:25:59 +0000 (17:25 +0000)]
Merge pull request #898 from jkczyz/2021-04-invoice-expiry
Require min_final_cltv_expiry in invoices
Matt Corallo [Thu, 29 Apr 2021 23:55:37 +0000 (23:55 +0000)]
Merge pull request #895 from valentinewallace/invoice-chanman-utility
Invoice chanman utility
Valentine Wallace [Fri, 23 Apr 2021 22:17:52 +0000 (18:17 -0400)]
Add utility to create an invoice using the ChannelManager
This also allows the ChannelManager to track information for inbound payments
to check the PaymentSecret on receive.
Valentine Wallace [Thu, 29 Apr 2021 16:19:05 +0000 (12:19 -0400)]
Move invoice signing behind KeysInterface
Valentine Wallace [Wed, 28 Apr 2021 21:28:10 +0000 (17:28 -0400)]
Move PaymentPreimage+PaymentHash+PaymentSecret to top-level ln module
Valentine Wallace [Wed, 28 Apr 2021 20:23:39 +0000 (16:23 -0400)]
Make _test_utils depend on bitcoinconsensus feature
Valentine Wallace [Wed, 21 Apr 2021 21:53:00 +0000 (17:53 -0400)]
invoice: swap PaymentSecret for ChannelManager's PaymentSecret
Matt Corallo [Thu, 29 Apr 2021 22:26:12 +0000 (22:26 +0000)]
Merge pull request #905 from TheBlueMatt/2021-04-mention-invoice-storage-docs
Mention storage req for users with a public invoice generation API
Matt Corallo [Thu, 29 Apr 2021 19:31:35 +0000 (19:31 +0000)]
Mention storage req for users with a public invoice generation API
Matt Corallo [Thu, 29 Apr 2021 22:02:01 +0000 (22:02 +0000)]
Merge pull request #904 from lightning-signer/no-send-sync
Remove Send and Sync from core crate
Jeffrey Czyz [Mon, 26 Apr 2021 21:24:36 +0000 (14:24 -0700)]
Test default invoice field values
Jeffrey Czyz [Mon, 26 Apr 2021 20:08:19 +0000 (13:08 -0700)]
Require min_final_cltv_expiry in invoice
Jeffrey Czyz [Mon, 26 Apr 2021 18:59:56 +0000 (11:59 -0700)]
Use default for invoice's min_final_cltv_expiry
Jeffrey Czyz [Sat, 24 Apr 2021 00:30:07 +0000 (17:30 -0700)]
Use constant for invoice's default expiry value
Devrandom [Thu, 29 Apr 2021 19:07:28 +0000 (21:07 +0200)]
Remove Send and Sync from core crate
Matt Corallo [Thu, 29 Apr 2021 18:57:37 +0000 (18:57 +0000)]
Merge pull request #903 from TheBlueMatt/2021-04-invoice-bindings
Prepare lightning-invoice for export in C
Matt Corallo [Thu, 29 Apr 2021 16:46:20 +0000 (16:46 +0000)]
Drop redundant generic parameter bounds on ChainMonitor trait impls
The ChannelSigner bounds are specified both in `impl<>` and in the
`where` clause, which the C bindings generator doesn't like. There
is no reason to have them specified twice.
Matt Corallo [Fri, 16 Apr 2021 22:32:49 +0000 (22:32 +0000)]
Add no-export tags for lightning-invoice where we can't map to C
Matt Corallo [Thu, 29 Apr 2021 15:47:08 +0000 (15:47 +0000)]
Rename lightning_invoice::Signature to InvoiceSignature
This prevents aliasing the global secp256k1::Signature name in C
bindings and also makes it a little more explicit that the object
is different from other signature types.
Matt Corallo [Fri, 23 Apr 2021 00:25:55 +0000 (00:25 +0000)]
Do not return a reference to a u64 in rust-lightning-invoices
There is generally never a reason to return a non-mutable reference
to a u64 vs just copying it, same applies here. It makes the API
slightly less consistent, but is easier to map in bindings and just
makes more sense.
Matt Corallo [Thu, 29 Apr 2021 00:26:13 +0000 (00:26 +0000)]
Merge pull request #900 from lightning-signer/init-asap
Send Init message immediately after handshake even if not initiator
Matt Corallo [Thu, 29 Apr 2021 00:24:40 +0000 (00:24 +0000)]
Merge pull request #902 from TheBlueMatt/2021-04-fix-fuzz-test
Fix fuzz secp patch by bumping the rust-secp version number in patch
Matt Corallo [Wed, 28 Apr 2021 19:59:33 +0000 (19:59 +0000)]
Merge pull request #893 from TheBlueMatt/2021-04-features-chanman
Require payment secrets and track them in ChannelManager
Matt Corallo [Tue, 27 Apr 2021 16:06:00 +0000 (16:06 +0000)]
Add a const and docs for the min `min_final_cltv_expiry` we allow
Matt Corallo [Wed, 28 Apr 2021 18:59:54 +0000 (14:59 -0400)]
Add some simple tests of payment secret tracking
Matt Corallo [Fri, 23 Apr 2021 23:56:58 +0000 (23:56 +0000)]
Fail PendingInboundPayments after their expiry time is reached
Matt Corallo [Fri, 23 Apr 2021 22:24:47 +0000 (22:24 +0000)]
Give users who use `get_payment_secret_preimage` the PaymentPreimage
For users who get PaymentPreimages via
`get_payment_secret_preimage`, they need to provide the
PaymentPreimage back in `claim_funds` but they aren't actually
given the preimage anywhere.
This commit gives users the PaymentPreimage in the
`PaymentReceived` event.
Matt Corallo [Fri, 23 Apr 2021 16:53:53 +0000 (16:53 +0000)]
Make the PaymentSecret in `PaymentReceived` events non-Optional
Matt Corallo [Mon, 26 Apr 2021 23:05:56 +0000 (23:05 +0000)]
Drop the amount parameter to claim_funds
Like the payment_secret parameter, this paramter has been the source
of much confusion, so we just drop it.
Users should prefer to do this check when registering the payment
secret instead of at claim-time.
Matt Corallo [Fri, 23 Apr 2021 03:00:44 +0000 (03:00 +0000)]
Drop now-useless PaymentSecret parameters when claiming/failing-back
Matt Corallo [Tue, 27 Apr 2021 01:29:39 +0000 (01:29 +0000)]
Add a `user_payment_id` to `get_payment_secret`+`PaymentReceived`
This allows users to store metadata about an invoice at
invoice-generation time and then index into that storage with a
general-purpose id when they call `get_payment_secret`. They will
then be provided the same index when the payment has been received.
Matt Corallo [Fri, 23 Apr 2021 04:08:41 +0000 (04:08 +0000)]
Drop dead code for handling non-MPP payments in claim_funds
Matt Corallo [Fri, 23 Apr 2021 19:04:02 +0000 (19:04 +0000)]
[fuzz] Always use PaymentSecrets in chanmon_consistency
Matt Corallo [Fri, 23 Apr 2021 04:04:55 +0000 (04:04 +0000)]
Req+check payment secrets for inbound payments pre-PaymentReceived
Our current PaymentReceived API is incredibly easy to mis-use -
the "obvious" way to implement a client is to always call
`ChannelManager::claim_funds` in response to a `PaymentReceived`
event. However, users are *required* to check the payment secret
and value against the expected values before claiming in order to
avoid a number of potentially funds-losing attacks.
Instead, if we rely on payment secrets being pre-registered with
the ChannelManager before we receive HTLCs for a payment we can
simply check the payment secrets and never generate
`PaymentReceived` events if they do not match. Further, when the
user knows the value to expect in advance, we can have them
register it as well, allowing us to check it for them.
Other implementations already require payment secrets for inbound
payments, so this shouldn't materially lose compatibility.
Matt Corallo [Fri, 23 Apr 2021 03:19:52 +0000 (03:19 +0000)]
Use payment_secrets in all sends in functional tests
This prepares us for requiring payment_secrets for all received
payments, by demonstrating test changes work even prior to the new
requirement.
In order to avoid needing to pipe payment secrets through to
additional places in the claim logic and then removing that
infrastructure once payment secrets are required, we use the new
payment secret storage in ChannelManager to look up the payment
secret for any given pament hash in claim and fail-back functions.
This part of the diff is reverted in the next commit.
Matt Corallo [Fri, 23 Apr 2021 03:15:37 +0000 (03:15 +0000)]
Use known InvoiceFeatures for routing in tests
Matt Corallo [Thu, 22 Apr 2021 22:45:14 +0000 (22:45 +0000)]
Pipe through PaymentSecrets in tests during payment hash creation
In order to reduce code movement in the next commit, this commit
simply tweaks get_payment_preimage_hash!() and related functions in
functional tests to return a payment secret. Further, we ensure
that we always call get_payment_preimage_hash!() with the node
which will ultimately receive the payment.
Matt Corallo [Thu, 22 Apr 2021 19:13:14 +0000 (19:13 +0000)]
DRY the get_route_and_payment_hash!() macro duplicated in tests
Matt Corallo [Thu, 22 Apr 2021 18:35:01 +0000 (18:35 +0000)]
Add payment secret and preimage tracking in ChannelManager
This adds support for tracking payment secrets and (optionally)
payment preimages in ChannelManager. This potentially makes client
implementations much simper as they don't have to have external
payment preimage tracking.
This doesn't yet use such tracking anywhere.
Matt Corallo [Wed, 28 Apr 2021 19:17:59 +0000 (15:17 -0400)]
Fix fuzz secp patch by bumping the rust-secp version number in patch
Devrandom [Wed, 28 Apr 2021 13:22:34 +0000 (15:22 +0200)]
Send Init message immediately after handshake even if not initiator
We were waiting for the initiator, but the spec doesn't guarantee that they will send Init first, so we might theoretically wait forever.
Also, lnprototest expects this behavior.
Matt Corallo [Thu, 22 Apr 2021 18:54:53 +0000 (18:54 +0000)]
Set payment_secret to required in features flags
Matt Corallo [Tue, 27 Apr 2021 02:05:29 +0000 (02:05 +0000)]
Merge pull request #854 from TheBlueMatt/2021-03-fix-lens
Fix serialization expected lengths and check them in test/fuzzing
Matt Corallo [Wed, 24 Mar 2021 18:31:03 +0000 (14:31 -0400)]
Use more descriptive names in serialization impl macros
Matt Corallo [Mon, 22 Mar 2021 22:27:34 +0000 (18:27 -0400)]
Fix serialization expected lengths and check them in test/fuzzing
Matt Corallo [Tue, 27 Apr 2021 01:06:11 +0000 (01:06 +0000)]
Merge pull request #897 from TheBlueMatt/2021-04-fix-ci
Bump MSRV to 1.36
Matt Corallo [Mon, 26 Apr 2021 17:48:57 +0000 (17:48 +0000)]
Test lightning-persister on rustc 1.36 as well
Matt Corallo [Mon, 26 Apr 2021 17:47:47 +0000 (17:47 +0000)]
Bump MSRV to 1.36.0
Debian is shipping 1.41 on oldstable and rust-bitcoin will likely
move to 1.36 over the coming months, so there's little reason to
wait on this.
cc https://github.com/rust-bitcoin/rust-bitcoin/issues/510
Matt Corallo [Mon, 26 Apr 2021 19:59:32 +0000 (19:59 +0000)]
Merge pull request #894 from TheBlueMatt/2021-04-fix-docs
Fix doc resolution in rustc 1.48
Matt Corallo [Mon, 26 Apr 2021 18:00:33 +0000 (18:00 +0000)]
Merge pull request #876 from valentinewallace/invoice-features
Invoice features
Valentine Wallace [Fri, 16 Apr 2021 19:29:33 +0000 (15:29 -0400)]
Add Features feature to invoices.
Matt Corallo [Sat, 24 Apr 2021 00:03:42 +0000 (00:03 +0000)]
Merge pull request #890 from TheBlueMatt/2021-04-fix-chan-shutdown-crash
Fix (and test) panic when our counterparty uses a bogus funding tx
Matt Corallo [Wed, 21 Apr 2021 00:11:54 +0000 (00:11 +0000)]
Fix (and test) panic when our counterparty uses a bogus funding tx
During the block API refactor, we started calling
Channel::force_shutdown when a channel is closed due to a bogus
funding tx. However, we still set the channel's state to Shutdown
prior to doing so, leading to an assertion in force_shutdown (that
the channel is not already closed).
This removes the state-set call and adds a (long-overdue) test for
this case.
Fixes: 60b962a18ebcf494340ddc001870f8160c625968
Valentine Wallace [Fri, 16 Apr 2021 19:26:38 +0000 (15:26 -0400)]
Expose Features::from_le_bytes() method
Useful for constructing features objects from raw feature bytes.
Valentine Wallace [Tue, 13 Apr 2021 14:34:33 +0000 (10:34 -0400)]
Fix indentation in payment_secret function
Matt Corallo [Fri, 23 Apr 2021 20:42:11 +0000 (20:42 +0000)]
Fix doc resolution in rustc 1.48
Matt Corallo [Fri, 23 Apr 2021 19:13:23 +0000 (19:13 +0000)]
Merge pull request #889 from jkczyz/2021-04-electrum-trait
Define chain::Confirm trait for use by Electrum clients
Jeffrey Czyz [Thu, 22 Apr 2021 16:52:10 +0000 (09:52 -0700)]
Drop pub functions for ChainMonitor's Listen impl
Jeffrey Czyz [Thu, 22 Apr 2021 07:11:00 +0000 (00:11 -0700)]
Implement chain::Confirm for ChainMonitor
Jeffrey Czyz [Tue, 20 Apr 2021 20:39:00 +0000 (13:39 -0700)]
Implement chain::Confirm for relevant structs
Jeffrey Czyz [Tue, 20 Apr 2021 17:24:08 +0000 (10:24 -0700)]
Define chain::Confirm trait
Define a separate trait akin to chain::Listen for notifying when
transactions have been confirmed on chain or unconfirmed during a chain
reorganization. Whereas chain::Listen is used for block-oriented chain
sources, chain::Confirm is used for chain sources supplying data for
activity related to transactions and outputs registered via
chain::Filter.
Matt Corallo [Thu, 22 Apr 2021 14:16:05 +0000 (14:16 +0000)]
Merge pull request #891 from TheBlueMatt/2021-04-peer_handler_lock
[peer_handler] Take the peers lock before getting messages to send
Matt Corallo [Wed, 21 Apr 2021 21:50:41 +0000 (21:50 +0000)]
[peer_handler] Take the peers lock before getting messages to send
Previously, if a user simultaneously called
`PeerHandler::process_events()` from two threads, we'd race, which
ended up sending messages out-of-order in the real world.
Specifically, we first called `get_and_clear_pending_msg_events`,
then take the `peers` lock and push the messages we got into the
sending queue. Two threads may both get some set of messages to
send, but then race each other into the `peers` lock and send the
messages in random order.
Because we already hold the `peers` lock when calling most message
handler functions, we can simply take the lock before calling
`get_and_clear_pending_msg_events`, solving the race.
Matt Corallo [Wed, 21 Apr 2021 15:21:39 +0000 (15:21 +0000)]
Merge pull request #887 from valentinewallace/invoice-use-RL-routehint
invoice: swap RouteHop for RouteHint
Valentine Wallace [Tue, 20 Apr 2021 19:46:58 +0000 (15:46 -0400)]
Test lightning-invoice on 1.30.0
Valentine Wallace [Mon, 19 Apr 2021 22:22:21 +0000 (18:22 -0400)]
invoice: rename Route to RouteHint (which is more accurate)
Valentine Wallace [Mon, 19 Apr 2021 22:12:51 +0000 (18:12 -0400)]
Rename RouteHint to RouteHintHop (which is more accurate)
Valentine Wallace [Fri, 16 Apr 2021 20:17:11 +0000 (16:17 -0400)]
invoice: swap RouteHop for RouteHint
To prevent naming conflicts in bindings
Matt Corallo [Tue, 20 Apr 2021 00:45:30 +0000 (00:45 +0000)]
Merge pull request #844 from sr-gi/843-ln-signing
Adds lightning message signing/verification/pk_recovery
Sergi Delgado Segura [Wed, 31 Mar 2021 09:38:31 +0000 (11:38 +0200)]
Changes zbase32 crate from pub to pub(crate)
Matt Corallo [Mon, 22 Mar 2021 16:22:24 +0000 (12:22 -0400)]
Correct license header in zbase32 to match original work
The original work is licensed dual MIT+Apache-2 just like us, so
the license header should not only mention MIT.
Matt Corallo [Mon, 22 Mar 2021 16:20:26 +0000 (12:20 -0400)]
Replace spaces with tabs in zbase32.rs
Matt Corallo [Mon, 22 Mar 2021 16:19:28 +0000 (12:19 -0400)]
Fix a number of bugs in zbase32 and add a fuzzer which caught them.
Sergi Delgado Segura [Tue, 16 Mar 2021 14:55:44 +0000 (15:55 +0100)]
Adds lightning message signing/verification/pk_recovery
Matt Corallo [Thu, 15 Apr 2021 21:55:53 +0000 (21:55 +0000)]
Merge pull request #886 from TheBlueMatt/2021-04-pub-alias
Make the used-in-pub-interfaces TransactionOutputs type alias pub