Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(wallet): only mark change address used if
create_tx
succeeds
If no drain script is specified in tx params then we get it from the change keychain by looking at the next unused address. Before, we marked the index used regardless of whether a change output is finally added. Then if creating a psbt failed, we never restored the unused status of the change address, so creating the next tx would have revealed an extra one. We want to mark the change address used so that other callers won't attempt to use the same address between the time we create the tx and when it appears on chain. Now we only mark the change address used if we successfully create a psbt and the drain script is used in the change output.
- Loading branch information