Skip to content

Commit 72e2bf0

Browse files
committed
Handle VM deposit PDAs in CanWithdrawToAccount
1 parent 2d0616d commit 72e2bf0

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

pkg/code/server/transaction/intent.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"github.com/code-payments/code-server/pkg/code/data/action"
2626
"github.com/code-payments/code-server/pkg/code/data/fulfillment"
2727
"github.com/code-payments/code-server/pkg/code/data/intent"
28+
"github.com/code-payments/code-server/pkg/code/data/timelock"
2829
"github.com/code-payments/code-server/pkg/code/transaction"
2930
currency_lib "github.com/code-payments/code-server/pkg/currency"
3031
"github.com/code-payments/code-server/pkg/grpc/client"
@@ -850,7 +851,18 @@ func (s *transactionServer) CanWithdrawToAccount(ctx context.Context, req *trans
850851
// If not, indicate to the client to pay a fee for a create-on-send withdrawal.
851852
//
852853

853-
if !isOnCurve {
854+
var isVmDepositPda bool
855+
_, err = s.data.GetTimelockByDepositPda(ctx, accountToCheck.PublicKey().ToBase58())
856+
switch err {
857+
case nil:
858+
isVmDepositPda = true
859+
case timelock.ErrTimelockNotFound:
860+
default:
861+
log.WithError(err).Warn("failure checking timelock db as a deposit pda account")
862+
return nil, status.Error(codes.Internal, "")
863+
}
864+
865+
if !isOnCurve && !isVmDepositPda {
854866
return &transactionpb.CanWithdrawToAccountResponse{
855867
IsValidPaymentDestination: false,
856868
AccountType: transactionpb.CanWithdrawToAccountResponse_Unknown,

0 commit comments

Comments
 (0)