Skip to content

Commit

Permalink
Merge pull request #1080 from MutinyWallet/lnaddress-mutiny-wasm
Browse files Browse the repository at this point in the history
Add bindings for lightning address reservations
  • Loading branch information
benthecarman authored Mar 25, 2024
2 parents 7165132 + 8775a78 commit 8fc834b
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions mutiny-wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ impl MutinyWallet {
nsec_override: Option<String>,
nip_07_key: Option<String>,
primal_url: Option<String>,
blind_auth_url: Option<String>,
hermes_url: Option<String>,
) -> Result<MutinyWallet, MutinyJsError> {
let start = instant::Instant::now();
// if both are set throw an error
Expand Down Expand Up @@ -143,6 +145,8 @@ impl MutinyWallet {
nsec_override,
nip_07_key,
primal_url,
blind_auth_url,
hermes_url,
)
.await
{
Expand Down Expand Up @@ -184,6 +188,8 @@ impl MutinyWallet {
nsec_override: Option<String>,
nip_07_key: Option<String>,
primal_url: Option<String>,
blind_auth_url: Option<String>,
hermes_url: Option<String>,
) -> Result<MutinyWallet, MutinyJsError> {
let safe_mode = safe_mode.unwrap_or(false);
let logger = Arc::new(MutinyLogger::default());
Expand Down Expand Up @@ -293,6 +299,12 @@ impl MutinyWallet {
if let Some(url) = primal_url {
config_builder.with_primal_url(url);
}
if let Some(url) = blind_auth_url {
config_builder.with_blind_auth_url(url);
}
if let Some(url) = hermes_url {
config_builder.with_hermes_url(url);
}
if let Some(true) = skip_device_lock {
config_builder.with_skip_device_lock();
}
Expand Down Expand Up @@ -1923,6 +1935,16 @@ impl MutinyWallet {
Ok(self.inner.upload_profile_pic(bytes).await?)
}

/// Checks if a given LNURL name is available
pub async fn check_available_lnurl_name(&self, name: String) -> Result<bool, MutinyJsError> {
Ok(self.inner.check_available_lnurl_name(name).await?)
}

/// Reserves a given LNURL name for the user
pub async fn reserve_lnurl_name(&self, name: String) -> Result<(), MutinyJsError> {
Ok(self.inner.reserve_lnurl_name(name).await?)
}

/// Resets the scorer and network graph. This can be useful if you get stuck in a bad state.
#[wasm_bindgen]
pub async fn reset_router(&self) -> Result<(), MutinyJsError> {
Expand Down Expand Up @@ -2105,6 +2127,8 @@ mod tests {
None,
None,
None,
None,
None,
)
.await
.expect("mutiny wallet should initialize");
Expand Down Expand Up @@ -2140,6 +2164,8 @@ mod tests {
None,
None,
None,
None,
None,
)
.await
.expect("mutiny wallet should initialize");
Expand Down Expand Up @@ -2169,6 +2195,8 @@ mod tests {
None,
None,
None,
None,
None,
)
.await;

Expand Down Expand Up @@ -2211,6 +2239,8 @@ mod tests {
None,
None,
None,
None,
None,
)
.await
.expect("mutiny wallet should initialize");
Expand Down Expand Up @@ -2239,6 +2269,8 @@ mod tests {
None,
None,
None,
None,
None,
)
.await;

Expand Down Expand Up @@ -2288,6 +2320,8 @@ mod tests {
None,
None,
None,
None,
None,
)
.await
.unwrap();
Expand Down Expand Up @@ -2335,6 +2369,8 @@ mod tests {
None,
None,
None,
None,
None,
)
.await
.unwrap();
Expand Down Expand Up @@ -2369,6 +2405,8 @@ mod tests {
None,
None,
None,
None,
None,
)
.await;

Expand Down Expand Up @@ -2407,6 +2445,8 @@ mod tests {
None,
None,
None,
None,
None,
)
.await
.expect("mutiny wallet should initialize");
Expand Down Expand Up @@ -2475,6 +2515,8 @@ mod tests {
None,
None,
None,
None,
None,
)
.await
.expect("mutiny wallet should initialize");
Expand Down Expand Up @@ -2532,6 +2574,8 @@ mod tests {
None,
None,
None,
None,
None,
)
.await
.expect("mutiny wallet should initialize");
Expand Down

0 comments on commit 8fc834b

Please sign in to comment.