fix: reject transfer when --from and --to are the same account

Previously, wallet submitted the transaction to the sequencer which
rejected it with 'Duplicate account_ids found in message'. The user
only saw 'Transaction not found in preconfigured amount of blocks'
with no actionable feedback.

Now wallet validates upfront and returns a clear error:
  'Invalid transfer: --from and --to cannot be the same account'

Fixes #264
This commit is contained in:
ygd58 2026-03-26 11:20:31 +01:00
parent fb083ce91e
commit 9b76da88ab
No known key found for this signature in database
GPG Key ID: 82B49AE8D5B28600

View File

@ -121,6 +121,13 @@ impl WalletSubcommand for AuthTransferSubcommand {
let (from, from_privacy) = parse_addr_with_privacy_prefix(&from)?;
let (to, to_privacy) = parse_addr_with_privacy_prefix(&to)?;
if from == to {
anyhow::bail!(
"Invalid transfer: --from and --to cannot be the same account ({})",
from
);
}
match (from_privacy, to_privacy) {
(AccountPrivacyKind::Public, AccountPrivacyKind::Public) => {
NativeTokenTransferProgramSubcommand::Public { from, to, amount }