AcceptXMR
: Accept Monero in Your Application
AcceptXMR
is a library for building payment gateways.
For a batteries-included gateway, please see
AcceptXMR-Server
.
Getting Started
To use AcceptXMR
in your rust project, first add it to your Cargo.toml
. For
example if you intend to use the Sqlite
storage backend and need serde
support, you should add this to your Cargo.toml
:
[]
= { = "0.12", = ["serde", "sqlite"] }
You can then create and run a PaymentGateway
:
use ;
use Duration;
let private_view_key =
"ad2093a5705b9f33e6f0f0c1bc1f5f639c756cdfc168c8f2ac6127ccbdab3a03";
let primary_address =
"4613YiHLM6JMH4zejMB2zJY5TwQCxL8p65ufw8kBP5yxX9itmuGLqp1dS4tkVoTxjyH3aYhYNrtGHbQzJQP5bFus3KHVdmf";
let store = new?;
let payment_gateway = builder
.daemon_url // Specify a node.
.scan_interval // Scan for updates every 500 ms.
.build?;
payment_gateway.run?;
Finally, you can create invoices and subscribe to them so you know when they get paid:
// Oh hey, a customer is checking out!
let invoice_id = payment_gateway.new_invoice.await?;
// We can now subscribe to updates to the pizza invoice.
let subscriber = payment_gateway.subscribe?
.expect;
// Have we been paid yet?
let update = subscriber.recv.await.expect;
if update.is_confirmed
For more detailed documentation, see docs.rs or the examples.