]> git.bitcoin.ninja Git - rust-lightning/log
rust-lightning
3 years agoAppend backwards-compat TLVs to serialization of larger structs
Matt Corallo [Wed, 5 May 2021 22:56:42 +0000 (22:56 +0000)]
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.

3 years agoMerge pull request #926 from GeneFerneau/core
Matt Corallo [Mon, 24 May 2021 17:49:54 +0000 (17:49 +0000)]
Merge pull request #926 from GeneFerneau/core

Use core replacements for std members

3 years agoUse core replacements for std members
Gene Ferneau [Sun, 23 May 2021 23:22:46 +0000 (23:22 +0000)]
Use core replacements for std members

In preparation for no_std build support, replace std structs and
functions with core equivalents

3 years agoMerge pull request #918 from TheBlueMatt/2021-05-dup-claims
Matt Corallo [Thu, 20 May 2021 17:10:52 +0000 (17:10 +0000)]
Merge pull request #918 from TheBlueMatt/2021-05-dup-claims

Make payments not duplicatively fail/succeed on reload/reconnect

3 years ago[fuzz] Make get_secure_random_bytes in chanmon_consistency unique 2021-05-dup-claims
Matt Corallo [Thu, 20 May 2021 16:38:18 +0000 (16:38 +0000)]
[fuzz] Make get_secure_random_bytes in chanmon_consistency unique

3 years agoTest pending payments when resolved duplicatively via reconnect
Matt Corallo [Sun, 9 May 2021 17:53:55 +0000 (17:53 +0000)]
Test pending payments when resolved duplicatively via reconnect

3 years agoTest pending payments when duplicatively resolved on chain
Matt Corallo [Sat, 8 May 2021 22:54:26 +0000 (22:54 +0000)]
Test pending payments when duplicatively resolved on chain

3 years agoMake payments not duplicatively fail/succeed on reload/reconnect
Matt Corallo [Sun, 9 May 2021 19:19:11 +0000 (19:19 +0000)]
Make payments not duplicatively fail/succeed on reload/reconnect

We currently generate duplicative PaymentFailed/PaymentSent events
in two cases:

a) If we receive a update_fulfill_htlc message, followed by a
   disconnect, then a resend of the same update_fulfill_htlc
   message, we will generate a PaymentSent event for each message.

b) When a Channel is closed, any outbound HTLCs which were relayed
   through it are simply dropped when the Channel is. From there,
   the ChannelManager relies on the ChannelMonitor having a copy of
   the relevant fail-/claim-back data and processes the HTLC
   fail/claim when the ChannelMonitor tells it to.

   If, due to an on-chain event, an HTLC is failed/claimed, and
   then we serialize the ChannelManager, but do not re-serialize
   the relevant ChannelMonitor, we may end up getting a duplicative
   event.

In order to provide the expected consistency, we add explicit
tracking of pending outbound payments using their unique
session_priv field which is generated when the payment is sent.
Then, before generating PaymentFailed/PaymentSent events, we check
that the session_priv for the payment is still pending.

Thix fixes #209.

3 years agoMerge pull request #925 from valentinewallace/ignore-zlib-compressed-msgs
Matt Corallo [Thu, 20 May 2021 16:26:49 +0000 (16:26 +0000)]
Merge pull request #925 from valentinewallace/ignore-zlib-compressed-msgs

Ignore messages with zlib-compressed fields

3 years agoReturn new DecodeError::UnsupportedCompression
Valentine Wallace [Wed, 19 May 2021 19:15:41 +0000 (15:15 -0400)]
Return new DecodeError::UnsupportedCompression

if we receive a message with zlib-compressed values.

3 years agoAdd new DecodeError for messages that include zlib-compressed values
Valentine Wallace [Wed, 19 May 2021 18:05:03 +0000 (14:05 -0400)]
Add new DecodeError for messages that include zlib-compressed values

No need to disconnect peers if this error is encountered. It just means
we can't use some of their gossip messages.

3 years agoMerge pull request #923 from ariard/2021-05-split-sign-justice
Matt Corallo [Tue, 18 May 2021 15:24:57 +0000 (15:24 +0000)]
Merge pull request #923 from ariard/2021-05-split-sign-justice

Split `sign_justice_transaction` in two halves

3 years agokeysinterface: replace Result match with map_err
Antoine Riard [Mon, 17 May 2021 18:22:12 +0000 (14:22 -0400)]
keysinterface: replace Result match with map_err

3 years agoSplit `sign_justice_transaction` in two halves
Antoine Riard [Sat, 15 May 2021 21:20:10 +0000 (17:20 -0400)]
Split `sign_justice_transaction` in two halves

To avoid caller data struct storing HTLC-related information when
a revokeable output is claimed on top of a commitment/second-stage
HTLC transactions, we split `keysinterface::sign_justice_transaction`
in two new halves `keysinterfaces::sign_justice_revoked_output` and
`keysinterfaces::sign_justice_revoked_htlc`.

Further, this split offers more flexibility to signer policy as a
commitment revokeable output might be of a value far more significant
than HTLC ones.

3 years agoMerge pull request #916 from TheBlueMatt/2021-05-fix-disabled-announcements
Matt Corallo [Sat, 15 May 2021 00:44:40 +0000 (00:44 +0000)]
Merge pull request #916 from TheBlueMatt/2021-05-fix-disabled-announcements

Avoid persisting a ChannelManager after each timer tick and send update_channel re-enable messages

3 years agoSimplify+expand per-channel check in test_announce_disable_channels 2021-05-fix-disabled-announcements
Matt Corallo [Thu, 13 May 2021 15:41:05 +0000 (15:41 +0000)]
Simplify+expand per-channel check in test_announce_disable_channels

3 years agoRename Channel::UpdateStatus to be more descriptive and update docs
Matt Corallo [Thu, 13 May 2021 15:33:54 +0000 (15:33 +0000)]
Rename Channel::UpdateStatus to be more descriptive and update docs

3 years agoDo not wait in PersistenceNotifier when the persist flag is set
Matt Corallo [Fri, 7 May 2021 22:17:29 +0000 (22:17 +0000)]
Do not wait in PersistenceNotifier when the persist flag is set

When we had a event which caused us to set the persist flag in a
PersistenceNotifier in between wait calls, we will still wait,
potentially not persisting a ChannelManager when we should.

Worse, for wait_timeout, this caused us to always wait up to the
timeout, but then always return true that a persistence is needed.

Instead, we simply check the persist flag before waiting, returning
immediately if it is set.

3 years agoAvoid persisting a ChannelManager update after each timer tick
Matt Corallo [Fri, 7 May 2021 22:16:47 +0000 (22:16 +0000)]
Avoid persisting a ChannelManager update after each timer tick

Currently, when a user calls `ChannelManager::timer_tick_occurred`
we always set the persister's update flag to true. This results in
a ChannelManager persistence after each timer tick, even when
nothing happened.

Instead, we add a new flag to `PersistenceNotifierGuard` to
indicate if we should skip setting the update flag.

3 years agoTest new channel_update re-enabled announcements
Matt Corallo [Sat, 8 May 2021 21:20:02 +0000 (21:20 +0000)]
Test new channel_update re-enabled announcements

3 years agoMerge pull request #922 from valentinewallace/update-default-expiry
Matt Corallo [Fri, 14 May 2021 22:31:34 +0000 (22:31 +0000)]
Merge pull request #922 from valentinewallace/update-default-expiry

Correct default invoice expiry

3 years agoCorrect default expiry.
Valentine Wallace [Fri, 14 May 2021 14:06:17 +0000 (10:06 -0400)]
Correct default expiry.

We previously stated in the codebase that the default invoice expiry
stated in the spec is 2 hours. It's actually 1 hour.

3 years agoMerge pull request #921 from TheBlueMatt/2021-05-no-control-chars
Matt Corallo [Fri, 14 May 2021 01:44:07 +0000 (01:44 +0000)]
Merge pull request #921 from TheBlueMatt/2021-05-no-control-chars

Don't return ASCII control characters in HTTP error messages

3 years agoDon't return ASCII control characters in HTTP error messages 2021-05-no-control-chars
Matt Corallo [Thu, 13 May 2021 19:34:17 +0000 (19:34 +0000)]
Don't return ASCII control characters in HTTP error messages

3 years agoSend update_channel messages to re-enable a disabled channel
Matt Corallo [Fri, 7 May 2021 20:56:10 +0000 (20:56 +0000)]
Send update_channel messages to re-enable a disabled channel

Currently, we only send an update_channel message after
disconnecting a peer and waiting some time. We do not send a
followup when the peer has been reconnected for some time.

This changes that behavior to make the disconnect and reconnect
channel updates symmetric, and also simplifies the state machine
somewhat to make it more clear.

Finally, it serializes the current announcement state so that we
usually know when we need to send a new update_channel.

3 years agoMerge pull request #919 from valentinewallace/http-error-msgs
Matt Corallo [Thu, 13 May 2021 19:25:47 +0000 (19:25 +0000)]
Merge pull request #919 from valentinewallace/http-error-msgs

Return more error details on http's read_response

3 years agoReturn more error details on http's read_response
Valentine Wallace [Tue, 11 May 2021 23:59:55 +0000 (19:59 -0400)]
Return more error details on http's read_response

Otherwise helpful error information gets swallowed

3 years agoMerge pull request #915 from TheBlueMatt/2021-05-bump-rpc-timeout
Matt Corallo [Mon, 10 May 2021 18:04:28 +0000 (18:04 +0000)]
Merge pull request #915 from TheBlueMatt/2021-05-bump-rpc-timeout

Increase the timeout for RPC responses from Bitcoin Core

3 years agoIncrease the timeout for RPC responses from Bitcoin Core 2021-05-bump-rpc-timeout
Matt Corallo [Thu, 6 May 2021 20:42:02 +0000 (20:42 +0000)]
Increase the timeout for RPC responses from Bitcoin Core

Early sample testing showed multiple users hitting
EWOULDBLOCK/EAGAIN waiting for an initial response from Bitcoin
Core while it was doing some long operation (eg UTXO cache
flushing). Instead of only waiting 5 seconds for each attempt, we
now wait a full two minutes, but only for the first header
response, not each byte.

3 years agoAllow retrying HTTP requests if we hit a socket timeout
Matt Corallo [Fri, 7 May 2021 22:40:22 +0000 (22:40 +0000)]
Allow retrying HTTP requests if we hit a socket timeout

3 years agoMerge pull request #912 from TheBlueMatt/2021-05-more-chan-info
Matt Corallo [Fri, 7 May 2021 15:19:44 +0000 (15:19 +0000)]
Merge pull request #912 from TheBlueMatt/2021-05-more-chan-info

Add flags for if a channel is pub and funding txo in ChannelDetails

3 years agoMerge pull request #911 from TheBlueMatt/2021-05-fix-cltv-diff
Matt Corallo [Thu, 6 May 2021 21:49:24 +0000 (21:49 +0000)]
Merge pull request #911 from TheBlueMatt/2021-05-fix-cltv-diff

3 years agoMerge pull request #914 from TheBlueMatt/2021-05-log-txids
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

3 years agoRename ChannelDetails::is_live to is_usable 2021-05-more-chan-info
Matt Corallo [Thu, 6 May 2021 20:26:39 +0000 (20:26 +0000)]
Rename ChannelDetails::is_live to is_usable

This matches is_usable_channels and slightly better captures the
meaning.

3 years agoIndiciate if a channel is outbound/confirmed in ChannelDetails
Matt Corallo [Wed, 5 May 2021 16:15:11 +0000 (16:15 +0000)]
Indiciate if a channel is outbound/confirmed in ChannelDetails

3 years agoAdd flags for if a channel is pub and funding txo in ChannelDetails
Matt Corallo [Wed, 5 May 2021 02:33:29 +0000 (02:33 +0000)]
Add flags for if a channel is pub and funding txo in ChannelDetails

3 years agoAlways log_info when we broadcast a transaction, including the txid 2021-05-log-txids
Matt Corallo [Thu, 6 May 2021 16:21:44 +0000 (16:21 +0000)]
Always log_info when we broadcast a transaction, including the txid

3 years agoClarify comment on CHECK_CLTV_EXPIRE_SANITY_2 somewhat 2021-05-fix-cltv-diff
Matt Corallo [Thu, 6 May 2021 15:34:51 +0000 (15:34 +0000)]
Clarify comment on CHECK_CLTV_EXPIRE_SANITY_2 somewhat

3 years agoMerge pull request #910 from TheBlueMatt/2021-05-sort-addrs
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

3 years agoCorrect MIN_FINAL_CLTV_EXPIRY to match our enforced requirements
Matt Corallo [Wed, 5 May 2021 02:17:02 +0000 (02:17 +0000)]
Correct MIN_FINAL_CLTV_EXPIRY to match our enforced requirements

Our enforced requirements for HTLC acceptance is that we have at
least HTLC_FAIL_BACK_BUFFER blocks before the HTLC expires. When we
receive an HTLC, the HTLC would be "already expired" if its
`cltv_expiry` is current-block + 1 (ie the next block could
broadcast the commitment transaction and time out the HTLC). From
there, we want an extra HTLC_FAIL_BACK_BUFFER in blocks, plus an
extra block or two to account for any differences in the view of
the current height before send or while the HTLC is transiting the
network.

