Browse Source

Experimental GUI: update to latest core

Herman Schoenfeld 6 years ago
parent
commit
97dbe5065c
29 changed files with 279 additions and 252 deletions
  1. 1 2
      src/gui-experimental/UCTRLSyncronization.lfm
  2. 51 49
      src/gui-experimental/UCTRLSyncronization.pas
  3. 1 1
      src/gui-experimental/UCTRLWallet.lfm
  4. 1 1
      src/gui-experimental/UCTRLWallet.pas
  5. 2 2
      src/gui-experimental/UFRMAccountExplorer.lfm
  6. 40 58
      src/gui-experimental/UFRMAccountExplorer.pas
  7. 1 1
      src/gui-experimental/UFRMAccountSelect.lfm
  8. 2 2
      src/gui-experimental/UFRMAccountSelect.pas
  9. 1 2
      src/gui-experimental/UFRMMessages.lfm
  10. 2 2
      src/gui-experimental/UFRMMessages.pas
  11. 1 1
      src/gui-experimental/UFRMNodes.lfm
  12. 9 6
      src/gui-experimental/UFRMNodes.pas
  13. 1 1
      src/gui-experimental/UFRMOperation.lfm
  14. 16 16
      src/gui-experimental/UFRMOperation.pas
  15. 1 2
      src/gui-experimental/UFRMPayloadDecoder.lfm
  16. 41 32
      src/gui-experimental/UFRMPayloadDecoder.pas
  17. 3 3
      src/gui-experimental/UFRMSaleAccounts.pas
  18. 17 4
      src/gui-experimental/UUserInterface.pas
  19. 32 16
      src/gui-experimental/core.utils/UCoreUtils.pas
  20. 32 25
      src/gui-experimental/core.utils/UDataSources.pas
  21. 1 1
      src/gui-experimental/wizards/operations/UWIZBuyAccount_Details.lfm
  22. 3 3
      src/gui-experimental/wizards/operations/UWIZBuyAccount_Details.pas
  23. 1 1
      src/gui-experimental/wizards/operations/UWIZEnlistAccountForSale_EnterSeller.lfm
  24. 3 3
      src/gui-experimental/wizards/operations/UWIZEnlistAccountForSale_EnterSeller.pas
  25. 1 2
      src/gui-experimental/wizards/operations/UWIZSendPASC_Details.lfm
  26. 5 4
      src/gui-experimental/wizards/operations/UWIZSendPASC_Details.pas
  27. 1 2
      src/gui-experimental/wizards/wallet/UWIZAddKey_SelectEncryption.lfm
  28. 4 6
      src/gui-experimental/wizards/wallet/UWIZAddKey_SelectEncryption.pas
  29. 5 4
      src/pascalcoin_wallet_experimental.lpi

+ 1 - 2
src/gui-experimental/UCTRLSyncronization.lfm

@@ -10,8 +10,7 @@ object CTRLSyncronization: TCTRLSyncronization
   ClientWidth = 728
   ClientWidth = 728
   OnCreate = FormCreate
   OnCreate = FormCreate
   OnDestroy = FormDestroy
   OnDestroy = FormDestroy
-  LCLVersion = '1.8.2.0'
-  Visible = False
+  LCLVersion = '2.0.2.0'
   object paSplash: TPanel
   object paSplash: TPanel
     Left = 0
     Left = 0
     Height = 428
     Height = 428

+ 51 - 49
src/gui-experimental/UCTRLSyncronization.pas

@@ -91,7 +91,9 @@ implementation
 
 
 {$R *.lfm}
 {$R *.lfm}
 
 
-uses UCommon, UTime, UConst, UUserInterface, UAccounts, UNode;
+uses
+  UCommon, UTime, UConst, UAccounts, UNode, UBlockChain,
+  UUserInterface;
 
 
 procedure TCTRLSyncronization.FormCreate(Sender: TObject);
 procedure TCTRLSyncronization.FormCreate(Sender: TObject);
 begin
 begin
@@ -215,59 +217,59 @@ end;
 procedure TCTRLSyncronization.UpdateBlockChainState;
 procedure TCTRLSyncronization.UpdateBlockChainState;
 Var
 Var
   f, favg : real;
   f, favg : real;
+  LMemPool : TPCOperationsComp;
 begin
 begin
-  TUserInterface.Node.Operations.Lock;
-  try
-    if not TUserInterface.Started then exit;
-    UpdateNodeStatus;
-    if Assigned(TUserInterface.Node) then begin
-      if TUserInterface.Node.Bank.BlocksCount>0 then begin
-        lblTotalBlocksValue.Caption :=  Inttostr(TUserInterface.Node.Bank.BlocksCount)+' (0..'+Inttostr(TUserInterface.Node.Bank.BlocksCount-1)+')'; ;
-      end else lblTotalBlocksValue.Caption :=  '(none)';
-      lblTotalAccountsValue.Caption := Inttostr(TUserInterface.Node.Bank.AccountsCount);
-      lblBlockAgeValue.Caption := UnixTimeToLocalElapsedTime(TUserInterface.Node.Bank.LastOperationBlock.timestamp);
-      lblPendingOperationsValue.Caption := Inttostr(TUserInterface.Node.Operations.Count);
-      lblBlockTargetValue.Caption := InttoHex(TUserInterface.Node.Operations.OperationBlock.compact_target,8);
-      favg := TUserInterface.Node.Bank.GetActualTargetSecondsAverage(CT_CalcNewTargetBlocksAverage);
-      f := (CT_NewLineSecondsAvg - favg) / CT_NewLineSecondsAvg;
-      lblTimeAverage.Caption := 'Last '+Inttostr(CT_CalcNewTargetBlocksAverage)+': '+FormatFloat('0.0',favg)+' sec. (Optimal '+Inttostr(CT_NewLineSecondsAvg)+'s) Deviation '+FormatFloat('0.00%',f*100);
-      if favg>=CT_NewLineSecondsAvg then begin
-        lblTimeAverage.Font.Color := clNavy;
-      end else begin
-        lblTimeAverage.Font.Color := clOlive;
-      end;
-      lblTimeAverageAux.Caption := Format('Last %d: %s sec. - %d: %s sec. - %d: %s sec. - %d: %s sec. - %d: %s sec.',[
-          CT_CalcNewTargetBlocksAverage * 2 ,FormatFloat('0.0',TUserInterface.Node.Bank.GetActualTargetSecondsAverage(CT_CalcNewTargetBlocksAverage * 2)),
-          ((CT_CalcNewTargetBlocksAverage * 3) DIV 2) ,FormatFloat('0.0',TUserInterface.Node.Bank.GetActualTargetSecondsAverage((CT_CalcNewTargetBlocksAverage * 3) DIV 2)),
-          ((CT_CalcNewTargetBlocksAverage DIV 4)*3),FormatFloat('0.0',TUserInterface.Node.Bank.GetActualTargetSecondsAverage(((CT_CalcNewTargetBlocksAverage DIV 4)*3))),
-          CT_CalcNewTargetBlocksAverage DIV 2,FormatFloat('0.0',TUserInterface.Node.Bank.GetActualTargetSecondsAverage(CT_CalcNewTargetBlocksAverage DIV 2)),
-          CT_CalcNewTargetBlocksAverage DIV 4,FormatFloat('0.0',TUserInterface.Node.Bank.GetActualTargetSecondsAverage(CT_CalcNewTargetBlocksAverage DIV 4))]);
+  if not TUserInterface.Started then exit;
+  UpdateNodeStatus;
+  if Assigned(TUserInterface.Node) then begin
+    if TUserInterface.Node.Bank.BlocksCount>0 then begin
+      lblTotalBlocksValue.Caption :=  Inttostr(TUserInterface.Node.Bank.BlocksCount)+' (0..'+Inttostr(TUserInterface.Node.Bank.BlocksCount-1)+')'; ;
+    end else lblTotalBlocksValue.Caption :=  '(none)';
+    lblTotalAccountsValue.Caption := Inttostr(TUserInterface.Node.Bank.AccountsCount);
+    lblBlockAgeValue.Caption := UnixTimeToLocalElapsedTime(TUserInterface.Node.Bank.LastOperationBlock.timestamp);
+    LMemPool := TUserInterface.Node.LockMempoolRead;
+    try
+      lblPendingOperationsValue.Caption := Inttostr(LMemPool.Count);
+      lblBlockTargetValue.Caption := InttoHex(LMemPool.OperationBlock.compact_target,8);
+    finally
+      TUserInterface.Node.UnlockMempoolRead;
+    end;
+    favg := TUserInterface.Node.Bank.GetActualTargetSecondsAverage(CT_CalcNewTargetBlocksAverage);
+    f := (CT_NewLineSecondsAvg - favg) / CT_NewLineSecondsAvg;
+    lblTimeAverage.Caption := 'Last '+Inttostr(CT_CalcNewTargetBlocksAverage)+': '+FormatFloat('0.0',favg)+' sec. (Optimal '+Inttostr(CT_NewLineSecondsAvg)+'s) Deviation '+FormatFloat('0.00%',f*100);
+    if favg>=CT_NewLineSecondsAvg then begin
+      lblTimeAverage.Font.Color := clNavy;
     end else begin
     end else begin
-      lblTotalBlocksValue.Caption := '';
-      lblTotalAccountsValue.Caption := '';
-      lblBlockAgeValue.Caption := '';
-      lblPendingOperationsValue.Caption := '';
-      lblBlockTargetValue.Caption := '';
-      lblTimeAverage.Caption := '';
-      lblTimeAverageAux.Caption := '';
+      lblTimeAverage.Font.Color := clOlive;
     end;
     end;
-    if (Assigned(TUserInterface.PoolMiningServer)) And (TUserInterface.PoolMiningServer.Active) then begin
-      If TUserInterface.PoolMiningServer.ClientsCount>0 then begin
-        lblMinersClientsValue.Caption := IntToStr(TUserInterface.PoolMiningServer.ClientsCount)+' connected JSON-RPC clients';
-        lblMinersClientsValue.Font.Color := clNavy;
-      end else begin
-        lblMinersClientsValue.Caption := 'No JSON-RPC clients';
-        lblMinersClientsValue.Font.Color := clDkGray;
-      end;
-      MinedBlocksCount := TUserInterface.PoolMiningServer.ClientsWins;
+    lblTimeAverageAux.Caption := Format('Last %d: %s sec. - %d: %s sec. - %d: %s sec. - %d: %s sec. - %d: %s sec.',[
+        CT_CalcNewTargetBlocksAverage * 2 ,FormatFloat('0.0',TUserInterface.Node.Bank.GetActualTargetSecondsAverage(CT_CalcNewTargetBlocksAverage * 2)),
+        ((CT_CalcNewTargetBlocksAverage * 3) DIV 2) ,FormatFloat('0.0',TUserInterface.Node.Bank.GetActualTargetSecondsAverage((CT_CalcNewTargetBlocksAverage * 3) DIV 2)),
+        ((CT_CalcNewTargetBlocksAverage DIV 4)*3),FormatFloat('0.0',TUserInterface.Node.Bank.GetActualTargetSecondsAverage(((CT_CalcNewTargetBlocksAverage DIV 4)*3))),
+        CT_CalcNewTargetBlocksAverage DIV 2,FormatFloat('0.0',TUserInterface.Node.Bank.GetActualTargetSecondsAverage(CT_CalcNewTargetBlocksAverage DIV 2)),
+        CT_CalcNewTargetBlocksAverage DIV 4,FormatFloat('0.0',TUserInterface.Node.Bank.GetActualTargetSecondsAverage(CT_CalcNewTargetBlocksAverage DIV 4))]);
+  end else begin
+    lblTotalBlocksValue.Caption := '';
+    lblTotalAccountsValue.Caption := '';
+    lblBlockAgeValue.Caption := '';
+    lblPendingOperationsValue.Caption := '';
+    lblBlockTargetValue.Caption := '';
+    lblTimeAverage.Caption := '';
+    lblTimeAverageAux.Caption := '';
+  end;
+  if (Assigned(TUserInterface.PoolMiningServer)) And (TUserInterface.PoolMiningServer.Active) then begin
+    If TUserInterface.PoolMiningServer.ClientsCount>0 then begin
+      lblMinersClientsValue.Caption := IntToStr(TUserInterface.PoolMiningServer.ClientsCount)+' connected JSON-RPC clients';
+      lblMinersClientsValue.Font.Color := clNavy;
     end else begin
     end else begin
-      MinedBlocksCount := 0;
-      lblMinersClientsValue.Caption := 'JSON-RPC server not active';
-      lblMinersClientsValue.Font.Color := clRed;
+      lblMinersClientsValue.Caption := 'No JSON-RPC clients';
+      lblMinersClientsValue.Font.Color := clDkGray;
     end;
     end;
-
-  finally
-    TUserInterface.Node.Operations.Unlock;
+    MinedBlocksCount := TUserInterface.PoolMiningServer.ClientsWins;
+  end else begin
+    MinedBlocksCount := 0;
+    lblMinersClientsValue.Caption := 'JSON-RPC server not active';
+    lblMinersClientsValue.Font.Color := clRed;
   end;
   end;
 end;
 end;
 
 

+ 1 - 1
src/gui-experimental/UCTRLWallet.lfm

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

+ 1 - 1
src/gui-experimental/UCTRLWallet.pas

@@ -628,7 +628,7 @@ begin
   if ASelection.RowCount = 1 then begin
   if ASelection.RowCount = 1 then begin
     if not TAccountComp.AccountTxtNumberToAccountNumber(FAccountsGrid.Rows[ASelection.Row].Account, accNo) then
     if not TAccountComp.AccountTxtNumberToAccountNumber(FAccountsGrid.Rows[ASelection.Row].Account, accNo) then
       raise Exception.Create('Error Parsing Account Number From Grid');
       raise Exception.Create('Error Parsing Account Number From Grid');
-    account := TNode.Node.Operations.SafeBoxTransaction.Account(accNo);
+    account := TNode.Node.GetAccount(accNo);
     miEnlistAccountsForSale.Visible := IIF(TAccountComp.IsAccountForSale(account.accountInfo), False, True);
     miEnlistAccountsForSale.Visible := IIF(TAccountComp.IsAccountForSale(account.accountInfo), False, True);
     miDelistAccountsFromSale.Visible := not miEnlistAccountsForSale.Visible;
     miDelistAccountsFromSale.Visible := not miEnlistAccountsForSale.Visible;
   end;
   end;

+ 2 - 2
src/gui-experimental/UFRMAccountExplorer.lfm

@@ -5,13 +5,13 @@ object FRMAccountExplorer: TFRMAccountExplorer
   Width = 868
   Width = 868
   ActiveControl = cbMyPrivateKeys
   ActiveControl = cbMyPrivateKeys
   Caption = 'Accounts Explorer'
   Caption = 'Accounts Explorer'
-  ClientHeight = 451
+  ClientHeight = 431
   ClientWidth = 868
   ClientWidth = 868
   Menu = meAccountExplorerMenu
   Menu = meAccountExplorerMenu
   OnCreate = FormCreate
   OnCreate = FormCreate
   OnDestroy = FormDestroy
   OnDestroy = FormDestroy
   Position = poOwnerFormCenter
   Position = poOwnerFormCenter
-  Visible = False
+  LCLVersion = '2.0.2.0'
   object Splitter1: TSplitter
   object Splitter1: TSplitter
     Left = 380
     Left = 380
     Height = 385
     Height = 385

+ 40 - 58
src/gui-experimental/UFRMAccountExplorer.pas

@@ -24,8 +24,8 @@ interface
 
 
 uses
 uses
   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,
   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,
-  ExtCtrls, StdCtrls, Buttons, Grids, Menus, UCommon.UI,
-  UGridUtils, UNode, UAccounts, UBlockChain;
+  ExtCtrls, StdCtrls, Buttons, Grids, Menus,
+  UCommon.UI, UBaseTypes, UGridUtils, UNode, UAccounts, UBlockChain;
 
 
 type
 type
 
 
@@ -194,6 +194,7 @@ type
     FOrderedAccountsKeyList : TOrderedAccountKeysList;
     FOrderedAccountsKeyList : TOrderedAccountKeysList;
     FMinAccountBalance : Int64;
     FMinAccountBalance : Int64;
     FMaxAccountBalance : Int64;
     FMaxAccountBalance : Int64;
+    FLastAccountsGridInvalidateTC : TTickCount;
     procedure RefreshMyKeysCombo;
     procedure RefreshMyKeysCombo;
     procedure RefreshAccountsGrid(RefreshData : Boolean);
     procedure RefreshAccountsGrid(RefreshData : Boolean);
     procedure OnLoaded(Sender: TObject);
     procedure OnLoaded(Sender: TObject);
@@ -211,8 +212,9 @@ implementation
 
 
 {$R *.lfm}
 {$R *.lfm}
 
 
-uses UFRMAccountSelect, UConst, USettings,
-     UWallet, UCrypto, UFRMMemoText, UUserInterface, UCommon, UPCOrderedLists;
+uses
+  UConst, USettings, UWallet, UCrypto, UCoreUtils,
+  UFRMAccountSelect, UFRMMemoText, UUserInterface, UCommon, UPCOrderedLists;
 
 
 { TFRMAccountExplorer }
 { TFRMAccountExplorer }
 
 
@@ -220,6 +222,7 @@ uses UFRMAccountSelect, UConst, USettings,
 
 
 procedure TFRMAccountExplorer.FormCreate(Sender: TObject);
 procedure TFRMAccountExplorer.FormCreate(Sender: TObject);
 begin
 begin
+  FLastAccountsGridInvalidateTC := TPlatform.GetTickCount;
   FMinAccountBalance := 0;
   FMinAccountBalance := 0;
   FMaxAccountBalance := CT_MaxWalletAmount;
   FMaxAccountBalance := CT_MaxWalletAmount;
   FOrderedAccountsKeyList := Nil;
   FOrderedAccountsKeyList := Nil;
@@ -284,70 +287,49 @@ Var accl : TOrderedCardinalList;
   l : TOrderedCardinalList;
   l : TOrderedCardinalList;
   i,j,k : Integer;
   i,j,k : Integer;
   c  : Cardinal;
   c  : Cardinal;
-  applyfilter : Boolean;
+  LApplyfilter : Boolean;
   acc : TAccount;
   acc : TAccount;
+  LFilters : TAccountsGridFilter;
 begin
 begin
   If Not Assigned(FOrderedAccountsKeyList) Then exit;
   If Not Assigned(FOrderedAccountsKeyList) Then exit;
+
   if Not RefreshData then begin
   if Not RefreshData then begin
-    dgAccounts.Invalidate;
+    if TPlatform.GetElapsedMilliseconds(FLastAccountsGridInvalidateTC)>1000 then begin
+      FLastAccountsGridInvalidateTC := TPlatform.GetTickCount;
+      dgAccounts.Invalidate;
+    end;
     exit;
     exit;
   end;
   end;
-  applyfilter := (cbFilterAccounts.Checked) and ((FMinAccountBalance>0) Or (FMaxAccountBalance<CT_MaxWalletAmount));
-  FAccountsGrid.ShowAllAccounts := (Not cbExploreMyAccounts.Checked) And (not applyfilter);
-  if Not FAccountsGrid.ShowAllAccounts then begin
-    accl := FAccountsGrid.LockAccountsList;
-    Try
-      accl.Clear;
-      if cbExploreMyAccounts.Checked then begin
-        if cbMyPrivateKeys.ItemIndex<0 then exit;
-        if cbMyPrivateKeys.ItemIndex=0 then begin
-          // All keys in the wallet
-          for i := 0 to TWallet.Keys.Count - 1 do begin
-            j := FOrderedAccountsKeyList.IndexOfAccountKey(TWallet.Keys[i].AccountKey);
-            if (j>=0) then begin
-              l := FOrderedAccountsKeyList.AccountKeyList[j];
-              for k := 0 to l.Count - 1 do begin
-                if applyfilter then begin
-                  acc := TUserInterface.Node.Bank.SafeBox.Account(l.Get(k));
-                  if (acc.balance>=FMinAccountBalance) And (acc.balance<=FMaxAccountBalance) then accl.Add(acc.account);
-                end else accl.Add(l.Get(k));
-              end;
-            end;
-          end;
-        end else begin
+  LApplyfilter := (cbFilterAccounts.Checked) and ((FMinAccountBalance>0) Or ((FMaxAccountBalance<CT_MaxWalletAmount) and (FMaxAccountBalance>=0)));
+  if (Not cbExploreMyAccounts.Checked) And (not LApplyfilter) then begin
+    FAccountsGrid.AccountsGridDatasource := acds_Node;
+    FAccountsGrid.UpdateData;
+  end else begin
+    LFilters := FAccountsGrid.AccountsGridFilter;
+    LFilters.MinBalance := FMinAccountBalance;
+    LFilters.MaxBalance := FMaxAccountBalance;
+    if cbExploreMyAccounts.Checked then begin
+      TNode.Node.Bank.SafeBox.StartThreadSafe;
+      try
+        LFilters.OrderedAccountsKeyList := TWallet.Keys.AccountsKeyList;
+        if cbMyPrivateKeys.ItemIndex>0 then begin
           i := PtrInt(cbMyPrivateKeys.Items.Objects[cbMyPrivateKeys.ItemIndex]);
           i := PtrInt(cbMyPrivateKeys.Items.Objects[cbMyPrivateKeys.ItemIndex]);
           if (i>=0) And (i<TWallet.Keys.Count) then begin
           if (i>=0) And (i<TWallet.Keys.Count) then begin
