Skip to content

Commit 8777c16

Browse files
authored
Make payjoin-cli v1 / v2 features additive (payjoin#538)
Fix payjoin#500 Following @nothingmuch's suggestion: > 1. make appconfig more hierarchical, and support both v1 and v2 specific options in sub-structures, that are not feature gated. also move bitcoind related stuff to its own substructure > > 2. out of appconfig, generate helper stuff, again i was focused on a struct representing bitcoind (or more generally wallet) capabilities for payjoin, to avoid needing to impl the `bitcoind` method in the trait impls and to hide the details (e.g. error checking, psbt parsing, etc) from the actual App impls, optimizing readability to correspond high level description of the spec > > 3. adding an explicit --prefer-bip-78 or option, or something similar, for payjoin-cli compiled with both. due to the backwards compatibility of bip77 that probably requires more than one flag or something that is not just boolean valued, e.g. as a sender be able to send bip78 only even to a bip77 receiver and even if v2 support is compiled can be useful for e2e testing with a single build > I think we're much closer to @nothingmuch's goal: > my goal was making sure both app/v{1,2}.rs kind of give a high level overview of both the protocol and the code, de-emphasizing the details like how to talk to bitcoind and emphasizing its role as a reference implementation for bip 77 specifically. Perhaps some network details could still be abstracted away to make this even more clear. But in terms of repaying tech debt and fixing the devex by making features additive, this should be complete.
2 parents 3b95ff2 + bfa282f commit 8777c16

File tree

10 files changed

+688
-426
lines changed

10 files changed

+688
-426
lines changed

payjoin-cli/contrib/test.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env bash
22
set -e
33

4-
cargo test --locked --package payjoin-cli --verbose --no-default-features --features=_danger-local-https,v2 --test e2e
5-
cargo test --locked --package payjoin-cli --verbose --no-default-features --features=v1,_danger-local-https
4+
cargo test --locked --package payjoin-cli --verbose --all-features

payjoin-cli/example.config.toml

+32-33
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,25 @@
22
## Payjoin config.toml configuration file. Lines beginning with # are comments.
33
##
44

5-
# Bitcoin RPC Connection Settings
6-
# ------------------------------
5+
# Common Settings
6+
# --------------
7+
8+
# The path to the database file
9+
db_path = "payjoin.db"
710

11+
# The maximum fee rate that the receiver is willing to pay (in sat/vB)
12+
max_fee_rate = 2.0
813

14+
# Bitcoin RPC Connection Settings
15+
# ------------------------------
16+
[bitcoind]
917
# The RPC host of the wallet to connect to.
1018
# For example, if the wallet is "sender", then default values are:
1119
# - mainnet: http://localhost:8332/wallet/sender
1220
# - testnet: http://localhost:18332/wallet/sender
1321
# - regtest: http://localhost:18443/wallet/sender
1422
# - signet: http://localhost:38332/wallet/sender
15-
bitcoind_rpchost="http://localhost:18443/wallet/sender"
16-
23+
rpchost = "http://localhost:18443/wallet/sender"
1724

1825
# The RPC .cookie file used only for local authentication to bitcoind.
1926
# If rpcuser and rpcpassword are being used, this is not necessary.
@@ -22,36 +29,28 @@ bitcoind_rpchost="http://localhost:18443/wallet/sender"
2229
# MacOS: ~/Library/Application Support/Bitcoin/<NETWORK>/.cookie
2330
# Windows Vista and later: C:\Users\YourUserName\AppData\Roaming\Bitcoin\<NETWORK>\.cookie
2431
# Windows XP: C:\Documents and Settings\YourUserName\Application Data\Bitcoin\<NETWORK>\.cookie
25-
# bitcoind_cookie=
26-
32+
cookie = ""
2733

2834
# The rpcuser to connect to (specified in bitcoin.conf).
29-
bitcoind_rpcuser="user"
30-
35+
rpcuser = "user"
3136

3237
# The rpcpassword of the user to connect to (specified in bitcoin.conf).
33-
bitcoind_rpcpassword="password"
34-
35-
## Payjoin Settings
36-
## ----------------
37-
38-
39-
# (v1, receiver only) The port for v1 receiving servers to bind to.
40-
port="3000"
41-
42-
43-
# (v1, receiver only) The payjoin endpoint which coordinates the transaction.
44-
pj_endpoint="https://localhost:3000"
45-
46-
47-
# (v2 only) The payjoin directory to rendezvous at.
48-
pj_directory = "https://payjo.in"
49-
50-
51-
# (v2 only) The OHTTP relay that will forward requests to the OHTTP Gateway, which will forward to the pj_endpoint directory.
52-
ohttp_relay="https://pj.bobspacebkk.com"
53-
54-
55-
# (v2 only, optional) The HPKE keys which need to be fetched ahead of time from the pj_endpoint for the payjoin packets to be encrypted.
56-
# These can now be fetched and no longer need to be configured.
57-
ohttp_keys="./path/to/ohttp_keys"
38+
rpcpassword = "password"
39+
40+
# Version Configuration
41+
# -------------------
42+
# Uncomment ONE of the following version configurations depending on which version you want to use
43+
44+
# Version 1 Configuration
45+
# [v1]
46+
# port = 3000
47+
# pj_endpoint = "https://localhost:3000"
48+
49+
# Version 2 Configuration
50+
# [v2]
51+
# pj_directory = "https://payjo.in"
52+
# ohttp_relay = "https://pj.bobspacebkk.com"
53+
# # Optional: The HPKE keys which need to be fetched ahead of time from the pj_endpoint
54+
# # for the payjoin packets to be encrypted.
55+
# # These can now be fetched and no longer need to be configured.
56+
# ohttp_keys = "./path/to/ohttp_keys"

0 commit comments

Comments
 (0)