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

PSBT Creation: Change Address Index Skipped on InsufficientFunds #1578

Closed
zhj4478 opened this issue Aug 27, 2024 · 1 comment · Fixed by #1579
Closed

PSBT Creation: Change Address Index Skipped on InsufficientFunds #1578

zhj4478 opened this issue Aug 27, 2024 · 1 comment · Fixed by #1579
Assignees
Labels
bug Something isn't working
Milestone

Comments

@zhj4478
Copy link

zhj4478 commented Aug 27, 2024

Describe the bug

When I create a PSBT using TxBuilder, we typically add the recipients, amounts, and other necessary data, and everything works as expected. However, sometimes when we receive an InsufficientFunds exception, the change address index increases, causing it to be skipped in next call to create_psbt, which then selects a new unused one.

In the create_psbt function and noticed that the latest unused index in the KeychainKind::Internal is marked as used first, but when the InsufficientFunds exception occurs, it doesn’t reset back to unused.

please take a look thx

@zhj4478 zhj4478 added the bug Something isn't working label Aug 27, 2024
@notmandatory notmandatory added this to the 1.0.0-beta milestone Aug 27, 2024
@ValuedMammal
Copy link
Contributor

Thanks @zhj4478 Indeed it seems wrong to mark the change address used before we're certain the tx can be created without error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants