Compare commits
4 changed files with 2 additions and 139 deletions
10
README.md
10
README.md
|
|
@ -82,16 +82,6 @@ install -m 755 onionwire-x86_64-unknown-linux-gnu ~/.local/bin/onionwire
|
|||
onionwire
|
||||
```
|
||||
|
||||
The app-owned wallet child looks for an executable named `monero-wallet-rpc` in
|
||||
the same directory as the OnionWire binary, then on `PATH`. A remote daemon and
|
||||
a remote wallet RPC stay available on F7. An absolute path configured for the
|
||||
wallet-rpc binary is used as given. To place the official binary beside
|
||||
`onionwire`:
|
||||
|
||||
```bash
|
||||
scripts/fetch-monero-wallet-rpc.sh ~/.local/bin
|
||||
```
|
||||
|
||||
The binary is dynamically linked against glibc (Ubuntu 24.04 builders). If it
|
||||
dies with `GLIBC_… not found`, use Option B. Checksum files are `sha256sum`
|
||||
format (`<hash> onionwire-<target>`).
|
||||
|
|
|
|||
|
|
@ -41,10 +41,7 @@ env var:
|
|||
|
||||
- **`monero-wallet-rpc`** is spawned with `--rpc-bind-ip 127.0.0.1`, a **random
|
||||
free loopback port**, a generated `--rpc-login` (`user:pass`, random
|
||||
`[a-z0-9]`), and `--wallet-dir $ONIONWIRE_HOME/wallet`. A bare name is the
|
||||
executable of that name next to the OnionWire binary, when that file is
|
||||
executable; otherwise `PATH`. An absolute path is spawned as given (Android's
|
||||
bundled library, or a path the operator set). No `--wallet-file` and
|
||||
`[a-z0-9]`), and `--wallet-dir $ONIONWIRE_HOME/wallet`. No `--wallet-file` and
|
||||
no `--password`: argv is world-readable to the same user through `ps`, so the
|
||||
wallet is opened **over RPC** (`open_wallet`) once the child is up, and never
|
||||
named on the command line.
|
||||
|
|
|
|||
|
|
@ -1,43 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
# Place the official monero-wallet-rpc next to an OnionWire binary.
|
||||
#
|
||||
# The TUI spawns a bare "monero-wallet-rpc" from that directory before PATH.
|
||||
# F7 remote daemon and remote wallet RPC are unchanged. An absolute
|
||||
# wallet_rpc_bin is not replaced by this file.
|
||||
#
|
||||
# Hashes are the CLI lines from https://www.getmonero.org/downloads/hashes.txt
|
||||
# for v0.18.5.3. Verify that signature out of band before treating a new pin
|
||||
# as canonical; this script checks the sha256 of the tarball it downloads.
|
||||
set -euo pipefail
|
||||
|
||||
dest="${1:?usage: fetch-monero-wallet-rpc.sh <directory-of-onionwire-binary>}"
|
||||
mkdir -p "$dest"
|
||||
|
||||
case "$(uname -m)" in
|
||||
x86_64)
|
||||
file=monero-linux-x64-v0.18.5.3.tar.bz2
|
||||
sum=3333d0e04c9cbe3023e7e2b6dd369c407f36bb8df5b05fb0a19d7685b3d56dfc
|
||||
;;
|
||||
aarch64)
|
||||
file=monero-linux-armv8-v0.18.5.3.tar.bz2
|
||||
sum=1490114f795ad2f67f57bc8d167c3e2539e9f173fc46f02f70ef4abf685f8c66
|
||||
;;
|
||||
*)
|
||||
echo "fetch-monero-wallet-rpc: unsupported arch $(uname -m)" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
url="https://downloads.getmonero.org/cli/$file"
|
||||
work="$(mktemp -d)"
|
||||
trap 'rm -rf "$work"' EXIT
|
||||
curl -fL --retry 3 -o "$work/$file" "$url"
|
||||
echo "$sum $work/$file" | sha256sum -c -
|
||||
tar -xjf "$work/$file" -C "$work" --wildcards '*/monero-wallet-rpc'
|
||||
found="$(find "$work" -type f -name monero-wallet-rpc -print -quit)"
|
||||
if [ -z "$found" ]; then
|
||||
echo "fetch-monero-wallet-rpc: tarball had no monero-wallet-rpc" >&2
|
||||
exit 1
|
||||
fi
|
||||
install -m 755 "$found" "$dest/monero-wallet-rpc"
|
||||
echo "installed $dest/monero-wallet-rpc"
|
||||
|
|
@ -603,11 +603,8 @@ impl WalletChild {
|
|||
let port = Self::pick_port()?;
|
||||
let login = format!("{user}:{}", pass.as_str());
|
||||
let daemon = Self::daemon_address(&self.source);
|
||||
// A bare name is the copy next to this binary, when one is there.
|
||||
// An absolute path is the caller's (Android jniLibs, a test fake).
|
||||
let bin = resolve_wallet_rpc_bin(&self.wallet_rpc_bin, bundled_wallet_rpc_dir().as_deref());
|
||||
let argv = Self::wallet_rpc_argv(
|
||||
&bin,
|
||||
&self.wallet_rpc_bin,
|
||||
port,
|
||||
&login,
|
||||
&self.wallet_dir,
|
||||
|
|
@ -1209,39 +1206,6 @@ fn source_from_json(value: &serde_json::Value) -> Result<ChainSource> {
|
|||
}
|
||||
}
|
||||
|
||||
/// A bare wallet-rpc name is the copy sitting next to this binary, when that
|
||||
/// file is executable. An absolute or relative path is the caller's binary
|
||||
/// (Android's jniLibs entry, a test fake, a path the operator typed) and is
|
||||
/// not rewritten. No executable sibling leaves the bare name, which `Command`
|
||||
/// resolves on `PATH`.
|
||||
fn resolve_wallet_rpc_bin(configured: &Path, beside: Option<&Path>) -> PathBuf {
|
||||
if configured.components().nth(1).is_some() {
|
||||
return configured.to_path_buf();
|
||||
}
|
||||
let Some(dir) = beside else {
|
||||
return configured.to_path_buf();
|
||||
};
|
||||
let candidate = dir.join(configured);
|
||||
if executable_file(&candidate) {
|
||||
candidate
|
||||
} else {
|
||||
configured.to_path_buf()
|
||||
}
|
||||
}
|
||||
|
||||
fn executable_file(path: &Path) -> bool {
|
||||
std::fs::metadata(path)
|
||||
.is_ok_and(|meta| meta.is_file() && meta.permissions().mode() & 0o111 != 0)
|
||||
}
|
||||
|
||||
/// Directory of the running executable. `None` if the process cannot name
|
||||
/// itself — the bare name then stays on `PATH`.
|
||||
fn bundled_wallet_rpc_dir() -> Option<PathBuf> {
|
||||
std::env::current_exe()
|
||||
.ok()
|
||||
.and_then(|exe| exe.parent().map(|dir| dir.to_path_buf()))
|
||||
}
|
||||
|
||||
fn spawn(argv: &[String], what: &str) -> Result<Child> {
|
||||
let (bin, args) = argv
|
||||
.split_first()
|
||||
|
|
@ -1867,51 +1831,6 @@ mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
/// A bare name is the bundled binary sitting next to the app. An absolute
|
||||
/// path (Android's jniLibs entry, a test fake, a path the operator typed)
|
||||
/// is not rewritten. No executable sibling leaves the bare name for `PATH`.
|
||||
#[test]
|
||||
fn a_bare_wallet_rpc_name_uses_the_executable_beside_the_app() {
|
||||
let dir = tmp_dir("bundled-rpc");
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
let sibling = dir.join("monero-wallet-rpc");
|
||||
std::fs::write(&sibling, b"#!/bin/sh\n").unwrap();
|
||||
let mut perms = std::fs::metadata(&sibling).unwrap().permissions();
|
||||
perms.set_mode(0o755);
|
||||
std::fs::set_permissions(&sibling, perms).unwrap();
|
||||
|
||||
assert_eq!(
|
||||
resolve_wallet_rpc_bin(Path::new("monero-wallet-rpc"), Some(&dir)),
|
||||
sibling
|
||||
);
|
||||
|
||||
let configured = PathBuf::from("/opt/monero/monero-wallet-rpc");
|
||||
assert_eq!(
|
||||
resolve_wallet_rpc_bin(&configured, Some(&dir)),
|
||||
configured,
|
||||
"an absolute path is the operator's binary, not the sibling"
|
||||
);
|
||||
|
||||
let empty = tmp_dir("bundled-rpc-miss");
|
||||
std::fs::create_dir_all(&empty).unwrap();
|
||||
assert_eq!(
|
||||
resolve_wallet_rpc_bin(Path::new("monero-wallet-rpc"), Some(&empty)),
|
||||
PathBuf::from("monero-wallet-rpc"),
|
||||
"no sibling means PATH"
|
||||
);
|
||||
|
||||
let blocked = empty.join("monero-wallet-rpc");
|
||||
std::fs::write(&blocked, b"no").unwrap();
|
||||
let mut perms = std::fs::metadata(&blocked).unwrap().permissions();
|
||||
perms.set_mode(0o644);
|
||||
std::fs::set_permissions(&blocked, perms).unwrap();
|
||||
assert_eq!(
|
||||
resolve_wallet_rpc_bin(Path::new("monero-wallet-rpc"), Some(&empty)),
|
||||
PathBuf::from("monero-wallet-rpc"),
|
||||
"a non-executable sibling is not the bundled binary"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn monerod_argv_binds_loopback_and_uses_the_datadir() {
|
||||
let dir = tmp_dir("monerod-argv");
|
||||
|
|
|
|||
Loading…
Reference in a new issue