2024-06-06 18:52:39 +01:00
|
|
|
use std::path::PathBuf;
|
|
|
|
|
|
2024-06-07 18:42:28 +01:00
|
|
|
use serde_json::{json, Value};
|
|
|
|
|
|
2024-06-06 18:52:39 +01:00
|
|
|
pub(crate) const KEY_FILE: &str = "keys.pem";
|
|
|
|
|
pub(crate) const CONFIG_FILE: &str = "config.toml";
|
|
|
|
|
|
2024-06-07 17:03:05 +01:00
|
|
|
/// Returns the path to the key file and config for this host OS.
|
2024-06-06 18:52:39 +01:00
|
|
|
pub(crate) fn side_paths(prefix: PathBuf) -> (PathBuf, PathBuf) {
|
|
|
|
|
let mut key_path = prefix.clone();
|
|
|
|
|
key_path.push(KEY_FILE);
|
|
|
|
|
|
|
|
|
|
let mut config_path = prefix.clone();
|
|
|
|
|
config_path.push(CONFIG_FILE);
|
|
|
|
|
|
|
|
|
|
(key_path, config_path)
|
|
|
|
|
}
|
2024-06-07 17:03:05 +01:00
|
|
|
|
|
|
|
|
pub(crate) fn home(name: &String) -> std::path::PathBuf {
|
|
|
|
|
let mut path = dirs::home_dir().unwrap();
|
|
|
|
|
path.push(".side");
|
|
|
|
|
path.push(name);
|
|
|
|
|
path
|
|
|
|
|
}
|
2024-06-07 18:42:28 +01:00
|
|
|
|
|
|
|
|
/// Generate a fake transaction with customizable from_pubkey String
|
|
|
|
|
pub(crate) fn fake_transaction(from_pubkey: String) -> Value {
|
|
|
|
|
json!({
|
|
|
|
|
"from": from_pubkey,
|
|
|
|
|
"to": "Bob",
|
|
|
|
|
"amount": 1
|
|
|
|
|
})
|
|
|
|
|
}
|