Selaa lähdekoodia

Refactor: updated operation wizard model pattern

Herman Schoenfeld 7 vuotta sitten
vanhempi
commit
5a2e0bdd0a
44 muutettua tiedostoa jossa 354 lisäystä ja 382 poistoa
  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
   ClientWidth = 1151
   OnCreate = FormCreate
   OnCreate = FormCreate
   OnResize = FormResize
   OnResize = FormResize
-  LCLVersion = '1.8.1.0'
+  LCLVersion = '1.8.2.0'
   Visible = False
   Visible = False
   object PairSplitter1: TPairSplitter
   object PairSplitter1: TPairSplitter
     Left = 0
     Left = 0

+ 18 - 38
src/gui/UCTRLWallet.pas

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

+ 1 - 1
src/gui/UFRMWalletKeys.pas

@@ -90,7 +90,7 @@ implementation
 
 
 {$R *.lfm}
 {$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}
 {%region Form life-cycle}
 
 

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@@ -14,13 +14,13 @@ interface
 uses
 uses
   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
   ExtCtrls, Buttons, UCommon, UCommon.Collections,
   ExtCtrls, Buttons, UCommon, UCommon.Collections,
-  UWizard, UWIZChangeAccountPrivateKey;
+  UWizard, UWIZChangeAccountPrivateKey, UWIZModels;
 
 
 type
 type
 
 
   { TWIZChangeAccountPrivateKey_TransactionPayload }
   { TWIZChangeAccountPrivateKey_TransactionPayload }
 
 
-  TWIZChangeAccountPrivateKey_TransactionPayload = class(TWizardForm<TWIZChangeAccountPrivateKeyModel>)
+  TWIZChangeAccountPrivateKey_TransactionPayload = class(TWizardForm<TWIZOperationsModel>)
     edtPassword: TEdit;
     edtPassword: TEdit;
     grpPayload: TGroupBox;
     grpPayload: TGroupBox;
     Label1: TLabel;
     Label1: TLabel;
@@ -48,25 +48,25 @@ uses
 
 
 procedure TWIZChangeAccountPrivateKey_TransactionPayload.OnNext;
 procedure TWIZChangeAccountPrivateKey_TransactionPayload.OnNext;
 begin
 begin
-  Model.Payload := mmoPayload.Lines.Text;
+  Model.ChangeAccountPrivateKeyModel.Payload := mmoPayload.Lines.Text;
   if rbEncryptedWithOldEC.Checked then
   if rbEncryptedWithOldEC.Checked then
   begin
   begin
-    Model.PayloadEncryptionMode := akaEncryptWithOldEC;
+    Model.ChangeAccountPrivateKeyModel.PayloadEncryptionMode := akaEncryptWithOldEC;
   end
   end
   else
   else
   if rbEncryptedWithEC.Checked then
   if rbEncryptedWithEC.Checked then
   begin
   begin
-    Model.PayloadEncryptionMode := akaEncryptWithEC;
+    Model.ChangeAccountPrivateKeyModel.PayloadEncryptionMode := akaEncryptWithEC;
   end
   end
   else
   else
   if rbEncryptedWithPassword.Checked then
   if rbEncryptedWithPassword.Checked then
   begin
   begin
-    Model.PayloadEncryptionMode := akaEncryptWithPassword;
+    Model.ChangeAccountPrivateKeyModel.PayloadEncryptionMode := akaEncryptWithPassword;
   end
   end
   else
   else
   if rbNotEncrypted.Checked then
   if rbNotEncrypted.Checked then
   begin
   begin
-    Model.PayloadEncryptionMode := akaNotEncrypt;
+    Model.ChangeAccountPrivateKeyModel.PayloadEncryptionMode := akaNotEncrypt;
   end;
   end;
 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
 interface
 
 
 uses
 uses
-  Classes, SysUtils, Forms, Dialogs, UCrypto, UWizard, UAccounts, LCLType;
+  Classes, SysUtils, Forms, Dialogs, UCrypto, UWizard, UAccounts, LCLType, UWIZModels;
 
 
 type
 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 }
 
 
-  TWIZSendPASCWizard = class(TWizard<TWIZSendPASCModel>)
+  TWIZSendPASCWizard = class(TWizard<TWIZOperationsModel>)
   private
   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 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();
     procedure SendPASC();
   public
   public
     constructor Create(AOwner: TComponent); override;
     constructor Create(AOwner: TComponent); override;
@@ -82,7 +65,7 @@ begin
     Exit;
     Exit;
   end;
   end;
 
 
-  if Length(Model.SelectedAccounts) = 0 then
+  if Length(Model.SendPASCModel.SelectedAccounts) = 0 then
   begin
   begin
     errors := 'No sender account';
     errors := 'No sender account';
     Exit;
     Exit;
@@ -90,15 +73,13 @@ begin
   else
   else
   begin
   begin
 
 
