]> git.bitcoin.ninja Git - rust-lightning/log
rust-lightning
2 years agoSupport phantom payment receive in ChannelManager, with invoice util
Valentine Wallace [Thu, 20 Jan 2022 20:29:41 +0000 (15:29 -0500)]
Support phantom payment receive in ChannelManager, with invoice util

See PhantomKeysManager and invoice util's create_phantom_invoice for more info

2 years agoAdd get_phantom_scid and get_phantom_route_hints + scid_utils::fake_scid module
Valentine Wallace [Thu, 30 Dec 2021 21:13:56 +0000 (16:13 -0500)]
Add get_phantom_scid and get_phantom_route_hints + scid_utils::fake_scid module

See method and module docs for more details

2 years agochannelmanager: DRY PendingHTLCInfo creation for receives
Valentine Wallace [Mon, 10 Jan 2022 20:58:28 +0000 (15:58 -0500)]
channelmanager: DRY PendingHTLCInfo creation for receives

Will be used to facilitate decoding multiple onion layers for phantom payment receive

2 years agoscid_utils: add utils for retrieving txindex and vout
Valentine Wallace [Fri, 31 Dec 2021 22:14:48 +0000 (17:14 -0500)]
scid_utils: add utils for retrieving txindex and vout

2 years agokeysinterface: adapt get_node_secret for phantom payments
Valentine Wallace [Wed, 9 Feb 2022 22:22:53 +0000 (17:22 -0500)]
keysinterface: adapt get_node_secret for phantom payments

We want LDK to be able to retrieve the phantom secret key when we see that a payment
is destined for a phantom node.

2 years agoKeysInterface::sign_invoice: indicate whether invoice is a phantom
Valentine Wallace [Tue, 1 Feb 2022 22:33:57 +0000 (17:33 -0500)]
KeysInterface::sign_invoice: indicate whether invoice is a phantom

2 years agokeysmanager: support phantom payments with PhantomKeysManager
Valentine Wallace [Mon, 27 Dec 2021 20:11:03 +0000 (15:11 -0500)]
keysmanager: support phantom payments with PhantomKeysManager

To support the feature of generating invoices that can be paid to any of
multiple nodes, a key manager need to be able to share an inbound_payment_key
and phantom secret key. This is because a phantom payment may be received by
any node participating in the invoice, so all nodes must be able to decrypt the
phantom payment (and therefore must share decryption key(s)) in the act of
pretending to be the phantom node. Thus we add a new `PhantomKeysManager` that
supports these features.

To be more specific, the inbound payment key must be shared because it is used
to decrypt the payment details for verification (LDK avoids storing inbound
payment data by encrypting payment metadata in the payment hash and/or payment
secret).

The phantom secret must be shared because enables any real node included in the
phantom invoice to decrypt the final layer of the onion packet, since the onion
is encrypted by the sender using the phantom public key provided in the
invoice.

2 years agoDRY shared hkdf_extract_expand code to new module
Valentine Wallace [Thu, 27 Jan 2022 18:40:30 +0000 (13:40 -0500)]
DRY shared hkdf_extract_expand code to new module

2 years agoImplement serialization for ChannelDetails
Valentine Wallace [Thu, 27 Jan 2022 19:56:02 +0000 (14:56 -0500)]
Implement serialization for ChannelDetails

Will be used in upcoming commit(s) where it may be desirable to cache ChannelDetails routehints

2 years agoRefactor out decode_next_hop util from ChannelManager::decode_update_add_htlc
Valentine Wallace [Tue, 9 Nov 2021 00:49:35 +0000 (19:49 -0500)]
Refactor out decode_next_hop util from ChannelManager::decode_update_add_htlc

This will be used in upcoming commit(s) to facilitate decoding multiple onion layers for
multi-node payment receive

2 years agoMerge pull request #1301 from TheBlueMatt/2022-02-router-no-test
Matt Corallo [Mon, 14 Feb 2022 18:29:03 +0000 (18:29 +0000)]
Merge pull request #1301 from TheBlueMatt/2022-02-router-no-test

Work around rustc bug on nightly and make benchmarks not run test code

2 years agoMerge pull request #1305 from ConorOkus/update-readme
valentinewallace [Mon, 14 Feb 2022 18:01:55 +0000 (13:01 -0500)]
Merge pull request #1305 from ConorOkus/update-readme

Update README to include community invite links

2 years agoMerge pull request #1281 from ViktorTigerstrom/2022-01-accept-or-reject-channels
Matt Corallo [Mon, 14 Feb 2022 17:54:22 +0000 (17:54 +0000)]
Merge pull request #1281 from ViktorTigerstrom/2022-01-accept-or-reject-channels

Add option accept or reject channel requests

