TxOrdering::Untouched no longer ensures the order of tx input #244
Description
Activity
Sorry for the late reply. You're right, I over sighted the importance of the insertion order. However, I would like to explore a solution that does not include an extra dependency just for this case. I will try to think in something else.
- added 2 commits that reference this issue
on Jun 9, 2025 Also, coin selection has no guarantee of maintaining the ordering. There are two solutions to this:
- the coin selection should only be allowed to return "additional" UTXOs so that the downstream code can guarantee the order is maintained
- the coin selection trait should require implementations to maintain the order of required UTXOs to be at the start.
Currently this line in the default bnb coin selection algorithm is violating that (but it's also not part of the
CoinSelectioncontract):selected_utxos.append(&mut required_utxos); I think opting for the first option would be best.
- added a commit that references this issue
on Jun 23, 2025 Also, coin selection has no guarantee of maintaining the ordering. There are two solutions to this:
* the coin selection should only be allowed to return "additional" utxos so that the downstream code can guarantee the order is maintained * the coin selection trait should require implementations to maintain the order of required vtxos to be at the start.I think opting for the first option would be best.
I agree coin selection should only return additional UTxOs, and is something which has been already proposed before (look at the third point of the changelog of this old PR).
TxBuilderis expected to be replaced bybdk-tx, so its going to only receive fixes from now on, mainly.As
bdk-txis leaning towards usingbdk-coin-select. As long as I can tell, is also providing the required UTxOs to the selection algorithms.If
bdk-coin-selectis not already doing what you propose, I think the change should be there.Reacted by Steven Roose- added a commit that references this issue
on Jun 23, 2025 Currently this line in the default bnb coin selection algorithm is violating that (but it's also not part of the
CoinSelectioncontract):Still it clearly looks like a bug and should probably be fixed. It would make sense to have a test for every coin-select algo that manually selected inputs come first as long as we specify a tx ordering of
Untouched.Reacted by nymius- An easy "fix" for the default algorithm is to swap the order in that line I linked. Then at least the default algo does what is expected.…On 6/24/25 6:27 PM, ValuedMammal ***@***.***> wrote: *ValuedMammal* left a comment (bitcoindevkit/bdk_wallet#244) <https:// github.com/bitcoindevkit/bdk_wallet/issues/244#issuecomment-3001297252> Currently this line in the default bnb coin selection algorithm is violating that (but it's also not part of the |CoinSelection| contract): Still it clearly looks like a bug and should probably be fixed. It would make sense to have a test for every coin-select algo that manually selected inputs come first as long as we specify a tx ordering of | Untouched|. — Reply to this email directly, view it on GitHub <https://github.com/ bitcoindevkit/bdk_wallet#244#issuecomment-3001297252>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ AAGQLXFIHXYXQIBAJE45E7T3FGC7FAVCNFSM6AAAAAB55ULKQGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTAMBRGI4TOMRVGI>. You are receiving this because you commented.Message ID: <bitcoindevkit/ ***@***.***>
- added 2 commits that reference this issue
on Jun 25, 2025 - added a commit that references this issue
on Jun 29, 2025 - added a commit that references this issue
on Jul 1, 2025 - added a commit that references this issue
on Apr 22, 2026
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Describe the bug
Since add_utxo of build_tx in 1.2.0 uses hashmap to contain input, TxOrdrering cannot ensure that the order is not changed.
To Reproduce
Expected behavior
Build environment
Additional context
bdk_wallet/crates/wallet/src/wallet/tx_builder.rs
Line 128 in 5817ed0