README.md

March 30, 2022 ยท View on GitHub

LRP protocol

Overview

LRP protocol allows buyer and seller to make a p2p payment while the cryptocurrencies of the buyer have locked until the seller delivers the order. The below diagram will explain the logic of LRP protocol when the sellers integrate with Libra Network.

Project Libra-LRP Protocol

Payment state transition

state-transition

Data structure of payment

Payment<T: Config> {
  pub id: u128,
  pub payer: AccountOf<T>,
  pub payee: AccountOf<T>,
  pub amount: BalanceOf<T>,
  pub currency_id: CurrencyIdOf<T>,
  pub description: Vec<u8>,
  pub status: PaymentStatus,
  pub receipt_hash: <Runtime as system::Config>::Hash,
  pub created_at: MomentOf<T>,
  pub updated_at: MomentOf<T>,
  pub updated_by: AccountOf<T>,
}

Usage

create_payment

pub fn create_payment(
  origin: <Runtime as system::Config>::Origin,
  payee: <Runtime as system::Config>::AccountId,
  amount: <Runtime as system::Config>::Balance,
  currency_id: <Runtime as system::Config>::Hash,
  description: Vec<u8>,
  receipt: Vec<u8>,
) -> DispatchResult

accept_payment

pub fn create_payment(
  origin: OriginFor<T>,
  payment_hash: <Runtime as system::Config>::Hash,
) -> DispatchResult

reject_payment

pub fn reject_payment(
  origin: <Runtime as system::Config>::Origin,
  payment_hash: <Runtime as system::Config>::Hash,
) -> DispatchResult

reject_payment

pub fn reject_payment(
  origin: <Runtime as system::Config>::Origin,
  payment_hash: <Runtime as system::Config>::Hash,
) -> DispatchResult

full_fill_payment

pub fn complete_payment(
  origin: <Runtime as system::Config>::Origin,
  payment_hash: <Runtime as system::Config>::Hash,
) -> DispatchResult

complete_payment

pub fn complete_payment(
  origin: <Runtime as system::Config>::Origin,
  payment_hash: <Runtime as system::Config>::Hash,
) -> DispatchResult