Browse Source

Fix: Account Data bug issue on V4 versions

Account Data is only available on V5
PascalCoin 5 years ago
parent
commit
d5c9f65f0c

+ 7 - 1
src/core/UOpTransaction.pas

@@ -441,6 +441,7 @@ begin
   if (b AND $04)=$04 then FData.changes_type:=FData.changes_type + [account_type];
   if (b AND $08)=$08 then FData.changes_type:=FData.changes_type + [account_data];
   // Check
+  if (FProtocolVersion<CT_PROTOCOL_5) and ((b AND $F8)<>0) then Exit;
   if (b AND $F0)<>0 then Exit;
   if TStreamOp.ReadAccountKey(Stream,FData.new_accountkey)<0 then Exit;
   if TStreamOp.ReadAnsiString(Stream,FData.new_name)<0 then Exit;
@@ -607,7 +608,12 @@ begin
     account_target.account_type := FData.new_type;
   end;
   If (account_data in FData.changes_type) then begin
-    account_target.account_data := FData.new_data;
+    if LSafeboxCurrentProtocol>=CT_PROTOCOL_5 then begin
+      account_target.account_data := FData.new_data
+    end else begin
+      errors := 'Account Data not available until protocol 5';
+      Exit;
+    end;
   end;
   Result := AccountTransaction.UpdateAccountInfo(AccountPreviousUpdatedBlock,
          GetOpID,

+ 4 - 0
src/core/UTxMultiOperation.pas

@@ -694,6 +694,10 @@ begin
     end;
     // Account Data protection: (PIP-0024)
     if (account_data in chi.Changes_type) then begin
+      if (LSafeboxCurrentProtocol<CT_PROTOCOL_5) then begin
+        errors := 'Account Data not available until protocol 5';
+        Exit;
+      end;
       if Length(chi.New_Data)>CT_MaxAccountDataSize then begin
         errors := 'New data length ('+IntToStr(Length(chi.New_data))+') > '+IntToStr(CT_MaxAccountDataSize);
         Exit;

+ 1 - 1
src/gui-classic/UFRMOperation.pas

@@ -999,7 +999,7 @@ begin
         errors := Format('Data size (%d) greater than %d',[Length(ANewData),CT_MaxAccountDataSize]);
         Exit;
       end;
-    end;
+    end else AChangeData:=False;
     If (SenderAccounts.Count=1) And (TBaseType.Equals(newName,TargetAccount.name)) And (newType=TargetAccount.account_type)
       And (TBaseType.Equals(ANewData,TargetAccount.account_data)) then begin
       errors := 'No changes on fields. Not changed';

+ 1 - 1
src/gui-classic/UFRMOperationsExplorer.pas

@@ -545,7 +545,7 @@ begin
   ms := TMemoryStream.Create;
   opht := TOperationsHashTree.Create;
   Try
-    ms.Write(raw[1],Length(raw));
+    ms.Write(raw[0],Length(raw));
     ms.Position:=0;
     If Not opht.LoadOperationsHashTreeFromStream(ms,false,TNode.Node.Bank.SafeBox.CurrentProtocol,TNode.Node.Bank.SafeBox.CurrentProtocol,Nil,errors) then Raise Exception.Create(errors);
     For i:=0 to opht.OperationsCount-1 do begin