Struct acceptxmr::PaymentGateway
source · pub struct PaymentGateway<S: Storage>(_);
Expand description
The PaymentGateway
allows you to track new Invoice
s, remove
old Invoice
s from tracking, and subscribe to Invoice
s that are already
pending.
Implementations§
source§impl<S: Storage + 'static> PaymentGateway<S>
impl<S: Storage + 'static> PaymentGateway<S>
sourcepub fn builder(
private_view_key: String,
primary_address: String,
store: S
) -> PaymentGatewayBuilder<S>
pub fn builder( private_view_key: String, primary_address: String, store: S ) -> PaymentGatewayBuilder<S>
Returns a builder used to create a new payment gateway.
sourcepub async fn run(&self) -> Result<(), AcceptXmrError>
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 Invoice
s in the database.
Errors
-
Returns an
AcceptXmrError::Storage
error if there was an underlying issue with the database. -
Returns an
AcceptXmrError::Rpc
error if there was an issue getting necessary data from the monero daemon while starting. -
Returns an
AcceptXmrError::AlreadyRunning
error if the payment gateway is already running. -
Returns an
AcceptXmrError::Threading
error if there was an error creating the scanning thread.
sourcepub fn status(&self) -> PaymentGatewayStatus
pub fn status(&self) -> PaymentGatewayStatus
Returns the enum PaymentGatewayStatus
describing whether the payment
gateway is running, not running, or has experienced an error.
sourcepub fn stop(&self) -> Result<(), AcceptXmrError>
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
-
Returns an
AcceptXmrError::StopSignal
error if the payment gateway could not be stopped. -
Returns an
AcceptXmrError::ScanningThreadPanic
error if the scanning thread exited with a panic. -
If the scanning thread exited with an error, returns the error encountered.
sourcepub fn new_invoice(
&self,
piconeros: u64,
confirmations_required: u64,
expiration_in: u64,
description: String
) -> Result<InvoiceId, AcceptXmrError>
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.
sourcepub fn remove_invoice(
&self,
invoice_id: InvoiceId
) -> Result<Option<Invoice>, AcceptXmrError>
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.
sourcepub fn subscribe(&self, invoice_id: InvoiceId) -> Option<Subscriber>
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.
sourcepub fn subscribe_all(&self) -> Subscriber ⓘ
pub fn subscribe_all(&self) -> Subscriber ⓘ
Returns a Subscriber
for all invoices.
sourcepub async fn daemon_height(&self) -> Result<u64, AcceptXmrError>
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.
sourcepub fn get_invoice(
&self,
invoice_id: InvoiceId
) -> Result<Option<Invoice>, AcceptXmrError>
pub fn get_invoice( &self, invoice_id: InvoiceId ) -> Result<Option<Invoice>, AcceptXmrError>
sourcepub fn daemon_url(&self) -> String
pub fn daemon_url(&self) -> String
Returns URL of configured daemon.