Implement Serverless Payjoin BIP - #101
Conversation
bb4c1f2 to
9230962
Compare
b47590c to
bb2b531
Compare
bb2b531 to
d742829
Compare
c999b55 to
5834266
Compare
jbesraa
left a comment
There was a problem hiding this comment.
So I just did a review to understand the implementation and link it the actual BIP. I went through the BIP again also while reviewing this so it is a great refreshment. the code is quite readable and its not too hard to link to the different parts of the BIP.
I added a few comments to make sure I get things correctly. Ill review this a couple of more times and might have a bit more code/design input then.
5834266 to
b46dac1
Compare
b46dac1 to
38f7dc1
Compare
9eb5cfc to
aca9982
Compare
b44a085 to
c0ce861
Compare
28cef51 to
e66f80d
Compare
| } else if endpoint.scheme() == "http" { | ||
| Ok(Payjoin::V2Only(PayjoinParams { | ||
| _endpoint: endpoint, | ||
| disable_output_substitution: pjos.unwrap_or(false), | ||
| })) |
There was a problem hiding this comment.
Although v2 is secure with plain http because sender - receiver communications are e2ee using hpke, it adds complexity to the library and specifically THIS PR which is now only used in places which also support https
| [features] | ||
| send = [] | ||
| receive = ["rand"] | ||
| relay = [] |
| let http = reqwest::Client::builder() | ||
| .danger_accept_invalid_certs(true) | ||
| .build() | ||
| .expect("Failed to build reqwest http client"); |
There was a problem hiding this comment.
Although reqwest is easier to use with tokio than ureq, it's a new dep and makes comparing this to the existing integration more burdenome
| reqwest = { version = "0.11.4" } No newline at end of file | ||
| reqwest = { version = "0.11.4" } |
| } | ||
|
|
||
| async fn post_enroll(body: Body) -> Result<Response<Body>, HandlerError> { | ||
| use payjoin::{base64, bitcoin}; |
There was a problem hiding this comment.
these dependencies are independent reexports of payjoin. consider depending on them directly
| MultipleParams(&'static str), | ||
| MissingEndpoint, | ||
| NotUtf8(core::str::Utf8Error), | ||
| NotBase64(bitcoin::base64::DecodeError), |
| use std::{error, fmt}; | ||
|
|
||
| pub const MAX_BUFFER_SIZE: usize = 65536; | ||
| pub const RECEIVE: &str = "receive"; |
There was a problem hiding this comment.
this can actually be removed in the postgres / subdir introduction
| message_a: &mut [u8], | ||
| s: SecretKey, | ||
| ) -> Result<(Vec<u8>, PublicKey), Error> { | ||
| pub fn decrypt_message_a(message_a: &[u8], s: SecretKey) -> Result<(Vec<u8>, PublicKey), Error> { |
There was a problem hiding this comment.
can this be immutable from the getgo?
| #[cfg(feature = "v2")] | ||
| async fn long_poll_post(&self, req_ctx: payjoin::send::RequestContext<'_>) -> Result<Psbt> { | ||
| loop { | ||
| let (req, ctx) = req_ctx.extract_v2(&self.config.ohttp_proxy)?; |
There was a problem hiding this comment.
I suppose the loops could be contained within one function that takes this line as a closure
| use std::fmt; | ||
| use std::str::FromStr; | ||
|
|
||
| use serde::de::{self, Deserializer, MapAccess, SeqAccess, Visitor}; |
e66f80d to
ee76271
Compare
ee76271 to
7d08034
Compare
34d16e0 to
e386f4f
Compare
Use postgres and hyper to store and notify clients' updates.
e386f4f to
97c5adf
Compare
97c5adf to
f81f401
Compare
|
This functionality is complete and includes comprehensive testing However it is rought around the edges and could be a bit more organized with module separation. I'm going to merge it to consider new organizations in independent pull requests |
The latest spec: bitcoin/bips#1483
Ongoing design discussion: https://delvingbitcoin.org/t/serverless-payjoin-protocol-design/96
Refactors for better production quality
[ ] Remove workspace (used to simplify testing & features)Prior Attempts: