Skip to content

payjoin-cli should demonstrate tx cut-through and utxo consolidation usage #1859

Open
1 of 1 issue completed

Description

@spacebear21

payjoin-cli is meant to be a reference implementation. We've built the API largely around enabling the receiver to do tx cut through and utxo consolidation, among others. There are a few integration tests that demonstrate this, but it would be cool to have these modes implemented in the reference cli as well. Perhaps receive can operate with different modes, e.g. --cut-through <address>, --consolidate...

Sub-issues

Sub-issues

1 of 1 Issues completed
Loading 1 sub-issues

Activity

  1. added this to the payjoin-cli-1.1 milestone on Sep 3, 2026
  2. AdamuAbba commented on Sep 10, 2026

    @AdamuAbba
    Contributor

    Hey @spacebear21 i'd love to take a jab at this as my first contribution to payjoin-cli and second contribution to rust-payjoin

    So here's what I'm thinking and i'd really appreciate any pointers i can get.

    i understand that the two modes in the issue are independent of each other. Consolidation is about the inputs the receiver adds, cut-through is about the outputs. That means you could reasonably want both at once i.e forward part of a payment to a supplier and tidy up your UTXO set in the same transaction.

    The integration tests you mentioned per feature:

    • --consolidate — contribute all available UTXOs instead of a single
      privacy-preserving one. Same thing receiver_consolidates_utxos does
      in the integration tests.
      fn receiver_consolidates_utxos() -> Result<(), BoxError> {
    • --cut-through <address>:<amount> — send part of the incoming payment
      on to a third party, as seen here receiver_forwards_payment.
      fn receiver_forwards_payment() -> Result<(), BoxError> {

    I'm planning one PR with two commits, so each one is self-contained and easier to review:

    1. --consolidate — adds the flag, wires it up in the v1 and v2 receiver paths, e2e test, README.
    2. --cut-through — same shape as above.

    I'd originally planned a third commit to make the flags survive payjoin-cli resume, but I think it belongs in both from the start rather than as a follow-up fix. Config is built once from the commandline at startup, and the flags are only read when the subcommand is Receive so on a resume run they're absent and silently fall back to the default.

    My instinct is to store the setting per-session in the CLI's own receive_sessions table, since it's an application preference

    conn.execute(
    "CREATE TABLE IF NOT EXISTS receive_sessions (
    session_id TEXT PRIMARY KEY,
    completed_at INTEGER
    )",
    [],
    )?;

    Both the fresh and the resumed run would then read the same row, so there's a single source of truth and no second code path to drift. I'd lean toward one serialized receive_options column rather than a column per setting. it matches how receive_session_events already stores event_data, and adding an option later becomes a struct field instead of another schema change.

    so let me know what you guys think?

  3. spacebear21 commented on Sep 10, 2026

    @spacebear21
    CollaboratorAuthor

    Hey @AdamuAbba , thanks for volunteering! That all sounds reasonable, I think it's worth attempting as you described then iterating from there once we have a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions