@@ -803,47 +803,60 @@ func (s *transactionServer) CanWithdrawToAccount(ctx context.Context, req *trans
803
803
}
804
804
log = log .WithField ("account" , accountToCheck .PublicKey ().ToBase58 ())
805
805
806
+ isOnCurve := accountToCheck .IsOnCurve ()
807
+
806
808
//
807
- // Part 1: Is this a timelock vault? If so, only allow primary accounts.
809
+ // Part 1: Is this a Timelock vault? If so, only allow primary accounts.
808
810
//
809
811
810
- accountInfoRecord , err := s .data .GetAccountInfoByTokenAddress (ctx , accountToCheck .PublicKey ().ToBase58 ())
811
- switch err {
812
- case nil :
813
- return & transactionpb.CanWithdrawToAccountResponse {
814
- IsValidPaymentDestination : accountInfoRecord .AccountType == commonpb .AccountType_PRIMARY ,
815
- AccountType : transactionpb .CanWithdrawToAccountResponse_TokenAccount ,
816
- }, nil
817
- case account .ErrAccountInfoNotFound :
818
- // Nothing to do
819
- default :
820
- log .WithError (err ).Warn ("failure checking account info db" )
821
- return nil , status .Error (codes .Internal , "" )
812
+ if ! isOnCurve {
813
+ accountInfoRecord , err := s .data .GetAccountInfoByTokenAddress (ctx , accountToCheck .PublicKey ().ToBase58 ())
814
+ switch err {
815
+ case nil :
816
+ return & transactionpb.CanWithdrawToAccountResponse {
817
+ IsValidPaymentDestination : accountInfoRecord .AccountType == commonpb .AccountType_PRIMARY ,
818
+ AccountType : transactionpb .CanWithdrawToAccountResponse_TokenAccount ,
819
+ }, nil
820
+ case account .ErrAccountInfoNotFound :
821
+ // Nothing to do
822
+ default :
823
+ log .WithError (err ).Warn ("failure checking account info db" )
824
+ return nil , status .Error (codes .Internal , "" )
825
+ }
822
826
}
823
827
824
828
//
825
829
// Part 2: Is this an opened core mint token account? If so, allow it.
826
830
//
827
831
828
- _ , err = s .data .GetBlockchainTokenAccountInfo (ctx , accountToCheck .PublicKey ().ToBase58 (), solana .CommitmentFinalized )
829
- switch err {
830
- case nil :
831
- return & transactionpb.CanWithdrawToAccountResponse {
832
- IsValidPaymentDestination : true ,
833
- AccountType : transactionpb .CanWithdrawToAccountResponse_TokenAccount ,
834
- }, nil
835
- case token .ErrAccountNotFound , solana .ErrNoAccountInfo , token .ErrInvalidTokenAccount :
836
- // Nothing to do
837
- default :
838
- log .WithError (err ).Warn ("failure checking against blockchain as a token account" )
839
- return nil , status .Error (codes .Internal , "" )
832
+ if ! isOnCurve {
833
+ _ , err = s .data .GetBlockchainTokenAccountInfo (ctx , accountToCheck .PublicKey ().ToBase58 (), solana .CommitmentFinalized )
834
+ switch err {
835
+ case nil :
836
+ return & transactionpb.CanWithdrawToAccountResponse {
837
+ IsValidPaymentDestination : true ,
838
+ AccountType : transactionpb .CanWithdrawToAccountResponse_TokenAccount ,
839
+ }, nil
840
+ case token .ErrAccountNotFound , solana .ErrNoAccountInfo , token .ErrInvalidTokenAccount :
841
+ // Nothing to do
842
+ default :
843
+ log .WithError (err ).Warn ("failure checking against blockchain as a token account" )
844
+ return nil , status .Error (codes .Internal , "" )
845
+ }
840
846
}
841
847
842
848
//
843
849
// Part 3: Is this an owner account with an opened Core Mint ATA? If so, allow it.
844
850
// If not, indicate to the client to pay a fee for a create-on-send withdrawal.
845
851
//
846
852
853
+ if ! isOnCurve {
854
+ return & transactionpb.CanWithdrawToAccountResponse {
855
+ IsValidPaymentDestination : false ,
856
+ AccountType : transactionpb .CanWithdrawToAccountResponse_Unknown ,
857
+ }, nil
858
+ }
859
+
847
860
ata , err := accountToCheck .ToAssociatedTokenAccount (common .CoreMintAccount )
848
861
if err != nil {
849
862
log .WithError (err ).Warn ("failure getting ata address" )
0 commit comments