3 years agoIncrease the CLTV delay required on payments and forwards
Matt Corallo [Wed, 5 May 2021 02:04:58 +0000 (02:04 +0000)]
Increase the CLTV delay required on payments and forwards

This increases the CLTV_CLAIM_BUFFER constant to 18, much better
capturing how long it takes to go on chain to claim payments.
This is also more in line with other clients, and the spec, which
sets the default CLTV delay in invoices to 18.

As a side effect, we have to increase MIN_CLTV_EXPIRY_DELTA as
otherwise as are subject to an attack where someone can hold an
HTLC being forwarded long enough that we *also* close the channel
on which we received the HTLC.

3 years agoBy default sort network addrs before inclusion in node_announcements 2021-05-sort-addrs
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.

3 years agoMerge pull request #909 from TheBlueMatt/2021-04-0.0.14 v0.0.14
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

3 years agoMerge pull request #901 from jkczyz/2021-04-invoice-feature-semantics
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

3 years agoMerge pull request #845 from ariard/2021-03-hardcode-dust
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

3 years agoTest feature bit semantics in Invoice::from_signed
Jeffrey Czyz [Fri, 30 Apr 2021 21:30:58 +0000 (14:30 -0700)]
Test feature bit semantics in Invoice::from_signed

3 years agoTest feature bits in InvoiceBuilder
Jeffrey Czyz [Fri, 30 Apr 2021 20:11:34 +0000 (13:11 -0700)]
Test feature bits in InvoiceBuilder

3 years agoAdd basic_mpp support to 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.

3 years agoHide InvoiceFeatures behind InvoiceBuilder API
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.

3 years agoMake third HTLC non-dust again in the full_stack_target demo seed
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

3 years agoAdd bolt2_open_channel_sane_dust_limit
Antoine Riard [Wed, 8 Apr 2020 01:51:50 +0000 (21:51 -0400)]
Add bolt2_open_channel_sane_dust_limit

3 years agoReplace config max counterpary `dust_limit_satoshis` by a constant.
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.

3 years agoMerge pull request #908 from TheBlueMatt/2021-04-invoice-real-bindings
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

3 years agoBump versions to 0.0.14, lightning-invoice 0.5 2021-04-0.0.14
Matt Corallo [Sat, 1 May 2021 00:43:15 +0000 (00:43 +0000)]
Bump versions to 0.0.14, lightning-invoice 0.5

3 years agoAdd a not-exported tag to the Display implementation for RawHrp 2021-04-invoice-real-bindings
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.

3 years agoUse explicit import lists instead of glob imports in invoice
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.

3 years agoSanity test InvoiceFeatures
Jeffrey Czyz [Fri, 30 Apr 2021 16:58:07 +0000 (09:58 -0700)]
Sanity test InvoiceFeatures

3 years agoRequire feature var_onion_optin
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.

3 years agoSkip TaggedField for now as `enum { A(A) }` is broken in Java
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.

3 years agoSet default error type for SignOrCreationError for bindings
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.

3 years agoMerge pull request #907 from TheBlueMatt/2021-04-merge-conflicts
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.

3 years agoDeny broken doc links in lightning-invoice as well 2021-04-merge-conflicts
Matt Corallo [Fri, 30 Apr 2021 17:33:05 +0000 (17:33 +0000)]
Deny broken doc links in lightning-invoice as well

3 years agoFix merge conflicts between #898 and #895.
Matt Corallo [Fri, 30 Apr 2021 17:32:36 +0000 (17:32 +0000)]
Fix merge conflicts between #898 and #895.

3 years agoMerge pull request #898 from jkczyz/2021-04-invoice-expiry
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

3 years agoMerge pull request #895 from valentinewallace/invoice-chanman-utility
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

3 years agoAdd utility to create an invoice using the ChannelManager
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.

3 years agoMove invoice signing behind KeysInterface
Valentine Wallace [Thu, 29 Apr 2021 16:19:05 +0000 (12:19 -0400)]
Move invoice signing behind KeysInterface

3 years agoMove PaymentPreimage+PaymentHash+PaymentSecret to top-level ln module
Valentine Wallace [Wed, 28 Apr 2021 21:28:10 +0000 (17:28 -0400)]
Move PaymentPreimage+PaymentHash+PaymentSecret to top-level ln module

3 years agoMake _test_utils depend on bitcoinconsensus feature
Valentine Wallace [Wed, 28 Apr 2021 20:23:39 +0000 (16:23 -0400)]
Make _test_utils depend on bitcoinconsensus feature

3 years agoinvoice: swap PaymentSecret for ChannelManager's PaymentSecret
Valentine Wallace [Wed, 21 Apr 2021 21:53:00 +0000 (17:53 -0400)]
invoice: swap PaymentSecret for ChannelManager's PaymentSecret

