pub struct PaymentGatewayBuilder<S> { /* private fields */ }
Expand description

A builder for the payment gateway. Used to configure your desired monero daemon, scan interval, view key, etc.

Examples

use acceptxmr::{PaymentGatewayBuilder, storage::stores::InMemory};
use std::time::Duration;

let private_view_key =
    "ad2093a5705b9f33e6f0f0c1bc1f5f639c756cdfc168c8f2ac6127ccbdab3a03";
let primary_address =
    "4613YiHLM6JMH4zejMB2zJY5TwQCxL8p65ufw8kBP5yxX9itmuGLqp1dS4tkVoTxjyH3aYhYNrtGHbQzJQP5bFus3KHVdmf";

let store = InMemory::new();

// Create a payment gateway with an extra fast scan rate and a custom monero daemon URL.
let payment_gateway = PaymentGatewayBuilder::new(
    private_view_key.to_string(),
    primary_address.to_string(),
    store
)
.scan_interval(Duration::from_millis(100)) // Scan for updates every 100 ms.
.daemon_url("http://example.com:18081".to_string()) // Set custom monero daemon URL.
.build();

Implementations§

source§

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

source

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

Create a new payment gateway builder.

source

pub fn daemon_url(self, url: String) -> PaymentGatewayBuilder<S>

Set the url and port of your preferred monero daemon. Defaults to http://node.moneroworld.com:18089.

Examples
use acceptxmr::{PaymentGatewayBuilder, storage::stores::InMemory};

let private_view_key =
    "ad2093a5705b9f33e6f0f0c1bc1f5f639c756cdfc168c8f2ac6127ccbdab3a03";
let primary_address =
    "4613YiHLM6JMH4zejMB2zJY5TwQCxL8p65ufw8kBP5yxX9itmuGLqp1dS4tkVoTxjyH3aYhYNrtGHbQzJQP5bFus3KHVdmf";

// Pick a storage layer. We'll store data in-memory here for simplicity.
let store = InMemory::new();

// Create a payment gateway with a custom monero daemon URL.
let payment_gateway = PaymentGatewayBuilder::new(
    private_view_key.to_string(),
    primary_address.to_string(),
    store
)
.daemon_url("http://example.com:18081".to_string()) // Set custom monero daemon URL.
.build()?;

// The payment gateway will now use the daemon specified.
payment_gateway.run().await?;
source

pub fn daemon_login( self, username: String, password: String ) -> PaymentGatewayBuilder<S>

If your preferred daemon requires a password, configure it here.

source

pub fn rpc_timeout(self, timeout: Duration) -> PaymentGatewayBuilder<S>

Time before an remote procedure call times out. If this amount of time elapses without receiving a full response from the RPC daemon, the current scan will be aborted and restarted. Defaults to 10 seconds.

source

pub fn rpc_connection_timeout( self, timeout: Duration ) -> PaymentGatewayBuilder<S>

Time before a remote procedure call times out while failing to connect. If this amount of time elapses without managing to connect to the monero daemon, the current scan will be aborted and restarted. Defaults to 5 seconds.

source

pub fn scan_interval(self, interval: Duration) -> PaymentGatewayBuilder<S>

Set the minimum scan interval. New blocks and transactions will be scanned for relevant outputs at most every interval. Defaults to 1 second.

source

pub fn seed(self, seed: u64) -> PaymentGatewayBuilder<S>

Seed for random number generator. Use only for reproducible testing. Do not set in a production environment.

source

pub fn account_index(self, index: u32) -> PaymentGatewayBuilder<S>

Set the account index (i.e. subaddress major index) the payment gateway should use. Defaults to account index 0.

source

pub fn initial_height(self, height: u64) -> PaymentGatewayBuilder<S>

Set the initial height that the payment gateway should start scanning from. For best protection against the burning bug, this should be set to your wallet’s restore height.

This method only affects new payment gateways. If a payment gateway has already scanned blocks higher than the specified initial height, then it will continue scanning from the height where it left off.

Defaults to the current blockchain tip. Setting an initial height greater than the blockchain tip will do nothing.

source

pub fn build(self) -> Result<PaymentGateway<S>, AcceptXmrError>

Build the payment gateway.

Errors

Returns an error if the database cannot be opened at the path specified, if the internal RPC client cannot parse the provided URL, or if the primary address or private view key cannot be parsed.

Auto Trait Implementations§

§

impl<S> RefUnwindSafe for PaymentGatewayBuilder<S>where S: RefUnwindSafe,

§

impl<S> Send for PaymentGatewayBuilder<S>where S: Send,

§

impl<S> Sync for PaymentGatewayBuilder<S>where S: Sync,

§

impl<S> Unpin for PaymentGatewayBuilder<S>where S: Unpin,

§

impl<S> UnwindSafe for PaymentGatewayBuilder<S>where S: UnwindSafe,

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, 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