mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-07-29 17:48:43 -04:00
feat: Add xmr-btc-swap repo in subdirectory
This commit is contained in:
parent
462f3b2e6f
commit
757183e857
526 changed files with 41757 additions and 1 deletions
50
src-xmr-btc-swap/src-tauri/src/lib.rs
Normal file
50
src-xmr-btc-swap/src-tauri/src/lib.rs
Normal file
|
@ -0,0 +1,50 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use once_cell::sync::OnceCell;
|
||||
use swap::{api::{request::{Method, Request}, Context}, cli::command::{Bitcoin, Monero}};
|
||||
|
||||
// Lazy load the Context
|
||||
static CONTEXT: OnceCell<Arc<Context>> = OnceCell::new();
|
||||
|
||||
#[tauri::command]
|
||||
async fn balance() -> String {
|
||||
let context = CONTEXT.get().unwrap();
|
||||
let request = Request::new(Method::Balance { force_refresh: true });
|
||||
let response = request.call(context.clone()).await.unwrap();
|
||||
response.to_string()
|
||||
}
|
||||
|
||||
fn setup<'a>(app: &'a mut tauri::App) -> Result<(), Box<dyn std::error::Error>> {
|
||||
tauri::async_runtime::block_on(async {
|
||||
let context = Context::build(
|
||||
Some(Bitcoin {
|
||||
bitcoin_electrum_rpc_url: None,
|
||||
bitcoin_target_block: None,
|
||||
}),
|
||||
Some(Monero {
|
||||
monero_daemon_address: None,
|
||||
}),
|
||||
None,
|
||||
None,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
None,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
CONTEXT.set(Arc::new(context)).expect("Failed to initialize cli context");
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_shell::init())
|
||||
.invoke_handler(tauri::generate_handler![balance])
|
||||
.setup(setup)
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
6
src-xmr-btc-swap/src-tauri/src/main.rs
Normal file
6
src-xmr-btc-swap/src-tauri/src/main.rs
Normal file
|
@ -0,0 +1,6 @@
|
|||
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
fn main() {
|
||||
unstoppableswap_gui_rs_lib::run()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue