Skip to content

feat: add search by payref - #18

Merged
martinserts merged 2 commits into
tari-project:mainfrom
martinserts:payref-search
Jan 5, 2026
Merged

feat: add search by payref#18
martinserts merged 2 commits into
tari-project:mainfrom
martinserts:payref-search

Conversation

@martinserts

@martinserts martinserts commented Jan 4, 2026

Copy link
Copy Markdown

Description

Adds an API to search payments by payref

Closes #5

How Has This Been Tested?

Run the payment processor

$ cargo run                                                                                             
Starting Minotari Payment Processor...                                                                    
Database initialized.                                                                                     
Unsigned Transaction Creator worker started. Polling every 15 seconds.                       
Minotari Payment Processor started. Press Ctrl+C to shut down.
Transaction Signer worker started. Polling every 10 seconds.                            
Confirmation Checker worker started. Polling every 60 seconds. Required Confirmations: 5
Batch Creator worker started. Cycle interval: 120s.                                                       
Transaction Broadcaster worker started. Polling every 15 seconds.    
Axum API server listening on 0.0.0.0:9145

Fails on non-existent payref

curl -X 'GET' \
  'http://localhost:9145/v1/payments/ref/123' \
  -H 'accept: application/json'
{
  "error": "Payment not found"
}

Finds existing one

curl -X 'GET' \
  'http://localhost:9145/v1/payments/ref/d330d2c5f7c2242f87634ba7b2db408e24fa9dd9590354b421ba024f0467992a' \
  -H 'accept: application/json
{
  "payment_id": "b30b246c-735a-488f-81c9-5c2f6e814c17",
  "status": "CONFIRMED",
  "client_id": "pay_2_2",
  "account_name": "default",
  "recipient_address": "f2LUUip8F3LCQ6PyJvQiySCEpQyzTQSfvQF4YX3N9pY4rz4gAUprFgaL9JANYinYN2HGtKexmfX2odeNHfatoNhozaL",
  "amount": 2000000,
  "payref": "d330d2c5f7c2242f87634ba7b2db408e24fa9dd9590354b421ba024f0467992a",
  "mined_height": 372858,
  "mined_header_hash": "4216e29bbd79035af314fb64b48999295ff2431aaf76c7b299dde71b3753bbba",
  "mined_timestamp": 1765289952,
  "created_at": "2025-12-09T14:17:39Z",
  "updated_at": "2025-12-09T14:35:19Z"
}

What process can a PR reviewer use to test or verify this change?

Breaking Changes

  • None
  • Requires data directory on base node to be deleted
  • Requires hard fork
  • Other - Please specify

@martinserts martinserts self-assigned this Jan 4, 2026
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @martinserts, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new capability to the payment processor's API, enabling users to search for specific payments using their unique payment reference (payref). This feature is supported by a new database index on the payref column, ensuring efficient data retrieval, and integrates seamlessly into the existing API structure with appropriate error handling and documentation.

Highlights

  • New API Endpoint: A new GET API endpoint /v1/payments/ref/{payref} has been introduced, allowing users to search for payments using their unique payref.
  • Database Index for Performance: A new SQL migration adds an index on the payref column in the payments table, significantly optimizing the lookup performance for the new API endpoint.
  • Enhanced Payment Retrieval Logic: A new database function get_by_payref_with_batch_info was implemented to efficiently retrieve payment details, including associated batch information, based on the provided payref.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new API endpoint to search for payments using payref, which is a valuable addition. The implementation is sound, including a database migration to add a necessary index for performance. My primary feedback concerns an opportunity to improve code maintainability by addressing duplicated code in the database access layer. A new function is nearly identical to an existing one, and I've provided a suggestion to refactor this by extracting the common logic.

Comment thread minotari_payment_processor/src/db/payment.rs
@martinserts
martinserts merged commit 91c12f7 into tari-project:main Jan 5, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Payment processor search payref

2 participants