From 8fa7626bd99aee2803abb9472f4418eec0d875d1 Mon Sep 17 00:00:00 2001 From: Edouard Paris Date: Tue, 15 Oct 2019 13:58:31 +0200 Subject: [PATCH] feat withdrawal --- src/lib.rs | 48 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 31e1bb2..46e5a50 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,43 @@ -#[cfg(test)] -mod tests { - #[test] - fn it_works() { - assert_eq!(2 + 2, 4); - } +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Serialize, Deserialize)] +pub enum Tag { + #[serde(rename = "withdrawalRequest")] + WithdrawalRequest, +} + +/// Withdrawal is a withdrawal resource. +#[derive(Debug, Serialize, Deserialize)] +pub struct Withdrawal { + /// A default withdrawal invoice description + #[serde(rename = "defaultDescription")] + pub default_description: String, + /// a second-level url which would accept a withdrawal + /// lightning invoice as query parameter + pub callback: String, + /// an ephemeral secret which would allow user to withdraw funds + pub k1: String, + /// max withdrawable amount for a given user on a given service + #[serde(rename = "maxWithdrawable")] + pub max_withdrawable: u64, + /// An optional field, defaults to 1 MilliSatoshi if not present, + /// can not be less than 1 or more than `maxWithdrawable` + #[serde(rename = "minWithdrawable")] + pub min_withdrawable: Option, + /// tag of the request + pub tag: Tag, +} + +#[derive(Debug, Serialize, Deserialize)] +pub enum ResponseStatus { + ERROR, + OK, +} + +/// Response is the response format returned by Service. +/// Example: `{\"status\":\"ERROR\",\"reason\":\"error detail...\"}"` +#[derive(Debug, Serialize, Deserialize)] +pub struct Response { + pub status: ResponseStatus, + pub reason: Option, }