-    for iAcc := Low(Model.SelectedAccounts) to High(Model.SelectedAccounts) do
+    for iAcc := Low(Model.SendPASCModel.SelectedAccounts) to High(Model.SendPASCModel.SelectedAccounts) do
     begin
     begin
-      sender_account := Model.SelectedAccounts[iAcc];
+      sender_account := Model.SendPASCModel.SelectedAccounts[iAcc];
       iWallet := TWallet.Keys.IndexOfAccountKey(sender_account.accountInfo.accountKey);
       iWallet := TWallet.Keys.IndexOfAccountKey(sender_account.accountInfo.accountKey);
       if (iWallet < 0) then
       if (iWallet < 0) then
       begin
       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;
         Exit;
       end;
       end;
       wk := TWallet.Keys.Key[iWallet];
       wk := TWallet.Keys.Key[iWallet];
@@ -112,33 +93,31 @@ begin
         else
         else
         begin
         begin
           errors := 'Only public key of account ' +
           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;
         end;
         Exit;
         Exit;
       end;
       end;
     end;
     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);
   UpdatePayload(sender_account, e);
 end;
 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
 var
   c: cardinal;
   c: cardinal;
 begin
 begin
   Result := False;
   Result := False;
   errors := '';
   errors := '';
 
 
-  DestAccount := Model.DestinationAccount;
+  DestAccount := Model.SendPASCModel.DestinationAccount;
 
 
-  if Length(Model.SelectedAccounts) = 1 then
+  if Length(Model.SendPASCModel.SelectedAccounts) = 1 then
   begin
   begin
-    if not TAccountComp.TxtToMoney(Model.AmountToSend, amount) then
+    if not TAccountComp.TxtToMoney(Model.SendPASCModel.AmountToSend, amount) then
     begin
     begin
-      errors := 'Invalid amount (' + Model.AmountToSend + ')';
+      errors := 'Invalid amount (' + Model.SendPASCModel.AmountToSend + ')';
       Exit;
       Exit;
     end;
     end;
   end
   end
@@ -153,9 +132,9 @@ begin
     Exit;
     Exit;
   end;
   end;
 
 
-  if (Length(Model.SelectedAccounts) = 1) then
+  if (Length(Model.SendPASCModel.SelectedAccounts) = 1) then
   begin
   begin
-    if (SenderAccount.balance < (amount + Model.DefaultFee)) then
+    if (SenderAccount.balance < (amount + Model.SendPASCModel.DefaultFee)) then
     begin
     begin
       errors := 'Insufficient funds';
       errors := 'Insufficient funds';
       Exit;
       Exit;
@@ -189,10 +168,10 @@ begin
     _signer_n_ops := 0;
     _signer_n_ops := 0;
     operationstxt := '';
     operationstxt := '';
     operation_to_string := '';
     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
     begin
       op := nil;
       op := nil;
