Browse Source

Merge downstream

Herman Schoenfeld 7 years ago
parent
commit
bbdb733a8e

+ 16 - 51
src/gui/wizards/operations/UWIZChangeKey.pas

@@ -46,6 +46,7 @@ uses
   UECIES,
   UAES,
   UWIZChangeKey_ConfirmAccount,
+  UWIZChangeKey_SelectOption,
   UWIZChangeKey_Confirmation;
 
 { TWIZChangeKeyWizard }
@@ -85,14 +86,10 @@ begin
 
         case Model.ChangeKey.ChangeKeyMode of
           akaTransferAccountOwnership:
-          begin
             public_key := Model.TransferAccount.AccountKey;
-          end;
 
           akaChangeAccountPrivateKey:
-          begin
             public_key := Model.ChangeAccountPrivateKey.NewWalletKey.AccountKey;
-          end;
 
         end;
 
@@ -126,22 +123,17 @@ begin
       end
 
       else
-      begin
         raise Exception.Create('Invalid Encryption Selection');
-      end;
     end;
 
   finally
     if valid then
-    begin
       if length(payload_encrypted) > CT_MaxPayloadSize then
       begin
         valid := False;
         errors := 'Payload size is bigger than ' + IntToStr(CT_MaxPayloadSize) +
           ' (' + IntToStr(length(payload_encrypted)) + ')';
       end;
-
-    end;
     Model.Payload.EncodedBytes := payload_encrypted;
     Result := valid;
   end;
@@ -171,8 +163,6 @@ begin
     Exit;
   end
   else
-  begin
-
     for iAcc := Low(Model.Account.SelectedAccounts) to High(Model.Account.SelectedAccounts) do
     begin
       sender_account := Model.Account.SelectedAccounts[iAcc];
@@ -188,20 +178,15 @@ begin
       if not assigned(wk.PrivateKey) then
       begin
         if wk.CryptedKey <> '' then
-        begin
-          // TODO: handle unlocking of encrypted wallet here
-          errors := 'Wallet is password protected. Need password';
-        end
+          errors := 'Wallet is password protected. Need password'// TODO: handle unlocking of encrypted wallet here
+
         else
-        begin
           errors := 'Only public key of account ' +
             TAccountComp.AccountNumberToAccountTxtNumber(sender_account.account) +
             ' found in wallet. You cannot operate with this account';
-        end;
         Exit;
       end;
     end;
-  end;
 
   Result := UpdateOpChangeKey(Model.Account.SelectedAccounts[0], signer_account,
     publicKey, errors);
@@ -217,14 +202,10 @@ begin
 
     case Model.ChangeKey.ChangeKeyMode of
       akaTransferAccountOwnership:
-      begin
         NewPublicKey := Model.TransferAccount.AccountKey;
-      end;
 
       akaChangeAccountPrivateKey:
-      begin
         NewPublicKey := Model.ChangeAccountPrivateKey.NewWalletKey.AccountKey;
-      end;
 
     end;
 
@@ -250,9 +231,7 @@ begin
       end;
     end
     else
-    begin
       SignerAccount := TargetAccount;
-    end;
 
     if (TAccountComp.EqualAccountKeys(TargetAccount.accountInfo.accountKey,
       NewPublicKey)) then
@@ -301,15 +280,11 @@ begin
         op := nil;
       account := Model.Account.SelectedAccounts[iAcc];
       if not UpdatePayload(account, errors) then
-      begin
         raise Exception.Create('Error encoding payload of sender account ' +
           TAccountComp.AccountNumberToAccountTxtNumber(account.account) + ': ' + errors);
-      end;
       i := TWallet.Keys.IndexOfAccountKey(account.accountInfo.accountKey);
       if i < 0 then
-      begin
         raise Exception.Create('Sender account private key not found in Wallet');
-      end;
 
       wk := TWallet.Keys.Key[i];
       dooperation := True;
@@ -320,9 +295,7 @@ begin
         _fee := account.balance;
 
       if not UpdateOpChangeKey(account, signerAccount, _newOwnerPublicKey, errors) then
-      begin
         raise Exception.Create(errors);
-      end;
       if _V2 then
       begin
         // must ensure is Signer account last if included in sender accounts (not necessarily ordered enumeration)
@@ -350,10 +323,8 @@ begin
         Inc(_totalSignerFee, _fee);
       end
       else
