Commit ea038a4
feat: full PayRef implementation (#7154)
## Description
---
Implements the Payment Reference (PayRef) system for Tari, providing
globally unique identifiers for individual transaction outputs to enable
payment verification in Mimblewimble-based blockchains. PayRefs solve
the critical business problem of payment verification for exchanges and
merchants without compromising privacy.
**Key Features:**
- Generate PayRefs using `PayRef = Blake2b_256(block_hash ||
output_hash)` for merkle proof compatibility
- Transaction-based PayRef calculation ensuring sender and receiver
generate identical references
- Support for multiple PayRefs per transaction (multi-output payments)
- Confirmation-based stability with reorg safety (default: 5
confirmations)
- Privacy-preserving payment verification
- Full FFI support for external integrations
- Exchange documentation and integration examples
## Motivation and Context
---
The primary use case is when users send payments to exchanges but the
exchange claims they haven't received the payment. Currently, there's no
reliable way to prove payments in Mimblewimble due to:
- **Kernel obfuscation**: No direct link between kernels and specific
outputs
- **Receiver limitations**: Receivers never see kernels in one-sided
payments
- **Privacy by design**: Transaction relationships are intentionally
hidden
This creates significant business friction:
- High customer support burden for exchanges
- Users cannot prove payments were sent
- Difficulty maintaining audit trails
- Adoption friction due to payment verification problems
PayRefs provide a practical solution that ensures both sender and
receiver can generate the same payment reference for verification, while
maintaining privacy and enabling future merkle proof verification
against block headers.
## How Has This Been Tested?
---
- **Unit tests**: PayRef generation with new formula, multiple output
scenarios, change output identification
- **Integration tests**: End-to-end payment flows ensuring
sender-receiver PayRef matching
- **Reorg tests**: Verification of PayRef cleanup during blockchain
reorganizations
- **Manual testing**: Console wallet transaction history display with
multiple PayRefs support
- **API testing**: gRPC endpoints for PayRef retrieval supporting
multiple references per transaction
- **Edge case validation**: Handling of spent outputs, burned outputs,
and same-block spends
## What process can a PR reviewer use to test or verify this change?
---
**Basic PayRef Generation:**
1. Send a transaction with multiple outputs using the console wallet
2. Wait for 5+ confirmations
3. Check transaction history - PayRefs should appear as "Available"
4. Verify each PayRef is a 64-character hex string
5. Confirm receiver generates identical PayRefs for the same outputs
**Multi-Output Transactions:**
1. Create a transaction with multiple recipients
2. Verify multiple PayRefs are displayed (one per non-change output)
3. Confirm each recipient can verify their specific PayRef
**PayRef Search:**
1. In console wallet, press `t` for transactions, then `s` to search
2. Enter a known PayRef (full or partial)
3. Verify it finds the matching transaction
**Reorg Safety Testing:**
1. Force a reorg on a test network
2. Verify PayRefs are properly cleaned up for reorged transactions
3. Confirm no orphaned PayRef entries remain
**FFI Interface:**
1. Build with `cargo build`
2. Check that new FFI functions compile without errors
3. Verify header file `wallet.h` includes new PayRef structures with
array support
**Documentation:**
1. Review exchange integration guide in
`docs/src/09_adding_tari_to_your_exchange.md`
2. Check user guide in `docs/src/payref_userguide.md`
3. Verify code examples reflect the new multi-PayRef support
**API Testing:**
```bash
# Test PayRef retrieval for specific transaction
grpcurl -plaintext -d '{"tx_id": "YOUR_TX_ID"}' \
localhost:18143 tari.rpc.Wallet/GetTransactionPayRefs
# Test payment lookup by PayRef
grpcurl -plaintext -d '{"payment_reference_hex": "YOUR_PAYREF_HERE"}' \
localhost:18143 tari.rpc.Wallet/GetPaymentByReference
# Verify multiple PayRefs for multi-output transactions
grpcurl -plaintext localhost:18143 tari.rpc.Wallet/GetCompletedTransactions
```
## Breaking Changes
---
- [x] None
- [ ] Requires data directory on base node to be deleted
- [ ] Requires hard fork
- [ ] Other - Please specify
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- **New Features**
- Introduced Payment Reference (PayRef) support across Tari blockchain
outputs, enabling unique, privacy-preserving identifiers.
- Added CLI commands and UI enhancements in the console wallet for
displaying, searching, and verifying PayRefs.
- Enabled gRPC and FFI APIs for retrieving and verifying transactions by
PayRef, facilitating integration with external services.
- Implemented database schema migrations, indexing, and backend support
for efficient PayRef lookups.
- Added a BaseNode gRPC streaming method to search blockchain outputs by
payment references.
- Extended wallet and transaction services with PayRef generation,
storage, and querying capabilities.
- Added PayRef verification and display configuration options in the
wallet UI.
- **Documentation**
- Added comprehensive user guides and integration documentation for
PayRef usage and best practices.
- Updated application and API overviews to include PayRef features.
- Added detailed gRPC and FFI overviews covering PayRef functionality.
- **Bug Fixes / Refactor**
- Improved error handling and code clarity across multiple modules.
- Streamlined output hash tracking and transaction model updates to
support PayRef features.
- Simplified error constructions and iterator usage in core and
communication modules for cleaner code.
- **Chores**
- Upgraded Diesel dependency in multiple crates for improved
compatibility and security.
- Added new hash domain for Payment Reference generation.
- Minor code cleanups and simplifications across core and comms crates.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: stringhandler <stringhandler@protonmail.com>
Co-authored-by: SW van Heerden <swvheerden@gmail.com>
Co-authored-by: Hansie Odendaal <pluto@tari.com>1 parent cf4254c commit ea038a4
File tree
85 files changed
+6820
-352
lines changed- applications
- minotari_app_grpc
- proto
- src/conversions
- minotari_console_wallet/src
- automation
- grpc
- init
- ui
- components
- state
- minotari_node/src
- grpc
- base_layer
- common_types
- src
- contacts
- core
- src
- base_node/comms_interface
- chain_storage
- lmdb_db
- consensus
- proof_of_work/monero_rx
- test_helpers
- transactions
- transaction_protocol
- tests/tests
- key_manager
- wallet_ffi
- src
- wallet
- migrations
- 2025-01-06-120000_payref_support
- 2025-06-06-160000_payref_table
- src
- output_manager_service
- storage
- sqlite_db
- storage
- transaction_service
- protocols
- storage
- tasks
- tests/transaction_service_tests
- common_sqlite
- comms
- core
- src
- memsocket
- multiplexing
- noise
- protocol
- rpc/test
- transports
- tests/tests
- dht
- src
- tests
- docs
- guide
- src
- hashing/src
- infrastructure/tari_script/src
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
85 files changed
+6820
-352
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| 103 | + | |
| 104 | + | |
103 | 105 | | |
104 | 106 | | |
105 | 107 | | |
| |||
559 | 561 | | |
560 | 562 | | |
561 | 563 | | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
118 | 122 | | |
119 | 123 | | |
120 | 124 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
434 | 434 | | |
435 | 435 | | |
436 | 436 | | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
437 | 475 | | |
438 | 476 | | |
439 | 477 | | |
| |||
1050 | 1088 | | |
1051 | 1089 | | |
1052 | 1090 | | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
1053 | 1137 | | |
1054 | 1138 | | |
1055 | 1139 | | |
| |||
1197 | 1281 | | |
1198 | 1282 | | |
1199 | 1283 | | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
1200 | 1287 | | |
1201 | 1288 | | |
1202 | 1289 | | |
| |||
1252 | 1339 | | |
1253 | 1340 | | |
1254 | 1341 | | |
| 1342 | + | |
1255 | 1343 | | |
1256 | 1344 | | |
1257 | 1345 | | |
| |||
1443 | 1531 | | |
1444 | 1532 | | |
1445 | 1533 | | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
| 1554 | + | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
| 1559 | + | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
| 1574 | + | |
| 1575 | + | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
114 | 117 | | |
115 | 118 | | |
116 | 119 | | |
| |||
Lines changed: 126 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2711 | 2711 | | |
2712 | 2712 | | |
2713 | 2713 | | |
| 2714 | + | |
| 2715 | + | |
| 2716 | + | |
| 2717 | + | |
| 2718 | + | |
| 2719 | + | |
| 2720 | + | |
| 2721 | + | |
| 2722 | + | |
| 2723 | + | |
| 2724 | + | |
| 2725 | + | |
| 2726 | + | |
| 2727 | + | |
| 2728 | + | |
| 2729 | + | |
| 2730 | + | |
| 2731 | + | |
| 2732 | + | |
| 2733 | + | |
| 2734 | + | |
| 2735 | + | |
| 2736 | + | |
| 2737 | + | |
| 2738 | + | |
| 2739 | + | |
| 2740 | + | |
| 2741 | + | |
| 2742 | + | |
| 2743 | + | |
| 2744 | + | |
| 2745 | + | |
| 2746 | + | |
| 2747 | + | |
| 2748 | + | |
| 2749 | + | |
| 2750 | + | |
| 2751 | + | |
| 2752 | + | |
| 2753 | + | |
| 2754 | + | |
| 2755 | + | |
| 2756 | + | |
| 2757 | + | |
| 2758 | + | |
| 2759 | + | |
| 2760 | + | |
| 2761 | + | |
| 2762 | + | |
| 2763 | + | |
| 2764 | + | |
| 2765 | + | |
| 2766 | + | |
| 2767 | + | |
| 2768 | + | |
| 2769 | + | |
| 2770 | + | |
| 2771 | + | |
| 2772 | + | |
| 2773 | + | |
| 2774 | + | |
| 2775 | + | |
| 2776 | + | |
| 2777 | + | |
| 2778 | + | |
| 2779 | + | |
| 2780 | + | |
| 2781 | + | |
| 2782 | + | |
| 2783 | + | |
| 2784 | + | |
| 2785 | + | |
| 2786 | + | |
| 2787 | + | |
| 2788 | + | |
| 2789 | + | |
| 2790 | + | |
| 2791 | + | |
| 2792 | + | |
| 2793 | + | |
| 2794 | + | |
| 2795 | + | |
| 2796 | + | |
| 2797 | + | |
| 2798 | + | |
| 2799 | + | |
| 2800 | + | |
| 2801 | + | |
| 2802 | + | |
| 2803 | + | |
| 2804 | + | |
| 2805 | + | |
| 2806 | + | |
| 2807 | + | |
| 2808 | + | |
| 2809 | + | |
| 2810 | + | |
| 2811 | + | |
| 2812 | + | |
| 2813 | + | |
| 2814 | + | |
| 2815 | + | |
| 2816 | + | |
| 2817 | + | |
| 2818 | + | |
| 2819 | + | |
| 2820 | + | |
| 2821 | + | |
| 2822 | + | |
| 2823 | + | |
| 2824 | + | |
| 2825 | + | |
| 2826 | + | |
| 2827 | + | |
| 2828 | + | |
| 2829 | + | |
| 2830 | + | |
| 2831 | + | |
| 2832 | + | |
| 2833 | + | |
| 2834 | + | |
| 2835 | + | |
| 2836 | + | |
| 2837 | + | |
| 2838 | + | |
| 2839 | + | |
2714 | 2840 | | |
2715 | 2841 | | |
2716 | 2842 | | |
| |||
0 commit comments