Просмотр исходного кода

Add: refactoring of changekey wizard.

deleted some unneeded files.
Ugochukwu Mmaduekwe 7 лет назад
Родитель
Сommit
696665c641
25 измененных файлов с 75 добавлено и 2998 удалено
  1. 0 455
      src/gui/wizards/operations/UWIZChangeAccountPrivateKey.pas
  2. 0 48
      src/gui/wizards/operations/UWIZChangeAccountPrivateKey_Confirmation.lfm
  3. 0 143
      src/gui/wizards/operations/UWIZChangeAccountPrivateKey_Confirmation.pas
  4. 0 32
      src/gui/wizards/operations/UWIZChangeAccountPrivateKey_Start.lfm
  5. 0 110
      src/gui/wizards/operations/UWIZChangeAccountPrivateKey_Start.pas
  6. 0 106
      src/gui/wizards/operations/UWIZChangeAccountPrivateKey_Transaction.lfm
  7. 0 210
      src/gui/wizards/operations/UWIZChangeAccountPrivateKey_Transaction.pas
  8. 0 97
      src/gui/wizards/operations/UWIZChangeAccountPrivateKey_TransactionPayload.lfm
  9. 0 84
      src/gui/wizards/operations/UWIZChangeAccountPrivateKey_TransactionPayload.pas
  10. 3 3
      src/gui/wizards/operations/UWIZChangeKey.pas
  11. 1 7
      src/gui/wizards/operations/UWIZChangeKey_ConfirmAccount.pas
  12. 1 1
      src/gui/wizards/operations/UWIZChangeKey_SelectOption.pas
  13. 0 453
      src/gui/wizards/operations/UWIZConfirmAccount.pas
  14. 1 0
      src/gui/wizards/operations/UWIZOperationConfirmation.lfm
  15. 38 1
      src/gui/wizards/operations/UWIZOperationConfirmation.pas
  16. 0 453
      src/gui/wizards/operations/UWIZTransferAccount.pas
  17. 0 48
      src/gui/wizards/operations/UWIZTransferAccount_Confirmation.lfm
  18. 0 137
      src/gui/wizards/operations/UWIZTransferAccount_Confirmation.pas
  19. 0 32
      src/gui/wizards/operations/UWIZTransferAccount_Start.lfm
  20. 0 110
      src/gui/wizards/operations/UWIZTransferAccount_Start.pas
  21. 0 93
      src/gui/wizards/operations/UWIZTransferAccount_Transaction.lfm
  22. 0 148
      src/gui/wizards/operations/UWIZTransferAccount_Transaction.pas
  23. 0 98
      src/gui/wizards/operations/UWIZTransferAccount_TransactionPayload.lfm
  24. 0 84
      src/gui/wizards/operations/UWIZTransferAccount_TransactionPayload.pas
  25. 31 45
      src/pascalcoin_wallet.lpi

+ 0 - 455
src/gui/wizards/operations/UWIZChangeAccountPrivateKey.pas

@@ -1,455 +0,0 @@
-unit UWIZChangeAccountPrivateKey;
-
-{$mode delphi}
-
-{ Copyright (c) 2018 by Ugochukwu Mmaduekwe
-
-  Distributed under the MIT software license, see the accompanying file LICENSE
-  or visit http://www.opensource.org/licenses/mit-license.php.
-
-}
-
-interface
-
-uses
-  Classes, SysUtils, Forms, Dialogs, UCrypto, UWallet, UCommon, UWizard,
-  UAccounts, LCLType, UWIZModels;
-
-type
-
-  { TWIZChangeAccountPrivateKeyWizard }
-
-  TWIZChangeAccountPrivateKeyWizard = class(TWizard<TWIZOperationsModel>)
-  private
-    function UpdatePayload(const SenderAccount: TAccount; var errors: string): boolean;
-    function UpdateOperationOptions(var errors: string): boolean;
-    function UpdateOpChangeKey(const TargetAccount: TAccount; var SignerAccount: TAccount; var NewPublicKey: TAccountKey; var errors: ansistring): boolean;
-    procedure ChangeAccountPrivateKey();
-  public
-    constructor Create(AOwner: TComponent); override;
-    function DetermineHasNext: boolean; override;
-    function DetermineHasPrevious: boolean; override;
-    function FinishRequested(out message: ansistring): boolean; override;
-    function CancelRequested(out message: ansistring): boolean; override;
-  end;
-
-implementation
-
-uses
-  UBlockChain,
-  UOpTransaction,
-  UNode,
-  UConst,
-  UECIES,
-  UAES,
-  UWIZChangeAccountPrivateKey_Start,
-  UWIZChangeAccountPrivateKey_Confirmation;
-
-{ TWIZChangeAccountPrivateKeyWizard }
-
-function TWIZChangeAccountPrivateKeyWizard.UpdatePayload(const SenderAccount: TAccount;
-  var errors: string): boolean;
-var
-  valid: boolean;
-  payload_encrypted, payload_u: string;
-  account: TAccount;
-  public_key: TAccountKey;
-begin
-  valid := False;
-  payload_encrypted := '';
- Model.Payload.EncodedBytes := '';
-  errors := 'Unknown error';
-  payload_u := Model.Payload.Content;
-
-  try
-    if (payload_u = '') then
-    begin
-      valid := True;
-      Exit;
-    end;
-    case Model.Payload.Mode of
-
-      akaEncryptWithSender:
-      begin
-        // Use sender
-        errors := 'Error encrypting';
-        account := SenderAccount;
-        payload_encrypted := ECIESEncrypt(account.accountInfo.accountKey, payload_u);
-        valid := payload_encrypted <> '';
-      end;
-
-      akaEncryptWithReceiver:
-      begin
-        errors := 'Error encrypting';
-
-        public_key := Model.ChangeAccountPrivateKey.NewWalletKey.AccountKey;
-        if public_key.EC_OpenSSL_NID <>
-          CT_Account_NUL.accountInfo.accountKey.EC_OpenSSL_NID then
-        begin
-          payload_encrypted := ECIESEncrypt(public_key, payload_u);
-          valid := payload_encrypted <> '';
-        end
-        else
-        begin
-          valid := False;
-          errors := 'Selected private key is not valid to encode';
-          exit;
-        end;
-      end;
-
-      akaEncryptWithPassword:
-      begin
-        payload_encrypted := TAESComp.EVP_Encrypt_AES256(
-          payload_u, Model.Payload.Password);
-        valid := payload_encrypted <> '';
-      end;
-
-      akaNotEncrypt:
-      begin
-        payload_encrypted := payload_u;
-        valid := True;
-      end
-
-      else
-      begin
-        raise Exception.Create('Invalid Encryption Selection');
-      end;
-    end;
-
-  finally
-    if valid then
-    begin
-      if length(payload_encrypted) > CT_MaxPayloadSize then
-      begin
-        valid := False;
-        errors := 'Payload size is bigger than ' + IntToStr(CT_MaxPayloadSize) +
-          ' (' + IntToStr(length(payload_encrypted)) + ')';
-      end;
-
-    end;
-   Model.Payload.EncodedBytes := payload_encrypted;
-    Result := valid;
-  end;
-
-end;
-
-function TWIZChangeAccountPrivateKeyWizard.UpdateOperationOptions(
-  var errors: string): boolean;
-var
-  iAcc, iWallet: integer;
-  sender_account, signer_account: TAccount;
-  publicKey: TAccountKey;
-  wk: TWalletKey;
-  e: string;
-  amount: int64;
-begin
-  Result := False;
-  errors := '';
-  if not Assigned(TWallet.Keys) then
-  begin
-    errors := 'No wallet keys';
-    Exit;
-  end;
-
-  if Length(Model.ChangeAccountPrivateKey.SelectedAccounts) = 0 then
-  begin
-    errors := 'No sender account';
-    Exit;
-  end
-  else
-  begin
-
-    for iAcc := Low(Model.ChangeAccountPrivateKey.SelectedAccounts) to High(Model.ChangeAccountPrivateKey.SelectedAccounts) do
-    begin
-      sender_account := Model.ChangeAccountPrivateKey.SelectedAccounts[iAcc];
-      iWallet := TWallet.Keys.IndexOfAccountKey(sender_account.accountInfo.accountKey);
-      if (iWallet < 0) then
-      begin
-        errors := 'Private key of account ' +
-          TAccountComp.AccountNumberToAccountTxtNumber(sender_account.account) +
-          ' not found in wallet';
-        Exit;
-      end;
-      wk := TWallet.Keys.Key[iWallet];
-      if not assigned(wk.PrivateKey) then
-      begin
-        if wk.CryptedKey <> '' then
-        begin
-          // TODO: handle unlocking of encrypted wallet here
-          errors := 'Wallet is password protected. Need password';
-        end
-        else
-        begin
-          errors := 'Only public key of account ' +
-            TAccountComp.AccountNumberToAccountTxtNumber(sender_account.account) +
-            ' found in wallet. You cannot operate with this account';
-        end;
-        Exit;
-      end;
-    end;
-  end;
-
-  Result := UpdateOpChangeKey(Model.ChangeAccountPrivateKey.SelectedAccounts[0], signer_account,
-    publicKey, errors);
-  UpdatePayload(sender_account, e);
-end;
-
-function TWIZChangeAccountPrivateKeyWizard.UpdateOpChangeKey(
-  const TargetAccount: TAccount; var SignerAccount: TAccount;
-  var NewPublicKey: TAccountKey; var errors: ansistring): boolean;
-begin
-  Result := False;
-  errors := '';
-  try
-    NewPublicKey := Model.ChangeAccountPrivateKey.NewWalletKey.AccountKey;
-
-    if TNode.Node.Bank.SafeBox.CurrentProtocol >= 1 then
-    begin
-      // Signer:
-      SignerAccount := Model.Signer.SignerAccount;
-      if (TAccountComp.IsAccountLocked(SignerAccount.accountInfo,
-        TNode.Node.Bank.BlocksCount)) then
-      begin
-        errors := 'Signer account ' + TAccountComp.AccountNumberToAccountTxtNumber(
-          SignerAccount.account) + ' is locked until block ' + IntToStr(
-          SignerAccount.accountInfo.locked_until_block);
-        exit;
-      end;
-      if (not TAccountComp.EqualAccountKeys(
-        SignerAccount.accountInfo.accountKey, TargetAccount.accountInfo.accountKey)) then
-      begin
-        errors := 'Signer account ' + TAccountComp.AccountNumberToAccountTxtNumber(
-          SignerAccount.account) + ' is not owner of account ' +
-          TAccountComp.AccountNumberToAccountTxtNumber(TargetAccount.account);
-        exit;
-      end;
-    end
-    else
-    begin
-      SignerAccount := TargetAccount;
-    end;
-
-    if (TAccountComp.EqualAccountKeys(TargetAccount.accountInfo.accountKey,
-      NewPublicKey)) then
-    begin
-      errors := 'New public key is the same public key';
-      exit;
-    end;
-
-  finally
-    Result := errors = '';
-  end;
-end;
-
-procedure TWIZChangeAccountPrivateKeyWizard.ChangeAccountPrivateKey();
-var
-  _V2, dooperation: boolean;
-  iAcc, i: integer;
-  _totalamount, _totalfee, _totalSignerFee, _amount, _fee: int64;
-  _signer_n_ops: cardinal;
-  operationstxt, operation_to_string, errors, auxs: string;
-  wk: TWalletKey;
-  ops: TOperationsHashTree;
-  op: TPCOperation;
-  account, signerAccount: TAccount;
-  _newOwnerPublicKey: TECDSA_Public;
-label
-  loop_start;
-begin
-  if not Assigned(TWallet.Keys) then
-    raise Exception.Create('No wallet keys');
-  if not UpdateOperationOptions(errors) then
-    raise Exception.Create(errors);
-  ops := TOperationsHashTree.Create;
-
-  try
-    _V2 := TNode.Node.Bank.SafeBox.CurrentProtocol >= CT_PROTOCOL_2;
-    _totalamount := 0;
-    _totalfee := 0;
-    _totalSignerFee := 0;
-    _signer_n_ops := 0;
-    operationstxt := '';
-    operation_to_string := '';
-    for iAcc := Low(Model.ChangeAccountPrivateKey.SelectedAccounts) to High(Model.ChangeAccountPrivateKey.SelectedAccounts) do
-    begin
-      loop_start:
-        op := nil;
-      account := Model.ChangeAccountPrivateKey.SelectedAccounts[iAcc];
-      if not UpdatePayload(account, errors) then
-      begin
-        raise Exception.Create('Error encoding payload of sender account ' +
-          TAccountComp.AccountNumberToAccountTxtNumber(account.account) + ': ' + errors);
-      end;
-      i := TWallet.Keys.IndexOfAccountKey(account.accountInfo.accountKey);
-      if i < 0 then
-      begin
-        raise Exception.Create('Sender account private key not found in Wallet');
-      end;
-
-      wk := TWallet.Keys.Key[i];
-      dooperation := True;
-      // Default fee
-      if account.balance > uint64(Model.Fee.DefaultFee) then
-        _fee := Model.Fee.DefaultFee
-      else
-        _fee := account.balance;
-
-      if not UpdateOpChangeKey(account, signerAccount, _newOwnerPublicKey, errors) then
-      begin
-        raise Exception.Create(errors);
-      end;
-      if _V2 then
-      begin
-        // must ensure is Signer account last if included in sender accounts (not necessarily ordered enumeration)
-        if (iAcc < Length(Model.ChangeAccountPrivateKey.SelectedAccounts) - 1) and
-          (account.account = signerAccount.account) then
-        begin
-          TArrayTool<TAccount>.Swap(Model.ChangeAccountPrivateKey.SelectedAccounts, iAcc,
-            Length(Model.ChangeAccountPrivateKey.SelectedAccounts) - 1); // ensure signer account processed last
-          // TArrayTool_internal<Cardinal>.Swap(_senderAccounts, iAcc, Length(_senderAccounts) - 1);
-          goto loop_start; // TODO: remove ugly hack with refactoring!
-        end;
-
-        // Maintain correct signer fee distribution
-        if uint64(_totalSignerFee) >= signerAccount.balance then
-          _fee := 0
-        else if signerAccount.balance - uint64(_totalSignerFee) >
-          uint64(Model.Fee.DefaultFee) then
-          _fee := Model.Fee.DefaultFee
-        else
-          _fee := signerAccount.balance - uint64(_totalSignerFee);
-        op := TOpChangeKeySigned.Create(signerAccount.account,
-          signerAccount.n_operation + _signer_n_ops + 1, account.account,
-          wk.PrivateKey, _newOwnerPublicKey, _fee,Model.Payload.EncodedBytes);
-        Inc(_signer_n_ops);
-        Inc(_totalSignerFee, _fee);
-      end
-      else
-      begin
-        op := TOpChangeKey.Create(account.account, account.n_operation +
-          1, account.account, wk.PrivateKey, _newOwnerPublicKey, _fee,
-         Model.Payload.EncodedBytes);
-      end;
-      Inc(_totalfee, _fee);
-      operationstxt :=
-        'Change private key to ' + TAccountComp.GetECInfoTxt(
-        _newOwnerPublicKey.EC_OpenSSL_NID);
-
-      if Assigned(op) and (dooperation) then
-      begin
-        ops.AddOperationToHashTree(op);
-        if operation_to_string <> '' then
-          operation_to_string := operation_to_string + #10;
-        operation_to_string := operation_to_string + op.ToString;
-      end;
-      FreeAndNil(op);
-    end;
-
-    if (ops.OperationsCount = 0) then
-      raise Exception.Create('No valid operation to execute');
-
-    if (Length(Model.ChangeAccountPrivateKey.SelectedAccounts) > 1) then
-    begin
-      auxs := '';
-      if Application.MessageBox(
-        PChar('Execute ' + IntToStr(Length(Model.ChangeAccountPrivateKey.SelectedAccounts)) +
-        ' operations?' + #10 + 'Operation: ' + operationstxt + #10 +
-        auxs + 'Total fee: ' + TAccountComp.FormatMoney(_totalfee) +
-        #10 + #10 + 'Note: This operation will be transmitted to the network!'),
-        PChar(Application.Title), MB_YESNO + MB_ICONINFORMATION + MB_DEFBUTTON2) <>
-        idYes then
-      begin
-        Exit;
-      end;
-    end
-    else
-    begin
-      if Application.MessageBox(PChar('Execute this operation:' +
-        #10 + #10 + operation_to_string + #10 + #10 +
-        'Note: This operation will be transmitted to the network!'),
-        PChar(Application.Title), MB_YESNO + MB_ICONINFORMATION + MB_DEFBUTTON2) <>
-        idYes then
-      begin
-        Exit;
-      end;
-    end;
-    i := TNode.Node.AddOperations(nil, ops, nil, errors);
-    if (i = ops.OperationsCount) then
-    begin
-      operationstxt := 'Successfully executed ' + IntToStr(i) +
-        ' operations!' + #10 + #10 + operation_to_string;
-      if i > 1 then
-      begin
-
-        ShowMessage(operationstxt);
-      end
-      else
-      begin
-        Application.MessageBox(
-          PChar('Successfully executed ' + IntToStr(i) + ' operations!' +
-          #10 + #10 + operation_to_string),
-          PChar(Application.Title), MB_OK + MB_ICONINFORMATION);
-      end;
-
-    end
-    else if (i > 0) then
-    begin
-      operationstxt := 'One or more of your operations has not been executed:' +
-        #10 + 'Errors:' + #10 + errors + #10 + #10 +
-        'Total successfully executed operations: ' + IntToStr(i);
-
-      ShowMessage(operationstxt);
-    end
-    else
-    begin
-      raise Exception.Create(errors);
-    end;
-
-
-  finally
-    ops.Free;
-  end;
-
-end;
-
-constructor TWIZChangeAccountPrivateKeyWizard.Create(AOwner: TComponent);
-begin
-  inherited Create(AOwner, [TWIZChangeAccountPrivateKey_Start,
-    TWIZChangeAccountPrivateKey_Confirmation]);
-  TitleText := 'Change Key';
-  FinishText := 'Change Key';
-end;
-
-function TWIZChangeAccountPrivateKeyWizard.DetermineHasNext: boolean;
-begin
-  Result := not (CurrentScreen is TWIZChangeAccountPrivateKey_Confirmation);
-end;
-
-function TWIZChangeAccountPrivateKeyWizard.DetermineHasPrevious: boolean;
-begin
-  Result := inherited DetermineHasPrevious;
-end;
-
-function TWIZChangeAccountPrivateKeyWizard.FinishRequested(
-  out message: ansistring): boolean;
-begin
-  // Execute the Change Account Private Key Action here
-  try
-    Result := True;
-    ChangeAccountPrivateKey();
-  except
-    On E: Exception do
-    begin
-      Result := False;
-      message := E.ToString;
-    end;
-  end;
-end;
-
-function TWIZChangeAccountPrivateKeyWizard.CancelRequested(
-  out message: ansistring): boolean;
-begin
-  Result := True;
-end;
-
-end.

+ 0 - 48
src/gui/wizards/operations/UWIZChangeAccountPrivateKey_Confirmation.lfm

@@ -1,48 +0,0 @@
-object WIZChangeAccountPrivateKey_Confirmation: TWIZChangeAccountPrivateKey_Confirmation
-  Left = 0
-  Height = 253
-  Top = 0
-  Width = 429
-  Caption = 'WIZChangeAccountPrivateKey_Confirmation'
-  ClientHeight = 253
-  ClientWidth = 429
-  LCLVersion = '1.8.2.0'
-  Visible = False
-  object GroupBox1: TGroupBox
-    Left = 10
-    Height = 232
-    Top = 8
-    Width = 408
-    Anchors = [akTop, akLeft, akRight, akBottom]
-    Caption = 'Confirm Transfer Transaction'
-    ClientHeight = 212
-    ClientWidth = 404
-    TabOrder = 0
-    object paGrid: TPanel
-      Left = 8
-      Height = 152
-      Top = 48
-      Width = 382
-      Anchors = [akTop, akLeft, akRight, akBottom]
-      BevelOuter = bvNone
-      Caption = 'GRID PANEL'
-      TabOrder = 0
-    end
-    object Label1: TLabel
-      Left = 8
-      Height = 15
-      Top = 16
-      Width = 84
-      Caption = 'Signer Account:'
-      ParentColor = False
-    end
-    object lblSgnAcc: TLabel
-      Left = 112
-      Height = 15
-      Top = 16
-      Width = 53
-      Caption = 'lblSgnAcc'
-      ParentColor = False
-    end
-  end
-end

+ 0 - 143
src/gui/wizards/operations/UWIZChangeAccountPrivateKey_Confirmation.pas

@@ -1,143 +0,0 @@
-unit UWIZChangeAccountPrivateKey_Confirmation;
-
-{$mode delphi}
-{$modeswitch nestedprocvars}
-
-{ Copyright (c) 2018 by Ugochukwu Mmaduekwe
-
-  Distributed under the MIT software license, see the accompanying file LICENSE
-  or visit http://www.opensource.org/licenses/mit-license.php.
-}
-
-interface
-
-uses
-  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
-  ExtCtrls, UVisualGrid, UCellRenderers, UCommon.Data, UWizard,
-  UWIZChangeAccountPrivateKey, UWIZModels;
-
-type
-
-  { TWIZChangeAccountPrivateKey_Confirmation }
-
-  TWIZChangeAccountPrivateKey_Confirmation = class(TWizardForm<TWIZOperationsModel>)
-    GroupBox1: TGroupBox;
-    Label1: TLabel;
-    lblSgnAcc: TLabel;
-    paGrid: TPanel;
-  private
-    FSendersGrid: TVisualGrid;
-  public
-    procedure OnPresent; override;
-  end;
-
-
-implementation
-
-{$R *.lfm}
-
-uses UAccounts, UCrypto, UDataSources, UCommon, UCommon.UI, Generics.Collections;
-
-type
-
-  { TAccountSenderDataSource }
-
-  TAccountSenderDataSource = class(TAccountsDataSourceBase)
-  private
-    FModel: TWIZOperationsModel;
-  protected
-    function GetColumns: TDataColumns; override;
-  public
-    property Model: TWIZOperationsModel read FModel write FModel;
-    procedure FetchAll(const AContainer: TList<TAccount>); override;
-    function GetItemField(constref AItem: TAccount;
-      const ABindingName: ansistring): variant; override;
-  end;
-
-{ TWIZChangeAccountPrivateKey_Confirmation }
-
-procedure TWIZChangeAccountPrivateKey_Confirmation.OnPresent;
-var
-  Data: TAccountSenderDataSource;
-begin
-  FSendersGrid := TVisualGrid.Create(Self);
-  FSendersGrid.CanSearch := False;
-  FSendersGrid.SortMode := smMultiColumn;
-  FSendersGrid.FetchDataInThread := False;
-  FSendersGrid.AutoPageSize := True;
-  FSendersGrid.SelectionType := stNone;
-  FSendersGrid.Options := [vgoColAutoFill, vgoColSizing, vgoSortDirectionAllowNone, vgoAutoHidePaging];
-  with FSendersGrid.AddColumn('Account') do
-  begin
-    Binding := 'Account';
-    Filters := SORTABLE_NUMERIC_FILTER;
-    Width := 100;
-    HeaderFontStyles := [fsBold];
-    DataFontStyles := [fsBold];
-  end;
-  with FSendersGrid.AddColumn('New Private Key Name') do
-  begin
-    Binding := 'NewPrivateKey';
-    Filters := SORTABLE_TEXT_FILTER;
-    Width := 100;
-  end;
-  with FSendersGrid.AddColumn('Fee') do
-  begin
-    Filters := SORTABLE_TEXT_FILTER;
-    Width := 100;
-  end;
-
-  Data := TAccountSenderDataSource.Create(FSendersGrid);
-  Data.Model := Model;
-  FSendersGrid.DataSource := Data;
-  paGrid.AddControlDockCenter(FSendersGrid);
-  lblSgnAcc.Caption := TAccountComp.AccountNumberToAccountTxtNumber(Model.Signer.SignerAccount.account);
-end;
-
-{ TAccountSenderDataSource }
-
-function TAccountSenderDataSource.GetColumns: TDataColumns;
-begin
-  Result := TDataColumns.Create(
-    TDataColumn.From('Account'),
-    TDataColumn.From('NewPrivateKey'),
-    TDataColumn.From('Fee')
-    );
-end;
-
-function TAccountSenderDataSource.GetItemField(constref AItem: TAccount;
-  const ABindingName: ansistring): variant;
-var
-  index: integer;
-begin
-  if ABindingName = 'Account' then
-    Result := TAccountComp.AccountNumberToAccountTxtNumber(AItem.account)
-  else if ABindingName = 'NewPrivateKey' then
-  begin
-    Result := IIF(Model.ChangeAccountPrivateKey.NewWalletKey.Name = '',
-      TCrypto.ToHexaString(TAccountComp.AccountKey2RawString(
-      Model.ChangeAccountPrivateKey.NewWalletKey.AccountKey)), Model.ChangeAccountPrivateKey.NewWalletKey.Name);
-    if not Assigned(Model.ChangeAccountPrivateKey.NewWalletKey.PrivateKey) then
-    begin
-      Result := Result + '(*)';
-    end;
-  end
-  else if ABindingName = 'Fee' then
-    Result := TAccountComp.FormatMoney(Model.Fee.DefaultFee)
-  else
-    raise Exception.Create(Format('Field not found [%s]', [ABindingName]));
-end;
-
-
-procedure TAccountSenderDataSource.FetchAll(const AContainer: TList<TAccount>);
-var
-  i: integer;
-begin
-  for i := Low(Model.ChangeAccountPrivateKey.SelectedAccounts) to High(Model.ChangeAccountPrivateKey.SelectedAccounts) do
-  begin
-    AContainer.Add(Model.ChangeAccountPrivateKey.SelectedAccounts[i]);
-  end;
-end;
-
-
-end.

+ 0 - 32
src/gui/wizards/operations/UWIZChangeAccountPrivateKey_Start.lfm

@@ -1,32 +0,0 @@
-object WIZChangeAccountPrivateKey_Start: TWIZChangeAccountPrivateKey_Start
-  Left = 0
-  Height = 253
-  Top = 0
-  Width = 429
-  Caption = 'WIZChangeAccountPrivateKey_Start'
-  ClientHeight = 253
-  ClientWidth = 429
-  LCLVersion = '1.8.2.0'
-  Visible = False
-  object grpSelectedAccount: TGroupBox
-    Left = 6
-    Height = 248
-    Top = 0
-    Width = 416
-    Anchors = [akTop, akLeft, akRight, akBottom]
-    Caption = 'Selected Accounts'
-    ClientHeight = 228
-    ClientWidth = 412
-    TabOrder = 0
-    object paGrid: TPanel
-      Left = 6
-      Height = 200
-      Top = 24
-      Width = 402
-      Anchors = [akTop, akLeft, akRight, akBottom]
-      BevelOuter = bvNone
-      Caption = 'GRID PANEL'
-      TabOrder = 0
-    end
-  end
-end

+ 0 - 110
src/gui/wizards/operations/UWIZChangeAccountPrivateKey_Start.pas

@@ -1,110 +0,0 @@
-unit UWIZChangeAccountPrivateKey_Start;
-
-{$mode delphi}
-{$modeswitch nestedprocvars}
-
-{ Copyright (c) 2018 by Ugochukwu Mmaduekwe
-
-  Distributed under the MIT software license, see the accompanying file LICENSE
-  or visit http://www.opensource.org/licenses/mit-license.php.
-}
-
-interface
-
-uses
-  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
-  ExtCtrls, UVisualGrid, UCommon.Data, UCellRenderers,
-  UWizard, UWIZChangeAccountPrivateKey, UWIZChangeAccountPrivateKey_Transaction, UWIZChangeAccountPrivateKey_Confirmation, UWIZModels;
-
-type
-
-  { TWIZChangeAccountPrivateKey_Start }
-
-  TWIZChangeAccountPrivateKey_Start = class(TWizardForm<TWIZOperationsModel>)
-    grpSelectedAccount: TGroupBox;
-    paGrid: TPanel;
-  private
-    FSendersGrid: TVisualGrid;
-  public
-    procedure OnPresent; override;
-    procedure OnNext; override;
-  end;
-
-
-
-implementation
-
-{$R *.lfm}
-
-uses UAccounts, USettings, UDataSources, UCommon, UCommon.UI, Generics.Collections;
-
-type
-
-  { TAccountSenderDataSource }
-
-  TAccountSenderDataSource = class(TAccountsDataSourceBase)
-  private
-    FModel: TWIZOperationsModel.TChangeAccountPrivateKeyModel;
-  public
-    property Model: TWIZOperationsModel.TChangeAccountPrivateKeyModel read FModel write FModel;
-    procedure FetchAll(const AContainer: TList<TAccount>); override;
-  end;
-
-procedure TAccountSenderDataSource.FetchAll(const AContainer: TList<TAccount>);
-var
-  i: integer;
-begin
-  for i := Low(Model.SelectedAccounts) to High(Model.SelectedAccounts) do
-  begin
-    AContainer.Add(Model.SelectedAccounts[i]);
-  end;
-end;
-
-{ TWIZChangeAccountPrivateKey_Start }
-
-procedure TWIZChangeAccountPrivateKey_Start.OnPresent;
-var
-  Data: TAccountSenderDataSource;
-begin
-  FSendersGrid := TVisualGrid.Create(Self);
-  FSendersGrid.CanSearch := False;
-  FSendersGrid.SortMode := smMultiColumn;
-  FSendersGrid.FetchDataInThread := False;
-  FSendersGrid.AutoPageSize := True;
-  FSendersGrid.SelectionType := stNone;
-  FSendersGrid.Options := [vgoColAutoFill, vgoColSizing, vgoSortDirectionAllowNone,
-    vgoAutoHidePaging];
-  with FSendersGrid.AddColumn('Account') do
-  begin
-    StretchedToFill := True;
-    Binding := 'AccountNumber';
-    SortBinding := 'AccountNumber';
-    DisplayBinding := 'Account';
-    Width := 100;
-    HeaderFontStyles := [fsBold];
-    DataFontStyles := [fsBold];
-    Filters := SORTABLE_NUMERIC_FILTER;
-  end;
-  with FSendersGrid.AddColumn('Balance') do
-  begin
-    Binding := 'BalanceDecimal';
-    SortBinding := 'Balance';
-    DisplayBinding := 'Balance';
-    Width := 100;
-    HeaderAlignment := taRightJustify;
-    DataAlignment := taRightJustify;
-    Renderer := TCellRenderers.PASC;
-    Filters := SORTABLE_NUMERIC_FILTER;
-  end;
-  Data := TAccountSenderDataSource.Create(FSendersGrid);
-  Data.Model := Model.ChangeAccountPrivateKey;
-  FSendersGrid.DataSource := Data;
-  paGrid.AddControlDockCenter(FSendersGrid);
-end;
-
-procedure TWIZChangeAccountPrivateKey_Start.OnNext;
-begin
-   UpdatePath(ptReplaceAllNext, [TWIZChangeAccountPrivateKey_Transaction, TWIZChangeAccountPrivateKey_Confirmation]);
-end;
-
-end.

+ 0 - 106
src/gui/wizards/operations/UWIZChangeAccountPrivateKey_Transaction.lfm

@@ -1,106 +0,0 @@
-object WIZChangeAccountPrivateKey_Transaction: TWIZChangeAccountPrivateKey_Transaction
-  Left = 0
-  Height = 253
-  Top = 0
-  Width = 429
-  ActiveControl = cbSignerAccount
-  Caption = 'WIZChangeAccountPrivateKey_Transaction'
-  ClientHeight = 253
-  ClientWidth = 429
-  LCLVersion = '1.8.2.0'
-  Visible = False
-  object gbTransaction: TGroupBox
-    Left = 24
-    Height = 192
-    Top = 40
-    Width = 384
-    Caption = 'Transaction Details'
-    ClientHeight = 172
-    ClientWidth = 380
-    TabOrder = 0
-    object cbSignerAccount: TComboBox
-      Left = 8
-      Height = 23
-      Top = 8
-      Width = 168
-      ItemHeight = 15
-      Items.Strings = (
-        ''
-      )
-      OnChange = cbSignerAccountChange
-      TabOrder = 0
-      Text = 'Select Signer Account'
-    end
-    object lblBalance: TLabel
-      Left = 200
-      Height = 15
-      Top = 12
-      Width = 151
-      Caption = 'Please Select Signer Account'
-      Font.Color = clRed
-      ParentColor = False
-      ParentFont = False
-    end
-    object lblprivatekey: TLabel
-      Left = 8
-      Height = 15
-      Top = 48
-      Width = 85
-      Caption = 'New Private Key'
-      ParentColor = False
-    end
-    object edtOpFee: TEdit
-      Left = 8
-      Height = 23
-      Top = 144
-      Width = 360
-      TabOrder = 1
-    end
-    object lblOpFee: TLabel
-      Left = 8
-      Height = 15
-      Top = 112
-      Width = 74
-      Caption = 'Operation Fee'
-      ParentColor = False
-    end
-    object cbNewPrivateKey: TComboBox
-      Left = 8
-      Height = 23
-      Top = 74
-      Width = 168
-      ItemHeight = 15
-      OnChange = cbNewPrivateKeyChange
-      TabOrder = 2
-      Text = 'Select Private Key'
-    end
-    object lblKeyName: TLabel
-      Left = 200
-      Height = 15
-      Top = 78
-      Width = 128
-      Caption = 'Please Select Private Key'
-      Font.Color = clRed
-      ParentColor = False
-      ParentFont = False
-    end
-  end
-  object lblTotalBalances: TLabel
-    Left = 24
-    Height = 15
-    Top = 16
-    Width = 176
-    Caption = 'Selected Accounts Total Balance: '
-    ParentColor = False
-  end
-  object lblTotalBalanceValue: TLabel
-    Left = 208
-    Height = 15
-    Top = 16
-    Width = 70
-    Caption = 'Total Balance'
-    Font.Color = clGreen
-    ParentColor = False
-    ParentFont = False
-  end
-end

+ 0 - 210
src/gui/wizards/operations/UWIZChangeAccountPrivateKey_Transaction.pas

@@ -1,210 +0,0 @@
-unit UWIZChangeAccountPrivateKey_Transaction;
-
-{$mode delphi}
-{$modeswitch nestedprocvars}
-
-{ Copyright (c) 2018 by Ugochukwu Mmaduekwe
-
-  Distributed under the MIT software license, see the accompanying file LICENSE
-  or visit http://www.opensource.org/licenses/mit-license.php.
-}
-
-interface
-
-uses
-  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
-  ExtCtrls, Buttons, UCommon, UCommon.Collections, UWallet,
-  UFRMAccountSelect, UNode, UWizard, UWIZChangeAccountPrivateKey,
-  UWIZChangeAccountPrivateKey_TransactionPayload,
-  UWIZChangeAccountPrivateKey_Confirmation, UWIZModels;
-
-type
-
-  { TWIZChangeAccountPrivateKey_Transaction }
-
-  TWIZChangeAccountPrivateKey_Transaction = class(TWizardForm<TWIZOperationsModel>)
-    cbSignerAccount: TComboBox;
-    cbNewPrivateKey: TComboBox;
-    edtOpFee: TEdit;
-    gbTransaction: TGroupBox;
-    lblKeyName: TLabel;
-    lblOpFee: TLabel;
-    lblprivatekey: TLabel;
-    lblTotalBalanceValue: TLabel;
-    lblTotalBalances: TLabel;
-    lblBalance: TLabel;
-    procedure cbNewPrivateKeyChange(Sender: TObject);
-    procedure cbSignerAccountChange(Sender: TObject);
-  private
-    procedure UpdateWalletKeys();
-  public
-    procedure OnPresent; override;
-    procedure OnNext; override;
-    function Validate(out message: ansistring): boolean; override;
-  end;
-
-
-implementation
-
-{$R *.lfm}
-
-uses
-  UAccounts, UCrypto, UUserInterface, USettings;
-
-{ TWIZChangeAccountPrivateKey_Transaction }
-
-procedure TWIZChangeAccountPrivateKey_Transaction.cbSignerAccountChange(Sender: TObject);
-begin
-  if cbSignerAccount.ItemIndex < 1 then
-  begin
-    lblBalance.Font.Color := clRed;
-    lblBalance.Caption := 'Please Select Signer Account';
-  end
-  else
-  begin
-    lblBalance.Font.Color := clGreen;
-    lblBalance.Caption := Format('%s PASC',
-      [TAccountComp.FormatMoney(Model.ChangeAccountPrivateKey.SelectedAccounts[PtrInt(cbSignerAccount.Items.Objects[cbSignerAccount.ItemIndex])].Balance)]);
-  end;
-end;
-
-procedure TWIZChangeAccountPrivateKey_Transaction.cbNewPrivateKeyChange(
-  Sender: TObject);
-var
-  i: integer;
-  wk: TWalletKey;
-begin
-  if cbNewPrivateKey.ItemIndex < 1 then
-  begin
-    lblKeyName.Font.Color := clRed;
-    lblKeyName.Caption := 'Please Select Private Key';
-  end
-  else
-  begin
-    lblKeyName.Font.Color := clGreen;
-    i := PtrInt(cbNewPrivateKey.Items.Objects[cbNewPrivateKey.ItemIndex]);
-    wk := TWallet.Keys.Key[i];
-    lblKeyName.Caption := Format('%s ',
-      [IIF(wk.Name = '', TCrypto.ToHexaString(
-      TAccountComp.AccountKey2RawString(wk.AccountKey)), wk.Name)]);
-  end;
-end;
-
-procedure TWIZChangeAccountPrivateKey_Transaction.UpdateWalletKeys();
-var
-  i: integer;
-  wk: TWalletKey;
-  s: string;
-begin
-  cbNewPrivateKey.items.BeginUpdate;
-  try
-    cbNewPrivateKey.Items.Clear;
-    cbNewPrivateKey.Items.Add('Select Private Key');
-    if not Assigned(TWallet.Keys) then
-    begin
-      Exit;
-    end;
-    for i := 0 to TWallet.Keys.Count - 1 do
-    begin
-      wk := TWallet.Keys.Key[i];
-      s := IIF(wk.Name = '', TCrypto.ToHexaString(TAccountComp.AccountKey2RawString(wk.AccountKey)), wk.Name);
-      if not Assigned(wk.PrivateKey) then
-      begin
-        s := s + '(*)';
-      end;
-      cbNewPrivateKey.Items.AddObject(s, TObject(i));
-    end;
-    cbNewPrivateKey.Sorted := True;
-  finally
-    cbNewPrivateKey.Items.EndUpdate;
-  end;
-end;
-
-procedure TWIZChangeAccountPrivateKey_Transaction.OnPresent;
-
-  function GetAccNoWithChecksum(AAccountNumber: cardinal): string;
-  begin
-    Result := TAccountComp.AccountNumberToAccountTxtNumber(AAccountNumber);
-  end;
-
-var
-  acc: TAccount;
-  accNumberwithChecksum: string;
-  totalBalance: int64;
-  i: integer;
-begin
-  cbSignerAccount.Items.BeginUpdate;
-  totalBalance := 0;
-  try
-    cbSignerAccount.Items.Clear;
-    cbSignerAccount.Items.Add('Select Signer Account');
-    for i := Low(Model.ChangeAccountPrivateKey.SelectedAccounts) to High(Model.ChangeAccountPrivateKey.SelectedAccounts) do
-    begin
-      acc := Model.ChangeAccountPrivateKey.SelectedAccounts[i];
-      accNumberwithChecksum := GetAccNoWithChecksum(acc.account);
-      totalBalance := totalBalance + acc.balance;
-      cbSignerAccount.Items.AddObject(accNumberwithChecksum, TObject(i));
-    end;
-  finally
-    cbSignerAccount.Items.EndUpdate;
-  end;
-  UpdateWalletKeys();
-  cbSignerAccount.ItemIndex := Model.ChangeAccountPrivateKey.SelectedIndex;
-  cbSignerAccountChange(Self);
-  cbNewPrivateKey.ItemIndex := Model.ChangeAccountPrivateKey.PrivateKeySelectedIndex;
-  cbNewPrivateKeyChange(Self);
-  lblTotalBalanceValue.Caption :=
-    Format('%s PASC', [TAccountComp.FormatMoney(totalBalance)]);
-
-  edtOpFee.Text := TAccountComp.FormatMoney(TSettings.DefaultFee);
-end;
-
-procedure TWIZChangeAccountPrivateKey_Transaction.OnNext;
-begin
-  Model.ChangeAccountPrivateKey.SelectedIndex := cbSignerAccount.ItemIndex;
-  Model.ChangeAccountPrivateKey.PrivateKeySelectedIndex := cbNewPrivateKey.ItemIndex;
-  Model.Signer.SignerAccount := Model.ChangeAccountPrivateKey.SelectedAccounts[PtrInt(cbSignerAccount.Items.Objects[cbSignerAccount.ItemIndex])];
-  Model.ChangeAccountPrivateKey.NewWalletKey := TWallet.Keys.Key[PtrInt(cbNewPrivateKey.Items.Objects[cbNewPrivateKey.ItemIndex])];
-
-  UpdatePath(ptReplaceAllNext, [TWIZChangeAccountPrivateKey_TransactionPayload, TWIZChangeAccountPrivateKey_Confirmation]);
-end;
-
-function TWIZChangeAccountPrivateKey_Transaction.Validate(out message: ansistring): boolean;
-var
-  i: integer;
-begin
-  if cbSignerAccount.ItemIndex < 1 then
-  begin
-    message := 'A signer account must be selected';
-    Result := False;
-    Exit;
-  end;
-
-  if cbNewPrivateKey.ItemIndex < 1 then
-  begin
-    message := 'A private key must be selected';
-    Result := False;
-    Exit;
-  end;
-
-  if not TAccountComp.TxtToMoney(Trim(edtOpFee.Text), Model.Fee.DefaultFee) then
-  begin
-    message := 'Invalid fee value "' + edtOpFee.Text + '"';
-    Result := False;
-    Exit;
-  end;
-
-  //Result := TAccountComp.AccountKeyFromImport(edtPublicKey.Text,
-  //  Model.AccountKey, message);
-  //for i := Low(Model.SelectedAccounts) to High(Model.SelectedAccounts) do
-  //begin
-  //  if TAccountComp.EqualAccountKeys(Model.SelectedAccounts[i].accountInfo.accountKey,
-  //    Model.AccountKey) then
-  //  begin
-  //    Result := False;
-  //    message := 'new public key is same as selected account public key';
-  //  end;
-  //end;
-end;
-
-end.

+ 0 - 97
src/gui/wizards/operations/UWIZChangeAccountPrivateKey_TransactionPayload.lfm

@@ -1,97 +0,0 @@
-object WIZChangeAccountPrivateKey_TransactionPayload: TWIZChangeAccountPrivateKey_TransactionPayload
-  Left = 0
-  Height = 253
-  Top = 0
-  Width = 429
-  ActiveControl = mmoPayload
-  Caption = 'Form1'
-  ClientHeight = 253
-  ClientWidth = 429
-  Visible = False
-  object grpPayload: TGroupBox
-    Left = 8
-    Height = 244
-    Top = 2
-    Width = 416
-    Anchors = [akTop, akLeft, akRight, akBottom]
-    Caption = 'Transaction Payload'
-    ClientHeight = 224
-    ClientWidth = 412
-    TabOrder = 0
-    object paPayload: TPanel
-      Left = 8
-      Height = 214
-      Top = 2
-      Width = 396
-      Anchors = [akTop, akLeft, akRight, akBottom]
-      BevelOuter = bvNone
-      ClientHeight = 214
-      ClientWidth = 396
-      TabOrder = 0
-      object mmoPayload: TMemo
-        Left = 0
-        Height = 70
-        Top = 136
-        Width = 386
-        TabOrder = 0
-      end
-      object Label1: TLabel
-        Left = 0
-        Height = 15
-        Top = 118
-        Width = 69
-        Caption = 'Payload Data'
-        ParentColor = False
-      end
-      object rbEncryptedWithOldEC: TRadioButton
-        Left = 3
-        Height = 19
-        Top = 0
-        Width = 176
-        Caption = 'Encrypted with old public key'
-        TabOrder = 1
-      end
-      object rbEncryptedWithEC: TRadioButton
-        Left = 3
-        Height = 19
-        Top = 24
-        Width = 181
-        Caption = 'Encrypted with new public key'
-        Checked = True
-        TabOrder = 2
-        TabStop = True
-      end
-      object rbEncryptedWithPassword: TRadioButton
-        Left = 3
-        Height = 19
-        Top = 48
-        Width = 152
-        Caption = 'Encrypted with password'
-        TabOrder = 3
-      end
-      object lblPassword: TLabel
-        Left = 3
-        Height = 15
-        Top = 73
-        Width = 53
-        Caption = 'Password:'
-        ParentColor = False
-      end
-      object rbNotEncrypted: TRadioButton
-        Left = 3
-        Height = 19
-        Top = 94
-        Width = 181
-        Caption = 'Don''t encrypt (public payload)'
-        TabOrder = 4
-      end
-      object edtPassword: TEdit
-        Left = 64
-        Height = 23
-        Top = 70
-        Width = 160
-        TabOrder = 5
-      end
-    end
-  end
-end

+ 0 - 84
src/gui/wizards/operations/UWIZChangeAccountPrivateKey_TransactionPayload.pas

@@ -1,84 +0,0 @@
-unit UWIZChangeAccountPrivateKey_TransactionPayload;
-
-{$mode delphi}
-{$modeswitch nestedprocvars}
-
-{ Copyright (c) 2018 by Ugochukwu Mmaduekwe
-
-  Distributed under the MIT software license, see the accompanying file LICENSE
-  or visit http://www.opensource.org/licenses/mit-license.php.
-}
-
-interface
-
-uses
-  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
-  ExtCtrls, Buttons, UCommon, UCommon.Collections,
-  UWizard, UWIZChangeAccountPrivateKey, UWIZModels;
-
-type
-
-  { TWIZChangeAccountPrivateKey_TransactionPayload }
-
-  TWIZChangeAccountPrivateKey_TransactionPayload = class(TWizardForm<TWIZOperationsModel>)
-    edtPassword: TEdit;
-    grpPayload: TGroupBox;
-    Label1: TLabel;
-    lblPassword: TLabel;
-    mmoPayload: TMemo;
-    paPayload: TPanel;
-    rbEncryptedWithOldEC: TRadioButton;
-    rbEncryptedWithEC: TRadioButton;
-    rbEncryptedWithPassword: TRadioButton;
-    rbNotEncrypted: TRadioButton;
-  public
-    procedure OnNext; override;
-    function Validate(out message: ansistring): boolean; override;
-  end;
-
-
-implementation
-
-{$R *.lfm}
-
-uses
-  UAccounts, UUserInterface;
-
-{ TWIZChangeAccountPrivateKey_TransactionPayload }
-
-procedure TWIZChangeAccountPrivateKey_TransactionPayload.OnNext;
-begin
-  Model.Payload.Content := mmoPayload.Lines.Text;
-  if rbEncryptedWithOldEC.Checked then
-  begin
-    Model.Payload.Mode := akaEncryptWithSender;
-  end
-  else
-  if rbEncryptedWithEC.Checked then
-  begin
-    Model.Payload.Mode := akaEncryptWithReceiver;
-  end
-  else
-  if rbEncryptedWithPassword.Checked then
-  begin
-    Model.Payload.Mode := akaEncryptWithPassword;
-  end
-  else
-  if rbNotEncrypted.Checked then
-  begin
-    Model.Payload.Mode := akaNotEncrypt;
-  end;
-end;
-
-function TWIZChangeAccountPrivateKey_TransactionPayload.Validate(out message: ansistring): boolean;
-begin
-  if (not rbNotEncrypted.Checked) and (not rbEncryptedWithEC.Checked) and
-    (not rbEncryptedWithOldEC.Checked) and (not rbEncryptedWithPassword.Checked) then
-  begin
-    message := 'you must select an encryption option for payload';
-    Result := False;
-    Exit;
-  end;
-end;
-
-end.

+ 3 - 3
src/gui/wizards/operations/UWIZChangeKey.pas

@@ -36,7 +36,7 @@ uses
   UCoreUtils,
   UWIZChangeKey_ConfirmAccount,
   UWIZChangeKey_SelectOption,
-  UWIZChangeKey_Confirmation;
+  UWIZOperationConfirmation;
 
 { TWIZChangeKeyWizard }
 
@@ -46,7 +46,7 @@ begin
     [
     TWIZChangeKey_ConfirmAccount,
     TWIZChangeKey_SelectOption,
-    TWIZChangeKey_Confirmation
+    TWIZOperationConfirmation
     ]
     );
   TitleText := 'Change Key';
@@ -55,7 +55,7 @@ end;
 
 function TWIZChangeKeyWizard.DetermineHasNext: boolean;
 begin
-  Result := not (CurrentScreen is TWIZChangeKey_Confirmation);
+  Result := not (CurrentScreen is TWIZOperationConfirmation);
 end;
 
 function TWIZChangeKeyWizard.DetermineHasPrevious: boolean;

+ 1 - 7
src/gui/wizards/operations/UWIZChangeKey_ConfirmAccount.pas

@@ -17,7 +17,7 @@ interface
 uses
   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
   ExtCtrls, UVisualGrid, UCommon.Data, UCellRenderers,
-  UWizard, UWIZSendPASC, UWIZChangeKey_SelectOption, UWIZChangeKey_Confirmation, UWIZModels;
+  UWizard, UWIZModels;
 
 type
 
@@ -32,7 +32,6 @@ type
     FChangeKeyGrid: TVisualGrid;
   public
     procedure OnPresent; override;
-    procedure OnNext; override;
     function Validate(out message: ansistring): boolean; override;
   end;
 
@@ -110,11 +109,6 @@ begin
     Format('%s PASC', [TAccountComp.FormatMoney(totalBalance)]);
 end;
 
-procedure TWIZChangeKey_ConfirmAccount.OnNext;
-begin
-  UpdatePath(ptReplaceAllNext, [TWIZChangeKey_SelectOption, TWIZChangeKey_Confirmation]);
-end;
-
 function TWIZChangeKey_ConfirmAccount.Validate(out message: ansistring): boolean;
 begin
   Result := True;

+ 1 - 1
src/gui/wizards/operations/UWIZChangeKey_SelectOption.pas

@@ -17,7 +17,7 @@ interface
 
 uses
   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
-  ExtCtrls, UWizard, UWIZChangeKey, UWIZModels, UWIZChangeKey_EnterKey, UWIZChangeKey_SelectKey;
+  ExtCtrls, UWizard, UWIZModels, UWIZChangeKey_EnterKey, UWIZChangeKey_SelectKey;
 
 type
 

+ 0 - 453
src/gui/wizards/operations/UWIZConfirmAccount.pas

@@ -1,453 +0,0 @@
-unit UWIZChangeKey;
-
-{$mode delphi}
-
-{ Copyright (c) 2018 by Ugochukwu Mmaduekwe
-
-  Distributed under the MIT software license, see the accompanying file LICENSE
-  or visit http://www.opensource.org/licenses/mit-license.php.
-
-  Acknowledgements:
-    Herman Schoenfeld <[email protected]>: added grid-based layout
-}
-
-interface
-
-uses
-  Classes, SysUtils, Forms, Dialogs, UCrypto, UCommon, UWizard, UAccounts, LCLType, UWIZModels;
-
-type
-
-  { TWIZChangeKeyWizard }
-
-  TWIZChangeKeyWizard = class(TWizard<TWIZOperationsModel>)
-  private
-    function UpdatePayload(const SenderAccount: TAccount; var errors: string): boolean;
-    function UpdateOperationOptions(var errors: string): boolean;
-    function UpdateOpChangeKey(const TargetAccount: TAccount; var SignerAccount: TAccount; var NewPublicKey: TAccountKey; var errors: ansistring): boolean;
-    procedure WIZChangeKeyOwnership();
-  public
-    constructor Create(AOwner: TComponent); override;
-    function DetermineHasNext: boolean; override;
-    function DetermineHasPrevious: boolean; override;
-    function FinishRequested(out message: ansistring): boolean; override;
-    function CancelRequested(out message: ansistring): boolean; override;
-  end;
-
-implementation
-
-uses
-  UBlockChain,
-  UOpTransaction,
-  UNode,
-  UConst,
-  UWallet,
-  UECIES,
-  UAES,
-  UWIZChangeKey_Start,
-  UWIZChangeKey_Confirmation;
-
-{ TWIZChangeKeyWizard }
-
-function TWIZChangeKeyWizard.UpdatePayload(const SenderAccount: TAccount; var errors: string): boolean;
-var
-  valid: boolean;
-  payload_encrypted, payload_u: string;
-  account: TAccount;
-begin
-  valid := False;
-  payload_encrypted := '';
-  Model.Payload.EncodedBytes := '';
-  errors := 'Unknown error';
-  payload_u := Model.Payload.Content;
-
-  try
-    if (payload_u = '') then
-    begin
-      valid := True;
-      Exit;
-    end;
-    case Model.Payload.Mode of
-
-      akaEncryptWithSender:
-      begin
-        // Use sender
-        errors := 'Error encrypting';
-        account := SenderAccount;
-        payload_encrypted := ECIESEncrypt(account.accountInfo.accountKey, payload_u);
-        valid := payload_encrypted <> '';
-      end;
-
-      akaEncryptWithReceiver:
-      begin
-        errors := 'Public key: ' + 'Error encrypting';
-
-        if Model.WIZChangeKey.AccountKey.EC_OpenSSL_NID <>
-          CT_Account_NUL.accountInfo.accountKey.EC_OpenSSL_NID then
-        begin
-          payload_encrypted := ECIESEncrypt(Model.WIZChangeKey.AccountKey, payload_u);
-          valid := payload_encrypted <> '';
-        end
-        else
-        begin
-          valid := False;
-          errors := 'Selected private key is not valid to encode';
-          exit;
-        end;
-      end;
-
-      akaEncryptWithPassword:
-      begin
-        payload_encrypted := TAESComp.EVP_Encrypt_AES256(
-          payload_u, Model.Payload.Password);
-        valid := payload_encrypted <> '';
-      end;
-
-      akaNotEncrypt:
-      begin
-        payload_encrypted := payload_u;
-        valid := True;
-      end
-
-      else
-      begin
-        raise Exception.Create('Invalid Encryption Selection');
-      end;
-    end;
-
-  finally
-    if valid then
-    begin
-      if length(payload_encrypted) > CT_MaxPayloadSize then
-      begin
-        valid := False;
-        errors := 'Payload size is bigger than ' + IntToStr(CT_MaxPayloadSize) +
-          ' (' + IntToStr(length(payload_encrypted)) + ')';
-      end;
-
-    end;
-    Model.Payload.EncodedBytes := payload_encrypted;
-    Result := valid;
-  end;
-
-end;
-
-function TWIZChangeKeyWizard.UpdateOperationOptions(var errors: string): boolean;
-var
-  iAcc, iWallet: integer;
-  sender_account, signer_account: TAccount;
-  publicKey: TAccountKey;
-  wk: TWalletKey;
-  e: string;
-  amount: int64;
-begin
-  Result := False;
-  errors := '';
-  if not Assigned(TWallet.Keys) then
-  begin
-    errors := 'No wallet keys';
-    Exit;
-  end;
-
-  if Length(Model.WIZChangeKey.SelectedAccounts) = 0 then
-  begin
-    errors := 'No sender account';
-    Exit;
-  end
-  else
-  begin
-
-    for iAcc := Low(Model.WIZChangeKey.SelectedAccounts) to High(Model.WIZChangeKey.SelectedAccounts) do
-    begin
-      sender_account := Model.WIZChangeKey.SelectedAccounts[iAcc];
-      iWallet := TWallet.Keys.IndexOfAccountKey(sender_account.accountInfo.accountKey);
-      if (iWallet < 0) then
-      begin
-        errors := 'Private key of account ' +
-          TAccountComp.AccountNumberToAccountTxtNumber(sender_account.account) +
-          ' not found in wallet';
-        Exit;
-      end;
-      wk := TWallet.Keys.Key[iWallet];
-      if not assigned(wk.PrivateKey) then
-      begin
-        if wk.CryptedKey <> '' then
-        begin
-          // TODO: handle unlocking of encrypted wallet here
-          errors := 'Wallet is password protected. Need password';
-        end
-        else
-        begin
-          errors := 'Only public key of account ' +
-            TAccountComp.AccountNumberToAccountTxtNumber(sender_account.account) +
-            ' found in wallet. You cannot operate with this account';
-        end;
-        Exit;
-      end;
-    end;
-  end;
-
-  Result := UpdateOpChangeKey(Model.WIZChangeKey.SelectedAccounts[0], signer_account,
-    publicKey, errors);
-  UpdatePayload(sender_account, e);
-end;
-
-function TWIZChangeKeyWizard.UpdateOpChangeKey(const TargetAccount: TAccount;
-  var SignerAccount: TAccount; var NewPublicKey: TAccountKey;
-  var errors: ansistring): boolean;
-begin
-  Result := False;
-  errors := '';
-  try
-    if not TAccountComp.AccountKeyFromImport(Model.WIZChangeKey.NewPublicKey,
-      NewPublicKey, errors) then
-    begin
-      Exit;
-    end;
-
-    if TNode.Node.Bank.SafeBox.CurrentProtocol >= 1 then
-    begin
-      // Signer:
-      SignerAccount := Model.Signer.SignerAccount;
-      if (TAccountComp.IsAccountLocked(SignerAccount.accountInfo,
-        TNode.Node.Bank.BlocksCount)) then
-      begin
-        errors := 'Signer account ' + TAccountComp.AccountNumberToAccountTxtNumber(
-          SignerAccount.account) + ' is locked until block ' + IntToStr(
-          SignerAccount.accountInfo.locked_until_block);
-        exit;
-      end;
-      if (not TAccountComp.EqualAccountKeys(
-        SignerAccount.accountInfo.accountKey, TargetAccount.accountInfo.accountKey)) then
-      begin
-        errors := 'Signer account ' + TAccountComp.AccountNumberToAccountTxtNumber(
-          SignerAccount.account) + ' is not owner of account ' +
-          TAccountComp.AccountNumberToAccountTxtNumber(TargetAccount.account);
-        exit;
-      end;
-    end
-    else
-    begin
-      SignerAccount := TargetAccount;
-    end;
-
-    if (TAccountComp.EqualAccountKeys(TargetAccount.accountInfo.accountKey,
-      NewPublicKey)) then
-    begin
-      errors := 'New public key is the same public key';
-      exit;
-    end;
-
-  finally
-    Result := errors = '';
-  end;
-end;
-
-procedure TWIZChangeKeyWizard.WIZChangeKeyOwnership();
-var
-  _V2, dooperation: boolean;
-  iAcc, i: integer;
-  _totalamount, _totalfee, _totalSignerFee, _amount, _fee: int64;
-  _signer_n_ops: cardinal;
-  operationstxt, operation_to_string, errors, auxs: string;
-  wk: TWalletKey;
-  ops: TOperationsHashTree;
-  op: TPCOperation;
-  account, signerAccount: TAccount;
-  _newOwnerPublicKey: TECDSA_Public;
-label
-  loop_start;
-begin
-  if not Assigned(TWallet.Keys) then
-    raise Exception.Create('No wallet keys');
-  if not UpdateOperationOptions(errors) then
-    raise Exception.Create(errors);
-  ops := TOperationsHashTree.Create;
-
-  try
-    _V2 := TNode.Node.Bank.SafeBox.CurrentProtocol >= CT_PROTOCOL_2;
-    _totalamount := 0;
-    _totalfee := 0;
-    _totalSignerFee := 0;
-    _signer_n_ops := 0;
-    operationstxt := '';
-    operation_to_string := '';
-    for iAcc := Low(Model.WIZChangeKey.SelectedAccounts) to High(Model.WIZChangeKey.SelectedAccounts) do
-    begin
-      loop_start:
-        op := nil;
-      account := Model.WIZChangeKey.SelectedAccounts[iAcc];
-      if not UpdatePayload(account, errors) then
-      begin
-        raise Exception.Create('Error encoding payload of sender account ' +
-          TAccountComp.AccountNumberToAccountTxtNumber(account.account) + ': ' + errors);
-      end;
-      i := TWallet.Keys.IndexOfAccountKey(account.accountInfo.accountKey);
-      if i < 0 then
-      begin
-        raise Exception.Create('Sender account private key not found in Wallet');
-      end;
-
-      wk := TWallet.Keys.Key[i];
-      dooperation := True;
-      // Default fee
-      if account.balance > uint64(Model.Fee.DefaultFee) then
-        _fee := Model.Fee.DefaultFee
-      else
-        _fee := account.balance;
-
-      if not UpdateOpChangeKey(account, signerAccount, _newOwnerPublicKey, errors) then
-      begin
-        raise Exception.Create(errors);
-      end;
-      if _V2 then
-      begin
-        // must ensure is Signer account last if included in sender accounts (not necessarily ordered enumeration)
-        if (iAcc < Length(Model.WIZChangeKey.SelectedAccounts) - 1) and
-          (account.account = signerAccount.account) then
-        begin
-          TArrayTool<TAccount>.Swap(Model.WIZChangeKey.SelectedAccounts, iAcc,
-            Length(Model.WIZChangeKey.SelectedAccounts) - 1); // ensure signer account processed last
-          // TArrayTool_internal<Cardinal>.Swap(_senderAccounts, iAcc, Length(_senderAccounts) - 1);
-          goto loop_start; // TODO: remove ugly hack with refactoring!
-        end;
-
-        // Maintain correct signer fee distribution
-        if uint64(_totalSignerFee) >= signerAccount.balance then
-          _fee := 0
-        else if signerAccount.balance - uint64(_totalSignerFee) >
-          uint64(Model.Fee.DefaultFee) then
-          _fee := Model.Fee.DefaultFee
-        else
-          _fee := signerAccount.balance - uint64(_totalSignerFee);
-        op := TOpChangeKeySigned.Create(signerAccount.account,
-          signerAccount.n_operation + _signer_n_ops + 1, account.account,
-          wk.PrivateKey, _newOwnerPublicKey, _fee, Model.Payload.EncodedBytes);
-        Inc(_signer_n_ops);
-        Inc(_totalSignerFee, _fee);
-      end
-      else
-      begin
-        op := TOpChangeKey.Create(account.account, account.n_operation +
-          1, account.account, wk.PrivateKey, _newOwnerPublicKey, _fee, Model.Payload.EncodedBytes);
-      end;
-      Inc(_totalfee, _fee);
-      operationstxt :=
-        'Change private key to ' + TAccountComp.GetECInfoTxt(
-        _newOwnerPublicKey.EC_OpenSSL_NID);
-
-      if Assigned(op) and (dooperation) then
-      begin
-        ops.AddOperationToHashTree(op);
-        if operation_to_string <> '' then
-          operation_to_string := operation_to_string + #10;
-        operation_to_string := operation_to_string + op.ToString;
-      end;
-      FreeAndNil(op);
-    end;
-
-    if (ops.OperationsCount = 0) then
-      raise Exception.Create('No valid operation to execute');
-
-    if (Length(Model.WIZChangeKey.SelectedAccounts) > 1) then
-    begin
-      auxs := '';
-      if Application.MessageBox(
-        PChar('Execute ' + IntToStr(Length(Model.WIZChangeKey.SelectedAccounts)) +
-        ' operations?' + #10 + 'Operation: ' + operationstxt + #10 +
-        auxs + 'Total fee: ' + TAccountComp.FormatMoney(_totalfee) +
-        #10 + #10 + 'Note: This operation will be transmitted to the network!'),
-        PChar(Application.Title), MB_YESNO + MB_ICONINFORMATION + MB_DEFBUTTON2) <>
-        idYes then
-      begin
-        Exit;
-      end;
-    end
-    else
-    begin
-      if Application.MessageBox(PChar('Execute this operation:' + #10 +
-        #10 + operation_to_string + #10 + #10 +
-        'Note: This operation will be transmitted to the network!'),
-        PChar(Application.Title), MB_YESNO + MB_ICONINFORMATION + MB_DEFBUTTON2) <> idYes then
-      begin
-        Exit;
-      end;
-    end;
-    i := TNode.Node.AddOperations(nil, ops, nil, errors);
-    if (i = ops.OperationsCount) then
-    begin
-      operationstxt := 'Successfully executed ' + IntToStr(i) +
-        ' operations!' + #10 + #10 + operation_to_string;
-      if i > 1 then
-      begin
-
-        ShowMessage(operationstxt);
-      end
-      else
-      begin
-        Application.MessageBox(
-          PChar('Successfully executed ' + IntToStr(i) + ' operations!' +
-          #10 + #10 + operation_to_string),
-          PChar(Application.Title), MB_OK + MB_ICONINFORMATION);
-      end;
-
-    end
-    else if (i > 0) then
-    begin
-      operationstxt := 'One or more of your operations has not been executed:' +
-        #10 + 'Errors:' + #10 + errors + #10 + #10 +
-        'Total successfully executed operations: ' + IntToStr(i);
-
-      ShowMessage(operationstxt);
-    end
-    else
-    begin
-      raise Exception.Create(errors);
-    end;
-
-
-  finally
-    ops.Free;
-  end;
-
-end;
-
-constructor TWIZChangeKeyWizard.Create(AOwner: TComponent);
-begin
-  inherited Create(AOwner, [TWIZChangeKey_Start,
-    TWIZChangeKey_Confirmation]);
-  TitleText := 'Transfer Account';
-  FinishText := 'Transfer Account';
-end;
-
-function TWIZChangeKeyWizard.DetermineHasNext: boolean;
-begin
-  Result := not (CurrentScreen is TWIZChangeKey_Confirmation);
-end;
-
-function TWIZChangeKeyWizard.DetermineHasPrevious: boolean;
-begin
-  Result := inherited DetermineHasPrevious;
-end;
-
-function TWIZChangeKeyWizard.FinishRequested(out message: ansistring): boolean;
-begin
-  // Execute the Transfer Account Action here
-  try
-    Result := True;
-    WIZChangeKeyOwnership();
-  except
-    On E: Exception do
-    begin
-      Result := False;
-      message := E.ToString;
-    end;
-  end;
-end;
-
-function TWIZChangeKeyWizard.CancelRequested(out message: ansistring): boolean;
-begin
-  Result := True;
-end;
-
-end.

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

@@ -6,6 +6,7 @@ object WIZOperationConfirmation: TWIZOperationConfirmation
   Caption = 'WIZOperationConfirmation'
   ClientHeight = 320
   ClientWidth = 511
+  LCLVersion = '1.8.2.0'
   Visible = False
   object GroupBox1: TGroupBox
     Left = 10

+ 38 - 1
src/gui/wizards/operations/UWIZOperationConfirmation.pas

@@ -42,7 +42,7 @@ implementation
 
 {$R *.lfm}
 
-uses UAccounts, UConst, UWallet, UUserInterface, UDataSources, UCommon, UCommon.UI, Generics.Collections, UCoreUtils;
+uses UAccounts, UCrypto, UConst, UWallet, UUserInterface, UDataSources, UCommon, UCommon.UI, Generics.Collections, UCoreUtils;
 
 type
 
@@ -153,7 +153,25 @@ end;
 function TAccountSenderDataSource.GetItemField(constref AItem: TAccount; const ABindingName: ansistring): variant;
 var
   LAmount: string;
+  LCurrentAccountKey, LDestinationAccountKey: TAccountKey;
 begin
+
+  case Model.ChangeKey.ChangeKeyMode of
+    akaTransferAccountOwnership:
+    begin
+      LCurrentAccountKey := AItem.accountInfo.accountKey;
+      LDestinationAccountKey := Model.TransferAccount.AccountKey;
+    end;
+    akaChangeAccountPrivateKey:
+    begin
+      LCurrentAccountKey := AItem.accountInfo.accountKey;
+      LDestinationAccountKey := Model.ChangeAccountPrivateKey.NewWalletKey.AccountKey;
+    end
+
+    else
+      raise ENotSupportedException.Create('ChangeKeyMode');
+  end;
+
   if ABindingName = 'Operation' then
     case Model.ModelType of
       omtSendPasc:
@@ -161,11 +179,30 @@ begin
         Result := IIF(Model.SendPASC.SendPASCMode = akaAllBalance, 'All Balance', Format('%s ', [TAccountComp.FormatMoney(Model.SendPASC.SingleAmountToSend)]));
         Result := Format('%s %s', [TOperationsManager.GetOperationShortText(CT_Op_Transaction, CT_OpSubtype_TransactionSender), Result]);
       end;
+      omtChangeKey:
+        Result := Format('%s', [TOperationsManager.GetOperationShortText(CT_Op_ChangeKeySigned, CT_OpSubtype_ChangeKey)]);
     end
   else if ABindingName = 'Recipient' then
     case Model.ModelType of
       omtSendPasc:
         Result := Model.SendPASC.DestinationAccount.AccountString;
+      omtChangeKey:
+        case Model.ChangeKey.ChangeKeyMode of
+          akaTransferAccountOwnership: Result := TAccountComp.AccountPublicKeyExport(Model.TransferAccount.AccountKey);
+          akaChangeAccountPrivateKey:
+          begin
+            Result := IIF(
+              Model.ChangeAccountPrivateKey.NewWalletKey.Name = '',
+              TCrypto.ToHexaString(TAccountComp.AccountKey2RawString(Model.ChangeAccountPrivateKey.NewWalletKey.AccountKey)),
+              Model.ChangeAccountPrivateKey.NewWalletKey.Name
+              );
+            if not Assigned(Model.ChangeAccountPrivateKey.NewWalletKey.PrivateKey) then
+              Result := Result + '(*)';
+          end
+          else
+            raise ENotSupportedException.Create('ChangeKeyMode');
+        end
+
     end
   else if ABindingName = 'Fee' then
     Result := -Model.Fee.SingleOperationFee

+ 0 - 453
src/gui/wizards/operations/UWIZTransferAccount.pas

@@ -1,453 +0,0 @@
-unit UWIZTransferAccount;
-
-{$mode delphi}
-
-{ Copyright (c) 2018 by Ugochukwu Mmaduekwe
-
-  Distributed under the MIT software license, see the accompanying file LICENSE
-  or visit http://www.opensource.org/licenses/mit-license.php.
-
-  Acknowledgements:
-    Herman Schoenfeld <[email protected]>: added grid-based layout
-}
-
-interface
-
-uses
-  Classes, SysUtils, Forms, Dialogs, UCrypto, UCommon, UWizard, UAccounts, LCLType, UWIZModels;
-
-type
-
-  { TWIZTransferAccountWizard }
-
-  TWIZTransferAccountWizard = class(TWizard<TWIZOperationsModel>)
-  private
-    function UpdatePayload(const SenderAccount: TAccount; var errors: string): boolean;
-    function UpdateOperationOptions(var errors: string): boolean;
-    function UpdateOpChangeKey(const TargetAccount: TAccount; var SignerAccount: TAccount; var NewPublicKey: TAccountKey; var errors: ansistring): boolean;
-    procedure TransferAccountOwnership();
-  public
-    constructor Create(AOwner: TComponent); override;
-    function DetermineHasNext: boolean; override;
-    function DetermineHasPrevious: boolean; override;
-    function FinishRequested(out message: ansistring): boolean; override;
-    function CancelRequested(out message: ansistring): boolean; override;
-  end;
-
-implementation
-
-uses
-  UBlockChain,
-  UOpTransaction,
-  UNode,
-  UConst,
-  UWallet,
-  UECIES,
-  UAES,
-  UWIZTransferAccount_Start,
-  UWIZTransferAccount_Confirmation;
-
-{ TWIZTransferAccountWizard }
-
-function TWIZTransferAccountWizard.UpdatePayload(const SenderAccount: TAccount; var errors: string): boolean;
-var
-  valid: boolean;
-  payload_encrypted, payload_u: string;
-  account: TAccount;
-begin
-  valid := False;
-  payload_encrypted := '';
-  Model.Payload.EncodedBytes := '';
-  errors := 'Unknown error';
-  payload_u := Model.Payload.Content;
-
-  try
-    if (payload_u = '') then
-    begin
-      valid := True;
-      Exit;
-    end;
-    case Model.Payload.Mode of
-
-      akaEncryptWithSender:
-      begin
-        // Use sender
-        errors := 'Error encrypting';
-        account := SenderAccount;
-        payload_encrypted := ECIESEncrypt(account.accountInfo.accountKey, payload_u);
-        valid := payload_encrypted <> '';
-      end;
-
-      akaEncryptWithReceiver:
-      begin
-        errors := 'Public key: ' + 'Error encrypting';
-
-        if Model.TransferAccount.AccountKey.EC_OpenSSL_NID <>
-          CT_Account_NUL.accountInfo.accountKey.EC_OpenSSL_NID then
-        begin
-          payload_encrypted := ECIESEncrypt(Model.TransferAccount.AccountKey, payload_u);
-          valid := payload_encrypted <> '';
-        end
-        else
-        begin
-          valid := False;
-          errors := 'Selected private key is not valid to encode';
-          exit;
-        end;
-      end;
-
-      akaEncryptWithPassword:
-      begin
-        payload_encrypted := TAESComp.EVP_Encrypt_AES256(
-          payload_u, Model.Payload.Password);
-        valid := payload_encrypted <> '';
-      end;
-
-      akaNotEncrypt:
-      begin
-        payload_encrypted := payload_u;
-        valid := True;
-      end
-
-      else
-      begin
-        raise Exception.Create('Invalid Encryption Selection');
-      end;
-    end;
-
-  finally
-    if valid then
-    begin
-      if length(payload_encrypted) > CT_MaxPayloadSize then
-      begin
-        valid := False;
-        errors := 'Payload size is bigger than ' + IntToStr(CT_MaxPayloadSize) +
-          ' (' + IntToStr(length(payload_encrypted)) + ')';
-      end;
-
-    end;
-    Model.Payload.EncodedBytes := payload_encrypted;
-    Result := valid;
-  end;
-
-end;
-
-function TWIZTransferAccountWizard.UpdateOperationOptions(var errors: string): boolean;
-var
-  iAcc, iWallet: integer;
-  sender_account, signer_account: TAccount;
-  publicKey: TAccountKey;
-  wk: TWalletKey;
-  e: string;
-  amount: int64;
-begin
-  Result := False;
-  errors := '';
-  if not Assigned(TWallet.Keys) then
-  begin
-    errors := 'No wallet keys';
-    Exit;
-  end;
-
-  if Length(Model.TransferAccount.SelectedAccounts) = 0 then
-  begin
-    errors := 'No sender account';
-    Exit;
-  end
-  else
-  begin
-
-    for iAcc := Low(Model.TransferAccount.SelectedAccounts) to High(Model.TransferAccount.SelectedAccounts) do
-    begin
-      sender_account := Model.TransferAccount.SelectedAccounts[iAcc];
-      iWallet := TWallet.Keys.IndexOfAccountKey(sender_account.accountInfo.accountKey);
-      if (iWallet < 0) then
-      begin
-        errors := 'Private key of account ' +
-          TAccountComp.AccountNumberToAccountTxtNumber(sender_account.account) +
-          ' not found in wallet';
-        Exit;
-      end;
-      wk := TWallet.Keys.Key[iWallet];
-      if not assigned(wk.PrivateKey) then
-      begin
-        if wk.CryptedKey <> '' then
-        begin
-          // TODO: handle unlocking of encrypted wallet here
-          errors := 'Wallet is password protected. Need password';
-        end
-        else
-        begin
-          errors := 'Only public key of account ' +
-            TAccountComp.AccountNumberToAccountTxtNumber(sender_account.account) +
-            ' found in wallet. You cannot operate with this account';
-        end;
-        Exit;
-      end;
-    end;
-  end;
-
-  Result := UpdateOpChangeKey(Model.TransferAccount.SelectedAccounts[0], signer_account,
-    publicKey, errors);
-  UpdatePayload(sender_account, e);
-end;
-
-function TWIZTransferAccountWizard.UpdateOpChangeKey(const TargetAccount: TAccount;
-  var SignerAccount: TAccount; var NewPublicKey: TAccountKey;
-  var errors: ansistring): boolean;
-begin
-  Result := False;
-  errors := '';
-  try
-    if not TAccountComp.AccountKeyFromImport(Model.TransferAccount.NewPublicKey,
-      NewPublicKey, errors) then
-    begin
-      Exit;
-    end;
-
-    if TNode.Node.Bank.SafeBox.CurrentProtocol >= 1 then
-    begin
-      // Signer:
-      SignerAccount := Model.Signer.SignerAccount;
-      if (TAccountComp.IsAccountLocked(SignerAccount.accountInfo,
-        TNode.Node.Bank.BlocksCount)) then
-      begin
-        errors := 'Signer account ' + TAccountComp.AccountNumberToAccountTxtNumber(
-          SignerAccount.account) + ' is locked until block ' + IntToStr(
-          SignerAccount.accountInfo.locked_until_block);
-        exit;
-      end;
-      if (not TAccountComp.EqualAccountKeys(
-        SignerAccount.accountInfo.accountKey, TargetAccount.accountInfo.accountKey)) then
-      begin
-        errors := 'Signer account ' + TAccountComp.AccountNumberToAccountTxtNumber(
-          SignerAccount.account) + ' is not owner of account ' +
-          TAccountComp.AccountNumberToAccountTxtNumber(TargetAccount.account);
-        exit;
-      end;
-    end
-    else
-    begin
-      SignerAccount := TargetAccount;
-    end;
-
-    if (TAccountComp.EqualAccountKeys(TargetAccount.accountInfo.accountKey,
-      NewPublicKey)) then
-    begin
-      errors := 'New public key is the same public key';
-      exit;
-    end;
-
-  finally
-    Result := errors = '';
-  end;
-end;
-
-procedure TWIZTransferAccountWizard.TransferAccountOwnership();
-var
-  _V2, dooperation: boolean;
-  iAcc, i: integer;
-  _totalamount, _totalfee, _totalSignerFee, _amount, _fee: int64;
-  _signer_n_ops: cardinal;
-  operationstxt, operation_to_string, errors, auxs: string;
-  wk: TWalletKey;
-  ops: TOperationsHashTree;
-  op: TPCOperation;
-  account, signerAccount: TAccount;
-  _newOwnerPublicKey: TECDSA_Public;
-label
-  loop_start;
-begin
-  if not Assigned(TWallet.Keys) then
-    raise Exception.Create('No wallet keys');
-  if not UpdateOperationOptions(errors) then
-    raise Exception.Create(errors);
-  ops := TOperationsHashTree.Create;
-
-  try
-    _V2 := TNode.Node.Bank.SafeBox.CurrentProtocol >= CT_PROTOCOL_2;
-    _totalamount := 0;
-    _totalfee := 0;
-    _totalSignerFee := 0;
-    _signer_n_ops := 0;
-    operationstxt := '';
-    operation_to_string := '';
-    for iAcc := Low(Model.TransferAccount.SelectedAccounts) to High(Model.TransferAccount.SelectedAccounts) do
-    begin
-      loop_start:
-        op := nil;
-      account := Model.TransferAccount.SelectedAccounts[iAcc];
-      if not UpdatePayload(account, errors) then
-      begin
-        raise Exception.Create('Error encoding payload of sender account ' +
-          TAccountComp.AccountNumberToAccountTxtNumber(account.account) + ': ' + errors);
-      end;
-      i := TWallet.Keys.IndexOfAccountKey(account.accountInfo.accountKey);
-      if i < 0 then
-      begin
-        raise Exception.Create('Sender account private key not found in Wallet');
-      end;
-
-      wk := TWallet.Keys.Key[i];
-      dooperation := True;
-      // Default fee
-      if account.balance > uint64(Model.Fee.DefaultFee) then
-        _fee := Model.Fee.DefaultFee
-      else
-        _fee := account.balance;
-
-      if not UpdateOpChangeKey(account, signerAccount, _newOwnerPublicKey, errors) then
-      begin
-        raise Exception.Create(errors);
-      end;
-      if _V2 then
-      begin
-        // must ensure is Signer account last if included in sender accounts (not necessarily ordered enumeration)
-        if (iAcc < Length(Model.TransferAccount.SelectedAccounts) - 1) and
-          (account.account = signerAccount.account) then
-        begin
-          TArrayTool<TAccount>.Swap(Model.TransferAccount.SelectedAccounts, iAcc,
-            Length(Model.TransferAccount.SelectedAccounts) - 1); // ensure signer account processed last
-          // TArrayTool_internal<Cardinal>.Swap(_senderAccounts, iAcc, Length(_senderAccounts) - 1);
-          goto loop_start; // TODO: remove ugly hack with refactoring!
-        end;
-
-        // Maintain correct signer fee distribution
-        if uint64(_totalSignerFee) >= signerAccount.balance then
-          _fee := 0
-        else if signerAccount.balance - uint64(_totalSignerFee) >
-          uint64(Model.Fee.DefaultFee) then
-          _fee := Model.Fee.DefaultFee
-        else
-          _fee := signerAccount.balance - uint64(_totalSignerFee);
-        op := TOpChangeKeySigned.Create(signerAccount.account,
-          signerAccount.n_operation + _signer_n_ops + 1, account.account,
-          wk.PrivateKey, _newOwnerPublicKey, _fee, Model.Payload.EncodedBytes);
-        Inc(_signer_n_ops);
-        Inc(_totalSignerFee, _fee);
-      end
-      else
-      begin
-        op := TOpChangeKey.Create(account.account, account.n_operation +
-          1, account.account, wk.PrivateKey, _newOwnerPublicKey, _fee, Model.Payload.EncodedBytes);
-      end;
-      Inc(_totalfee, _fee);
-      operationstxt :=
-        'Change private key to ' + TAccountComp.GetECInfoTxt(
-        _newOwnerPublicKey.EC_OpenSSL_NID);
-
-      if Assigned(op) and (dooperation) then
-      begin
-        ops.AddOperationToHashTree(op);
-        if operation_to_string <> '' then
-          operation_to_string := operation_to_string + #10;
-        operation_to_string := operation_to_string + op.ToString;
-      end;
-      FreeAndNil(op);
-    end;
-
-    if (ops.OperationsCount = 0) then
-      raise Exception.Create('No valid operation to execute');
-
-    if (Length(Model.TransferAccount.SelectedAccounts) > 1) then
-    begin
-      auxs := '';
-      if Application.MessageBox(
-        PChar('Execute ' + IntToStr(Length(Model.TransferAccount.SelectedAccounts)) +
-        ' operations?' + #10 + 'Operation: ' + operationstxt + #10 +
-        auxs + 'Total fee: ' + TAccountComp.FormatMoney(_totalfee) +
-        #10 + #10 + 'Note: This operation will be transmitted to the network!'),
-        PChar(Application.Title), MB_YESNO + MB_ICONINFORMATION + MB_DEFBUTTON2) <>
-        idYes then
-      begin
-        Exit;
-      end;
-    end
-    else
-    begin
-      if Application.MessageBox(PChar('Execute this operation:' + #10 +
-        #10 + operation_to_string + #10 + #10 +
-        'Note: This operation will be transmitted to the network!'),
-        PChar(Application.Title), MB_YESNO + MB_ICONINFORMATION + MB_DEFBUTTON2) <> idYes then
-      begin
-        Exit;
-      end;
-    end;
-    i := TNode.Node.AddOperations(nil, ops, nil, errors);
-    if (i = ops.OperationsCount) then
-    begin
-      operationstxt := 'Successfully executed ' + IntToStr(i) +
-        ' operations!' + #10 + #10 + operation_to_string;
-      if i > 1 then
-      begin
-
-        ShowMessage(operationstxt);
-      end
-      else
-      begin
-        Application.MessageBox(
-          PChar('Successfully executed ' + IntToStr(i) + ' operations!' +
-          #10 + #10 + operation_to_string),
-          PChar(Application.Title), MB_OK + MB_ICONINFORMATION);
-      end;
-
-    end
-    else if (i > 0) then
-    begin
-      operationstxt := 'One or more of your operations has not been executed:' +
-        #10 + 'Errors:' + #10 + errors + #10 + #10 +
-        'Total successfully executed operations: ' + IntToStr(i);
-
-      ShowMessage(operationstxt);
-    end
-    else
-    begin
-      raise Exception.Create(errors);
-    end;
-
-
-  finally
-    ops.Free;
-  end;
-
-end;
-
-constructor TWIZTransferAccountWizard.Create(AOwner: TComponent);
-begin
-  inherited Create(AOwner, [TWIZTransferAccount_Start,
-    TWIZTransferAccount_Confirmation]);
-  TitleText := 'Transfer Account';
-  FinishText := 'Transfer Account';
-end;
-
-function TWIZTransferAccountWizard.DetermineHasNext: boolean;
-begin
-  Result := not (CurrentScreen is TWIZTransferAccount_Confirmation);
-end;
-
-function TWIZTransferAccountWizard.DetermineHasPrevious: boolean;
-begin
-  Result := inherited DetermineHasPrevious;
-end;
-
-function TWIZTransferAccountWizard.FinishRequested(out message: ansistring): boolean;
-begin
-  // Execute the Transfer Account Action here
-  try
-    Result := True;
-    TransferAccountOwnership();
-  except
-    On E: Exception do
-    begin
-      Result := False;
-      message := E.ToString;
-    end;
-  end;
-end;
-
-function TWIZTransferAccountWizard.CancelRequested(out message: ansistring): boolean;
-begin
-  Result := True;
-end;
-
-end.

+ 0 - 48
src/gui/wizards/operations/UWIZTransferAccount_Confirmation.lfm

@@ -1,48 +0,0 @@
-object WIZTransferAccount_Confirmation: TWIZTransferAccount_Confirmation
-  Left = 0
-  Height = 253
-  Top = 0
-  Width = 429
-  Caption = 'WIZTransferAccount_Confirmation'
-  ClientHeight = 253
-  ClientWidth = 429
-  LCLVersion = '1.8.2.0'
-  Visible = False
-  object GroupBox1: TGroupBox
-    Left = 10
-    Height = 232
-    Top = 8
-    Width = 408
-    Anchors = [akTop, akLeft, akRight, akBottom]
-    Caption = 'Confirm Transfer Transaction'
-    ClientHeight = 212
-    ClientWidth = 404
-    TabOrder = 0
-    object paGrid: TPanel
-      Left = 8
-      Height = 152
-      Top = 48
-      Width = 382
-      Anchors = [akTop, akLeft, akRight, akBottom]
-      BevelOuter = bvNone
-      Caption = 'GRID PANEL'
-      TabOrder = 0
-    end
-    object Label1: TLabel
-      Left = 8
-      Height = 15
-      Top = 16
-      Width = 84
-      Caption = 'Signer Account:'
-      ParentColor = False
-    end
-    object lblSgnAcc: TLabel
-      Left = 112
-      Height = 15
-      Top = 16
-      Width = 53
-      Caption = 'lblSgnAcc'
-      ParentColor = False
-    end
-  end
-end

+ 0 - 137
src/gui/wizards/operations/UWIZTransferAccount_Confirmation.pas

@@ -1,137 +0,0 @@
-unit UWIZTransferAccount_Confirmation;
-
-{$mode delphi}
-{$modeswitch nestedprocvars}
-
-{ Copyright (c) 2018 by Ugochukwu Mmaduekwe
-
-  Distributed under the MIT software license, see the accompanying file LICENSE
-  or visit http://www.opensource.org/licenses/mit-license.php.
-}
-
-interface
-
-uses
-  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
-  ExtCtrls, UVisualGrid, UCellRenderers, UCommon.Data, UWizard, UWIZTransferAccount, UWIZModels;
-
-type
-
-  { TWIZTransferAccount_Confirmation }
-
-  TWIZTransferAccount_Confirmation = class(TWizardForm<TWIZOperationsModel>)
-    GroupBox1: TGroupBox;
-    Label1: TLabel;
-    lblSgnAcc: TLabel;
-    paGrid: TPanel;
-  private
-    FSendersGrid : TVisualGrid;
-  public
-    procedure OnPresent; override;
-  end;
-
-
-implementation
-
-{$R *.lfm}
-
-uses UAccounts, UDataSources, UCommon, UCommon.UI, Generics.Collections;
-
-type
-
-  { TAccountSenderDataSource }
-
-  TAccountSenderDataSource = class(TAccountsDataSourceBase)
-    private
-      FModel : TWIZOperationsModel;
-    protected
-      function GetColumns : TDataColumns; override;
-    public
-      property Model : TWIZOperationsModel read FModel write FModel;
-      procedure FetchAll(const AContainer : TList<TAccount>); override;
-      function GetItemField(constref AItem: TAccount; const ABindingName : AnsiString) : Variant; override;
-  end;
-
-{ TWIZTransferAccount_Confirmation }
-
-procedure TWIZTransferAccount_Confirmation.OnPresent;
-var
-  data : TAccountSenderDataSource;
-begin
-  FSendersGrid := TVisualGrid.Create(Self);
-  FSendersGrid.CanSearch:= False;
-  FSendersGrid.SortMode := smMultiColumn;
-  FSendersGrid.FetchDataInThread := False;
-  FSendersGrid.AutoPageSize := True;
-  FSendersGrid.SelectionType := stNone;
-  FSendersGrid.Options := [vgoColAutoFill, vgoColSizing, vgoSortDirectionAllowNone, vgoAutoHidePaging];
-  with FSendersGrid.AddColumn('Account') do begin
-    Binding := 'Account';
-    Filters := SORTABLE_NUMERIC_FILTER;
-    Width := 100;
-    HeaderFontStyles := [fsBold];
-    DataFontStyles := [fsBold];
-  end;
-  with FSendersGrid.AddColumn('Current Public Key') do begin
-    Binding := 'CurrentPublicKey';
-    Filters := SORTABLE_TEXT_FILTER;
-    Width := 100;
-  end;
-   with FSendersGrid.AddColumn('New Public Key') do begin
-    Binding := 'NewPublicKey';
-    Filters := SORTABLE_TEXT_FILTER;
-    Width := 100;
-  end;
-  with FSendersGrid.AddColumn('Fee') do begin
-    Filters := SORTABLE_TEXT_FILTER;
-    Width := 100;
-  end;
-
-   data := TAccountSenderDataSource.Create(FSendersGrid);
-   data.Model := Model;
-   FSendersGrid.DataSource := data;
-   paGrid.AddControlDockCenter(FSendersGrid);
-   lblSgnAcc.Caption := TAccountComp.AccountNumberToAccountTxtNumber(Model.Signer.SignerAccount.account);
-end;
-
-{ TAccountSenderDataSource }
-
-function TAccountSenderDataSource.GetColumns : TDataColumns;
-begin
-  Result := TDataColumns.Create(
-    TDataColumn.From('Account'),
-    TDataColumn.From('CurrentPublicKey'),
-    TDataColumn.From('NewPublicKey'),
-    TDataColumn.From('Fee')
-  );
-end;
-
-function TAccountSenderDataSource.GetItemField(constref AItem: TAccount; const ABindingName : AnsiString) : Variant;
-var
-  index : Integer;
-begin
-   if ABindingName = 'Account' then
-     Result := TAccountComp.AccountNumberToAccountTxtNumber(AItem.account)
-   else if ABindingName = 'CurrentPublicKey' then
-     Result := TAccountComp.AccountPublicKeyExport(AItem.accountInfo.accountKey)
-   else if ABindingName = 'NewPublicKey' then
-     Result := Model.TransferAccount.NewPublicKey
-     else if ABindingName = 'Fee' then
-     Result := TAccountComp.FormatMoney(Model.Fee.DefaultFee)
-   else raise Exception.Create(Format('Field not found [%s]', [ABindingName]));
-end;
-
-
-procedure TAccountSenderDataSource.FetchAll(const AContainer : TList<TAccount>);
-var
-  i: Integer;
-begin
-  for i := Low(Model.TransferAccount.SelectedAccounts) to High(Model.TransferAccount.SelectedAccounts) do
-  begin
-    AContainer.Add( Model.TransferAccount.SelectedAccounts[i] );
-  end;
-end;
-
-
-end.
-

+ 0 - 32
src/gui/wizards/operations/UWIZTransferAccount_Start.lfm

@@ -1,32 +0,0 @@
-object WIZTransferAccount_Start: TWIZTransferAccount_Start
-  Left = 0
-  Height = 253
-  Top = 0
-  Width = 429
-  Caption = 'WIZTransferAccount_Start'
-  ClientHeight = 253
-  ClientWidth = 429
-  LCLVersion = '1.8.2.0'
-  Visible = False
-  object grpTransferAccount: TGroupBox
-    Left = 6
-    Height = 248
-    Top = 0
-    Width = 416
-    Anchors = [akTop, akLeft, akRight, akBottom]
-    Caption = 'Transfer Accounts'
-    ClientHeight = 228
-    ClientWidth = 412
-    TabOrder = 0
-    object paGrid: TPanel
-      Left = 6
-      Height = 200
-      Top = 24
-      Width = 402
-      Anchors = [akTop, akLeft, akRight, akBottom]
-      BevelOuter = bvNone
-      Caption = 'GRID PANEL'
-      TabOrder = 0
-    end
-  end
-end

+ 0 - 110
src/gui/wizards/operations/UWIZTransferAccount_Start.pas

@@ -1,110 +0,0 @@
-unit UWIZTransferAccount_Start;
-
-{$mode delphi}
-{$modeswitch nestedprocvars}
-
-{ Copyright (c) 2018 by Ugochukwu Mmaduekwe
-
-  Distributed under the MIT software license, see the accompanying file LICENSE
-  or visit http://www.opensource.org/licenses/mit-license.php.
-}
-
-interface
-
-uses
-  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
-  ExtCtrls, UVisualGrid, UCommon.Data, UCellRenderers,
-  UWizard, UWIZTransferAccount, UWIZTransferAccount_Transaction, UWIZTransferAccount_Confirmation, UWIZModels;
-
-type
-
-  { TWIZTransferAccount_Start }
-
-  TWIZTransferAccount_Start = class(TWizardForm<TWIZOperationsModel>)
-    grpTransferAccount: TGroupBox;
-    paGrid: TPanel;
-  private
-    FSendersGrid: TVisualGrid;
-  public
-    procedure OnPresent; override;
-    procedure OnNext; override;
-  end;
-
-
-
-implementation
-
-{$R *.lfm}
-
-uses UAccounts, USettings, UDataSources, UCommon, UCommon.UI, Generics.Collections;
-
-type
-
-  { TAccountSenderDataSource }
-
-  TAccountSenderDataSource = class(TAccountsDataSourceBase)
-  private
-    FModel: TWIZOperationsModel.TTransferAccountModel;
-  public
-    property Model: TWIZOperationsModel.TTransferAccountModel read FModel write FModel;
-    procedure FetchAll(const AContainer: TList<TAccount>); override;
-  end;
-
-procedure TAccountSenderDataSource.FetchAll(const AContainer: TList<TAccount>);
-var
-  i: integer;
-begin
-  for i := Low(Model.SelectedAccounts) to High(Model.SelectedAccounts) do
-  begin
-    AContainer.Add(Model.SelectedAccounts[i]);
-  end;
-end;
-
-{ TWIZTransferAccount_Start }
-
-procedure TWIZTransferAccount_Start.OnPresent;
-var
-  Data: TAccountSenderDataSource;
-begin
-  FSendersGrid := TVisualGrid.Create(Self);
-  FSendersGrid.CanSearch := False;
-  FSendersGrid.SortMode := smMultiColumn;
-  FSendersGrid.FetchDataInThread := False;
-  FSendersGrid.AutoPageSize := True;
-  FSendersGrid.SelectionType := stNone;
-  FSendersGrid.Options := [vgoColAutoFill, vgoColSizing, vgoSortDirectionAllowNone,
-    vgoAutoHidePaging];
-  with FSendersGrid.AddColumn('Account') do
-  begin
-    StretchedToFill := True;
-    Binding := 'AccountNumber';
-    SortBinding := 'AccountNumber';
-    DisplayBinding := 'Account';
-    Width := 100;
-    HeaderFontStyles := [fsBold];
-    DataFontStyles := [fsBold];
-    Filters := SORTABLE_NUMERIC_FILTER;
-  end;
-  with FSendersGrid.AddColumn('Balance') do
-  begin
-    Binding := 'BalanceDecimal';
-    SortBinding := 'Balance';
-    DisplayBinding := 'Balance';
-    Width := 100;
-    HeaderAlignment := taRightJustify;
-    DataAlignment := taRightJustify;
-    Renderer := TCellRenderers.PASC;
-    Filters := SORTABLE_NUMERIC_FILTER;
-  end;
-  Data := TAccountSenderDataSource.Create(FSendersGrid);
-  Data.Model := Model.TransferAccount;
-  FSendersGrid.DataSource := Data;
-  paGrid.AddControlDockCenter(FSendersGrid);
-end;
-
-procedure TWIZTransferAccount_Start.OnNext;
-begin
-   UpdatePath(ptReplaceAllNext, [TWIZTransferAccount_Transaction, TWIZTransferAccount_Confirmation]);
-end;
-
-end.

+ 0 - 93
src/gui/wizards/operations/UWIZTransferAccount_Transaction.lfm

@@ -1,93 +0,0 @@
-object WIZTransferAccount_Transaction: TWIZTransferAccount_Transaction
-  Left = 0
-  Height = 253
-  Top = 0
-  Width = 429
-  ActiveControl = cbSignerAccount
-  Caption = 'WIZTransferAccount_Transaction'
-  ClientHeight = 253
-  ClientWidth = 429
-  LCLVersion = '1.8.2.0'
-  Visible = False
-  object gbTransaction: TGroupBox
-    Left = 24
-    Height = 192
-    Top = 40
-    Width = 384
-    Caption = 'Transfer Transaction Details'
-    ClientHeight = 172
-    ClientWidth = 380
-    TabOrder = 0
-    object cbSignerAccount: TComboBox
-      Left = 8
-      Height = 23
-      Top = 8
-      Width = 168
-      ItemHeight = 15
-      Items.Strings = (
-        ''
-      )
-      OnChange = cbSignerAccountChange
-      TabOrder = 0
-      Text = 'Select Signer Account'
-    end
-    object lblBalance: TLabel
-      Left = 200
-      Height = 15
-      Top = 12
-      Width = 151
-      Caption = 'Please Select Signer Account'
-      Font.Color = clRed
-      ParentColor = False
-      ParentFont = False
-    end
-    object lblpublickey: TLabel
-      Left = 8
-      Height = 15
-      Top = 48
-      Width = 120
-      Caption = 'New Owner Public Key'
-      ParentColor = False
-    end
-    object edtPublicKey: TEdit
-      Left = 8
-      Height = 23
-      Top = 74
-      Width = 360
-      TabOrder = 1
-    end
-    object edtOpFee: TEdit
-      Left = 8
-      Height = 23
-      Top = 144
-      Width = 360
-      TabOrder = 2
-    end
-    object lblOpFee: TLabel
-      Left = 8
-      Height = 15
-      Top = 112
-      Width = 74
-      Caption = 'Operation Fee'
-      ParentColor = False
-    end
-  end
-  object lblTotalBalances: TLabel
-    Left = 24
-    Height = 15
-    Top = 16
-    Width = 176
-    Caption = 'Selected Accounts Total Balance: '
-    ParentColor = False
-  end
-  object lblTotalBalanceValue: TLabel
-    Left = 208
-    Height = 15
-    Top = 16
-    Width = 70
-    Caption = 'Total Balance'
-    Font.Color = clGreen
-    ParentColor = False
-    ParentFont = False
-  end
-end

+ 0 - 148
src/gui/wizards/operations/UWIZTransferAccount_Transaction.pas

@@ -1,148 +0,0 @@
-unit UWIZTransferAccount_Transaction;
-
-{$mode delphi}
-{$modeswitch nestedprocvars}
-
-{ Copyright (c) 2018 by Ugochukwu Mmaduekwe
-
-  Distributed under the MIT software license, see the accompanying file LICENSE
-  or visit http://www.opensource.org/licenses/mit-license.php.
-}
-
-interface
-
-uses
-  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
-  ExtCtrls, Buttons, UCommon, UCommon.Collections, UWallet,
-  UFRMAccountSelect, UNode, UWizard, UWIZTransferAccount,
-  UWIZTransferAccount_TransactionPayload,
-  UWIZTransferAccount_Confirmation, UWIZModels;
-
-type
-
-  { TWIZTransferAccount_Transaction }
-
-  TWIZTransferAccount_Transaction = class(TWizardForm<TWIZOperationsModel>)
-    cbSignerAccount: TComboBox;
-    edtOpFee: TEdit;
-    edtPublicKey: TEdit;
-    gbTransaction: TGroupBox;
-    lblOpFee: TLabel;
-    lblpublickey: TLabel;
-    lblTotalBalanceValue: TLabel;
-    lblTotalBalances: TLabel;
-    lblBalance: TLabel;
-    procedure cbSignerAccountChange(Sender: TObject);
-
-
-  public
-    procedure OnPresent; override;
-    procedure OnNext; override;
-    function Validate(out message: ansistring): boolean; override;
-  end;
-
-
-implementation
-
-{$R *.lfm}
-
-uses
-  UAccounts, UUserInterface, USettings;
-
-{ TWIZTransferAccount_Transaction }
-
-procedure TWIZTransferAccount_Transaction.cbSignerAccountChange(Sender: TObject);
-begin
-  if cbSignerAccount.ItemIndex < 1 then
-  begin
-    lblBalance.Font.Color := clRed;
-    lblBalance.Caption := 'Please Select Signer Account';
-  end
-  else
-  begin
-    lblBalance.Font.Color := clGreen;
-    lblBalance.Caption := Format('%s PASC', [TAccountComp.FormatMoney(Model.TransferAccount.SelectedAccounts[PtrInt(cbSignerAccount.Items.Objects[cbSignerAccount.ItemIndex])].Balance)]);
-  end;
-end;
-
-procedure TWIZTransferAccount_Transaction.OnPresent;
-
-  function GetAccNoWithChecksum(AAccountNumber: cardinal): string;
-  begin
-    Result := TAccountComp.AccountNumberToAccountTxtNumber(AAccountNumber);
-  end;
-
-var
-  acc: TAccount;
-  accNumberwithChecksum: string;
-  totalBalance: int64;
-  i: integer;
-begin
-  cbSignerAccount.Items.BeginUpdate;
-  totalBalance := 0;
-  try
-    cbSignerAccount.Items.Clear;
-    cbSignerAccount.Items.Add('Select Signer Account');
-    for i := Low(Model.TransferAccount.SelectedAccounts) to High(Model.TransferAccount.SelectedAccounts) do
-    begin
-      acc := Model.TransferAccount.SelectedAccounts[i];
-      accNumberwithChecksum := GetAccNoWithChecksum(acc.account);
-      totalBalance := totalBalance + acc.balance;
-      cbSignerAccount.Items.AddObject(accNumberwithChecksum, TObject(i));
-    end;
-  finally
-    cbSignerAccount.Items.EndUpdate;
-  end;
-  cbSignerAccount.ItemIndex := Model.TransferAccount.SelectedIndex;
-  cbSignerAccountChange(Self);
-  lblTotalBalanceValue.Caption :=
-    Format('%s PASC', [TAccountComp.FormatMoney(totalBalance)]);
-
-  edtOpFee.Text := TAccountComp.FormatMoney(TSettings.DefaultFee);
-end;
-
-procedure TWIZTransferAccount_Transaction.OnNext;
-begin
-  Model.TransferAccount.SelectedIndex := cbSignerAccount.ItemIndex;
-  Model.Signer.SignerAccount := Model.TransferAccount.SelectedAccounts[PtrInt(
-    cbSignerAccount.Items.Objects[cbSignerAccount.ItemIndex])];
-  Model.TransferAccount.NewPublicKey := Trim(edtPublicKey.Text);
-
-  UpdatePath(ptReplaceAllNext, [TWIZTransferAccount_TransactionPayload,
-    TWIZTransferAccount_Confirmation]);
-end;
-
-function TWIZTransferAccount_Transaction.Validate(out message: ansistring): boolean;
-var
-  i: integer;
-begin
-  Result := True;
-  if cbSignerAccount.ItemIndex < 1 then
-  begin
-    message := 'A signer account must be selected';
-    Result := False;
-    Exit;
-  end;
-
-  if not TAccountComp.TxtToMoney(Trim(edtOpFee.Text), Model.Fee.DefaultFee) then
-  begin
-    message := 'Invalid fee value "' + edtOpFee.Text + '"';
-    Result := False;
-    Exit;
-  end;
-
-  Result := TAccountComp.AccountKeyFromImport(edtPublicKey.Text,
-    Model.TransferAccount.AccountKey, message);
-  for i := Low(Model.TransferAccount.SelectedAccounts) to High(Model.TransferAccount.SelectedAccounts) do
-  begin
-    if TAccountComp.EqualAccountKeys(Model.TransferAccount.SelectedAccounts[i].accountInfo.accountKey,
-      Model.TransferAccount.AccountKey) then
-    begin
-      Result := False;
-      message := 'new public key is same as selected account public key';
-      Exit;
-    end;
-  end;
-end;
-
-end.

+ 0 - 98
src/gui/wizards/operations/UWIZTransferAccount_TransactionPayload.lfm

@@ -1,98 +0,0 @@
-object WIZTransferAccount_TransactionPayload: TWIZTransferAccount_TransactionPayload
-  Left = 0
-  Height = 253
-  Top = 0
-  Width = 429
-  ActiveControl = mmoPayload
-  Caption = 'Form1'
-  ClientHeight = 253
-  ClientWidth = 429
-  LCLVersion = '1.8.1.0'
-  Visible = False
-  object grpPayload: TGroupBox
-    Left = 8
-    Height = 244
-    Top = 2
-    Width = 416
-    Anchors = [akTop, akLeft, akRight, akBottom]
-    Caption = 'Transfer Transaction Payload'
-    ClientHeight = 224
-    ClientWidth = 412
-    TabOrder = 0
-    object paPayload: TPanel
-      Left = 8
-      Height = 214
-      Top = 2
-      Width = 396
-      Anchors = [akTop, akLeft, akRight, akBottom]
-      BevelOuter = bvNone
-      ClientHeight = 214
-      ClientWidth = 396
-      TabOrder = 0
-      object mmoPayload: TMemo
-        Left = 0
-        Height = 70
-        Top = 136
-        Width = 386
-        TabOrder = 0
-      end
-      object Label1: TLabel
-        Left = 0
-        Height = 15
-        Top = 118
-        Width = 69
-        Caption = 'Payload Data'
-        ParentColor = False
-      end
-      object rbEncryptedWithOldEC: TRadioButton
-        Left = 3
-        Height = 19
-        Top = 0
-        Width = 176
-        Caption = 'Encrypted with old public key'
-        TabOrder = 1
-      end
-      object rbEncryptedWithEC: TRadioButton
-        Left = 3
-        Height = 19
-        Top = 24
-        Width = 181
-        Caption = 'Encrypted with new public key'
-        Checked = True
-        TabOrder = 2
-        TabStop = True
-      end
-      object rbEncryptedWithPassword: TRadioButton
-        Left = 3
-        Height = 19
-        Top = 48
-        Width = 152
-        Caption = 'Encrypted with password'
-        TabOrder = 3
-      end
-      object lblPassword: TLabel
-        Left = 3
-        Height = 15
-        Top = 73
-        Width = 53
-        Caption = 'Password:'
-        ParentColor = False
-      end
-      object rbNotEncrypted: TRadioButton
-        Left = 3
-        Height = 19
-        Top = 94
-        Width = 181
-        Caption = 'Don''t encrypt (public payload)'
-        TabOrder = 4
-      end
-      object edtPassword: TEdit
-        Left = 64
-        Height = 23
-        Top = 70
-        Width = 160
-        TabOrder = 5
-      end
-    end
-  end
-end

+ 0 - 84
src/gui/wizards/operations/UWIZTransferAccount_TransactionPayload.pas

@@ -1,84 +0,0 @@
-unit UWIZTransferAccount_TransactionPayload;
-
-{$mode delphi}
-{$modeswitch nestedprocvars}
-
-{ Copyright (c) 2018 by Ugochukwu Mmaduekwe
-
-  Distributed under the MIT software license, see the accompanying file LICENSE
-  or visit http://www.opensource.org/licenses/mit-license.php.
-}
-
-interface
-
-uses
-  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
-  ExtCtrls, Buttons, UCommon, UCommon.Collections,
-  UWizard, UWIZTransferAccount, UWIZModels;
-
-type
-
-  { TWIZTransferAccount_TransactionPayload }
-
-  TWIZTransferAccount_TransactionPayload = class(TWizardForm<TWIZOperationsModel>)
-    edtPassword: TEdit;
-    grpPayload: TGroupBox;
-    Label1: TLabel;
-    lblPassword: TLabel;
-    mmoPayload: TMemo;
-    paPayload: TPanel;
-    rbEncryptedWithOldEC: TRadioButton;
-    rbEncryptedWithEC: TRadioButton;
-    rbEncryptedWithPassword: TRadioButton;
-    rbNotEncrypted: TRadioButton;
-  public
-    procedure OnNext; override;
-    function Validate(out message: ansistring): boolean; override;
-  end;
-
-
-implementation
-
-{$R *.lfm}
-
-uses
-  UAccounts, UUserInterface;
-
-{ TWIZTransferAccount_TransactionPayload }
-
-procedure TWIZTransferAccount_TransactionPayload.OnNext;
-begin
-  Model.Payload.Content := mmoPayload.Lines.Text;
-  if rbEncryptedWithOldEC.Checked then
-  begin
-    Model.Payload.Mode := akaEncryptWithSender;
-  end
-  else
-  if rbEncryptedWithEC.Checked then
-  begin
-    Model.Payload.Mode := akaEncryptWithReceiver;
-  end
-  else
-  if rbEncryptedWithPassword.Checked then
-  begin
-    Model.Payload.Mode := akaEncryptWithPassword;
-  end
-  else
-  if rbNotEncrypted.Checked then
-  begin
-    Model.Payload.Mode := akaNotEncrypt;
-  end;
-end;
-
-function TWIZTransferAccount_TransactionPayload.Validate(out message: ansistring): boolean;
-begin
-  if (not rbNotEncrypted.Checked) and (not rbEncryptedWithEC.Checked) and
-    (not rbEncryptedWithOldEC.Checked) and (not rbEncryptedWithPassword.Checked) then
-  begin
-    message := 'you must select an encryption option for payload';
-    Result := False;
-    Exit;
-  end;
-end;
-
-end.

+ 31 - 45
src/pascalcoin_wallet.lpi

@@ -36,7 +36,7 @@
         <PackageName Value="LCL"/>
       </Item2>
     </RequiredPackages>
-    <Units Count="99">
+    <Units Count="97">
       <Unit0>
         <Filename Value="pascalcoin_wallet.dpr"/>
         <IsPartOfProject Value="True"/>
@@ -457,122 +457,108 @@
         <IsPartOfProject Value="True"/>
       </Unit80>
       <Unit81>
-        <Filename Value="gui\wizards\operations\UWIZSendPASC_Confirmation.pas"/>
+        <Filename Value="gui\wizards\operations\UWIZSendPASC_ConfirmSender.pas"/>
         <IsPartOfProject Value="True"/>
-        <ComponentName Value="WIZSendPASC_Confirmation"/>
+        <ComponentName Value="WIZSendPASC_ConfirmSender"/>
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
       </Unit81>
       <Unit82>
-        <Filename Value="gui\wizards\operations\UWIZSendPASC_ConfirmSender.pas"/>
+        <Filename Value="gui\wizards\operations\UWIZSendPASC_EnterQuantity.pas"/>
         <IsPartOfProject Value="True"/>
-        <ComponentName Value="WIZSendPASC_ConfirmSender"/>
+        <ComponentName Value="WIZSendPASC_EnterQuantity"/>
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
       </Unit82>
       <Unit83>
-        <Filename Value="gui\wizards\operations\UWIZSendPASC_EnterQuantity.pas"/>
+        <Filename Value="gui\wizards\operations\UWIZSendPASC_EnterRecipient.pas"/>
         <IsPartOfProject Value="True"/>
-        <ComponentName Value="WIZSendPASC_EnterQuantity"/>
+        <ComponentName Value="WIZSendPASC_EnterRecipient"/>
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
       </Unit83>
       <Unit84>
-        <Filename Value="gui\wizards\operations\UWIZSendPASC_EnterRecipient.pas"/>
+        <Filename Value="gui\wizards\operations\UWIZChangeKey.pas"/>
         <IsPartOfProject Value="True"/>
-        <ComponentName Value="WIZSendPASC_EnterRecipient"/>
-        <HasResources Value="True"/>
-        <ResourceBaseClass Value="Form"/>
       </Unit84>
       <Unit85>
-        <Filename Value="gui\wizards\operations\UWIZChangeKey.pas"/>
-        <IsPartOfProject Value="True"/>
-      </Unit85>
-      <Unit86>
         <Filename Value="gui\wizards\operations\UWIZChangeKey_SelectOption.pas"/>
         <IsPartOfProject Value="True"/>
         <ComponentName Value="WIZChangeKey_SelectOption"/>
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
-      </Unit86>
-      <Unit87>
+      </Unit85>
+      <Unit86>
         <Filename Value="gui\wizards\operations\UWIZChangeKey_EnterKey.pas"/>
         <IsPartOfProject Value="True"/>
         <ComponentName Value="WIZChangeKey_EnterKey"/>
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
-      </Unit87>
-      <Unit88>
+      </Unit86>
+      <Unit87>
         <Filename Value="gui\wizards\operations\UWIZChangeKey_SelectKey.pas"/>
         <IsPartOfProject Value="True"/>
         <ComponentName Value="WIZChangeKey_SelectKey"/>
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
-      </Unit88>
-      <Unit89>
+      </Unit87>
+      <Unit88>
         <Filename Value="gui\wizards\operations\UWIZChangeKey_ConfirmAccount.pas"/>
         <IsPartOfProject Value="True"/>
         <ComponentName Value="WIZChangeKey_ConfirmAccount"/>
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
-      </Unit89>
-      <Unit90>
-        <Filename Value="gui\wizards\operations\UWIZChangeKey_Confirmation.pas"/>
-        <IsPartOfProject Value="True"/>
-        <ComponentName Value="WIZChangeKey_Confirmation"/>
-        <HasResources Value="True"/>
-        <ResourceBaseClass Value="Form"/>
-      </Unit90>
-      <Unit91>
+      </Unit88>
+      <Unit89>
         <Filename Value="gui-classic\UGridUtils.pas"/>
         <IsPartOfProject Value="True"/>
-      </Unit91>
-      <Unit92>
+      </Unit89>
+      <Unit90>
         <Filename Value="gui\wizards\operations\UWIZEnlistAccountForSale_EnterSeller.pas"/>
         <IsPartOfProject Value="True"/>
         <ComponentName Value="WIZEnlistAccountForSale_EnterSeller"/>
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
-      </Unit92>
-      <Unit93>
+      </Unit90>
+      <Unit91>
         <Filename Value="gui\wizards\operations\UWIZEnlistAccountForSale_EnterSaleAmount.pas"/>
         <IsPartOfProject Value="True"/>
         <ComponentName Value="WIZEnlistAccountForSale_EnterSaleAmount"/>
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
-      </Unit93>
-      <Unit94>
+      </Unit91>
+      <Unit92>
         <Filename Value="gui\wizards\operations\UWIZEnlistAccountForSale_SelectOption.pas"/>
         <IsPartOfProject Value="True"/>
         <ComponentName Value="WIZEnlistAccountForSale_SelectOption"/>
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
-      </Unit94>
-      <Unit95>
+      </Unit92>
+      <Unit93>
         <Filename Value="gui\wizards\operations\UWIZEnlistAccountForSale_EnterLockingBlock.pas"/>
         <IsPartOfProject Value="True"/>
         <ComponentName Value="WIZEnlistAccountForSale_EnterLockingBlock"/>
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
-      </Unit95>
-      <Unit96>
+      </Unit93>
+      <Unit94>
         <Filename Value="gui\wizards\operations\UWIZEnlistAccountForSale_EnterPublicKey.pas"/>
         <IsPartOfProject Value="True"/>
         <ComponentName Value="WIZEnlistAccountForSale_EnterPublicKey"/>
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
-      </Unit96>
-      <Unit97>
+      </Unit94>
+      <Unit95>
         <Filename Value="gui\wizards\operations\UWIZEnlistAccountForSale_ConfirmAccount.pas"/>
         <IsPartOfProject Value="True"/>
         <ComponentName Value="WIZEnlistAccountForSale_ConfirmAccount"/>
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
-      </Unit97>
-      <Unit98>
+      </Unit95>
+      <Unit96>
         <Filename Value="core.utils\UCoreObjects.pas"/>
         <IsPartOfProject Value="True"/>
-      </Unit98>
+      </Unit96>
     </Units>
   </ProjectOptions>
   <CompilerOptions>