Commit Graph

167 Commits

Author SHA1 Message Date
Elle Mouton
743502f99d
funding: rename from router graph to graph 2024-07-15 15:56:33 +02:00
Elle Mouton
7f1be39d45
refactor: move various duties from ChannelRouter to graph.Builder
This commit is a large refactor that moves over various responsibilities
from the ChannelRouter to the graph.Builder. These include all graph
related tasks such as:
- graph pruning
- validation of new network updates & persisting new updates
- notifying topology update clients of any changes.

This is a large commit but:
- many of the files are purely moved from `routing` to `graph`
- the business logic put in the graph Builder is copied exactly as is
  from the ChannelRouter with one exception:
- The ChannelRouter just needs to be able to call the Builder's
  `ApplyChannelUpdate` method. So this is now exported and provided to
the ChannelRouter as a config option.
- The trickiest part was just moving over the test code since quite a
  bit had to be duplicated.
2024-07-15 15:56:33 +02:00
Elle Mouton
1c65c3d072
funding: allow AcceptChannel with min depth of zero
Even if the channel type is not zero conf. We will still use a min depth
of at least 1. We just dont fail if our peer indicates trust.
2024-06-27 15:26:34 -07:00
yyforyongyu
78cc1619d7
multi: fix complaints from IDE and linter
Fixed unused param and nilness cond.
2024-06-07 00:45:15 +08:00
zoupingshi
30047feb35 chore: fix some comments
Signed-off-by: zoupingshi <hellocatty@tom.com>
2024-05-31 15:16:33 +08:00
Oliver Gugger
2a8ca878fd
Merge pull request #8663 from Filiprogrammer/funding-manager-log-errors
funding: add absent error logs for failed inbound funding requests
2024-05-20 15:23:32 +02:00
Filiprogrammer
593a564332
funding: enhance error logs for failed inbound funding requests
For failed inbound funding requests, add missing error logs and make
sparse error logs more descriptive.
2024-05-11 14:56:37 +02:00
ziggie
351e9a68dd
multi: Add tests to psbt and normal open channel flow.
Itests were added to the normal channel funding flow and the psbt
funding flow using unstable (unconfirmed sweeper inputs).
2024-04-24 13:58:20 +01:00
ziggie
62a52b4d7c
multi: Utxo restriction single funding case.
Restrict the utxo selection when opening a single internal wallet
funded backed channel.
2024-04-24 13:58:19 +01:00
Oliver Gugger
648fb22f63
multi: wrap all errors 2024-04-11 15:04:03 +02:00
Mohamed Awnallah
1a2d50d385
multi: add coin selection strategy option to all on-chain rpcs
In this commit, we add the coin selection strategy option to the following
on-chain RPCs `fundpsbt`, `batchopenchannel`, `estimatefee`, `sendcoins`,
`sendmany`, and `sendoutputs`.
2024-04-01 19:08:22 +02:00
Keagan McClelland
db39a905cb multi: make NewChanIDFromOutpoint accept value instead of pointer 2024-03-08 15:47:55 -08:00
Olaoluwa Osuntokun
cac779b69e
funding: send warning to remote peer if chan nonce missing on reest 2024-02-29 11:32:31 -06:00
Olaoluwa Osuntokun
7feb8b21e1
multi: upgrade new taproot TLVs to use tlv.OptionalRecordT
In this commit, we update new Taproot related TLVs (nonces, partial sig,
sig with nonce, etc). Along the way we were able to get rid of some
boiler plate, but most importantly, we're able to better protect against
API misuse (using a nonce that isn't initialized, etc) with the new
options API. In some areas this introduces a bit of extra boiler plate,
and where applicable I used some new helper functions to help cut down
on the noise.

Note to reviewers: this is done as a single commit, as changing the API
breaks all callers, so if we want things to compile it needs to be in a
wumbo commit.
2024-02-29 11:32:26 -06:00
ffranr
cd566eb097
multi: fix fmt.Errorf error wrapping
Refactor fmt.Errorf usage to correctly wrap errors instead of using
non-wrapping format verbs.
2024-02-27 11:13:40 +00:00
Oliver Gugger
cbc11dac8f
multi: add coin selection strategy to channel funding
With this commit we prepare for the lnwallet channel funding logic to be
aware of the config-level coin selection strategy by adding it to the
wallet config.
2024-02-23 08:58:07 +01:00
Keagan McClelland
fb8de14798 lnwallet+funding+lnd: trim unused parameters, from lnwallet.Config
chainreg: remove unused GenDefaultBtcConstraints

lnwallet+funding+lnd: remove DefaultDustLimit from lnwallet.Config
2024-02-19 17:06:21 -08:00
Elle
08c18a338b
Merge pull request #8275 from ProofOfKeags/chore/enforce-feature-bits
multi: make legacy feature bits compulsory
2024-01-18 17:26:09 +02:00
Keagan McClelland
109265c77a multi: make static remote key compulsory 2024-01-11 13:58:01 -08:00
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
Oliver Gugger
b0bb853f77
Merge pull request #8092 from yyforyongyu/fix-peer-unit-test
multi: fix peer unit test and disable `paralleltest`
2023-10-17 10:18:27 +00:00
yyforyongyu
0532b82dd5
multi: add new method FeePerVByte to avoid manual conversion 2023-10-13 17:00:53 +08:00
yyforyongyu
22600b47f1
multi: disable linter paralleltest 2023-10-13 13:50:09 +08: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
8f20cd82fb
funding: add TestFundingManagerCoinbase test
This tests that the funding manager doesn't immediately consider
a coinbase transaction that is also a funding transaction usable
until the maturity has been reached.
2023-09-21 11:33:42 -04: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
3f8d33d7ab
funding: add SIMPLE_TAPROOT case to TestCommitmentTypeFundmaxSanityCheck 2023-08-22 16:34:36 -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
dd05dd55d4
funding: add explicit chan type support for zeroconf+scid+taproot
We also remove the old implicit negotiation as well, as we'll be
updating tests to use explciit when required.
2023-08-22 16:34:20 -07:00
Olaoluwa Osuntokun
d98136e850
funding: add support for implicit negotiation for taproot chans
Otherwise, in the itests (which are mainly based on implicit
negotiation), we won't try to open taproot chans when we actually need
to.

We may want to revisit this however, since it may lock in parties trying
to use the defaults that aren't currently setting the explicit commit
type during funding.
2023-08-22 16:33:52 -07:00
Olaoluwa Osuntokun
9f6ed65d80
funding: add unit tests for reg+zero conf taproot chans 2023-08-22 16:32:27 -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
Olaoluwa Osuntokun
a8416300dd
funding: update explicitNegotiateCommitmentType to recognize taproot chans 2023-08-22 16:32:05 -07:00
yyforyongyu
6820b08b53
funding: put assertNoFwdingPolicy in wait.NoError 2023-08-22 11:10:15 +08: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