Commit Graph

541 Commits

Author SHA1 Message Date
Keagan McClelland
31d45757a4
contractcourt: properly detect RBF coop close transactions
This commit fixes an issue where we did not properly detect and
therefore record the coop close transaction if it used the newer
RBF coop close v2 scheme. This only affects coop closes of
taproot channels today.
2024-07-17 14:48:20 -07:00
Yong
286ee95735
Merge pull request #8800 from ProofOfKeags/bugfix/8535
contractcourt: consider delivery addresses when evaluating toSelfAmount
2024-06-12 01:06:36 +08:00
Keagan McClelland
30e10322b2 contractcourt: consider delivery addresses when evaluating toSelfAmount
This commit fixes #8535 by changing how we assess toSelfAmount inside
the chainWatcher.

In certain cases users may wish to close out channel funds to external
delivery addresses set either during open or close.

Prior to this change we only consider addresses that our wallet is
aware of.

This change now identifies outputs as to_self outputs if the delivery
script matches OR if our wallet is aware of the address. In certain
edge cases it can be possible for there to be more than one output
that matches these criteria and in that case we will return the sum
of those values.
2024-06-10 11:38:17 -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
yyforyongyu
8da68bb7db
multi: apply the new type lntypes.WeightUnit 2024-05-25 13:37:13 +08:00
yyforyongyu
e45db07a10
contractcourt+itest: make sure ChannelArbitrator has the latest htlcs 2024-05-21 00:53:23 +08:00
yyforyongyu
1470adbed2
contractcourt: share deadlines between CPFP anchors and HTLCs
This commit changes how the deadline is calculated for CPFP anchor
sweeping. In order to sweep the second-level HTLCs, we need to first
get the FC tx confirmed. If we use a larger conf target for CPFP, we'd
end up having few blocks to sweep the HTLCs, as these two sweeping txns
share the deadline of the HTLC, as shown below,
```
More aggressive on the CPFP part.
|-CPFP-|-----HTLC-----|

Share the deadlines evenly.
|---CPFP---|---HTLC---|

More aggressive on the HTLC part.
|-----CPFP-----|-HTLC-|
```
In this commit, we decide to share the deadlines evenly as a starting
point so neither side will have a short of deadlines.
2024-05-18 07:45:09 +08:00
Carla Kirk-Cohen
776c889267
multi: return route role from HopPayload
We need to know what role we're playing to be able to handle errors
correctly, but the information that we need for this is held by our
iterator:
- Whether we had a blinding point in update add (blinding kit)
- Whether we had a blinding point in payload

As we're now going to use the route role return value even when our
err!=nil, we rename the error to signal that we're using less
canonical golang here.

