Struct acceptxmr::PaymentGatewayBuilder
source · 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>
impl<S: Storage + 'static> PaymentGatewayBuilder<S>
sourcepub fn new(
private_view_key: String,
primary_address: String,
store: S
) -> PaymentGatewayBuilder<S>
pub fn new( private_view_key: String, primary_address: String, store: S ) -> PaymentGatewayBuilder<S>
Create a new payment gateway builder.
sourcepub fn daemon_url(self, url: String) -> PaymentGatewayBuilder<S>
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?;
sourcepub fn daemon_login(
self,
username: String,
password: String
) -> PaymentGatewayBuilder<S>
pub fn daemon_login( self, username: String, password: String ) -> PaymentGatewayBuilder<S>
If your preferred daemon requires a password, configure it here.
sourcepub fn rpc_timeout(self, timeout: Duration) -> PaymentGatewayBuilder<S>
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.
sourcepub fn rpc_connection_timeout(
self,
timeout: Duration
) -> PaymentGatewayBuilder<S>
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.
sourcepub fn scan_interval(self, interval: Duration) -> PaymentGatewayBuilder<S>
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.
sourcepub fn seed(self, seed: u64) -> PaymentGatewayBuilder<S>
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.
sourcepub fn account_index(self, index: u32) -> PaymentGatewayBuilder<S>
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.
sourcepub fn initial_height(self, height: u64) -> PaymentGatewayBuilder<S>
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.
sourcepub fn build(self) -> Result<PaymentGateway<S>, AcceptXmrError>
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.