Commit graph

2920 commits

Author SHA1 Message Date
Valentine Wallace
641e20763f
Implement Readable/Writeable for HashSet
To be used in upcoming commits for MPP ID storage
2021-09-17 15:23:45 -04:00
Valentine Wallace
c986e52ce8
Add MppId field to HTLCSource as a way to correlate mpp payment paths 2021-09-17 15:23:45 -04:00
Valentine Wallace
f6f950db75
test utils: refactor fail_payment_along_route for mpp 2021-09-17 15:23:42 -04:00
Valentine Wallace
612d1fb120
Update Watch docs to disallow dup channel outpoints
on watch_channel
2021-09-17 14:50:44 -04:00
Valentine Wallace
e06484b0f4
Don't apply monitor updates after watch_channel PermFail
The full stack fuzzer found an unreachable panic where we receive a
FundingSigned with a duplicate channel outpoint.
2021-09-17 14:50:20 -04:00
Matt Corallo
088daf79aa
Merge pull request #1070 from TheBlueMatt/2021-09-fix-bindings-ignore
Move CounterpartyForwardingInfo from channel to channelmanager
2021-09-17 17:26:54 +00:00
Matt Corallo
78d6c3cb01
Merge pull request #1066 from valentinewallace/2021-08-fix-double-temp-failure
Allow multiple calls to `monitor_update_failed`
2021-09-15 20:51:37 +00:00
Valentine Wallace
3d77cc790c
Allow multiple monitor_update_failed calls
without requiring calls to channel_monitor_updated in between.

Found by the fuzzer
2021-09-15 15:37:27 -04:00
Valentine Wallace
3af0c8e146
Update fuzz README with latest instructions 2021-09-15 15:37:27 -04:00
Matt Corallo
24065c89a9
Merge pull request #1074 from p2pderivatives/add-node-id-to-custom-msg-cb
Add node id to custom message callback
2021-09-15 18:54:15 +00:00
Matt Corallo
35573bb3d7
Merge pull request #1034 from TheBlueMatt/2021-07-maturing-claims
Expose in-flight claim balances
2021-09-15 18:44:04 +00:00
Matt Corallo
bb9df69d0d
Merge pull request #1043 from jkczyz/2021-07-network-update-handler
Handle network updates from failed payments in BackgroundProcessor
2021-09-15 18:13:20 +00:00
Matt Corallo
cae2123793 Expand ANTI_REORG_DELAY docs to say its a library-wide assumption 2021-09-15 18:07:34 +00:00
Matt Corallo
a675886e10 Add an accessor to ChainMonitor to get the claimable balances
The common user desire is to get the set of claimable balances for
all non-closed channels. In order to do so, they really want to
just ask their `ChainMonitor` for the set of balances, which they
can do here by passing the `ChannelManager::list_channels` output
to `ChainMonitor::get_claimable_balances`.
2021-09-15 18:07:34 +00:00
Matt Corallo
00906418aa Expose the amount of funds available for claim in ChannelMonitor
In general, we should always allow users to query for how much is
currently in-flight being claimed on-chain at any time.

This does so by examining the confirmed claims on-chain and
breaking down what is left to be claimed into a new
`ClaimableBalance` enum.

Fixes #995.
2021-09-15 18:07:34 +00:00
Matt Corallo
f9febb0351 Fix indentation in ChannelMonitor 2021-09-15 18:07:34 +00:00
Matt Corallo
c02b6a3807 Track how our HTLCs are resolved on-chain persistently
This tracks how any HTLC outputs in broadcast commitment
transactions are resolved on-chain, storing the result of the HTLC
resolution persistently in the ChannelMonitor.

This can be used to determine which outputs may still be available
for claiming on-chain.
2021-09-15 18:07:34 +00:00
Matt Corallo
73ee30d9da Track the tx which spends our funding output in ChannelMonitor
This allows us to easily look up how our channel was closed and
track which balances may be spendable on-chain.
2021-09-15 18:07:34 +00:00
Matt Corallo
cd578b55f3 Rename CounterpartyCommitmentTransaction to Params as it is static 2021-09-15 18:07:34 +00:00
Matt Corallo
44e48679fb Drop unused CounterpartyCommitmentTransaction::per_htlc HashMap 2021-09-15 18:07:34 +00:00
Matt Corallo
aaba0a2ec9 Store to-self value in the current commitment tx in ChannelMonitor 2021-09-15 18:07:34 +00:00
Jeffrey Czyz
992df51001
Update NetworkGraph in BackgroundProcessor
Decorate the user-supplied EventHandler with NetGraphMsgHandler in
the BackgroundProcessor. The resulting handler will intercept
PaymentFailed events in order to update the NetworkGraph in the
background before delegating to the user's event handler.
2021-09-15 11:53:13 -05:00
Jeffrey Czyz
e2f088c371
Expand and format BackgroundProcessor docs 2021-09-15 11:53:12 -05:00
Jeffrey Czyz
ba2c00b3f8
EventHandler for applying NetworkUpdate
PaymentFailed events contain an optional NetworkUpdate describing
changes to the NetworkGraph as conveyed by a node along a failed payment
path according to BOLT 4. An EventHandler should apply the update to the
graph so that future routing decisions can account for it.