-      begin
         op := TOpChangeKey.Create(account.account, account.n_operation +
           1, account.account, wk.PrivateKey, _newOwnerPublicKey, _fee, Model.Payload.EncodedBytes);
-      end;
       Inc(_totalfee, _fee);
       operationstxt :=
         'Change private key to ' + TAccountComp.GetECInfoTxt(
@@ -382,30 +353,21 @@ begin
         #10 + #10 + 'Note: This operation will be transmitted to the network!'),
         PChar(Application.Title), MB_YESNO + MB_ICONINFORMATION + MB_DEFBUTTON2) <>
         idYes then
-      begin
         Exit;
-      end;
     end
     else
-    begin
-      if Application.MessageBox(PChar('Execute this operation:' + #10 +
-        #10 + operation_to_string + #10 + #10 +
-        'Note: This operation will be transmitted to the network!'),
-        PChar(Application.Title), MB_YESNO + MB_ICONINFORMATION + MB_DEFBUTTON2) <> idYes then
-      begin
-        Exit;
-      end;
-    end;
+    if Application.MessageBox(PChar('Execute this operation:' + #10 +
+      #10 + operation_to_string + #10 + #10 +
+      'Note: This operation will be transmitted to the network!'),
+      PChar(Application.Title), MB_YESNO + MB_ICONINFORMATION + MB_DEFBUTTON2) <> idYes then
+      Exit;
     i := TNode.Node.AddOperations(nil, ops, nil, errors);
     if (i = ops.OperationsCount) then
     begin
       operationstxt := 'Successfully executed ' + IntToStr(i) +
         ' operations!' + #10 + #10 + operation_to_string;
       if i > 1 then