-            j := FOrderedAccountsKeyList.IndexOfAccountKey(TWallet.Keys[i].AccountKey);
-            if (j>=0) then begin
-              l := FOrderedAccountsKeyList.AccountKeyList[j];
-              for k := 0 to l.Count - 1 do begin
-                if applyfilter then begin
-                  acc := TUserInterface.Node.Bank.SafeBox.Account(l.Get(k));
-                  if (acc.balance>=FMinAccountBalance) And (acc.balance<=FMaxAccountBalance) then accl.Add(acc.account);
-                end else accl.Add(l.Get(k));
-              end;
-            end;
-          end;
-        end;
-      end else begin
-        // There is a filter... check every account...
-        c := 0;
-        while (c<TUserInterface.Node.Bank.SafeBox.AccountsCount) do begin
-          acc := TUserInterface.Node.Bank.SafeBox.Account(c);
-          if (acc.balance>=FMinAccountBalance) And (acc.balance<=FMaxAccountBalance) then accl.Add(acc.account);
-          inc(c);
-        end;
+            LFilters.indexAccountsKeyList := TWallet.Keys.AccountsKeyList.IndexOfAccountKey(TWallet.Keys[i].AccountKey);
+          end
+        end else LFilters.indexAccountsKeyList := -1;
+      finally
+        TNode.Node.Bank.SafeBox.EndThreadSave;
       end;
       end;
-    Finally
-      FAccountsGrid.UnlockAccountsList;
-    End;
-    lblAccountsCount.Caption := inttostr(accl.Count);
-  end else begin
-    lblAccountsCount.Caption := inttostr(TUserInterface.Node.Bank.AccountsCount);
+    end else begin
+      LFilters.OrderedAccountsKeyList := Nil;
+      LFilters.indexAccountsKeyList := -1;
+    end;
+    FAccountsGrid.AccountsGridFilter := LFilters;
+    FAccountsGrid.AccountsGridDatasource := acds_NodeFiltered;
   end;
   end;
+
   bbChangeKeyName.Enabled := cbExploreMyAccounts.Checked;
   bbChangeKeyName.Enabled := cbExploreMyAccounts.Checked;
-  // Show Totals:
-  lblAccountsBalance.Caption := TAccountComp.FormatMoney(FAccountsGrid.AccountsBalance);
   OnSelectedAccountChanged;
   OnSelectedAccountChanged;
 end;
 end;
 
 
@@ -717,7 +699,7 @@ begin
   if accn >= TUserInterface.Node.Bank.AccountsCount then
   if accn >= TUserInterface.Node.Bank.AccountsCount then
     raise Exception.Create('Account not found');
     raise Exception.Create('Account not found');
 
 
-  acc := TUserInterface.Node.Operations.SafeBoxTransaction.Account(accn);
+  acc := TUserInterface.Node.GetAccount(accn);
 
 
   i := FAccountOperationsGrid.DrawGrid.Row;
   i := FAccountOperationsGrid.DrawGrid.Row;
   if (i>0) and (i<=FAccountOperationsGrid.OperationsResume.Count) then begin
   if (i>0) and (i<=FAccountOperationsGrid.OperationsResume.Count) then begin

+ 1 - 1
src/gui-experimental/UFRMAccountSelect.lfm

@@ -15,7 +15,7 @@ object FRMAccountSelect: TFRMAccountSelect
   OnCreate = FormCreate
   OnCreate = FormCreate
   OnDestroy = FormDestroy
   OnDestroy = FormDestroy
   Position = poOwnerFormCenter
   Position = poOwnerFormCenter
-  Visible = False
+  LCLVersion = '2.0.2.0'
   object pnlAccountsTop: TPanel
   object pnlAccountsTop: TPanel
     Left = 395
     Left = 395
     Height = 282
     Height = 282

+ 2 - 2
src/gui-experimental/UFRMAccountSelect.pas

@@ -497,11 +497,11 @@ begin
   If (searchValues.inAccountKey.EC_OpenSSL_NID=0) AND (searchValues.inWalletKeys=Nil) And (searchValues.maxBal<0) And (searchValues.minBal<=0) And
   If (searchValues.inAccountKey.EC_OpenSSL_NID=0) AND (searchValues.inWalletKeys=Nil) And (searchValues.maxBal<0) And (searchValues.minBal<=0) And
      (Not searchValues.onlyForPrivateSaleToMe) And (Not searchValues.onlyForPublicSale) And (Not searchValues.onlyForSale) And
      (Not searchValues.onlyForPrivateSaleToMe) And (Not searchValues.onlyForPublicSale) And (Not searchValues.onlyForSale) And
      (Length(searchValues.searchName)=0) then begin
      (Length(searchValues.searchName)=0) then begin
-    FAccountsGrid.ShowAllAccounts:=True;
+    FAccountsGrid.AccountsGridDatasource := acds_Node;
     lblAccountsCount.Caption := IntToStr(FAccountsGrid.Node.Bank.SafeBox.AccountsCount);
     lblAccountsCount.Caption := IntToStr(FAccountsGrid.Node.Bank.SafeBox.AccountsCount);
     lblAccountsBalance.Caption := TAccountComp.FormatMoney(FAccountsGrid.AccountsBalance);
     lblAccountsBalance.Caption := TAccountComp.FormatMoney(FAccountsGrid.AccountsBalance);
   end else begin
   end else begin
-    FAccountsGrid.ShowAllAccounts:=False;
+    FAccountsGrid.AccountsGridDatasource := acds_InternalList;
     FSearchThread.DoSearch(searchValues);
     FSearchThread.DoSearch(searchValues);
   end;
   end;
 end;
 end;

+ 1 - 2
src/gui-experimental/UFRMMessages.lfm

@@ -11,8 +11,7 @@ object FRMMessages: TFRMMessages
   OnCreate = FormCreate
   OnCreate = FormCreate
   OnDestroy = FormDestroy
   OnDestroy = FormDestroy
   Position = poOwnerFormCenter
   Position = poOwnerFormCenter
-  LCLVersion = '1.8.2.0'
-  Visible = False
+  LCLVersion = '2.0.2.0'
   object Label11: TLabel
   object Label11: TLabel
     Left = 15
     Left = 15
     Height = 15
     Height = 15

+ 2 - 2
src/gui-experimental/UFRMMessages.pas

@@ -56,7 +56,7 @@ type
 
 
 implementation
 implementation
 
 
-uses UUserInterface, USettings;
+uses UUserInterface, USettings, Generics.Collections;
 
 
 {$R *.lfm}
 {$R *.lfm}
 
 
@@ -105,7 +105,7 @@ end;
 procedure TFRMMessages.UpdateAvailableConnections;
 procedure TFRMMessages.UpdateAvailableConnections;
 Var i : integer;
 Var i : integer;
  NC : TNetConnection;
  NC : TNetConnection;
- l : TList;
+ l : TList<TNetConnection>;
 begin
 begin
   if Not TNetData.NetData.NetConnections.TryLockList(100,l) then exit;
   if Not TNetData.NetData.NetConnections.TryLockList(100,l) then exit;
   try
   try

+ 1 - 1
src/gui-experimental/UFRMNodes.lfm

@@ -10,7 +10,7 @@ object FRMNodes: TFRMNodes
   OnCreate = FormCreate
   OnCreate = FormCreate
   OnDestroy = FormDestroy
   OnDestroy = FormDestroy
   Position = poOwnerFormCenter
   Position = poOwnerFormCenter
-  Visible = False
+  LCLVersion = '2.0.2.0'
   object Label3: TLabel
   object Label3: TLabel
     Left = 15
     Left = 15
     Height = 15
     Height = 15

+ 9 - 6
src/gui-experimental/UFRMNodes.pas

@@ -60,7 +60,7 @@ type
 
 
 implementation
 implementation
 
 
-uses UCommon, UUserInterface, UTime;
+uses UCommon, UUserInterface, UTime, Generics.Collections;
 
 
 {$R *.lfm}
 {$R *.lfm}
 
 
@@ -87,7 +87,7 @@ procedure TFRMNodes.CM_NetConnectionUpdated(var Msg: TMessage);
 Const CT_BooleanToString : Array[Boolean] of String = ('False','True');
 Const CT_BooleanToString : Array[Boolean] of String = ('False','True');
 Var i : integer;
 Var i : integer;
  NC : TNetConnection;
  NC : TNetConnection;
- l : TList;
+ l : TList<TNetConnection>;
  sClientApp, sLastConnTime : String;
  sClientApp, sLastConnTime : String;
  strings, sNSC, sRS, sDisc : TStrings;
  strings, sNSC, sRS, sDisc : TStrings;
  hh,nn,ss,ms : Word;
  hh,nn,ss,ms : Word;
@@ -170,7 +170,7 @@ end;
 procedure TFRMNodes.CM_NetNodeServersUpdated(var Msg: TMessage);
 procedure TFRMNodes.CM_NetNodeServersUpdated(var Msg: TMessage);
 Var i : integer;
 Var i : integer;
  P : PNodeServerAddress;
  P : PNodeServerAddress;
- l : TList;
+ l : TList<Pointer>;
  strings : TStrings;
  strings : TStrings;
  s : String;
  s : String;
 begin
 begin
@@ -185,6 +185,10 @@ begin
         P := l[i];
         P := l[i];
         if Not (P^.is_blacklisted) then begin
         if Not (P^.is_blacklisted) then begin
           s := Format('Server IP:%s:%d',[P^.ip,P^.port]);
           s := Format('Server IP:%s:%d',[P^.ip,P^.port]);
+          if (P^.last_connection_by_me>0) then begin
+            s := s + ' [Server] ';
+          end;
+
           if Assigned(P.netConnection) then begin
           if Assigned(P.netConnection) then begin
             If P.last_connection>0 then  s := s+ ' ** ACTIVE **'
             If P.last_connection>0 then  s := s+ ' ** ACTIVE **'
             else s := s+' ** TRYING TO CONNECT **';
             else s := s+' ** TRYING TO CONNECT **';
@@ -226,7 +230,7 @@ procedure TFRMNodes.CM_BlackListUpdated(var Msg: TMessage);
 Const CT_TRUE_FALSE : Array[Boolean] Of AnsiString = ('FALSE','TRUE');
 Const CT_TRUE_FALSE : Array[Boolean] Of AnsiString = ('FALSE','TRUE');
 Var i,j,n : integer;
 Var i,j,n : integer;
  P : PNodeServerAddress;
  P : PNodeServerAddress;
- l : TList;
+ l : TList<Pointer>;
  strings : TStrings;
  strings : TStrings;
 begin
 begin
   l := TNetData.NetData.NodeServersAddresses.LockList;
   l := TNetData.NetData.NodeServersAddresses.LockList;
@@ -235,8 +239,7 @@ begin
     strings.BeginUpdate;
     strings.BeginUpdate;
     Try
     Try
       strings.Clear;
       strings.Clear;
-//      strings.Add('BlackList Updated: %s by TID: %p', [DateTimeToStr(now), TThread.CurrentThread.ThreadID]);  XXXXXXXXXXXXXXXX Windows %p is invalid (not a pointer)
-      strings.Add('BlackList Updated: %s by TID: %s', [DateTimeToStr(now), IntToHex(PtrInt(TThread.CurrentThread.ThreadID),8)]);
+      strings.Add('BlackList Updated: '+DateTimeToStr(now)+' by TID:'+IntToHex(PtrInt(TThread.CurrentThread.ThreadID),8));
       j := 0; n:=0;
       j := 0; n:=0;
       for i := 0 to l.Count - 1 do begin
       for i := 0 to l.Count - 1 do begin
         P := l[i];
         P := l[i];