2 years agoMerge pull request #1304 from jkczyz/2021-12-remove-mut-ref
valentinewallace [Mon, 14 Feb 2022 17:23:02 +0000 (12:23 -0500)]
Merge pull request #1304 from jkczyz/2021-12-remove-mut-ref

Remove unnecessary mut from reference

2 years agoUpdate README to include community invite links
Conor Okus [Mon, 14 Feb 2022 11:47:00 +0000 (11:47 +0000)]
Update README to include community invite links

2 years agoAdd tests for responding to inbound channel reqs
Viktor Tigerström [Mon, 7 Feb 2022 23:54:41 +0000 (00:54 +0100)]
Add tests for responding to inbound channel reqs

Add functional tests for manually responding to inbound channel requests.
Responding to inbound channel requests are required when the
`manually_accept_inbound_channels` config flag is set to true.

The tests cover the following cases:
* Accepting an inbound channel request
* Rejecting an inbound channel request
* FundingCreated message sent by the counterparty before accepting the
inbound channel request
* Attempting to accept an inbound channel request twice
* Attempting to accept an unkown inbound channel

2 years agoAdd option to accept or reject inbound channels
Viktor Tigerström [Tue, 25 Jan 2022 23:21:22 +0000 (00:21 +0100)]
Add option to accept or reject inbound channels

Add a new config flag `UserConfig::manually_accept_inbound_channels`,
which when set to true allows the node operator to accept or reject new
channel requests.

When set to true, `Event::OpenChannelRequest` will be triggered once a
request to open a new inbound channel is received. When accepting the
request, `ChannelManager::accept_inbound_channel` should be called.
Rejecting the request is done through
`ChannelManager::force_close_channel`.

2 years agoRemove unnecessary mut from reference
Jeffrey Czyz [Sat, 4 Dec 2021 18:08:05 +0000 (12:08 -0600)]
Remove unnecessary mut from reference

chain::Listen's interface is defined in terms of non-mutable references,
so there's no need to use mutable references in lightning-block-sync.

2 years agoMerge pull request #1292 from TheBlueMatt/2022-02-override-handshake-limits
valentinewallace [Sat, 12 Feb 2022 00:45:44 +0000 (19:45 -0500)]
Merge pull request #1292 from TheBlueMatt/2022-02-override-handshake-limits

Store override counterparty handshake limits until we enforce them

2 years agoMerge pull request #1268 from TheBlueMatt/2022-01-balance-underflow
Arik Sosman [Fri, 11 Feb 2022 00:30:48 +0000 (16:30 -0800)]
Merge pull request #1268 from TheBlueMatt/2022-01-balance-underflow

Include inbound-claimed-HTLCs in reported channel balances

2 years agoMake router benchmarks more realistic by not running test-only code 2022-02-router-no-test
Matt Corallo [Thu, 10 Feb 2022 21:13:19 +0000 (21:13 +0000)]
Make router benchmarks more realistic by not running test-only code

`cargo bench` sets `cfg(test)`, causing us to hit some test-only
code in the router when benchmarking, throwing off our benchmarks
substantially. Here we swap from the `unstable` feature to a more
clearly internal feature (`_bench_unstable`) and also checking for
it when enabling test-only code.

2 years agoInclude inbound-claimed-HTLCs in reported channel balances 2022-01-balance-underflow
Matt Corallo [Thu, 20 Jan 2022 04:28:38 +0000 (04:28 +0000)]
Include inbound-claimed-HTLCs in reported channel balances

Given the balance is reported as "total balance if we went to chain
ignoring fees", it seems reasonable to include claimed HTLCs - if
we went to chain we'd get those funds, less on-chain fees. Further,
if we do not include them, its possible to have pending outbound
holding-cell HTLCs underflow the balance calculation, causing a
panic in debug mode, and bogus values in release.

This resolves a subtraction underflow bug found by the
`chanmon_consistency` fuzz target.

2 years agoWork around rustc compilation regression on nightly
Matt Corallo [Thu, 10 Feb 2022 21:11:59 +0000 (21:11 +0000)]
Work around rustc compilation regression on nightly

Apparently rustc doesn't (actually) provide any kind of
compilation-stability guarantees, despite their claims. Here we
work around rustc being unstable by making the trait call explicit.

See also https://github.com/rust-lang/rust/issues/93599

2 years agoMerge pull request #1299 from p2pderivatives/make-counterpartycommitmentsecrets-public
Matt Corallo [Thu, 10 Feb 2022 17:12:27 +0000 (17:12 +0000)]
Merge pull request #1299 from p2pderivatives/make-counterpartycommitmentsecrets-public

Make CounterpartyCommitmentSecrets public

2 years agoMake CounterpartyCommitmentSecrets public
Tibo-lg [Tue, 8 Feb 2022 01:25:12 +0000 (10:25 +0900)]
Make CounterpartyCommitmentSecrets public

2 years agoMerge pull request #1285 from TheBlueMatt/2022-01-remove-closed-issue-ref
Matt Corallo [Fri, 4 Feb 2022 19:42:26 +0000 (19:42 +0000)]
Merge pull request #1285 from TheBlueMatt/2022-01-remove-closed-issue-ref

Remove stale reference to incomplete BOLT compliance

2 years agoMerge pull request #1227 from jkczyz/2021-12-probabilistic-scorer
valentinewallace [Thu, 3 Feb 2022 15:50:49 +0000 (10:50 -0500)]
Merge pull request #1227 from jkczyz/2021-12-probabilistic-scorer

Probabilistic channel scoring

2 years agoAdd ProbabilisticScorer benchmarks
Jeffrey Czyz [Mon, 17 Jan 2022 04:54:42 +0000 (22:54 -0600)]
Add ProbabilisticScorer benchmarks

2 years agoDeprecate Scorer in favor of ProbabilisticScorer
Jeffrey Czyz [Mon, 17 Jan 2022 04:12:58 +0000 (22:12 -0600)]
Deprecate Scorer in favor of ProbabilisticScorer

2 years agoDecay channel liquidity balance offsets
Jeffrey Czyz [Wed, 5 Jan 2022 00:15:59 +0000 (18:15 -0600)]
Decay channel liquidity balance offsets

ProbabilisticScorer uses successful and unsuccessful payments to gain
more certainty of a channel's liquidity balance. Decay this knowledge
over time to indicate decreasing certainty about the liquidity balance.

2 years agoProbabilistic channel scoring
Jeffrey Czyz [Mon, 3 Jan 2022 14:35:19 +0000 (08:35 -0600)]
Probabilistic channel scoring

Add a Score implementation based on "Optimally Reliable & Cheap Payment
Flows on the Lightning Network" by Rene Pickhardt and Stefan Richter[1].
Given the uncertainty of channel liquidity balances, probability
distributions are defined based on knowledge learned from successful and
unsuccessful attempts. Then the negative log of the success probability
is used to determine the cost of routing a specific HTLC amount through
a channel.

[1]: https://arxiv.org/abs/2107.05322

2 years agoEffective channel capacity for router and scoring
Jeffrey Czyz [Wed, 29 Dec 2021 15:56:54 +0000 (09:56 -0600)]
Effective channel capacity for router and scoring

A channel's capacity may be inferred or learned and is used to make
routing decisions, including as a parameter to channel scoring. Define
an EffectiveCapacity for this purpose. Score::channel_penalty_msat takes
the effective capacity (less in-flight HTLCs for the same payment), and
never None. Thus, for hops given in an invoice, the effective capacity
is now considered (near) infinite if over a private channel or based on
learned information if over a public channel.

If a Score implementations needs the effective capacity when updating a
channel's score, i.e. in payment_path_failed or payment_path_successful,
it can access the channel's EffectiveCapacity via the NetworkGraph by
first looking up the channel and then specifying which direction is
desired using ChannelInfo::as_directed.

2 years agoStore override counterparty handshake limits until we enforce them 2022-02-override-handshake-limits
Matt Corallo [Tue, 1 Feb 2022 21:16:27 +0000 (21:16 +0000)]
Store override counterparty handshake limits until we enforce them

We currently allow users to provide an `override_config` in
`ChannelManager::create_channel` which it seems should apply to the
channel. However, because we don't store any of it, the only parts
which we apply to the channel are those which are set in the
`Channel` object immediately in `Channel::new_outbound` and used
from there.

This is great in most cases, however the
`UserConfig::peer_channel_config_limits` `ChannelHandshakeLimits`
object is used in `accept_channel` to bound what is acceptable in
our peer's `AcceptChannel` message. Thus, for outbound channels, we
are given a full `UserConfig` object to "override" the default
config, but we don't use any of the handshake limits specified in
it.

Here, we move to storing the `ChannelHandshakeLimits` explicitly
and applying it when we receive our peer's `AcceptChannel`. Note
that we don't need to store it anywhere because if we haven't
received an `AcceptChannel` from our peer when we reload from disk
we will forget the channel entirely anyway.

2 years agoMerge pull request #1282 from TheBlueMatt/2022-01-fuzz-overflow
valentinewallace [Thu, 27 Jan 2022 16:42:05 +0000 (11:42 -0500)]
Merge pull request #1282 from TheBlueMatt/2022-01-fuzz-overflow

Avoid overflow in addition when checking counterparty feerates

2 years agoRemove stale reference to incomplete BOLT compliance 2022-01-remove-closed-issue-ref
Matt Corallo [Wed, 26 Jan 2022 23:28:45 +0000 (23:28 +0000)]
Remove stale reference to incomplete BOLT compliance

The referenced issue was closed some time ago with a PR to amend
the BOLTs to be more restrictive, which we are in compliance with.

2 years agoMerge pull request #1179 from TheBlueMatt/2021-11-fix-announce-sigs-broadcast-time
Matt Corallo [Wed, 26 Jan 2022 23:27:04 +0000 (23:27 +0000)]
Merge pull request #1179 from TheBlueMatt/2021-11-fix-announce-sigs-broadcast-time

Disconnect announcement_signatures sending from funding_locked

2 years agoMake `Channel::get_announcement_sigs` return an Option and log 2021-11-fix-announce-sigs-broadcast-time
Matt Corallo [Tue, 7 Dec 2021 19:11:18 +0000 (19:11 +0000)]
Make `Channel::get_announcement_sigs` return an Option and log

Channel::get_announcement_sigs is only used in contexts where we
have a logger already, and the error returned is always ignored, so
instead of returning an ignored error message we return an `Option`
directly and log when it won't be too verbose.

2 years agoSwap loop and condition order to avoid looping unnecessarily
Matt Corallo [Tue, 7 Dec 2021 01:56:31 +0000 (01:56 +0000)]
Swap loop and condition order to avoid looping unnecessarily

2 years agoDisconect `announcement_signatures` sending from `funding_locked`
Matt Corallo [Thu, 18 Nov 2021 21:54:13 +0000 (21:54 +0000)]
Disconect `announcement_signatures` sending from `funding_locked`

The spec actually requires we never send `announcement_signatures`
(and, thus, `channel_announcement`s) until after six confirmations.
However, we would happily have sent them prior to that as long as
we exchange `funding_locked` messages with our countarparty. Thanks
to re-broadcasting this issue is largely harmless, however it could
have some negative interactions with less-robust peers. Much more
importantly, this represents an important step towards supporting
0-conf channels, where `funding_locked` messages may be exchanged
before we even have an SCID to construct the messages with.

Because there is no ACK mechanism for `announcement_signatures` we
rely on existing channel updates to stop rebroadcasting them - if
we sent a `commitment_signed` after an `announcement_signatures`
and later receive a `revoke_and_ack`, we know our counterparty also
received our `announcement_signatures`. This may resolve some rare
edge-cases where we send a `funding_locked` which our counterparty
receives, but lose connection before the `announcement_signatures`
(usually the very next message) arrives.

Sadly, because the set of places where an `announcement_signatures`
may now be generated more closely mirrors where `funding_locked`
messages may be generated, but they are now separate, there is a
substantial amount of code motion providing relevant parameters
about current block information and ensuring we can return new
`announcement_signatures` messages.

2 years agoUnset `Channel::is_usable` if mon update is blocking funding_locked
Matt Corallo [Thu, 18 Nov 2021 21:54:10 +0000 (21:54 +0000)]
Unset `Channel::is_usable` if mon update is blocking funding_locked

If we have not yet sent `funding_locked` only because of a pending
channel monitor update, we shouldn't consider a channel
`is_usable`. This has a number of downstream effects, including
not attempting to route payments through the channel, not sending
private `channel_update` messages to our counterparty, or sending
channel_announcement messages if our couterparty has already signed
for it.

We further gate generation of `node_announcement`s on `is_usable`,
preventing generation of those or `announcement_signatures` until
we've sent our `funding_locked`.

Finally, `during_funding_monitor_fail` is updated to test a case
where we see the funding transaction lock in but have a pending
monitor update failure, then receive `funding_locked` from our
counterparty and ensure we don't generate the above messages until
after the monitor update completes.

2 years agoDo not Send FundingLocked messages while disconnected
Matt Corallo [Mon, 15 Nov 2021 01:09:27 +0000 (01:09 +0000)]
Do not Send FundingLocked messages while disconnected

While its generally harmless to do so (the messages will simply be
dropped in `PeerManager`) there is a potential race condition where
the FundingLocked message enters the outbound message queue, then
the peer reconnects, and then the FundingLocked message is
delivered prior to the normal ChannelReestablish flow.

We also take this opportunity to rewrite
`test_funding_peer_disconnect` to be explicit instead of using
`reconnect_peers`. This allows it to check each message being sent
carefully, whereas `reconnect_peers` is rather lazy and accepts
that sometimes signatures will be exchanged, and sometimes not.

2 years agoReturn struct, not long tuple, from `Channel::channel_reestablish`
Matt Corallo [Sat, 13 Nov 2021 22:47:42 +0000 (22:47 +0000)]
Return struct, not long tuple, from `Channel::channel_reestablish`

This improves readability and makes it easier to add additional
return fields.

