This repository was archived by the owner on Mar 11, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -782,16 +782,23 @@ async fn command_transfer(
782
782
let token = token_client_from_config ( config, & token_pubkey) ;
783
783
let mint_info = config. get_mint_info ( & token_pubkey, mint_decimals) . await ?;
784
784
785
- // decimals arg, which determines whether transfer or transfer_checked instruction is used
786
- // the logic here is tricky because "do what we are told" and "do the right thing" are at odds
785
+ // if the user got the decimals wrong, they may well have calculated the transfer amount wrong
786
+ if !config. sign_only && mint_decimals. is_some ( ) && mint_decimals != Some ( mint_info. decimals ) {
787
+ return Err ( format ! (
788
+ "Decimals {} was provided, but actual value is {}" ,
789
+ mint_decimals. unwrap( ) ,
790
+ mint_info. decimals
791
+ )
792
+ . into ( ) ) ;
793
+ }
794
+
795
+ // decimals determines whether transfer_checked is used or not
787
796
let decimals = if use_unchecked_instruction {
788
797
None
789
- } else if !config. sign_only {
790
- Some ( mint_info. decimals )
791
798
} else if mint_decimals. is_some ( ) {
792
799
mint_decimals
793
800
} else {
794
- return Err ( "Decimals must be specified with --mint-decimals in offline mode" . into ( ) ) ;
801
+ Some ( mint_info . decimals )
795
802
} ;
796
803
797
804
// pubkey of the actual account we are sending from
You can’t perform that action at this time.
0 commit comments