+ 1 - 1
src/gui-experimental/UFRMOperation.lfm

@@ -16,7 +16,7 @@ object FRMOperation: TFRMOperation
   OnCreate = FormCreate
   OnCreate = FormCreate
   OnDestroy = FormDestroy
   OnDestroy = FormDestroy
   Position = poOwnerFormCenter
   Position = poOwnerFormCenter
-  Visible = False
+  LCLVersion = '2.0.2.0'
   object lblAccountCaption: TLabel
   object lblAccountCaption: TLabel
     Left = 25
     Left = 25
     Height = 13
     Height = 13

+ 16 - 16
src/gui-experimental/UFRMOperation.pas

@@ -177,7 +177,7 @@ type
 implementation
 implementation
 
 
 uses
 uses
-  UECIES, UConst, UOpTransaction, UAES, UFRMWalletKeys, UUserInterface, UPCDataTypes;
+  UECIES, UCoreUtils, UConst, UOpTransaction, UAES, UFRMWalletKeys, UUserInterface, UPCDataTypes;
 
 
 {$R *.lfm}
 {$R *.lfm}
 
 
@@ -221,7 +221,7 @@ begin
     for iAcc := 0 to Length(_senderAccounts) - 1 do begin
     for iAcc := 0 to Length(_senderAccounts) - 1 do begin
 loop_start:
 loop_start:
       op := Nil;
       op := Nil;
-      account := FNode.Operations.SafeBoxTransaction.Account(_senderAccounts[iAcc]);
+      account := FNode.GetAccount(_senderAccounts[iAcc]);
       If Not UpdatePayload(account, errors) then
       If Not UpdatePayload(account, errors) then
         raise Exception.Create('Error encoding payload of sender account '+TAccountComp.AccountNumberToAccountTxtNumber(account.account)+': '+errors);
         raise Exception.Create('Error encoding payload of sender account '+TAccountComp.AccountNumberToAccountTxtNumber(account.account)+': '+errors);
       i := WalletKeys.IndexOfAccountKey(account.accountInfo.accountKey);
       i := WalletKeys.IndexOfAccountKey(account.accountInfo.accountKey);
@@ -552,7 +552,7 @@ end;
 
 
 function TFRMOperation.GetDefaultSenderAccount: TAccount;
 function TFRMOperation.GetDefaultSenderAccount: TAccount;
 begin
 begin
-  if FSenderAccounts.Count>=1 then Result := FNode.Operations.SafeBoxTransaction.Account( FSenderAccounts.Get(0) )
+  if FSenderAccounts.Count>=1 then Result := FNode.GetAccount( FSenderAccounts.Get(0) )
   else Result := CT_Account_NUL;
   else Result := CT_Account_NUL;
 end;
 end;
 
 
@@ -607,8 +607,8 @@ begin
   end;
   end;
   If SenderAccounts.Count>=1 then begin
   If SenderAccounts.Count>=1 then begin
     ebSignerAccount.text := TAccountComp.AccountNumberToAccountTxtNumber(SenderAccounts.Get(0));
     ebSignerAccount.text := TAccountComp.AccountNumberToAccountTxtNumber(SenderAccounts.Get(0));
-    ebChangeName.Text := FNode.Operations.SafeBoxTransaction.Account(SenderAccounts.Get(0)).name.ToPrintable;
-    ebChangeType.Text := IntToStr(FNode.Operations.SafeBoxTransaction.Account(SenderAccounts.Get(0)).account_type);
+    ebChangeName.Text := FNode.GetAccount(SenderAccounts.Get(0)).name.ToPrintable;
+    ebChangeType.Text := IntToStr(FNode.GetAccount(SenderAccounts.Get(0)).account_type);
   end else begin
   end else begin
     ebSignerAccount.text := '';
     ebSignerAccount.text := '';
     ebChangeName.Text := '';
     ebChangeName.Text := '';
@@ -699,7 +699,7 @@ begin
       ebSenderAccount.Text := TAccountComp.AccountNumberToAccountTxtNumber(SenderAccounts.Get(0));
       ebSenderAccount.Text := TAccountComp.AccountNumberToAccountTxtNumber(SenderAccounts.Get(0));
       memoAccounts.Visible := false;
       memoAccounts.Visible := false;
       ebSenderAccount.Visible := true;
       ebSenderAccount.Visible := true;
-      balance := TNode.Node.Operations.SafeBoxTransaction.Account(SenderAccounts.Get(0)).balance;
+      balance := TNode.Node.GetAccount(SenderAccounts.Get(0)).balance;
     end else begin
     end else begin
       // Multiple sender accounts
       // Multiple sender accounts
       lblAccountCaption.Caption := 'Accounts';
       lblAccountCaption.Caption := 'Accounts';
@@ -707,7 +707,7 @@ begin
       ebSenderAccount.Visible := false;
       ebSenderAccount.Visible := false;
       accountstext := '';
       accountstext := '';
       for i := 0 to SenderAccounts.Count - 1 do begin
       for i := 0 to SenderAccounts.Count - 1 do begin
-         acc := TNode.Node.Operations.SafeBoxTransaction.Account(SenderAccounts.Get(i));
+         acc := TNode.Node.GetAccount(SenderAccounts.Get(i));
          balance := balance + acc.balance;
          balance := balance + acc.balance;
          if (accountstext<>'') then accountstext:=accountstext+'; ';
          if (accountstext<>'') then accountstext:=accountstext+'; ';
          accountstext := accountstext+TAccountComp.AccountNumberToAccountTxtNumber(acc.account)+' ('+TAccountComp.FormatMoney(acc.balance)+')';
          accountstext := accountstext+TAccountComp.AccountNumberToAccountTxtNumber(acc.account)+' ('+TAccountComp.FormatMoney(acc.balance)+')';
@@ -760,7 +760,7 @@ begin
       errors := 'Invalid account number';
       errors := 'Invalid account number';
       exit;
       exit;
     end;
     end;
-    AccountToBuy := FNode.Operations.SafeBoxTransaction.Account(c);
+    AccountToBuy := FNode.GetAccount(c);
     If not TAccountComp.IsAccountForSale(AccountToBuy.accountInfo) then begin
     If not TAccountComp.IsAccountForSale(AccountToBuy.accountInfo) then begin
       errors := 'Account '+TAccountComp.AccountNumberToAccountTxtNumber(c)+' is not for sale';
       errors := 'Account '+TAccountComp.AccountNumberToAccountTxtNumber(c)+' is not for sale';
       exit;
       exit;
@@ -822,7 +822,7 @@ begin
       errors := 'Signer account does not exists '+TAccountComp.AccountNumberToAccountTxtNumber(auxC);
       errors := 'Signer account does not exists '+TAccountComp.AccountNumberToAccountTxtNumber(auxC);
       exit;
       exit;
     end;
     end;
-    SignerAccount := FNode.Operations.SafeBoxTransaction.Account(auxC);
+    SignerAccount := FNode.GetAccount(auxC);
     if (TAccountComp.IsAccountLocked(SignerAccount.accountInfo,FNode.Bank.BlocksCount)) then begin
     if (TAccountComp.IsAccountLocked(SignerAccount.accountInfo,FNode.Bank.BlocksCount)) then begin
       errors := 'Signer account '+TAccountComp.AccountNumberToAccountTxtNumber(SignerAccount.account)+' is locked until block '+IntToStr(SignerAccount.accountInfo.locked_until_block);
       errors := 'Signer account '+TAccountComp.AccountNumberToAccountTxtNumber(SignerAccount.account)+' is locked until block '+IntToStr(SignerAccount.accountInfo.locked_until_block);
       exit;
       exit;
@@ -917,7 +917,7 @@ begin
         errors := 'Signer account does not exists '+TAccountComp.AccountNumberToAccountTxtNumber(auxC);
         errors := 'Signer account does not exists '+TAccountComp.AccountNumberToAccountTxtNumber(auxC);
         exit;
         exit;
       end;
       end;
-      SignerAccount := FNode.Operations.SafeBoxTransaction.Account(auxC);
+      SignerAccount := FNode.GetAccount(auxC);
       if (TAccountComp.IsAccountLocked(SignerAccount.accountInfo,FNode.Bank.BlocksCount)) then begin
       if (TAccountComp.IsAccountLocked(SignerAccount.accountInfo,FNode.Bank.BlocksCount)) then begin
         errors := 'Signer account '+TAccountComp.AccountNumberToAccountTxtNumber(SignerAccount.account)+' is locked until block '+IntToStr(SignerAccount.accountInfo.locked_until_block);
         errors := 'Signer account '+TAccountComp.AccountNumberToAccountTxtNumber(SignerAccount.account)+' is locked until block '+IntToStr(SignerAccount.accountInfo.locked_until_block);
         exit;
         exit;
@@ -963,7 +963,7 @@ begin
       errors := 'Signer account does not exists '+TAccountComp.AccountNumberToAccountTxtNumber(auxC);
       errors := 'Signer account does not exists '+TAccountComp.AccountNumberToAccountTxtNumber(auxC);
       exit;
       exit;
     end;
     end;
-    SignerAccount := FNode.Operations.SafeBoxTransaction.Account(auxC);
+    SignerAccount := FNode.GetAccount(auxC);
     if (TAccountComp.IsAccountLocked(SignerAccount.accountInfo,FNode.Bank.BlocksCount)) then begin
     if (TAccountComp.IsAccountLocked(SignerAccount.accountInfo,FNode.Bank.BlocksCount)) then begin
       errors := 'Signer account '+TAccountComp.AccountNumberToAccountTxtNumber(SignerAccount.account)+' is locked until block '+IntToStr(SignerAccount.accountInfo.locked_until_block);
       errors := 'Signer account '+TAccountComp.AccountNumberToAccountTxtNumber(SignerAccount.account)+' is locked until block '+IntToStr(SignerAccount.accountInfo.locked_until_block);
       exit;
       exit;
@@ -1133,7 +1133,7 @@ begin
         errors := 'Signer account does not exists '+TAccountComp.AccountNumberToAccountTxtNumber(auxC);
         errors := 'Signer account does not exists '+TAccountComp.AccountNumberToAccountTxtNumber(auxC);
         exit;
         exit;
       end;
       end;
-      SignerAccount := FNode.Operations.SafeBoxTransaction.Account(auxC);
+      SignerAccount := FNode.GetAccount(auxC);
       // Seller
       // Seller
       If Not TAccountComp.AccountTxtNumberToAccountNumber(ebSellerAccount.Text,auxC) then begin
       If Not TAccountComp.AccountTxtNumberToAccountNumber(ebSellerAccount.Text,auxC) then begin
         errors := 'Invalid seller account';
         errors := 'Invalid seller account';
@@ -1148,7 +1148,7 @@ begin
         exit;
         exit;
       end;
       end;
 
 
-      SellerAccount := FNode.Operations.SafeBoxTransaction.Account(auxC);
+      SellerAccount := FNode.GetAccount(auxC);
       if rbListAccountForPrivateSale.Checked then begin
       if rbListAccountForPrivateSale.Checked then begin
         lblSaleNewOwnerPublicKey.Enabled := true;
         lblSaleNewOwnerPublicKey.Enabled := true;
         ebSaleNewOwnerPublicKey.Enabled := true;
         ebSaleNewOwnerPublicKey.Enabled := true;
@@ -1209,7 +1209,7 @@ begin
     lblTransactionErrors.Caption := errors;
     lblTransactionErrors.Caption := errors;
     exit;
     exit;
   end;
   end;
-  DestAccount := TNode.Node.Operations.SafeBoxTransaction.Account(c);
+  DestAccount := TNode.Node.GetAccount(c);
   if SenderAccounts.Count=1 then begin
   if SenderAccounts.Count=1 then begin
     if not TAccountComp.TxtToMoney(ebAmount.Text,amount) then begin
     if not TAccountComp.TxtToMoney(ebAmount.Text,amount) then begin
       errors := 'Invalid amount ('+ebAmount.Text+')';
       errors := 'Invalid amount ('+ebAmount.Text+')';
@@ -1256,7 +1256,7 @@ begin
     if (rbEncryptedWithOldEC.Checked) then begin
     if (rbEncryptedWithOldEC.Checked) then begin
       // Use sender
       // Use sender
       errors := 'Error encrypting';
       errors := 'Error encrypting';
-      account := FNode.Operations.SafeBoxTransaction.Account(SenderAccount.account);
+      account := FNode.GetAccount(SenderAccount.account);
       payload_encrypted := ECIESEncrypt(account.accountInfo.accountKey,TEncoding.ANSI.GetBytes(payload_u));
       payload_encrypted := ECIESEncrypt(account.accountInfo.accountKey,TEncoding.ANSI.GetBytes(payload_u));
       valid := Length(payload_encrypted)>0;
       valid := Length(payload_encrypted)>0;
     end else if (rbEncryptedWithEC.Checked) then begin
     end else if (rbEncryptedWithEC.Checked) then begin
@@ -1292,7 +1292,7 @@ begin
           errors := 'Invalid payload encrypted account number: '+TAccountComp.AccountNumberToAccountTxtNumber(dest_account_number);
           errors := 'Invalid payload encrypted account number: '+TAccountComp.AccountNumberToAccountTxtNumber(dest_account_number);
           exit;
           exit;
         end;
         end;
-        account := FNode.Operations.SafeBoxTransaction.Account(dest_account_number);
+        account := FNode.GetAccount(dest_account_number);
         payload_encrypted := ECIESEncrypt(account.accountInfo.accountKey,TEncoding.ANSI.GetBytes(payload_u));
         payload_encrypted := ECIESEncrypt(account.accountInfo.accountKey,TEncoding.ANSI.GetBytes(payload_u));
         valid := Length(payload_encrypted)>0;
         valid := Length(payload_encrypted)>0;
       end else if (PageControlOpType.ActivePage=tsChangePrivateKey) then begin
       end else if (PageControlOpType.ActivePage=tsChangePrivateKey) then begin

+ 1 - 2
src/gui-experimental/UFRMPayloadDecoder.lfm

@@ -15,8 +15,7 @@ object FRMPayloadDecoder: TFRMPayloadDecoder
   Font.Name = 'Tahoma'
   Font.Name = 'Tahoma'
   OnCreate = FormCreate
   OnCreate = FormCreate
   Position = poOwnerFormCenter
   Position = poOwnerFormCenter
-  LCLVersion = '1.8.2.0'
-  Visible = False
+  LCLVersion = '2.0.2.0'
   object Label1: TLabel
   object Label1: TLabel
     Left = 20
     Left = 20
     Height = 13
     Height = 13

+ 41 - 32
src/gui-experimental/UFRMPayloadDecoder.pas

@@ -96,7 +96,9 @@ implementation
 
 
 {$R *.lfm}
 {$R *.lfm}
 
 
-Uses UNode, UTime, UECIES, UAES, UAccounts, UCommon, UFRMMemoText, USettings, UBaseTypes;
+Uses
+  UNode, UTime, UECIES, UAES, UAccounts, UCommon, USettings, UBaseTypes,
+  UPCEncryption, UFRMMemoText;
 
 
 { TFRMPayloadDecoder }
 { TFRMPayloadDecoder }
 
 
@@ -347,10 +349,12 @@ procedure TFRMPayloadDecoder.TryToDecode;
   Var i : Integer;
   Var i : Integer;
   begin
   begin
     Result := false;
     Result := false;
+    if Not assigned(TWallet.Keys) then exit;
+
     for i := 0 to TWallet.Keys.Count - 1 do begin
     for i := 0 to TWallet.Keys.Count - 1 do begin
       WalletKey := TWallet.Keys.Key[i];
       WalletKey := TWallet.Keys.Key[i];
       If Assigned(WalletKey.PrivateKey) then begin
       If Assigned(WalletKey.PrivateKey) then begin
-        If ECIESDecrypt(WalletKey.PrivateKey.EC_OpenSSL_NID,WalletKey.PrivateKey.PrivateKey,false,raw,Decrypted) then begin
+        if TPCEncryption.DoPascalCoinECIESDecrypt(WalletKey.PrivateKey.PrivateKey,raw,Decrypted) then begin
           Result := true;
           Result := true;
           exit;
           exit;
         end;
         end;
@@ -359,12 +363,12 @@ procedure TFRMPayloadDecoder.TryToDecode;
 
 
   end;
   end;
 
 
-  Function  UsePassword(const raw : TRawBytes; var Decrypted: TRawBytes; var PasswordUsed : AnsiString) : Boolean;
+  Function  UsePassword(const raw : TRawBytes; var Decrypted : TRawBytes; var PasswordUsed : AnsiString) : Boolean;
   Var i : Integer;
   Var i : Integer;
   Begin
   Begin
     Result := false;
     Result := false;
     for i := 0 to memoPasswords.Lines.Count - 1 do begin
     for i := 0 to memoPasswords.Lines.Count - 1 do begin
-      if (TAESComp.EVP_Decrypt_AES256(raw,memoPasswords.Lines[i],Decrypted)) then begin
+      if TPCEncryption.DoPascalCoinAESDecrypt(raw,TEncoding.ANSI.GetBytes(memoPasswords.Lines[i]),Decrypted) then begin
         if (TCrypto.IsHumanReadable(Decrypted)) then begin
         if (TCrypto.IsHumanReadable(Decrypted)) then begin
           Result := true;
           Result := true;
           PasswordUsed := memoPasswords.Lines[i];
           PasswordUsed := memoPasswords.Lines[i];
@@ -377,42 +381,47 @@ procedure TFRMPayloadDecoder.TryToDecode;
 
 
 Var raw : TRawBytes;
 Var raw : TRawBytes;
   WalletKey : TWalletKey;
   WalletKey : TWalletKey;
-  Decrypted: TRawBytes;
+  Decrypted : TRawBytes;
   PasswordUsed : AnsiString;
   PasswordUsed : AnsiString;
   ok : boolean;
   ok : boolean;
 begin
 begin
   ok := true;
   ok := true;
-  raw := FOpResume.OriginalPayload;
-  if Length(raw)>0 then begin
-    // First try to a human readable...
-    if (cbMethodPublicPayload.Checked) and (TCrypto.IsHumanReadable(raw)) then begin
-      if cbShowAsHexadecimal.Checked then memoDecoded.Lines.Text := TCrypto.ToHexaString(raw)
-      else memoDecoded.Lines.Text := TEncoding.ANSI.GetString(raw);
-      lblDecodedMethod.Caption := 'Not encrypted payload';
-    end else if (cbUsingPrivateKeys.Checked) And (UseWallet(raw,Decrypted,WalletKey)) then begin
-      if cbShowAsHexadecimal.Checked then memoDecoded.Lines.Text := TCrypto.ToHexaString(Decrypted)
-      else memoDecoded.Lines.Text := TEncoding.ANSI.GetString(Decrypted);
-      lblDecodedMethod.Caption := 'Encrypted with EC '+TAccountComp.GetECInfoTxt(WalletKey.PrivateKey.EC_OpenSSL_NID);
-    end else if (cbUsingPasswords.Checked) And (UsePassword(raw,Decrypted,PasswordUsed)) then begin
-      if cbShowAsHexadecimal.Checked then memoDecoded.Lines.Text := TCrypto.ToHexaString(Decrypted)
-      else memoDecoded.Lines.Text := TEncoding.ANSI.GetString(Decrypted);
-      lblDecodedMethod.Caption := 'Encrypted with pwd:"'+PasswordUsed+'"';
+  if Assigned(TWallet.Keys) then begin
+    raw := FOpResume.OriginalPayload;
+    if Length(raw)>0 then begin
+      // First try to a human readable...
+      if (cbMethodPublicPayload.Checked) and (TCrypto.IsHumanReadable(raw)) then begin
+        if cbShowAsHexadecimal.Checked then memoDecoded.Lines.Text := TCrypto.ToHexaString(raw)
+        else memoDecoded.Lines.Text := TEncoding.ANSI.GetString(raw);
+        lblDecodedMethod.Caption := 'Not encrypted payload';
+      end else if (cbUsingPrivateKeys.Checked) And (UseWallet(raw,Decrypted,WalletKey)) then begin
+        if cbShowAsHexadecimal.Checked then memoDecoded.Lines.Text := TCrypto.ToHexaString(Decrypted)
+        else memoDecoded.Lines.Text := TEncoding.ANSI.GetString(Decrypted);
+        lblDecodedMethod.Caption := 'Encrypted with EC '+TAccountComp.GetECInfoTxt(WalletKey.PrivateKey.EC_OpenSSL_NID);
+      end else if (cbUsingPasswords.Checked) And (UsePassword(raw,Decrypted,PasswordUsed)) then begin
+        if cbShowAsHexadecimal.Checked then memoDecoded.Lines.Text := TCrypto.ToHexaString(Decrypted)
+        else memoDecoded.Lines.Text := TEncoding.ANSI.GetString(Decrypted);
+        lblDecodedMethod.Caption := 'Encrypted with pwd:"'+PasswordUsed+'"';
+      end else begin
+        memoDecoded.Lines.Text := 'CANNOT DECRYPT';
+        lblDecodedMethod.Caption := '';
+        ok := false;
+      end;
+      if ok then begin
+        memoDecoded.Font.Color := clBlack;
+        memoDecoded.Color := clWhite;
+      end else begin
+        memoDecoded.Font.Color := clRed;
+        memoDecoded.Color := clBtnFace;
+      end;
     end else begin
     end else begin
-      memoDecoded.Lines.Text := 'CANNOT DECRYPT';
+      memoDecoded.Lines.Text := '(No payload)';
+      memoDecoded.Font.Color := clDkGray;
+      memoDecoded.Color := clLtGray;
       lblDecodedMethod.Caption := '';
       lblDecodedMethod.Caption := '';
-      ok := false;
-    end;
-    if ok then begin
-      memoDecoded.Font.Color := clBlack;
-      memoDecoded.Color := clWhite;
-    end else begin
-      memoDecoded.Font.Color := clRed;
-      memoDecoded.Color := clBtnFace;
     end;
     end;
   end else begin
   end else begin
