Skip to content

Add migrate sol command - #87

Merged
mcintyre94 merged 1 commit into
mainfrom
migrate-sol
Oct 22, 2026
Merged

mcintyre94 merged 1 commit into
mainfrom
migrate-sol

Conversation

@mcintyre94

@mcintyre94 mcintyre94 commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

This command is for sending SOL to a programmatic signer

This is similar to migrate token, bt for native SOL. By default this will create an execution message that sends the full current balance, closing the account. An optional --amount will customise this. We check that both the source and destination accounts are rent-exempt (if the source is not closed).

This requires a bit of caution because if the account pays fees for another transaction then these balances can become invalid. We also assume that if transferring an amount at/near the full balance, the relay fee payer will be another account, as we don't account for that.

Again the recipient is not required as a signer on the transfer instruction, so we add a memo instruction to enforce it.

@mcintyre94
mcintyre94 added this pull request to stack #72 October 15, 2026 16:49
@mcintyre94
mcintyre94 removed this pull request from stack #72 October 16, 2026 11:22
@mcintyre94
mcintyre94 marked this pull request as ready for review October 16, 2026 11:40
@mcintyre94
mcintyre94 added this pull request to stack #88 October 16, 2026 11:40
@mcintyre94
mcintyre94 force-pushed the migrate-sol branch 3 times, most recently from cd584fe to c73ac04 Compare October 20, 2026 17:15
@mcintyre94
mcintyre94 force-pushed the migrate-sol branch 2 times, most recently from 9f05bf4 to acfad14 Compare October 21, 2026 18:05

@joncinque joncinque 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.

Just some terminology bits to say "wallet" instead of "owner" in most places, but that can be done in a follow-up -- looks great!

Comment on lines +20 to +21
/// If transferring the full balance, it must not also pay the
/// relay transaction's fee, since that comes out of the same balance.

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.

We have some (overly complicated) logic in the CLI to estimate fees so that transferring everything out of a system account is actually possible, which could be a useful feature. We can add that in a follow-up though

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thinking about it, this should actually be straightforward if we keep priority fees at 0 here (which I think in practice is what happens with durable nonces?). We'd know the fee that will eventually be paid. Only tricky thing is we don't know who the relay fee payer will be because that's a separate later CLI command. So I'm not sure if we should try to be clever here, or leave it to them to adjust by 5000 lamports if they plan to use the sender as the fee payer.

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.

Ah right, that's a good point. Let's just leave it to them then. Maybe we can put a comment saying to reduce the amount by 5000 lamports if the migrated account is also the fee payer

Comment thread clients/cli/src/commands/migrate/sol.rs Outdated
Comment thread clients/cli/src/commands/migrate/sol.rs Outdated
Comment thread clients/cli/src/commands/migrate/sol.rs Outdated
@mcintyre94
mcintyre94 force-pushed the migrate-sol branch 2 times, most recently from 2ef4670 to f8ea080 Compare October 22, 2026 09:17
Base automatically changed from migrate-token to main October 22, 2026 09:18
This command is for sending SOL to a programmatic signer. The new
authority signing pubkey defaults to the current owner.

This is similar to `migrate token`, bt for native SOL. By default this
will create an execution message that sends the full current balance,
closing the account. An optional `--amount` will customise this. We
check that both the source and destination accounts are rent-exempt (if
the source is not closed).

This requires a bit of caution because if the account pays fees for
another transaction then these balances can become invalid. We also
assume that if transferring an amount at/near the full balance, the
relay fee payer will be another account, as we don't account for that.

Again the recipient is not required as a signer on the transfer
instruction, so we add a memo instruction to enforce it.
@mcintyre94
mcintyre94 merged commit adc529b into main Oct 22, 2026
45 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

Development

Successfully merging this pull request may close these issues.

2 participants