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

Fix: Payjoin wasn't always properly choosing utxo for optimal change #4600

Merged
merged 2 commits into from Feb 7, 2023

Conversation

NicolasDorier
Copy link
Member

@NicolasDorier NicolasDorier commented Feb 6, 2023

This paper assert that lot's of payjoin transaction exhibit UIH2: Unnecessary input trait.

I was surprised as @Kukks made this PR a while ago #1473

By writing a proper test, I found out that the implementation was actually broken, and not always avoiding UIH2.
On top of it the implementation was suboptimal.

image

I also updated the tests.

Closing #4599

{
// UIH2: Unnecessary input, let's try to get an optimal change by using a different output
continue;
Copy link

Choose a reason for hiding this comment

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

I think this will loop without getting any closer to maxTries because it does not add to locked. Therefore maxTries is not the hard cap on tries it once was

Copy link
Member Author

Choose a reason for hiding this comment

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

This was on purpose, as this line doesn't make any DB roundtrip.
Irrelevant now, as I use a timeout.

Comment on lines 594 to 595
// We don't want to make too many db roundtrip which would be inconvenient for the sender
int maxTries = 30;
Copy link

@DanGould DanGould Feb 6, 2023

Choose a reason for hiding this comment

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

If the goal here is to accommodate the sender a timeout may make more sense. Default HTTP request range timeouts are 30 to > 100 seconds. A timeout of say 10s would be well within the acceptable range for every HTTP client I know of. That would allow you to account for other slowdowns, too.

@NicolasDorier
Copy link
Member Author

@DanGould indeed, will update code to use a timeout instead.

@NicolasDorier
Copy link
Member Author

Updated for timeout of 10s

@NicolasDorier NicolasDorier merged commit 6a4d8f7 into btcpayserver:master Feb 7, 2023
@NicolasDorier NicolasDorier deleted the fweioqn branch February 7, 2023 07:43
@DanGould
Copy link

Looks like the update applied a timeout of 30s, not 10s, but if it takes that long to search through utxos selection it would seem extraordinary to find a solution

https://github.com/NicolasDorier/btcpayserver/blob/7f9dd1c2f59c0802eb8fe280c8c0f1b3987682b2/BTCPayServer/Payments/PayJoin/PayJoinEndpointController.cs#L596

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.

None yet

3 participants