Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lnwallet/btcwallet: remove invalid transactions from the wallet when broadcast fails #2671

Merged
merged 2 commits into from
Mar 14, 2019

Conversation

wpaulino
Copy link
Contributor

@wpaulino wpaulino commented Feb 20, 2019

In this PR, we update our btcwallet dependency to the latest version, which includes some minor improvements to our error handling when broadcasting transactions.

Along the way, we also address a lingering issue within some subsystems that are responsible for broadcasting transactions. Previously, ErrDoubleSpend indicated that a transaction was already included in the mempool/chain. This error was then modified to actually be returned for conflicting transactions, but its callers were not modified accordingly. This would lead to conflicting transactions to be interpreted as valid, when they shouldn't be.

Depends on btcsuite/btcwallet#597.
Fixes #2657.

@wpaulino
Copy link
Contributor Author

There are two cases left which I cannot determine if they should also be ignoring ErrDoubleSpend:

if err != nil && err != lnwallet.ErrDoubleSpend {

if err != nil && err != lnwallet.ErrDoubleSpend {

cc @joostjager

@joostjager
Copy link
Contributor

Yes, they should be ignoring. The mechanism in sweeper is that it often tries to publish and if it is a double spend, it keeps retrying with exponential randomized back-off. This is to avoid making all kinds of mempool assumptions in the sweeper why a tx might be a double spend.

@joostjager
Copy link
Contributor

Even though the first case that you refer to is rebroadcasting an exact tx of ours, it may still be that it fails because there is a conflict.

@Roasbeef Roasbeef added wallet The wallet (lnwallet) which LND uses P2 should be fixed if one has time bug fix labels Mar 1, 2019
@Roasbeef
Copy link
Member

Roasbeef commented Mar 9, 2019

Needs a rebase now that the dependent PR is in.

@wpaulino
Copy link
Contributor Author

Will rebase this after we've caught up lnd with btcwallet and neutrino.

Copy link
Contributor

@halseth halseth left a comment

Choose a reason for hiding this comment

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

Nice! LGTM after dependency update 👍

The checks to determine whether the transaction broadcast failed due to
it already existing in the mempool/chain are no longer needed since the
underlying btcwallet PublishTransaction call will not return an error
when running into these cases.
In this commit, we address a lingering issue within some subsystems that
are responsible for broadcasting transactions. Previously,
ErrDoubleSpend indicated that a transaction was already included in the
mempool/chain. This error was then modified to actually be returned for
conflicting transactions, but its callers were not modified accordingly.
This would lead to conflicting transactions to be interpreted as valid,
when they shouldn't be.
@Roasbeef
Copy link
Member

Needs rebase now that the dep PR has been merged.

@wpaulino
Copy link
Contributor Author

Rebased.

Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

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

LGTM 🎮

@Roasbeef Roasbeef merged commit c1228ae into lightningnetwork:master Mar 14, 2019
@wpaulino wpaulino deleted the tx-broadcast-err-handling branch March 14, 2019 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fix P2 should be fixed if one has time wallet The wallet (lnwallet) which LND uses
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants