Skip to content

Commit 195c6e5

Browse files
arminsabouriDanGould
authored andcommitted
Use IntoUrl for ohttp_relay argument
Switching to `IntoUrl` makes the function more ergonomic by allowing a broader range of URL-like inputs. This also simplifies bindings, as strings can be passed directly without extra conversion.
1 parent 7f27656 commit 195c6e5

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

payjoin/src/send/multiparty/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::ohttp::ohttp_decapsulate;
1313
use crate::output_substitution::OutputSubstitution;
1414
use crate::send::v2::V2PostContext;
1515
use crate::uri::UrlExt;
16-
use crate::{ImplementationError, PjUri, Request};
16+
use crate::{ImplementationError, IntoUrl, PjUri, Request};
1717

1818
mod error;
1919
mod persist;
@@ -38,7 +38,7 @@ pub struct Sender(v2::Sender);
3838
impl Sender {
3939
pub fn extract_v2(
4040
&self,
41-
ohttp_relay: Url,
41+
ohttp_relay: impl IntoUrl,
4242
) -> Result<(Request, PostContext), CreateRequestError> {
4343
let rs = self
4444
.0
@@ -117,7 +117,7 @@ impl GetContext {
117117
/// Extract the GET request that will give us the psbt to be finalized
118118
pub fn extract_req(
119119
&self,
120-
ohttp_relay: Url,
120+
ohttp_relay: impl IntoUrl,
121121
) -> Result<(Request, ohttp::ClientResponse), crate::send::v2::CreateRequestError> {
122122
self.0.extract_req(ohttp_relay)
123123
}
@@ -175,7 +175,7 @@ pub struct FinalizeContext {
175175
impl FinalizeContext {
176176
pub fn extract_req(
177177
&self,
178-
ohttp_relay: Url,
178+
ohttp_relay: impl IntoUrl,
179179
) -> Result<(Request, ohttp::ClientResponse), CreateRequestError> {
180180
let reply_key = self.hpke_ctx.reply_pair.secret_key();
181181
let body = serialize_v2_body(

payjoin/src/send/v2/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ impl Sender {
169169
/// and has no fallback to v1.
170170
pub fn extract_v2(
171171
&self,
172-
ohttp_relay: Url,
172+
ohttp_relay: impl IntoUrl,
173173
) -> Result<(Request, V2PostContext), CreateRequestError> {
174174
if let Ok(expiry) = self.v1.endpoint.exp() {
175175
if std::time::SystemTime::now() > expiry {
@@ -225,13 +225,14 @@ impl Sender {
225225
}
226226

227227
pub(crate) fn extract_request(
228-
ohttp_relay: Url,
228+
ohttp_relay: impl IntoUrl,
229229
reply_key: HpkeSecretKey,
230230
body: Vec<u8>,
231231
url: Url,
232232
receiver_pubkey: HpkePublicKey,
233233
ohttp_keys: &mut OhttpKeys,
234234
) -> Result<(Request, ClientResponse), CreateRequestError> {
235+
let ohttp_relay = ohttp_relay.into_url()?;
235236
let hpke_ctx = HpkeContext::new(receiver_pubkey, &reply_key);
236237
let body = encrypt_message_a(
237238
body,

0 commit comments

Comments
 (0)