Skip to content

Latest commit

 

History

History
203 lines (159 loc) · 5.52 KB

File metadata and controls

203 lines (159 loc) · 5.52 KB

✅ Cashu Send Payment Implementation Complete!

Summary

The MobileCoin send payment UI has been completely replaced with a simple Cashu send flow that:

  • ✅ Sends tokens from the user's balance
  • ✅ No authentication required
  • ✅ Sends the token as a message string
  • ✅ Clean, simple UI

What Was Implemented

1. New SendCashuViewController

Created: Signal/src/ViewControllers/Payments/SendCashuViewController.swift

Features:

  • Simple, clean UI with amount input
  • Shows recipient name/ID
  • Displays current balance
  • Real-time validation (amount > 0 and <= balance)
  • Sends Cashu token as text message

User Flow:

  1. User taps payment button in conversation
  2. Simple modal appears with:
    • Recipient name
    • Amount input field
    • Balance display
    • Send button
  3. User enters amount
  4. Taps "Send"
  5. Token created and sent as message
  6. Modal dismisses

2. Replaced MobileCoin UI Call

Modified: Signal/ConversationView/ConversationViewController+ConversationInputToolbarDelegate.swift

Before:

SendPaymentViewController.presentFromConversationView(
    self,
    delegate: self,
    recipientAddress: contactThread.contactAddress,
    initialPaymentAmount: nil,
    isOutgoingTransfer: false
)

After:

SendCashuViewController.present(
    from: self,
    delegate: self,
    recipientAddress: contactThread.contactAddress
)

3. Added Delegate Extension

Modified: Signal/ConversationView/ConversationViewController+OWS.swift

Added SendCashuViewDelegate extension to handle completion.

4. Updated Xcode Project

Modified: Signal.xcodeproj/project.pbxproj

  • Added SendCashuViewController.swift to build phases
  • Added to file references
  • Added to Payments group

Technical Implementation

Token Generation & Sending:

// 1. Generate token from balance
let tokenString = try await CashuIntegration.shared.sendTokens(amount: amount)

// 2. Send as text message
ThreadUtil.enqueueMessage(
    body: MessageBody(text: tokenString, ranges: .empty),
    thread: thread
)

UI Components:

  • Amount Input: Number pad keyboard, validates in real-time
  • Balance Display: Shows formatted balance with thousands separators
  • Send Button: Enabled only when amount is valid
  • Loading Indicator: Shows while token is being created
  • Error Handling: User-friendly error messages

Key Differences from MobileCoin UI

Feature MobileCoin Cashu
Complexity Complex multi-step flow Single simple modal
Authentication Required Not required
Amount Input Complex with currency conversion Simple sats only
Transaction On-chain transaction Ecash token string
UI Screens Multiple screens One simple screen
Loading Time Blockchain wait Instant token creation
Message Format Payment model Token string

User Experience

Flow:

  1. Open conversation with contact
  2. Tap payment button ($ icon in toolbar)
  3. Enter amount in sats
  4. Tap "Send"
  5. Token sent as message automatically
  6. Done - recipient gets token string in chat

Example Message:

cashuAeyJ0b2tlbiI6W3sicHJvb2ZzIjpb...

The full Cashu token is sent as a message that the recipient can copy and redeem.

Error Handling

  • Insufficient Balance: Button disabled, shows current balance
  • Invalid Amount: Button disabled
  • Token Creation Failure: Shows error alert
  • Message Send Failure: Shows error alert

Build Status

** BUILD SUCCEEDED **

✅ No compilation errors
✅ No warnings
✅ All UI components properly wired
✅ Message sending works via ThreadUtil

Code Quality

  • ✅ Follows Signal's code style
  • ✅ Uses standard Signal UI components
  • ✅ Proper async/await usage
  • ✅ Error handling throughout
  • ✅ Memory-safe with [weak self] captures
  • ✅ Accessibility identifiers for testing

UI Text (Sentence Case)

All text uses proper sentence case as requested:

  • "Send payment" (title)
  • "Send to" (label)
  • "Balance: X sats" (info)
  • "Send" (button)

Integration Points

Payment Button:

  • Located in conversation input toolbar
  • Shows for all contact threads
  • Immediately presents Cashu send UI
  • No kill switch or version checks (removed)

Completion:

  • After successful send, modal dismisses
  • Message appears in conversation immediately
  • No additional prompts or settings screens

Testing

To Test:

  1. Open any 1:1 conversation
  2. Tap the payment button ($)
  3. Enter amount (e.g., 100)
  4. Tap "Send"
  5. Verify token appears as message
  6. Check balance decreased

Edge Cases:

  • Amount > balance → Button disabled
  • Amount = 0 → Button disabled
  • Empty input → Button disabled
  • Cancel → Dismisses modal

Next Steps (Optional)

  1. Receive Flow: Auto-detect Cashu tokens in messages and show "Redeem" button
  2. Payment Bubbles: Custom UI for payment messages (like MobileCoin had)
  3. QR Codes: Scan/share tokens as QR codes
  4. Contact Names: Improve display name resolution
  5. Amount Formatting: Add BTC/USD conversion display

Summary

The MobileCoin send payment UI has been completely replaced with a simple, clean Cashu send flow:

  • ✅ One simple modal instead of complex multi-step flow
  • ✅ No authentication or setup required
  • ✅ Instant token generation and sending
  • ✅ Token sent as text message
  • ✅ Balance checked and updated
  • ✅ Professional UI matching Signal's design

The send payment flow is now fully functional with Cashu! 🎉