Skip to content

There is no documented best practice or API to display historical payjoin activity #336

Closed

Description

@DanGould

there is no off-the-shelf way to display historical activity for both senders receivers once a payjoin was initiated, updated, and completed. Basically we want to be able to add "payjoin happened" to a tx history screen (or cli output) in a consistent way. And we want to have documentation and an API around best practices wrt that

any particular protocol offers a number of user-facing APIs that are ~independent from the particular implementation. For Payjoin users, they need some thing that allows them to identify where their money went, and probably the'd expect this thing to be the same independently from which particular wallet they use. Similar probably could be said for some kind of identifier for the flow by which they can easily discern which payment is which if they, e.g., have multiple concurrent payments going on.
We probably can find some good contenders for both of these in the concrete LDK Node implementation, but it feels almost like a layer violation as it's essentially not up to us to make up typical APIs for the payjoin protocol. Hence my view that, as all implementors would have the same issue, it might be good to provide clear guidance in rust-payjoin itself.

@tnull

Fortunately there are multiple implementations (payjoin-cli, nolooking, LDK-Node, Mutiny) to reference and come up with a unified solution:

This seems more like a wallet issue than a rust-payjoin issue since the historical activity is related to a label of activity.

payjoin-cli details

payjoin-cli stores Sender and Receiver structs serialized as json and identified by Sender::pj_uri() and Receiver::id() respectively I think the first thing to figure out is whether or not this is sufficient. Historical data is maintained by the blockchain at bitcoin core without issue. Does this serialization make sense?

Activity

  1. added
    enhancement
    on Aug 6, 2024
  2. added
    documentation
    on Aug 13, 2024
  3. added this to the payjoin-1.0 milestone on Jan 3, 2025
  4. arminsabouri commented on Feb 24, 2025

    @arminsabouri
    Contributor
  5. arminsabouri commented on Feb 24, 2025

    @arminsabouri
    Contributor

    There seems to be two motivations for this work:

    1. Restore state in case of crashes. For example if we require the reciever to store the state machine state at each step they can recover at the last state in case of an application crash. This has an interesting consequence of also allowing the application to revert states. Not sure why you would want to at this moment.
    2. Displaying Payjoin history to the end user

    Imo there is two ways to consider this.

    1. We make it non optional. i.e for every reciver state machine update you must pass in a closure that will accept a encoded version of the state and persist it. If the caller really is not interested in persisting they can just pass in a dummy closure. Or we can keep it Optional. This will break the current interface unless we have a "persist" versions of the state transition functions. For example
    pub fn check_broadcast_suitability_and_persist(
            self,
            min_fee_rate: Option<FeeRate>,
            can_broadcast: impl Fn(&bitcoin::Transaction) -> Result<bool, ImplementationError>,
            persist_state: Option<impl Fn(&Self) -> ()>,
        ) -> Result<MaybeInputsOwned, ReplyableError> {
          ...
          if let Some(persist_state) = persist_state {
                    persist_state(&self);
          }
    1. We can impl serde on each state machine struct. The caller can chose to persist the state machine however they want.

    Edit: meeting notes
    Save state trait for sender + reciver. A simple interface would include a get method to get a key and a body which is serialized.

  6. arminsabouri commented on Feb 24, 2025

    @arminsabouri
    Contributor

    One open question is what format do we chose for the serialized data? JSON comes with some data overhead but its ussually universally accepted by most software projects. And it would make the implementation easier as we can just use serde::json.

    It looks like its also the prefered option of payjoin cli

    cc @DanGould

  7. self-assigned this
    on Feb 27, 2025
  8. 85 remaining items

  9. arminsabouri commented on Jul 18, 2025

    @arminsabouri
    Contributor

    The only thing missing is a refrence for "displaying historical payjoin activity" in payjoin-cli. But that can be its own ticket.

  10. DanGould commented on Jul 18, 2025

    @DanGould
    MemberAuthor

    I think a reference is fair bounds within this ticket. we still have not demonstrated best practice. getting there

  11. arminsabouri commented on Sep 2, 2025

    @arminsabouri
    Contributor

    The only thing missing is a refrence for "displaying historical payjoin activity" in payjoin-cli. But that can be its own ticket.

    This can take the shape of a new command --history <active | inactive>. Maybe by default we display all.
    Inactive sessions should be sorted by created_at. Active sessions should be sorted by completed_at. If session is fatally terminated error should be provided in human readable format. All sessions should be printed in a tabular format with \n delimiting sessions

  12. DanGould commented on Sep 3, 2025

    @DanGould
    MemberAuthor

    I'd prefer a subcommand -- history just like send, receive. vs an option --history. A first iteration that displays all seems appropriate.

  13. arminsabouri commented on Oct 3, 2025

    @arminsabouri
    Contributor

    Our refrence implementation has suitable db schema that can be used as a refrence for other integrations
    https://github.com/payjoin/rust-payjoin/blob/master/payjoin-cli/src/db/mod.rs

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

Metadata

Metadata

Assignees

Labels

documentationenhancement

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions