core/payment-drivers
directory,PaymentDriver
trait. Some of them are described in the section below,cron
module, but it is not mandatory to use them,core/payment-driver
directory. Here's what can be found there:core/payment-driver/base
- base driver components which defines the database schema and operations, registers to GSB events, help with creation of background jobs and some utility code.core/payment-driver/base/driver.rs
- declares a Rust's trait that a new driver has to implementcore/payment-driver/base/cron.rs
- declares a driver's periodical operation trait. It's optional to use it.core/payment-driver/base/bus.rs
- declares the driver's operations to other daemon services, e.g. register_account
, sign
, notify_payment
.core/payment-driver/base/dao
- handy functions to DB (sqlite) interaction. It's optional to use it.init
- Initializes the account to be used with the driver service. After successful intialization the account should be ready to send and/or receive payments (depending on the mode
parameter). It should call bus::register_account
to notify Payment service about the driver readiness. Driver should be able to handle multiple accounts. Called by CLI.enter
- Deposits the funds from Ethereum L1 into the driver's supported network. Called by CLI.exit
- Exits the funds outside the driver's supported network (most likely to L1). Called by CLI.get_account_balance
- Gets the balance of the account.transfer
- Transfers the funds between specified accounts. Called by CLI.fund
- Funds the account from faucet when run on testnet. Provides instructions how to fund on mainnet.schedule_payment
- Schedules the payment between specified accounts. Payments are processed by the cron
job. Payment tracking is done by cron job, see: PaymentDriverCron::confirm_payments
. Returns an order_id
. See also notify_payment
.verify_payment
- Verifies the payment transaction specified by transaction's confirmation (transaction's identifier).validate_allocation
- Validates that allocated funds are still sufficient to cover the costs of the task (including the transaction fees, e.g. Ethereum's Gas). Allocation is created when the requestor publishes the task on the market.account_event
- Called by the Identity service to notify the driver that specified account is locked / unlocked. Identity service holds accounts private keys and signs transactions.recv_init_required
- Tells whether account initialization is needed for receiving payments.sign_payment
- Signs Yagna's payment message with the same key that was used to sign the blockchain transaction. Driver trait provides a default implementation of this method so it's not required to implement it.verify_signature
- Verifies the signature on payment message (see sign_payment
). Driver trait provides a default implementation of this method so it's not required to implement it.get_name
- Returns driver's name. It should be lowercase, ASCII-only with no whitespace.get_networks
- Returns networks supported by the driver (e.g. mainnet, rinkeby, ropsten).get_default_network
- Returns default network for the dirver. It should be one of the networks returned by get_networks
.shut_down
- Performs all neccesary shutdown routines. It is recommended that the driver sends out all pending transactions on shutdown.PaymentDriverCron
trait as long as the driver can operate without the cron.confirm_payments
- Confirms scheduled payments.process_payments
- Processes scheduled payments.core/payment-driver/base/bus.rs
file.register_account
- Notifies the Payment service that the account is ready to sending / receiving funds. See init
above.sign
- Delegates signing of the transaction's payload to the Identity service.notify_payment
- Notifies the Payment service that the scheduled payment is processed successfully. It also links the order_id
with the confirmation
(e.g. transaction's hash). See schedule_payment
above. This notification leads to verify_payment
call on the provider side.start_payment_drivers
function in the core/serv/src/main.rs
file. It should follow the convention and declares its own compilation flag. Don't forget to set this flag during the compilation init
, fund
, enter
, transfer
, status
, exit
...payment_api
enum and resolve compilation errors in the following match
expressions.rm payment.db* && cargo run --example payment_api -- --driver=<DRIVER> --platform=<PLATFORM>
platform_api
on each test) cargo run --example invoice_flow -- --platform=<PLATFORM>
platform_api
on each test) cargo run --example debit_note_flow -- --platform=<PLATFORM>