WORK IN PROGRESS!
A library to allow receiving monero payments in an Erlang project.
do_payment/1: pay to the currently configured walletverify_payment/1: verify if a payment went through
This library depends on the following:
- Erlang/OTP 19
- rebar3
- The monero wallet RPC daemon. You can find the Monero wallet-rpc here.
These are very general guidelines, if you'd like to expand them feel free to open a PR and I'll glady merge them in. You will need an RPC daemon, linked to your wallet, so that the module will be able to function.
-
Setup a monero wallet. More instructions can be read at getmonero.org.
-
Start the wallet RPC process, ideally in background. This example makes the following assumptions:
- You will run the daemon at port 18082. Change it if you want, and take note of it.
- This example uses username:password as an example for the RPC login, please make sure to use a strong combination.
- A log level of 2 is set
- The wallet file is located at /path/to/your/wallet, change it to your wallet file path.
$ ./monero-wallet-rpc --rpc-bind-port 18082 --rpc-login username:password --log-level 2 --wallet-file /path/to/your/wallet
For the example above, a configuration for your application will look something like this:
{application, example, [
{description, "An example application"},
{vsn, "0.1"},
{applications, [kernel, stdlib, sasl]},
{modules, [example]},
{registered, [example]},
{mod, {example, []}},
{env, [
{monerl, [
{wallet_address, <<"49BKZLHvmgKacPjYFv4iZKJTg2KEhyM958tWaJHX3bUCGrZ3SKXNirvfrCw611eNJid9DKzrUuSwbfXtJjaiNHggLrH6PLN">>},
{rpc_daemon_host, "localhost"},
{rpc_daemon_port, 18082},
{rpc_daemon_conn_timeout, 500},
{rpc_daemon_timeout, 1000},
{rpc_daemon_username, <<"username">>},
{rpc_daemon_passwd, <<"password">>},
{rpc_daemon_proto, json_rpc}
]}
]}
]}.If you want to run unit tests or test the library, you can use a testnet wallet instead of the real deal. To do such, do the following:
- Start
monerodwith the--testnetflag - Meanwhile, while the testnet blockchain is synchronizing, start your wallet with the
--testnetflag as well. Keep in mind that the daemon may bind to a different port while in testnet mode, so provide the port if the--testnetflag is not enough. - Configure a testnet wallet, store its address.
- Start the
monero-wallet-rpcwith the usual flags, but provide the testnet wallet name and thetestnetflag too - Top-up your testnet wallet using a testnet faucet.
- Run the library with the testnet address.
Right now the module is quite dumb. There's only two operations available, your application still has the burden to verify if payment went through, etc. So, to make things better, this should be done:
- Build a mechanism for asynchronously notifying a process if a payment was received.
- Make the mechanism work even if the application crashes totally (probably with some external component to store payment data).
- Have some nice unit tests.
$ rebar3 compile
$ rebar3 shell --config <your.config> --apps monerl
This project is done mostly as a hobby. I am not affiliated in any way to the Monero movement, but I relate to the ideals of the project. Online privacy is taking a beating nowadays, and standing still doesn't do much.
I am not affiliated to any dark web projects. Those are for Mr. Robot.
This piece of software is provided as is. Use it at your own risk.
I do this mostly as a hobby, but if you'd like to buy me a beer, you're more than welcome! :)
My XMR address is 49BKZLHvmgKacPjYFv4iZKJTg2KEhyM958tWaJHX3bUCGrZ3SKXNirvfrCw611eNJid9DKzrUuSwbfXtJjaiNHggLrH6PLN.