Browse Source

Refactor: updated operation wizard model pattern

Herman Schoenfeld 7 years ago
parent
commit
5a2e0bdd0a
44 changed files with 354 additions and 382 deletions
  1. 1 1
      src/gui/UCTRLWallet.lfm
  2. 18 38
      src/gui/UCTRLWallet.pas
  3. 1 1
      src/gui/UFRMWalletKeys.pas
  4. 1 12
      src/gui/wizards/UWIZAddKey.pas
  5. 2 1
      src/gui/wizards/UWIZAddKey_EnterName.lfm
  6. 1 1
      src/gui/wizards/UWIZAddKey_EnterName.pas
  7. 2 1
      src/gui/wizards/UWIZAddKey_GenerateOrImport.lfm
  8. 1 1
      src/gui/wizards/UWIZAddKey_GenerateOrImport.pas
  9. 2 1
      src/gui/wizards/UWIZAddKey_ImportPrivKey.lfm
  10. 1 1
      src/gui/wizards/UWIZAddKey_ImportPrivKey.pas
  11. 2 1
      src/gui/wizards/UWIZAddKey_ImportPubKey.lfm
  12. 1 1
      src/gui/wizards/UWIZAddKey_ImportPubKey.pas
  13. 1 1
      src/gui/wizards/UWIZAddKey_SelectEncryption.pas
  14. 2 1
      src/gui/wizards/UWIZAddKey_Start.lfm
  15. 1 1
      src/gui/wizards/UWIZAddKey_Start.pas
  16. 29 48
      src/gui/wizards/UWIZChangeAccountPrivateKey.pas
  17. 1 1
      src/gui/wizards/UWIZChangeAccountPrivateKey_Confirmation.lfm
  18. 6 8
      src/gui/wizards/UWIZChangeAccountPrivateKey_Confirmation.pas
  19. 1 0
      src/gui/wizards/UWIZChangeAccountPrivateKey_Start.lfm
  20. 5 5
      src/gui/wizards/UWIZChangeAccountPrivateKey_Start.pas
  21. 1 0
      src/gui/wizards/UWIZChangeAccountPrivateKey_Transaction.lfm
  22. 15 21
      src/gui/wizards/UWIZChangeAccountPrivateKey_Transaction.pas
  23. 1 1
      src/gui/wizards/UWIZChangeAccountPrivateKey_TransactionPayload.lfm
  24. 7 7
      src/gui/wizards/UWIZChangeAccountPrivateKey_TransactionPayload.pas
  25. 108 0
      src/gui/wizards/UWIZModels.pas
  26. 37 62
      src/gui/wizards/UWIZSendPASC.pas
  27. 1 0
      src/gui/wizards/UWIZSendPASC_Confirmation.lfm
  28. 7 7
      src/gui/wizards/UWIZSendPASC_Confirmation.pas
  29. 1 0
      src/gui/wizards/UWIZSendPASC_Start.lfm
  30. 5 5
      src/gui/wizards/UWIZSendPASC_Start.pas
  31. 1 0
      src/gui/wizards/UWIZSendPASC_Transaction.lfm
  32. 14 15
      src/gui/wizards/UWIZSendPASC_Transaction.pas
  33. 1 0
      src/gui/wizards/UWIZSendPASC_TransactionPayload.lfm
  34. 7 7
      src/gui/wizards/UWIZSendPASC_TransactionPayload.pas
  35. 31 51
      src/gui/wizards/UWIZTransferAccount.pas
  36. 1 1
      src/gui/wizards/UWIZTransferAccount_Confirmation.lfm
  37. 6 6
      src/gui/wizards/UWIZTransferAccount_Confirmation.pas
  38. 1 1
      src/gui/wizards/UWIZTransferAccount_Start.lfm
  39. 5 5
      src/gui/wizards/UWIZTransferAccount_Start.pas
  40. 1 1
      src/gui/wizards/UWIZTransferAccount_Transaction.lfm
  41. 14 16
      src/gui/wizards/UWIZTransferAccount_Transaction.pas
  42. 1 0
      src/gui/wizards/UWIZTransferAccount_TransactionPayload.lfm
  43. 7 7
      src/gui/wizards/UWIZTransferAccount_TransactionPayload.pas
  44. 2 44
      src/pascalcoin_wallet.lpi

+ 1 - 1
src/gui/UCTRLWallet.lfm

@@ -10,7 +10,7 @@ object CTRLWallet: TCTRLWallet
   ClientWidth = 1151
   OnCreate = FormCreate
   OnResize = FormResize
-  LCLVersion = '1.8.1.0'
+  LCLVersion = '1.8.2.0'
   Visible = False
   object PairSplitter1: TPairSplitter
     Left = 0

+ 18 - 38
src/gui/UCTRLWallet.pas

@@ -10,7 +10,7 @@ uses
   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, Menus,
   ExtCtrls, PairSplitter, Buttons, UVisualGrid, UCommon.UI, Generics.Collections,
   UAccounts, UDataSources, UNode, UWIZSendPASC, UWIZTransferAccount,
-  UWIZChangeAccountPrivateKey, UWIZEnlistAccountForSale;
+  UWIZChangeAccountPrivateKey;
 
 type
 
@@ -104,7 +104,7 @@ implementation
 
 uses
   UUserInterface, UCellRenderers, UBlockChain, UWallet, UCrypto, UCoreUtils,
-  UCommon, UMemory, Generics.Defaults, UCommon.Data, UCommon.Collections;
+  UCommon, UMemory, Generics.Defaults, UCommon.Data, UCommon.Collections, UWIZModels;
 
 {$R *.lfm}
 
@@ -390,8 +390,8 @@ end;
 //  Result := ARow.Account;
 //end;
 
-function TCTRLWallet.GetAccounts(const AccountNumbers: TArray<cardinal>):
-TArray<TAccount>;
+function TCTRLWallet.GetAccounts(
+  const AccountNumbers: TArray<cardinal>): TArray<TAccount>;
 var
   acc: TAccount;
   safeBox: TPCSafeBox;
@@ -637,18 +637,18 @@ procedure TCTRLWallet.miSendPASCClick(Sender: TObject);
 var
   Scoped: TDisposables;
   wiz: TWIZSendPASCWizard;
-  model: TWizSendPASCModel;
+  model: TWIZOperationsModel;
   AccountNumbersWithoutChecksum: TArray<cardinal>;
 begin
   wiz := Scoped.AddObject(TWIZSendPASCWizard.Create(nil)) as TWIZSendPASCWizard;
-  model := Scoped.AddObject(TWizSendPASCModel.Create(nil)) as TWizSendPASCModel;
+  model := TWIZOperationsModel.Create(wiz, omtSendPasc);
 
   AccountNumbersWithoutChecksum :=
     TListTool<variant, cardinal>.Transform(FAccountsGrid.SelectedRows,
     GetAccNoWithoutChecksum);
 
-  model.SelectedAccounts := GetAccounts(AccountNumbersWithoutChecksum);
-  model.SelectedIndex := 0;
+  model.SendPASCModel.SelectedAccounts := GetAccounts(AccountNumbersWithoutChecksum);
+  model.SendPASCModel.SelectedIndex := 0;
   wiz.Start(model);
 end;
 
@@ -656,20 +656,18 @@ procedure TCTRLWallet.miTransferAccountsClick(Sender: TObject);
 var
   Scoped: TDisposables;
   wiz: TWIZTransferAccountWizard;
-  model: TWIZTransferAccountModel;
+  model: TWIZOperationsModel;
   AccountNumbersWithoutChecksum: TArray<cardinal>;
 begin
   wiz := Scoped.AddObject(TWIZTransferAccountWizard.Create(nil)) as
     TWIZTransferAccountWizard;
-  model := Scoped.AddObject(TWIZTransferAccountModel.Create(nil)) as
-    TWIZTransferAccountModel;
-
+  model := TWIZOperationsModel.Create(wiz, omtTransferAccount);
   AccountNumbersWithoutChecksum :=
     TListTool<variant, cardinal>.Transform(FAccountsGrid.SelectedRows,
     GetAccNoWithoutChecksum);
 
-  model.SelectedAccounts := GetAccounts(AccountNumbersWithoutChecksum);
-  model.SelectedIndex := 0;
+  model.TransferAccountModel.SelectedAccounts := GetAccounts(AccountNumbersWithoutChecksum);
+  model.TransferAccountModel.SelectedIndex := 0;
   wiz.Start(model);
 end;
 
@@ -677,42 +675,24 @@ procedure TCTRLWallet.miChangeAccountsPrivateKeyClick(Sender: TObject);
 var
   Scoped: TDisposables;
   wiz: TWIZChangeAccountPrivateKeyWizard;
-  model: TWIZChangeAccountPrivateKeyModel;
+  model: TWIZOperationsModel;
   AccountNumbersWithoutChecksum: TArray<cardinal>;
 begin
-  wiz := Scoped.AddObject(TWIZChangeAccountPrivateKeyWizard.Create(nil)) as
-    TWIZChangeAccountPrivateKeyWizard;
-  model := Scoped.AddObject(TWIZChangeAccountPrivateKeyModel.Create(nil)) as
-    TWIZChangeAccountPrivateKeyModel;
+  wiz := Scoped.AddObject(TWIZChangeAccountPrivateKeyWizard.Create(nil)) as TWIZChangeAccountPrivateKeyWizard;
+  model := TWIZOperationsModel.Create(wiz, omtChangeAccountPrivateKey);
 
   AccountNumbersWithoutChecksum :=
     TListTool<variant, cardinal>.Transform(FAccountsGrid.SelectedRows,
     GetAccNoWithoutChecksum);
 
-  model.SelectedAccounts := GetAccounts(AccountNumbersWithoutChecksum);
-  model.SelectedIndex := 0;
+  model.ChangeAccountPrivateKeyModel.SelectedAccounts := GetAccounts(AccountNumbersWithoutChecksum);
+  model.ChangeAccountPrivateKeyModel.SelectedIndex := 0;
   wiz.Start(model);
 end;
 
 procedure TCTRLWallet.miEnlistAccountsForSaleClick(Sender: TObject);
-var
-  Scoped: TDisposables;
-  wiz: TWIZEnlistAccountForSaleWizard;
-  model: TWIZEnlistAccountForSaleModel;
-  AccountNumbersWithoutChecksum: TArray<cardinal>;
 begin
-  wiz := Scoped.AddObject(TWIZEnlistAccountForSaleWizard.Create(nil)) as
-    TWIZEnlistAccountForSaleWizard;
-  model := Scoped.AddObject(TWIZEnlistAccountForSaleModel.Create(nil)) as
-    TWIZEnlistAccountForSaleModel;
-
-  AccountNumbersWithoutChecksum :=
-    TListTool<variant, cardinal>.Transform(FAccountsGrid.SelectedRows,
-    GetAccNoWithoutChecksum);
-
-  model.SelectedAccounts := GetAccounts(AccountNumbersWithoutChecksum);
-  model.SelectedIndex := 0;
-  wiz.Start(model);
+ raise ENotImplemented.Create('not yet implemented.');
 end;
 
 procedure TCTRLWallet.miDelistAccountsFromSaleClick(Sender: TObject);

+ 1 - 1
src/gui/UFRMWalletKeys.pas

@@ -90,7 +90,7 @@ implementation
 
 {$R *.lfm}
 
-uses  LCLIntf, Clipbrd, UUserInterface, USettings, UCommon, UAccounts, UWIZAddKey, UMemory;
+uses LCLIntf, Clipbrd, UUserInterface, USettings, UCommon, UWIZModels, UAccounts, UWIZAddKey, UMemory;
 
 {%region Form life-cycle}
 

+ 1 - 12
src/gui/wizards/UWIZAddKey.pas

@@ -11,21 +11,10 @@ unit UWIZAddKey;
 interface
 
 uses
-  Classes, SysUtils, Forms, UWizard;
+  Classes, SysUtils, Forms, UWizard, UWIZModels;
 
 type
 
-  { TFRMAddKeyModel }
-  TWIZAddKeyAction = (akaGenerateKey, akaImportPrivateKey, akaImportPublicKey);
-  TWIZAddKeyModel = class(TComponent)
-    public
-      Name : String;
-      KeyText : String;
-      Password : String;
-      EncryptionTypeNID : word;
-      Action : TWIZAddKeyAction;
-  end;
-
   { TWIZAddKeyWizard }
 
   TWIZAddKeyWizard = class(TWizard<TWIZAddKeyModel>)

+ 2 - 1
src/gui/wizards/UWIZAddKey_EnterName.lfm

@@ -6,7 +6,8 @@ object WIZAddKey_EnterName: TWIZAddKey_EnterName
   Caption = 'WIZAddKey_EnterName'
   ClientHeight = 100
   ClientWidth = 334
-  LCLVersion = '1.6.4.0'
+  LCLVersion = '1.8.2.0'
+  Visible = False
   object Label2: TLabel
     Left = 17
     Height = 15

+ 1 - 1
src/gui/wizards/UWIZAddKey_EnterName.pas

@@ -12,7 +12,7 @@ interface
 
 uses
   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
-  ExtCtrls, UWizard, UWIZAddKey;
+  ExtCtrls, UWizard, UWIZAddKey, UWIZModels;
 
 type
 

+ 2 - 1
src/gui/wizards/UWIZAddKey_GenerateOrImport.lfm

@@ -6,7 +6,8 @@ object WIZAddKey_GenerateOrImport: TWIZAddKey_GenerateOrImport
   Caption = 'Add Key'
   ClientHeight = 285
   ClientWidth = 448
-  LCLVersion = '1.6.4.0'
+  LCLVersion = '1.8.2.0'
+  Visible = False
   object rbPrivateKey: TRadioButton
     Left = 32
     Height = 19

+ 1 - 1
src/gui/wizards/UWIZAddKey_GenerateOrImport.pas

@@ -12,7 +12,7 @@ interface
 
 uses
   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
-  UWizard, UWIZAddKey;
+  UWizard, UWIZAddKey, UWIZModels;
 
 type
 

+ 2 - 1
src/gui/wizards/UWIZAddKey_ImportPrivKey.lfm

@@ -6,7 +6,8 @@ object WIZAddKey_ImportPrivKey: TWIZAddKey_ImportPrivKey
   Caption = 'WIZAddKey_ImportPrivKey'
   ClientHeight = 225
   ClientWidth = 438
-  LCLVersion = '1.6.4.0'
+  LCLVersion = '1.8.2.0'
+  Visible = False
   object Label1: TLabel
     Left = 32
     Height = 32

+ 1 - 1
src/gui/wizards/UWIZAddKey_ImportPrivKey.pas

@@ -12,7 +12,7 @@ interface
 
 uses
   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
-  UWizard, UWIZAddKey;
+  UWizard, UWIZAddKey, UWIZModels;
 
 type
 

+ 2 - 1
src/gui/wizards/UWIZAddKey_ImportPubKey.lfm

@@ -6,7 +6,8 @@ object WIZAddKey_ImportPubKey: TWIZAddKey_ImportPubKey
   Caption = 'WIZAddKey_ImportPubKey'
   ClientHeight = 253
   ClientWidth = 429
-  LCLVersion = '1.6.4.0'
+  LCLVersion = '1.8.2.0'
+  Visible = False
   object Label1: TLabel
     Left = 32
     Height = 32

+ 1 - 1
src/gui/wizards/UWIZAddKey_ImportPubKey.pas

@@ -12,7 +12,7 @@ interface
 
 uses
   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
-  UWizard, UWIZAddKey;
+  UWizard, UWIZAddKey, UWIZModels;
 
 type
 

+ 1 - 1
src/gui/wizards/UWIZAddKey_SelectEncryption.pas

@@ -5,7 +5,7 @@ unit UWIZAddKey_SelectEncryption;
 interface
 
 uses
-  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls, UWizard, UWIZAddKey;
+  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls, UWizard, UWIZAddKey, UWIZModels;
 
 type
 

+ 2 - 1
src/gui/wizards/UWIZAddKey_Start.lfm

@@ -6,7 +6,8 @@ object WIZAddKey_Start: TWIZAddKey_Start
   Caption = 'Add Key'
   ClientHeight = 300
   ClientWidth = 437
-  LCLVersion = '1.6.4.0'
+  LCLVersion = '1.8.2.0'
+  Visible = False
   object rbPrivateKey: TRadioButton
     Left = 32
     Height = 19

+ 1 - 1
src/gui/wizards/UWIZAddKey_Start.pas

@@ -12,7 +12,7 @@ interface
 
 uses
   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
-  UWizard, UWIZAddKey;
+  UWizard, UWIZAddKey, UWIZModels;
 
 type
 

+ 29 - 48
src/gui/wizards/UWIZChangeAccountPrivateKey.pas

@@ -13,36 +13,17 @@ interface
 
 uses
   Classes, SysUtils, Forms, Dialogs, UCrypto, UWallet, UCommon, UWizard,
-  UAccounts, LCLType;
+  UAccounts, LCLType, UWIZModels;
 
 type
 
-  { TWIZChangeAccountPrivateKeyModel }
-  TWIZPayloadEncryptionMode = (akaEncryptWithOldEC, akaEncryptWithEC,
-    akaEncryptWithPassword, akaNotEncrypt);
-
-  TWIZChangeAccountPrivateKeyModel = class(TComponent)
-  public
-    DefaultFee: int64;
-    NewPublicKey, Payload, EncryptionPassword: string;
-    SelectedIndex, PrivateKeySelectedIndex: integer;
-    NewWalletKey: TWalletKey;
-    EncodedPayload: TRawBytes;
-    SignerAccount: TAccount;
-    SelectedAccounts: TArray<TAccount>;
-    PayloadEncryptionMode: TWIZPayloadEncryptionMode;
-  end;
-
   { TWIZChangeAccountPrivateKeyWizard }
 
-  TWIZChangeAccountPrivateKeyWizard = class(TWizard<TWIZChangeAccountPrivateKeyModel>)
+  TWIZChangeAccountPrivateKeyWizard = class(TWizard<TWIZOperationsModel>)
   private
-    function UpdatePayload(const SenderAccount: TAccount;
-      var errors: string): boolean;
+    function UpdatePayload(const SenderAccount: TAccount; var errors: string): boolean;
     function UpdateOperationOptions(var errors: string): boolean;
-    function UpdateOpChangeKey(const TargetAccount: TAccount;
-      var SignerAccount: TAccount; var NewPublicKey: TAccountKey;
-      var errors: ansistring): boolean;
+    function UpdateOpChangeKey(const TargetAccount: TAccount; var SignerAccount: TAccount; var NewPublicKey: TAccountKey; var errors: ansistring): boolean;
     procedure ChangeAccountPrivateKey();
   public
     constructor Create(AOwner: TComponent); override;
@@ -76,9 +57,9 @@ var
 begin
   valid := False;
   payload_encrypted := '';
-  Model.EncodedPayload := '';
+  Model.ChangeAccountPrivateKeyModel.EncodedPayload := '';
   errors := 'Unknown error';
-  payload_u := Model.Payload;
+  payload_u := Model.ChangeAccountPrivateKeyModel.Payload;
 
   try
     if (payload_u = '') then
@@ -86,7 +67,7 @@ begin
       valid := True;
       Exit;
     end;
-    case Model.PayloadEncryptionMode of
+    case Model.ChangeAccountPrivateKeyModel.PayloadEncryptionMode of
 
       akaEncryptWithOldEC:
       begin
@@ -101,7 +82,7 @@ begin
       begin
         errors := 'Error encrypting';
 
-        public_key := Model.NewWalletKey.AccountKey;
+        public_key := Model.ChangeAccountPrivateKeyModel.NewWalletKey.AccountKey;
         if public_key.EC_OpenSSL_NID <>
           CT_Account_NUL.accountInfo.accountKey.EC_OpenSSL_NID then
         begin
@@ -119,7 +100,7 @@ begin
       akaEncryptWithPassword:
       begin
         payload_encrypted := TAESComp.EVP_Encrypt_AES256(
-          payload_u, Model.EncryptionPassword);
+          payload_u, Model.ChangeAccountPrivateKeyModel.EncryptionPassword);
         valid := payload_encrypted <> '';
       end;
 
@@ -146,7 +127,7 @@ begin
       end;
 
     end;
-    Model.EncodedPayload := payload_encrypted;
+    Model.ChangeAccountPrivateKeyModel.EncodedPayload := payload_encrypted;
     Result := valid;
   end;
 
@@ -170,7 +151,7 @@ begin
     Exit;
   end;
 
-  if Length(Model.SelectedAccounts) = 0 then
+  if Length(Model.ChangeAccountPrivateKeyModel.SelectedAccounts) = 0 then
   begin
     errors := 'No sender account';
     Exit;
@@ -178,9 +159,9 @@ begin
   else
   begin
 
-    for iAcc := Low(Model.SelectedAccounts) to High(Model.SelectedAccounts) do
+    for iAcc := Low(Model.ChangeAccountPrivateKeyModel.SelectedAccounts) to High(Model.ChangeAccountPrivateKeyModel.SelectedAccounts) do
     begin
-      sender_account := Model.SelectedAccounts[iAcc];
+      sender_account := Model.ChangeAccountPrivateKeyModel.SelectedAccounts[iAcc];
       iWallet := TWallet.Keys.IndexOfAccountKey(sender_account.accountInfo.accountKey);
       if (iWallet < 0) then
       begin
@@ -208,7 +189,7 @@ begin
     end;
   end;
 
-  Result := UpdateOpChangeKey(Model.SelectedAccounts[0], signer_account,
+  Result := UpdateOpChangeKey(Model.ChangeAccountPrivateKeyModel.SelectedAccounts[0], signer_account,
     publicKey, errors);
   UpdatePayload(sender_account, e);
 end;
@@ -220,12 +201,12 @@ begin
   Result := False;
   errors := '';
   try
-    NewPublicKey := Model.NewWalletKey.AccountKey;
+    NewPublicKey := Model.ChangeAccountPrivateKeyModel.NewWalletKey.AccountKey;
 
     if TNode.Node.Bank.SafeBox.CurrentProtocol >= 1 then
     begin
       // Signer:
-      SignerAccount := Model.SignerAccount;
+      SignerAccount := Model.ChangeAccountPrivateKeyModel.SignerAccount;
       if (TAccountComp.IsAccountLocked(SignerAccount.accountInfo,
         TNode.Node.Bank.BlocksCount)) then
       begin
@@ -289,11 +270,11 @@ begin
     _signer_n_ops := 0;
     operationstxt := '';
     operation_to_string := '';
-    for iAcc := Low(Model.SelectedAccounts) to High(Model.SelectedAccounts) do
+    for iAcc := Low(Model.ChangeAccountPrivateKeyModel.SelectedAccounts) to High(Model.ChangeAccountPrivateKeyModel.SelectedAccounts) do
     begin
       loop_start:
         op := nil;
-      account := Model.SelectedAccounts[iAcc];
+      account := Model.ChangeAccountPrivateKeyModel.SelectedAccounts[iAcc];
       if not UpdatePayload(account, errors) then
       begin
         raise Exception.Create('Error encoding payload of sender account ' +
@@ -308,8 +289,8 @@ begin
       wk := TWallet.Keys.Key[i];
       dooperation := True;
       // Default fee
-      if account.balance > uint64(Model.DefaultFee) then
-        _fee := Model.DefaultFee
+      if account.balance > uint64(Model.ChangeAccountPrivateKeyModel.DefaultFee) then
+        _fee := Model.ChangeAccountPrivateKeyModel.DefaultFee
       else
         _fee := account.balance;
 
@@ -320,11 +301,11 @@ begin
       if _V2 then
       begin
         // must ensure is Signer account last if included in sender accounts (not necessarily ordered enumeration)
-        if (iAcc < Length(Model.SelectedAccounts) - 1) and
+        if (iAcc < Length(Model.ChangeAccountPrivateKeyModel.SelectedAccounts) - 1) and
           (account.account = signerAccount.account) then
         begin
-          TArrayTool<TAccount>.Swap(Model.SelectedAccounts, iAcc,
-            Length(Model.SelectedAccounts) - 1); // ensure signer account processed last
+          TArrayTool<TAccount>.Swap(Model.ChangeAccountPrivateKeyModel.SelectedAccounts, iAcc,
+            Length(Model.ChangeAccountPrivateKeyModel.SelectedAccounts) - 1); // ensure signer account processed last
           // TArrayTool_internal<Cardinal>.Swap(_senderAccounts, iAcc, Length(_senderAccounts) - 1);
           goto loop_start; // TODO: remove ugly hack with refactoring!
         end;
@@ -333,13 +314,13 @@ begin
         if uint64(_totalSignerFee) >= signerAccount.balance then
           _fee := 0
         else if signerAccount.balance - uint64(_totalSignerFee) >
-          uint64(Model.DefaultFee) then
-          _fee := Model.DefaultFee
+          uint64(Model.ChangeAccountPrivateKeyModel.DefaultFee) then
+          _fee := Model.ChangeAccountPrivateKeyModel.DefaultFee
         else
           _fee := signerAccount.balance - uint64(_totalSignerFee);
         op := TOpChangeKeySigned.Create(signerAccount.account,
           signerAccount.n_operation + _signer_n_ops + 1, account.account,
-          wk.PrivateKey, _newOwnerPublicKey, _fee, Model.EncodedPayload);
+          wk.PrivateKey, _newOwnerPublicKey, _fee, Model.ChangeAccountPrivateKeyModel.EncodedPayload);
         Inc(_signer_n_ops);
         Inc(_totalSignerFee, _fee);
       end
@@ -347,7 +328,7 @@ begin
       begin
         op := TOpChangeKey.Create(account.account, account.n_operation +
           1, account.account, wk.PrivateKey, _newOwnerPublicKey, _fee,
-          Model.EncodedPayload);
+          Model.ChangeAccountPrivateKeyModel.EncodedPayload);
       end;
       Inc(_totalfee, _fee);
       operationstxt :=
@@ -367,11 +348,11 @@ begin
     if (ops.OperationsCount = 0) then
       raise Exception.Create('No valid operation to execute');
 
-    if (Length(Model.SelectedAccounts) > 1) then
+    if (Length(Model.ChangeAccountPrivateKeyModel.SelectedAccounts) > 1) then
     begin
       auxs := '';
       if Application.MessageBox(
-        PChar('Execute ' + IntToStr(Length(Model.SelectedAccounts)) +
+        PChar('Execute ' + IntToStr(Length(Model.ChangeAccountPrivateKeyModel.SelectedAccounts)) +
         ' operations?' + #10 + 'Operation: ' + operationstxt + #10 +
         auxs + 'Total fee: ' + TAccountComp.FormatMoney(_totalfee) +
         #10 + #10 + 'Note: This operation will be transmitted to the network!'),

+ 1 - 1
src/gui/wizards/UWIZChangeAccountPrivateKey_Confirmation.lfm

@@ -6,7 +6,7 @@ object WIZChangeAccountPrivateKey_Confirmation: TWIZChangeAccountPrivateKey_Conf
   Caption = 'WIZChangeAccountPrivateKey_Confirmation'
   ClientHeight = 253
   ClientWidth = 429
-  LCLVersion = '1.8.1.0'
+  LCLVersion = '1.8.2.0'
   Visible = False
   object GroupBox1: TGroupBox
     Left = 10

+ 6 - 8
src/gui/wizards/UWIZChangeAccountPrivateKey_Confirmation.pas

@@ -14,14 +14,13 @@ interface
 uses
   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
   ExtCtrls, UVisualGrid, UCellRenderers, UCommon.Data, UWizard,
-  UWIZChangeAccountPrivateKey;
+  UWIZChangeAccountPrivateKey, UWIZModels;
 
 type
 
   { TWIZChangeAccountPrivateKey_Confirmation }
 
-  TWIZChangeAccountPrivateKey_Confirmation =
-    class(TWizardForm<TWIZChangeAccountPrivateKeyModel>)
+  TWIZChangeAccountPrivateKey_Confirmation = class(TWizardForm<TWIZOperationsModel>)
     GroupBox1: TGroupBox;
     Label1: TLabel;
     lblSgnAcc: TLabel;
@@ -45,11 +44,11 @@ type
 
   TAccountSenderDataSource = class(TAccountsDataSourceBase)
   private
-    FModel: TWIZChangeAccountPrivateKeyModel;
+    FModel: TWIZOperationsModel.TChangeAccountPrivateKeyModel;
   protected
     function GetColumns: TDataColumns; override;
   public
-    property Model: TWIZChangeAccountPrivateKeyModel read FModel write FModel;
+    property Model: TWIZOperationsModel.TChangeAccountPrivateKeyModel read FModel write FModel;
     procedure FetchAll(const AContainer: TList<TAccount>); override;
     function GetItemField(constref AItem: TAccount;
       const ABindingName: ansistring): variant; override;
@@ -90,11 +89,10 @@ begin
   end;
 
   Data := TAccountSenderDataSource.Create(FSendersGrid);
-  Data.Model := Model;
+  Data.Model := Model.ChangeAccountPrivateKeyModel;
   FSendersGrid.DataSource := Data;
   paGrid.AddControlDockCenter(FSendersGrid);
-  lblSgnAcc.Caption := TAccountComp.AccountNumberToAccountTxtNumber(
-    Model.SignerAccount.account);
+  lblSgnAcc.Caption := TAccountComp.AccountNumberToAccountTxtNumber(Model.ChangeAccountPrivateKeyModel.SignerAccount.account);
 end;
 
 { TAccountSenderDataSource }

+ 1 - 0
src/gui/wizards/UWIZChangeAccountPrivateKey_Start.lfm

@@ -6,6 +6,7 @@ object WIZChangeAccountPrivateKey_Start: TWIZChangeAccountPrivateKey_Start
   Caption = 'WIZChangeAccountPrivateKey_Start'
   ClientHeight = 253
   ClientWidth = 429
+  LCLVersion = '1.8.2.0'
   Visible = False
   object grpSelectedAccount: TGroupBox
     Left = 6

+ 5 - 5
src/gui/wizards/UWIZChangeAccountPrivateKey_Start.pas

@@ -14,13 +14,13 @@ interface
 uses
   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
   ExtCtrls, UVisualGrid, UCommon.Data, UCellRenderers,
-  UWizard, UWIZChangeAccountPrivateKey, UWIZChangeAccountPrivateKey_Transaction, UWIZChangeAccountPrivateKey_Confirmation;
+  UWizard, UWIZChangeAccountPrivateKey, UWIZChangeAccountPrivateKey_Transaction, UWIZChangeAccountPrivateKey_Confirmation, UWIZModels;
 
 type
 
   { TWIZChangeAccountPrivateKey_Start }
 
-  TWIZChangeAccountPrivateKey_Start = class(TWizardForm<TWIZChangeAccountPrivateKeyModel>)
+  TWIZChangeAccountPrivateKey_Start = class(TWizardForm<TWIZOperationsModel>)
     grpSelectedAccount: TGroupBox;
     paGrid: TPanel;
   private
@@ -44,9 +44,9 @@ type
 
   TAccountSenderDataSource = class(TAccountsDataSourceBase)
   private
-    FModel: TWIZChangeAccountPrivateKeyModel;
+    FModel: TWIZOperationsModel.TChangeAccountPrivateKeyModel;
   public
-    property Model: TWIZChangeAccountPrivateKeyModel read FModel write FModel;
+    property Model: TWIZOperationsModel.TChangeAccountPrivateKeyModel read FModel write FModel;
     procedure FetchAll(const AContainer: TList<TAccount>); override;
   end;
 
@@ -97,7 +97,7 @@ begin
     Filters := SORTABLE_NUMERIC_FILTER;
   end;
   Data := TAccountSenderDataSource.Create(FSendersGrid);
-  Data.Model := Model;
+  Data.Model := Model.ChangeAccountPrivateKeyModel;
   FSendersGrid.DataSource := Data;
   paGrid.AddControlDockCenter(FSendersGrid);
 end;

+ 1 - 0
src/gui/wizards/UWIZChangeAccountPrivateKey_Transaction.lfm

@@ -7,6 +7,7 @@ object WIZChangeAccountPrivateKey_Transaction: TWIZChangeAccountPrivateKey_Trans
   Caption = 'WIZChangeAccountPrivateKey_Transaction'
   ClientHeight = 253
   ClientWidth = 429
+  LCLVersion = '1.8.2.0'
   Visible = False
   object gbTransaction: TGroupBox
     Left = 24

+ 15 - 21
src/gui/wizards/UWIZChangeAccountPrivateKey_Transaction.pas

@@ -16,14 +16,13 @@ uses
   ExtCtrls, Buttons, UCommon, UCommon.Collections, UWallet,
   UFRMAccountSelect, UNode, UWizard, UWIZChangeAccountPrivateKey,
   UWIZChangeAccountPrivateKey_TransactionPayload,
-  UWIZChangeAccountPrivateKey_Confirmation;
+  UWIZChangeAccountPrivateKey_Confirmation, UWIZModels;
 
 type
 
   { TWIZChangeAccountPrivateKey_Transaction }
 
-  TWIZChangeAccountPrivateKey_Transaction =
-  class(TWizardForm<TWIZChangeAccountPrivateKeyModel>)
+  TWIZChangeAccountPrivateKey_Transaction = class(TWizardForm<TWIZOperationsModel>)
     cbSignerAccount: TComboBox;
     cbNewPrivateKey: TComboBox;
     edtOpFee: TEdit;
@@ -65,8 +64,7 @@ begin
   begin
     lblBalance.Font.Color := clGreen;
     lblBalance.Caption := Format('%s PASC',
-      [TAccountComp.FormatMoney(Model.SelectedAccounts[PtrInt(
-      cbSignerAccount.Items.Objects[cbSignerAccount.ItemIndex])].Balance)]);
+      [TAccountComp.FormatMoney(Model.ChangeAccountPrivateKeyModel.SelectedAccounts[PtrInt(cbSignerAccount.Items.Objects[cbSignerAccount.ItemIndex])].Balance)]);
   end;
 end;
 
@@ -140,9 +138,9 @@ begin
   try
     cbSignerAccount.Items.Clear;
     cbSignerAccount.Items.Add('Select Signer Account');
-    for i := Low(Model.SelectedAccounts) to High(Model.SelectedAccounts) do
+    for i := Low(Model.ChangeAccountPrivateKeyModel.SelectedAccounts) to High(Model.ChangeAccountPrivateKeyModel.SelectedAccounts) do
     begin
-      acc := Model.SelectedAccounts[i];
+      acc := Model.ChangeAccountPrivateKeyModel.SelectedAccounts[i];
       accNumberwithChecksum := GetAccNoWithChecksum(acc.account);
       totalBalance := totalBalance + acc.balance;
       cbSignerAccount.Items.AddObject(accNumberwithChecksum, TObject(i));
@@ -151,9 +149,9 @@ begin
     cbSignerAccount.Items.EndUpdate;
   end;
   UpdateWalletKeys();
-  cbSignerAccount.ItemIndex := Model.SelectedIndex;
+  cbSignerAccount.ItemIndex := Model.ChangeAccountPrivateKeyModel.SelectedIndex;
   cbSignerAccountChange(Self);
-  cbNewPrivateKey.ItemIndex := Model.PrivateKeySelectedIndex;
+  cbNewPrivateKey.ItemIndex := Model.ChangeAccountPrivateKeyModel.PrivateKeySelectedIndex;
   cbNewPrivateKeyChange(Self);
   lblTotalBalanceValue.Caption :=
     Format('%s PASC', [TAccountComp.FormatMoney(totalBalance)]);
@@ -163,19 +161,15 @@ end;
 
 procedure TWIZChangeAccountPrivateKey_Transaction.OnNext;
 begin
-  Model.SelectedIndex := cbSignerAccount.ItemIndex;
-  Model.PrivateKeySelectedIndex := cbNewPrivateKey.ItemIndex;
-  Model.SignerAccount := Model.SelectedAccounts[PtrInt(
-    cbSignerAccount.Items.Objects[cbSignerAccount.ItemIndex])];
-  Model.NewWalletKey := TWallet.Keys.Key[PtrInt(
-    cbNewPrivateKey.Items.Objects[cbNewPrivateKey.ItemIndex])];
-
-  UpdatePath(ptReplaceAllNext, [TWIZChangeAccountPrivateKey_TransactionPayload,
-    TWIZChangeAccountPrivateKey_Confirmation]);
+  Model.ChangeAccountPrivateKeyModel.SelectedIndex := cbSignerAccount.ItemIndex;
+  Model.ChangeAccountPrivateKeyModel.PrivateKeySelectedIndex := cbNewPrivateKey.ItemIndex;
+  Model.ChangeAccountPrivateKeyModel.SignerAccount := Model.ChangeAccountPrivateKeyModel.SelectedAccounts[PtrInt(cbSignerAccount.Items.Objects[cbSignerAccount.ItemIndex])];
+  Model.ChangeAccountPrivateKeyModel.NewWalletKey := TWallet.Keys.Key[PtrInt(cbNewPrivateKey.Items.Objects[cbNewPrivateKey.ItemIndex])];
+
+  UpdatePath(ptReplaceAllNext, [TWIZChangeAccountPrivateKey_TransactionPayload, TWIZChangeAccountPrivateKey_Confirmation]);
 end;
 
-function TWIZChangeAccountPrivateKey_Transaction.Validate(
-  out message: ansistring): boolean;
+function TWIZChangeAccountPrivateKey_Transaction.Validate(out message: ansistring): boolean;
 var
   i: integer;
 begin
@@ -193,7 +187,7 @@ begin
     Exit;
   end;
 
-  if not TAccountComp.TxtToMoney(Trim(edtOpFee.Text), Model.DefaultFee) then
+  if not TAccountComp.TxtToMoney(Trim(edtOpFee.Text), Model.ChangeAccountPrivateKeyModel.DefaultFee) then
   begin
     message := 'Invalid fee value "' + edtOpFee.Text + '"';
     Result := False;

+ 1 - 1
src/gui/wizards/UWIZChangeAccountPrivateKey_TransactionPayload.lfm

@@ -7,7 +7,7 @@ object WIZChangeAccountPrivateKey_TransactionPayload: TWIZChangeAccountPrivateKe
   Caption = 'Form1'
   ClientHeight = 253
   ClientWidth = 429
-  LCLVersion = '1.8.1.0'
+  LCLVersion = '1.8.2.0'
   Visible = False
   object grpPayload: TGroupBox
     Left = 8

+ 7 - 7
src/gui/wizards/UWIZChangeAccountPrivateKey_TransactionPayload.pas

@@ -14,13 +14,13 @@ interface
 uses
   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
   ExtCtrls, Buttons, UCommon, UCommon.Collections,
-  UWizard, UWIZChangeAccountPrivateKey;
+  UWizard, UWIZChangeAccountPrivateKey, UWIZModels;
 
 type
 
   { TWIZChangeAccountPrivateKey_TransactionPayload }
 
-  TWIZChangeAccountPrivateKey_TransactionPayload = class(TWizardForm<TWIZChangeAccountPrivateKeyModel>)
+  TWIZChangeAccountPrivateKey_TransactionPayload = class(TWizardForm<TWIZOperationsModel>)
     edtPassword: TEdit;
     grpPayload: TGroupBox;
     Label1: TLabel;
@@ -48,25 +48,25 @@ uses
 
 procedure TWIZChangeAccountPrivateKey_TransactionPayload.OnNext;
 begin
-  Model.Payload := mmoPayload.Lines.Text;
+  Model.ChangeAccountPrivateKeyModel.Payload := mmoPayload.Lines.Text;
   if rbEncryptedWithOldEC.Checked then
   begin
-    Model.PayloadEncryptionMode := akaEncryptWithOldEC;
+    Model.ChangeAccountPrivateKeyModel.PayloadEncryptionMode := akaEncryptWithOldEC;
   end
   else
   if rbEncryptedWithEC.Checked then
   begin
-    Model.PayloadEncryptionMode := akaEncryptWithEC;
+    Model.ChangeAccountPrivateKeyModel.PayloadEncryptionMode := akaEncryptWithEC;
   end
   else
   if rbEncryptedWithPassword.Checked then
   begin
-    Model.PayloadEncryptionMode := akaEncryptWithPassword;
+    Model.ChangeAccountPrivateKeyModel.PayloadEncryptionMode := akaEncryptWithPassword;
   end
   else
   if rbNotEncrypted.Checked then
   begin
-    Model.PayloadEncryptionMode := akaNotEncrypt;
+    Model.ChangeAccountPrivateKeyModel.PayloadEncryptionMode := akaNotEncrypt;
   end;
 end;
 

+ 108 - 0
src/gui/wizards/UWIZModels.pas

@@ -0,0 +1,108 @@
+unit UWIZModels;
+
+
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+
+interface
+
+uses Classes, SysUtils, UWizard, UAccounts, UBlockChain, UWallet, UBaseTypes, Generics.Defaults;
+
+type
+
+  { TWIZAddKeyAction }
+
+  TWIZAddKeyAction = (akaGenerateKey, akaImportPrivateKey, akaImportPublicKey);
+
+  { TFRMAddKeyModel }
+
+  TWIZAddKeyModel = class(TComponent)
+    public
+      Name : String;
+      KeyText : String;
+      Password : String;
+      EncryptionTypeNID : word;
+      Action : TWIZAddKeyAction;
+  end;
+
+  { TWIZOperationsModel }
+
+  TWIZOperationsModel = class (TComponent)
+    public type
+
+       { TModelType }
+
+       TModelType = (omtSendPasc, omtTransferAccount, omtChangeAccountPrivateKey, omtAddKey);
+
+       { TPayloadEncryptionMode }
+
+       TPayloadEncryptionMode = (akaEncryptWithOldEC, akaEncryptWithEC, akaEncryptWithPassword, akaNotEncrypt);
+
+       { TSendPASCModel }
+
+       TSendPASCModel = class(TComponent)
+       public
+         SelectedIndex: integer;
+         DefaultFee: int64;
+         AmountToSend, Payload, EncryptionPassword: string;
+         EncodedPayload: TRawBytes;
+         SignerAccount, DestinationAccount: TAccount;
+         SelectedAccounts: TArray<TAccount>;
+         PayloadEncryptionMode: TPayloadEncryptionMode;
+       end;
+
+       { TTransferAccountModel }
+
+       TTransferAccountModel = class(TComponent)
+       public
+         DefaultFee: int64;
+         NewPublicKey, Payload, EncryptionPassword: string;
+         SelectedIndex: integer;
+         AccountKey: TAccountKey;
+         EncodedPayload: TRawBytes;
+         SignerAccount: TAccount;
+         SelectedAccounts: TArray<TAccount>;
+         PayloadEncryptionMode: TPayloadEncryptionMode;
+       end;
+
+       { TChangeAccountPrivateKeyModel }
+
+       TChangeAccountPrivateKeyModel = class(TComponent)
+       public
+         DefaultFee: int64;
+         NewPublicKey, Payload, EncryptionPassword: string;
+         SelectedIndex, PrivateKeySelectedIndex: integer;
+         NewWalletKey: TWalletKey;
+         EncodedPayload: TRawBytes;
+         SignerAccount: TAccount;
+         SelectedAccounts: TArray<TAccount>;
+         PayloadEncryptionMode: TPayloadEncryptionMode;
+       end;
+
+    private
+      FModelType : TModelType;
+      FSendModel : TSendPASCModel;
+      FTransferAccountModel : TTransferAccountModel;
+      FChangeAccountPrivateKeyModel : TChangeAccountPrivateKeyModel;
+    public
+      constructor Create(AOwner : TComponent; AType : TModelType);  overload;
+      property ModelType : TModelType read FModelType;
+      property SendPASCModel : TSendPASCModel read FSendModel;
+      property TransferAccountModel : TTransferAccountModel read FTransferAccountModel;
+      property ChangeAccountPrivateKeyModel : TChangeAccountPrivateKeyModel read FChangeAccountPrivateKeyModel;
+  end;
+
+implementation
+
+constructor TWIZOperationsModel.Create(AOwner : TComponent; AType : TWIZOperationsModel.TModelType);
+begin
+  inherited Create(AOwner);
+  FModelType := AType;
+  FSendModel := TSendPASCModel.Create(Self);
+  FTransferAccountModel := TTransferAccountModel.Create(Self);
+  FChangeAccountPrivateKeyModel := TChangeAccountPrivateKeyModel.Create(Self);
+end;
+
+end.
+

+ 37 - 62
src/gui/wizards/UWIZSendPASC.pas

@@ -14,34 +14,17 @@ unit UWIZSendPASC;
 interface
 
 uses
-  Classes, SysUtils, Forms, Dialogs, UCrypto, UWizard, UAccounts, LCLType;
+  Classes, SysUtils, Forms, Dialogs, UCrypto, UWizard, UAccounts, LCLType, UWIZModels;
 
 type
 
-  { TWIZSendPASCModel }
-  TWIZPayloadEncryptionMode = (akaEncryptWithOldEC, akaEncryptWithEC,
-    akaEncryptWithPassword, akaNotEncrypt);
-
-  TWIZSendPASCModel = class(TComponent)
-  public
-    SelectedIndex: integer;
-    DefaultFee: int64;
-    AmountToSend, Payload, EncryptionPassword: string;
-    EncodedPayload: TRawBytes;
-    SignerAccount, DestinationAccount: TAccount;
-    SelectedAccounts: TArray<TAccount>;
-    PayloadEncryptionMode: TWIZPayloadEncryptionMode;
-  end;
-
   { TWIZSendPASCWizard }
 
-  TWIZSendPASCWizard = class(TWizard<TWIZSendPASCModel>)
+  TWIZSendPASCWizard = class(TWizard<TWIZOperationsModel>)
   private
-    function UpdatePayload(const SenderAccount: TAccount;
-      var errors: string): boolean;
+    function UpdatePayload(const SenderAccount: TAccount; var errors: string): boolean;
     function UpdateOperationOptions(var errors: string): boolean;
-    function UpdateOpTransaction(const SenderAccount: TAccount;
-      var DestAccount: TAccount; var amount: int64; var errors: string): boolean;
+    function UpdateOpTransaction(const SenderAccount: TAccount; var DestAccount: TAccount; var amount: int64; var errors: string): boolean;
     procedure SendPASC();
   public
     constructor Create(AOwner: TComponent); override;
@@ -82,7 +65,7 @@ begin
     Exit;
   end;
 
-  if Length(Model.SelectedAccounts) = 0 then
+  if Length(Model.SendPASCModel.SelectedAccounts) = 0 then
   begin
     errors := 'No sender account';
     Exit;
@@ -90,15 +73,13 @@ begin
   else
   begin
 
-    for iAcc := Low(Model.SelectedAccounts) to High(Model.SelectedAccounts) do
+    for iAcc := Low(Model.SendPASCModel.SelectedAccounts) to High(Model.SendPASCModel.SelectedAccounts) do
     begin
-      sender_account := Model.SelectedAccounts[iAcc];
+      sender_account := Model.SendPASCModel.SelectedAccounts[iAcc];
       iWallet := TWallet.Keys.IndexOfAccountKey(sender_account.accountInfo.accountKey);
       if (iWallet < 0) then
       begin
-        errors := 'Private key of account ' +
-          TAccountComp.AccountNumberToAccountTxtNumber(sender_account.account) +
-          ' not found in wallet';
+        errors := 'Private key of account ' + TAccountComp.AccountNumberToAccountTxtNumber(sender_account.account) + ' not found in wallet';
         Exit;
       end;
       wk := TWallet.Keys.Key[iWallet];
@@ -112,33 +93,31 @@ begin
         else
         begin
           errors := 'Only public key of account ' +
-            TAccountComp.AccountNumberToAccountTxtNumber(sender_account.account) +
-            ' found in wallet. You cannot operate with this account';
+            TAccountComp.AccountNumberToAccountTxtNumber(sender_account.account) + ' found in wallet. You cannot operate with this account';
         end;
         Exit;
       end;
     end;
   end;
 
-  Result := UpdateOpTransaction(Model.SelectedAccounts[0], dest_account, amount, errors);
+  Result := UpdateOpTransaction(Model.SendPASCModel.SelectedAccounts[0], dest_account, amount, errors);
   UpdatePayload(sender_account, e);
 end;
 
-function TWIZSendPASCWizard.UpdateOpTransaction(const SenderAccount: TAccount;
-  var DestAccount: TAccount; var amount: int64; var errors: string): boolean;
+function TWIZSendPASCWizard.UpdateOpTransaction(const SenderAccount: TAccount; var DestAccount: TAccount; var amount: int64; var errors: string): boolean;
 var
   c: cardinal;
 begin
   Result := False;
   errors := '';
 
-  DestAccount := Model.DestinationAccount;
+  DestAccount := Model.SendPASCModel.DestinationAccount;
 
-  if Length(Model.SelectedAccounts) = 1 then
+  if Length(Model.SendPASCModel.SelectedAccounts) = 1 then
   begin
-    if not TAccountComp.TxtToMoney(Model.AmountToSend, amount) then
+    if not TAccountComp.TxtToMoney(Model.SendPASCModel.AmountToSend, amount) then
     begin
-      errors := 'Invalid amount (' + Model.AmountToSend + ')';
+      errors := 'Invalid amount (' + Model.SendPASCModel.AmountToSend + ')';
       Exit;
     end;
   end
@@ -153,9 +132,9 @@ begin
     Exit;
   end;
 
-  if (Length(Model.SelectedAccounts) = 1) then
+  if (Length(Model.SendPASCModel.SelectedAccounts) = 1) then
   begin
-    if (SenderAccount.balance < (amount + Model.DefaultFee)) then
+    if (SenderAccount.balance < (amount + Model.SendPASCModel.DefaultFee)) then
     begin
       errors := 'Insufficient funds';
       Exit;
@@ -189,10 +168,10 @@ begin
     _signer_n_ops := 0;
     operationstxt := '';
     operation_to_string := '';
-    for iAcc := Low(Model.SelectedAccounts) to High(Model.SelectedAccounts) do
+    for iAcc := Low(Model.SendPASCModel.SelectedAccounts) to High(Model.SendPASCModel.SelectedAccounts) do
     begin
       op := nil;
-      account := Model.SelectedAccounts[iAcc];
+      account := Model.SendPASCModel.SelectedAccounts[iAcc];
       if not UpdatePayload(account, errors) then
       begin
         raise Exception.Create('Error encoding payload of sender account ' +
@@ -207,21 +186,21 @@ begin
       wk := TWallet.Keys.Key[i];
       dooperation := True;
       // Default fee
-      if account.balance > uint64(Model.DefaultFee) then
-        _fee := Model.DefaultFee
+      if account.balance > uint64(Model.SendPASCModel.DefaultFee) then
+        _fee := Model.SendPASCModel.DefaultFee
       else
         _fee := account.balance;
 
       if not UpdateOpTransaction(account, destAccount, _amount, errors) then
         raise Exception.Create(errors);
-      if Length(Model.SelectedAccounts) > 1 then
+      if Length(Model.SendPASCModel.SelectedAccounts) > 1 then
       begin
         if account.balance > 0 then
         begin
-          if account.balance > Model.DefaultFee then
+          if account.balance > Model.SendPASCModel.DefaultFee then
           begin
-            _amount := account.balance - Model.DefaultFee;
-            _fee := Model.DefaultFee;
+            _amount := account.balance - Model.SendPASCModel.DefaultFee;
+            _fee := Model.SendPASCModel.DefaultFee;
           end
           else
           begin
@@ -239,12 +218,11 @@ begin
       begin
         op := TOpTransaction.CreateTransaction(
           account.account, account.n_operation + 1, destAccount.account,
-          wk.PrivateKey, _amount, _fee, Model.EncodedPayload);
+          wk.PrivateKey, _amount, _fee, Model.SendPASCModel.EncodedPayload);
         Inc(_totalamount, _amount);
         Inc(_totalfee, _fee);
       end;
-      operationstxt := 'Transaction to ' + TAccountComp.AccountNumberToAccountTxtNumber(
-        destAccount.account);
+      operationstxt := 'Transaction to ' + TAccountComp.AccountNumberToAccountTxtNumber(destAccount.account);
 
       if Assigned(op) and (dooperation) then
       begin
@@ -259,12 +237,11 @@ begin
     if (ops.OperationsCount = 0) then
       raise Exception.Create('No valid operation to execute');
 
-    if (Length(Model.SelectedAccounts) > 1) then
+    if (Length(Model.SendPASCModel.SelectedAccounts) > 1) then
     begin
-      auxs := 'Total amount that dest will receive: ' + TAccountComp.FormatMoney(
-        _totalamount) + #10;
+      auxs := 'Total amount that dest will receive: ' + TAccountComp.FormatMoney(_totalamount) + #10;
       if Application.MessageBox(
-        PChar('Execute ' + IntToStr(Length(Model.SelectedAccounts)) +
+        PChar('Execute ' + IntToStr(Length(Model.SendPASCModel.SelectedAccounts)) +
         ' operations?' + #10 + 'Operation: ' + operationstxt + #10 +
         auxs + 'Total fee: ' + TAccountComp.FormatMoney(_totalfee) +
         #10 + #10 + 'Note: This operation will be transmitted to the network!'),
@@ -335,8 +312,7 @@ begin
   end;
 end;
 
-function TWIZSendPASCWizard.UpdatePayload(const SenderAccount: TAccount;
-  var errors: string): boolean;
+function TWIZSendPASCWizard.UpdatePayload(const SenderAccount: TAccount; var errors: string): boolean;
 var
   valid: boolean;
   payload_encrypted, payload_u: string;
@@ -344,9 +320,9 @@ var
 begin
   valid := False;
   payload_encrypted := '';
-  Model.EncodedPayload := '';
+  Model.SendPASCModel.EncodedPayload := '';
   errors := 'Unknown error';
-  payload_u := Model.Payload;
+  payload_u := Model.SendPASCModel.Payload;
 
   try
     if (payload_u = '') then
@@ -354,7 +330,7 @@ begin
       valid := True;
       Exit;
     end;
-    case Model.PayloadEncryptionMode of
+    case Model.SendPASCModel.PayloadEncryptionMode of
 
       akaEncryptWithOldEC:
       begin
@@ -369,15 +345,14 @@ begin
       begin
         // With dest public key
         errors := 'Error encrypting';
-        account := Model.DestinationAccount;
+        account := Model.SendPASCModel.DestinationAccount;
         payload_encrypted := ECIESEncrypt(account.accountInfo.accountKey, payload_u);
         valid := payload_encrypted <> '';
       end;
 
       akaEncryptWithPassword:
       begin
-        payload_encrypted := TAESComp.EVP_Encrypt_AES256(
-          payload_u, Model.EncryptionPassword);
+        payload_encrypted := TAESComp.EVP_Encrypt_AES256(payload_u, Model.SendPASCModel.EncryptionPassword);
         valid := payload_encrypted <> '';
       end;
 
@@ -404,7 +379,7 @@ begin
       end;
 
     end;
-    Model.EncodedPayload := payload_encrypted;
+    Model.SendPASCModel.EncodedPayload := payload_encrypted;
     Result := valid;
   end;
 

+ 1 - 0
src/gui/wizards/UWIZSendPASC_Confirmation.lfm

@@ -6,6 +6,7 @@ object WIZSendPASC_Confirmation: TWIZSendPASC_Confirmation
   Caption = 'WIZSendPASC_Confirmation'
   ClientHeight = 253
   ClientWidth = 429
+  LCLVersion = '1.8.2.0'
   Visible = False
   object GroupBox1: TGroupBox
     Left = 10

+ 7 - 7
src/gui/wizards/UWIZSendPASC_Confirmation.pas

@@ -13,13 +13,13 @@ interface
 
 uses
   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
-  ExtCtrls, UVisualGrid, UCellRenderers, UCommon.Data, UWizard, UWIZSendPASC;
+  ExtCtrls, UVisualGrid, UCellRenderers, UCommon.Data, UWizard, UWIZSendPASC, UWIZModels;
 
 type
 
   { TWIZSendPASC_Confirmation }
 
-  TWIZSendPASC_Confirmation = class(TWizardForm<TWIZSendPASCModel>)
+  TWIZSendPASC_Confirmation = class(TWizardForm<TWIZOperationsModel>)
     GroupBox1: TGroupBox;
     Label1: TLabel;
     Label2: TLabel;
@@ -45,11 +45,11 @@ type
 
   TAccountSenderDataSource = class(TAccountsDataSourceBase)
     private
-      FModel : TWIZSendPASCModel;
+      FModel : TWIZOperationsModel.TSendPASCModel;
     protected
       function GetColumns : TDataColumns; override;
     public
-      property Model : TWIZSendPASCModel read FModel write FModel;
+      property Model : TWIZOperationsModel.TSendPASCModel read FModel write FModel;
       procedure FetchAll(const AContainer : TList<TAccount>); override;
       function GetItemField(constref AItem: TAccount; const ABindingName : AnsiString) : Variant; override;
   end;
@@ -90,11 +90,11 @@ begin
   end;
 
    data := TAccountSenderDataSource.Create(FSendersGrid);
-   data.Model := Model;
+   data.Model := Model.SendPASCModel;
    FSendersGrid.DataSource := data;
    paGrid.AddControlDockCenter(FSendersGrid);
-   lblSgnAcc.Caption := TAccountComp.AccountNumberToAccountTxtNumber(Model.SignerAccount.account);
-   lblDestAcc.Caption := TAccountComp.AccountNumberToAccountTxtNumber(Model.DestinationAccount.account);
+   lblSgnAcc.Caption := TAccountComp.AccountNumberToAccountTxtNumber(Model.SendPASCModel.SignerAccount.account);
+   lblDestAcc.Caption := TAccountComp.AccountNumberToAccountTxtNumber(Model.SendPASCModel.DestinationAccount.account);
 end;
 
 { TAccountSenderDataSource }

+ 1 - 0
src/gui/wizards/UWIZSendPASC_Start.lfm

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

+ 5 - 5
src/gui/wizards/UWIZSendPASC_Start.pas

@@ -17,13 +17,13 @@ interface
 uses
   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
   ExtCtrls, UVisualGrid, UCommon.Data, UCellRenderers,
-  UWizard, UWIZSendPASC, UWIZSendPASC_Transaction, UWIZSendPASC_Confirmation;
+  UWizard, UWIZSendPASC, UWIZSendPASC_Transaction, UWIZSendPASC_Confirmation, UWIZModels;
 
 type
 
   { TWIZSendPASC_Start }
 
-  TWIZSendPASC_Start = class(TWizardForm<TWIZSendPASCModel>)
+  TWIZSendPASC_Start = class(TWizardForm<TWIZOperationsModel>)
     gpSender: TGroupBox;
     paGrid: TPanel;
   private
@@ -47,9 +47,9 @@ type
 
   TAccountSenderDataSource = class(TAccountsDataSourceBase)
     private
-      FModel : TWIZSendPASCModel;
+      FModel : TWIZOperationsModel.TSendPASCModel;
     public
-      property Model : TWIZSendPASCModel read FModel write FModel;
+      property Model : TWIZOperationsModel.TSendPASCModel read FModel write FModel;
       procedure FetchAll(const AContainer : TList<TAccount>); override;
   end;
 
@@ -87,7 +87,7 @@ begin
     Filters:=SORTABLE_NUMERIC_FILTER;
   end;
   data := TAccountSenderDataSource.Create(FSendersGrid);
-  data.Model := Model;
+  data.Model := Model.SendPASCModel;
   FSendersGrid.DataSource := data;
   paGrid.AddControlDockCenter(FSendersGrid);
 end;

+ 1 - 0
src/gui/wizards/UWIZSendPASC_Transaction.lfm

@@ -7,6 +7,7 @@ object WIZSendPASC_Transaction: TWIZSendPASC_Transaction
   Caption = 'WIZSendPASC_Transaction'
   ClientHeight = 253
   ClientWidth = 429
+  LCLVersion = '1.8.2.0'
   Visible = False
   object gbTransaction: TGroupBox
     Left = 22

+ 14 - 15
src/gui/wizards/UWIZSendPASC_Transaction.pas

@@ -14,13 +14,13 @@ interface
 uses
   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
   ExtCtrls, Buttons, UCommon, UCommon.Collections, UWallet,
-  UFRMAccountSelect, UNode, UWizard, UWIZSendPASC, UWIZSendPASC_Confirmation, UWIZSendPASC_TransactionPayload;
+  UFRMAccountSelect, UNode, UWizard, UWIZSendPASC, UWIZSendPASC_Confirmation, UWIZSendPASC_TransactionPayload, UWIZModels;
 
 type
 
   { TWIZSendPASC_Transaction }
 
-  TWIZSendPASC_Transaction = class(TWizardForm<TWIZSendPASCModel>)
+  TWIZSendPASC_Transaction = class(TWizardForm<TWIZOperationsModel>)
     cbSignerAccount: TComboBox;
     edtOpFee: TEdit;
     edtAmt: TEdit;
@@ -63,7 +63,7 @@ begin
   begin
     lblBalance.Font.Color := clGreen;
     lblBalance.Caption := Format('%s PASC',
-      [TAccountComp.FormatMoney(Model.SelectedAccounts[PtrInt(
+      [TAccountComp.FormatMoney(Model.SendPASCModel.SelectedAccounts[PtrInt(
       cbSignerAccount.Items.Objects[cbSignerAccount.ItemIndex])].Balance)]);
   end;
 end;
@@ -109,9 +109,9 @@ begin
   try
     cbSignerAccount.Items.Clear;
     cbSignerAccount.Items.Add('Select Signer Account');
-    for i := 0 to High(Model.SelectedAccounts) do
+    for i := 0 to High(Model.SendPASCModel.SelectedAccounts) do
     begin
-      acc := Model.SelectedAccounts[i];
+      acc := Model.SendPASCModel.SelectedAccounts[i];
       accNumberwithChecksum := GetAccNoWithChecksum(acc.account);
       totalBalance := totalBalance + acc.balance;
       cbSignerAccount.Items.AddObject(accNumberwithChecksum, TObject(i));
@@ -119,12 +119,12 @@ begin
   finally
     cbSignerAccount.Items.EndUpdate;
   end;
-  cbSignerAccount.ItemIndex := Model.SelectedIndex;
+  cbSignerAccount.ItemIndex := Model.SendPASCModel.SelectedIndex;
   cbSignerAccountChange(Self);
   lblTotalBalanceValue.Caption :=
     Format('%s PASC', [TAccountComp.FormatMoney(totalBalance)]);
 
-  if Length(Model.SelectedAccounts) > 1 then
+  if Length(Model.SendPASCModel.SelectedAccounts) > 1 then
   begin
     edtAmt.Text := 'ALL BALANCE';
     edtAmt.Enabled := False;
@@ -170,11 +170,11 @@ procedure TWIZSendPASC_Transaction.OnNext;
   end;
 
 begin
-  Model.SelectedIndex := cbSignerAccount.ItemIndex;
-  Model.SignerAccount := Model.SelectedAccounts[PtrInt(
+  Model.SendPASCModel.SelectedIndex := cbSignerAccount.ItemIndex;
+  Model.SendPASCModel.SignerAccount := Model.SendPASCModel.SelectedAccounts[PtrInt(
     cbSignerAccount.Items.Objects[cbSignerAccount.ItemIndex])];
-  Model.DestinationAccount := GetAccounts(GetAccNoWithoutChecksum(edtDestAcc.Text));
-  Model.AmountToSend := edtAmt.Text;
+  Model.SendPASCModel.DestinationAccount := GetAccounts(GetAccNoWithoutChecksum(edtDestAcc.Text));
+  Model.SendPASCModel.AmountToSend := edtAmt.Text;
   UpdatePath(ptReplaceAllNext, [TWIZSendPASC_TransactionPayload, TWIZSendPASC_Confirmation]);
 end;
 
@@ -193,7 +193,7 @@ var
   amount, opfee: int64;
   i: integer;
 begin
-  Accounts := Model.SelectedAccounts;
+  Accounts := Model.SendPASCModel.SelectedAccounts;
   Result := True;
   if cbSignerAccount.ItemIndex < 1 then
   begin
@@ -228,8 +228,7 @@ begin
     end;
   end;
 
-  AccountNumbersWithChecksum :=
-    TListTool<TAccount, string>.Transform(Accounts, GetAccNoWithCheckSum);
+  AccountNumbersWithChecksum := TListTool<TAccount, string>.Transform(Accounts, GetAccNoWithCheckSum);
 
   if TArrayTool<string>.Contains(AccountNumbersWithChecksum, edtDestAcc.Text) then
   begin
@@ -238,7 +237,7 @@ begin
     Exit;
   end;
 
-  if not TAccountComp.TxtToMoney(Trim(edtOpFee.Text), Model.DefaultFee) then
+  if not TAccountComp.TxtToMoney(Trim(edtOpFee.Text), Model.SendPASCModel.DefaultFee) then
   begin
     message := 'Invalid fee value "' + edtOpFee.Text + '"';
     Result := False;

+ 1 - 0
src/gui/wizards/UWIZSendPASC_TransactionPayload.lfm

@@ -7,6 +7,7 @@ object WIZSendPASC_TransactionPayload: TWIZSendPASC_TransactionPayload
   Caption = 'Form1'
   ClientHeight = 253
   ClientWidth = 429
+  LCLVersion = '1.8.2.0'
   Visible = False
   object grpPayload: TGroupBox
     Left = 8

+ 7 - 7
src/gui/wizards/UWIZSendPASC_TransactionPayload.pas

@@ -14,13 +14,13 @@ interface
 uses
   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
   ExtCtrls, Buttons, UCommon, UCommon.Collections,
-  UWizard, UWIZSendPASC;
+  UWizard, UWIZSendPASC, UWIZModels;
 
 type
 
   { TWIZSendPASC_TransactionPayload }
 
-  TWIZSendPASC_TransactionPayload = class(TWizardForm<TWIZSendPASCModel>)
+  TWIZSendPASC_TransactionPayload = class(TWizardForm<TWIZOperationsModel>)
     edtPassword: TEdit;
     grpPayload: TGroupBox;
     Label1: TLabel;
@@ -48,25 +48,25 @@ uses
 
 procedure TWIZSendPASC_TransactionPayload.OnNext;
 begin
-  Model.Payload := mmoPayload.Lines.Text;
+  Model.SendPASCModel.Payload := mmoPayload.Lines.Text;
   if rbEncryptedWithOldEC.Checked then
   begin
-    Model.PayloadEncryptionMode := akaEncryptWithOldEC;
+    Model.SendPASCModel.PayloadEncryptionMode := akaEncryptWithOldEC;
   end
   else
   if rbEncryptedWithEC.Checked then
   begin
-    Model.PayloadEncryptionMode := akaEncryptWithEC;
+    Model.SendPASCModel.PayloadEncryptionMode := akaEncryptWithEC;
   end
   else
   if rbEncryptedWithPassword.Checked then
   begin
-    Model.PayloadEncryptionMode := akaEncryptWithPassword;
+    Model.SendPASCModel.PayloadEncryptionMode := akaEncryptWithPassword;
   end
   else
   if rbNotEncrypted.Checked then
   begin
-    Model.PayloadEncryptionMode := akaNotEncrypt;
+    Model.SendPASCModel.PayloadEncryptionMode := akaNotEncrypt;
   end;
 end;
 

+ 31 - 51
src/gui/wizards/UWIZTransferAccount.pas

@@ -12,36 +12,17 @@ unit UWIZTransferAccount;
 interface
 
 uses
-  Classes, SysUtils, Forms, Dialogs, UCrypto, UCommon, UWizard, UAccounts, LCLType;
+  Classes, SysUtils, Forms, Dialogs, UCrypto, UCommon, UWizard, UAccounts, LCLType, UWIZModels;
 
 type
 
-  { TWIZTransferAccountModel }
-  TWIZPayloadEncryptionMode = (akaEncryptWithOldEC, akaEncryptWithEC,
-    akaEncryptWithPassword, akaNotEncrypt);
-
-  TWIZTransferAccountModel = class(TComponent)
-  public
-    DefaultFee: int64;
-    NewPublicKey, Payload, EncryptionPassword: string;
-    SelectedIndex: integer;
-    AccountKey: TAccountKey;
-    EncodedPayload: TRawBytes;
-    SignerAccount: TAccount;
-    SelectedAccounts: TArray<TAccount>;
-    PayloadEncryptionMode: TWIZPayloadEncryptionMode;
-  end;
-
   { TWIZTransferAccountWizard }
 
-  TWIZTransferAccountWizard = class(TWizard<TWIZTransferAccountModel>)
+  TWIZTransferAccountWizard = class(TWizard<TWIZOperationsModel>)
   private
-    function UpdatePayload(const SenderAccount: TAccount;
-      var errors: string): boolean;
+    function UpdatePayload(const SenderAccount: TAccount; var errors: string): boolean;
     function UpdateOperationOptions(var errors: string): boolean;
-    function UpdateOpChangeKey(const TargetAccount: TAccount;
-      var SignerAccount: TAccount; var NewPublicKey: TAccountKey;
-      var errors: ansistring): boolean;
+    function UpdateOpChangeKey(const TargetAccount: TAccount; var SignerAccount: TAccount; var NewPublicKey: TAccountKey; var errors: ansistring): boolean;
     procedure TransferAccountOwnership();
   public
     constructor Create(AOwner: TComponent); override;
@@ -66,8 +47,7 @@ uses
 
 { TWIZTransferAccountWizard }
 
-function TWIZTransferAccountWizard.UpdatePayload(const SenderAccount: TAccount;
-  var errors: string): boolean;
+function TWIZTransferAccountWizard.UpdatePayload(const SenderAccount: TAccount; var errors: string): boolean;
 var
   valid: boolean;
   payload_encrypted, payload_u: string;
@@ -75,9 +55,9 @@ var
 begin
   valid := False;
   payload_encrypted := '';
-  Model.EncodedPayload := '';
+  Model.TransferAccountModel.EncodedPayload := '';
   errors := 'Unknown error';
-  payload_u := Model.Payload;
+  payload_u := Model.TransferAccountModel.Payload;
 
   try
     if (payload_u = '') then
@@ -85,7 +65,7 @@ begin
       valid := True;
       Exit;
     end;
-    case Model.PayloadEncryptionMode of
+    case Model.TransferAccountModel.PayloadEncryptionMode of
 
       akaEncryptWithOldEC:
       begin
@@ -100,10 +80,10 @@ begin
       begin
         errors := 'Public key: ' + 'Error encrypting';
 
-        if Model.AccountKey.EC_OpenSSL_NID <>
+        if Model.TransferAccountModel.AccountKey.EC_OpenSSL_NID <>
           CT_Account_NUL.accountInfo.accountKey.EC_OpenSSL_NID then
         begin
-          payload_encrypted := ECIESEncrypt(Model.AccountKey, payload_u);
+          payload_encrypted := ECIESEncrypt(Model.TransferAccountModel.AccountKey, payload_u);
           valid := payload_encrypted <> '';
         end
         else
@@ -117,7 +97,7 @@ begin
       akaEncryptWithPassword:
       begin
         payload_encrypted := TAESComp.EVP_Encrypt_AES256(
-          payload_u, Model.EncryptionPassword);
+          payload_u, Model.TransferAccountModel.EncryptionPassword);
         valid := payload_encrypted <> '';
       end;
 
@@ -144,7 +124,7 @@ begin
       end;
 
     end;
-    Model.EncodedPayload := payload_encrypted;
+    Model.TransferAccountModel.EncodedPayload := payload_encrypted;
     Result := valid;
   end;
 
@@ -167,7 +147,7 @@ begin
     Exit;
   end;
 
-  if Length(Model.SelectedAccounts) = 0 then
+  if Length(Model.TransferAccountModel.SelectedAccounts) = 0 then
   begin
     errors := 'No sender account';
     Exit;
@@ -175,9 +155,9 @@ begin
   else
   begin
 
-    for iAcc := Low(Model.SelectedAccounts) to High(Model.SelectedAccounts) do
+    for iAcc := Low(Model.TransferAccountModel.SelectedAccounts) to High(Model.TransferAccountModel.SelectedAccounts) do
     begin
-      sender_account := Model.SelectedAccounts[iAcc];
+      sender_account := Model.TransferAccountModel.SelectedAccounts[iAcc];
       iWallet := TWallet.Keys.IndexOfAccountKey(sender_account.accountInfo.accountKey);
       if (iWallet < 0) then
       begin
@@ -205,7 +185,7 @@ begin
     end;
   end;
 
-  Result := UpdateOpChangeKey(Model.SelectedAccounts[0], signer_account,
+  Result := UpdateOpChangeKey(Model.TransferAccountModel.SelectedAccounts[0], signer_account,
     publicKey, errors);
   UpdatePayload(sender_account, e);
 end;
@@ -217,7 +197,7 @@ begin
   Result := False;
   errors := '';
   try
-    if not TAccountComp.AccountKeyFromImport(Model.NewPublicKey,
+    if not TAccountComp.AccountKeyFromImport(Model.TransferAccountModel.NewPublicKey,
       NewPublicKey, errors) then
     begin
       Exit;
@@ -226,7 +206,7 @@ begin
     if TNode.Node.Bank.SafeBox.CurrentProtocol >= 1 then
     begin
       // Signer:
-      SignerAccount := Model.SignerAccount;
+      SignerAccount := Model.TransferAccountModel.SignerAccount;
       if (TAccountComp.IsAccountLocked(SignerAccount.accountInfo,
         TNode.Node.Bank.BlocksCount)) then
       begin
@@ -290,11 +270,11 @@ begin
     _signer_n_ops := 0;
     operationstxt := '';
     operation_to_string := '';
-    for iAcc := Low(Model.SelectedAccounts) to High(Model.SelectedAccounts) do
+    for iAcc := Low(Model.TransferAccountModel.SelectedAccounts) to High(Model.TransferAccountModel.SelectedAccounts) do
     begin
       loop_start:
         op := nil;
-      account := Model.SelectedAccounts[iAcc];
+      account := Model.TransferAccountModel.SelectedAccounts[iAcc];
       if not UpdatePayload(account, errors) then
       begin
         raise Exception.Create('Error encoding payload of sender account ' +
@@ -309,8 +289,8 @@ begin
       wk := TWallet.Keys.Key[i];
       dooperation := True;
       // Default fee
-      if account.balance > uint64(Model.DefaultFee) then
-        _fee := Model.DefaultFee
+      if account.balance > uint64(Model.TransferAccountModel.DefaultFee) then
+        _fee := Model.TransferAccountModel.DefaultFee
       else
         _fee := account.balance;
 
@@ -321,11 +301,11 @@ begin
       if _V2 then
       begin
         // must ensure is Signer account last if included in sender accounts (not necessarily ordered enumeration)
-        if (iAcc < Length(Model.SelectedAccounts) - 1) and
+        if (iAcc < Length(Model.TransferAccountModel.SelectedAccounts) - 1) and
           (account.account = signerAccount.account) then
         begin
-          TArrayTool<TAccount>.Swap(Model.SelectedAccounts, iAcc,
-            Length(Model.SelectedAccounts) - 1); // ensure signer account processed last
+          TArrayTool<TAccount>.Swap(Model.TransferAccountModel.SelectedAccounts, iAcc,
+            Length(Model.TransferAccountModel.SelectedAccounts) - 1); // ensure signer account processed last
           // TArrayTool_internal<Cardinal>.Swap(_senderAccounts, iAcc, Length(_senderAccounts) - 1);
           goto loop_start; // TODO: remove ugly hack with refactoring!
         end;
@@ -334,20 +314,20 @@ begin
         if uint64(_totalSignerFee) >= signerAccount.balance then
           _fee := 0
         else if signerAccount.balance - uint64(_totalSignerFee) >
-          uint64(Model.DefaultFee) then
-          _fee := Model.DefaultFee
+          uint64(Model.TransferAccountModel.DefaultFee) then
+          _fee := Model.TransferAccountModel.DefaultFee
         else
           _fee := signerAccount.balance - uint64(_totalSignerFee);
         op := TOpChangeKeySigned.Create(signerAccount.account,
           signerAccount.n_operation + _signer_n_ops + 1, account.account,
-          wk.PrivateKey, _newOwnerPublicKey, _fee, Model.EncodedPayload);
+          wk.PrivateKey, _newOwnerPublicKey, _fee, Model.TransferAccountModel.EncodedPayload);
         Inc(_signer_n_ops);
         Inc(_totalSignerFee, _fee);
       end
       else
       begin
         op := TOpChangeKey.Create(account.account, account.n_operation +
-          1, account.account, wk.PrivateKey, _newOwnerPublicKey, _fee, Model.EncodedPayload);
+          1, account.account, wk.PrivateKey, _newOwnerPublicKey, _fee, Model.TransferAccountModel.EncodedPayload);
       end;
       Inc(_totalfee, _fee);
       operationstxt :=
@@ -367,11 +347,11 @@ begin
     if (ops.OperationsCount = 0) then
       raise Exception.Create('No valid operation to execute');
 
-    if (Length(Model.SelectedAccounts) > 1) then
+    if (Length(Model.TransferAccountModel.SelectedAccounts) > 1) then
     begin
       auxs := '';
       if Application.MessageBox(
-        PChar('Execute ' + IntToStr(Length(Model.SelectedAccounts)) +
+        PChar('Execute ' + IntToStr(Length(Model.TransferAccountModel.SelectedAccounts)) +
         ' operations?' + #10 + 'Operation: ' + operationstxt + #10 +
         auxs + 'Total fee: ' + TAccountComp.FormatMoney(_totalfee) +
         #10 + #10 + 'Note: This operation will be transmitted to the network!'),

+ 1 - 1
src/gui/wizards/UWIZTransferAccount_Confirmation.lfm

@@ -6,7 +6,7 @@ object WIZTransferAccount_Confirmation: TWIZTransferAccount_Confirmation
   Caption = 'WIZTransferAccount_Confirmation'
   ClientHeight = 253
   ClientWidth = 429
-  LCLVersion = '1.8.1.0'
+  LCLVersion = '1.8.2.0'
   Visible = False
   object GroupBox1: TGroupBox
     Left = 10

+ 6 - 6
src/gui/wizards/UWIZTransferAccount_Confirmation.pas

@@ -13,13 +13,13 @@ interface
 
 uses
   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
-  ExtCtrls, UVisualGrid, UCellRenderers, UCommon.Data, UWizard, UWIZTransferAccount;
+  ExtCtrls, UVisualGrid, UCellRenderers, UCommon.Data, UWizard, UWIZTransferAccount, UWIZModels;
 
 type
 
   { TWIZTransferAccount_Confirmation }
 
-  TWIZTransferAccount_Confirmation = class(TWizardForm<TWIZTransferAccountModel>)
+  TWIZTransferAccount_Confirmation = class(TWizardForm<TWIZOperationsModel>)
     GroupBox1: TGroupBox;
     Label1: TLabel;
     lblSgnAcc: TLabel;
@@ -43,11 +43,11 @@ type
 
   TAccountSenderDataSource = class(TAccountsDataSourceBase)
     private
-      FModel : TWIZTransferAccountModel;
+      FModel : TWIZOperationsModel.TTransferAccountModel;
     protected
       function GetColumns : TDataColumns; override;
     public
-      property Model : TWIZTransferAccountModel read FModel write FModel;
+      property Model : TWIZOperationsModel.TTransferAccountModel read FModel write FModel;
       procedure FetchAll(const AContainer : TList<TAccount>); override;
       function GetItemField(constref AItem: TAccount; const ABindingName : AnsiString) : Variant; override;
   end;
@@ -88,10 +88,10 @@ begin
   end;
 
    data := TAccountSenderDataSource.Create(FSendersGrid);
-   data.Model := Model;
+   data.Model := Model.TransferAccountModel;
    FSendersGrid.DataSource := data;
    paGrid.AddControlDockCenter(FSendersGrid);
-   lblSgnAcc.Caption := TAccountComp.AccountNumberToAccountTxtNumber(Model.SignerAccount.account);
+   lblSgnAcc.Caption := TAccountComp.AccountNumberToAccountTxtNumber(Model.TransferAccountModel.SignerAccount.account);
 end;
 
 { TAccountSenderDataSource }

+ 1 - 1
src/gui/wizards/UWIZTransferAccount_Start.lfm

@@ -6,7 +6,7 @@ object WIZTransferAccount_Start: TWIZTransferAccount_Start
   Caption = 'WIZTransferAccount_Start'
   ClientHeight = 253
   ClientWidth = 429
-  LCLVersion = '1.8.1.0'
+  LCLVersion = '1.8.2.0'
   Visible = False
   object grpTransferAccount: TGroupBox
     Left = 6

+ 5 - 5
src/gui/wizards/UWIZTransferAccount_Start.pas

@@ -14,13 +14,13 @@ interface
 uses
   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
   ExtCtrls, UVisualGrid, UCommon.Data, UCellRenderers,
-  UWizard, UWIZTransferAccount, UWIZTransferAccount_Transaction, UWIZTransferAccount_Confirmation;
+  UWizard, UWIZTransferAccount, UWIZTransferAccount_Transaction, UWIZTransferAccount_Confirmation, UWIZModels;
 
 type
 
   { TWIZTransferAccount_Start }
 
-  TWIZTransferAccount_Start = class(TWizardForm<TWIZTransferAccountModel>)
+  TWIZTransferAccount_Start = class(TWizardForm<TWIZOperationsModel>)
     grpTransferAccount: TGroupBox;
     paGrid: TPanel;
   private
@@ -44,9 +44,9 @@ type
 
   TAccountSenderDataSource = class(TAccountsDataSourceBase)
   private
-    FModel: TWIZTransferAccountModel;
+    FModel: TWIZOperationsModel.TTransferAccountModel;
   public
-    property Model: TWIZTransferAccountModel read FModel write FModel;
+    property Model: TWIZOperationsModel.TTransferAccountModel read FModel write FModel;
     procedure FetchAll(const AContainer: TList<TAccount>); override;
   end;
 
@@ -97,7 +97,7 @@ begin
     Filters := SORTABLE_NUMERIC_FILTER;
   end;
   Data := TAccountSenderDataSource.Create(FSendersGrid);
-  Data.Model := Model;
+  Data.Model := Model.TransferAccountModel;
   FSendersGrid.DataSource := Data;
   paGrid.AddControlDockCenter(FSendersGrid);
 end;

+ 1 - 1
src/gui/wizards/UWIZTransferAccount_Transaction.lfm

@@ -7,7 +7,7 @@ object WIZTransferAccount_Transaction: TWIZTransferAccount_Transaction
   Caption = 'WIZTransferAccount_Transaction'
   ClientHeight = 253
   ClientWidth = 429
-  LCLVersion = '1.8.1.0'
+  LCLVersion = '1.8.2.0'
   Visible = False
   object gbTransaction: TGroupBox
     Left = 24

+ 14 - 16
src/gui/wizards/UWIZTransferAccount_Transaction.pas

@@ -16,13 +16,13 @@ uses
   ExtCtrls, Buttons, UCommon, UCommon.Collections, UWallet,
   UFRMAccountSelect, UNode, UWizard, UWIZTransferAccount,
   UWIZTransferAccount_TransactionPayload,
-  UWIZTransferAccount_Confirmation;
+  UWIZTransferAccount_Confirmation, UWIZModels;
 
 type
 
   { TWIZTransferAccount_Transaction }
 
-  TWIZTransferAccount_Transaction = class(TWizardForm<TWIZTransferAccountModel>)
+  TWIZTransferAccount_Transaction = class(TWizardForm<TWIZOperationsModel>)
     cbSignerAccount: TComboBox;
     edtOpFee: TEdit;
     edtPublicKey: TEdit;
@@ -61,9 +61,7 @@ begin
   else
   begin
     lblBalance.Font.Color := clGreen;
-    lblBalance.Caption := Format('%s PASC',
-      [TAccountComp.FormatMoney(Model.SelectedAccounts[PtrInt(
-      cbSignerAccount.Items.Objects[cbSignerAccount.ItemIndex])].Balance)]);
+    lblBalance.Caption := Format('%s PASC', [TAccountComp.FormatMoney(Model.TransferAccountModel.SelectedAccounts[PtrInt(cbSignerAccount.Items.Objects[cbSignerAccount.ItemIndex])].Balance)]);
   end;
 end;
 
@@ -85,9 +83,9 @@ begin
   try
     cbSignerAccount.Items.Clear;
     cbSignerAccount.Items.Add('Select Signer Account');
-    for i := Low(Model.SelectedAccounts) to High(Model.SelectedAccounts) do
+    for i := Low(Model.TransferAccountModel.SelectedAccounts) to High(Model.TransferAccountModel.SelectedAccounts) do
     begin
-      acc := Model.SelectedAccounts[i];
+      acc := Model.TransferAccountModel.SelectedAccounts[i];
       accNumberwithChecksum := GetAccNoWithChecksum(acc.account);
       totalBalance := totalBalance + acc.balance;
       cbSignerAccount.Items.AddObject(accNumberwithChecksum, TObject(i));
@@ -95,7 +93,7 @@ begin
   finally
     cbSignerAccount.Items.EndUpdate;
   end;
-  cbSignerAccount.ItemIndex := Model.SelectedIndex;
+  cbSignerAccount.ItemIndex := Model.TransferAccountModel.SelectedIndex;
   cbSignerAccountChange(Self);
   lblTotalBalanceValue.Caption :=
     Format('%s PASC', [TAccountComp.FormatMoney(totalBalance)]);
@@ -105,10 +103,10 @@ end;
 
 procedure TWIZTransferAccount_Transaction.OnNext;
 begin
-  Model.SelectedIndex := cbSignerAccount.ItemIndex;
-  Model.SignerAccount := Model.SelectedAccounts[PtrInt(
+  Model.TransferAccountModel.SelectedIndex := cbSignerAccount.ItemIndex;
+  Model.TransferAccountModel.SignerAccount := Model.TransferAccountModel.SelectedAccounts[PtrInt(
     cbSignerAccount.Items.Objects[cbSignerAccount.ItemIndex])];
-  Model.NewPublicKey := Trim(edtPublicKey.Text);
+  Model.TransferAccountModel.NewPublicKey := Trim(edtPublicKey.Text);
 
   UpdatePath(ptReplaceAllNext, [TWIZTransferAccount_TransactionPayload,
     TWIZTransferAccount_Confirmation]);
@@ -126,7 +124,7 @@ begin
     Exit;
   end;
 
-  if not TAccountComp.TxtToMoney(Trim(edtOpFee.Text), Model.DefaultFee) then
+  if not TAccountComp.TxtToMoney(Trim(edtOpFee.Text), Model.TransferAccountModel.DefaultFee) then
   begin
     message := 'Invalid fee value "' + edtOpFee.Text + '"';
     Result := False;
@@ -134,11 +132,11 @@ begin
   end;
 
   Result := TAccountComp.AccountKeyFromImport(edtPublicKey.Text,
-    Model.AccountKey, message);
-  for i := Low(Model.SelectedAccounts) to High(Model.SelectedAccounts) do
+    Model.TransferAccountModel.AccountKey, message);
+  for i := Low(Model.TransferAccountModel.SelectedAccounts) to High(Model.TransferAccountModel.SelectedAccounts) do
   begin
-    if TAccountComp.EqualAccountKeys(Model.SelectedAccounts[i].accountInfo.accountKey,
-      Model.AccountKey) then
+    if TAccountComp.EqualAccountKeys(Model.TransferAccountModel.SelectedAccounts[i].accountInfo.accountKey,
+      Model.TransferAccountModel.AccountKey) then
     begin
       Result := False;
       message := 'new public key is same as selected account public key';

+ 1 - 0
src/gui/wizards/UWIZTransferAccount_TransactionPayload.lfm

@@ -7,6 +7,7 @@ object WIZTransferAccount_TransactionPayload: TWIZTransferAccount_TransactionPay
   Caption = 'Form1'
   ClientHeight = 253
   ClientWidth = 429
+  LCLVersion = '1.8.2.0'
   Visible = False
   object grpPayload: TGroupBox
     Left = 8

+ 7 - 7
src/gui/wizards/UWIZTransferAccount_TransactionPayload.pas

@@ -14,13 +14,13 @@ interface
 uses
   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
   ExtCtrls, Buttons, UCommon, UCommon.Collections,
-  UWizard, UWIZTransferAccount;
+  UWizard, UWIZTransferAccount, UWIZModels;
 
 type
 
   { TWIZTransferAccount_TransactionPayload }
 
-  TWIZTransferAccount_TransactionPayload = class(TWizardForm<TWIZTransferAccountModel>)
+  TWIZTransferAccount_TransactionPayload = class(TWizardForm<TWIZOperationsModel>)
     edtPassword: TEdit;
     grpPayload: TGroupBox;
     Label1: TLabel;
@@ -48,25 +48,25 @@ uses
 
 procedure TWIZTransferAccount_TransactionPayload.OnNext;
 begin
-  Model.Payload := mmoPayload.Lines.Text;
+  Model.TransferAccountModel.Payload := mmoPayload.Lines.Text;
   if rbEncryptedWithOldEC.Checked then
   begin
-    Model.PayloadEncryptionMode := akaEncryptWithOldEC;
+    Model.TransferAccountModel.PayloadEncryptionMode := akaEncryptWithOldEC;
   end
   else
   if rbEncryptedWithEC.Checked then
   begin
-    Model.PayloadEncryptionMode := akaEncryptWithEC;
+    Model.TransferAccountModel.PayloadEncryptionMode := akaEncryptWithEC;
   end
   else
   if rbEncryptedWithPassword.Checked then
   begin
-    Model.PayloadEncryptionMode := akaEncryptWithPassword;
+    Model.TransferAccountModel.PayloadEncryptionMode := akaEncryptWithPassword;
   end
   else
   if rbNotEncrypted.Checked then
   begin
-    Model.PayloadEncryptionMode := akaNotEncrypt;
+    Model.TransferAccountModel.PayloadEncryptionMode := akaNotEncrypt;
   end;
 end;
 

+ 2 - 44
src/pascalcoin_wallet.lpi

@@ -33,7 +33,7 @@
         <PackageName Value="LCL"/>
       </Item1>
     </RequiredPackages>
-    <Units Count="95">
+    <Units Count="89">
       <Unit0>
         <Filename Value="pascalcoin_wallet.dpr"/>
         <IsPartOfProject Value="True"/>
@@ -500,51 +500,9 @@
         <ResourceBaseClass Value="Form"/>
       </Unit87>
       <Unit88>
-        <Filename Value="gui\wizards\UWIZEnlistAccountForSale.pas"/>
+        <Filename Value="gui\wizards\UWIZModels.pas"/>
         <IsPartOfProject Value="True"/>
       </Unit88>
-      <Unit89>
-        <Filename Value="gui\wizards\UWIZEnlistAccountForSale_Confirmation.pas"/>
-        <IsPartOfProject Value="True"/>
-        <ComponentName Value="WIZEnlistAccountForSale_Confirmation"/>
-        <HasResources Value="True"/>
-        <ResourceBaseClass Value="Form"/>
-      </Unit89>
-      <Unit90>
-        <Filename Value="gui\wizards\UWIZEnlistAccountForSale_Start.pas"/>
-        <IsPartOfProject Value="True"/>
-        <ComponentName Value="WIZEnlistAccountForSale_Start"/>
-        <HasResources Value="True"/>
-        <ResourceBaseClass Value="Form"/>
-      </Unit90>
-      <Unit91>
-        <Filename Value="gui\wizards\UWIZEnlistAccountForSale_Transaction.pas"/>
-        <IsPartOfProject Value="True"/>
-        <ComponentName Value="WIZEnlistAccountForSale_Transaction"/>
-        <HasResources Value="True"/>
-        <ResourceBaseClass Value="Form"/>
-      </Unit91>
-      <Unit92>
-        <Filename Value="gui\wizards\UWIZEnlistAccountForSale_TransactionPayload.pas"/>
-        <IsPartOfProject Value="True"/>
-        <ComponentName Value="WIZEnlistAccountForSale_TransactionPayload"/>
-        <HasResources Value="True"/>
-        <ResourceBaseClass Value="Form"/>
-      </Unit92>
-      <Unit93>
-        <Filename Value="gui\wizards\UWIZEnlistAccountForSale_List.pas"/>
-        <IsPartOfProject Value="True"/>
-        <ComponentName Value="WIZEnlistAccountForSale_List"/>
-        <HasResources Value="True"/>
-        <ResourceBaseClass Value="Form"/>
-      </Unit93>
-      <Unit94>
-        <Filename Value="gui\wizards\UWIZEnlistAccountForSale_PrivateSaleConfig.pas"/>
-        <IsPartOfProject Value="True"/>
-        <ComponentName Value="WIZEnlistAccountForSale_PrivateSaleConfig"/>
-        <HasResources Value="True"/>
-        <ResourceBaseClass Value="Form"/>
-      </Unit94>
     </Units>
   </ProjectOptions>
   <CompilerOptions>