Skip to content

Commit

Permalink
Document payjoin-cli v2 in README
Browse files Browse the repository at this point in the history
  • Loading branch information
DanGould committed Dec 14, 2023
1 parent 6f5bc1b commit f764113
Showing 1 changed file with 61 additions and 18 deletions.
79 changes: 61 additions & 18 deletions payjoin-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,73 @@

## A command-line payjoin client for bitcoind in rust

### Install payjoin-cli
The `payjoin-cli` client enables sending and receiving of [BIP 78 Payjoin V1](https://github.com/bitcoin/bips/blob/master/bip-0078.mediawiki) and [Draft BIP Payjoin V2](https://github.com/bitcoin/bips/pull/1483) transactions. By default it supports Payjoin V1, and the `v2` feature sends and receives both since the protocol is backwards compatible. The implementation is built on [Payjoin Dev Kit](https://payjoindevkit.org).

While this code and design has had significant testing, it is still alpha-quality experimental software. Use at your own risk.
Independent audit is welcome.

## Install payjoin-cli

```console
cargo install payjoin-cli --version 0.0.2-alpha
```

Get a list of commands and options:

```console
RUST_LOG=debug cargo run -- --help
payjoin-cli --help
```

Manually create a `config.toml` file within the payjoin-cli directory
and configure it like so:
Either pass config options from cli, or manually edit a `config.toml` file within directory you run payjoin-cli from.
Configure it like so:

```toml
# config.toml
bitcoind_cookie = "/tmp/regtest1/bitcoind/regtest/.cookie"
bitcoind_rpchost = "http://localhost:18443/wallet/boom"
# config.toml
bitcoind_cookie = "/tmp/regtest1/bitcoind/regtest/.cookie"
# specify your wallet via rpchost connection string
bitcoind_rpchost = "http://localhost:18443/wallet/boom"
```

Your configuration details will vary, but you may use this as a template.

### Receive Payjoin
## Test Payjoin 2

### Install payjoin-cli with the V2 feature

```console
cargo install payjoin-cli --version 0.0.2-alpha --features v2
```

### V2 Configuration

In addition to the rpc configuration above, specify relevant ohttp and payjoin directory configuration as follows:

```toml
# config.toml
...
# a production payjoin directory server
pj_endpoint="https://payjo.in"
# payjo.in's ohttp_config with which ohttp requests will be encrypted
ohttp_config="AQAgQB9BwO5taMV6Skp4dl9HpFPw5SNUnnd-imKkUm8P5EIABAABAAM"
# an ohttp relay with ingress to payjo.in
ohttp_proxy="https://ohttp-relay.obscuravpn.io/payjoin"
```

### Asynchronous Operation

Send and receiver state is saved to json files in the directory from which payjoin-cli is run. Once a send or receive session is started, it may resume using the `--retry` argument if the payjoin has not yet complete.

```console
payjoin-cli --retry <subcommmand>
```

`<subcommand>` should be either send or receive followed by the same arguments as the first time it was called.

## Manual End to End Regtest Testing

Set up 2 local regtest wallets and fund them. This example uses "boom" and "ocean"
### Test Receive

Set up 2 local regtest wallets and fund them. This example uses "boom" and "ocean"

Determine the RPC port specified in your bitcoind's `bitcoin.conf`
file. 18443 is the default. This can be set like so:
Expand All @@ -32,7 +77,7 @@ file. 18443 is the default. This can be set like so:
rpcport = 18443
```

From the `payjoin-cli directory, where "boom" is the receiving wallet, 18443 is the rpc port, and you wish to request 10,000 sats run:
From the directory you'll run payjoin-cli, assuming "boom" is the name of the receiving wallet, 18443 is the rpc port, and you wish to request 10,000 sats run:

```console
RUST_LOG=debug cargo run --features=danger-local-https -- -r "http://localhost:18443/wallet/boom" receive 10000
Expand All @@ -47,13 +92,13 @@ This will generate a payjoin capable bip21 URI with which to accept payjoin:
BITCOIN:BCRT1QCJ4X75DUNY4X5NAWLM3CR8MALM9YAUYWWEWKWL?amount=0.00010&pj=https://localhost:3000
```

### Send Payjoin
### Test Send

Create a "sender" directory within payjoin-cli. Open a new terminal window and navigate to this directory.
Note: A wallet cannot payjoin with itself, need separate wallets.
Create another config.toml file in this directory and configure it as you did
previously, except replace the receiver wallet name with the sender
wallet name ("ocean" for me).

Note: A wallet cannot payjoin with itself, one needs separate wallets.

Create another `config.toml` file in the directory the sender will run from and configure it as you did previously, except replace the receiver wallet name with the sender

Using the previously generated bip21 URI, run the following command
from the sender directory:
Expand All @@ -62,8 +107,6 @@ from the sender directory:
RUST_LOG=debug cargo run -- send <BIP21> --fee-rate <FEE_SAT_PER_VB>
```

You should see the payjoin transaction occur and be able to verify the
Partially Signed Bitcoin Transaction (PSBT), inputs, and Unspent
Transaction Outputs (UTXOs).
You should see the payjoin transaction occur and be able to verify the Partially Signed Bitcoin Transaction (PSBT), inputs, and Unspent Transaction Outputs (UTXOs).

Congrats, you've payjoined!

0 comments on commit f764113

Please sign in to comment.