Skip to content

Commit 213c1a2

Browse files
committed
feat: completed removal of encryption reference from all the codebase and docs
1 parent 232203d commit 213c1a2

11 files changed

Lines changed: 50 additions & 103 deletions

File tree

Cargo.lock

Lines changed: 0 additions & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ clap = { version = "4.5.45", features = ["derive"] }
7777
lnurl-rs = { version = "0.9.0", default-features = false, features = ["ureq"] }
7878
once_cell = "1.20.2"
7979
bitcoin = "0.32.5"
80-
rpassword = "7.3.1"
81-
argon2 = "0.5"
82-
secrecy = "0.10.0"
8380
dirs = "6.0.0"
8481
clearscreen = "4.0.1"
8582
tonic = "0.14.2"

docker/ENV_VARIABLES.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ These files are copied to `docker/config/lnd/` during the build process.
1818
- Used in `compose.yml` for port mapping
1919
- Example: `export MOSTRO_RELAY_LOCAL_PORT=7000`
2020

21-
- `MOSTRO_DB_PASSWORD`: Not used (database encryption was removed). Kept in `compose.yml` for backward compatibility; can be omitted or left empty.
22-
2321
## Usage Examples
2422

2523
### Linux/macOS

docker/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,12 @@ To build and run the Docker container using Docker Compose, follow these steps:
6969
make docker-up
7070
```
7171

72-
Or pass it inline:
72+
Or set the variable on one line before `make docker-up`:
7373
```sh
7474
MOSTRO_RELAY_LOCAL_PORT=7000 make docker-up
7575
```
7676

77-
5. **Note:** Database encryption has been removed. The `MOSTRO_DB_PASSWORD` environment variable (if set in `compose.yml`) is no longer used for the database; you can omit it. For more details about environment variables, see [ENV_VARIABLES.md](ENV_VARIABLES.md).
78-
79-
6. Run the docker compose file:
77+
5. Run the docker compose file:
8078

8179
```sh
8280
make docker-up

docker/compose.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ services:
33
build:
44
context: ..
55
dockerfile: docker/Dockerfile
6-
environment:
7-
MOSTRO_DB_PASSWORD: ${MOSTRO_DB_PASSWORD-}
86
volumes:
97
- ./config:/config # settings.toml and mostro.db
108
platform: linux/amd64
@@ -15,8 +13,6 @@ services:
1513
build:
1614
context: ..
1715
dockerfile: docker/dockerfile-startos
18-
environment:
19-
MOSTRO_DB_PASSWORD: ${MOSTRO_DB_PASSWORD-}
2016
platform: linux/amd64
2117
networks:
2218
- default

docs/RPC.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,67 +29,84 @@ port = 50051
2929
The RPC interface supports the following admin operations:
3030

3131
### 1. Cancel Order
32+
3233
Cancel an order as an admin.
3334

3435
**Request:**
36+
3537
- `order_id`: UUID of the order to cancel
3638
- `request_id`: Optional request identifier
3739

3840
**Response:**
41+
3942
- `success`: Boolean indicating operation success
4043
- `error_message`: Optional error message if operation failed
4144

4245
### 2. Settle Order
46+
4347
Settle a disputed order as an admin.
4448

4549
**Request:**
50+
4651
- `order_id`: UUID of the order to settle
4752
- `request_id`: Optional request identifier
4853

4954
**Response:**
55+
5056
- `success`: Boolean indicating operation success
5157
- `error_message`: Optional error message if operation failed
5258

5359
### 3. Add Solver
60+
5461
Add a new dispute solver.
5562

5663
**Request:**
64+
5765
- `solver_pubkey`: Public key of the solver to add (in bech32 format)
5866
- `request_id`: Optional request identifier
5967

6068
**Response:**
69+
6170
- `success`: Boolean indicating operation success
6271
- `error_message`: Optional error message if operation failed
6372

