Repository navigation
Conversation
Kixunil
left a comment
There was a problem hiding this comment.
The reason I started modeling it as type-based state machine is I didn't want to assume sync vs async. That trait now forces it to be sync which goes against the goals of the crate.
It may be little less comfortable to write for some people but I think the difference is minimal and it's also somewhat counter-balanced by not having to write trait-impl-related boilerplate.
| } | ||
|
|
||
| pub fn create_uri(address: &Address, amount: &Amount, pj: &str) -> String { | ||
| format!("{}?amount={}&pj={}", address.to_qr_uri(), amount.as_btc(), pj) |
There was a problem hiding this comment.
FTR, this needs to be URL encoded.
There was a problem hiding this comment.
Are we going to add URL dep? for this and for #3 ?
There was a problem hiding this comment.
IDK, I would really, really like to move BIP21 to bitcoin and folks there are mostly averse to dependencies. I think encoding is not that hard to do manually if we have to.
There was a problem hiding this comment.
I thought we can have BIP21 stuff without URL but with Extras inside rust-bitcoin and then this payjoin separated repo leveraging BIP21 parsing but with a layer on top using also URL
There was a problem hiding this comment.
Encoding belongs to BIP21 because it's also used for description etc. If we use a dependency there it should be percent-encoding because url seems to have web semantics.
There was a problem hiding this comment.
are we sure we need to percent-encode pj?
it looks btcpay doesn't percent encode neither I found mention in the bip
Right, I didn't think about async... Did you consider implementing the state with phantom data? Something like: |
|
Yeah, having state as generic would be nicer. I didn't realize at first there are more states than two and then just kept adding them without more thinking. |
|
Is it naive to think you can provide something similar to the (or only one available through a feature) |
Probably yes, as async are not yet available in traits... However |
I was actually researching this topic in the past and concluded it's impossible to do without either loss of performance or having both GAT and a slightly different |
I don't get how you can mix it together, we provide the async version or the other, could you have a look at https://github.com/bitcoindevkit/bdk/blob/5cdc5fb58a4635ce6a302093c78b511255bbc1a3/macros/src/lib.rs#L89 ? I think providing a trait could make the work of implementers less error-prone |
|
I'm not familiar with
I don't see a huge difference. Could you provide a specific example where error is less likely with trait? |
Yeah maybe they are equally likely, I just feel that calling But yeah, now I am more convinced that maybe it's not worth the complexity of |
|
OK, let's use state approach. If someone comes up with strong reason to switch we can revisit it. |
On top of #17, see only a6aebbb
This is some WIP code (especially Errors and unwrap) but if you can give early feedback on receiver checks through the
Checkstrait it would be appreciated