Implement EventHandler for NetGraphMsgHandler to update NetworkGraph.
Previously, NetGraphMsgHandler::handle_htlc_fail_channel_update
implemented this behavior.
2021-09-15 11:50:31 -05:00
Jeffrey Czyz
eff9a47075
Refactor PaymentFailureNetworkUpdate event
MessageSendEvent::PaymentFailureNetworkUpdate served as a hack to pass
an HTLCFailChannelUpdate from ChannelManager to NetGraphMsgHandler via
PeerManager. Instead, remove the event entirely and move the contained
data (renamed NetworkUpdate) to Event::PaymentFailed to be processed by
an event handler.
2021-09-15 11:50:27 -05:00
Tibo-lg
2c6a078d2c Add node id to custom message callback 2021-09-15 09:29:29 +09:00
Matt Corallo
3f9efe717b Move CounterpartyForwardingInfo from channel to channelmanager
CounterpartyForwardingInfo is public (previously exposed with a
`pub use`), and used inside of ChannelCounterparty in
channelmanager.rs. However, it is defined in channel.rs, away from
where it is used.

This would be fine, except that the bindings generator is somewhat
confused by this - it doesn't currently support interpreting
`pub use` as a struct to expose, instead ignoring it.

Fixes https://github.com/lightningdevkit/ldk-garbagecollected/issues/44
2021-09-13 17:31:59 +00:00
Matt Corallo
de9fba82f2
Merge pull request #1072 from TheBlueMatt/2021-09-tighter-max_fee-constant
Reduce our stated max closing-transaction fee to be the true value
2021-09-13 16:42:36 +00:00
Matt Corallo
ce3a04ba1a
Merge pull request #1073 from gilescope/less-deps 2021-09-13 04:22:26 +00:00
Giles Cope
b74ab25b61
Not needed now. We refer to std::futures. 2021-09-11 20:11:10 +01:00
Jeffrey Czyz
bd3ee0ab3d
Fail with PERM|8 (permanent_channel_failure)
This affects the htlc_fail_async_shutdown test.
2021-09-09 23:11:12 -05:00
Jeffrey Czyz
a6749d582d
Remove test_invalid_channel_announcement
It doesn't seem to be testing anything useful that isn't covered
elsewhere.
2021-09-09 23:11:12 -05:00
Jeffrey Czyz
798cf6ea83
Add a read-only view of NetworkGraph
Hide the internal locking of NetworkGraph by providing a read-only
view. This way the locking order is handled internally.
2021-09-09 23:11:12 -05:00
Jeffrey Czyz
16ad7f17a1
Remove RwLock from around NetworkGraph
Now that NetworkGraph uses interior mutability, the RwLock used around
it in NetGraphMsgHandler is no longer needed. This allows for shared
ownership without a lock.
2021-09-09 23:11:09 -05:00
Jeffrey Czyz
777661ae52
Individually lock NetworkGraph fields
In preparation for giving NetworkGraph shared ownership, wrap individual
fields in RwLock. This allows removing the outer RwLock used in
NetGraphMsgHandler.
2021-09-09 23:01:28 -05:00
Jeffrey Czyz
a6e650630d
Pass Event by reference to EventHandler
Passing an Event by reference rather and by move gives more flexibility
for composing event handlers without needing to clone events.
2021-09-09 22:57:51 -05:00
Matt Corallo
b348d9cb60 Reduce our stated max closing-transaction fee to be the true value
When communicating the maximum fee we're willing to accept on a
cooperative closing transaction to our peer, we currently tell them
we'll accept `u64::max_value()` if they're the ones who have to pay
it. Spec-wise this is fine - they aren't allowed to try to claim
our balance, and we don't care how much of their own funds they
want to spend on transaction fees.

However, the Eclair folks prefer to check all values on the wire
do not exceed 21 million BTC, which seems like generally good
practice to avoid overflows and such issues. Thus, our close
messages are rejected by Eclair.

Here we simply relax our stated maximum to be the real value - our
counterparty's current balance in satoshis.

Fixes #1071
2021-09-10 00:24:58 +00:00
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