Files
solana/sdk/src/payment_plan.rs

28 lines
887 B
Rust
Raw Normal View History

2018-11-02 20:13:33 -06:00
//! The `plan` module provides a domain-specific language for payment plans. Users create BudgetExpr objects that
2018-05-25 15:51:41 -06:00
//! are given to an interpreter. The interpreter listens for `Witness` transactions,
2018-03-20 15:52:46 -06:00
//! which it uses to reduce the payment plan. When the plan is reduced to a
//! `Payment`, the payment is executed.
2018-03-17 14:42:43 -06:00
2018-12-14 20:39:10 -08:00
use crate::pubkey::Pubkey;
2018-03-17 14:42:43 -06:00
use chrono::prelude::*;
2018-06-06 17:16:12 -06:00
/// The types of events a payment plan can process.
2018-05-22 21:42:04 -06:00
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
2018-03-20 15:31:28 -06:00
pub enum Witness {
2018-06-06 17:16:12 -06:00
/// The current time.
2018-03-17 14:42:43 -06:00
Timestamp(DateTime<Utc>),
2018-06-06 17:16:12 -06:00
2018-09-10 19:58:18 -07:00
/// A signature from Pubkey.
Signature,
2018-03-17 14:42:43 -06:00
}
/// Some amount of tokens that should be sent to the `to` `Pubkey`.
2018-03-17 14:42:43 -06:00
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
pub struct Payment {
2018-06-06 17:16:12 -06:00
/// Amount to be paid.
pub tokens: u64,
2018-06-06 17:16:12 -06:00
/// The `Pubkey` that `tokens` should be paid to.
pub to: Pubkey,
2018-03-17 14:42:43 -06:00
}