Commit Graph

106 Commits

Author SHA1 Message Date
Slyghtning
a6b4135781
funding: fix logs 2024-01-11 19:39:11 +01:00
Elle Mouton
84cdcd6847
multi: move DB schemas to channeldb/models
This commit moves the ChannelEdgePolicy, ChannelEdgeInfo,
ChanelAuthProof and CachedEdgePolicy structs to the `channeldb/models`
package.
2023-11-08 14:50:35 +02:00
Olaoluwa Osuntokun
4f346060df
Merge pull request #8067 from lightningnetwork/0-18-staging-rebased
branch: merge 0.18 staging branch into master
2023-10-09 11:20:11 -07:00
Yong
ec2377db79
funding: remove dead code and sanity check pending chan ID (#7887)
* funding: remove unused field `newChanBarriers`

This commit removes the occurance of `newChanBarriers` as it's not used
anywhere.

* funding: rename method names to clear the funding flow

Slightly refactored the names so it's easier to see which side is
processing what messages.

* lnwallet: sanity check empty pending channel ID

This commit adds a sanity check to make sure an empty pending channel ID
will not be accepted.
2023-10-09 10:58:18 +02:00
yyforyongyu
66b8700c0b multi: add debug logs to catch slow shutdown 2023-10-06 16:34:47 -07:00
Elle Mouton
031dbd7760 multi: remove ChainRegistry 2023-10-06 16:34:47 -07:00
Elle Mouton
3912d5a0c6 multi: remove Litecoin config options
This commit removes the `Litecoin`, `LtcMode` and `LitecoindMode`
members from the main LND `Config` struct. Since only the bitcoin
blockchain is now supported, this commit also deprecates the
`cfg.Bitcoin.Active` config option.
2023-10-06 16:34:47 -07:00
eugene
0cf3552515
funding: wait for coinbase maturity before sending channel_ready 2023-09-21 11:33:38 -04:00
Olaoluwa Osuntokun
92da6b1d44
multi: fix linter warnings with updated linter 2023-08-22 16:34:47 -07:00
Olaoluwa Osuntokun
384b1b1c12
feature: use +100 staging bit for taproot channels
In this commit, we carry out a new notion introduced during a recent
spec meeting to use a feature bit plus 100 before the feature has been
finalized in the spec.

We split into the Final and Staging bits.
2023-08-22 16:34:28 -07:00
Olaoluwa Osuntokun
7d7513aa3c
routing+funding: add new makeFundingScript to support reg and taproot channels
In this commit, we start to set _internally_ a new feature bit in the
channel announcements we generate. As these taproot channels can only be
unadvertised, this will never actually leak to the public network. The
funding manager will then set this field to allow the router to properly
validate these channels.
2023-08-22 16:32:10 -07:00
Olaoluwa Osuntokun
15978a8691
funding+peer: add support for new musig2 channel funding flow
In this commit, we add support for the new musig2 channel funding flow.
This flow is identical to the existing flow, but not both sides need to
exchange local nonces up front, and then signatures sent are now partial
signatures instead of regular signatures.

The funding manager also gains some new state of the local nonces it
needs to generate in order to send the funding locked message, and also
process the funding locked message from the remote party.

In order to allow the funding manger to generate the nonces that need to
be applied to each channel, then AddNewChannel method has been modified
to accept a set of options that the peer will then use to bind the
nonces to a new channel.
2023-08-22 16:32:07 -07:00
yyforyongyu
0a6b05d2de
funding: catching barrier signal in receivedChannelReady
There is a race condition,
- goroutine_1: performing `stateStep` under `channelReadySent`. Once
  `receivedChannelReady` returns true, it will mark the channel state as
  `addedToRouterGraph`, which will delete the initial forwarding policy
  for private channels.
- goroutine_2: performing `handleChannelReady`, which processes the
  remote's channelReady message. It will ask brontide to `AddNewChannel`
  in the end.
- goroutine_3: performing `handleNewActiveChannel` in brontide, which
  will query the initial forwarding policy and fail to find it because
  it's already deleted in goroutine_1.

To fix it, we require `receivedChannelReady` to also check that the
channel's barrier signal in the map `handleChannelReadyBarriers` doesn't
exist, as this signal is removed once `handleChannelReady` finishes
adding the channel in brontide.
2023-08-22 09:52:49 +08:00
yyforyongyu
32d8208272
funding: add new method handleChannelReadyReceived
This commit is a pure code move. We add a new method
`handleChannelReadyReceived` to handle the channel's state change after
the remote's channel ready message is received.
2023-08-22 09:52:46 +08:00
yyforyongyu
d9e0464929
funding: defer initial forwarding policy deletion
This commit moves the deletion of the initial forwarding policy to the
end of `stateStep` to make sure the router has persisted it to disk
before the deletion.
2023-08-22 08:21:53 +08:00
yyforyongyu
38b106ccf3
funding: rename channelReady to channelReadySent for clarity 2023-08-22 07:04:17 +08:00
Oliver Gugger
d822d75f00
server+funding: remove previous link update mechanism
Because we now send the correct initial forwarding policy to Brontide,
the correct initial values are inserted into the link and we no longer
need to update the link in a later step.
2023-08-22 06:22:34 +08:00
Oliver Gugger
7ac445caaf
funding: make sure initial policy is always set 2023-08-22 06:22:34 +08:00
Oliver Gugger
d5c504c8de
multi: use fwding policy from models pkg 2023-08-22 06:22:33 +08:00
Oliver Gugger
59b5fb1565
channeldb+funding: move policy encoding into channel DB 2023-08-22 06:22:33 +08:00
Oliver Gugger
36fcf65e97
funding+channeldb: rename fwding -> forwarding 2023-08-18 09:44:23 +02:00
Oliver Gugger
4770cb0aaf
manager: also store initial time lock delta and HTLC settings
This will allow us to also set the TimeLockDelta and HTLC settings
when creating the channel. We leave the actual implementation of
the RPC and CLI changes to another PR, this is just to make
things more consistent.
2023-08-18 09:44:06 +02:00
Oliver Gugger
5b9aa63cec
funding: extract defaultForwardingPolicy 2023-08-18 09:44:06 +02:00
Oliver Gugger
665179ece2
funding+server: don't use wallet DB for channel operations
Since the actual wallet backends might be different between the wallet
DB and the actual channel state DB, we pass in the correct struct to the
funding manager.
2023-08-18 09:44:05 +02:00
Olaoluwa Osuntokun
c6a68d193c
Merge pull request #7177 from morehouse/fix_chantype_negotiation
funding: fix channel type negotiation bug
2023-08-14 17:15:52 -07:00
yyforyongyu
0dd2aa0aef
multi: add itest to check race between channel_ready and update_add_htlc
This commit adds a new itest case to check the race condition found in
issue #7401. In order to control the funding manager's state, a new dev
config for the funding manager is introduced to specify a duration we
should hold before processing remote node's channel_ready message.

A new development config, `DevConfig` is introduced in `lncfg` and will
only have effect if built with flag `integration`. This can also be
extended for future integration tests if more dev-only flags are needed.
2023-08-09 01:29:19 +08:00
yyforyongyu
927572583b
multi: remove pending channel from Brontide when funding flow failed
This commit adds a new interface method, `RemovePendingChannel`, to be
used when the funding flow is failed after calling `AddPendingChannel`
such that the Brontide has the most up-to-date view of the active
channels.
2023-08-09 01:29:18 +08:00
yyforyongyu
3ed579d06f
funding: make failFundingFlow takes both channel IDs
This commit adds a new struct `chanIdentifier` which wraps the pending
channel ID and active channel ID. This struct is then used in
`failFundingFlow` so the channel ID can be access there.
2023-08-09 01:29:18 +08:00
yyforyongyu
e46bd8e177
multi: add AddPendingChannel to peer interface
The funding manager has been updated to use `AddPendingChannel`. Note
that we track the pending channel before it's confirmed as the peer may
have a block height in the future(from our view), thus they may start
operating in this channel before we consider it as fully open.

The mocked peers have been updated to implement the new interface method.
2023-08-09 00:17:22 +08:00
Slyghtning
e4f0e58214
lnd: handles selected outpoints in parseOpenChannelReq 2023-07-24 13:06:59 +02:00
yyforyongyu
a66d42c682
funding: use SyncMap to simplify map usage 2023-06-27 20:19:37 +08:00
Maxwell Sayles
9dea695079 funding: make MaxWaitNumBlocksFundingConf public to be used to compute
`FundingExpiryBlocks`.
2023-06-12 10:04:04 -07:00
shaurya947
db44924c5a
lnwallet: add Memo to InitFundingReserveMsg
We also pass the value of Memo from funding/manager.go.
2023-05-18 13:02:30 -04:00
shaurya947
7c6faa4c98
funding: add Memo to InitFundingMsg struct
We add byte-array field called Memo to the InitFundingMsg struct.
We also provide a value for this from
rpcserver.go#parseOpenChannelReq().
2023-05-18 13:02:30 -04:00
Matt Morehouse
a8a50f32f5
funding: fix channel type negotiation bug
The bug manifests when a nil ChannelType is passed to the funding
manager in InitFundingMsg. A default value for ChannelType is selected
and sent in the OpenChannel message. However, a nil ChannelType is
stored in the reservation context. This causes our ChannelType checks in
handleFundingAccept to be bypassed.

Usually this makes us end up in the "peer unexpectedly sent explicit
ChannelType" case, where we can still recover by reselecting a default
ChannelType and verifying it matches the one the peer sent. But if the
peer sends a nil ChannelType, we miss it.

While fixing the bug, I also tried to simplify the negotiation logic, as
the complexity is likely what hid the bug in the first place.

Now negotiateCommitmentType only returns the ChannelType to be used in
OpenChannel/AcceptChannel and the CommitmentType to pass to the wallet.
It will even return a nil ChannelType when we're supposed to use implicit
negotiation, so we don't need to manually set it to nil for OpenChannel
and AcceptChannel.
2023-05-17 11:28:40 -05:00
Matt Morehouse
34186dee19
funding: remove incorrect and repetitive comments
We don't actually do the logging described in the first comment, and the
second comment block repeats much of the first comment block.
2023-05-17 11:27:41 -05:00
Matt Morehouse
e59cd7f91d
funding: stop naming commit types chanType
negotiateCommitmentType returns both a chanType and a commitType, so it
is really confusing when the commitType is called chanType instead.
2023-05-17 11:27:41 -05:00
Carla Kirk-Cohen
3f9f0ea5d1
multi/refactor: separate methods for get and set node announcement
In preparation for a more complex function signature for set node
announcement, separate get and set so that readonly callers don't need
to handle the extra arguments.
2023-05-04 10:35:42 -04:00
Elle Mouton
ef17b12a86
funding: update "funding locked" in error string
Replace a few uncaught instances of "funding locked" found in error
strings with "channel_ready"
2023-04-27 20:03:44 +02:00
Elle Mouton
9ea3f55694
multi: update "funding locked" comments
Replace a few un-caught instances of "funding locked" in some comments
with "channel_ready"
2023-04-27 20:02:34 +02:00
Elle Mouton
784dc8d530
funding: use default fwding policy if persisted values not found
In this commit, a bug is fixed in the funding manager that could result
in the funding process erroring out if the persisted initial forwarding
policy is not found. This could occur if a node restarts after opening a
channel that is not yet fully confirmed and also upgrades their node
from a pre-0.16 version to 0.16 since the values are only expected to be
persisted after 0.16.
2023-04-19 11:51:32 +02:00
Oliver Gugger
af70af2710
funding+server: update switch after sending channel update
With this commit we give the funding manager the ability to inform the
switch about custom channel policies, right after we've announced the
channel to the network.
This change is necessary because before #6753 a channel could only be
opened with the default forwarding policies, so the switch automatically
had the "correct" default values. Since #6753 added the ability to
specify forwarding policies at channel open time, we announced those
policies to the network but never updated the switch to inform it about
the changed policies (previously changing the policies was only possible
through the UpdateChannelPolicy RPC which did call the switch).
2023-04-18 09:40:18 +02:00
Slyghtning
5d88693852 lnd+lnwallet: fundmax flag for openchannel 2023-04-05 23:09:11 +02:00
Bjarne Magnussen
0e5b3e77cb lnd: handles the FundMax field inside parseOpenChannelReq
Adds handling of the `FundMax` field when parsing an
`OpenChannelRequest` with `rpcServer.parseOpenChannelReq`.
2023-04-05 23:05:07 +02:00
yyforyongyu
dc3f83c670
funding+lnwire: rename and fix make lint
Fix linter and rename `funding_locked.go` to `channel_ready.go`
2023-03-17 18:21:59 +08:00
yyforyongyu
d4ad5f362f
funding: replace fundingLocked found in docs
This commit is created by running,
```shell
find . -name "*.go" -exec sed -i '' 's/fundingLocked/channelReady/g' {} \;
```
2023-03-17 18:21:59 +08:00
yyforyongyu
465285efb8
funding: replace fundingLocked with channelReady 2023-03-17 18:21:59 +08:00
yyforyongyu
6b9217acfc
multi: replace FundingLocked related docs
This commit replaces `FundingLocked` found in docs using the following
command,
```shell
find . -name "*.go" -exec sed -i '' 's/FundingLocked/ChannelReady/g' {} \;
find . -name "*.go" -exec sed -i '' 's/FundingLock/ChannelReady/g' {} \;
```
2023-03-17 18:21:59 +08:00
yyforyongyu
f8a8326141
multi: replace FundingLocked and funding_locked strings
This commit is created by running the following commands,
```shell
find . -name "*.go" -exec sed -i '' 's/\"FundingLocked/\"ChannelReady/g' {} \;
find . -name "*.go" -exec sed -i '' 's/FundingLocked\"/ChannelReady\"/g' {} \;
find . -name "*.go" -exec sed -i '' 's/\ funding_locked/\ channel_ready/g' {} \;
```
2023-03-17 18:21:59 +08:00
yyforyongyu
539cae1999
multi: rename fundingLockedMsg to channelReadyMsg
This commit is created by running,
```shell
gofmt -d -w -r 'fundingLockedMsg -> channelReadyMsg' .
```
2023-03-17 18:21:59 +08:00