Repository navigation
Conversation
Kixunil
left a comment
There was a problem hiding this comment.
I don't understand what problem you're trying to solve by putting data into type state. It looks like you only do it to get specific errors of the same type, so that user doesn't need to define an error type. This could be solved by just providing the error type.
Note that my idea was for checking code to be written like this:
let proposal = UncheckedProposal::from_request(...)?;
let tx = proposal.get_transaction_to_check_broadcast();
// do testmempoolaccept call with tx
if !broadcastable {
// We could simply allow writing return Err(proposal.not_broadcastable()) to generate error with context.
return Err(MyError::NotBroadcastableError);
}
let proposal = proposal.assume_broadcastability_was_verified();
// ... same style for other checks
| /// Validate a [`PartiallySignedTransaction`] by checking transaction inputs number are equal to the | ||
| /// psbt inputs and the same for outputs. Note deserialization already have this guarantee (TODO verify) | ||
| #[derive(Clone, Debug)] | ||
| pub struct Validated; |
There was a problem hiding this comment.
Validated sounds like all checks were finished. Perhaps call it Consistent?
| Err(PsbtError::UnequalInputCounts { tx_ins, psbt_ins, }) | ||
| } else if psbt_outs != tx_outs { | ||
| Err(PsbtError::UnequalOutputCounts { tx_outs, psbt_outs, }) | ||
| } else { |
support std::convert::TryFrom
Yes, I know. My intention was to have one check per state to be less error prone for users |
Any particular reason? I don't see how
That was already the case wasn't it? Maybe I misunderstand? |
Yeah maybe it's just missing the check if inputs are owned
Yeah maybe is unnecessary complication |
Abstract receive into a library
Remake of #19 that should be agnostic about sync/async
It's similar to the original but has one state for every needed check
Can't use PhantomData to represent the state because it needs to store at least a boolean
Very WIP, just wanted to have feedback before continuing here