@@ -520,12 +520,11 @@ fn process_transfer(
520
520
return Err ( TokenError :: FeeParametersMismatch . into ( ) ) ;
521
521
}
522
522
523
- // Process source account
524
- let ciphertext_lo_source = EncryptedBalance :: from ( (
523
+ let ciphertext_lo= EncryptedBalance :: from ( (
525
524
proof_data. ciphertext_lo . commitment ,
526
525
proof_data. ciphertext_lo . handle_source ,
527
526
) ) ;
528
- let ciphertext_hi_source = EncryptedBalance :: from ( (
527
+ let ciphertext_hi = EncryptedBalance :: from ( (
529
528
proof_data. ciphertext_hi . commitment ,
530
529
proof_data. ciphertext_hi . handle_source ,
531
530
) ) ;
@@ -537,27 +536,16 @@ fn process_transfer(
537
536
authority_info,
538
537
account_info_iter. as_slice ( ) ,
539
538
& proof_data. transfer_with_fee_pubkeys . pubkey_source ,
540
- ciphertext_lo_source ,
541
- ciphertext_hi_source ,
539
+ & ciphertext_lo ,
540
+ & ciphertext_hi ,
542
541
new_source_decryptable_available_balance,
543
542
) ?;
544
-
545
- // Process destination account (with fee)
546
- let ciphertext_lo_dest = EncryptedBalance :: from ( (
547
- proof_data. ciphertext_lo . commitment ,
548
- proof_data. ciphertext_lo . handle_source ,
549
- ) ) ;
550
- let ciphertext_hi_dest = EncryptedBalance :: from ( (
551
- proof_data. ciphertext_hi . commitment ,
552
- proof_data. ciphertext_hi . handle_source ,
553
- ) ) ;
554
-
555
543
process_dest_for_transfer (
556
544
dest_token_account_info,
557
545
mint_info,
558
546
& proof_data. transfer_with_fee_pubkeys . pubkey_dest ,
559
- ciphertext_lo_dest ,
560
- ciphertext_hi_dest ,
547
+ & ciphertext_lo ,
548
+ & ciphertext_hi ,
561
549
Some ( proof_data. ciphertext_fee ) ,
562
550
) ?;
563
551
} else {
@@ -571,44 +559,32 @@ fn process_transfer(
571
559
return Err ( TokenError :: ConfidentialTransferElGamalPubkeyMismatch . into ( ) ) ;
572
560
}
573
561
574
- // Process source account
575
- let ciphertext_lo_source = EncryptedBalance :: from ( (
562
+ let ciphertext_lo= EncryptedBalance :: from ( (
576
563
proof_data. ciphertext_lo . commitment ,
577
564
proof_data. ciphertext_lo . handle_source ,
578
565
) ) ;
579
- let ciphertext_hi_source = EncryptedBalance :: from ( (
566
+ let ciphertext_hi = EncryptedBalance :: from ( (
580
567
proof_data. ciphertext_hi . commitment ,
581
568
proof_data. ciphertext_hi . handle_source ,
582
569
) ) ;
583
-
584
570
process_source_for_transfer (
585
571
program_id,
586
572
token_account_info,
587
573
mint_info,
588
574
authority_info,
589
575
account_info_iter. as_slice ( ) ,
590
576
& proof_data. transfer_pubkeys . pubkey_source ,
591
- ciphertext_lo_source ,
592
- ciphertext_hi_source ,
577
+ & ciphertext_lo ,
578
+ & ciphertext_hi ,
593
579
new_source_decryptable_available_balance,
594
580
) ?;
595
581
596
- // Process destination account (without fee)
597
- let ciphertext_lo_dest = EncryptedBalance :: from ( (
598
- proof_data. ciphertext_lo . commitment ,
599
- proof_data. ciphertext_lo . handle_source ,
600
- ) ) ;
601
- let ciphertext_hi_dest = EncryptedBalance :: from ( (
602
- proof_data. ciphertext_hi . commitment ,
603
- proof_data. ciphertext_hi . handle_source ,
604
- ) ) ;
605
-
606
582
process_dest_for_transfer (
607
583
dest_token_account_info,
608
584
mint_info,
609
585
& proof_data. transfer_pubkeys . pubkey_dest ,
610
- ciphertext_lo_dest ,
611
- ciphertext_hi_dest ,
586
+ & ciphertext_lo ,
587
+ & ciphertext_hi ,
612
588
None ,
613
589
) ?;
614
590
}
@@ -624,14 +600,14 @@ fn process_source_for_transfer(
624
600
authority_info : & AccountInfo ,
625
601
signers : & [ AccountInfo ] ,
626
602
elgamal_pubkey_source : & EncryptionPubkey ,
627
- ciphertext_lo_source : EncryptedBalance ,
628
- ciphertext_hi_source : EncryptedBalance ,
603
+ ciphertext_lo_source : & EncryptedBalance ,
604
+ ciphertext_hi_source : & EncryptedBalance ,
629
605
new_source_decryptable_available_balance : DecryptableBalance ,
630
606
) -> ProgramResult {
631
607
check_program_account ( token_account_info. owner ) ?;
608
+ let authority_info_data_len = authority_info. data_len ( ) ;
632
609
let token_account_data = & mut token_account_info. data . borrow_mut ( ) ;
633
610
let mut token_account = StateWithExtensionsMut :: < Account > :: unpack ( token_account_data) ?;
634
- let authority_info_data_len = authority_info. data_len ( ) ;
635
611
636
612
Processor :: validate_owner (
637
613
program_id,
@@ -659,8 +635,8 @@ fn process_source_for_transfer(
659
635
let new_source_available_balance = {
660
636
ops:: subtract_with_lo_hi (
661
637
& confidential_transfer_account. available_balance ,
662
- & ciphertext_lo_source,
663
- & ciphertext_hi_source,
638
+ ciphertext_lo_source,
639
+ ciphertext_hi_source,
664
640
)
665
641
. ok_or ( ProgramError :: InvalidInstructionData ) ?
666
642
} ;
@@ -676,8 +652,8 @@ fn process_dest_for_transfer(
676
652
dest_token_account_info : & AccountInfo ,
677
653
mint_info : & AccountInfo ,
678
654
elgamal_pubkey_dest : & EncryptionPubkey ,
679
- ciphertext_lo_dest : EncryptedBalance ,
680
- ciphertext_hi_dest : EncryptedBalance ,
655
+ ciphertext_lo_dest : & EncryptedBalance ,
656
+ ciphertext_hi_dest : & EncryptedBalance ,
681
657
encrypted_fee : Option < EncryptedFee > ,
682
658
) -> ProgramResult {
683
659
check_program_account ( dest_token_account_info. owner ) ?;
@@ -705,10 +681,10 @@ fn process_dest_for_transfer(
705
681
return Err ( TokenError :: ConfidentialTransferElGamalPubkeyMismatch . into ( ) ) ;
706
682
}
707
683
708
- let new_dest_pending_balance = ops:: subtract_with_lo_hi (
684
+ let new_dest_pending_balance = ops:: add_with_lo_hi (
709
685
& dest_confidential_transfer_account. pending_balance ,
710
- & ciphertext_lo_dest,
711
- & ciphertext_hi_dest,
686
+ ciphertext_lo_dest,
687
+ ciphertext_hi_dest,
712
688
)
713
689
. ok_or ( ProgramError :: InvalidInstructionData ) ?;
714
690
0 commit comments