Skip to main content

UncheckedOriginalPayload

Struct UncheckedOriginalPayload 

Source
pub struct UncheckedOriginalPayload { /* private fields */ }
Available on crate feature v1 only.
Expand description

The original PSBT and the optional parameters received from the sender.

This is the first typestate after the retrieval of the sender’s original proposal in the receiver’s workflow. At this stage, the receiver can verify that the original PSBT they have received from the sender is broadcastable to the network in the case of a payjoin failure.

The recommended usage of this typestate differs based on whether you are implementing an interactive (where the receiver takes manual actions to respond to the payjoin proposal) or a non-interactive (ex. a donation page which automatically generates a new QR code for each visit) payment receiver. For the latter, you should call Self::check_broadcast_suitability to check that the proposal is actually broadcastable (and, optionally, whether the fee rate is above the minimum limit you have set). These mechanisms protect the receiver against probing attacks, where a malicious sender can repeatedly send proposals to have the non-interactive receiver reveal the UTXOs it owns with the proposals it modifies.

If you are implementing an interactive payment receiver, then such checks are not necessary, and you can go ahead with calling Self::assume_interactive_receiver to move on to the next typestate.

Implementations§

Source§

impl UncheckedOriginalPayload

Source

pub fn from_request( body: &[u8], query: &str, headers: impl Headers, ) -> Result<Self, Error>

Source§

impl UncheckedOriginalPayload

Source

pub fn check_broadcast_suitability( self, min_fee_rate: Option<FeeRate>, can_broadcast: impl Fn(&Transaction) -> Result<bool, ImplementationError>, ) -> Result<MaybeInputsOwned, Error>

Checks that the original PSBT in the proposal can be broadcasted.

If the receiver is a non-interactive payment processor (ex. a donation page which generates a new QR code for each visit), then it should make sure that the original PSBT is broadcastable as a fallback mechanism in case the payjoin fails. This validation would be equivalent to testmempoolaccept Bitcoin Core RPC call returning {"allowed": true,...}.

Receiver can optionally set a minimum fee rate which will be enforced on the original PSBT in the proposal. This can be used to further prevent probing attacks since the attacker would now need to probe the receiver with transactions which are both broadcastable and pay high fee. Unrelated to the probing attack scenario, this parameter also makes operating in a high fee environment easier for the receiver.

Source

pub fn assume_interactive_receiver(self) -> MaybeInputsOwned

Moves on to the next typestate without any of the current typestate’s validations.

Use this for interactive payment receivers, where there is no risk of a probing attack since the receiver needs to manually create payjoin URIs.

Trait Implementations§

Source§

impl Clone for UncheckedOriginalPayload

Source§

fn clone(&self) -> UncheckedOriginalPayload

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for UncheckedOriginalPayload

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more