Skip to content

Conversation

@hieblmi
Copy link
Collaborator

@hieblmi hieblmi commented Feb 28, 2025

This PR adds the ability to request signatures for higher fee versions of previously published withdrawal transactions.

@hieblmi hieblmi self-assigned this Feb 28, 2025
@hieblmi hieblmi marked this pull request as draft February 28, 2025 13:06
@hieblmi hieblmi force-pushed the resign-withdrawal branch 2 times, most recently from f868520 to 4031671 Compare March 5, 2025 13:01
@hieblmi hieblmi force-pushed the resign-withdrawal branch 2 times, most recently from 49e8c1d to 6b1f478 Compare March 19, 2025 12:33
@hieblmi hieblmi marked this pull request as ready for review March 19, 2025 12:35
@hieblmi hieblmi force-pushed the resign-withdrawal branch 13 times, most recently from 8eb6597 to 5151ca2 Compare March 25, 2025 16:15
@hieblmi hieblmi force-pushed the resign-withdrawal branch 4 times, most recently from 8a74aae to 91ea1cf Compare March 31, 2025 12:10
Copy link
Member

@bhandras bhandras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the iterations on the design 🎉

Copy link
Collaborator

@starius starius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
Few notes.

// We also avoid that the user selects a subset of previously
// clustered deposits for a fee bump. This would result in a
// different transaction shape.
allDeposits, err := m.cfg.DepositManager.GetActiveDepositsInState(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can avoid this call. Previously we got a transaction in deposits[i].FinalizedWithdrawalTx.
Can't we verify that the transaction has the same set of deposits as deposits?

If we make sure that all deposits are unique, we can just compare len(deposits) == len(prevTx.TxIn).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you, fixed

// the withdrawal transaction.
// Since we ensure above that the same ensemble of deposits is
// republished in case of a fee bump, it suffices if only one spent
// notifier is run, since if the first input is spent.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if loopd restarts after first withdrawal tx is published? Will it listen for spending after the restart?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, after a restart recoverWithdrawals will republish the latest version of the withdrawal tx and monitor the spending.

for _, d := range deposits {
err = m.cfg.DepositManager.UpdateDeposit(ctx, d)
if err != nil {
return "", "", err
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose to use fmt.Errorf to attach an error message to simplify debugging.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


confChan, errChan, err := m.cfg.ChainNotifier.RegisterConfirmationsNtfn(
ctx, &txHash, withdrawalPkScript, MinConfs,
int32(m.initiationHeight.Load()),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MinConfs is now not used. What if a reorg happens? Shouldn't we run RegisterConfirmationsNtfn after a successful spending (1 conf) before transitioning the deposit to Withdrawn state?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch, I re-added the confirmation listener.

!strings.Contains(err.Error(), "insufficient fee") {
if !strings.Contains(err.Error(), chain.ErrSameNonWitnessData.Error()) &&
!strings.Contains(err.Error(), "output already spent") &&
!strings.Contains(err.Error(), chain.ErrInsufficientFee.Error()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose to factor out this check to a function and reuse everywhere (e.g. in sweepbatcher package).

Also this commit should be squashed into commit staticaddr: allow rbf'ing withdrawal transactions.

@hieblmi hieblmi force-pushed the resign-withdrawal branch from 91ea1cf to 94fa46f Compare April 4, 2025 12:11
@hieblmi hieblmi force-pushed the resign-withdrawal branch 4 times, most recently from 1db759e to 0a0806d Compare April 9, 2025 15:44
@lightninglabs-deploy
Copy link

@sputn1ck: review reminder

@hieblmi hieblmi force-pushed the resign-withdrawal branch 3 times, most recently from b1ee0d2 to 80fff99 Compare April 28, 2025 14:24
@hieblmi hieblmi force-pushed the resign-withdrawal branch from 80fff99 to b5af507 Compare April 28, 2025 17:43
@hieblmi hieblmi merged commit 903266a into lightninglabs:master Apr 28, 2025
4 checks passed
@hieblmi hieblmi deleted the resign-withdrawal branch April 28, 2025 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants