Skip to content

Conversation

@febo
Copy link
Contributor

@febo febo commented Jan 18, 2026

Problem

Currently it is not possible to use a delegate to unwrap_lamports.

Solution

Add delegate support to unwrap_lamports. The delegate implementation works similarly to how it works on transfer:

  • delegates can only unwrap up to the amount delegated
  • when the delegated amount reaches 0, the delegate is cleared

@febo febo requested a review from joncinque January 20, 2026 10:59
Copy link
Contributor

@joncinque joncinque left a comment

Choose a reason for hiding this comment

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

Looks great to me! Just a tiny nit, which you can take or leave

Comment on lines +824 to +826
// When we try to unwrap 2_000_000_000 lamports, we expect a
// `TokenError::InsufficientFunds` error since only 1_000_000_000
// lamports are delegated.
Copy link
Contributor

Choose a reason for hiding this comment

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

This behavior makes sense to me -- there's an argument that using an amount of None with a delegate should unwrap the rest of the delegated amount, but that seems like more of a footgun than anything else

}

#[test]
fn unwrap_lamports_from_multisig() {
Copy link
Contributor

Choose a reason for hiding this comment

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

micro-nit: This isn't unwrapping the lamports from the multisig, but rather from a multisig-owned account. I got a bit confused, so maybe just update the naming?

Suggested change
fn unwrap_lamports_from_multisig() {
fn unwrap_lamports_with_multisig_owner() {

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.

3 participants