-
Notifications
You must be signed in to change notification settings - Fork 2.2k
added a flag to check if the recipient address is correct #3085
added a flag to check if the recipient address is correct #3085
Conversation
@joncinque can you check this out ! |
token/cli/src/main.rs
Outdated
let recipient_account = config.rpc_client.get_account(&recipient).unwrap(); | ||
if recipient_account.owner != system_program::id() && !yolo { | ||
return Err( | ||
("Recipient is not a Account owned by System Program. Use --yolo if you know what you doing").to_string() | ||
.into(), | ||
); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs to be moved into the block at ln705 where recipient_is_token_account
is resolved taking into account:
- No RPC calls are allowed in sign-only mode. Probably fine because the account is already queried in that block, so you can just reuse it.
- The recipient may have been specified as a token account directly. In which case, it is owned by the SPL Token program and this check should not be performed at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got the changes done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking really close! Since the testing framework landed in #3070, how about a test to make sure this works as intended?
What if we just always denied the transfer if the account owner is the token program. No need for a user flag to override at all, this is always wrong. |
@mvines the current behavior is to allow people to specify the token account address as well, e.g. if your wallet is |
I think I'm being dense, what's an example of a |
It's possible for someone to do |
ah, k. if the account owner is a token account, require that the account not be a mint? |
I was thinking we could cover a larger surface area by checking the program owner is the system account, and that way we also protect against things like:
or
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks for the contribution!
Fix for #3078 .
--yolo