(4.0) fix: return structured insufficient funds errors - #1069
Conversation
thunderbiscuit
left a comment
There was a problem hiding this comment.
I'm trying to dig into this one and I think we might have had an extra variant that cannot be hit?
If you look at the CreateTxError in Rust, you find a CreateTxError::CoinSelection variant: https://docs.rs/bdk_wallet/3.1.0/bdk_wallet/error/enum.CreateTxError.html#variant.CoinSelection. This variant contains the InsufficientFunds struct.
Here instead we have InsufficientFunds as an error variant, and the CreateTx::CoinSelection variant can never really be returned anywhere as far as I see.
I think we can't return full structs inside our errors (wait can we with the new 0.31? need to check), and in my mind the CreateTxError::InsufficientFunds we are currently using is the most intuitive way to return this to the user (rather than putting the fields on a CreateTxError::CoinSelection variant), but just want to point it out, and suggest we remove the CreateTxError::CoinSelection variant as part of this PR.
|
Ok following up on this:
|
|
Agree. Adding to 4.0 tracking, and we can get this just how we want it for 4.0 |
Description
We already expose a structured
CreateTxError::InsufficientFundscontainingneededandavailableamounts.Currently are converting the errors into the generic string based CoinSelection variant though.
So this PR just maps the upstream amounts to the existing
InsufficientFundsand adds regression coverage.Notes to the reviewers
Documentation
bdk_wallethttps://docs.rs/bdk_wallet/3.1.0/bdk_wallet/coin_selection/struct.InsufficientFunds.html
https://docs.rs/bdk_wallet/3.1.0/src/bdk_wallet/wallet/coin_selection.rs.html#123-132
https://docs.rs/bdk_wallet/3.1.0/bdk_wallet/error/enum.CreateTxError.html#variant.CoinSelection
bitcoinuniffiChangelog
Checklists
All Submissions:
cargo fmtandcargo clippybefore committingchangelog:*labelNew Features:
Bugfixes: