@@ -71,15 +71,14 @@ fn subdir_path_from_pubkey(pubkey: &HpkePublicKey) -> ShortId {
7171 sha256:: Hash :: hash ( & pubkey. to_compressed_bytes ( ) ) . into ( )
7272}
7373
74- /// A payjoin V2 receiver, allowing for polled requests to the
75- /// payjoin directory and response processing.
74+ /// A new payjoin receiver, which must be persisted before initiating the payjoin flow.
7675#[ derive( Debug ) ]
7776pub struct NewReceiver {
7877 context : SessionContext ,
7978}
8079
8180impl NewReceiver {
82- /// Creates a new `Receiver` with the provided parameters.
81+ /// Creates a new [`NewReceiver`] with the provided parameters.
8382 ///
8483 /// # Parameters
8584 /// - `address`: The Bitcoin address for the payjoin session.
@@ -88,7 +87,7 @@ impl NewReceiver {
8887 /// - `expire_after`: The duration after which the session expires.
8988 ///
9089 /// # Returns
91- /// A new instance of `Receiver` .
90+ /// A new instance of [`NewReceiver`] .
9291 ///
9392 /// # References
9493 /// - [BIP 77: Payjoin Version 2: Serverless Payjoin](https://github.com/bitcoin/bips/pull/1483)
@@ -113,6 +112,7 @@ impl NewReceiver {
113112 Ok ( receiver)
114113 }
115114
115+ /// Saves the new [`Receiver`] using the provided persister and returns the storage token.
116116 pub fn persist < P : Persister < Receiver > > (
117117 & self ,
118118 persister : & mut P ,
@@ -122,6 +122,8 @@ impl NewReceiver {
122122 }
123123}
124124
125+ /// A payjoin V2 receiver, allowing for polled requests to the
126+ /// payjoin directory and response processing.
125127#[ derive( Debug , Clone , PartialEq , Eq , Serialize , Deserialize ) ]
126128pub struct Receiver {
127129 context : SessionContext ,
@@ -150,6 +152,7 @@ impl persist::Value for Receiver {
150152}
151153
152154impl Receiver {
155+ /// Loads a [`Receiver`] from the provided persister using the storage token.
153156 pub fn load < P : Persister < Receiver > > (
154157 token : P :: Token ,
155158 persister : & P ,
@@ -361,7 +364,7 @@ impl UncheckedProposal {
361364
362365/// Typestate to validate that the Original PSBT has no receiver-owned inputs.
363366///
364- /// Call [`check_no_receiver_owned_inputs()`](struct.UncheckedProposal.html#method.check_no_receiver_owned_inputs) to proceed.
367+ /// Call [`Self::check_inputs_not_owned`] to proceed.
365368#[ derive( Debug , Clone ) ]
366369pub struct MaybeInputsOwned {
367370 v1 : v1:: MaybeInputsOwned ,
@@ -384,7 +387,7 @@ impl MaybeInputsOwned {
384387
385388/// Typestate to validate that the Original PSBT has no inputs that have been seen before.
386389///
387- /// Call [`check_no_inputs_seen`](struct.MaybeInputsSeen.html#method.check_no_inputs_seen_before) to proceed.
390+ /// Call [`Self::check_no_inputs_seen_before`] to proceed.
388391#[ derive( Debug , Clone ) ]
389392pub struct MaybeInputsSeen {
390393 v1 : v1:: MaybeInputsSeen ,
@@ -407,7 +410,7 @@ impl MaybeInputsSeen {
407410/// The receiver has not yet identified which outputs belong to the receiver.
408411///
409412/// Only accept PSBTs that send us money.
410- /// Identify those outputs with ` identify_receiver_outputs()` to proceed
413+ /// Identify those outputs with [`Self:: identify_receiver_outputs`] to proceed.
411414#[ derive( Debug , Clone ) ]
412415pub struct OutputsUnknown {
413416 inner : v1:: OutputsUnknown ,
@@ -426,6 +429,8 @@ impl OutputsUnknown {
426429}
427430
428431/// A checked proposal that the receiver may substitute or add outputs to
432+ ///
433+ /// Call [`Self::commit_outputs`] to proceed.
429434#[ derive( Debug , Clone ) ]
430435pub struct WantsOutputs {
431436 v1 : v1:: WantsOutputs ,
@@ -468,6 +473,8 @@ impl WantsOutputs {
468473}
469474
470475/// A checked proposal that the receiver may contribute inputs to to make a payjoin
476+ ///
477+ /// Call [`Self::commit_inputs`] to proceed.
471478#[ derive( Debug , Clone ) ]
472479pub struct WantsInputs {
473480 v1 : v1:: WantsInputs ,
@@ -513,13 +520,21 @@ impl WantsInputs {
513520
514521/// A checked proposal that the receiver may sign and finalize to make a proposal PSBT that the
515522/// sender will accept.
523+ ///
524+ /// Call [`Self::finalize_proposal`] to return a finalized [`PayjoinProposal`].
516525#[ derive( Debug , Clone ) ]
517526pub struct ProvisionalProposal {
518527 v1 : v1:: ProvisionalProposal ,
519528 context : SessionContext ,
520529}
521530
522531impl ProvisionalProposal {
532+ /// Return a Payjoin Proposal PSBT that the sender will find acceptable.
533+ ///
534+ /// This attempts to calculate any network fee owed by the receiver, subtract it from their output,
535+ /// and return a PSBT that can produce a consensus-valid transaction that the sender will accept.
536+ ///
537+ /// wallet_process_psbt should sign and finalize receiver inputs
523538 pub fn finalize_proposal (
524539 self ,
525540 wallet_process_psbt : impl Fn ( & Psbt ) -> Result < Psbt , ImplementationError > ,
@@ -532,7 +547,8 @@ impl ProvisionalProposal {
532547 }
533548}
534549
535- /// A mutable checked proposal that the receiver may contribute inputs to to make a payjoin.
550+ /// A finalized payjoin proposal, complete with fees and receiver signatures, that the sender
551+ /// should find acceptable.
536552#[ derive( Clone ) ]
537553pub struct PayjoinProposal {
538554 v1 : v1:: PayjoinProposal ,
@@ -546,12 +562,15 @@ impl PayjoinProposal {
546562 Self { v1, context }
547563 }
548564
565+ /// The UTXOs that would be spent by this Payjoin transaction
549566 pub fn utxos_to_be_locked ( & self ) -> impl ' _ + Iterator < Item = & bitcoin:: OutPoint > {
550567 self . v1 . utxos_to_be_locked ( )
551568 }
552569
570+ /// The Payjoin Proposal PSBT
553571 pub fn psbt ( & self ) -> & Psbt { self . v1 . psbt ( ) }
554572
573+ /// Extract an OHTTP Encapsulated HTTP POST request for the Proposal PSBT
555574 pub fn extract_req (
556575 & mut self ,
557576 ohttp_relay : impl IntoUrl ,
0 commit comments