An alternative to this approach is to attach a RouteRole to our
ErrInvalidPayload. The downside of that approach is:
- Propagate context through parsing (whether we had updateAddHtlc)
- Clumsy handling for errors that are not of type ErrInvalidPayload
2024-04-25 09:46:31 -04:00
erik
619c8f4eb8 multi: repleace ioutil.ReadAll 2024-04-25 11:21:18 +02:00
Oliver Gugger
5cf700d611
Merge pull request #8658 from hidewrong/master
chore: fix struct names
2024-04-24 10:56:20 -06:00
yyforyongyu
9c5124e117
sweep: remove unused param Fee 2024-04-23 04:44:00 +08:00
yyforyongyu
f5a321d0d3
contractcourt: remove unused param to please linter 2024-04-19 21:33:39 +08:00
yyforyongyu
49cfb91af1
contractcourt: make sure sweep happens immediately on startup
This commit makes sure the time-sensitive outputs are swept immediately
during startup.
2024-04-19 21:33:39 +08:00
yyforyongyu
9be5b370a7
sweep+contractcourt: replace ParamsUpdate with Params 2024-04-19 21:33:38 +08:00
yyforyongyu
30c2b9f2df
itest: fix channel backup tests 2024-04-19 21:33:36 +08:00
yyforyongyu
acde08c65a
contractcourt: offer second-level outputs at CSV-1
This commit moves the offering of second-level outputs one block
earlier. The sweeper will check the required locktime and wait until it
matures. This is needed so the second-level outputs can be aggregated
properly.
2024-04-19 21:33:35 +08:00
yyforyongyu
c644deb49f
contractcourt: add locks in SubscribeChannelEvents 2024-04-19 21:33:35 +08:00
yyforyongyu
07466c4f8c
multi: query circuit map inside contractcourt
This commit adds a new config method `QueryIncomingCircuit` that can be
used to query the payment's incoming circuit for giving its outgoing
circuit key.
2024-04-19 21:33:35 +08:00
yyforyongyu
dc7d90c16f
contractcourt+sweep: offer direct-preimage spend via SweepInput
This commit removes the method `CreateSweepTx` and makes sure when
sweeping the htlc output via the direct-preimage spend, it's offered via
the `SweepInput` interface.
2024-04-19 21:33:35 +08:00
yyforyongyu
9c1e6941c3
contractcourt: specify deadline and budget for nursery 2024-04-19 21:33:34 +08:00
yyforyongyu
33abbe1942
contractcourt+lnd: make IncubateOutputs take fn.Option
`IncubateOutputs` never takes more than one HTLC, so we change the
params to be optional, which helps with the following commit where we
pass the deadline height when incubating outgoing HTLCs.
2024-04-19 21:33:34 +08:00
yyforyongyu
6f0c2b5bab
contractcourt: specify deadline and budget for anchor output 2024-04-19 21:33:34 +08:00
yyforyongyu
f4035ade05
contractcourt: calculate value left when searching for commit deadline
This commit changes `findCommitmentDeadline` to
`findCommitmentDeadlineAndValue` to calculate the value left from all
the time-sensitive HTLCs after subtracting their budgets. This value is
then used to calculate the budget to be used when sweeping the anchor
output.
2024-04-19 21:33:34 +08:00
yyforyongyu
cab180a52e
contractcourt: specify deadline and budget for htlc timeout 2024-04-19 21:33:34 +08:00
yyforyongyu
d1ad07fa21
contractcourt+lnwallet: specify deadline and budget for htlc success 2024-04-19 21:33:33 +08:00
yyforyongyu
01fd4e5642
contractcourt: specify deadline and budget for commit sweep 2024-04-19 21:33:33 +08:00
yyforyongyu
aa44197f88
contractcourt: init BudgetConfig in unit tests 2024-04-19 21:33:33 +08:00
yyforyongyu
0a611aae00
multi: add new config option BudgetConfig and NoDeadlineConfTarget
This commit adds a new group config `BudgetConfig` to allow users
specifying their own preference when sweeping outputs. And a new config
option `NoDeadlineConfTarget` is added in case the user wants to use a
different "lazy" conf target.
2024-04-19 21:33:33 +08:00
yyforyongyu
e771993785
multi: make input.OutPoint return wire.OutPoint 2024-04-19 21:33:32 +08:00
yyforyongyu
90e727a776
sweep: add monitor loop to TxPublisher
This commit finishes the implementation of `TxPublisher` by adding the
monitor process. Whenever a new block arrives, the publisher will check
all its monitored records and attempt fee bumping them if necessary.
2024-04-19 21:33:29 +08:00
yyforyongyu
a8f5a09dea
sweep: don't give up an input based on number of attempts
This commit removes the logic where we remove an input when it's been
published more than 10 times. This is needed as in our future fee
bumper, we might start with a low fee and rebroadcast the same input for
hundred of blocks.
2024-04-19 21:33:23 +08:00
yyforyongyu
3bcac318eb
sweep+lnrpc: add new interface FeePreference
This commit adds a new interface `FeePreference` which makes it easier
to write unit tests and allows more customized implementation in
following commits.
2024-04-19 21:33:21 +08:00
yyforyongyu
530eed92a0
multi: rename FeePreference to FeeEstimateInfo
Results from running,
```
gofmt -d -w -r 'FeePreference -> FeeEstimateInfo' .
```
2024-04-19 21:33:21 +08:00
yyforyongyu
84a6fdcda3
sweep+contractcourt: track best height in UtxoSweeper
Thus we can use shorter method signatures. In doing so we also remove an
old TODO in one use case of `CreateSweepTx`.
2024-04-19 21:33:20 +08:00
hidewrong
8afb978c81 chore: fix struct names
Signed-off-by: hidewrong <hidewrong@outlook.com>
2024-04-17 11:19:31 +08:00
Oliver Gugger
648fb22f63
multi: wrap all errors 2024-04-11 15:04:03 +02:00
Carla Kirk-Cohen
1e6fae37f7
htlcswitch: add blinding point to sphinx iterator for decoding 2024-04-03 08:52:25 -04:00
Carla Kirk-Cohen
4a93f4d8d3
multi: pass blinding point through to reconstruction 2024-03-27 09:38:59 -04:00
Keagan McClelland
fd1cd315ce multi: don't leak underlying pointer to LightningChannel.ChannelPoint() 2024-03-08 15:27:19 -08:00
Keagan McClelland
e9b3808c29 lnwallet+contractcourt: remove redundant ChanPoint field 2024-03-07 14:16:16 -08: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
Keagan McClelland
0f245bf237 contractcourt: rename breacharbiter*.go to breach_arbitrator
This is just to finish the cleaning things up to make them more
consistent.
2024-02-06 13:32:51 -07:00
Keagan McClelland
bc3feba267 contractcourt+lnrpc+lnd: s/BreachArbiter/BreachArbitrator
Since we have two other examples of XArbitrator, we rename
BreachArbiter to BreachArbitrator to keep things consistent.
The aim is to reduce the amount of lore you need to know to
intuit where things are or what they do.
2024-02-06 13:32:47 -07:00
Olaoluwa Osuntokun
d44c72b979
Merge pull request #8345 from yyforyongyu/use-testmempoolaccept
lnwallet: perform mempool acceptance check before publishing
2024-01-26 18:54:43 -08:00
Keagan McClelland
9b92b55b9b contractcourt: rename files for package consistency 2024-01-24 17:15:01 -08:00
yyforyongyu
a6a8415a26
contractcourt: make sure ChainArbitrator is started properly
We should not fail to start the node if a republish attempt failed for a
channel's closing tx. Instead, we log an error to continue the startup
and let other channels continue their operations.
2024-01-25 07:54:39 +08:00
Slyghtning
8c04c1e7ce
contractcourt: log amount if incoming htlc times out 2023-11-08 09:56:03 +01:00
yyforyongyu
971d3d8d9c
contractcourt: make sure isPreimageSpend won't panic
This commit adds a length check in `isPreimageSpend` to make sure it
won't ever panic and adds a unit test to verify it.
2023-10-31 01:44:43 +08:00
Jonathan Harvey-Buschel
6edd1e1220
multi: add GetBlockHeader to BlockChainIO 2023-10-27 11:05:27 -04:00
Yong
939375f1a5
sweeper: relax anchor sweeping when there's no deadline pressure (#7965)
* sweep: use longer variable name for clarity in `addToState`