3 years agoMerge pull request #905 from TheBlueMatt/2021-04-mention-invoice-storage-docs
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

3 years agoMention storage req for users with a public invoice generation API 2021-04-mention-invoice-storage-docs
Matt Corallo [Thu, 29 Apr 2021 19:31:35 +0000 (19:31 +0000)]
Mention storage req for users with a public invoice generation API

3 years agoMerge pull request #904 from lightning-signer/no-send-sync
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

3 years agoTest default invoice field values
Jeffrey Czyz [Mon, 26 Apr 2021 21:24:36 +0000 (14:24 -0700)]
Test default invoice field values

3 years agoRequire min_final_cltv_expiry in invoice
Jeffrey Czyz [Mon, 26 Apr 2021 20:08:19 +0000 (13:08 -0700)]
Require min_final_cltv_expiry in invoice

3 years agoUse default for invoice's min_final_cltv_expiry
Jeffrey Czyz [Mon, 26 Apr 2021 18:59:56 +0000 (11:59 -0700)]
Use default for invoice's min_final_cltv_expiry

3 years agoUse constant for invoice's default expiry value
Jeffrey Czyz [Sat, 24 Apr 2021 00:30:07 +0000 (17:30 -0700)]
Use constant for invoice's default expiry value

3 years agoRemove Send and Sync from core crate
Devrandom [Thu, 29 Apr 2021 19:07:28 +0000 (21:07 +0200)]
Remove Send and Sync from core crate

3 years agoMerge pull request #903 from TheBlueMatt/2021-04-invoice-bindings
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

3 years agoDrop redundant generic parameter bounds on ChainMonitor trait impls 2021-04-invoice-bindings
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.

3 years agoAdd no-export tags for lightning-invoice where we can't map to C
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

3 years agoRename lightning_invoice::Signature to InvoiceSignature
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.

3 years agoDo not return a reference to a u64 in rust-lightning-invoices
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.

3 years agoMerge pull request #900 from lightning-signer/init-asap
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

3 years agoMerge pull request #902 from TheBlueMatt/2021-04-fix-fuzz-test
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

3 years agoMerge pull request #893 from TheBlueMatt/2021-04-features-chanman
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

3 years agoAdd a const and docs for the min `min_final_cltv_expiry` we allow 2021-04-features-chanman
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

3 years agoAdd some simple tests of payment secret tracking
Matt Corallo [Wed, 28 Apr 2021 18:59:54 +0000 (14:59 -0400)]
Add some simple tests of payment secret tracking

3 years agoFail PendingInboundPayments after their expiry time is reached
Matt Corallo [Fri, 23 Apr 2021 23:56:58 +0000 (23:56 +0000)]
Fail PendingInboundPayments after their expiry time is reached

3 years agoGive users who use `get_payment_secret_preimage` the PaymentPreimage
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.

3 years agoMake the PaymentSecret in `PaymentReceived` events non-Optional
Matt Corallo [Fri, 23 Apr 2021 16:53:53 +0000 (16:53 +0000)]
Make the PaymentSecret in `PaymentReceived` events non-Optional

3 years agoDrop the amount parameter to claim_funds
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.

3 years agoDrop now-useless PaymentSecret parameters when claiming/failing-back
Matt Corallo [Fri, 23 Apr 2021 03:00:44 +0000 (03:00 +0000)]
Drop now-useless PaymentSecret parameters when claiming/failing-back

3 years agoAdd a `user_payment_id` to `get_payment_secret`+`PaymentReceived`
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.

3 years agoDrop dead code for handling non-MPP payments in claim_funds
Matt Corallo [Fri, 23 Apr 2021 04:08:41 +0000 (04:08 +0000)]
Drop dead code for handling non-MPP payments in claim_funds

3 years ago[fuzz] Always use PaymentSecrets in chanmon_consistency
Matt Corallo [Fri, 23 Apr 2021 19:04:02 +0000 (19:04 +0000)]
[fuzz] Always use PaymentSecrets in chanmon_consistency

3 years agoReq+check payment secrets for inbound payments pre-PaymentReceived
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.

3 years agoUse payment_secrets in all sends in functional tests
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.

3 years agoUse known InvoiceFeatures for routing in tests
Matt Corallo [Fri, 23 Apr 2021 03:15:37 +0000 (03:15 +0000)]
Use known InvoiceFeatures for routing in tests

3 years agoPipe through PaymentSecrets in tests during payment hash creation
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.