This repository has been archived by the owner on Sep 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
masterpaskalform.pas
3535 lines (3269 loc) · 114 KB
/
masterpaskalform.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
unit MasterPaskalForm;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, LCLType,
Grids, ExtCtrls, Buttons, IdTCPServer, IdContext, IdGlobal, IdTCPClient,
fileutil, Clipbrd, Menus, formexplore, lclintf, ComCtrls,
strutils, math, IdHTTPServer, IdCustomHTTPServer,
IdHTTP, fpJSON, Types, DefaultTranslator, LCLTranslator, translation, nosodebug,
IdComponent,nosogeneral,nosocrypto, nosounit, nosoconsensus, nosopsos, NosoWallCon,
nosoheaders, nosoblock,nosonetwork,nosogvts,nosomasternodes,nosonosocfg,nosoIPControl;
type
{ TThreadClientRead }
{
TNodeConnectionInfo = class(TObject)
private
FTimeLast: Int64;
public
constructor Create;
property TimeLast: int64 read FTimeLast write FTimeLast;
end;
}
TServerTipo = class(TObject)
private
VSlot: integer;
public
constructor Create;
property Slot: integer read VSlot write VSlot;
end;
{
TThreadClientRead = class(TThread)
private
FSlot: Integer;
protected
procedure Execute; override;
public
constructor Create(const CreatePaused: Boolean; const ConexSlot:Integer);
end;
}
TThreadDirective = class(TThread)
private
command: string;
protected
procedure Execute; override;
public
constructor Create(const CreatePaused: Boolean; const TCommand:string);
end;
TThreadSendOutMsjs = class(TThread)
protected
procedure Execute; override;
public
Constructor Create(CreateSuspended : boolean);
end;
TThreadKeepConnect = class(TThread)
protected
procedure Execute; override;
public
Constructor Create(CreateSuspended : boolean);
end;
TThreadIndexer = class(TThread)
protected
procedure Execute; override;
public
Constructor Create(CreateSuspended : boolean);
end;
TUpdateMNs = class(TThread)
protected
procedure Execute; override;
public
Constructor Create(CreateSuspended : boolean);
end;
TCryptoThread = class(TThread)
protected
procedure Execute; override;
public
Constructor Create(CreateSuspended : boolean);
end;
TUpdateLogs = class(TThread)
private
procedure UpdateConsole;
procedure UpdateEvents;
procedure UpdateExceps;
protected
procedure Execute; override;
public
Constructor Create(CreateSuspended : boolean);
end;
{
BotData = Packed Record
ip: string[15];
LastRefused : string[17];
end;
}
{
NodeData = Packed Record
ip: string[15];
port: string[8];
LastConexion : string[17];
end;
}
{
conectiondata = Packed Record
Autentic: boolean; // si la conexion esta autenticada por un ping
Connections : Integer; // A cuantos pares esta conectado
tipo: string[8]; // Tipo: SER o CLI
ip: string[20]; // La IP del par
lastping: string[15]; // UTCTime del ultimo ping
context: TIdContext; // Informacion para los canales cliente
Lastblock: string[15]; // Numero del ultimo bloque
LastblockHash: string[64]; // Hash del ultimo bloque
SumarioHash : string[64]; // Hash del sumario de cuenta
Pending: Integer; // Cantidad de operaciones pendientes
Protocol : integer; // Numero de protocolo usado
Version : string[8];
ListeningPort : integer;
offset : integer; // Segundos de diferencia a su tiempo
ResumenHash : String[64]; //
ConexStatus : integer;
IsBusy : Boolean;
Thread : TThreadClientRead;
MNsHash : string[5];
MNsCount : Integer;
BestHashDiff : string[32];
MNChecksCount : integer;
GVTsHash : string[32];
CFGHash : string[32];
MerkleHash : string[32];
PSOHash : string[32];
end;
}
{
BlockHeaderData = Packed Record
Number : Int64;
TimeStart : Int64;
TimeEnd : Int64;
TimeTotal : integer;
TimeLast20 : integer;
TrxTotales : integer;
Difficult : integer;
TargetHash : String[32];
Solution : String[200]; // 180 necessary
LastBlockHash : String[32];
NxtBlkDiff : integer;
AccountMiner : String[40];
MinerFee : Int64;
Reward : Int64;
end;
}
NetworkData = Packed Record
Value : String[64]; // el valor almacenado
Porcentaje : integer; // porcentaje de peers que tienen el valor
Count : integer; // cuantos peers comparten ese valor
Slot : integer; // en que slots estan esos peers
end;
{
ResumenData = Packed Record
block : integer;
blockhash : string[32];
SumHash : String[32];
end;
}
{
BlockOrdersArray = Array of OrderData;
}
TArrayPos = Packed Record
address : string[32];
end;
BlockArraysPos = array of TArrayPos;
TMasterNode = Packed Record
SignAddress : string[40];
PublicKey : string[120];
FundAddress : string[40];
Ip : string[40];
Port : integer;
Block : integer;
BlockHash : string[32];
Signature : string[120];
Time : string[15];
ReportHash : string[32];
end;
{
TMNode = Packed Record
Ip : string[15];
Port : integer;
Sign : string[40];
Fund : string[40];
First : integer;
Last : integer;
Total : integer;
Validations : integer;
Hash : String[32];
end;
}
{
TMNCheck = Record
ValidatorIP : string; // Validator IP
Block : integer;
SignAddress : string;
PubKey : string;
ValidNodes : string;
Signature : string;
end;
}
TArrayCriptoOp = Packed record
tipo: integer;
data: string;
result: string;
end;
{
TNMSData = Packed Record
Diff : string;
Hash : String;
Miner : String;
TStamp : string;
Pkey : string;
Signat : string;
end;
}
{
TMNsData = Packed Record
ipandport : string;
address : string;
age : integer;
end;
}
{
TGVT = packed record
number : string[2];
owner : string[32];
Hash : string[64];
control : integer;
end;
}
{
TNosoCFG = packed record
NetStatus : string;
SeedNode : string;
NTPNodes : string;
Pools : string;
end;
}
{TOrdIndex = record
block : integer;
orders : string;
end;}
{ TForm1 }
TForm1 = class(TForm)
BitBtnDonate: TBitBtn;
BitBtnWeb: TBitBtn;
BSaveNodeOptions: TBitBtn;
BitBtnPending: TBitBtn;
BitBtnBlocks: TBitBtn;
BTestNode: TBitBtn;
Button1: TButton;
Button2: TButton;
CBSendReports: TCheckBox;
CBKeepBlocksDB: TCheckBox;
CB_BACKRPCaddresses: TCheckBox;
CB_WO_Autoupdate: TCheckBox;
CBAutoIP: TCheckBox;
CBRunNodeAlone: TCheckBox;
CB_WO_HideEmpty: TCheckBox;
Edit2: TEdit;
Label19: TLabel;
Memobannedmethods: TMemo;
Label1: TLabel;
Label14: TLabel;
Label15: TLabel;
Label16: TLabel;
Label17: TLabel;
Label18: TLabel;
LabelNodesHash: TLabel;
LE_Rpc_Pass: TEdit;
Label13: TLabel;
LE_Rpc_Port: TEdit;
Label12: TLabel;
LabeledEdit9: TEdit;
Label11: TLabel;
LabeledEdit8: TEdit;
Label10: TLabel;
LabeledEdit6: TEdit;
Label8: TLabel;
Label9: TLabel;
LabeledEdit5: TEdit;
PageControl2: TPageControl;
PCNodes: TPageControl;
PC_Processes: TPageControl;
Panel10: TPanel;
Panel11: TPanel;
Panel12: TPanel;
Panel13: TPanel;
Panel14: TPanel;
Panel15: TPanel;
Panel16: TPanel;
Panel17: TPanel;
Panel18: TPanel;
Panel19: TPanel;
Panel20: TPanel;
Panel21: TPanel;
Panel23: TPanel;
PanelTransferGVT: TPanel;
PanelNodesHeaders: TPanel;
Panel7: TPanel;
Panel9: TPanel;
SG_OpenThreads: TStringGrid;
SG_FileProcs: TStringGrid;
StaRPCimg: TImage;
StaSerImg: TImage;
StaConLab: TLabel;
Imgs32: TImageList;
ImgRotor: TImage;
GridNodes: TStringGrid;
GVTsGrid: TStringGrid;
SGConSeeds: TStringGrid;
TabGVTs: TTabSheet;
TabConsensus: TTabSheet;
TabSheet1: TTabSheet;
TabNodesReported: TTabSheet;
TabNodesVerified: TTabSheet;
TabThreads: TTabSheet;
TabFiles: TTabSheet;
StaTimeLab: TLabel;
SCBitSend: TBitBtn;
SCBitClea: TBitBtn;
CB_AUTORPC: TCheckBox;
CB_WO_Multisend: TCheckBox;
CheckBox4: TCheckBox;
CB_RPCFilter: TCheckBox;
CheckBox7: TCheckBox;
CheckBox8: TCheckBox;
CheckBox9: TCheckBox;
Edit1: TEdit;
ConsoleLine: TEdit;
EditSCMont: TEdit;
EditSCDest: TEdit;
EditCustom: TEdit;
Image1: TImage;
ImageOptionsAbout: TImage;
ImgSCMont: TImage;
ImgSCDest: TImage;
ImageOut: TImage;
ImageInc: TImage;
Imagenes: TImageList;
LSCTop: TLabel;
LabAbout: TLabel;
LabelBigBalance: TLabel;
Latido : TTimer;
InfoTimer : TTimer;
InicioTimer : TTimer;
MainMenu: TMainMenu;
MemoSCCon: TMemo;
MemoConsola: TMemo;
DataPanel: TStringGrid;
MenuItem1: TMenuItem;
MenuItem23: TMenuItem;
MenuItem24: TMenuItem;
MenuItem25: TMenuItem;
MenuItem26: TMenuItem;
MenuItem27: TMenuItem;
MenuItem5: TMenuItem;
MenuItem6: TMenuItem;
MenuItem8: TMenuItem;
MenuItem9: TMenuItem;
DireccionesPanel: TStringGrid;
InfoPanel: TPanel;
PanelCustom: TPanel;
PanelSend: TPanel;
ConsolePopUp2: TPopupMenu;
ConsoLinePopUp2: TPopupMenu;
SCBitCancel: TBitBtn;
SCBitConf: TBitBtn;
BDefAddr: TSpeedButton;
BCustomAddr: TSpeedButton;
BCopyAddr: TSpeedButton;
BNewAddr: TSpeedButton;
BOkCustom: TSpeedButton;
SGridSC: TStringGrid;
SBSCPaste: TSpeedButton;
SBSCMax: TSpeedButton;
TabAddresses: TTabSheet;
TabNodes: TTabSheet;
TabWalletMain: TPageControl;
TopPanel: TPanel;
StatusPanel: TPanel;
RestartTimer : Ttimer;
MemoRPCWhitelist: TMemo;
Memo2: TMemo;
MemoLog: TMemo;
MemoExceptLog: TMemo;
PageControl1: TPageControl;
PCMonitor: TPageControl;
PageMain: TPageControl;
Server: TIdTCPServer;
RPCServer : TIdHTTPServer;
SG_Performance: TStringGrid;
tabOptions: TTabSheet;
TabOpt_Wallet: TTabSheet;
TabProcesses: TTabSheet;
TabNodeOptions: TTabSheet;
Tab_Options_RPC: TTabSheet;
Tab_Options_Trade: TTabSheet;
TabMonitor: TTabSheet;
TabDebug_Log: TTabSheet;
TabSheet8: TTabSheet;
TabMonitorMonitor: TTabSheet;
Tab_Options_About: TTabSheet;
TabWallet: TTabSheet;
TabConsole: TTabSheet;
procedure BitBtnDonateClick(sender: TObject);
procedure BitBtnWebClick(sender: TObject);
procedure BSaveNodeOptionsClick(sender: TObject);
procedure BTestNodeClick(sender: TObject);
procedure Button1Click(sender: TObject);
procedure Button2Click(sender: TObject);
procedure CBKeepBlocksDBChange(Sender: TObject);
procedure CBRunNodeAloneChange(sender: TObject);
procedure CBSendReportsChange(Sender: TObject);
procedure CB_BACKRPCaddressesChange(Sender: TObject);
procedure CB_RPCFilterChange(sender: TObject);
procedure CB_WO_AutoupdateChange(sender: TObject);
procedure CBAutoIPClick(sender: TObject);
procedure CB_WO_HideEmptyChange(Sender: TObject);
procedure DataPanelResize(sender: TObject);
procedure DireccionesPanelDrawCell(sender: TObject; aCol, aRow: Integer;
aRect: TRect; aState: TGridDrawState);
procedure DireccionesPanelResize(sender: TObject);
procedure FormCloseQuery(sender: TObject; var CanClose: boolean);
procedure FormCreate(sender: TObject);
procedure FormDestroy(sender: TObject);
procedure FormResize(sender: TObject);
procedure GridNodesResize(sender: TObject);
procedure GVTsGridResize(sender: TObject);
procedure LE_Rpc_PassEditingDone(sender: TObject);
Procedure LoadOptionsToPanel();
procedure FormShow(sender: TObject);
Procedure InicoTimerEjecutar(sender: TObject);
procedure MemobannedmethodsEditingDone(Sender: TObject);
procedure MemoRPCWhitelistEditingDone(sender: TObject);
procedure PC_ProcessesResize(Sender: TObject);
Procedure RestartTimerEjecutar(sender: TObject);
Procedure StartProgram();
Procedure ConsoleLineKeyup(sender: TObject; var Key: Word; Shift: TShiftState);
procedure Grid1PrepareCanvas(sender: TObject; aCol, aRow: Integer; aState: TGridDrawState);
procedure Grid2PrepareCanvas(sender: TObject; aCol, aRow: Integer; aState: TGridDrawState);
Procedure heartbeat(sender: TObject);
Procedure InfoTimerEnd(sender: TObject);
function ClientsCount : Integer ;
procedure SG_PerformanceResize(sender: TObject);
procedure SG_OpenThreadsResize(Sender: TObject);
procedure StaConLabDblClick(sender: TObject);
procedure SGConSeedsResize(Sender: TObject);
procedure TabNodeOptionsShow(sender: TObject);
procedure Tab_Options_AboutResize(sender: TObject);
Procedure TryCloseServerConnection(AContext: TIdContext; closemsg:string='');
procedure IdTCPServer1Execute(AContext: TIdContext);
procedure IdTCPServer1Connect(AContext: TIdContext);
procedure IdTCPServer1Disconnect(AContext: TIdContext);
procedure IdTCPServer1Exception(AContext: TIdContext;AException: Exception);
Procedure BDefAddrOnClick(sender: TObject);
Procedure BCustomAddrOnClick(sender: TObject);
Procedure EditCustomKeyUp(sender: TObject; var Key: Word; Shift: TShiftState);
Procedure BOkCustomClick(sender: TObject);
Procedure PanelCustomMouseLeave(sender: TObject);
Procedure BNewAddrOnClick(sender: TObject);
Procedure BCopyAddrClick(sender: TObject);
Procedure CheckForHint(sender:TObject);
Procedure SBSCPasteOnClick(sender:TObject);
Procedure SBSCMaxOnClick(sender:TObject);
Procedure EditSCDestChange(sender:TObject);
Procedure EditSCMontChange(sender:TObject);
Procedure DisablePopUpMenu(sender: TObject;MousePos: TPoint;var Handled: Boolean);
Procedure EditMontoOnKeyUp(sender: TObject; var Key: char);
Procedure SCBitSendOnClick(sender:TObject);
Procedure SCBitCancelOnClick(sender:TObject);
Procedure SCBitConfOnClick(sender:TObject);
Procedure ResetSendFundsPanel(sender:TObject);
// NODE SERVER
Function TryMessageToNode(AContext: TIdContext;message:string):boolean;
Function GetStreamFromContext(AContext: TIdContext;out LStream:TMemoryStream):boolean;
// RPC
procedure RPCServerExecute(AContext: TIdContext;
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
// MAIN MENU
Procedure MMImpWallet(sender:TObject);
Procedure MMExpWallet(sender:TObject);
Procedure MMQuit(sender:TObject);
Procedure MMRestart(sender:TObject);
// CONSOLE POPUP
Procedure CheckConsolePopUp(sender: TObject;MousePos: TPoint;var Handled: Boolean);
Procedure ConsolePopUpClear(sender:TObject);
Procedure ConsolePopUpCopy(sender:TObject);
// CONSOLE LINE POPUP
Procedure CheckConsoLinePopUp(sender: TObject;MousePos: TPoint;var Handled: Boolean);
Procedure ConsoLinePopUpClear(sender:TObject);
Procedure ConsoLinePopUpCopy(sender:TObject);
Procedure ConsoLinePopUpPaste(sender:TObject);
// OPTIONS
// WALLET
procedure CB_WO_MultisendChange(sender: TObject);
// RPC
procedure CB_AUTORPCChange(sender: TObject);
procedure LE_Rpc_PortEditingDone(sender: TObject);
private
public
end;
Procedure InitMainForm();
Procedure CloseeAppSafely();
Procedure UpdateStatusBar();
Procedure CompleteInicio();
CONST
HexAlphabet : string = '0123456789ABCDEF';
ReservedWords : string = 'NULL,DELADDR';
FundsAddress : string = 'NpryectdevepmentfundsGE';
JackPotAddress : string = 'NPrjectPrtcRandmJacptE5';
ValidProtocolCommands : string = '$PING$PONG$GETPENDING$NEWBL$GETRESUMEN$LASTBLOCK$GETCHECKS'+
'$CUSTOMORDERADMINMSGNETREQ$REPORTNODE$GETMNS$BESTHASH$MNREPO$MNCHECK'+
'GETMNSFILEMNFILEGETHEADUPDATE$GETSUMARY$GETGVTSGVTSFILE$SNDGVTGETCFGDATA'+
'SETCFGDATA$GETPSOSPSOSFILE';
HideCommands : String = 'CLEAR SENDPOOLSOLUTION SENDPOOLSTEPS DELBOTS';
CustomValid : String = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890@*+-_:';
MainnetVersion = '0.4.3';
{$IFDEF WINDOWS}
RestartFileName = 'launcher.bat';
updateextension = 'zip';
{$ENDIF}
{$IFDEF UNIX}
RestartFileName = 'launcher.sh';
updateextension = 'tgz';
{$ENDIF}
NodeRelease = 'Aa8';
OficialRelease = true;
BetaRelease = false;
VersionRequired = '0.4.2';
BuildDate = 'August 2024';
{Developer addresses}
ADMINHash = 'N2kydpxwvFRv8mM3SXD2tpNKwbpKrGo';
AdminPubKey = 'BKh0UNjUmbPDuApWPxEL9mzoMUwe0Xf3jGi5FnP7N044dOc1k2PGrd5Xq/5LW+xYog1Pi3P6KBiwi1Y7oo/KN7U=';
Authorizedaddresses = 'N4HgivS84xzgG6uPAnhQprLVsfry6GM N4GvsJ7SjBw6Ls8XNk6gELpXoLTt5Dv';
DefaultServerPort = 8080;
MaxConecciones = 99;
//Protocolo = 2;
DefaultDonation = 10;
// Custom values for coin
SecondsPerBlock = 600; // 10 minutes
PremineAmount = 1030390730000; // 1030390730000;
InitialReward = 5000000000; // Initial reward
BlockHalvingInterval = 210000; // 210000;
HalvingSteps = 10; // total number of halvings
Comisiontrfr = 10000; // ammount/Comisiontrfr = 0.01 % of the ammount
ComisionCustom = 200000; // 0.05 % of the Initial reward
CoinSimbol = 'NOSO'; // Coin symbol
CoinName = 'Noso'; // Coin name
CoinChar = 'N'; // Char for addresses
MinimunFee = 10;
NewMinFee = 1000000; // Minimun fee for transfer
PoSPercentage = 1000; // PoS part: reward * PoS / 10000
MNsPercentage = 2000;
PosStackCoins = 20; // PoS stack ammoount: supply*20 / PoSStack
PoSBlockStart : integer = 8425; // first block with PoSPayment
PoSBlockEnd : integer = 88500; // To verify
MNBlockStart : integer = 48010; // First block with MNpayments
InitialBlockDiff = 60; // First 20 blocks diff
GenesysTimeStamp = 1615132800; // 1615132800;
AvailableMarkets = '/LTC';
SumMarkInterval = 100;
SecurityBlocks = 4000;
//GVTBaseValue = 70000000000;
Update050Block = 120000;
var
Form1 : TForm1;
//Customizationfee : int64 = InitialReward div ComisionCustom;
{Options}
FileAdvOptions : textfile;
S_AdvOpt : boolean = false;
RPCPort : integer = 8078;
RPCPass : string = 'default';
MaxPeersAllow : integer = 50;
WO_AutoServer : boolean = false;
WO_PosWarning : int64 = 7;
WO_MultiSend : boolean = false;
WO_HideEmpty : boolean = false;
WO_Language : string = 'en';
WO_LastPoUpdate: string = MainnetVersion+NodeRelease;
WO_CloseStart : boolean = true;
WO_AutoUpdate : Boolean = true;
WO_SendReport : boolean = false;
WO_StopGUI : boolean = false;
WO_BlockDB : boolean = false;
WO_PRestart : int64 = 0;
WO_skipBlocks : boolean = false;
RPCFilter : boolean = true;
RPCWhitelist : string = '127.0.0.1,localhost';
RPCBanned : string = '';
RPCAuto : boolean = false;
RPCSaveNew : boolean = false;
//MN_IP : string = 'localhost';
//MN_Port : string = '8080';
//MN_Funds : string = '';
//MN_Sign : string = '';
MN_AutoIP : Boolean = false;
//MN_FileText : String = '';
WO_FullNode : boolean = true;
{Network}
MaxOutgoingConnections : integer = 3;
{
SlotLines : array [1..MaxConecciones] of TStringList;
CanalCliente : array [1..MaxConecciones] of TIdTCPClient;
}
//ListadoBots : array of BotData;
//ListaNodos : array of NodeData;
//ArrayPoolTXs : Array of TOrderData;
ArrayOrderIDsProcessed : array of string;
OutgoingMsjs : TStringlist;
KeepServerOn : Boolean = false;
LastTryServerOn : Int64 = 0;
ServerStartTime : Int64 = 0;
{
DownloadHeaders : boolean = false;
DownloadSumary : Boolean = false;
DownLoadBlocks : boolean = false;
DownLoadGVTs : boolean = false;
DownloadPSOs : boolean = false;
}
RebuildingSumary : boolean = false;
//OpenReadClientThreads : integer = 0;
// Threads
SendOutMsgsThread : TThreadSendOutMsjs;
KeepConnectThread : TThreadKeepConnect;
IndexerThread : TThreadIndexer;
ThreadMNs : TUpdateMNs;
CryptoThread : TCryptoThread;
UpdateLogsThread : TUpdateLogs;
// GUI/APP related
ConnectedRotor : integer = 0;
EngineLastUpdate : int64 = 0;
LastLogLine : String = '';
RestartNosoAfterQuit : boolean = false;
U_DirPanel : boolean = false;
U_DataPanel : boolean = true;
G_ClosingAPP : Boolean = false;
MyCurrentBalance : Int64 = 0;
G_Launching : boolean = true;
G_CloseRequested : boolean = false;
G_LastPing : int64;
G_TotalPings : Int64 = 0;
LastCommand : string = '';
ProcessLines : TStringlist;
//LastBotClear : string = '';
S_Wallet : boolean = false;
MontoIncoming : Int64 = 0;
MontoOutgoing : Int64 = 0;
InfoPanelTime : integer = 0;
// FormState
FormState_Top : integer;
FormState_Left : integer;
FormState_Heigth : integer;
FormState_Width : integer;
FormState_Status : integer;
// Masternodes
//G_MNVerifications : integer = 0;
//ArrayMNsData : array of TMNsData;
LastTimeReportMyMN : int64 = 0;
MNsArray : array of TMasterNode;
//WaitingMNs : array of String;
U_MNsGrid : boolean = false;
U_MNsGrid_Last : int64 = 0;
//MNsList : array of TMnode;
//ArrMNChecks : array of TMNCheck;
MNsRandomWait : Integer= 0;
{
//MySumarioHash : String = '';
MyLastBlock : integer = 0;
MyLastBlockHash : String = '';
MyResumenHash : String = '';
MyGVTsHash : string = '';
MyCFGHash : string = '';
MyPublicIP : String = '';
MyMNsHash : String = '';
}
{LastBlockData : BlockHeaderData;}
BuildingBlock : integer = 0;
Last_SyncWithMainnet : int64 = 0;
{
LastTimeRequestSumary : int64 = 0;
LastTimeRequestBlock : int64 = 0;
LastTimeRequestResumen : int64 = 0;
LastTimePendingRequested : int64 = 0;
}
//ForceCompleteHeadersDownload : boolean = false;
{
LastTimeMNHashRequestes : int64 = 0;
LastTimeBestHashRequested : int64 = 0;
LastTimeMNsRequested : int64 = 0;
LastTimeChecksRequested : int64 = 0;
LastRunMNVerification : int64 = 0;
LasTimeGVTsRequest : int64 = 0;
}
//LasTimeCFGRequest : int64 = 0;
//LasTimePSOsRequest : int64 = 0;
// Variables asociadas a mi conexion
MyConStatus : integer = 0;
STATUS_Connected : boolean = false;
BuildNMSBlock : int64 = 0;
ArrayCriptoOp : array of TArrayCriptoOp;
// Critical Sections
CSProcessLines: TRTLCriticalSection;
CSOutgoingMsjs: TRTLCriticalSection;
CSBlocksAccess: TRTLCriticalSection;
//CSPending : TRTLCriticalSection;
CSCriptoThread: TRTLCriticalSection;
CSClosingApp : TRTLCriticalSection;
//CSClientReads : TRTLCriticalSection;
//CSGVTsArray : TRTLCriticalSection;
CSNosoCFGStr : TRTLCriticalSection;
//MNs system
//CSMNsArray : TRTLCriticalSection;
//CSWaitingMNs : TRTLCriticalSection;
//CSMNsChecks : TRTLCriticalSection;
CSIdsProcessed: TRTLCriticalSection;
// Outgoing lines, needs to be initialized
//CSOutGoingArr : array[1..MaxConecciones] of TRTLCriticalSection;
//ArrayOutgoing : array[1..MaxConecciones] of array of string;
//CSIncomingArr : array[1..MaxConecciones] of TRTLCriticalSection;
// Filename variables
MarksDirectory : string= 'NOSODATA'+DirectorySeparator+'SUMMARKS'+DirectorySeparator;
GVTMarksDirectory : string= 'NOSODATA'+DirectorySeparator+'SUMMARKS'+DirectorySeparator+'GVTS'+DirectorySeparator;
UpdatesDirectory : string= 'NOSODATA'+DirectorySeparator+'UPDATES'+DirectorySeparator;
LogsDirectory : string= 'NOSODATA'+DirectorySeparator+'LOGS'+DirectorySeparator;
ExceptLogFilename : string= 'NOSODATA'+DirectorySeparator+'LOGS'+DirectorySeparator+'exceptlog.txt';
ConsoleLogFilename : string= 'NOSODATA'+DirectorySeparator+'LOGS'+DirectorySeparator+'console.txt';
NodeFTPLogFilename : string= 'NOSODATA'+DirectorySeparator+'LOGS'+DirectorySeparator+'nodeftp.txt';
DeepDebLogFilename : string= 'NOSODATA'+DirectorySeparator+'LOGS'+DirectorySeparator+'deepdeb.txt';
EventLogFilename : string= 'NOSODATA'+DirectorySeparator+'LOGS'+DirectorySeparator+'eventlog.txt';
ResumeLogFilename : string= 'NOSODATA'+DirectorySeparator+'LOGS'+DirectorySeparator+'report.txt';
PerformanceFIlename : string= 'NOSODATA'+DirectorySeparator+'LOGS'+DirectorySeparator+'performance.txt';
AdvOptionsFilename : string= 'NOSODATA'+DirectorySeparator+'advopt.txt';
{MasterNodesFilename : string= 'NOSODATA'+DirectorySeparator+'masternodes.txt';}
ZipHeadersFileName : string= 'NOSODATA'+DirectorySeparator+'blchhead.zip';
{GVTsFilename : string= 'NOSODATA'+DirectorySeparator+'gvts.psk';}
ClosedAppFilename : string= 'NOSODATA'+DirectorySeparator+'LOGS'+DirectorySeparator+'proclo.dat';
RPCBakDirectory : string= 'NOSODATA'+DirectorySeparator+'SUMMARKS'+DirectorySeparator+'RPC'+DirectorySeparator;
IMPLEMENTATION
Uses
mpgui, mpdisk, mpParser, mpRed, nosotime, mpProtocol, mpcoin,
mpRPC,mpblock;
{$R *.lfm}
{
// Identify the pool miners connections
constructor TNodeConnectionInfo.Create;
Begin
FTimeLast:= 0;
End;
}
constructor TServerTipo.Create;
Begin
VSlot:= -1;
End;
// ***************
// *** THREADS ***
// ***************
{$REGION Thread update logs}
constructor TUpdateLogs.Create(CreateSuspended : boolean);
Begin
inherited Create(CreateSuspended);
FreeOnTerminate := True;
End;
procedure TUpdateLogs.UpdateConsole();
Begin
if not WO_StopGUI then
form1.MemoConsola.Lines.Add(LastLogLine);
End;
procedure TUpdateLogs.UpdateEvents();
Begin
if not WO_StopGUI then
form1.MemoLog.Lines.Add(LastLogLine);
End;
procedure TUpdateLogs.UpdateExceps();
Begin
if not WO_StopGUI then
form1.MemoExceptLog.Lines.Add(LastLogLine);
End;
procedure TUpdateLogs.Execute;
Begin
AddNewOpenThread('UpdateLogs',UTCTime);
While not terminated do
begin
sleep(10);
UpdateOpenThread('UpdateLogs',UTCTime);
while GetLogLine('console',lastlogline) do Synchronize(@UpdateConsole);
while GetLogLine('events',lastlogline) do Synchronize(@UpdateEvents);
while GetLogLine('exceps',lastlogline) do Synchronize(@UpdateExceps);
GetLogLine('nodeftp',lastlogline);
// Deep debug
Repeat
until not GetDeepDebLine(lastlogline);
end;
End;
{$ENDREGION Thread update logs}
{$REGION Thread Client read}
{
constructor TThreadClientRead.Create(const CreatePaused: Boolean; const ConexSlot:Integer);
Begin
inherited Create(CreatePaused);
FSlot:= ConexSlot;
End;
procedure TThreadClientRead.Execute;
var
LLine: String;
MemStream : TMemoryStream;
BlockZipName : string = '';
Continuar : boolean = true;
Errored : Boolean;
downloaded : boolean;
LineToSend : string;
LineSent : boolean;
KillIt : boolean = false;
SavedToFile : boolean;
FTPTime : int64;
FTPSize : int64;
FTPSpeed : int64;
ErrMsg : string;
begin
AddNewOpenThread('ReadClient '+FSlot.ToString,UTCTime);
REPEAT
TRY
sleep(10);
continuar := true;
if CanalCliente[FSlot].IOHandler.InputBufferIsEmpty then
begin
CanalCliente[FSlot].IOHandler.CheckForDataOnSource(1000);
if CanalCliente[FSlot].IOHandler.InputBufferIsEmpty then Continuar := false;
end;
if Continuar then
begin
While not CanalCliente[FSlot].IOHandler.InputBufferIsEmpty do
begin
Conexiones[fSlot].IsBusy:=true;
Conexiones[fSlot].lastping:=UTCTimeStr;
TRY
CanalCliente[FSlot].ReadTimeout:=1000;
CanalCliente[FSlot].IOHandler.MaxLineLength:=Maxint;
LLine := CanalCliente[FSlot].IOHandler.ReadLn(IndyTextEncoding_UTF8);
EXCEPT on E:Exception do
begin
ErrMsg := E.Message;
ToLog('exceps',FormatDateTime('dd mm YYYY HH:MM:SS.zzz', Now)+' -> '+Format(rs0002,[IntToStr(Fslot)+slinebreak+ErrMsg]));
Conexiones[fSlot].IsBusy:=false;
if AnsiContainsStr(Uppercase(ErrMsg),'SOCKET ERROR') then
begin
KillIt := true;
ToLog('console',Format('Socket error: ',[ErrMsg]));
end;
continue;
end;
END; {TRY}
if continuar then
begin
if Parameter(LLine,0) = 'RESUMENFILE' then
begin
DownloadHeaders := true;
AddFileProcess('Get','Headers',CanalCliente[FSlot].Host,GetTickCount64);
ToLog('events',TimeToStr(now)+rs0003); //'Receiving headers'
ToLog('console',rs0003); //'Receiving headers'
MemStream := TMemoryStream.Create;
CanalCliente[FSlot].ReadTimeout:=10000;
TRY
CanalCliente[FSlot].IOHandler.ReadStream(MemStream);
FTPsize := MemStream.Size;
downloaded := True;
EXCEPT ON E:Exception do
begin
ToLog('exceps',FormatDateTime('dd mm YYYY HH:MM:SS.zzz', Now)+' -> '+format(rs0004,[conexiones[fSlot].ip,E.Message])); //'Error Receiving headers from
downloaded := false;
end;
END; {TRY}
if Downloaded then SavedToFile := SaveStreamAsHeaders(MemStream)
else SavedToFile := false;
if ((Downloaded) and (SavedToFile)) then
begin
ToLog('console',format(rs0005,[copy(HashMD5File(ResumenFilename),1,5)])); //'Headers file received'
LastTimeRequestResumen := 0;
UpdateMyData();
end
else ToLog('console','Error downloading headers: downloaded: '+booltostr(Downloaded,true)+' / Saved: '+booltostr(SavedToFile,true));
MemStream.Free;
DownloadHeaders := false;
FTPTime := CloseFileProcess('Get','Headers',CanalCliente[FSlot].Host,GetTickCount64);
FTPSpeed := (FTPSize div FTPTime);
ToLog('nodeftp','Downloaded headers from '+CanalCliente[FSlot].Host+' at '+FTPSpeed.ToString+' kb/s');
end
else if Parameter(LLine,0) = 'SUMARYFILE' then
begin
DownloadSumary := true;
AddFileProcess('Get','Summary',CanalCliente[FSlot].Host,GetTickCount64);
ToLog('console',rs0085); //'Receiving sumary'
MemStream := TMemoryStream.Create;
CanalCliente[FSlot].ReadTimeout:=10000;
TRY
CanalCliente[FSlot].IOHandler.ReadStream(MemStream);
FTPsize := MemStream.Size;
downloaded := True;
EXCEPT ON E:Exception do
begin
ToLog('exceps',FormatDateTime('dd mm YYYY HH:MM:SS.zzz', Now)+' -> '+format(rs0086,[conexiones[fSlot].ip,E.Message])); //'Error Receiving sumary from