-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
51aea7c
commit b55b2ea
Showing
11 changed files
with
685 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
/// See https://github.com/Blockstream/Jade/blob/master/docs/index.rst | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct Request<'a, T: Serialize> { | ||
pub id: String, | ||
pub method: &'a str, | ||
pub params: Option<T>, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct EmptyRequest; | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct Response<T> { | ||
pub id: String, | ||
pub result: Option<T>, | ||
pub error: Option<Error>, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct Error { | ||
pub code: i32, | ||
pub message: Option<String>, | ||
pub data: Option<Vec<u8>>, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct GetXpubParams<'a> { | ||
pub network: &'a str, | ||
pub path: Vec<u32>, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct AuthUserParams<'a> { | ||
pub network: &'a str, | ||
pub epoch: u64, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
#[serde(untagged)] | ||
pub enum AuthUserResponse { | ||
Authenticated(bool), | ||
PinServerRequired { | ||
http_request: PinServerRequest<String>, | ||
}, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct PinServerRequest<T> { | ||
pub params: PinServerRequestParams<T>, | ||
#[serde(alias = "on-reply")] | ||
pub onreply: String, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct PinServerRequestParams<T> { | ||
pub urls: PinServerUrls, | ||
pub method: String, | ||
pub accept: String, | ||
pub data: T, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
#[serde(untagged)] | ||
pub enum PinServerUrls { | ||
Array(Vec<String>), | ||
Object { url: String, onion: String }, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct PinServerEncryptedData { | ||
pub cke: String, | ||
pub encrypted_data: String, | ||
pub hmac_encrypted_data: String, | ||
pub ske: String, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct HandShakeInitParams { | ||
pub sig: String, | ||
pub ske: String, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct HandShakeInitResponse { | ||
pub http_request: PinServerRequest<PinServerEncryptedData>, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct HandShakeCompleteParams { | ||
pub encrypted_key: String, | ||
pub hmac: String, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct GetInfoResponse { | ||
#[serde(alias = "JADE_VERSION")] | ||
pub jade_version: String, | ||
#[serde(alias = "JADE_STATE")] | ||
pub jade_state: JadeState, | ||
#[serde(alias = "JADE_NETWORKS")] | ||
pub jade_networks: JadeNetworks, | ||
} | ||
|
||
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] | ||
pub enum JadeState { | ||
#[serde(alias = "UNINIT")] | ||
Uninit, | ||
#[serde(alias = "UNSAVED")] | ||
Unsaved, | ||
#[serde(alias = "LOCKED")] | ||
Locked, | ||
#[serde(alias = "READY")] | ||
Ready, | ||
#[serde(alias = "TEMP")] | ||
Temp, | ||
} | ||
|
||
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] | ||
pub enum JadeNetworks { | ||
#[serde(alias = "MAIN")] | ||
Main, | ||
#[serde(alias = "TEST")] | ||
Test, | ||
#[serde(alias = "ALL")] | ||
All, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct RegisterDescriptorParams<'a> { | ||
pub network: &'a str, | ||
pub descriptor_name: String, | ||
pub descriptor: String, | ||
pub datavalues: Vec<DataValue>, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct DataValue { | ||
pub key: String, | ||
pub value: String, | ||
} |
Oops, something went wrong.