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

Don't double-spend unspendable inputs #559

Merged
merged 2 commits into from
Nov 20, 2023
Merged

Conversation

t-bast
Copy link
Member

@t-bast t-bast commented Nov 20, 2023

When filtering inputs that can be used for swaps, we filter out all the inputs that are already used in pending funding transactions. However, we ignored previously confirmed funding transactions, assuming that our electrum server would have already filtered them from our wallet state.

Unfortunately, we cannot assume that our electrum server is up-to-date (especially if we connect to a different one after a restart) and behaving correctly, so we must also exclude inputs use in the latest confirmed funding transaction.

When filtering inputs that can be used for swaps, we filter out all the
inputs that are already used in pending funding transactions. However,
we ignored previously confirmed funding transactions, assuming that our
electrum server would have already filtered them from our wallet state.

Unfortunately, we cannot assume that our electrum server is up-to-date
(especially if we connect to a different one after a restart) and behaving
correctly, so we must also exclude inputs use in the latest confirmed
funding transaction.
@t-bast t-bast requested a review from pm47 November 20, 2023 13:07
Copy link
Member

@pm47 pm47 left a comment

Choose a reason for hiding this comment

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

LGTM, but why did you remove the factorization on fundingTx.tx.localInputs.map { it.outPoint }?

@t-bast
Copy link
Member Author

t-bast commented Nov 20, 2023

Because this isn't using the same type anymore, we cannot factor ConfirmedFundingTx which only has a Transaction, not a SharedTransaction.

Copy link
Member

@pm47 pm47 left a comment

Choose a reason for hiding this comment

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

Because this isn't using the same type anymore, we cannot factor ConfirmedFundingTx which only has a Transaction, not a SharedTransaction.

You could stil factor on Transaction, but I suppose you didn't want to call sharedTx.tx.buildUnsignedTx()? Anyway that's fine.

@t-bast
Copy link
Member Author

t-bast commented Nov 20, 2023

You could stil factor on Transaction, but I suppose you didn't want to call sharedTx.tx.buildUnsignedTx()?

Exactly, we'd be losing information if we did that, and would be including remote inputs as well.
When we only have a Transaction we can't avoid it, but when we can, I think we should, it's more correct that way.

@t-bast t-bast merged commit f1a09ce into master Nov 20, 2023
2 checks passed
@t-bast t-bast deleted the fix-reserved-wallet-inputs branch November 20, 2023 14:09
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.

2 participants