-
Notifications
You must be signed in to change notification settings - Fork 321
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
Add CreateTxError and use as error type for TxBuilder::finish() #1028
Add CreateTxError and use as error type for TxBuilder::finish() #1028
Conversation
f19ce86
to
0bbb998
Compare
17b3987
to
d99e4a5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for taking this on!
I appreciate your attempt to be conservative in the amount of changes made. However, the current state of this PR does not result in a better API since the caller still has to handle a large list of redundant error variants.
If it was a PR to purely remove the .expect("TODO")
s, I would just return a bdk::Error::Generic
or introduce a new variant in bdk::Error
.
However, I would prefer this PR to fix the error-handling API for tx creation completely (as it seems you already have done the majority of the work).
But we probably just need a quick fix for the next release. |
be04de6
to
cc4ba36
Compare
I added fallible |
I removed the
|
Per comment: #1025 (comment) I'm moving this to future alpha release. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 on adding CreateTxError
. left some comments.
@notmandatory we didn't talk about this PR in the last calls. Is it correct to keep it into alpha.3 milestone? Shall we discuss it in the next call? |
I don't think we need to discuss it until after alpha.2 is released. Then I'll have to rebase it and fix a few small things and will bug folks for a re-review. |
26ce0fa
to
55e2c9f
Compare
I've removed the cfg for fmt::Display and created a new issue for that change (if we want to do it). Tests passing and ready for re-review. |
55e2c9f
to
1014b87
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made minor comments, but nothing that should block this from moving forward
39476fb
to
626bdf0
Compare
I pushed a couple more commits to add changes suggested by @ValuedMammal. I'll squash commits to clean up the history prior to merging. |
Hey! This needs fixing too, "not enough" bdk/crates/bdk/src/descriptor/policy.rs Line 524 in d6a0cf0
|
626bdf0
to
35a108b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just nits. LGTM. ACK 35a108b
92f8579
to
1ec4716
Compare
I don't think this should be addressed in this PR, but I think we should use idiomatic naming for methods: https://rust-lang.github.io/api-guidelines/naming.html#getter-names-follow-rust-convention-c-getter I.e. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 35a108b
Thank you for this work. Now the errors are more domain-specific and detailed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic work, than you.
I think Lloyd's comment should be fixed, as it should be fairly trivial. I left a comment on that.
Ohhhh! 🤦♂️ thanks for the help here, now I get it. I'm going to push your fix, rebase, clean up the history a little, and then it should be ready to merge. |
6f570ed
to
d36bafe
Compare
…ror mod refactor(bdk)!: remove impl_error macro refactor(wallet)!: add MiniscriptPsbtError, CreateTxError, BuildFeeBumpError error enums refactor(coin_selection)!: add module Error enum test(bdk): use anyhow dev-dependency for all tests
…ss functions refactor!(wallet)!: rename fallible Wallet try_get_address(), try_get_internal_address functions
d36bafe
to
77f9977
Compare
I made the requested fix (with some help from Daniela)
Description
To remove some places where there were
.expect("TODO")
I added a newCreateTxError
type which is returned fromTxBuilder::finish()
. I also updated related tests and doc tests.Fixes #996 (comment)
Also added fallible
Wallet::try_get_address()
andtry_get_internal_address()
to returnResult
with a possibleD:WriteError
when a PersistBackend is used. This should fix #996.I removed catch-all bdk::Error and replaced usages with new types and updated related functions, fixes #994.
Notes to the reviewers
I didn't add all possible bdk::Error types thatWallet::create_tx()
andTxBuilder::finish()
functions might throw. It's probably not too much more work but will take a bit more research so I want to make sure this is the right general approach first.I added
anyhow
to the dev-dependencies so I could remove some.expect()
lines from the docs tests and make the examples closer to what an end user should do. I also used theanyhow!()
macro to replace a few places that were using thebdk::Error::Generic
in example code.I also moved the module level error.rs file to wallet/error.rs so no one would be tempted to make any new catch all errors and to make it clear that all the errors in it are wallet module related.
Changelog notice
Changed
Removed
Added
Checklists
All Submissions:
cargo fmt
andcargo clippy
before committingBugfixes: