Add 'contact' to Config and NIP-11 output

This commit is contained in:
Mike Dilger 2024-02-17 13:13:03 +13:00
parent 592b77dc02
commit a5ac657a65
3 changed files with 14 additions and 2 deletions

View File

@ -5,8 +5,9 @@ FriendlyConfig(
use_tls: false,
certchain_pem_path: "tls/fullchain.pem",
key_pem_path: "tls/privkey.pem",
name: None,
description: None,
name: Some("Chorus Sample"),
description: Some("A sample run of the Chorus relay"),
contact: None,
public_key_hex: None,
user_hex_keys: [
"ee11a5dff40c19a555f41fe42b48f00e618c91225622ae37b6c2bb67b76c4e49"

View File

@ -12,6 +12,7 @@ pub struct FriendlyConfig {
pub key_pem_path: String,
pub name: Option<String>,
pub description: Option<String>,
pub contact: Option<String>,
pub public_key_hex: Option<String>,
pub user_hex_keys: Vec<String>,
pub verify_events: bool,
@ -29,6 +30,7 @@ impl Default for FriendlyConfig {
key_pem_path: "./tls/privkey.pem".to_string(),
name: None,
description: None,
contact: None,
public_key_hex: None,
user_hex_keys: vec![],
verify_events: true,
@ -48,6 +50,7 @@ impl FriendlyConfig {
key_pem_path,
name,
description,
contact,
public_key_hex,
user_hex_keys,
verify_events,
@ -73,6 +76,7 @@ impl FriendlyConfig {
key_pem_path,
name,
description,
contact,
public_key,
user_keys,
user_hex_keys,
@ -92,6 +96,7 @@ pub struct Config {
pub key_pem_path: String,
pub name: Option<String>,
pub description: Option<String>,
pub contact: Option<String>,
pub public_key: Option<Pubkey>,
pub user_keys: Vec<Pubkey>,
pub user_hex_keys: Vec<String>,

View File

@ -59,6 +59,12 @@ fn build_rid(config: &Config) -> String {
rid.push_str(description);
rid.push('\"');
}
if let Some(contact) = &config.contact {
rid.push(',');
rid.push_str("\"contact\":\"");
rid.push_str(contact);
rid.push('\"');
}
if let Some(pubkey) = &config.public_key {
let mut pkh: [u8; 64] = [0; 64];
pubkey.write_hex(&mut pkh).unwrap();