6473
### 4. Take Dispute
74+
6575
Take a dispute for resolution.
6676

6777
**Request:**
78+
6879
- `dispute_id`: UUID of the dispute to take
6980
- `request_id`: Optional request identifier
7081

7182
**Response:**
83+
7284
- `success`: Boolean indicating operation success
7385
- `error_message`: Optional error message if operation failed
7486

7587
### 5. Validate Database Password
76-
Kept for backward compatibility. Database encryption has been removed; this RPC always succeeds and does not validate a password.
88+
89+
Kept for backward compatibility with older clients. The SQLite database is **not** encrypted and this RPC does **not** validate any password; it always succeeds.
7790

7891
**Request:**
79-
- `password`: Ignored
80-
- `request_id`: Optional request identifier
92+
93+
- `password`: Ignored (kept in the protobuf for compatibility only)
8194

8295
**Response:**
96+
8397
- `success`: Always `true`
8498
- `error_message`: Always `None`
8599

86100
### 6. Get Version
101+
87102
Retrieve the Mostro daemon version.
88103

89104
**Request:**
105+
90106
- No parameters required
91107

92108
**Response:**
109+
93110
- `version`: String containing the daemon version (from CARGO_PKG_VERSION)
94111

95112
## Protocol Details

docs/RPC_RATE_LIMITING.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
## Overview
44

5-
The `ValidateDbPassword` RPC endpoint is protected against brute-force attacks
6-
with an in-memory rate limiter that tracks failed attempts per client IP.
5+
The `ValidateDbPassword` RPC is a **backward-compatibility** stub: the database is
6+
not encrypted, the `password` field is **ignored**, and the handler always returns
7+
success after an initial per-IP check in `validate_db_password` (`src/rpc/service.rs`).
78

8-
## Problem
9+
An in-memory rate limiter (`src/rpc/rate_limiter.rs`) runs **before** the handler
10+
processes the request. It can enforce backoff or lockout for a client IP when the
11+
limiter’s failure state is used; the current handler path records **success** only
12+
and does not validate passwords.
913

10-
The `ValidateDbPassword` endpoint is kept for backward compatibility (database
11-
encryption was removed, so it always succeeds). The rate limiter remains to
12-
throttle abuse of this endpoint.
13-
14-
See [Issue #569](https://github.com/MostroP2P/mostro/issues/569) for full details.
14+
See [Issue #569](https://github.com/MostroP2P/mostro/issues/569) for background.
1515

1616
## Implementation
1717

@@ -34,12 +34,12 @@ After a successful validation, the client's failure state is reset.
3434

3535
### Integration (`src/rpc/service.rs`)
3636

37-
The `validate_db_password` method now:
37+
The `validate_db_password` method:
3838

3939
1. Extracts the client's remote address from the gRPC request
40-
2. Checks the rate limiter — returns `RESOURCE_EXHAUSTED` if locked out
41-
3. Does not validate a password (database encryption was removed); always succeeds
42-
4. On success: resets the client's failure state
40+
2. Runs `check_rate_limit` — may return `RESOURCE_EXHAUSTED` if the limiter denies the IP
41+
3. Ignores `password` (no database encryption); returns `success: true`
42+
4. Calls `record_success` on the limiter for that IP
4343

4444
### Audit Logging
4545

docs/STARTUP_AND_CONFIG.md

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ This guide explains Mostro’s boot sequence and configuration surfaces.
99

1010
## Pre-Boot Initialization
1111

12-
**Lines 33-48 in src/main.rs**:
13-
14-
Before settings initialization, the daemon performs:
12+
Before settings initialization, the daemon performs (see `src/main.rs`):
1513

1614
1. **Screen clearing**: Clears terminal for clean output
1715
2. **Logging setup**:
@@ -86,8 +84,8 @@ Configuration is loaded from `~/.mostro/settings.toml` (template: `settings.tpl.
8684
### Configuration Sections:
8785

8886
**Database** (`src/config/types.rs:21-26`):
89-
- `url` (String): Database connection URL
90-
- Example: `"sqlite://mostro.db"` or `"postgres://user:pass@localhost/dbname"`
87+
- `url` (String): Database connection URL (Mostro uses SQLite)
88+
- Example: `"sqlite://mostro.db"` or `"sqlite://~/.mostro/mostro.db"`
9189
- Default: `"sqlite://mostro.db"`
9290

9391
**Nostr** (`src/config/types.rs:47-54`):
@@ -148,25 +146,22 @@ Configuration is loaded from `~/.mostro/settings.toml` (template: `settings.tpl.
148146

149147
## Global Variables
150148

151-
**Source**: `src/config/mod.rs:26-48`
149+
**Source**: `src/config/mod.rs`
152150

153151
```rust
154-
// Settings and configuration
155152
pub static MOSTRO_CONFIG: OnceLock<Settings> = OnceLock::new();
156-
157-
// Infrastructure connections
158153
pub static NOSTR_CLIENT: OnceLock<Client> = OnceLock::new();
159154
pub static LN_STATUS: OnceLock<LnStatus> = OnceLock::new();
160155
pub static DB_POOL: OnceLock<Arc<sqlx::SqlitePool>> = OnceLock::new();
161156

162-
// Security (MOSTRO_DB_PASSWORD unused; database encryption was removed)
163-
pub static MOSTRO_DB_PASSWORD: OnceLock<String> = OnceLock::new();
164-
165-
// Message routing
166-
pub static MESSAGE_QUEUES: LazyLock<Arc<Mutex<HashMap<String, VecDeque<String>>>>> =
167-
LazyLock::new(|| Arc::new(Mutex::new(HashMap::new())));
157+
pub static MESSAGE_QUEUES: LazyLock<MessageQueues> =
158+
LazyLock::new(MessageQueues::default);
168159
```
169160

161+
(`MessageQueues` holds `Arc<RwLock<…>>` queues for order DMs, cant-do messages, rating events, and restore-session messages.)
162+
163+
There is **no** database password or separate global for SQLite; the daemon opens the file URL from `[database]` in `settings.toml` only.
164+
170165
**Access patterns**:
171166
- `Settings::get_mostro()` → Mostro settings
172167
- `Settings::get_ln()` → Lightning settings

examples/rpc_client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
2121
.await?;
2222

2323
let mut client = AdminServiceClient::new(channel);
24-
// Example 0: ValidateDbPassword (backward compatibility; DB encryption removed, always succeeds)
24+
// Example 0: ValidateDbPassword backward-compat only; password is ignored by the server
2525
println!("Calling ValidateDbPassword (backward-compat endpoint)...");
2626
let validate_request = tonic::Request::new(ValidateDbPasswordRequest {
27-
password: std::env::var("MOSTRO_DB_TEST_PASSWORD").unwrap_or_default(),
27+
password: String::new(),
2828
});
2929

3030
match client.validate_db_password(validate_request).await {

proto/admin.proto

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ service AdminService {
1616
// Take a dispute for resolution
1717
rpc TakeDispute(TakeDisputeRequest) returns (TakeDisputeResponse);
1818

19-
// Validate database password (kept for backward compatibility; DB encryption removed)
19+
// Backward compatibility only: password is ignored; SQLite is not encrypted
2020
rpc ValidateDbPassword(ValidateDbPasswordRequest) returns (ValidateDbPasswordResponse);
2121

2222
// Get Mostro version
@@ -71,7 +71,7 @@ message TakeDisputeResponse {
7171
optional string error_message = 2;
7272
}
7373

74-
// Validate database password (backward compatibility; no longer used for DB encryption)
74+
// Backward compatibility: `password` is ignored (no DB encryption)
7575
message ValidateDbPasswordRequest {
7676
string password = 1;
7777
}

0 commit comments

Comments
 (0)