* sweeper: add more docs and debug logs

* sweep: prioritize smaller inputs when adding wallet UTXOs

This commit sorts wallet UTXOs by their values when using them for
sweeping inputs. This way we'd avoid locking large UTXOs when sweeping
inputs and also provide an opportunity to aggregate wallet UTXOs.

* contractcourt+itest: relax anchor sweeping for CPFP purpose

This commit changes from always sweeping anchor for a local force close
to only do so when there is an actual time pressure. After this change,
a forced anchor sweeping will only be attempted when the deadline is
less than 144 blocks.

* docs: update release notes

* itest: update test `testMultiHopHtlcLocalChainClaim` to skip CPFP

Since we now only perform CPFP when both the fee rate is higher and the
deadline is less than 144, we need to update the test to reflect that
Bob will not CPFP the force close tx for the channle Alice->Bob.

* itest: fix `testMultiHopRemoteForceCloseOnChainHtlcTimeout`

* itest: update related tests to reflect anchor sweeping

This commit updates all related tests to reflect the latest anchor
sweeping behavior. Previously, anchor sweeping is always attempted as
CPFP when a force close is broadcast, while now it only happens when the
deadline is less than 144. For non-CPFP purpose sweeping, it will happen
after one block is mined after the force close transaction is confirmed
as the anchor will be resent to the sweeper with a floor fee rate, hence
making it economical to sweep.
2023-10-12 17:18:59 +02:00