Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tx cut-through #332

Merged
merged 9 commits into from
Sep 12, 2024
Merged

Tx cut-through #332

merged 9 commits into from
Sep 12, 2024

Commits on Sep 6, 2024

  1. Add new typestates for output and input contributions

    This effectively splits the `ProvisionalProposal` state into three
    states that must be completed in order:
    - `WantsOutputs` allows the receiver to substitute or add output(s) and
    produces a WantsInputs
    - `WantsInputs` allows the receiver to contribute input(s) as needed to
    fund their outputs and produces a ProvisionalProposal
    - `ProvisionalProposal` is only responsible for finalizing the payjoin
    proposal and producing a PSBT that will be acceptable to the sender
    spacebear21 committed Sep 6, 2024
    Configuration menu
    Copy the full SHA
    b5dae4e View commit details
    Browse the repository at this point in the history
  2. Allow contributing multiple inputs

    `contribute_witness_input` is now `contribute_witness_inputs`.
    
    It takes an arbitrary number of inputs as a HashMap and returns a
    `ProvisionalProposal`.
    spacebear21 committed Sep 6, 2024
    Configuration menu
    Copy the full SHA
    4325e93 View commit details
    Browse the repository at this point in the history
  3. Implement disable_output_substitution check correctly

    When disable_output_substitition is true, the receiver may not change
    the script pubkey or decrease the value of their original output, but is
    allowed to increase the amount or add new outputs.
    spacebear21 committed Sep 6, 2024
    Configuration menu
    Copy the full SHA
    4062b56 View commit details
    Browse the repository at this point in the history
  4. Use a builder pattern in WantsOutputs and WantsInputs

    - Output substitution functions return a modified WantsOutputs instead
      of a WantsInputs. `freeze_outputs` is used to proceed to the
      WantsInputs step.
    - Similarly, contribute_witness_inputs returns a modified WantsInputs
      and `freeze_inputs` returns the ProvisionalProposal
    - One change output (aka drain script) must be identified if outputs are
      replaced. The change output receives all excess input amount from the
      receiver, and will be responsible for paying receiver fees if
      applicable.
    spacebear21 committed Sep 6, 2024
    Configuration menu
    Copy the full SHA
    5f9ca53 View commit details
    Browse the repository at this point in the history
  5. Implement receiver fee contributions

    Modify `apply_fee` to enable fee contributions from the receiver for
    fees not covered by the sender. This includes
    - any fees that pay for additional inputs, in excess of the sender's
      max_additional_fee_contribution.
    - all fees that pay for additional *outputs*.
    - in the case where the sender doesn't have a fee output (e.g. a sweep
      transaction), all tx fees are deducted from the receiver output.
    spacebear21 committed Sep 6, 2024
    Configuration menu
    Copy the full SHA
    d629598 View commit details
    Browse the repository at this point in the history
  6. Add batching tests

    Adds two integration tests for transaction cut-through:
    - Receiver UTXO consolidation
    - Receiver forwarding payment to a third-party
    
    Also fixes some issues in outputs and inputs contribution logic that
    became apparent while testing.
    spacebear21 committed Sep 6, 2024
    Configuration menu
    Copy the full SHA
    b737500 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    f4f2f37 View commit details
    Browse the repository at this point in the history
  8. Insert additional outputs in random indices

    Additional outputs should be inserted at random indices for privacy,
    while preserving the relative ordering of receiver/sender outputs from
    the original PSBT.
    
    This commit also ensures that `disable_output_substitution` checks are
    made for every receiver output, in the unlikely case that there are
    multiple receiver outputs in the original PSBT.
    spacebear21 committed Sep 6, 2024
    Configuration menu
    Copy the full SHA
    ab9b8b8 View commit details
    Browse the repository at this point in the history

Commits on Sep 11, 2024

  1. Allow receiver to specify a max feerate

    This ensures that the receiver does not pay more in fees than they would
    by building a separate transaction at max_feerate instead. That prevents
    a scenario where the sender specifies a `minfeerate` param that would
    require the receiver to pay more than they are willing to spend in fees.
    
    Privacy-conscious receivers should err on the side of indulgence with
    their preferred max feerate in order to satisfy their preference for
    privacy.
    
    This commit also adds a `max-feerate` receive option to payjoin-cli.
    spacebear21 committed Sep 11, 2024
    Configuration menu
    Copy the full SHA
    59c3d27 View commit details
    Browse the repository at this point in the history