Allow to connect to monero-wallet-rpc when it runs without --wallet-dir option

This commit is contained in:
silverpill 2022-11-27 13:04:42 +00:00
parent 12861a98b7
commit 73a7668d18
5 changed files with 16 additions and 10 deletions

View file

@ -103,7 +103,7 @@ An HTTP server will be needed to handle HTTPS requests and serve the frontend. S
Install Monero node or choose a [public one](https://monero.fail/). Install Monero node or choose a [public one](https://monero.fail/).
Configure and start [monero-wallet-rpc](https://monerodocs.org/interacting/monero-wallet-rpc-reference/) daemon. Configure and start [monero-wallet-rpc](https://monerodocs.org/interacting/monero-wallet-rpc-reference/) daemon. Add `disable-rpc-login=1` to your `monero-wallet-rpc` config (currently RPC auth is not supported in Mitra).
Create a wallet for your instance. Create a wallet for your instance.

View file

@ -51,8 +51,8 @@ registrations_open: false
# - chain_id: monero:mainnet # - chain_id: monero:mainnet
# node_url: 'http://opennode.xmr-tw.org:18089' # node_url: 'http://opennode.xmr-tw.org:18089'
# wallet_url: 'http://127.0.0.1:18083' # wallet_url: 'http://127.0.0.1:18083'
# wallet_name: mitra # wallet_name: null
# wallet_password: mitra # wallet_password: null
# IPFS integration # IPFS integration

View file

@ -385,6 +385,7 @@ impl ResetSubscriptions {
} }
/// Create Monero wallet /// Create Monero wallet
/// (can be used when monero-wallet-rpc runs with --wallet-dir option)
#[derive(Parser)] #[derive(Parser)]
pub struct CreateMoneroWallet { pub struct CreateMoneroWallet {
name: String, name: String,

View file

@ -56,7 +56,9 @@ pub struct MoneroConfig {
#[serde(alias = "daemon_url")] #[serde(alias = "daemon_url")]
pub node_url: String, pub node_url: String,
pub wallet_url: String, pub wallet_url: String,
pub wallet_name: String, // Wallet name and password are required when
// monero-wallet-rpc is running with --wallet-dir option
pub wallet_name: Option<String>,
pub wallet_password: Option<String>, pub wallet_password: Option<String>,
} }

View file

@ -36,7 +36,7 @@ pub enum MoneroError {
OtherError(&'static str), OtherError(&'static str),
} }
/// http://monerotoruzizulg5ttgat2emf4d6fbmiea25detrmmy7erypseyteyd.onion/resources/developer-guides/wallet-rpc.html#create_wallet /// https://monerodocs.org/interacting/monero-wallet-rpc-reference/#create_wallet
pub async fn create_monero_wallet( pub async fn create_monero_wallet(
config: &MoneroConfig, config: &MoneroConfig,
name: String, name: String,
@ -48,14 +48,17 @@ pub async fn create_monero_wallet(
Ok(()) Ok(())
} }
/// https://monerodocs.org/interacting/monero-wallet-rpc-reference/#open_wallet
pub async fn open_monero_wallet( pub async fn open_monero_wallet(
config: &MoneroConfig, config: &MoneroConfig,
) -> Result<WalletClient, MoneroError> { ) -> Result<WalletClient, MoneroError> {
let wallet_client = RpcClient::new(config.wallet_url.clone()).wallet(); let wallet_client = RpcClient::new(config.wallet_url.clone()).wallet();
wallet_client.open_wallet( if let Some(ref wallet_name) = config.wallet_name {
config.wallet_name.clone(), wallet_client.open_wallet(
config.wallet_password.clone(), wallet_name.clone(),
).await?; config.wallet_password.clone(),
).await?;
};
Ok(wallet_client) Ok(wallet_client)
} }
@ -89,7 +92,7 @@ pub async fn get_subaddress_balance(
Ok(subaddress_data) Ok(subaddress_data)
} }
/// http://monerotoruzizulg5ttgat2emf4d6fbmiea25detrmmy7erypseyteyd.onion/resources/developer-guides/wallet-rpc.html#sweep_all /// https://monerodocs.org/interacting/monero-wallet-rpc-reference/#sweep_all
pub async fn send_monero( pub async fn send_monero(
wallet_client: &WalletClient, wallet_client: &WalletClient,
from_address: u32, from_address: u32,