2 years agoMerge pull request #1283 from TheBlueMatt/2022-01-correct-req-feature-handling
valentinewallace [Wed, 26 Jan 2022 16:30:43 +0000 (11:30 -0500)]
Merge pull request #1283 from TheBlueMatt/2022-01-correct-req-feature-handling

Correct handling of `UnknownRequiredFeature` deserialization

2 years agoMerge pull request #1273 from jkczyz/2022-01-invoice-expiry
valentinewallace [Wed, 26 Jan 2022 14:51:14 +0000 (09:51 -0500)]
Merge pull request #1273 from jkczyz/2022-01-invoice-expiry

Support invoice expiry over a year

2 years agoCorrect handling of `UnknownRequiredFeature` deserialization 2022-01-correct-req-feature-handling
Matt Corallo [Wed, 26 Jan 2022 02:04:20 +0000 (02:04 +0000)]
Correct handling of `UnknownRequiredFeature` deserialization

Quite some time ago, `UnknownRequiredFeature` was only used when a
gossip message has a missing required feature. These days, its also
used for any required TLV which we do not understand in any
message. However, the handling of it was never updated in
`PeerManager`, leaving it printing a warning about gossip and
ignoring the message entirely.

Instead, we send a warning message and disconnect.

Closes #1236, as caught by @jkczyz.

2 years agoAvoid overflow in addition when checking counterparty feerates 2022-01-fuzz-overflow
Matt Corallo [Wed, 26 Jan 2022 00:10:19 +0000 (00:10 +0000)]
Avoid overflow in addition when checking counterparty feerates

This is harmless outside of debug builds - the feerate will
overflow causing it to either spuriously fail the first check, or
correctly pass it and fail the second check. In debug builds,
however, it panics due to integer overflow.

Found by the `full_stack_target` fuzz test in the
Chaincode-provided continuous fuzzing. Thanks Chaincode!

2 years agoSupport invoice expiry over a year
Jeffrey Czyz [Fri, 21 Jan 2022 22:57:17 +0000 (16:57 -0600)]
Support invoice expiry over a year

The lightning-invoice crate represents timestamps as Duration since the
UNIX epoch rather than a SystemTime. Therefore, internal calculations
are in terms of u64-based Durations. This allows for relaxing the one
year maximum expiry.

2 years agoMove node_id signing of ChannelAnnouncement into Signer
Matt Corallo [Sun, 14 Nov 2021 17:25:39 +0000 (17:25 +0000)]
Move node_id signing of ChannelAnnouncement into Signer

This removes one more place where we directly access the node_id
secret key in `ChannelManager`, slowly marching towards allowing
the node_id secret key to be offline in the signer.

More importantly, it allows more ChannelAnnouncement logic to move
into the `Channel` without having to pass the node secret key
around, avoiding the announcement logic being split across two
files.

2 years agoMerge pull request #1275 from jkczyz/2022-01-benchmark-improvements
valentinewallace [Tue, 25 Jan 2022 17:18:17 +0000 (12:18 -0500)]
Merge pull request #1275 from jkczyz/2022-01-benchmark-improvements

Router benchmark improvements

2 years agoMerge pull request #1251 from lightning-signer/2022-01-signer-preimages
Matt Corallo [Tue, 25 Jan 2022 17:12:05 +0000 (17:12 +0000)]
Merge pull request #1251 from lightning-signer/2022-01-signer-preimages

Provide payment preimages to signer on HTLC success

2 years agoBenchmark zero-penalty scorer
Jeffrey Czyz [Sun, 16 Jan 2022 16:16:19 +0000 (10:16 -0600)]
Benchmark zero-penalty scorer

2 years agoBenchmark router using a scorer seeded with data
Jeffrey Czyz [Mon, 17 Jan 2022 03:07:57 +0000 (21:07 -0600)]
Benchmark router using a scorer seeded with data

Scorers may have different performance characteristics after seeing
failed and successful paths. Seed the scorer with some random data
before executing the benchmark in order to exercise such behavior.

2 years agoAdd first_hops to generate_routes benchmarks
Jeffrey Czyz [Sun, 16 Jan 2022 16:04:11 +0000 (10:04 -0600)]
Add first_hops to generate_routes benchmarks

Passing first_hops to get_route increases the coverage of the benchmark
test. For scorers needing the sending node, it allows for using a single
scorer in the benchmark rather than re-initializing on each iteration.
As a consequence, the scorer can be seeded with success and failure
data.

2 years agoRemove duplicate generate_routes benchmark code
Jeffrey Czyz [Fri, 14 Jan 2022 18:28:30 +0000 (12:28 -0600)]
Remove duplicate generate_routes benchmark code

Refactor generate_routes and generate_mpp_routes into a single utility
for benchmarking. The utility is parameterized with features in order to
test both single path and multi-path routing. Additionally, it is
parameterized with a Score to be used with other scorers.

2 years agoProvide preimages to signer
Devrandom [Wed, 19 Jan 2022 11:19:27 +0000 (12:19 +0100)]
Provide preimages to signer

2 years agoKeep track of preimage in OutboundHTLCState on success
Devrandom [Tue, 18 Jan 2022 13:17:52 +0000 (14:17 +0100)]
Keep track of preimage in OutboundHTLCState on success

2 years agoMerge pull request #1272 from lightning-signer/2022-01-sign-invoice-api
valentinewallace [Mon, 24 Jan 2022 16:39:58 +0000 (11:39 -0500)]
Merge pull request #1272 from lightning-signer/2022-01-sign-invoice-api

Improve KeysInterface::sign_invoice API

2 years agoMerge pull request #1271 from tnull/rename_payee_struct
valentinewallace [Mon, 24 Jan 2022 16:34:48 +0000 (11:34 -0500)]
Merge pull request #1271 from tnull/rename_payee_struct

Rename `Payee` to `PaymentParameters`

2 years agoMerge pull request #1253 from TheBlueMatt/2022-01-background-persist-exit
valentinewallace [Mon, 24 Jan 2022 16:23:12 +0000 (11:23 -0500)]
Merge pull request #1253 from TheBlueMatt/2022-01-background-persist-exit

Persist `ChannelManager` before `BackgroundProcessor` exits

2 years agoImprove KeysInterface::sign_invoice API
Devrandom [Fri, 21 Jan 2022 10:33:39 +0000 (11:33 +0100)]
Improve KeysInterface::sign_invoice API

split hrp from invoice data, to allow parsing, since there is no delimiter between the two parts

2 years agoMerge pull request #1250 from vss96/sanity_check
Matt Corallo [Sat, 22 Jan 2022 18:19:35 +0000 (18:19 +0000)]
Merge pull request #1250 from vss96/sanity_check

Sanity check for ChannelManager and KeysInterface

2 years agoSanity check for ChannelManager and KeysInterface
vss96 [Tue, 18 Jan 2022 12:00:19 +0000 (17:30 +0530)]
Sanity check for ChannelManager and KeysInterface

Fix build errors

Create script using p2wsh for comparison

Using p2wpkh for generating the payment script

spendable_outputs sanity check

Return err in spendable_outputs

Doc updates in keysinterface

2 years agoMerge pull request #1269 from TheBlueMatt/022-01-no-disconnect-on-slow-persist
valentinewallace [Fri, 21 Jan 2022 16:52:05 +0000 (11:52 -0500)]
Merge pull request #1269 from TheBlueMatt/022-01-no-disconnect-on-slow-persist

Avoid disconnecting all peers if user code is slow

2 years agoRename `Payee` to `PaymentParameters`
Elias Rohrer [Fri, 21 Jan 2022 09:39:01 +0000 (10:39 +0100)]
Rename `Payee` to `PaymentParameters`

2 years agoIncrease our PING_TIMER to ten seconds, from five. 022-01-no-disconnect-on-slow-persist
Matt Corallo [Thu, 20 Jan 2022 23:42:56 +0000 (23:42 +0000)]
Increase our PING_TIMER to ten seconds, from five.

Because many lightning nodes can take quite some time to respond to
pings, the five second ping timer can sometimes cause spurious
disconnects even though a peer is online. However, in part as a
response to mobile users where a connection may be lost as result
of only a short time with the app in a "paused" state, we had a
rather aggressive ping time to ensure we would disconnect quickly.

However, since we now just used a fixed time for the "went to
sleep" detection, we can somewhat increase the ping timer. We still
want to be fairly aggressive to avoid sending HTLCs to a peer that
is offline, but the tradeoff between spurious disconnections and
stuck payments is likely doesn't need to be quite as aggressive.

2 years agoAvoid disconnecting all peers if user code is slow
Matt Corallo [Sun, 26 Sep 2021 00:09:17 +0000 (00:09 +0000)]
Avoid disconnecting all peers if user code is slow

In the sample client (and likely other downstream users), event
processing may block on slow operations (e.g. Bitcoin Core RPCs)
and ChannelManager persistence may take some time. This should be
fine, except that we consider this a case of possible backgrounding
and disconnect all of our peers when it happens.

Instead, we here avoid considering event processing time in the
time between PeerManager events.

2 years agoMerge pull request #1234 from tnull/limit_max_cltv_delta
Jeffrey Czyz [Thu, 20 Jan 2022 16:36:22 +0000 (10:36 -0600)]
Merge pull request #1234 from tnull/limit_max_cltv_delta

Limit maximum CLTV delta during routing

2 years agoMerge pull request #1248 from naveensrinivasan/naveen/feat/update-readme
Matt Corallo [Thu, 20 Jan 2022 16:34:01 +0000 (16:34 +0000)]
Merge pull request #1248 from naveensrinivasan/naveen/feat/update-readme

Docs: Updated README to include crates information

2 years agoLimit maximum total CLTV expiry delta during routing.
Elias Rohrer [Thu, 20 Jan 2022 15:00:00 +0000 (16:00 +0100)]
Limit maximum total CLTV expiry delta during routing.

2 years agoDocs: Updated README to include crates information
naveen [Tue, 18 Jan 2022 02:43:45 +0000 (02:43 +0000)]
Docs: Updated README to include crates information

Included crates information into README.

2 years agoMerge pull request #1258 from lightningdevkit/dependabot/cargo/hex-0.4
valentinewallace [Wed, 19 Jan 2022 18:19:59 +0000 (13:19 -0500)]
Merge pull request #1258 from lightningdevkit/dependabot/cargo/hex-0.4

Update hex requirement from 0.3 to 0.4

2 years agoFixed some typos
Elias Rohrer [Wed, 19 Jan 2022 17:15:47 +0000 (18:15 +0100)]
Fixed some typos

2 years agoPersist `ChannelManager` before `BackgroundProcessor` exits 2022-01-background-persist-exit
Matt Corallo [Tue, 18 Jan 2022 21:48:28 +0000 (21:48 +0000)]
Persist `ChannelManager` before `BackgroundProcessor` exits

Fixes #1237.

2 years agoUpdate hex requirement from 0.3 to 0.4
dependabot[bot] [Tue, 18 Jan 2022 22:05:49 +0000 (22:05 +0000)]
Update hex requirement from 0.3 to 0.4

Updates the requirements on [hex](https://github.com/KokaKiwi/rust-hex) to permit the latest version.
- [Release notes](https://github.com/KokaKiwi/rust-hex/releases)
- [Commits](https://github.com/KokaKiwi/rust-hex/compare/v0.3...v0.4.3)

---
updated-dependencies:
- dependency-name: hex
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2 years agoMerge pull request #1243 from naveensrinivasan/naveensrinivasan/dependabot
Arik Sosman [Tue, 18 Jan 2022 22:04:38 +0000 (14:04 -0800)]
Merge pull request #1243 from naveensrinivasan/naveensrinivasan/dependabot

Enable Dependabot

2 years agoCreate dependabot.yml
Naveen [Mon, 17 Jan 2022 01:32:04 +0000 (19:32 -0600)]
Create dependabot.yml

Signed-off-by: naveen <172697+naveensrinivasan@users.noreply.github.com>
2 years agoMerge pull request #1249 from tnull/fix_compile_warnings
valentinewallace [Tue, 18 Jan 2022 16:18:05 +0000 (11:18 -0500)]
Merge pull request #1249 from tnull/fix_compile_warnings

Fix compiler warning during building/testing.

2 years agoFix unused return warning for 'transmute_copy'.
Elias Rohrer [Tue, 18 Jan 2022 13:45:43 +0000 (14:45 +0100)]
Fix unused return warning for 'transmute_copy'.

2 years agoMerge pull request #1238 from TheBlueMatt/2022-01-lockorder-checks
Matt Corallo [Fri, 14 Jan 2022 16:59:42 +0000 (16:59 +0000)]
Merge pull request #1238 from TheBlueMatt/2022-01-lockorder-checks

Fix and test lockorder

2 years agoCheck lockorders in tests with a trivial lockorder tracker 2022-01-lockorder-checks
Matt Corallo [Thu, 13 Jan 2022 01:00:43 +0000 (01:00 +0000)]
Check lockorders in tests with a trivial lockorder tracker

2 years agoMerge pull request #1229 from lightning-signer/2021-12-htlc-anchor-sighashtype
Matt Corallo [Fri, 14 Jan 2022 04:10:14 +0000 (04:10 +0000)]
Merge pull request #1229 from lightning-signer/2021-12-htlc-anchor-sighashtype

anchors: Fix SigHashType and weight calculations for anchors

2 years agoFixed comment on weight_received_htlc
Ken Sedgwick [Thu, 13 Jan 2022 02:29:05 +0000 (18:29 -0800)]
Fixed comment on weight_received_htlc

2 years agoSet opt_anchors for calls to CommitmentTransaction::new_with_auxiliary_htlc_data
Ken Sedgwick [Thu, 13 Jan 2022 01:10:07 +0000 (17:10 -0800)]
Set opt_anchors for calls to CommitmentTransaction::new_with_auxiliary_htlc_data

2 years agoAdd anchor tests to outbound_commitment_test
Ken Sedgwick [Tue, 4 Jan 2022 22:53:44 +0000 (14:53 -0800)]
Add anchor tests to outbound_commitment_test

2 years agoDebit funder's output to cover anchors
Ken Sedgwick [Wed, 5 Jan 2022 00:05:28 +0000 (16:05 -0800)]
Debit funder's output to cover anchors

2 years agoConvert HTLC_{SUCCESS,TIMEOUT}_TX_WEIGHT to anchor-aware functions
Ken Sedgwick [Wed, 5 Jan 2022 21:40:08 +0000 (13:40 -0800)]
Convert HTLC_{SUCCESS,TIMEOUT}_TX_WEIGHT to anchor-aware functions

2 years agoConvert COMMITMENT_TX_BASE_WEIGHT to anchor-aware function
Ken Sedgwick [Tue, 4 Jan 2022 23:54:54 +0000 (15:54 -0800)]
Convert COMMITMENT_TX_BASE_WEIGHT to anchor-aware function

2 years agoAdd unit test coverage for package::weight_{offered,received}_htlc
Ken Sedgwick [Sun, 2 Jan 2022 23:00:54 +0000 (15:00 -0800)]
Add unit test coverage for package::weight_{offered,received}_htlc

2 years agomake WEIGHT{_REVOKED,}_{OFFERED,RECEIVED}_HTLC functions with opt_anchors parameter
Ken Sedgwick [Fri, 31 Dec 2021 20:21:22 +0000 (12:21 -0800)]
make WEIGHT{_REVOKED,}_{OFFERED,RECEIVED}_HTLC functions with opt_anchors parameter

2 years agoIsolated channelmonitor weight unit tests and added anchor loops
Ken Sedgwick [Fri, 31 Dec 2021 16:47:38 +0000 (08:47 -0800)]
Isolated channelmonitor weight unit tests and added anchor loops

2 years agoSet the SigHashType of remote htlc signatures w/ anchors to SinglePlusAnyoneCanPay
Ken Sedgwick [Wed, 29 Dec 2021 04:37:20 +0000 (20:37 -0800)]
Set the SigHashType of remote htlc signatures w/ anchors to SinglePlusAnyoneCanPay

2 years agoFix some (non-bug) lock-order-inversions in tests
Matt Corallo [Thu, 13 Jan 2022 01:51:29 +0000 (01:51 +0000)]
Fix some (non-bug) lock-order-inversions in tests

2 years agoMake lockorder consistent in channelmanager
Matt Corallo [Wed, 12 Jan 2022 19:58:08 +0000 (19:58 +0000)]
Make lockorder consistent in channelmanager

This resolves a lockorder inversion in
`ChannelManager::finalize_claims` where `pending_outbound_payments`
is locked after `pending_events`, opposite of, for example, the
lockorder in `ChannelManager::fail_htlc_backwards_internal` where
`pending_outbound_payments` is locked at the top of the
`HTLCSource::OutboundRoute` handling and then `pending_events` is
locked at the end.

2 years agoMerge pull request #1013 from TheBlueMatt/2021-07-warning-msgs
Matt Corallo [Tue, 11 Jan 2022 22:52:44 +0000 (22:52 +0000)]
Merge pull request #1013 from TheBlueMatt/2021-07-warning-msgs

2 years agoRely on Error/Warning message data lengths being correct 2021-07-warning-msgs
Matt Corallo [Fri, 7 Jan 2022 20:11:31 +0000 (20:11 +0000)]
Rely on Error/Warning message data lengths being correct

In https://github.com/lightning/bolts/pull/950, the (somewhat
strange) requirement that error messages be handled even if the
length field is set larger than the size of the package was
removed. Here we change the code to drop the special handling for
this, opting to just fail to read the message if the length is
incorrect.

2 years agoSend `warning` instead of `error` when we incounter bogus gossip
Matt Corallo [Fri, 7 Jan 2022 20:30:50 +0000 (20:30 +0000)]
Send `warning` instead of `error` when we incounter bogus gossip

2 years agoConvert `shutdown` invalid script checks to warning messages
Matt Corallo [Thu, 30 Sep 2021 22:45:07 +0000 (22:45 +0000)]
Convert `shutdown` invalid script checks to warning messages

As required by the warning messages PR, we should simply warn our
counterparty in this case and let them try again, continuing to try
to use the channel until they tell us otherwise.

2 years agoSend warning messages when appropriate in gossip handling pipeline
Matt Corallo [Thu, 22 Jul 2021 16:06:33 +0000 (16:06 +0000)]
Send warning messages when appropriate in gossip handling pipeline

2 years agoHandle sending and receiving warning messages
Matt Corallo [Thu, 22 Jul 2021 16:05:48 +0000 (16:05 +0000)]
Handle sending and receiving warning messages

2 years agoAdd a new `WarningMessage` message to send and receive warnings
Matt Corallo [Thu, 22 Jul 2021 15:25:13 +0000 (15:25 +0000)]
Add a new `WarningMessage` message to send and receive warnings