Skip to content

Support payment hub transfer#3836

Merged
jolestar merged 2 commits into
mainfrom
payment_hub_transfer2
Dec 2, 2025
Merged

Support payment hub transfer#3836
jolestar merged 2 commits into
mainfrom
payment_hub_transfer2

Conversation

@jolestar

@jolestar jolestar commented Dec 1, 2025

Copy link
Copy Markdown
Contributor

Summary

Summary about this PR

  • Closes #issue

@vercel

vercel Bot commented Dec 1, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
rooch-portal-v2.1 Ready Ready Preview Comment Dec 1, 2025 2:48am
test-portal Ready Ready Preview Comment Dec 1, 2025 2:48am
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
rooch Ignored Ignored Preview Dec 1, 2025 2:48am

@jolestar jolestar requested a review from Copilot December 1, 2025 00:05
@github-actions

github-actions Bot commented Dec 1, 2025

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds payment hub transfer functionality to enable direct transfers between payment hubs without going through account coin stores. The implementation follows the existing patterns for hub operations (deposit/withdraw) and includes both typed and generic coin transfer functions.

Key Changes

  • Adds PaymentHubTransferEvent struct to track transfer operations between payment hubs
  • Implements transfer_to_hub, transfer_to_hub_entry, and transfer_to_hub_generic functions to enable hub-to-hub transfers
  • Adds test coverage for basic success and insufficient balance scenarios

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
frameworks/rooch-framework/sources/payment_channel.move Implements payment hub transfer functionality with event emission and balance validation
frameworks/rooch-framework/sources/tests/payment_channel_test.move Adds Test Group 8 with tests for successful transfer and insufficient balance error
frameworks/rooch-framework/doc/payment_channel.md Updates documentation to reflect new transfer functions and events

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

Comment thread frameworks/rooch-framework/sources/payment_channel.move
Comment on lines +452 to +486
public fun transfer_to_hub_generic(
sender: &signer,
receiver: address,
amount: u256,
coin_type: String,
) {
let sender_addr = signer::address_of(sender);

// Check unlocked balance
let unlocked = get_unlocked_balance_in_hub_with_name_internal(sender_addr, coin_type);
assert!(amount <= unlocked, ErrorInsufficientUnlockedBalance);

// Withdraw from sender's hub
let sender_hub_obj = borrow_or_create_payment_hub(sender_addr);
let sender_hub = object::borrow_mut(sender_hub_obj);
let coin = multi_coin_store::withdraw(&mut sender_hub.multi_coin_store, coin_type, amount);
let sender_hub_id = object::id(sender_hub_obj);

// Deposit to receiver's hub
let receiver_hub_obj = borrow_or_create_payment_hub(receiver);
let receiver_hub = object::borrow_mut(receiver_hub_obj);
multi_coin_store::deposit(&mut receiver_hub.multi_coin_store, coin);
let receiver_hub_id = object::id(receiver_hub_obj);

// Emit transfer event
let event_handle_id = hub_event_handle_id<PaymentHubTransferEvent>(sender_hub_id);
event::emit_with_handle(event_handle_id, PaymentHubTransferEvent {
sender_hub_id,
sender: sender_addr,
receiver_hub_id,
receiver,
coin_type,
amount,
});
}

Copilot AI Dec 1, 2025

Copy link

Choose a reason for hiding this comment

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

The transfer_to_hub_generic function lacks the same input validation as transfer_to_hub:

  1. Zero amount validation: Should reject amount == 0 transfers.
  2. Self-transfer validation: Should reject transfers where sender_addr == receiver.

These validations should be consistent across both the generic and typed versions of the function to prevent wasteful operations.

Copilot uses AI. Check for mistakes.
Comment thread frameworks/rooch-framework/sources/tests/payment_channel_test.move
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.

PaymentHub: Allow withdrawals/transfers with active channels via global per-coin locked_unit × active channel count

2 participants