Skip to content

Implement Anti-Spam Deposits, Batch Refunds, Payment Thresholds, and Platform Fee Accounting#247

Merged
Kingsman-99 merged 2 commits into
Stellar-split:mainfrom
johnsmccain:main
Jun 26, 2026
Merged

Implement Anti-Spam Deposits, Batch Refunds, Payment Thresholds, and Platform Fee Accounting#247
Kingsman-99 merged 2 commits into
Stellar-split:mainfrom
johnsmccain:main

Conversation

@johnsmccain

Copy link
Copy Markdown
Contributor

Summary

This PR enhances invoice management by introducing anti-spam deposits, batch refund processing, configurable minimum payment increments, and platform fee accounting.

Closes

Changes

#196 Anti-Spam Deposit

  • Added configurable refundable spam deposit
  • Deposit held in contract custody alongside creation fee
  • Early cancellation slashes deposit to treasury
  • Late cancellation refunds deposit to creator
  • Deposit disabled when configured as 0

#197 Batch Refunds

  • Added refund_batch() for processing multiple expired invoices
  • Supports up to 20 invoice IDs per transaction
  • Skips ineligible invoices without aborting the batch
  • Returns refunded invoice IDs while preserving refund events

#201 Minimum Payment Increment

  • Added optional min_payment_increment to invoice options
  • Rejects payments below the configured threshold
  • Remains compatible with existing micro-payment accumulation logic
  • Backward compatible when unset or zero

#202 Platform Fee Ledger

  • Added cumulative platform fee accounting
  • Tracks fees collected during invoice releases
  • Added get_total_platform_fees() view function
  • Zero-fee releases leave the counter unchanged

Validation

  • Added unit tests for all new functionality
  • Existing test suite passes
  • cargo clippy passes with zero warnings
  • Backward compatibility preserved

johnsmccain and others added 2 commits June 26, 2026 03:38
…split#201, Stellar-split#202 with tests

Stellar-split#196 - Add spam deposit slashing for invoice creation
- set_spam_deposit(admin, amount, min_age_secs) stores deposit config
- create_invoice charges deposit to contract custody
- cancel_invoice slashes to treasury if age < min_age_secs, else refunds creator
- Deposit of 0 disables the feature
- Tests: early cancel slashes, late cancel refunds, zero disables, get returns values

Stellar-split#197 - Batch refund for multiple expired invoices
- refund_batch(invoice_ids) accepts up to 20 IDs, panics above that
- Skips ineligible invoices (not Pending, deadline not passed, auction active)
- Returns Vec of IDs actually refunded
- Each refund emits individual invoice_refunded/payer_refunded events
- Tests: mixed batch processes correct subset, panics at >20, empty returns empty

Stellar-split#201 - Creator-set minimum payment increment
- min_payment_increment field on InvoiceOptions/InvoiceExt2
- _pay() rejects amounts below threshold with 'payment below minimum increment'
- Independent of existing min_payment micro-payment accumulator
- Tests: below threshold panics, at/above threshold succeeds, zero disables

Stellar-split#202 - Total platform fee accounting ledger
- total_platform_fees_key() counter incremented on every release path
- get_total_platform_fees() pure view function
- Zero platform_fee_bps releases do not increment counter
- Tests: starts at zero, accumulates across invoices, zero bps unchanged, exact amounts

fix: add missing ToXdr trait import for ScVal::to_xdr in compute_shard_id
@drips-wave

drips-wave Bot commented Jun 26, 2026

Copy link
Copy Markdown

@johnsmccain Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Kingsman-99 Kingsman-99 merged commit f1173ad into Stellar-split:main Jun 26, 2026
1 of 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

2 participants