-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
token-cli: withdraw-withheld-tokens silently fails #7042
Comments
@joncinque I understand that to check if the operation has gone well, you only have to check the amount of the destination is equal before and after the operation and launch an error message with |
This issue is a bit of a misunderstanding of how In this case, neither a list of pubkeys nor the
It might be easiest to put solana-program-library/token/cli/src/clap_app.rs Lines 2244 to 2258 in 209362f
multiple(true) https://docs.rs/clap/2.34.0/clap/struct.ArgGroup.html, and then we don't need to worry about a custom error message.
And I don't assign issues to outside contributors, but if you put in a PR, I will happily review it! |
Return a error when the arguments source is empty and include-mint flag is not present
Would just like to add that "mint" is an ambiguous term, as in HarvestWithheldTokensToMint. It's not immediately clear whether it refers to the mint address or the mint authority or "the account provided". Might want to make that explicit in the help text. Test case: what happens if this "mint" has its own Withheld Amount (if that's even possible) and you HarvestWithheldTokensToMint? (Only applies if "mint" can mean mint address or mint authority.) There are use cases where one would want to withdraw Withheld Amount back to the mint authority (as taxes) and other use cases where one would simply want to free some percentage of them within the same token account. And just so no readers make the mistake: mint authority and mint address must be separate in the "tax" case because mint addresses cannot spend or move SOL. |
Maybe I'm misunderstanding, but where do you suggest making it clearer that "mint" does not refer to the mint authority? I'd probably find that more confusing, to be honest.
The mint does have its own withheld amount, but since it's not a token account, you can't harvest from it. We could rename the instruction to Either way, token accounts can actually be owned by mint accounts -- if you keep the keypair for the mint account, then you can still sign for it, same as any token account owner. Fun fact: check out all of the token accounts owned by the USDC mint account,
That's $100k, completely bricked 😅 |
@joncinque Well "HarvestWithheldTokensToMint" could (naively) mean:
"RevertWithheldToMintAuthority" is almost impossible to misinterpret. Ah semantics! LOL $104K! |
@tapirtoken it's actually none of those! |
Copied from anza-xyz/agave#2224 cc @tapirtoken
Problem
If you look at this transaction:
4N1GvNc27DFhKK7Y8dcjMhrDuze4LMfM1qhoG6nkFG2EWTMPEcuevXVGEXmwt6gR55VEskQ9X37Z8RKkP1HhgL8i
You'll notice that instruction 5 (on Solscan) is HarvestWithheldTokensToMint. However, the Withdraw Authority is Null so this operation should normally fail. But this is an exceptional case in which the tokens are being immediately burned (by instruction 6) in the same atomic transaction, so the harvest is allowed in order to permit the wallet owner to recover the rent.
Nevertheless we wanted to make absolutely sure that there was no way to withdraw withheld tokens, so we tried to withdraw our own:
spl-token withdraw-withheld-tokens 8QhMP4HVfUd78hSjwzRXmifYCWAYB2nYiM6Emd7fTstd --fee-payer AirDpo61FVsNDoWSBoBX3K4gcBiTVnkfZRAZk7bKfRtX.json --url mainnet-beta --output json --program-id TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb --withdraw-withheld-authority AirDpo61FVsNDoWSBoBX3K4gcBiTVnkfZRAZk7bKfRtX.json
This command just terminates as though it succeeded. It definitely didn't succeed because our Withheld Amount on explorer.solana.com is unchanged:
8QhMP4HVfUd78hSjwzRXmifYCWAYB2nYiM6Emd7fTstd
This is correct behavior but withdraw-withheld-tokens should have returned an error message.
Proposed Solution
Just check if the operation succeeded and report to the user.
The text was updated successfully, but these errors were encountered: