From e796281850c4f88cd690bea6f5a01ed594007227 Mon Sep 17 00:00:00 2001 From: NosoDevTeam <142863157+NosoDevTeam@users.noreply.github.com> Date: Sun, 1 Sep 2024 17:29:07 +0200 Subject: [PATCH] aa7 --- lastrelease.txt | 2 +- masterpaskalform.pas | 2 +- mpparser.pas | 1 - mpprotocol.pas | 142 +++++++++++++++++++++++++++---------------- nosonetwork.pas | 1 - 5 files changed, 92 insertions(+), 56 deletions(-) diff --git a/lastrelease.txt b/lastrelease.txt index adfdee3..0201014 100644 --- a/lastrelease.txt +++ b/lastrelease.txt @@ -1 +1 @@ -0.4.3Aa6 0.4.2Da2 x {LastOfficial} {LastBeta} {TestNet} \ No newline at end of file +0.4.3Aa7 0.4.2Da2 x {LastOfficial} {LastBeta} {TestNet} \ No newline at end of file diff --git a/masterpaskalform.pas b/masterpaskalform.pas index 402ea29..13a968d 100644 --- a/masterpaskalform.pas +++ b/masterpaskalform.pas @@ -576,7 +576,7 @@ TForm1 = class(TForm) RestartFileName = 'launcher.sh'; updateextension = 'tgz'; {$ENDIF} - NodeRelease = 'Aa6'; + NodeRelease = 'Aa7'; OficialRelease = true; BetaRelease = false; VersionRequired = '0.4.2'; diff --git a/mpparser.pas b/mpparser.pas index 6e752b2..b1e90f3 100644 --- a/mpparser.pas +++ b/mpparser.pas @@ -276,7 +276,6 @@ function GetOpData(textLine:string):String; else if UpperCase(Command) = 'GETMULTI' then CreateMultiAddress(LineText) else if UpperCase(Command) = 'DELBOTS' then DeleteBots - // New system else if UpperCase(Command) = 'SUMARY' then ShowSumary() diff --git a/mpprotocol.pas b/mpprotocol.pas index 3a182cd..57f17eb 100644 --- a/mpprotocol.pas +++ b/mpprotocol.pas @@ -10,7 +10,7 @@ interface nosoheaders, NosoNosoCFG, nosoblock, nosonetwork,nosogvts,nosoMasternodes,NosoIPControl; //function GetPTCEcn():String; -Function GetOrderFromString(textLine:String):TOrderData; +Function GetOrderFromString(textLine:String;out ThisData:TOrderData):boolean; //function GetStringFromOrder(order:Torderdata):String; function GetStringFromBlockHeader(blockheader:BlockHeaderdata):String; //Function ProtocolLine(tipo:integer):String; @@ -25,6 +25,7 @@ function GetPingString():string; Procedure PTC_SendResumen(Slot:int64); Procedure PTC_SendSumary(Slot:int64); Procedure PTC_SendPSOS(Slot:int64); +Procedure PTC_SendGVTs(Slot:int64); Function ZipHeaders():boolean; function CreateZipBlockfile(firstblock:integer):string; Procedure PTC_SendBlocks(Slot:integer;TextLine:String); @@ -89,33 +90,34 @@ function GetPTCEcn():String; } // convierte los datos de la cadena en una order -Function GetOrderFromString(textLine:String):TOrderData; +Function GetOrderFromString(textLine:String;out ThisData:TOrderData):boolean; var orderinfo : TOrderData; Begin -BeginPerformance('GetOrderFromString'); -OrderInfo := Default(TOrderData); -TRY -OrderInfo.OrderID := Parameter(textline,1); -OrderInfo.OrderLines := StrToInt(Parameter(textline,2)); -OrderInfo.OrderType := Parameter(textline,3); -OrderInfo.TimeStamp := StrToInt64(Parameter(textline,4)); -OrderInfo.reference := Parameter(textline,5); -OrderInfo.TrxLine := StrToInt(Parameter(textline,6)); -OrderInfo.sender := Parameter(textline,7); -OrderInfo.Address := Parameter(textline,8); -OrderInfo.Receiver := Parameter(textline,9); -OrderInfo.AmmountFee := StrToInt64(Parameter(textline,10)); -OrderInfo.AmmountTrf := StrToInt64(Parameter(textline,11)); -OrderInfo.Signature := Parameter(textline,12); -OrderInfo.TrfrID := Parameter(textline,13); -EXCEPT ON E:Exception do - begin - ToLog('exceps',FormatDateTime('dd mm YYYY HH:MM:SS.zzz', Now)+' -> '+'Error GetOrderFromString : '+E.Message); - end; -END;{TRY} -Result := OrderInfo; -EndPerformance('GetOrderFromString'); + BeginPerformance('GetOrderFromString'); + Result := true; + ThisData := Default(TOrderData); + TRY + ThisData.OrderID := Parameter(textline,1); + ThisData.OrderLines := StrToInt(Parameter(textline,2)); + ThisData.OrderType := Parameter(textline,3); + ThisData.TimeStamp := StrToInt64(Parameter(textline,4)); + ThisData.reference := Parameter(textline,5); + ThisData.TrxLine := StrToInt(Parameter(textline,6)); + ThisData.sender := Parameter(textline,7); + ThisData.Address := Parameter(textline,8); + ThisData.Receiver := Parameter(textline,9); + ThisData.AmmountFee := StrToInt64(Parameter(textline,10)); + ThisData.AmmountTrf := StrToInt64(Parameter(textline,11)); + ThisData.Signature := Parameter(textline,12); + ThisData.TrfrID := Parameter(textline,13); + EXCEPT ON E:Exception do + begin + ToLog('exceps',FormatDateTime('dd mm YYYY HH:MM:SS.zzz', Now)+' -> '+'Error GetOrderFromString : '+E.Message); + Result := False; + end; + END;{TRY} + EndPerformance('GetOrderFromString'); End; { @@ -279,6 +281,7 @@ function GetStringFromBlockHeader(BlockHeader:blockheaderdata):String; else if UpperCase(LineComando) = '$GETSUMARY' then PTC_SendSumary(contador) //else if UpperCase(LineComando) = '$SNDGVT' then INC_PTC_SendGVT(GetOpData(ProcessLine), contador) else if UpperCase(LineComando) = '$GETPSOS' then PTC_SendPSOS(contador) + else if UpperCase(LineComando) = '$GETGVTS' then PTC_SendGVTs(contador) else Begin // El comando recibido no se reconoce. Verificar protocolos posteriores. @@ -573,6 +576,39 @@ procedure PTC_SendPending(Slot:int64); MemStream.Free; End; +Procedure PTC_SendGVTs(Slot:int64); +var + MemStream : TMemoryStream; +Begin + MemStream := TMemoryStream.Create; + GetGVTsAsStream(MemStream); + if GetConexIndex(slot).tipo='CLI' then + begin + TRY + GetConexIndex(slot).context.Connection.IOHandler.WriteLn('GVTSFILE'); + GetConexIndex(slot).context.connection.IOHandler.Write(MemStream,0,true); + EXCEPT on E:Exception do + begin + Form1.TryCloseServerConnection(GetConexIndex(Slot).context); + ToDeepDeb('Error sending GVTs file: '+E.Message); + end; + END; {TRY} + end; + if GetConexIndex(slot).tipo='SER' then + begin + TRY + CanalCliente[slot].IOHandler.WriteLn('GVTSFILE'); + CanalCliente[slot].IOHandler.Write(MemStream,0,true); + EXCEPT on E:Exception do + begin + ToDeepDeb('Error sending GVTs file: '+E.Message); + CloseSlot(slot); + end; + END;{TRY} + end; + MemStream.Free; +End; + // Zips the headers file. Uses deprecated methods, to be removed... Function ZipHeaders():boolean; var @@ -713,8 +749,7 @@ function CreateZipBlockfile(firstblock:integer):string; ErrorCode : Integer = 0; Begin Result := 0; -OrderInfo := Default(TOrderData); -OrderInfo := GetOrderFromString(TextLine); +if not GetOrderFromString(TextLine,OrderInfo) then exit; Address := GetAddressFromPublicKey(OrderInfo.sender); if address <> OrderInfo.Address then ErrorCode := 1; // La direccion no dispone de fondos @@ -824,6 +859,7 @@ function ValidateTrfr(order:Torderdata;Origen:String):integer; TRY NumTransfers := StrToInt(Parameter(TextLine,5)); ToLog('Console',format('Order with %d transfers',[Numtransfers])); +ToLog('Console',format('Complete line: %s',[TextLine])); RecOrderId := Parameter(TextLine,7); GenOrderID := Parameter(TextLine,5)+Parameter(TextLine,10); Textbak := GetOpData(TextLine); @@ -831,8 +867,11 @@ function ValidateTrfr(order:Torderdata;Origen:String):integer; for cont := 0 to NumTransfers-1 do begin SetLength(TrxArray,length(TrxArray)+1);SetLength(senderTrx,length(senderTrx)+1); - TrxArray[cont] := default (Torderdata); - TrxArray[cont] := GetOrderFromString(Textbak); + if not GetOrderFromString(Textbak,TrxArray[cont]) then + begin + Proceder := false; + ErrorCode := 96; + end; Inc(TotalSent,TrxArray[cont].AmmountTrf); Inc(TotalFee,TrxArray[cont].AmmountFee); GenOrderID := GenOrderID+TrxArray[cont].TrfrID; @@ -856,6 +895,7 @@ function ValidateTrfr(order:Torderdata;Origen:String):integer; sendersString := sendersString + senderTrx[cont]; Textbak := copy(textBak,2,length(textbak)); Textbak := GetOpData(Textbak); + if not Proceder then Break; end; GenOrderID := GetOrderHash(GenOrderID); if TotalFee >= GetMinimumFee(TotalSent) then @@ -924,29 +964,27 @@ function ValidateTrfr(order:Torderdata;Origen:String):integer; ErrorCode : Integer = 0; StrTosign : String = ''; Begin -OrderInfo := Default(TOrderData); -//ToLog('console',TextLine); -OrderInfo := GetOrderFromString(TextLine); -Address := GetAddressFromPublicKey(OrderInfo.sender); -if address <> OrderInfo.Address then ErrorCode := 1; -// La direccion no dispone de fondos -if GetAddressBalanceIndexed(Address)-GetAddressPendingPays(Address) < GetCustFee(MyLastBlock) then ErrorCode:=2; -if TranxAlreadyPending(OrderInfo.TrfrID ) then ErrorCode:=3; -if OrderInfo.TimeStamp < LastBlockData.TimeStart then ErrorCode:=4; -if TrxExistsInLastBlock(OrderInfo.TrfrID) then ErrorCode:=5; - if GVTAlreadyTransfered(OrderInfo.Reference) then ErrorCode := 6; -StrTosign := 'Transfer GVT '+OrderInfo.Reference+' '+OrderInfo.Receiver+OrderInfo.TimeStamp.ToString; -if not VerifySignedString(StrToSign,OrderInfo.Signature,OrderInfo.sender ) then ErrorCode:=7; -if OrderInfo.sender <> AdminPubKey then ErrorCode := 8; -if ErrorCode= 0 then - begin - OpData := GetOpData(TextLine); // remove trx header - AddArrayPoolTXs(OrderInfo); - if form1.Server.Active then OutgoingMsjsAdd(GetPTCEcn+opdata); - end; -Result := ErrorCode; -if ErrorCode > 0 then - ToLog('events',TimeToStr(now)+'SendGVT error: '+ErrorCode.ToString); + if not GetOrderFromString(TextLine,OrderInfo) then exit; + Address := GetAddressFromPublicKey(OrderInfo.sender); + if address <> OrderInfo.Address then ErrorCode := 1; + // La direccion no dispone de fondos + if GetAddressBalanceIndexed(Address)-GetAddressPendingPays(Address) < GetCustFee(MyLastBlock) then ErrorCode:=2; + if TranxAlreadyPending(OrderInfo.TrfrID ) then ErrorCode:=3; + if OrderInfo.TimeStamp < LastBlockData.TimeStart then ErrorCode:=4; + if TrxExistsInLastBlock(OrderInfo.TrfrID) then ErrorCode:=5; + if GVTAlreadyTransfered(OrderInfo.Reference) then ErrorCode := 6; + StrTosign := 'Transfer GVT '+OrderInfo.Reference+' '+OrderInfo.Receiver+OrderInfo.TimeStamp.ToString; + if not VerifySignedString(StrToSign,OrderInfo.Signature,OrderInfo.sender ) then ErrorCode:=7; + if OrderInfo.sender <> AdminPubKey then ErrorCode := 8; + if ErrorCode= 0 then + begin + OpData := GetOpData(TextLine); // remove trx header + AddArrayPoolTXs(OrderInfo); + if form1.Server.Active then OutgoingMsjsAdd(GetPTCEcn+opdata); + end; + Result := ErrorCode; + if ErrorCode > 0 then + ToLog('events',TimeToStr(now)+'SendGVT error: '+ErrorCode.ToString); End; Procedure PTC_AdminMSG(TextLine:String); diff --git a/nosonetwork.pas b/nosonetwork.pas index 61b4270..fa58079 100644 --- a/nosonetwork.pas +++ b/nosonetwork.pas @@ -1240,7 +1240,6 @@ procedure TThreadClientRead.Execute; MemStream.Free; DownloadPSOs := false; end - else if Parameter(LLine,0) = 'GVTSFILE' then begin DownloadGVTs := true;