-    memoDecoded.Lines.Text := '(No payload)';
-    memoDecoded.Font.Color := clDkGray;
-    memoDecoded.Color := clLtGray;
+    memoDecoded.Lines.Text := '';
     lblDecodedMethod.Caption := '';
     lblDecodedMethod.Caption := '';
   end;
   end;
 end;
 end;

+ 3 - 3
src/gui-experimental/UFRMSaleAccounts.pas

@@ -92,7 +92,7 @@ begin
     operation_to_string := '';
     operation_to_string := '';
     for iAcc := 0 to FSenderAccounts.Count - 1 do begin
     for iAcc := 0 to FSenderAccounts.Count - 1 do begin
       op := Nil;
       op := Nil;
-      account := FNode.Operations.SafeBoxTransaction.Account(FSenderAccounts.Get(iAcc));
+      account := FNode.GetAccount(FSenderAccounts.Get(iAcc));
       If Not UpdatePayload(account, errors) then
       If Not UpdatePayload(account, errors) then
         raise Exception.Create('Error encoding payload of sender account '+TAccountComp.AccountNumberToAccountTxtNumber(account.account)+': '+errors);
         raise Exception.Create('Error encoding payload of sender account '+TAccountComp.AccountNumberToAccountTxtNumber(account.account)+': '+errors);
       i := WalletKeys.IndexOfAccountKey(account.accountInfo.accountKey);
       i := WalletKeys.IndexOfAccountKey(account.accountInfo.accountKey);
@@ -236,7 +236,7 @@ begin
       ebSenderAccount.Text := TAccountComp.AccountNumberToAccountTxtNumber(SenderAccounts.Get(0));
       ebSenderAccount.Text := TAccountComp.AccountNumberToAccountTxtNumber(SenderAccounts.Get(0));
       memoAccounts.Visible := false;
       memoAccounts.Visible := false;
       ebSenderAccount.Visible := true;
       ebSenderAccount.Visible := true;
-      balance := TNode.Node.Operations.SafeBoxTransaction.Account(SenderAccounts.Get(0)).balance;
+      balance := TNode.Node.GetAccount(SenderAccounts.Get(0)).balance;
     end else begin
     end else begin
       // Multiple sender accounts
       // Multiple sender accounts
       lblAccountCaption.Caption := 'Accounts';
       lblAccountCaption.Caption := 'Accounts';
@@ -244,7 +244,7 @@ begin
       ebSenderAccount.Visible := false;
       ebSenderAccount.Visible := false;
       accountstext := '';
       accountstext := '';
       for i := 0 to SenderAccounts.Count - 1 do begin
       for i := 0 to SenderAccounts.Count - 1 do begin
-         acc := TNode.Node.Operations.SafeBoxTransaction.Account(SenderAccounts.Get(i));
+         acc := TNode.Node.GetAccount(SenderAccounts.Get(i));
          balance := balance + acc.balance;
          balance := balance + acc.balance;
          if (accountstext<>'') then accountstext:=accountstext+'; ';
          if (accountstext<>'') then accountstext:=accountstext+'; ';
          accountstext := accountstext+TAccountComp.AccountNumberToAccountTxtNumber(acc.account)+' ('+TAccountComp.FormatMoney(acc.balance)+')';
          accountstext := accountstext+TAccountComp.AccountNumberToAccountTxtNumber(acc.account)+' ('+TAccountComp.FormatMoney(acc.balance)+')';

+ 17 - 4
src/gui-experimental/UUserInterface.pas

@@ -485,12 +485,18 @@ begin
 end;
 end;
 
 
 class procedure TUserInterface.OnLoaded(Sender: TObject);
 class procedure TUserInterface.OnLoaded(Sender: TObject);
+var LLockedMempool : TPCOperationsComp;
 begin
 begin
   FPoolMiningServer := TPoolMiningServer.Create;
   FPoolMiningServer := TPoolMiningServer.Create;
   FPoolMiningServer.Port := TSettings.MinerServerRpcPort;
   FPoolMiningServer.Port := TSettings.MinerServerRpcPort;
   FPoolMiningServer.MinerAccountKey := TWallet.MiningKey;
   FPoolMiningServer.MinerAccountKey := TWallet.MiningKey;
   FPoolMiningServer.MinerPayload := TEncoding.ANSI.GetBytes(TSettings.MinerName);
   FPoolMiningServer.MinerPayload := TEncoding.ANSI.GetBytes(TSettings.MinerName);
-  FNode.Operations.AccountKey := TWallet.MiningKey;
+  LLockedMempool := FNode.LockMempoolWrite;
+  try
+    LLockedMempool.AccountKey := TWallet.MiningKey;
+  finally
+    FNode.UnlockMempoolWrite;
+  end;
   FPoolMiningServer.Active := TSettings.MinerServerRpcActive;
   FPoolMiningServer.Active := TSettings.MinerServerRpcActive;
   FPoolMiningServer.OnMiningServerNewBlockFound := NotifyMiningServerNewBlockFoundEvent;
   FPoolMiningServer.OnMiningServerNewBlockFound := NotifyMiningServerNewBlockFoundEvent;
   State := uisLoaded;
   State := uisLoaded;
@@ -531,8 +537,10 @@ begin
 end;
 end;
 
 
 class procedure TUserInterface.OnSettingsChanged(Sender: TObject);
 class procedure TUserInterface.OnSettingsChanged(Sender: TObject);
-Var wa : Boolean;
+var
+  wa : Boolean;
   i : Integer;
   i : Integer;
+  LLockedMempool : TPCOperationsComp;
 begin
 begin
   if TSettings.SaveLogFiles then begin
   if TSettings.SaveLogFiles then begin
     if TSettings.SaveDebugLogs then
     if TSettings.SaveDebugLogs then
@@ -548,7 +556,12 @@ begin
     wa := FNode.NetServer.Active;
     wa := FNode.NetServer.Active;
     FNode.NetServer.Port := TSettings.InternetServerPort;
     FNode.NetServer.Port := TSettings.InternetServerPort;
     FNode.NetServer.Active := wa;
     FNode.NetServer.Active := wa;
-    FNode.Operations.BlockPayload := TEncoding.ANSI.GetBytes(TSettings.MinerName);
+    LLockedMempool := FNode.LockMempoolWrite;
+    try
+      LLockedMempool.BlockPayload := TEncoding.ANSI.GetBytes(TSettings.MinerName);
+    finally
+      FNode.UnlockMempoolWrite;
+    end;
     FNode.NodeLogFilename := TFolderHelper.GetPascalCoinDataFolder+PathDelim+'blocks.log';
     FNode.NodeLogFilename := TFolderHelper.GetPascalCoinDataFolder+PathDelim+'blocks.log';
   end;
   end;
   if Assigned(FPoolMiningServer) then begin
   if Assigned(FPoolMiningServer) then begin
@@ -723,7 +736,7 @@ class procedure TUserInterface.ShowAccountInfoDialog(parentForm: TForm; const ac
 begin
 begin
   if account >= TUserInterface.Node.Bank.AccountsCount then
   if account >= TUserInterface.Node.Bank.AccountsCount then
     raise EUserInterface.Create('Account not found');
     raise EUserInterface.Create('Account not found');
-  ShowAccountInfoDialog(parentForm, TUserInterface.Node.Operations.SafeBoxTransaction.Account(account));
+  ShowAccountInfoDialog(parentForm, TUserInterface.Node.GetAccount(account));
 end;
 end;
 
 
 class procedure TUserInterface.ShowAccountInfoDialog(parentForm: TForm; const account : TAccount); overload;
 class procedure TUserInterface.ShowAccountInfoDialog(parentForm: TForm; const account : TAccount); overload;

+ 32 - 16
src/gui-experimental/core.utils/UCoreUtils.pas

@@ -234,11 +234,13 @@ var
   LAccs: TList<TAccount>;
   LAccs: TList<TAccount>;
   LAcc: TAccount;
   LAcc: TAccount;
   LList: TOrderedCardinalList;
   LList: TOrderedCardinalList;
+  LMemPool: TPCOperationsComp;
   Disposables: TDisposables;
   Disposables: TDisposables;
 begin
 begin
   Balance := CT_BalanceSummary_Nil;
   Balance := CT_BalanceSummary_Nil;
   LAccs := Disposables.AddObject(TList<TAccount>.Create) as TList<TAccount>;
   LAccs := Disposables.AddObject(TList<TAccount>.Create) as TList<TAccount>;
-  TNode.Node.Bank.SafeBox.StartThreadSafe;
+//  TNode.Node.Bank.SafeBox.StartThreadSafe;
+  LMemPool := TNode.Node.LockMempoolRead;
   try
   try
     for i := 0 to TWallet.Keys.Count - 1 do
     for i := 0 to TWallet.Keys.Count - 1 do
     begin
     begin
@@ -246,7 +248,7 @@ begin
       for j := 0 to LList.Count - 1 do
       for j := 0 to LList.Count - 1 do
       begin
       begin
         if IncludePending then
         if IncludePending then
-          LAcc := TNode.Node.Operations.SafeBoxTransaction.Account(LList.Get(j))
+          LAcc := LMemPool.SafeBoxTransaction.Account(LList.Get(j))
         else
         else
           LAcc := TNode.Node.Bank.SafeBox.Account(LList.Get(j));
           LAcc := TNode.Node.Bank.SafeBox.Account(LList.Get(j));
         LAccs.Add(LAcc);
         LAccs.Add(LAcc);
@@ -255,7 +257,8 @@ begin
       end;
       end;
     end;
     end;
   finally
   finally
-    TNode.Node.Bank.SafeBox.EndThreadSave;
+    TNode.Node.UnlockMempoolRead;
+//    TNode.Node.Bank.SafeBox.EndThreadSave;
   end;
   end;
   LAccs.Sort(TAccountComparer.Create);
   LAccs.Sort(TAccountComparer.Create);
   Result := LAccs.ToArray;
   Result := LAccs.ToArray;
@@ -328,11 +331,18 @@ end;
 function TNodeHelper.GetAccounts(const AAccountNumbers: array of cardinal; AIncludePending: boolean = True): TArray<TAccount>;
 function TNodeHelper.GetAccounts(const AAccountNumbers: array of cardinal; AIncludePending: boolean = True): TArray<TAccount>;
 var
 var
   i: integer;
   i: integer;
+  LMemPool : TPCOperationsComp;
 begin
 begin
   SetLength(Result, Length(AAccountNumbers));
   SetLength(Result, Length(AAccountNumbers));
-  if AIncludePending then
-    for i := Low(AAccountNumbers) to High(AAccountNumbers) do
-      Result[i] := Self.Operations.SafeBoxTransaction.Account(AAccountNumbers[i])
+  if AIncludePending then begin
+    LMemPool := Self.LockMempoolRead;
+    try
+      for i := Low(AAccountNumbers) to High(AAccountNumbers) do
+        Result[i] := LMemPool.SafeBoxTransaction.Account(AAccountNumbers[i])
+    finally
+      Self.UnlockMempoolRead;
+    end;
+  end
   else
   else
     for i := Low(AAccountNumbers) to High(AAccountNumbers) do
     for i := Low(AAccountNumbers) to High(AAccountNumbers) do
       Result[i] := Self.Bank.SafeBox.Account(AAccountNumbers[i]);
       Result[i] := Self.Bank.SafeBox.Account(AAccountNumbers[i]);
@@ -340,37 +350,43 @@ end;
 
 
 function TNodeHelper.GetPendingOperationsAffectingAccounts(const AAccountNumbers: array of cardinal; ASkipCount, ATakeCount: integer): TArray<TOperationResume>;
 function TNodeHelper.GetPendingOperationsAffectingAccounts(const AAccountNumbers: array of cardinal; ASkipCount, ATakeCount: integer): TArray<TOperationResume>;
 var
 var
-  LList: Classes.TList;
+  LList: TList<Cardinal>;
   LOps: TList<TOperationResume>;
   LOps: TList<TOperationResume>;
   LOp: TPCOperation;
   LOp: TPCOperation;
   LOpResume: TOperationResume;
   LOpResume: TOperationResume;
+  LMemPool : TPCOperationsComp;
   LAccNo: cardinal;
   LAccNo: cardinal;
   LNumOps, i: integer;
   LNumOps, i: integer;
   GC: TDisposables;
   GC: TDisposables;
 begin
 begin
   LNumOps := 0;
   LNumOps := 0;
-  LList := GC.AddObject(Classes.TList.Create) as Classes.TList;
+  LList := GC.AddObject(TList<Cardinal>.Create) as TList<Cardinal>;
   LOps := GC.AddObject(TList<TOperationResume>.Create) as TList<TOperationResume>;
   LOps := GC.AddObject(TList<TOperationResume>.Create) as TList<TOperationResume>;
   for LAccNo in AAccountNumbers do
   for LAccNo in AAccountNumbers do
   begin
   begin
+    LMemPool := Self.LockMempoolRead;
+    try
     LList.Clear;
     LList.Clear;
-    Self.Operations.OperationsHashTree.GetOperationsAffectingAccount(LAccNo, LList);
+    LMemPool.OperationsHashTree.GetOperationsAffectingAccount(LAccNo, LList);
     if LList.Count > 0 then
     if LList.Count > 0 then
       for i := LList.Count - 1 downto 0 do
       for i := LList.Count - 1 downto 0 do
       begin
       begin
         Inc(LNumOps);
         Inc(LNumOps);
         if (LNumOps > ASkipCount) and (LNumOps <= ASkipCount + ATakeCount) then
         if (LNumOps > ASkipCount) and (LNumOps <= ASkipCount + ATakeCount) then
         begin
         begin
-          LOp := Self.Operations.OperationsHashTree.GetOperation(PtrInt(LList[i]));
+          LOp := LMemPool.OperationsHashTree.GetOperation(LList[i]);
           if TPCOperation.OperationToOperationResume(0, LOp, False, LAccNo, LOpResume) then
           if TPCOperation.OperationToOperationResume(0, LOp, False, LAccNo, LOpResume) then
           begin
           begin
             LOpResume.NOpInsideBlock := i;
             LOpResume.NOpInsideBlock := i;
-            LOpResume.Block := Node.Operations.OperationBlock.block;
-            LOpResume.Balance := Node.Operations.SafeBoxTransaction.Account(LAccNo {Op.SignerAccount}).balance;
+            LOpResume.Block := LMemPool.OperationBlock.block;
+            LOpResume.Balance := LMemPool.SafeBoxTransaction.Account(LAccNo {Op.SignerAccount}).balance;
             LOps.Add(LOpResume);
             LOps.Add(LOpResume);
           end;
           end;
         end;
         end;
       end;
       end;
+    finally
+      Self.UnlockMempoolRead;
+    end;
   end;
   end;
   Result := LOps.ToArray;
   Result := LOps.ToArray;
 end;
 end;
@@ -381,7 +397,7 @@ type
 var
 var
   i: integer;
   i: integer;
   LBlock: cardinal;
   LBlock: cardinal;
-  LRelevantBlockOps: Classes.TList;
+  LRelevantBlockOps: TList<Cardinal>;
   LOp: TPCOperation;
   LOp: TPCOperation;
   LOpResume: TOperationResume;
   LOpResume: TOperationResume;
   LFoundOps: TList<TOperationResume>;
   LFoundOps: TList<TOperationResume>;
@@ -409,7 +425,7 @@ var
     LDisposables: TDisposables;
     LDisposables: TDisposables;
   begin
   begin
     LOpsComp := LDisposables.AddObject(TPCOperationsComp.Create(nil)) as TPCOperationsComp;
     LOpsComp := LDisposables.AddObject(TPCOperationsComp.Create(nil)) as TPCOperationsComp;
-    LRelevantBlockOps := LDisposables.AddObject(Classes.TList.Create) as Classes.TList;
+    LRelevantBlockOps := LDisposables.AddObject(TList<Cardinal>.Create) as TList<Cardinal>;
 
 
     // load block
     // load block
     if not Bank.Storage.LoadBlockChainBlock(LOpsComp, ABlockNum) then
     if not Bank.Storage.LoadBlockChainBlock(LOpsComp, ABlockNum) then
@@ -425,10 +441,10 @@ var
       LOpsComp.OperationsHashTree.GetOperationsAffectingAccount(LAccNo, LRelevantBlockOps);
       LOpsComp.OperationsHashTree.GetOperationsAffectingAccount(LAccNo, LRelevantBlockOps);
       for i := LRelevantBlockOps.Count - 1 downto 0 do
       for i := LRelevantBlockOps.Count - 1 downto 0 do
       begin
       begin
-        LOp := LOpsComp.Operation[PtrInt(LRelevantBlockOps.Items[i])];
+        LOp := LOpsComp.Operation[LRelevantBlockOps.Items[i]];
         if TPCOperation.OperationToOperationResume(i, LOp, False, LAccNo, LOpResume) then
         if TPCOperation.OperationToOperationResume(i, LOp, False, LAccNo, LOpResume) then
         begin
         begin
-          LOpResume.NOpInsideBlock := PtrInt(LRelevantBlockOps.Items[i]);
+          LOpResume.NOpInsideBlock := LRelevantBlockOps.Items[i];
           LOpResume.time := LOpsComp.OperationBlock.timestamp;
           LOpResume.time := LOpsComp.OperationBlock.timestamp;
           LOpResume.Block := ABlockNum;
           LOpResume.Block := ABlockNum;
           if LAccountBalances[LAccNo] >= 0 then
           if LAccountBalances[LAccNo] >= 0 then

+ 32 - 25
src/gui-experimental/core.utils/UDataSources.pas

@@ -234,27 +234,28 @@ end;
 procedure TAccountsDataSource.FetchAll(const AContainer: TList<TAccount>);
 procedure TAccountsDataSource.FetchAll(const AContainer: TList<TAccount>);
 var
 var
   i: integer;
   i: integer;
-  acc: TAccount;
-  safeBox: TPCSafeBox;
+  LAcc: TAccount;
+  LSafeBox: TPCSafeBox;
+  LMemPool : TPCOperationsComp;
 begin
 begin
-  safeBox := TNode.Node.Bank.SafeBox;
-  safeBox.StartThreadSafe;
+  LSafeBox := TNode.Node.Bank.SafeBox;
+  LMemPool := TNode.Node.LockMempoolRead;
   try
   try
     if FKeys.Count = 0 then
     if FKeys.Count = 0 then
-      for i := 0 to safeBox.AccountsCount - 1 do
-        AContainer.Add(safeBox.Account(i)) // Load all accounts
+      for i := 0 to LSafeBox.AccountsCount - 1 do
+        AContainer.Add(LSafeBox.Account(i)) // Load all accounts
     else
     else
-      for i := 0 to safeBox.AccountsCount - 1 do begin
+      for i := 0 to LSafeBox.AccountsCount - 1 do begin
         // Load key-matching accounts
         // Load key-matching accounts
         if FIncludePending then
         if FIncludePending then
-          acc := TNode.Node.Operations.SafeBoxTransaction.Account(i)
+          LAcc := LMemPool.SafeBoxTransaction.Account(i)
         else
         else
-          acc := safeBox.Account(i);
-        if FKeys.Contains(acc.accountInfo.accountKey) then
-          AContainer.Add(acc);
+          LAcc := LSafeBox.Account(i);
+        if FKeys.Contains(LAcc.accountInfo.accountKey) then
+          AContainer.Add(LAcc);
       end;
       end;
   finally
   finally
-    safeBox.EndThreadSave;
+    TNode.Node.UnlockMempoolRead;
   end;
   end;
 end;
 end;
 
 
@@ -393,23 +394,29 @@ end;
 procedure TPendingOperationsDataSource.FetchAll(const AContainer: TList<TOperationResume>);
 procedure TPendingOperationsDataSource.FetchAll(const AContainer: TList<TOperationResume>);
 var
 var
   i: integer;
   i: integer;
-  node: TNode;
-  Op: TPCOperation;
-  OPR: TOperationResume;
+  LNode: TNode;
+  LOp: TPCOperation;
+  LOPR: TOperationResume;
+  LMemPool : TPCOperationsComp;
 begin
 begin
-  node := TNode.Node;
-  if not Assigned(Node) then
+  LNode := TNode.Node;
+  if not Assigned(LNode) then
     exit;
     exit;
-  for i := Node.Operations.Count - 1 downto 0 do
-  begin
-    Op := Node.Operations.OperationsHashTree.GetOperation(i);
-    if TPCOperation.OperationToOperationResume(0, Op, False, Op.SignerAccount, OPR) then
+  LMemPool := LNode.LockMempoolRead;
+  try
+    for i := LMemPool.Count - 1 downto 0 do
     begin
     begin
-      OPR.NOpInsideBlock := i;
-      OPR.Block := Node.Bank.BlocksCount;
-      OPR.Balance := Node.Operations.SafeBoxTransaction.Account(Op.SignerAccount).balance;
-      AContainer.Add(OPR);
+      LOp := LMemPool.OperationsHashTree.GetOperation(i);
+      if TPCOperation.OperationToOperationResume(0, LOp, False, LOp.SignerAccount, LOPR) then
+      begin
+        LOPR.NOpInsideBlock := i;
+        LOPR.Block := LNode.Bank.BlocksCount;
+        LOPR.Balance := LMemPool.SafeBoxTransaction.Account(LOp.SignerAccount).balance;
+        AContainer.Add(LOPR);
+      end;
     end;
     end;
+  finally
+    LNode.UnlockMempoolRead;
   end;
   end;
 end;
 end;
 
 

+ 1 - 1
src/gui-experimental/wizards/operations/UWIZBuyAccount_Details.lfm

@@ -8,7 +8,7 @@ object WIZBuyAccount_Details: TWIZBuyAccount_Details
   Caption = 'WIZBuyAccount_Details'
   Caption = 'WIZBuyAccount_Details'
   ClientHeight = 561
   ClientHeight = 561
   ClientWidth = 450
   ClientWidth = 450
-  Visible = False
+  LCLVersion = '2.0.2.0'
   object gbAccountToBuy: TGroupBox
   object gbAccountToBuy: TGroupBox
     Left = 8
     Left = 8
     Height = 124
     Height = 124

+ 3 - 3
src/gui-experimental/wizards/operations/UWIZBuyAccount_Details.pas

@@ -122,7 +122,7 @@ begin
       lblAccountToBuyDetails.Caption := ''
       lblAccountToBuyDetails.Caption := ''
     else
     else
     begin
     begin
-      LTempAccount := TNode.Node.Operations.SafeBoxTransaction.account(LAccountNumber);
+      LTempAccount := TNode.Node.GetAccount(LAccountNumber);
       lblAccountToBuyDetails.Caption := LTempAccount.Name.ToPrintable;
       lblAccountToBuyDetails.Caption := LTempAccount.Name.ToPrintable;
     end;
     end;
 end;
 end;
@@ -163,7 +163,7 @@ begin
 
 
   // Account To Buy section
   // Account To Buy section
   TAccountComp.AccountTxtNumberToAccountNumber(txtAccountToBuy.Text, LAccountNumber);
   TAccountComp.AccountTxtNumberToAccountNumber(txtAccountToBuy.Text, LAccountNumber);
-  Model.BuyAccount.AccountToBuy := TNode.Node.Operations.SafeBoxTransaction.account(LAccountNumber);
+  Model.BuyAccount.AccountToBuy := TNode.Node.GetAccount(LAccountNumber);
 
 
   // Fee Section
   // Fee Section
   Model.Fee.SingleOperationFee := TSettings.DefaultFee;
   Model.Fee.SingleOperationFee := TSettings.DefaultFee;
@@ -204,7 +204,7 @@ begin
     Exit(False);
     Exit(False);
   end;
   end;
 
 
-  LAccountToBuy := TNode.Node.Operations.SafeBoxTransaction.Account(LAccountNumber);
+  LAccountToBuy := TNode.Node.GetAccount(LAccountNumber);
 
 
   if not TAccountComp.IsAccountForSale(LAccountToBuy.accountInfo) then
   if not TAccountComp.IsAccountForSale(LAccountToBuy.accountInfo) then
   begin
   begin

+ 1 - 1
src/gui-experimental/wizards/operations/UWIZEnlistAccountForSale_EnterSeller.lfm

@@ -7,7 +7,7 @@ object WIZEnlistAccountForSale_EnterSeller: TWIZEnlistAccountForSale_EnterSeller
   Caption = 'WIZEnlistAccountForSale_EnterSeller'
   Caption = 'WIZEnlistAccountForSale_EnterSeller'
   ClientHeight = 286
   ClientHeight = 286
   ClientWidth = 450
   ClientWidth = 450
-  Visible = False
+  LCLVersion = '2.0.2.0'
   object gbBeneficiary: TGroupBox
   object gbBeneficiary: TGroupBox
     Left = 8
     Left = 8
     Height = 124
     Height = 124

+ 3 - 3
src/gui-experimental/wizards/operations/UWIZEnlistAccountForSale_EnterSeller.pas

@@ -73,7 +73,7 @@ begin
     end
     end
     else
     else
     begin
     begin
-      LAccount := TNode.Node.Operations.SafeBoxTransaction.account(LAccountNumber);
+      LAccount := TNode.Node.GetAccount(LAccountNumber);
       lblBeneficiaryDetails.Caption := LAccount.Name.ToPrintable;
       lblBeneficiaryDetails.Caption := LAccount.Name.ToPrintable;
       lblBeneficiaryDetails.Visible := True;
       lblBeneficiaryDetails.Visible := True;
     end;
     end;
@@ -118,7 +118,7 @@ var
   LAccount: TAccount;
   LAccount: TAccount;
 begin
 begin
   TAccountComp.AccountTxtNumberToAccountNumber(edtBeneficiaryAcc.Text, LAccountNumber);
   TAccountComp.AccountTxtNumberToAccountNumber(edtBeneficiaryAcc.Text, LAccountNumber);
-  Model.SendPASC.DestinationAccount := TNode.Node.Operations.SafeBoxTransaction.account(LAccountNumber);
+  Model.SendPASC.DestinationAccount := TNode.Node.GetAccount(LAccountNumber);
 end;
 end;
 
 
 function TWIZEnlistAccountForSale_EnterSeller.Validate(out message: ansistring): boolean;
 function TWIZEnlistAccountForSale_EnterSeller.Validate(out message: ansistring): boolean;
@@ -147,7 +147,7 @@ begin
       Exit(False);
       Exit(False);
     end;
     end;
 
 
-  Model.EnlistAccountForSale.SellerAccount := TNode.Node.Operations.SafeBoxTransaction.account(LAccountNumber);
+  Model.EnlistAccountForSale.SellerAccount := TNode.Node.GetAccount(LAccountNumber);
 
 
 end;
 end;
 
 

+ 1 - 2
src/gui-experimental/wizards/operations/UWIZSendPASC_Details.lfm

@@ -8,8 +8,7 @@ object WIZSendPASC_Details: TWIZSendPASC_Details
   Caption = 'WIZSendPASC_Details'
   Caption = 'WIZSendPASC_Details'
   ClientHeight = 379
   ClientHeight = 379
   ClientWidth = 450
   ClientWidth = 450
-  LCLVersion = '1.8.2.0'
-  Visible = False
+  LCLVersion = '2.0.2.0'
   object gbRecipient: TGroupBox
   object gbRecipient: TGroupBox
     Left = 8
     Left = 8
     Height = 124
     Height = 124

+ 5 - 4
src/gui-experimental/wizards/operations/UWIZSendPASC_Details.pas

@@ -69,6 +69,7 @@ uses
   UCoreUtils,
   UCoreUtils,
   UBaseTypes,
   UBaseTypes,
   UCoreObjects,
   UCoreObjects,
+  UBlockChain,
   UFRMAccountSelect,
   UFRMAccountSelect,
   UCommon.Collections,
   UCommon.Collections,
   Generics.Collections,
   Generics.Collections,
@@ -102,13 +103,13 @@ var
   LTempAccount: TAccount;
   LTempAccount: TAccount;
   LAccountNumber: cardinal;
   LAccountNumber: cardinal;
 begin
 begin
+
   // Recipient section
   // Recipient section
   if TAccountComp.AccountTxtNumberToAccountNumber(txtRecipient.Text, LAccountNumber) then
   if TAccountComp.AccountTxtNumberToAccountNumber(txtRecipient.Text, LAccountNumber) then
     if ((LAccountNumber < 0) or (LAccountNumber >= TNode.Node.Bank.AccountsCount)) then
     if ((LAccountNumber < 0) or (LAccountNumber >= TNode.Node.Bank.AccountsCount)) then
       lblRecipientDetails.Caption := ''
       lblRecipientDetails.Caption := ''
-    else
-    begin
-      LTempAccount := TNode.Node.Operations.SafeBoxTransaction.account(LAccountNumber);
+    else begin
+      LTempAccount := TNode.Node.GetAccount(LAccountNumber);
       lblRecipientDetails.Caption := LTempAccount.Name.ToPrintable;
       lblRecipientDetails.Caption := LTempAccount.Name.ToPrintable;
     end;
     end;
 
 
@@ -138,7 +139,7 @@ begin
 
 
   // Recipient section
   // Recipient section
   TAccountComp.AccountTxtNumberToAccountNumber(txtRecipient.Text, LAccountNumber);
   TAccountComp.AccountTxtNumberToAccountNumber(txtRecipient.Text, LAccountNumber);
-  Model.SendPASC.DestinationAccount := TNode.Node.Operations.SafeBoxTransaction.account(LAccountNumber);
+  Model.SendPASC.DestinationAccount := TNode.Node.GetAccount(LAccountNumber);
 
 
   // Quantity section
   // Quantity section
   if chkSendAll.Checked then
   if chkSendAll.Checked then

+ 1 - 2
src/gui-experimental/wizards/wallet/UWIZAddKey_SelectEncryption.lfm

@@ -7,8 +7,7 @@ object WIZAddKey_SelectEncryption: TWIZAddKey_SelectEncryption
   ClientHeight = 240
   ClientHeight = 240
   ClientWidth = 320
   ClientWidth = 320
   OnCreate = FormCreate
   OnCreate = FormCreate
-  LCLVersion = '1.8.4.0'
-  Visible = False
+  LCLVersion = '2.0.2.0'
   object rgKeyType: TRadioGroup
   object rgKeyType: TRadioGroup
     Left = 24
     Left = 24
     Height = 209
     Height = 209

+ 4 - 6
src/gui-experimental/wizards/wallet/UWIZAddKey_SelectEncryption.pas

@@ -38,9 +38,7 @@ implementation
 {$R *.lfm}
 {$R *.lfm}
 
 
 uses
 uses
-  UAccounts,
-  UConst,
-  UMemory;
+  UAccounts, UConst, UMemory, Generics.Collections;
 
 
 { TWIZAddKey_SelectEncryption }
 { TWIZAddKey_SelectEncryption }
 
 
@@ -48,13 +46,13 @@ procedure TWIZAddKey_SelectEncryption.FormCreate(Sender: TObject);
 var
 var
   i : Integer;
   i : Integer;
   GC : TDisposables;
   GC : TDisposables;
-  availableEncryptionTypes : TList;
+  availableEncryptionTypes : TList<Word>;
 begin
 begin
   rgKeyType.Items.Clear;
   rgKeyType.Items.Clear;
-  availableEncryptionTypes := GC.AddObject( TList.Create ) as TList;
+  availableEncryptionTypes := GC.AddObject( TList<Word>.Create ) as TList<Word>;
   TAccountComp.ValidsEC_OpenSSL_NID(availableEncryptionTypes);
   TAccountComp.ValidsEC_OpenSSL_NID(availableEncryptionTypes);
   for i := 0 to availableEncryptionTypes.Count - 1 do begin
   for i := 0 to availableEncryptionTypes.Count - 1 do begin
-    rgKeyType.Items.AddObject(GetOptionText(PtrInt(availableEncryptionTypes[i])),availableEncryptionTypes[i]);
+    rgKeyType.Items.AddObject(GetOptionText(availableEncryptionTypes[i]),TObject(availableEncryptionTypes[i]));
   end;
   end;
 end;
 end;
 
 

+ 5 - 4
src/pascalcoin_wallet_experimental.lpi

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <CONFIG>
 <CONFIG>
   <ProjectOptions>
   <ProjectOptions>
-    <Version Value="10"/>
+    <Version Value="11"/>
     <PathDelim Value="\"/>
     <PathDelim Value="\"/>
     <General>
     <General>
       <Flags>
       <Flags>
@@ -73,9 +73,10 @@
       <Version Value="2"/>
       <Version Value="2"/>
     </PublishOptions>
     </PublishOptions>
     <RunParams>
     <RunParams>
-      <local>
-        <FormatVersion Value="1"/>
-      </local>
+      <FormatVersion Value="2"/>
+      <Modes Count="1">
+        <Mode0 Name="default"/>
+      </Modes>
     </RunParams>
     </RunParams>
     <RequiredPackages Count="1">
     <RequiredPackages Count="1">
       <Item1>
       <Item1>