-      begin
-
-        ShowMessage(operationstxt);
-      end
+        ShowMessage(operationstxt)
       else
       begin
         Application.MessageBox(
@@ -424,9 +386,7 @@ begin
       ShowMessage(operationstxt);
     end
     else
-    begin
       raise Exception.Create(errors);
-    end;
 
 
   finally
@@ -437,8 +397,13 @@ end;
 
 constructor TWIZChangeKeyWizard.Create(AOwner: TComponent);
 begin
-  inherited Create(AOwner, [TWIZChangeKey_ConfirmAccount,
-    TWIZChangeKey_Confirmation]);
+  inherited Create(AOwner,
+    [
+    TWIZChangeKey_ConfirmAccount,
+    TWIZChangeKey_SelectOption,
+    TWIZChangeKey_Confirmation
+    ]
+    );
   TitleText := 'Change Key';
   FinishText := 'Change Key';
 end;

+ 1 - 0
src/gui/wizards/operations/UWIZChangeKey_EnterKey.lfm

@@ -7,6 +7,7 @@ object WIZChangeKey_EnterKey: TWIZChangeKey_EnterKey
   Caption = 'ChangeKey_EnterKey'
   ClientHeight = 253
   ClientWidth = 429
+  LCLVersion = '1.8.2.0'
   Visible = False
   object gbNewPublicKey: TGroupBox
     Left = 16

+ 4 - 17
src/gui/wizards/operations/UWIZChangeKey_EnterKey.pas

@@ -19,7 +19,7 @@ uses
   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
   ExtCtrls, Buttons, UCommon, UCommon.Collections, UWallet,
   UFRMAccountSelect, UNode, UWizard, UWIZOperationFee_Custom, UWIZOperationPayload_Encryption, UWIZOperationSigner_Select,
-  UWIZChangeKey_Confirmation, UWIZModels;
+  UWIZModels;
 
 type
 
@@ -61,31 +61,18 @@ end;
 
 procedure TWIZChangeKey_EnterKey.OnNext;
 begin
-  //Model.Payload.HasPayload := chkAttachPayload.Checked;
-  //
-  //if chkChooseFee.Checked then
-  //  UpdatePath(ptReplaceAllNext, [TWIZOperationFee_Custom, TWIZChangeKey_Confirmation])
-  //else
-  //begin
-  //  Model.Fee.SingleOperationFee := TSettings.DefaultFee;
-  //  if Model.Payload.HasPayload then
-  //    UpdatePath(ptReplaceAllNext, [TWIZOperationPayload_Encryption, TWIZChangeKey_Confirmation])
-  //  else
-  //    UpdatePath(ptReplaceAllNext, [TWIZOperationSigner_Select, TWIZChangeKey_Confirmation]);
-  //end;
-
 
   Model.Payload.HasPayload := chkAttachPayload.Checked;
 
   if chkChooseFee.Checked then
-    UpdatePath(ptReplaceAllNext, [TWIZOperationFee_Custom, TWIZChangeKey_Confirmation])
+    UpdatePath(ptInject, [TWIZOperationFee_Custom])
   else
   begin
     Model.Fee.SingleOperationFee := TSettings.DefaultFee;
     if Model.Payload.HasPayload then
-      UpdatePath(ptReplaceAllNext, [TWIZOperationPayload_Encryption, TWIZChangeKey_Confirmation])
+      UpdatePath(ptInject, [TWIZOperationPayload_Encryption])
     else if Length(Model.Account.SelectedAccounts) > 1 then
-      UpdatePath(ptReplaceAllNext, [TWIZOperationSigner_Select, TWIZChangeKey_Confirmation])
+      UpdatePath(ptInject, [TWIZOperationSigner_Select])
     else
     begin
       Model.Signer.SignerAccount := Model.Account.SelectedAccounts[0];

+ 1 - 0
src/gui/wizards/operations/UWIZChangeKey_SelectKey.lfm

@@ -7,6 +7,7 @@ object WIZChangeKey_SelectKey: TWIZChangeKey_SelectKey
   Caption = 'WIZChangeKey_SelectKey'
   ClientHeight = 253
   ClientWidth = 429
+  LCLVersion = '1.8.2.0'
   Visible = False
   object gbNewPrivateKey: TGroupBox
     Left = 16

+ 5 - 16
src/gui/wizards/operations/UWIZChangeKey_SelectKey.pas

@@ -18,8 +18,8 @@ interface
 uses
   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
   ExtCtrls, Buttons, UCommon, UCommon.Collections, UWallet,
-  UFRMAccountSelect, UNode, UWizard,
-  UWIZChangeKey_Confirmation, UWIZOperationFee_Custom, UWIZOperationSigner_Select, UWIZOperationPayload_Encryption, UWIZModels;
+  UFRMAccountSelect, UNode, UWizard, UWIZOperationFee_Custom, UWIZOperationSigner_Select, UWIZOperationPayload_Encryption,
+  UWIZModels;
 
 type
 
@@ -119,27 +119,16 @@ begin
   Model.ChangeAccountPrivateKey.SelectedIndex := cbNewPrivateKey.ItemIndex;
   Model.ChangeAccountPrivateKey.NewWalletKey := TWallet.Keys.Key[PtrInt(cbNewPrivateKey.Items.Objects[cbNewPrivateKey.ItemIndex])];
   Model.Payload.HasPayload := chkAttachPayload.Checked;
-  //
-  //if chkChooseFee.Checked then
-  //  UpdatePath(ptReplaceAllNext, [TWIZOperationFee_Custom, TWIZChangeKey_Confirmation])
-  //else
-  //begin
-  //  Model.Fee.SingleOperationFee := TSettings.DefaultFee;
-  //  if Model.Payload.HasPayload then
-  //    UpdatePath(ptReplaceAllNext, [TWIZOperationPayload_Encryption, TWIZChangeKey_Confirmation])
-  //  else
-  //    UpdatePath(ptReplaceAllNext, [TWIZOperationSigner_Select, TWIZChangeKey_Confirmation]);
-  //end;
 
   if chkChooseFee.Checked then
-    UpdatePath(ptReplaceAllNext, [TWIZOperationFee_Custom, TWIZChangeKey_Confirmation])
+    UpdatePath(ptInject, [TWIZOperationFee_Custom])
   else
   begin
     Model.Fee.SingleOperationFee := TSettings.DefaultFee;
     if Model.Payload.HasPayload then
-      UpdatePath(ptReplaceAllNext, [TWIZOperationPayload_Encryption, TWIZChangeKey_Confirmation])
+      UpdatePath(ptInject, [TWIZOperationPayload_Encryption])
     else if Length(Model.Account.SelectedAccounts) > 1 then
-      UpdatePath(ptReplaceAllNext, [TWIZOperationSigner_Select, TWIZChangeKey_Confirmation])
+      UpdatePath(ptInject, [TWIZOperationSigner_Select])
     else
     begin
       Model.Signer.SignerAccount := Model.Account.SelectedAccounts[0];

+ 1 - 0
src/gui/wizards/operations/UWIZChangeKey_SelectOption.lfm

@@ -7,6 +7,7 @@ object WIZChangeKey_SelectOption: TWIZChangeKey_SelectOption
   Caption = 'WIZChangeKey_SelectOption'
   ClientHeight = 253
   ClientWidth = 429
+  LCLVersion = '1.8.2.0'
   Visible = False
   object gbChangeKeyOptions: TGroupBox
     Left = 8

+ 3 - 5
src/gui/wizards/operations/UWIZChangeKey_SelectOption.pas

@@ -17,7 +17,7 @@ interface
 
 uses
   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
-  ExtCtrls, UWizard, UWIZChangeKey, UWIZModels, UWIZChangeKey_EnterKey, UWIZChangeKey_SelectKey, UWIZChangeKey_Confirmation;
+  ExtCtrls, UWizard, UWIZChangeKey, UWIZModels, UWIZChangeKey_EnterKey, UWIZChangeKey_SelectKey;
 
 type
 
@@ -49,14 +49,12 @@ begin
   if rbTransferAccountOwnership.Checked then
   begin
     Model.ChangeKey.ChangeKeyMode := akaTransferAccountOwnership;
-    UpdatePath(ptReplaceAllNext, [TWIZChangeKey_EnterKey,
-      TWIZChangeKey_Confirmation]);
+    UpdatePath(ptInject, [TWIZChangeKey_EnterKey]);
   end
   else if rbChangeAccountPrivateKey.Checked then
   begin
     Model.ChangeKey.ChangeKeyMode := akaChangeAccountPrivateKey;
-    UpdatePath(ptReplaceAllNext, [TWIZChangeKey_SelectKey,
-      TWIZChangeKey_Confirmation]);
+    UpdatePath(ptInject, [TWIZChangeKey_SelectKey]);
   end;
 end;
 

+ 9 - 1
src/gui/wizards/operations/UWIZSendPASC.pas

@@ -47,6 +47,7 @@ uses
   UAES,
   UWIZSendPASC_ConfirmSender,
   UWIZSendPASC_EnterRecipient,
+  UWIZSendPASC_EnterQuantity,
   UWIZSendPASC_Confirmation;
 
 { TWIZSendPASCWizard }
@@ -366,7 +367,14 @@ end;
 
 constructor TWIZSendPASCWizard.Create(AOwner: TComponent);
 begin
-  inherited Create(AOwner, [TWIZSendPASC_ConfirmSender, TWIZSendPASC_Confirmation]);
+  inherited Create(AOwner,
+    [
+    TWIZSendPASC_ConfirmSender,
+    TWIZSendPASC_EnterRecipient,
+    TWIZSendPASC_EnterQuantity,
+    TWIZSendPASC_Confirmation
+    ]
+    );
   TitleText := 'Send PASC';
   FinishText := 'Send PASC';
 end;

+ 1 - 0
src/gui/wizards/operations/UWIZSendPASC_ConfirmSender.lfm

@@ -6,6 +6,7 @@ object WIZSendPASC_ConfirmSender: TWIZSendPASC_ConfirmSender
   Caption = 'WIZSendPASC_ConfirmSender'
   ClientHeight = 261
   ClientWidth = 429
+  LCLVersion = '1.8.2.0'
   Visible = False
   object gpSender: TGroupBox
     Left = 4

+ 2 - 2
src/gui/wizards/operations/UWIZSendPASC_ConfirmSender.pas

@@ -17,7 +17,7 @@ interface
 uses
   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
   ExtCtrls, UVisualGrid, UCommon.Data, UCellRenderers,
-  UWizard, UWIZSendPASC, UWIZSendPASC_EnterRecipient, UWIZSendPASC_Confirmation, UWIZModels;
+  UWizard, UWIZSendPASC, UWIZSendPASC_EnterRecipient, UWIZModels;
 
 type
 
@@ -97,7 +97,7 @@ end;
 
 procedure TWIZSendPASC_ConfirmSender.OnNext;
 begin
-  UpdatePath(ptReplaceAllNext, [TWIZSendPASC_EnterRecipient, TWIZSendPASC_Confirmation]);
+  UpdatePath(ptInject, [TWIZSendPASC_EnterRecipient]);
 end;
 
 function TWIZSendPASC_ConfirmSender.Validate(out message: ansistring): boolean;

+ 1 - 0
src/gui/wizards/operations/UWIZSendPASC_EnterQuantity.lfm

@@ -7,6 +7,7 @@ object WIZSendPASC_EnterQuantity: TWIZSendPASC_EnterQuantity
   Caption = 'WIZSendPASC_EnterQuantity'
   ClientHeight = 253
   ClientWidth = 429
+  LCLVersion = '1.8.2.0'
   Visible = False
   object gbQuantity: TGroupBox
     Left = 16

+ 6 - 6
src/gui/wizards/operations/UWIZSendPASC_EnterQuantity.pas

@@ -18,8 +18,8 @@ interface
 uses
   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
   ExtCtrls, Buttons, UCommon, UCommon.Collections, UWallet,
-  UFRMAccountSelect, UNode, UWizard, UWIZSendPASC, UWIZOperationFee_Custom, UWIZOperationPayload_Encryption, UWIZOperationSigner_Select,
-  UWIZSendPASC_Confirmation, UWIZModels;
+  UFRMAccountSelect, UNode, UWizard, UWIZSendPASC, UWIZOperationFee_Custom, UWIZOperationPayload_Encryption,
+  UWIZOperationSigner_Select, UWIZModels;
 
 type
 
@@ -95,20 +95,20 @@ var
 begin
   Model.Payload.HasPayload := chkAttachPayload.Checked;
   if chkallfunds.Checked then
-    Model.SendPASC.SingleAmountToSend := 0// all balance
+    Model.SendPASC.SingleAmountToSend := 0 // all balance
 
   else
     TAccountComp.TxtToMoney(edtAmt.Text, Model.SendPASC.SingleAmountToSend);
 
   if chkChooseFee.Checked then
-    UpdatePath(ptReplaceAllNext, [TWIZOperationFee_Custom, TWIZSendPASC_Confirmation])
+    UpdatePath(ptInject, [TWIZOperationFee_Custom])
   else
   begin
     Model.Fee.SingleOperationFee := TSettings.DefaultFee;
     if Model.Payload.HasPayload then
-      UpdatePath(ptReplaceAllNext, [TWIZOperationPayload_Encryption, TWIZSendPASC_Confirmation])
+      UpdatePath(ptInject, [TWIZOperationPayload_Encryption])
     else if Length(Model.Account.SelectedAccounts) > 1 then
-      UpdatePath(ptReplaceAllNext, [TWIZOperationSigner_Select, TWIZSendPASC_Confirmation])
+      UpdatePath(ptInject, [TWIZOperationSigner_Select])
     else
     begin
       Model.Signer.SignerAccount := Model.Account.SelectedAccounts[0];

+ 5 - 7
src/gui/wizards/operations/UWIZSendPASC_EnterRecipient.pas

@@ -18,8 +18,7 @@ interface
 uses
   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
   ExtCtrls, Buttons, UCommon, UCommon.Collections, UWallet,
-  UFRMAccountSelect, UNode, UWizard, UWIZSendPASC, UWIZSendPASC_EnterQuantity,
-  UWIZSendPASC_Confirmation, UWIZModels;
+  UFRMAccountSelect, UNode, UWizard, UWIZSendPASC, UWIZSendPASC_EnterQuantity, UWIZModels;
 
 type
 
@@ -39,6 +38,7 @@ type
     procedure UpdateUI();
 
 
+
   public
     procedure OnPresent; override;
     procedure OnNext; override;
@@ -63,7 +63,7 @@ end;
 procedure TWIZSendPASC_EnterRecipient.UpdateUI();
 var
   tempAcc: TAccount;
-  c: Cardinal;
+  c: cardinal;
 begin
   if TAccountComp.AccountTxtNumberToAccountNumber(edtDestAcc.Text, c) then
   begin
@@ -106,9 +106,7 @@ begin
       F.DefaultAccount := c;
     F.AllowSelect := True;
     if F.ShowModal = mrOk then
-    begin
       edtDestAcc.Text := TAccountComp.AccountNumberToAccountTxtNumber(F.GetSelected);
-    end;
   finally
     F.Free;
   end;
@@ -122,8 +120,8 @@ var
 begin
   TAccountComp.AccountTxtNumberToAccountNumber(edtDestAcc.Text, c);
   Model.SendPASC.DestinationAccount := TNode.Node.Operations.SafeBoxTransaction.account(c);
-  UpdatePath(ptReplaceAllNext, [TWIZSendPASC_EnterQuantity,
-    TWIZSendPASC_Confirmation]);
+  UpdatePath(ptInject, [TWIZSendPASC_EnterQuantity]);
+
 end;
 
 function TWIZSendPASC_EnterRecipient.Validate(out message: ansistring): boolean;