Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/workflows/release-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: "Build and publish Docker image"
on:
pull_request:
paths:
- payjoin-service/**
- payjoin-mailroom/**
push:
tags:
- payjoin-service-**
- payjoin-mailroom-**
workflow_dispatch:

jobs:
Expand All @@ -33,7 +33,7 @@ jobs:
password: ${{ secrets.PAYJOIN_DOCKER_RW }}

- name: Build and release image
run: nix run .#packages.x86_64-linux.payjoin-service-image.copyToRegistry
run: nix run .#packages.x86_64-linux.payjoin-mailroom-image.copyToRegistry

build-pr:
name: "Build and upload image artifact"
Expand All @@ -55,17 +55,17 @@ jobs:
run: |
TAG=$(git rev-parse --short HEAD)

nix build .#packages.x86_64-linux.payjoin-service-image.copyToDockerDaemon
nix build .#packages.x86_64-linux.payjoin-mailroom-image.copyToDockerDaemon
result/bin/copy-to-docker-daemon

docker save docker.io/payjoin/payjoin-service:${TAG} -o payjoin-service-${TAG}.tar
docker save docker.io/payjoin/payjoin-mailroom:${TAG} -o payjoin-mailroom-${TAG}.tar

echo "Image saved: payjoin-service-${TAG}.tar"
ls -lh payjoin-service-${TAG}.tar
echo "Image saved: payjoin-mailroom-${TAG}.tar"
ls -lh payjoin-mailroom-${TAG}.tar

- name: Upload image artifact
uses: actions/upload-artifact@v4
with:
name: payjoin-service-image-${{ github.sha }}
path: payjoin-service-*.tar
name: payjoin-mailroom-image-${{ github.sha }}
path: payjoin-mailroom-*.tar
retention-days: 7
4 changes: 2 additions & 2 deletions Cargo-minimal.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2769,7 +2769,7 @@ dependencies = [
]

[[package]]
name = "payjoin-service"
name = "payjoin-mailroom"
version = "0.0.1"
dependencies = [
"anyhow",
Expand Down Expand Up @@ -2808,7 +2808,7 @@ dependencies = [
"http",
"once_cell",
"payjoin",
"payjoin-service",
"payjoin-mailroom",
"rcgen 0.14.3",
"reqwest",
"rustls 0.23.31",
Expand Down
4 changes: 2 additions & 2 deletions Cargo-recent.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2769,7 +2769,7 @@ dependencies = [
]

[[package]]
name = "payjoin-service"
name = "payjoin-mailroom"
version = "0.0.1"
dependencies = [
"anyhow",
Expand Down Expand Up @@ -2808,7 +2808,7 @@ dependencies = [
"http",
"once_cell",
"payjoin",
"payjoin-service",
"payjoin-mailroom",
"rcgen 0.14.3",
"reqwest",
"rustls 0.23.31",
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ members = [
"payjoin-directory",
"payjoin-test-utils",
"payjoin-ffi",
"payjoin-service",
"payjoin-mailroom",
]
resolver = "2"

Expand All @@ -16,7 +16,7 @@ payjoin-fuzz = { path = "fuzz" }
ohttp-relay = { path = "ohttp-relay" }
payjoin = { path = "payjoin" }
payjoin-directory = { path = "payjoin-directory" }
payjoin-service = { path = "payjoin-service" }
payjoin-mailroom = { path = "payjoin-mailroom" }
payjoin-test-utils = { path = "payjoin-test-utils" }

[profile.crane]
Expand Down
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,9 @@ The main Payjoin Dev Kit library which provides tools for implementing both Asyn

A CLI tool which performs no-frills Payjoin. It is a reference implementation of the Payjoin Dev Kit which uses a Bitcoin Core wallet.

### [`ohttp-relay`](https://github.com/payjoin/rust-payjoin/tree/master/ohttp-relay)
### [`payjoin-mailroom`](https://github.com/payjoin/rust-payjoin/tree/master/payjoin-mailroom)

A Rust implementation of an Oblivious HTTP (OHTTP) relay resource.

**Disclaimer: Both this crate and the [IETF paper](https://ietf-wg-ohai.github.io/oblivious-http/draft-ietf-ohai-ohttp.html) are undergoing active revision. Use at your own risk.**

### [`payjoin-directory`](https://github.com/payjoin/rust-payjoin/tree/master/payjoin-directory)

A reference implementation for a Payjoin Directory which stores and forwards HTTP client messages between the sender and the receiver to allow for Async Payjoin transactions. Async Payjoin clients make requests to the directory using [Oblivious HTTP (OHTTP)](https://www.ietf.org/rfc/rfc9458.html) which prevents the directory from being able to link payjoins to specific client IP addresses.
An [Oblivious HTTP (OHTTP) Relay](https://github.com/payjoin/rust-payjoin/tree/master/ohttp-relay) and a BIP77 [Payjoin Directory](https://github.com/payjoin/rust-payjoin/tree/master/payjoin-directory) combined in one binary.

### [`payjoin-test-utils`](https://github.com/payjoin/rust-payjoin/tree/master/payjoin-test-utils)

Expand Down
2 changes: 1 addition & 1 deletion contrib/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if [ -f "$LOCKFILE" ]; then
fi

DEPS="recent minimal"
CRATES="ohttp-relay payjoin payjoin-cli payjoin-directory payjoin-ffi payjoin-service"
CRATES="ohttp-relay payjoin payjoin-cli payjoin-directory payjoin-ffi payjoin-mailroom"

for dep in $DEPS; do
cargo --version
Expand Down
4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
"payjoin-cli" = "--features v1,v2";
"payjoin-directory" = "";
"ohttp-relay" = "";
"payjoin-service" = "--features acme,telemetry";
"payjoin-mailroom" = "--features acme,telemetry";
};

# nix2container for building OCI/Docker images
Expand Down Expand Up @@ -193,7 +193,7 @@
tag = self.shortRev or "dirty";
in
{
"payjoin-service-image" = mkContainerImage "payjoin-service" packages.payjoin-service tag;
"payjoin-mailroom-image" = mkContainerImage "payjoin-mailroom" packages.payjoin-mailroom tag;
};

devShells = builtins.mapAttrs (
Expand Down
2 changes: 1 addition & 1 deletion payjoin-directory/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ impl<D: Db> Service<D> {
debug!("Service::serve_request: {:?}", &path_segments);

// Best-effort validation that the relay and gateway aren't on the same
// payjoin-service instance
// payjoin-mailroom instance
if let Some(header_value) =
parts.headers.get(ohttp_relay::sentinel::HEADER_NAME).and_then(|v| v.to_str().ok())
{
Expand Down
2 changes: 1 addition & 1 deletion payjoin-ffi/dart/native/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ payjoin-ffi = { path = "../.." }
ohttp-relay = { path = "../../../ohttp-relay" }
payjoin = { path = "../../../payjoin" }
payjoin-directory = { path = "../../../payjoin-directory" }
payjoin-service = { path = "../../../payjoin-service" }
payjoin-mailroom = { path = "../../../payjoin-mailroom" }
payjoin-test-utils = { path = "../../../payjoin-test-utils" }
4 changes: 2 additions & 2 deletions payjoin-ffi/javascript/test-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ path = "../../../payjoin"
[patch.crates-io.payjoin-directory]
path = "../../../payjoin-directory"

[patch.crates-io.payjoin-service]
path = "../../../payjoin-service"
[patch.crates-io.payjoin-mailroom]
path = "../../../payjoin-mailroom"

[patch.crates-io.payjoin-test-utils]
path = "../../../payjoin-test-utils"
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions payjoin-service/Cargo.toml → payjoin-mailroom/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "payjoin-service"
name = "payjoin-mailroom"
version = "0.0.1"
description = "Unified Payjoin Directory and OHTTP Relay service"
repository = "https://github.com/payjoin/rust-payjoin/tree/master/payjoin-service"
description = "Combined Payjoin Directory and OHTTP Relay"
repository = "https://github.com/payjoin/rust-payjoin/tree/master/payjoin-mailroom"
keywords = ["bip77", "bitcoin", "ohttp", "payjoin", "privacy"]
categories = [
"cryptography::cryptocurrencies",
Expand Down
54 changes: 54 additions & 0 deletions payjoin-mailroom/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Payjoin Mailroom

The Payjoin Mailroom is a unified Payjoin Directory and OHTTP Relay server. Combines [payjoin-directory](../payjoin-directory/README.md) and [ohttp-relay](../ohttp-relay/README.md) into a single binary.

Note that this binary is under active development and thus the CLI and configuration file may be unstable.

## Configuration

payjoin-mailroom reads configuration from `config.toml` (or the path given with `--config`). Every setting can also be supplied via environment variables prefixed with `PJ_`, using double underscores for nesting (e.g., `PJ_TELEMETRY__ENDPOINT`).

## Usage

### Cargo

```sh
cargo run
```

### Docker Compose

A simple [docker-compose.yml](docker-compose.yml) is provided for convenience.

```sh
docker compose up
```

### Nix

The rust-payjoin flake also provides `payjoin-mailroom` as a package.

```sh
nix run .#payjoin-mailroom -- --config payjoin-mailroom/config.toml
```

## Telemetry

payjoin-mailroom supports **optional** OpenTelemetry-based telemetry (metrics, traces, and logs). Build with `--features telemetry` and add a `[telemetry]` section to your config:

```toml
[telemetry]
endpoint = "https://otlp-gateway-prod-us-west-0.grafana.net/otlp"
auth_token = "<base64 instanceID:token>"
operator_domain = "your-domain.example.com"
```

Or set the equivalent environment variables:

```sh
export PJ_TELEMETRY__ENDPOINT="https://otlp-gateway-prod-us-west-0.grafana.net/otlp"
export PJ_TELEMETRY__AUTH_TOKEN="<base64 instanceID:token>"
export PJ_TELEMETRY__OPERATOR_DOMAIN="your-domain.example.com"
```

When no `[telemetry]` section is present and no `PJ_TELEMETRY__*` variables are set, it falls back to local-only console tracing.
4 changes: 4 additions & 0 deletions payjoin-mailroom/contrib/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
set -e

cargo test --locked --package payjoin-mailroom --verbose --all-features --lib
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
payjoin-service:
image: payjoin/payjoin-service:latest
payjoin-mailroom:
image: payjoin/payjoin-mailroom:latest
command: ["--config", "/config/config.toml"]
environment:
RUST_LOG: "info"
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions payjoin-service/src/lib.rs → payjoin-mailroom/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub async fn serve(config: Config, meter_provider: Option<SdkMeterProvider>) ->
Ok(())
}

/// Serves payjoin-service with manual TLS configuration.
/// Serves payjoin-mailroom with manual TLS configuration.
///
/// Binds to `config.listener` (use port 0 to let the OS assign a free port) and returns
/// the actual bound port and a task handle.
Expand Down Expand Up @@ -96,7 +96,7 @@ pub async fn serve_manual_tls(
Ok((port, handle))
}

/// Serves payjoin-service with ACME-managed TLS certificates.
/// Serves payjoin-mailroom with ACME-managed TLS certificates.
///
/// Uses `tokio-rustls-acme` to automatically obtain and renew TLS
/// certificates from Let's Encrypt via the TLS-ALPN-01 challenge.
Expand Down
8 changes: 4 additions & 4 deletions payjoin-service/src/main.rs → payjoin-mailroom/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use clap::Parser;
use opentelemetry_sdk::metrics::SdkMeterProvider;
use payjoin_service::{cli, config};
use payjoin_mailroom::{cli, config};
use tracing_subscriber::filter::LevelFilter;
use tracing_subscriber::EnvFilter;

Expand All @@ -20,10 +20,10 @@ async fn main() -> anyhow::Result<()> {

#[cfg(feature = "acme")]
if config.acme.is_some() {
return payjoin_service::serve_acme(config, meter_provider).await;
return payjoin_mailroom::serve_acme(config, meter_provider).await;
}

payjoin_service::serve(config, meter_provider).await
payjoin_mailroom::serve(config, meter_provider).await
}

fn init_tracing() -> Option<SdkMeterProvider> {
Expand All @@ -41,7 +41,7 @@ fn init_tracing_with_telemetry(telemetry: &config::TelemetryConfig) -> SdkMeterP
use opentelemetry_sdk::Resource;

let resource = Resource::builder()
.with_service_name("payjoin-service")
.with_service_name("payjoin-mailroom")
.with_attribute(KeyValue::new("operator.domain", telemetry.operator_domain.clone()))
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub struct MetricsService {
impl MetricsService {
pub fn new(provider: Option<SdkMeterProvider>) -> Self {
let provider = provider.unwrap_or_default();
let meter = provider.meter("payjoin-service");
let meter = provider.meter("payjoin-mailroom");

let http_requests_total = meter
.u64_counter(HTTP_REQUESTS)
Expand Down
File renamed without changes.
54 changes: 0 additions & 54 deletions payjoin-service/README.md

This file was deleted.

4 changes: 0 additions & 4 deletions payjoin-service/contrib/test.sh

This file was deleted.

2 changes: 1 addition & 1 deletion payjoin-test-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ payjoin = { version = "1.0.0-rc.1", features = [
"_manual-tls",
"_test-utils",
] }
payjoin-service = { path = "../payjoin-service", features = ["_manual-tls"] }
payjoin-mailroom = { path = "../payjoin-mailroom", features = ["_manual-tls"] }
rcgen = "0.14.3"
reqwest = { version = "0.12.23", default-features = false, features = [
"rustls-tls",
Expand Down
Loading
Loading