Ran
|
Files
48
|
Run time
2s
|
Badge
Embed ▾
README BADGES
|
push
github
Merge bitcoindevkit/bdk#1579: fix(wallet): only mark change address used if `create_tx` succeeds 606fa0874 ci: bump actions/upload-artifact to v4 (valued mammal) 75989d8cd test(wallet): Add `test_create_tx_increment_change_index` (valued mammal) b60d1d29c fix(wallet): only mark change address used if `create_tx` succeeds (valued mammal) Pull request description: 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 this PR 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. With this PR we only mark the change address used if we successfully create a psbt and the drain script is used in the change output. fixes #1578 ### Notes to the reviewers An early idea was to unmark the change address used if we fail to create a tx due to `InsufficientFunds`, but after looking into it I figure it doesn't totally make sense to mark the address used before we've determined that a change output is necessary. Further, `create_tx` can fail in other ways besides running coin selection, so I moved the `mark_used` logic to the end of the function. ### Changelog notice Fixed an issue that caused an unused internal address to be skipped when creating transactions (#1578) ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) * [x] I ran `cargo fmt` and `cargo clippy` before committing #### Bugfixes: * [x... (continued)
11101 of 13582 relevant lines covered (81.73%)
14145.81 hits per line
Coverage | ∆ | File | Lines | Relevant | Covered | Missed | Hits/Line |
---|