Skip to content

Commit 0e65fff

Browse files
committed
evert changes to changelog and impl FinalizeContext
1 parent a56edeb commit 0e65fff

15 files changed

Lines changed: 62 additions & 88 deletions

File tree

flake.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@
6969
doCheck = false; # skip testing, since that's done in flake check
7070
};
7171

72-
fileSetForCrate = mailbox:
72+
fileSetForCrate = subdir:
7373
pkgs.lib.fileset.toSource {
7474
root = ./.;
7575
fileset = pkgs.lib.fileset.unions [
7676
./Cargo.toml
77-
(craneLib.fileset.commonCargoSources mailbox)
77+
(craneLib.fileset.commonCargoSources subdir)
7878
];
7979
};
8080

payjoin-cli/src/app/v1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl AppTrait for App {
6969
let (req, ctx) = SenderBuilder::new(psbt, uri.clone())
7070
.build_recommended(fee_rate)
7171
.with_context(|| "Failed to build payjoin request")?
72-
.extract_v1();
72+
.create_v1_post_request();
7373
let http = http_agent()?;
7474
let body = String::from_utf8(req.body.clone()).unwrap();
7575
println!("Sending fallback request to {}", &req.url);

payjoin-cli/src/app/v2/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,9 @@ impl App {
208208
sender: Sender<WithReplyKey>,
209209
persister: &SenderPersister,
210210
) -> Result<()> {
211-
let (req, ctx) = sender
212-
.create_v2_post_request(self.unwrap_relay_or_else_fetch(Some(sender.endpoint().clone())).await?)?;
211+
let (req, ctx) = sender.create_v2_post_request(
212+
self.unwrap_relay_or_else_fetch(Some(sender.endpoint().clone())).await?,
213+
)?;
213214
let response = post_request(req).await?;
214215
println!("Posted original proposal...");
215216
let sender = sender.process_response(&response.bytes().await?, ctx).save(persister)?;
@@ -514,4 +515,4 @@ fn map_reqwest_err(e: reqwest::Error) -> anyhow::Error {
514515
Some(status_code) => anyhow!("HTTP request failed: {} {}", status_code, e),
515516
None => anyhow!("No HTTP response: {}", e),
516517
}
517-
}
518+
}

payjoin-directory/src/db.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,24 +71,15 @@ impl DbPool {
7171
self.peek_with_timeout(mailbox_id, PJ_V1_COLUMN).await
7272
}
7373

74-
async fn push(
75-
&self,
76-
mailbox_id: &ShortId,
77-
channel_type: &str,
78-
data: Vec<u8>,
79-
) -> Result<()> {
74+
async fn push(&self, mailbox_id: &ShortId, channel_type: &str, data: Vec<u8>) -> Result<()> {
8075
let mut conn = self.client.get_async_connection().await?;
8176
let key = channel_name(mailbox_id, channel_type);
8277
() = conn.set(&key, data.clone()).await?;
8378
() = conn.publish(&key, "updated").await?;
8479
Ok(())
8580
}
8681

87-
async fn peek_with_timeout(
88-
&self,
89-
mailbox_id: &ShortId,
90-
channel_type: &str,
91-
) -> Result<Vec<u8>> {
82+
async fn peek_with_timeout(&self, mailbox_id: &ShortId, channel_type: &str) -> Result<Vec<u8>> {
9283
match tokio::time::timeout(self.timeout, self.peek(mailbox_id, channel_type)).await {
9384
Ok(redis_result) => match redis_result {
9485
Ok(result) => Ok(result),

payjoin-ffi/python/test/test_payjoin_integration_test.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,7 @@ async def test_integration_v2_to_v2(self):
159159
# Create a funded PSBT (not broadcasted) to address with amount given in the pj_uri
160160
pj_uri = session.pj_uri()
161161
psbt = build_sweep_psbt(self.sender, pj_uri)
162-
new_sender = SenderBuilder(psbt, pj_uri).build_recommended(1000)
163-
persister = InMemorySenderPersister()
164-
token = new_sender.persist(persister)
165-
req_ctx: WithReplyKey = WithReplyKey.load(token, persister)
162+
req_ctx: WithReplyKey = SenderBuilder(psbt, pj_uri).build_recommended(1000).save(sender_persister)
166163
request: RequestV2PostContext = req_ctx.create_v2_post_request(ohttp_relay.as_string())
167164
response = await agent.post(
168165
url=request.request.url.as_string(),

payjoin-ffi/src/receive/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl InitInputsTransition {
8787
}
8888
}
8989

90-
pub struct x(
90+
pub struct UninitializedReceiver(
9191
payjoin::receive::v2::Receiver<payjoin::receive::v2::UninitializedReceiver>,
9292
);
9393

@@ -208,7 +208,7 @@ impl
208208
}
209209
}
210210

211-
impl WithContext {
211+
impl Initialized {
212212
pub fn create_poll_request(&self, ohttp_relay: String) -> Result<(Request, ClientResponse), Error> {
213213
self.0
214214
.clone()
@@ -218,8 +218,8 @@ impl WithContext {
218218
}
219219

220220
///The response can either be an UncheckedProposal or an ACCEPTED message indicating no UncheckedProposal is available yet.
221-
pub fn process_response(&self, body: &[u8], ctx: &ClientResponse) -> WithContextTransition {
222-
WithContextTransition(Arc::new(RwLock::new(Some(
221+
pub fn process_response(&self, body: &[u8], ctx: &ClientResponse) -> InitializedTransition {
222+
InitializedTransition(Arc::new(RwLock::new(Some(
223223
self.0.clone().process_response(body, ctx.into()),
224224
))))
225225
}

payjoin-ffi/src/receive/uni.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ impl InitializedTransitionOutcome {
271271

272272
#[uniffi::export]
273273
impl Initialized {
274-
/// The contents of the `&pj=` query parameter including the base64url-encoded public key receiver subdirectory.
274+
/// The contents of the `&pj=` query parameter including the base64url-encoded public key receiver mailbox.
275275
/// This identifies a session at the payjoin directory server.
276276
pub fn pj_uri(&self) -> crate::PjUri { self.0.pj_uri() }
277277

@@ -282,8 +282,8 @@ impl Initialized {
282282
}
283283

284284
///The response can either be an UncheckedProposal or an ACCEPTED message indicating no UncheckedProposal is available yet.
285-
pub fn process_res(&self, body: &[u8], context: Arc<ClientResponse>) -> InitializedTransition {
286-
InitializedTransition(self.0.process_res(body, &context))
285+
pub fn process_response(&self, body: &[u8], context: Arc<ClientResponse>) -> InitializedTransition {
286+
InitializedTransition(self.0.process_response(body, &context))
287287
}
288288

289289
pub fn to_json(&self) -> Result<String, SerdeJsonError> { self.0.to_json() }
@@ -730,7 +730,7 @@ impl PayjoinProposal {
730730
///
731731
/// After this function is called, the receiver can either wait for the Payjoin transaction to be broadcast or choose to broadcast the original PSBT.
732732
pub fn process_res(&self, body: &[u8], ctx: Arc<ClientResponse>) -> PayjoinProposalTransition {
733-
PayjoinProposalTransition(self.0.process_res(body, ctx.as_ref()))
733+
PayjoinProposalTransition(self.0.process_response(body, ctx.as_ref()))
734734
}
735735
}
736736

payjoin-ffi/src/send/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,6 @@ impl WithReplyKeyTransition {
208208
}
209209

210210
impl WithReplyKey {
211-
pub fn extract_v1(&self) -> (Request, V1Context) {
212-
let (req, ctx) = self.0.clone().extract_v1();
213-
}
214211
pub fn create_v1_post_request(&self) -> (Request, V1Context) {
215212
let (req, ctx) = self.0.clone().create_v1_post_request();
216213
(req.into(), ctx.into())

payjoin-ffi/src/send/uni.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -222,20 +222,6 @@ impl WithReplyKeyTransition {
222222

223223
#[uniffi::export]
224224
impl WithReplyKey {
225-
pub fn extract_v1(&self) -> RequestV1Context {
226-
let (req, ctx) = self.0.extract_v1();
227-
}
228-
#[uniffi::constructor]
229-
pub fn load(
230-
token: Arc<SenderToken>,
231-
persister: Arc<dyn SenderPersister>,
232-
) -> Result<Self, ImplementationError> {
233-
Ok(super::WithReplyKey::from(
234-
(*persister.load(token).map_err(|e| ImplementationError::from(e.to_string()))?).clone(),
235-
)
236-
.into())
237-
}
238-
239225
pub fn create_v1_post_request(&self) -> RequestV1Context {
240226
let (req, ctx) = self.0.create_v1_post_request();
241227
RequestV1Context { request: req, context: Arc::new(ctx.into()) }

payjoin-ffi/tests/bdk_integration_test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ mod v2 {
316316
.send()
317317
.await?;
318318
let proposal = session
319-
.process_res(&response.bytes().await?, &client_response)
319+
.process_response(&response.bytes().await?, &client_response)
320320
.save(&recv_session_persister)?
321321
.success()
322322
.expect("proposal should exist");
@@ -330,7 +330,7 @@ mod v2 {
330330
.send()
331331
.await?;
332332
payjoin_proposal
333-
.process_res(&response.bytes().await?, &client_response)
333+
.process_response(&response.bytes().await?, &client_response)
334334
.save(&recv_session_persister)?;
335335

336336
// **********************

0 commit comments

Comments
 (0)