Browse Source

PIP-0032: atomic swap fixes

Herman Schoenfeld 6 years ago
parent
commit
e8b7f666af
1 changed files with 8 additions and 4 deletions
  1. 8 4
      src/core/UOpTransaction.pas

+ 8 - 4
src/core/UOpTransaction.pas

@@ -901,7 +901,13 @@ begin
     if (TAccountComp.IsAccountForSwap( LTarget.accountInfo ) AND (ASafeBoxTransaction.FreezedSafeBox.CurrentProtocol<CT_PROTOCOL_5)) then begin
     if (TAccountComp.IsAccountForSwap( LTarget.accountInfo ) AND (ASafeBoxTransaction.FreezedSafeBox.CurrentProtocol<CT_PROTOCOL_5)) then begin
       AErrors := 'Tx-Buy atomic swaps are not allowed until Protocol 5';
       AErrors := 'Tx-Buy atomic swaps are not allowed until Protocol 5';
       exit;
       exit;
-    end else If Not (TAccountComp.IsValidAccountKey(FData.new_accountkey,AErrors)) then exit; // BUG 20171511
+    end else If (ASafeBoxTransaction.FreezedSafeBox.CurrentProtocol<CT_PROTOCOL_5) then begin
+      // the below line was a bug fix that introduced a new bug, and is retained here for
+      // V2-V4 consistency
+      //------
+      if Not (TAccountComp.IsValidAccountKey(FData.new_accountkey,AErrors)) then exit; // BUG 20171511
+      //------
+    end else if Not (TAccountComp.IsValidAccountKey(LTarget.accountInfo.new_publicKey,AErrors)) then exit;
 
 
     // Fill the purchase data
     // Fill the purchase data
     FData.opTransactionStyle := transaction_with_auto_buy_account; // Set this data!
     FData.opTransactionStyle := transaction_with_auto_buy_account; // Set this data!
@@ -929,10 +935,8 @@ begin
       AErrors := 'Target key cannot be changed during atomic coin swap';
       AErrors := 'Target key cannot be changed during atomic coin swap';
       exit;
       exit;
     end;
     end;
-
   end;
   end;
 
 
-
   if (FData.opTransactionStyle in [buy_account, transaction_with_auto_buy_account]) then begin
   if (FData.opTransactionStyle in [buy_account, transaction_with_auto_buy_account]) then begin
     // account purchase
     // account purchase
     if (ASafeBoxTransaction.FreezedSafeBox.CurrentProtocol<CT_PROTOCOL_2) then begin
     if (ASafeBoxTransaction.FreezedSafeBox.CurrentProtocol<CT_PROTOCOL_2) then begin
@@ -1434,7 +1438,7 @@ end;
 
 
 procedure TOpChangeKey.InitializeData(AProtocolVersion : Word);
 procedure TOpChangeKey.InitializeData(AProtocolVersion : Word);
 begin
 begin
-  inherited(AProtocolVersion);
+  inherited InitializeData(AProtocolVersion);
   FData := CT_TOpChangeKeyData_NUL;
   FData := CT_TOpChangeKeyData_NUL;
 end;
 end;