-      account := Model.SelectedAccounts[iAcc];
+      account := Model.SendPASCModel.SelectedAccounts[iAcc];
       if not UpdatePayload(account, errors) then
       if not UpdatePayload(account, errors) then
       begin
       begin
         raise Exception.Create('Error encoding payload of sender account ' +
         raise Exception.Create('Error encoding payload of sender account ' +
@@ -207,21 +186,21 @@ begin
       wk := TWallet.Keys.Key[i];
       wk := TWallet.Keys.Key[i];
       dooperation := True;
       dooperation := True;
       // Default fee
       // 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
       else
         _fee := account.balance;
         _fee := account.balance;
 
 
       if not UpdateOpTransaction(account, destAccount, _amount, errors) then
       if not UpdateOpTransaction(account, destAccount, _amount, errors) then
         raise Exception.Create(errors);
         raise Exception.Create(errors);
-      if Length(Model.SelectedAccounts) > 1 then
+      if Length(Model.SendPASCModel.SelectedAccounts) > 1 then
       begin
       begin
         if account.balance > 0 then
         if account.balance > 0 then
         begin
         begin
-          if account.balance > Model.DefaultFee then
+          if account.balance > Model.SendPASCModel.DefaultFee then
           begin
           begin
-            _amount := account.balance - Model.DefaultFee;
-            _fee := Model.DefaultFee;
+            _amount := account.balance - Model.SendPASCModel.DefaultFee;
+            _fee := Model.SendPASCModel.DefaultFee;
           end
           end
           else
           else
           begin
           begin
@@ -239,12 +218,11 @@ begin
       begin
       begin
         op := TOpTransaction.CreateTransaction(
         op := TOpTransaction.CreateTransaction(
           account.account, account.n_operation + 1, destAccount.account,
           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(_totalamount, _amount);
         Inc(_totalfee, _fee);
         Inc(_totalfee, _fee);
       end;
       end;
-      operationstxt := 'Transaction to ' + TAccountComp.AccountNumberToAccountTxtNumber(
-        destAccount.account);
+      operationstxt := 'Transaction to ' + TAccountComp.AccountNumberToAccountTxtNumber(destAccount.account);
 
 
       if Assigned(op) and (dooperation) then
       if Assigned(op) and (dooperation) then
       begin
       begin
@@ -259,12 +237,11 @@ begin
     if (ops.OperationsCount = 0) then
     if (ops.OperationsCount = 0) then
       raise Exception.Create('No valid operation to execute');
       raise Exception.Create('No valid operation to execute');
 
 
-    if (Length(Model.SelectedAccounts) > 1) then
+    if (Length(Model.SendPASCModel.SelectedAccounts) > 1) then
     begin
     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(
       if Application.MessageBox(
-        PChar('Execute ' + IntToStr(Length(Model.SelectedAccounts)) +
+        PChar('Execute ' + IntToStr(Length(Model.SendPASCModel.SelectedAccounts)) +
         ' operations?' + #10 + 'Operation: ' + operationstxt + #10 +
         ' operations?' + #10 + 'Operation: ' + operationstxt + #10 +
         auxs + 'Total fee: ' + TAccountComp.FormatMoney(_totalfee) +
         auxs + 'Total fee: ' + TAccountComp.FormatMoney(_totalfee) +
         #10 + #10 + 'Note: This operation will be transmitted to the network!'),
         #10 + #10 + 'Note: This operation will be transmitted to the network!'),
@@ -335,8 +312,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-function TWIZSendPASCWizard.UpdatePayload(const SenderAccount: TAccount;
-  var errors: string): boolean;
+function TWIZSendPASCWizard.UpdatePayload(const SenderAccount: TAccount; var errors: string): boolean;
 var
 var
   valid: boolean;
   valid: boolean;
   payload_encrypted, payload_u: string;
   payload_encrypted, payload_u: string;
@@ -344,9 +320,9 @@ var
 begin
 begin
   valid := False;
   valid := False;
   payload_encrypted := '';
   payload_encrypted := '';
-  Model.EncodedPayload := '';
+  Model.SendPASCModel.EncodedPayload := '';
   errors := 'Unknown error';
   errors := 'Unknown error';
-  payload_u := Model.Payload;
+  payload_u := Model.SendPASCModel.Payload;
 
 
   try
   try
     if (payload_u = '') then
     if (payload_u = '') then
@@ -354,7 +330,7 @@ begin
       valid := True;
       valid := True;
       Exit;
       Exit;
     end;
     end;
-    case Model.PayloadEncryptionMode of
+    case Model.SendPASCModel.PayloadEncryptionMode of
 
 
       akaEncryptWithOldEC:
       akaEncryptWithOldEC:
       begin
       begin
@@ -369,15 +345,14 @@ begin
       begin
       begin
         // With dest public key
         // With dest public key
         errors := 'Error encrypting';
         errors := 'Error encrypting';
-        account := Model.DestinationAccount;
+        account := Model.SendPASCModel.DestinationAccount;
         payload_encrypted := ECIESEncrypt(account.accountInfo.accountKey, payload_u);
         payload_encrypted := ECIESEncrypt(account.accountInfo.accountKey, payload_u);
         valid := payload_encrypted <> '';
         valid := payload_encrypted <> '';
       end;
       end;
 
 
       akaEncryptWithPassword:
       akaEncryptWithPassword:
       begin
       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 <> '';
         valid := payload_encrypted <> '';
       end;
       end;
 
 
@@ -404,7 +379,7 @@ begin
       end;
       end;
 
 
     end;
     end;
-    Model.EncodedPayload := payload_encrypted;
+    Model.SendPASCModel.EncodedPayload := payload_encrypted;
     Result := valid;
     Result := valid;
   end;
   end;
 
 

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

+ 2 - 44
src/pascalcoin_wallet.lpi

@@ -33,7 +33,7 @@
         <PackageName Value="LCL"/>
         <PackageName Value="LCL"/>
       </Item1>
       </Item1>
     </RequiredPackages>
     </RequiredPackages>
-    <Units Count="95">
+    <Units Count="89">
       <Unit0>
       <Unit0>
         <Filename Value="pascalcoin_wallet.dpr"/>
         <Filename Value="pascalcoin_wallet.dpr"/>
         <IsPartOfProject Value="True"/>
         <IsPartOfProject Value="True"/>
@@ -500,51 +500,9 @@
         <ResourceBaseClass Value="Form"/>
         <ResourceBaseClass Value="Form"/>
       </Unit87>
       </Unit87>
       <Unit88>
       <Unit88>
-        <Filename Value="gui\wizards\UWIZEnlistAccountForSale.pas"/>
+        <Filename Value="gui\wizards\UWIZModels.pas"/>
         <IsPartOfProject Value="True"/>
         <IsPartOfProject Value="True"/>
       </Unit88>
       </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>
     </Units>
   </ProjectOptions>
   </ProjectOptions>
   <CompilerOptions>
   <CompilerOptions>