-
Notifications
You must be signed in to change notification settings - Fork 39
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
Implement Serverless Payjoin BIP #101
Conversation
bb4c1f2
to
9230962
Compare
b47590c
to
bb2b531
Compare
bb2b531
to
d742829
Compare
c999b55
to
5834266
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.
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
payjoin/src/uri.rs
Outdated
} 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
payjoin/Cargo.toml
Outdated
@@ -17,6 +17,7 @@ exclude = ["tests"] | |||
[features] | |||
send = [] | |||
receive = ["rand"] | |||
relay = [] |
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.
this is never used
payjoin-relay/tests/integration.rs
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
payjoin-relay/Cargo.toml
Outdated
reqwest = { version = "0.11.4" } No newline at end of file | ||
reqwest = { version = "0.11.4" } |
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.
sp
payjoin-relay/src/main.rs
Outdated
@@ -103,28 +111,50 @@ impl From<hyper::http::Error> for HandlerError { | |||
fn from(e: hyper::http::Error) -> Self { HandlerError::InternalServerError(e.into()) } | |||
} | |||
|
|||
async fn post_enroll(body: Body) -> Result<Response<Body>, HandlerError> { | |||
use payjoin::{base64, bitcoin}; |
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.
these dependencies are independent reexports of payjoin. consider depending on them directly
@@ -207,7 +265,10 @@ enum InternalPjParseError { | |||
MultipleParams(&'static str), | |||
MissingEndpoint, | |||
NotUtf8(core::str::Utf8Error), | |||
NotBase64(bitcoin::base64::DecodeError), |
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.
cfg feature v2 only?
payjoin/src/v2.rs
Outdated
@@ -1,7 +1,6 @@ | |||
use std::{error, fmt}; | |||
|
|||
pub const MAX_BUFFER_SIZE: usize = 65536; | |||
pub const RECEIVE: &str = "receive"; |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose the loops could be contained within one function that takes this line as a closure
payjoin/src/receive/v2.rs
Outdated
use std::fmt; | ||
use std::str::FromStr; | ||
|
||
use serde::de::{self, Deserializer, MapAccess, SeqAccess, Visitor}; |
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.
should be at file top
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: