Repository navigation
Open
Description
I ran the following from latest master (c35b20a):
RUST_LOG=debug cargo run --bin payjoin-directory
Compiling payjoin-directory v0.0.2 (/home/blu/src/rust-payjoin/payjoin-directory)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.72s
Running `target/debug/payjoin-directory`
Logging initialized
2025-06-09T12:58:39.286312Z INFO payjoin_directory::key_config: Loaded existing OHTTP Key Configuration from ohttp_keys/1.ikmI checked the code and saw that the directory runs on port 8080 by default. I tried to run a receive with the following config.toml:
# Nigiri uses the following RPC credentials
[bitcoind]
rpcuser = "admin1"
rpcpassword = "123"
rpchost = "http://localhost:18443/wallet/receiver"
# For v2, our config also requires a payjoin directory server and OHTTP relay
[v2]
pj_directory = "http://0.0.0.0:8080"
ohttp_relays = ["https://pj.benalleng.com", "https://pj.bobspacebkk.com", "https://ohttp.achow101.com"]And got a 400 Bad Request:
UST_LOG=debug cargo run --bin payjoin-cli -- receive 10000
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.10s
Running `/home/blu/src/rust-payjoin/target/debug/payjoin-cli receive 10000`
[2025-06-09T13:07:46Z DEBUG payjoin_cli::app::config] App config: Config { db_path: "payjoin.sled", max_fee_rate: None, bitcoind: BitcoindConfig { rpchost: Url { scheme: "http", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("localhost")), port: Some(18443), path: "/wallet/receiver", query: None, fragment: None }, cookie: None, rpcuser: "admin1", rpcpassword: "123" }, version: Some(V2(V2Config { ohttp_keys: None, ohttp_relays: [Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("pj.benalleng.com")), port: None, path: "/", query: None, fragment: None }, Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("pj.bobspacebkk.com")), port: None, path: "/", query: None, fragment: None }, Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("ohttp.achow101.com")), port: None, path: "/", query: None, fragment: None }], pj_directory: Url { scheme: "http", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("localhost")), port: Some(8080), path: "/", query: None, fragment: None } })) }
[2025-06-09T13:07:46Z DEBUG sled::pagecache::iterator] ordering before clearing tears: {0: 0}, max_header_stable_lsn: 0
[2025-06-09T13:07:46Z DEBUG sled::pagecache::iterator] in clean_tail_tears, found missing item in tail: None and we'll scan segments {0: 0} above lowest lsn 0
[2025-06-09T13:07:46Z DEBUG sled::pagecache::iterator] filtering out segments after detected tear at (lsn, lid) 12635
[2025-06-09T13:07:46Z DEBUG sled::pagecache::iterator] hit max_lsn 12635 in iterator, stopping
[2025-06-09T13:07:46Z DEBUG sled::pagecache::snapshot] zeroing the end of the recovered segment at lsn 0 between lids 12636 and 524287
[2025-06-09T13:07:46Z DEBUG sled::pagecache::blob_io] gc_blobs removing any blob with an lsn above 12636
[2025-06-09T13:07:46Z DEBUG sled::pagecache::segment] SA starting with tip 524288 stable -1 free {}
[2025-06-09T13:07:46Z DEBUG sled::pagecache::iobuf] starting log at recovered active offset 12636, recovered lsn 12636
[2025-06-09T13:07:46Z DEBUG sled::pagecache::iobuf] starting IoBufs with next_lsn: 12636 next_lid: 12636
[2025-06-09T13:07:46Z DEBUG sled::pagecache] load_snapshot loading pages from 0..8
[2025-06-09T13:07:46Z DEBUG bitcoincore_rpc] JSON-RPC request: getblockchaininfo []
[2025-06-09T13:07:46Z DEBUG bitcoincore_rpc] JSON-RPC request: getnetworkinfo []
[2025-06-09T13:07:46Z DEBUG bitcoincore_rpc] JSON-RPC request: getnewaddress [null,null]
[2025-06-09T13:07:46Z DEBUG bitcoincore_rpc] JSON-RPC request: getblockchaininfo []
[2025-06-09T13:07:46Z DEBUG bitcoincore_rpc] JSON-RPC request: getnetworkinfo []
Bootstrapping private network transport over Oblivious HTTP
[2025-06-09T13:07:46Z DEBUG reqwest::connect] starting new connection: http://localhost:8080/
[2025-06-09T13:07:46Z DEBUG reqwest::connect] proxy(https://pj.benalleng.com) intercepts 'http://localhost:8080/'
[2025-06-09T13:07:46Z DEBUG rustls::client::hs] No cached session for DnsName("pj.benalleng.com")
[2025-06-09T13:07:46Z DEBUG rustls::client::hs] Not resuming any session
[2025-06-09T13:07:46Z DEBUG rustls::client::hs] Using ciphersuite TLS13_AES_256_GCM_SHA384
[2025-06-09T13:07:46Z DEBUG rustls::client::tls13] Not resuming
[2025-06-09T13:07:46Z DEBUG rustls::client::tls13] TLS1.3 encrypted extensions: [ServerNameAck]
[2025-06-09T13:07:46Z DEBUG rustls::client::hs] ALPN protocol is None
[2025-06-09T13:07:46Z DEBUG rustls::common_state] Sending warning alert CloseNotify
[2025-06-09T13:07:46Z DEBUG sled::pagecache::logger] IoBufs dropped
Error: Unexpected status code from payjoin directory: 400 Bad RequestI also tried using http://localhost:8080 for pj_directory. When I change the pj_directory to https://payjo.in, everything works fine. I'm wondering what step I am missing here to run and use a directory locally. There doesn't
Metadata
Metadata
Assignees
Labels
No labels
Activity
zealsham commentedon Jun 9, 2025
I think this issues occurs because the Ohttp relays can not resolve http://localhost:8080 to point to your local host . Localhost will be unresolvable for the relays since that will point to their own local host .
A work around would be making your local host reachable over the internet using something like Ngrok or any tunnel of your choosing .
DanGould commentedon Jun 9, 2025
another unsafe workaround is to terminate directory TLS with a reverse proxy like nginx and hand packets directly to the directory, ignoring the use of an OHTTP relay.
thebrandonlucas commentedon Jun 10, 2025
This makes a lot of sense, thank you.
I tried the
ngrokmethod and got a bit further, but still no dice. Looks like it still has something to do with a failure to bootstrap OHTTP properly, perhaps due to a.well-known/ohttp-gatewaynot being setup by ngrok. On the ngrok server side, we're seeing a500 Internal Server Errorwhen trying toPOSTto the.well-known/ohttp-gateway. Perhaps the ability to do this is what we need yet is disabled on the ngrok side? I may have to try this using a solution on my own VPS via a self-hostable alternative to ngrok like frp?payjoin-directory:cargo run --bin payjoin-directory Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.07s Running `/home/blu/src/rust-payjoin/target/debug/payjoin-directory` Logging initialized 2025-06-10T15:12:04.178298Z INFO payjoin_directory::key_config: Loaded existing OHTTP Key Configuration from ohttp_keys/1.ikm 2025-06-10T15:12:11.357669Z ERROR payjoin_directory: Redis error: Connection refused (os error 111) 2025-06-10T15:12:11.357722Z ERROR payjoin_directory: Internal server error: Internal server errorngrok http 8080:HTTP Requests ------------- 11:12:11.135 EDT GET /.well-known/ohttp-gateway 200 OK 11:12:11.331 EDT POST /.well-known/ohttp-gateway 500 Internal Server Error 11:12:10.879 EDT GET /.well-known/ohttp-gateway 200 OKpayjoin-cli receive:RUST_LOG=DEBUG cargo run --bin payjoin-cli -- receive 10000 Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.10s Running `/home/blu/src/rust-payjoin/target/debug/payjoin-cli receive 10000` [2025-06-10T15:12:10Z DEBUG payjoin_cli::app::config] App config: Config { db_path: "payjoin.sled", max_fee_rate: None, bitcoind: BitcoindConfig { rpchost: Url { scheme: "http", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("localhost")), port: Some(18443), path: "/wallet/receiver", query: None, fragment: None }, cookie: None, rpcuser: "admin1", rpcpassword: "123" }, version: Some(V2(V2Config { ohttp_keys: None, ohttp_relays: [Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("pj.benalleng.com")), port: None, path: "/", query: None, fragment: None }, Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("pj.bobspacebkk.com")), port: None, path: "/", query: None, fragment: None }, Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("ohttp.achow101.com")), port: None, path: "/", query: None, fragment: None }], pj_directory: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("f619-96-75-30-113.ngrok-free.app")), port: None, path: "/", query: None, fragment: None } })) } [2025-06-10T15:12:10Z DEBUG sled::pagecache::iterator] ordering before clearing tears: {0: 0}, max_header_stable_lsn: 0 [2025-06-10T15:12:10Z DEBUG sled::pagecache::iterator] in clean_tail_tears, found missing item in tail: None and we'll scan segments {0: 0} above lowest lsn 0 [2025-06-10T15:12:10Z DEBUG sled::pagecache::iterator] filtering out segments after detected tear at (lsn, lid) 14405 [2025-06-10T15:12:10Z DEBUG sled::pagecache::iterator] hit max_lsn 14405 in iterator, stopping [2025-06-10T15:12:10Z DEBUG sled::pagecache::snapshot] zeroing the end of the recovered segment at lsn 0 between lids 14406 and 524287 [2025-06-10T15:12:10Z DEBUG sled::pagecache::snapshot] removing old snapshot file "/home/blu/src/rust-payjoin/receiver/payjoin.sled/snap.00000000000034D4" [2025-06-10T15:12:10Z DEBUG sled::pagecache::blob_io] gc_blobs removing any blob with an lsn above 14406 [2025-06-10T15:12:10Z DEBUG sled::pagecache::segment] SA starting with tip 524288 stable -1 free {} [2025-06-10T15:12:10Z DEBUG sled::pagecache::iobuf] starting log at recovered active offset 14406, recovered lsn 14406 [2025-06-10T15:12:10Z DEBUG sled::pagecache::iobuf] starting IoBufs with next_lsn: 14406 next_lid: 14406 [2025-06-10T15:12:10Z DEBUG sled::pagecache] load_snapshot loading pages from 0..8 [2025-06-10T15:12:10Z DEBUG bitcoincore_rpc] JSON-RPC request: getblockchaininfo [] [2025-06-10T15:12:10Z DEBUG bitcoincore_rpc] JSON-RPC request: getnetworkinfo [] [2025-06-10T15:12:10Z DEBUG bitcoincore_rpc] JSON-RPC request: getnewaddress [null,null] [2025-06-10T15:12:10Z DEBUG bitcoincore_rpc] JSON-RPC request: getblockchaininfo [] [2025-06-10T15:12:10Z DEBUG bitcoincore_rpc] JSON-RPC request: getnetworkinfo [] Bootstrapping private network transport over Oblivious HTTP [2025-06-10T15:12:10Z DEBUG reqwest::connect] starting new connection: https://f619-96-75-30-113.ngrok-free.app/ [2025-06-10T15:12:10Z DEBUG reqwest::connect] proxy(https://ohttp.achow101.com) intercepts 'https://f619-96-75-30-113.ngrok-free.app/' [2025-06-10T15:12:10Z DEBUG rustls::client::hs] No cached session for DnsName("ohttp.achow101.com") [2025-06-10T15:12:10Z DEBUG rustls::client::hs] Not resuming any session [2025-06-10T15:12:10Z DEBUG rustls::client::hs] Using ciphersuite TLS13_AES_256_GCM_SHA384 [2025-06-10T15:12:10Z DEBUG rustls::client::tls13] Not resuming [2025-06-10T15:12:10Z DEBUG rustls::client::tls13] TLS1.3 encrypted extensions: [ServerNameAck] [2025-06-10T15:12:10Z DEBUG rustls::client::hs] ALPN protocol is None [2025-06-10T15:12:10Z DEBUG rustls::client::hs] No cached session for DnsName("f619-96-75-30-113.ngrok-free.app") [2025-06-10T15:12:10Z DEBUG rustls::client::hs] Not resuming any session [2025-06-10T15:12:11Z DEBUG rustls::client::hs] Using ciphersuite TLS13_AES_128_GCM_SHA256 [2025-06-10T15:12:11Z DEBUG rustls::client::tls13] Not resuming [2025-06-10T15:12:11Z DEBUG rustls::client::tls13] TLS1.3 encrypted extensions: [] [2025-06-10T15:12:11Z DEBUG rustls::client::hs] ALPN protocol is None [2025-06-10T15:12:11Z DEBUG rustls::common_state] Sending warning alert CloseNotify [2025-06-10T15:12:11Z DEBUG rustls::common_state] Sending warning alert CloseNotify [2025-06-10T15:12:11Z DEBUG sled::pagecache::iobuf] advancing offset within the current segment from 14406 to 15285 [2025-06-10T15:12:11Z DEBUG sled::pagecache::iobuf] wrote lsns 14406-15284 to disk at offsets 14406-15284, maxed false complete_len 879 [2025-06-10T15:12:11Z DEBUG sled::pagecache::iobuf] mark_interval(14406, 879) [2025-06-10T15:12:11Z DEBUG sled::pagecache::iobuf] new highest interval: 14406 - 15284 [2025-06-10T15:12:11Z DEBUG sled::pagecache::iobuf] make_stable(15284) returning Receive session established Request Payjoin by sharing this Payjoin Uri: bitcoin:bcrt1qpy8gqcfjplq29w5chqa5tf8345j77msnk78xvj?amount=0.0001&pj=HTTPS://F619-96-75-30-113.NGROK-FREE.APP/6H9K0QM6K9Z47%23RK1QFPV6P4KD55RKZNRCCLS37KFG4JSMA0PGNZ29AGGA7EZ6Z9GCTYDX+OH1QYP3UQPXKKXS0JFP2H5TUW930DN7KUH3UAUTHDPLYD2U7DU8M4DRXLQ+EX1EWWYJ6Q Polling receive request... [2025-06-10T15:12:11Z DEBUG reqwest::connect] starting new connection: https://ohttp.achow101.com/ [2025-06-10T15:12:11Z DEBUG rustls::client::hs] No cached session for DnsName("ohttp.achow101.com") [2025-06-10T15:12:11Z DEBUG rustls::client::hs] Not resuming any session [2025-06-10T15:12:11Z DEBUG rustls::client::hs] Using ciphersuite TLS13_AES_256_GCM_SHA384 [2025-06-10T15:12:11Z DEBUG rustls::client::tls13] Not resuming [2025-06-10T15:12:11Z DEBUG rustls::client::tls13] TLS1.3 encrypted extensions: [ServerNameAck] [2025-06-10T15:12:11Z DEBUG rustls::client::hs] ALPN protocol is None [2025-06-10T15:12:11Z DEBUG rustls::common_state] Sending warning alert CloseNotify [2025-06-10T15:12:11Z DEBUG sled::pagecache::logger] IoBufs dropped Error: GET fallback failedthebrandonlucas commentedon Jun 11, 2025
Update: Got past this error! Turns out it wasn't
ngrok, it was the fact that I did not haveredisinstalled and running (the other error message in thepayjoin-directorylogs).Now it just seems that there is an error with the size of the response that the receiver is sending to the directory. It gets all the way to trying to send the response back to the sender for broadcast via the directory. Here is the flow with the new error
Directory:
Receiver
Sender
nothingmuch commentedon Jun 11, 2025
Trying to understand the motivations, wouldn't it make more sense to also run an OHTTP relay locally?
And to debug this particular issue, what happens if you bypass the OHTTP relay entirely (by setting the relay URI to be your directory's OHTTP gateway URI, i.e.
HTTPS://F619-96-75-30-113.NGROK-FREE.APP/.well-known/ohttp-gateway?We should probably improve the error reporting, since unexpected response sizes typically mean the relay is returning an error response itself instead of relaying a response from the OHTTP gateway it would make sense to at least print the status code if not the response body as well
thebrandonlucas commentedon Jun 11, 2025
Motivation is ultimately just to learn how to run a Payjoin Directory (and OHTTP relay as well, for that matter) with the purpose of eventually writing up a tutorial and/or packaging it up via nix or docker or something to make these as easy as possible for people to run. Ultimate goal is to have more and more people running OHTTP relays and payjoin directories because it'll be so easy. I'm playing around with this inspired by discussion in #735: could we package up the payjoin-directory or OHTTP relay (with prometheus/grafana) such that people have something easy to run and deploy out of the box if they want to support payjoin?
I only didn't run an ohttp relay locally because I'm unsure how and didn't anticipate the complications, but I can pursue that route instead. FWIW I am running this now on a remote server and got the same error as above, so now I'm trying to find the gap in my knowledge of how the production payjoin directories are running successfully but mine isn't.
Thanks for the suggestion, I'll try this when I have a moment later.
Agreed, I notice
RUST_LOG=debughas no effect onpayjoin-directoryunlike withpayjoin-cli.nothingmuch commentedon Jun 11, 2025
This is a useful debugging tidbit FWIW, the response body received by the relay is just sent as is to the directory, but it should probably come with a warning to be extra sure that real requests definitely go through the relay or privacy falls apart
It has a few
tracelogs, but i don't think the sender is reaching the directory, if it generates an error response it would still be 8192 bytes when encapsulatedthebrandonlucas commentedon Jun 11, 2025
@nothingmuch Okay updates after playing around a bit more:
Sorry I'm not 100% sure what you mean here, did you mean literally pass
HTTPS://F619-96-75-30-113.NGROK-FREE.APP/.well-known/ohttp-gatewayas theohttp_relaysparam topayjoin-cli'sconfig.toml?e.g.
ohttp_relays = ["HTTPS://F619-96-75-30-113.NGROK-FREE.APP/.well-known/ohttp-gateway"]If so, I did that, and also tried just
HTTPS://F619-96-75-30-113.NGROK-FREE.APP. Both resulted in:I also took your suggestion to run
ohttp-relaylocally. I can now reliably reproduce everything with everything running locally.With this in both my receiver and sender
config.toml:A payjoin succeeds. If I change it to this however, I can reproduce the errors as before:
Receiver run:
Sender run:
Thus far I had been trying everything on latest master (aad4c0f), but I figured I should switch to the latest release version relevant to
payjoin-directory(8456a6a, or payjoin-directory-0.0.2). Same error as above. I am curious what commit/release thepayjo.indirectory is running on and what differences there may be with how I'm running this, or if it is simply running on a different version where this works.