pub struct PaymentGateway<S: Storage>(_);
Expand description

The PaymentGateway allows you to track new Invoices, remove old Invoices from tracking, and subscribe to Invoices that are already pending.

Implementations§

source§

impl<S: Storage + 'static> PaymentGateway<S>

source

pub fn builder( private_view_key: String, primary_address: String, store: S ) -> PaymentGatewayBuilder<S>

Returns a builder used to create a new payment gateway.

source

pub async fn run(&self) -> Result<(), AcceptXmrError>

Runs the payment gateway. This function spawns a new thread, which periodically scans new blocks and transactions from the configured daemon and updates pending Invoices in the database.

Errors
source

pub fn status(&self) -> PaymentGatewayStatus

Returns the enum PaymentGatewayStatus describing whether the payment gateway is running, not running, or has experienced an error.

source

pub fn stop(&self) -> Result<(), AcceptXmrError>

Stops the payment gateway, blocking until complete. If the payment gateway is not running, this method does nothing.

Errors
source

pub fn new_invoice( &self, piconeros: u64, confirmations_required: u64, expiration_in: u64, description: String ) -> Result<InvoiceId, AcceptXmrError>

Adds a new Invoice to the payment gateway for tracking, and returns the ID of the new invoice. Use a Subscriber to receive updates on the new invoice invoice as they occur.

Errors

Returns an error if there are any underlying issues modifying data in the database.

source

pub fn remove_invoice( &self, invoice_id: InvoiceId ) -> Result<Option<Invoice>, AcceptXmrError>

Remove (i.e. stop tracking) invoice, returning the old invoice if it existed.

Errors

Returns an error if there are any underlying issues modifying/retrieving data in the database.

source

pub fn subscribe(&self, invoice_id: InvoiceId) -> Option<Subscriber>

Returns a Subscriber for the given invoice ID. If a tracked invoice exists for that ID, the subscriber can be used to receive updates to for that invoice.

source

pub fn subscribe_all(&self) -> Subscriber

Returns a Subscriber for all invoices.

source

pub async fn daemon_height(&self) -> Result<u64, AcceptXmrError>

Get current height of daemon using a monero daemon remote procedure call.

Errors

Returns an error if a connection can not be made to the daemon, or if the daemon’s response cannot be parsed.

source

pub fn get_invoice( &self, invoice_id: InvoiceId ) -> Result<Option<Invoice>, AcceptXmrError>

Get the up-to-date invoice associated with the given InvoiceId, if it exists.

Errors

Returns an error if there are any underlying issues retrieving data from the database.

source

pub fn daemon_url(&self) -> String

Returns URL of configured daemon.

Trait Implementations§

source§

impl<S: Storage> Clone for PaymentGateway<S>

source§

fn clone(&self) -> Self

Returns a copy 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<S: Storage> Deref for PaymentGateway<S>

§

type Target = PaymentGatewayInner<S>

The resulting type after dereferencing.
source§

fn deref(&self) -> &PaymentGatewayInner<S>

Dereferences the value.

Auto Trait Implementations§

§

impl<S> !RefUnwindSafe for PaymentGateway<S>

§

impl<S> Send for PaymentGateway<S>

§

impl<S> Sync for PaymentGateway<S>

§

impl<S> Unpin for PaymentGateway<S>

§

impl<S> !UnwindSafe for PaymentGateway<S>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
§

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

§

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