Skip to content

Commit d1c9c09

Browse files
committed
Cleanup comments and fix doc links
1 parent 0fabbf3 commit d1c9c09

File tree

5 files changed

+23
-17
lines changed

5 files changed

+23
-17
lines changed

payjoin-cli/src/app/v1.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ impl App {
319319
}
320320
})?;
321321
log::trace!("check2");
322-
// Receive Check 3: receiver can't sign for proposal inputs
322+
// Receive Check 3: no mixed input scripts
323323
let proposal = proposal.check_no_mixed_input_scripts()?;
324324
log::trace!("check3");
325325

payjoin-cli/src/app/v2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ impl App {
306306
}
307307
})?;
308308
log::trace!("check2");
309-
// Receive Check 3: receiver can't sign for proposal inputs
309+
// Receive Check 3: no mixed input scripts
310310
let proposal = proposal.check_no_mixed_input_scripts()?;
311311
log::trace!("check3");
312312

payjoin/src/receive/mod.rs

+13-5
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ impl UncheckedProposal {
165165

166166
/// Typestate to validate that the Original PSBT has no receiver-owned inputs.
167167
///
168-
/// Call [`check_no_receiver_owned_inputs()`](struct.UncheckedProposal.html#method.check_no_receiver_owned_inputs) to proceed.
168+
/// Call [`Self::check_inputs_not_owned`] to proceed.
169169
#[derive(Clone)]
170170
pub struct MaybeInputsOwned {
171171
psbt: Psbt,
@@ -208,8 +208,9 @@ impl MaybeInputsOwned {
208208
}
209209

210210
/// Typestate to validate that the Original PSBT has no mixed input types.
211+
/// This check is skipped in payjoin v2.
211212
///
212-
/// Call [`check_no_mixed_input_types`](struct.UncheckedProposal.html#method.check_no_mixed_input_scripts) to proceed.
213+
/// Call [`Self::check_no_mixed_input_scripts`] to proceed.
213214
#[derive(Clone)]
214215
pub struct MaybeMixedInputScripts {
215216
psbt: Psbt,
@@ -261,7 +262,7 @@ impl MaybeMixedInputScripts {
261262

262263
/// Typestate to validate that the Original PSBT has no inputs that have been seen before.
263264
///
264-
/// Call [`check_no_inputs_seen`](struct.MaybeInputsSeen.html#method.check_no_inputs_seen_before) to proceed.
265+
/// Call [`Self::check_no_inputs_seen_before`] to proceed.
265266
#[derive(Clone)]
266267
pub struct MaybeInputsSeen {
267268
psbt: Psbt,
@@ -295,7 +296,7 @@ impl MaybeInputsSeen {
295296
/// The receiver has not yet identified which outputs belong to the receiver.
296297
///
297298
/// Only accept PSBTs that send us money.
298-
/// Identify those outputs with `identify_receiver_outputs()` to proceed
299+
/// Identify those outputs with [`Self::identify_receiver_outputs`] to proceed.
299300
#[derive(Clone)]
300301
pub struct OutputsUnknown {
301302
psbt: Psbt,
@@ -345,6 +346,8 @@ impl OutputsUnknown {
345346
}
346347

347348
/// A checked proposal that the receiver may substitute or add outputs to
349+
///
350+
/// Call [`Self::commit_outputs`] to proceed.
348351
#[derive(Debug, Clone)]
349352
pub struct WantsOutputs {
350353
original_psbt: Psbt,
@@ -486,6 +489,8 @@ fn interleave_shuffle<T: Clone, R: rand::Rng>(
486489
}
487490

488491
/// A checked proposal that the receiver may contribute inputs to to make a payjoin
492+
///
493+
/// Call [`Self::commit_inputs`] to proceed.
489494
#[derive(Debug, Clone)]
490495
pub struct WantsInputs {
491496
original_psbt: Psbt,
@@ -658,6 +663,8 @@ impl WantsInputs {
658663

659664
/// A checked proposal that the receiver may sign and finalize to make a proposal PSBT that the
660665
/// sender will accept.
666+
///
667+
/// Call [`Self::finalize_proposal`] to return a finalized [`PayjoinProposal`].
661668
#[derive(Debug, Clone)]
662669
pub struct ProvisionalProposal {
663670
original_psbt: Psbt,
@@ -861,7 +868,8 @@ impl ProvisionalProposal {
861868
}
862869
}
863870

864-
/// A mutable checked proposal that the receiver may contribute inputs to to make a payjoin.
871+
/// A finalized payjoin proposal, complete with fees and receiver signatures, that the sender
872+
/// should find acceptable.
865873
#[derive(Clone)]
866874
pub struct PayjoinProposal {
867875
payjoin_psbt: Psbt,

payjoin/src/send/mod.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@
99
//! 2. Construct URI request parameters, a finalized “Original PSBT” paying .amount to .address
1010
//! 3. (optional) Spawn a thread or async task that will broadcast the original PSBT fallback after
1111
//! delay (e.g. 1 minute) unless canceled
12-
//! 4. Construct the request using [`RequestBuilder`](crate::send::RequestBuilder) with the PSBT
13-
//! and payjoin uri
12+
//! 4. Construct the request using [`RequestBuilder`] with the PSBT and payjoin uri
1413
//! 5. Send the request and receive response
15-
//! 6. Process the response with
16-
//! [`Context::process_response()`](crate::send::Context::process_response())
14+
//! 6. Process the response with [`ContextV1::process_response`]
1715
//! 7. Sign and finalize the Payjoin Proposal PSBT
1816
//! 8. Broadcast the Payjoin Transaction (and cancel the optional fallback broadcast)
1917
//!
@@ -34,7 +32,7 @@ pub(crate) use error::{InternalCreateRequestError, InternalValidationError};
3432
use serde::{Deserialize, Serialize};
3533
use url::Url;
3634

37-
use crate::psbt::{InputPair, PsbtExt};
35+
use crate::psbt::PsbtExt;
3836
use crate::request::Request;
3937
#[cfg(feature = "v2")]
4038
use crate::v2::{HpkePublicKey, HpkeSecretKey};
@@ -123,7 +121,7 @@ impl<'a> RequestBuilder<'a> {
123121
.find(|(_, txo)| payout_scripts.all(|script| script != txo.script_pubkey))
124122
.map(|(i, txo)| (i, txo.value))
125123
{
126-
let mut input_pairs = self.psbt.input_pairs().collect::<Vec<InputPair>>().into_iter();
124+
let mut input_pairs = self.psbt.input_pairs();
127125
let first_input_pair =
128126
input_pairs.next().ok_or(InternalCreateRequestError::NoInputs)?;
129127
let mut input_weight = first_input_pair
@@ -370,8 +368,8 @@ impl RequestContext {
370368

371369
/// Data required for validation of response.
372370
///
373-
/// This type is used to process the response. Get it from [`RequestBuilder`](crate::send::RequestBuilder)'s build methods.
374-
/// Then you only need to call [`.process_response()`](crate::send::Context::process_response()) on it to continue BIP78 flow.
371+
/// This type is used to process the response. Get it from [`RequestBuilder`]'s build methods.
372+
/// Then you only need to call [`Self::process_response`] on it to continue BIP78 flow.
375373
#[derive(Debug, Clone)]
376374
pub struct ContextV1 {
377375
original_psbt: Psbt,

payjoin/tests/integration.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ mod integration {
860860
})
861861
.expect("Receiver should not own any of the inputs");
862862

863-
// Receive Check 3: receiver can't sign for proposal inputs
863+
// Receive Check 3: no mixed input scripts
864864
let proposal = proposal.check_no_mixed_input_scripts().unwrap();
865865

866866
// Receive Check 4: have we seen this input before? More of a check for non-interactive i.e. payment processor receivers.
@@ -1301,7 +1301,7 @@ mod integration {
13011301
})
13021302
.expect("Receiver should not own any of the inputs");
13031303

1304-
// Receive Check 3: receiver can't sign for proposal inputs
1304+
// Receive Check 3: no mixed input scripts
13051305
let proposal = proposal.check_no_mixed_input_scripts().unwrap();
13061306

13071307
// Receive Check 4: have we seen this input before? More of a check for non-interactive i.e. payment processor receivers.

0 commit comments

Comments
 (0)