|
@@ -41,6 +41,20 @@ Type
|
|
|
|
|
|
{ TRPCServer }
|
|
{ TRPCServer }
|
|
|
|
|
|
|
|
+ { TPascalCoinJSONComp }
|
|
|
|
+
|
|
|
|
+ TPascalCoinJSONComp = Class
|
|
|
|
+ private
|
|
|
|
+ class function OperationsHashTreeToHexaString(Const OperationsHashTree : TOperationsHashTree) : AnsiString;
|
|
|
|
+ public
|
|
|
|
+ class function ToJSONCurrency(pascalCoins : Int64) : Real;
|
|
|
|
+ class procedure FillAccountObject(Const account : TAccount; jsonObj : TPCJSONObject);
|
|
|
|
+ class procedure FillBlockObject(nBlock : Cardinal; ANode : TNode; jsonObject: TPCJSONObject);
|
|
|
|
+ class procedure FillOperationObject(Const OPR : TOperationResume; currentNodeBlocksCount : Cardinal; jsonObject : TPCJSONObject);
|
|
|
|
+ class procedure FillOperationsHashTreeObject(Const OperationsHashTree : TOperationsHashTree; jsonObject : TPCJSONObject);
|
|
|
|
+ class procedure FillPublicKeyObject(const PubKey : TAccountKey; jsonObj : TPCJSONObject);
|
|
|
|
+ end;
|
|
|
|
+
|
|
TRPCServerThread = Class;
|
|
TRPCServerThread = Class;
|
|
TRPCServer = Class
|
|
TRPCServer = Class
|
|
private
|
|
private
|
|
@@ -108,6 +122,192 @@ Uses {$IFNDEF FPC}windows,{$ENDIF}
|
|
|
|
|
|
var _RPCServer : TRPCServer = Nil;
|
|
var _RPCServer : TRPCServer = Nil;
|
|
|
|
|
|
|
|
+{ TPascalCoinJSONComp }
|
|
|
|
+
|
|
|
|
+class function TPascalCoinJSONComp.ToJSONCurrency(pascalCoins: Int64): Real;
|
|
|
|
+Begin
|
|
|
|
+ Result := RoundTo( pascalCoins / 10000 , -4);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+class procedure TPascalCoinJSONComp.FillBlockObject(nBlock : Cardinal; ANode : TNode; jsonObject: TPCJSONObject);
|
|
|
|
+var pcops : TPCOperationsComp;
|
|
|
|
+ ob : TOperationBlock;
|
|
|
|
+begin
|
|
|
|
+ pcops := TPCOperationsComp.Create(Nil);
|
|
|
|
+ try
|
|
|
|
+ If ANode.Bank.BlocksCount<=nBlock then begin
|
|
|
|
+ Exit;
|
|
|
|
+ end;
|
|
|
|
+ ob := ANode.Bank.SafeBox.Block(nBlock).blockchainInfo;
|
|
|
|
+
|
|
|
|
+ jsonObject.GetAsVariant('block').Value:=ob.block;
|
|
|
|
+ jsonObject.GetAsVariant('enc_pubkey').Value := TCrypto.ToHexaString(TAccountComp.AccountKey2RawString(ob.account_key));
|
|
|
|
+ jsonObject.GetAsVariant('reward').Value:=ToJSONCurrency(ob.reward);
|
|
|
|
+ jsonObject.GetAsVariant('fee').Value:=ToJSONCurrency(ob.fee);
|
|
|
|
+ jsonObject.GetAsVariant('ver').Value:=ob.protocol_version;
|
|
|
|
+ jsonObject.GetAsVariant('ver_a').Value:=ob.protocol_available;
|
|
|
|
+ jsonObject.GetAsVariant('timestamp').Value:=Int64(ob.timestamp);
|
|
|
|
+ jsonObject.GetAsVariant('target').Value:=Int64(ob.compact_target);
|
|
|
|
+ jsonObject.GetAsVariant('nonce').Value:=Int64(ob.nonce);
|
|
|
|
+ jsonObject.GetAsVariant('payload').Value:=ob.block_payload;
|
|
|
|
+ jsonObject.GetAsVariant('sbh').Value:=TCrypto.ToHexaString(ob.initial_safe_box_hash);
|
|
|
|
+ jsonObject.GetAsVariant('oph').Value:=TCrypto.ToHexaString(ob.operations_hash);
|
|
|
|
+ jsonObject.GetAsVariant('pow').Value:=TCrypto.ToHexaString(ob.proof_of_work);
|
|
|
|
+ jsonObject.GetAsVariant('hashratekhs').Value := ANode.Bank.SafeBox.CalcBlockHashRateInKhs(ob.Block,50);
|
|
|
|
+ jsonObject.GetAsVariant('maturation').Value := ANode.Bank.BlocksCount - ob.block - 1;
|
|
|
|
+ If ANode.Bank.LoadOperations(pcops,nBlock) then begin
|
|
|
|
+ jsonObject.GetAsVariant('operations').Value:=pcops.Count;
|
|
|
|
+ end;
|
|
|
|
+ finally
|
|
|
|
+ pcops.Free;
|
|
|
|
+ end;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+class procedure TPascalCoinJSONComp.FillOperationObject(const OPR: TOperationResume; currentNodeBlocksCount : Cardinal; jsonObject: TPCJSONObject);
|
|
|
|
+Var i : Integer;
|
|
|
|
+ jsonArr : TPCJSONArray;
|
|
|
|
+ auxObj : TPCJSONObject;
|
|
|
|
+Begin
|
|
|
|
+ if Not OPR.valid then begin
|
|
|
|
+ jsonObject.GetAsVariant('valid').Value := OPR.valid;
|
|
|
|
+ end;
|
|
|
|
+ if (OPR.errors<>'') And (Not OPR.valid) then begin
|
|
|
|
+ jsonObject.GetAsVariant('errors').Value := OPR.errors;
|
|
|
|
+ end;
|
|
|
|
+ if OPR.valid then begin
|
|
|
|
+ jsonObject.GetAsVariant('block').Value:=OPR.Block;
|
|
|
|
+ jsonObject.GetAsVariant('time').Value:=OPR.time;
|
|
|
|
+ jsonObject.GetAsVariant('opblock').Value:=OPR.NOpInsideBlock;
|
|
|
|
+ if (OPR.Block>0) And (OPR.Block<currentNodeBlocksCount) then
|
|
|
|
+ jsonObject.GetAsVariant('maturation').Value := currentNodeBlocksCount - OPR.Block - 1
|
|
|
|
+ else jsonObject.GetAsVariant('maturation').Value := null;
|
|
|
|
+ end;
|
|
|
|
+ jsonObject.GetAsVariant('optype').Value:=OPR.OpType;
|
|
|
|
+ jsonObject.GetAsVariant('subtype').Value:=OPR.OpSubtype;
|
|
|
|
+ If (Not OPR.isMultiOperation) then Begin
|
|
|
|
+ jsonObject.GetAsVariant('account').Value:=OPR.AffectedAccount;
|
|
|
|
+ jsonObject.GetAsVariant('signer_account').Value:=OPR.SignerAccount;
|
|
|
|
+ jsonObject.GetAsVariant('n_operation').Value:=OPR.n_operation;
|
|
|
|
+ end else begin
|
|
|
|
+ jsonArr := jsonObject.GetAsArray('senders');
|
|
|
|
+ for i:=Low(OPR.senders) to High(OPR.Senders) do begin
|
|
|
|
+ auxObj := jsonArr.GetAsObject(jsonArr.Count);
|
|
|
|
+ auxObj.GetAsVariant('account').Value := OPR.Senders[i].Account;
|
|
|
|
+ auxObj.GetAsVariant('n_operation').Value := OPR.Senders[i].N_Operation;
|
|
|
|
+ auxObj.GetAsVariant('amount').Value := ToJSONCurrency(OPR.Senders[i].Amount * (-1));
|
|
|
|
+ auxObj.GetAsVariant('payload').Value := TCrypto.ToHexaString(OPR.Senders[i].Payload);
|
|
|
|
+ end;
|
|
|
|
+ //
|
|
|
|
+ jsonArr := jsonObject.GetAsArray('receivers');
|
|
|
|
+ for i:=Low(OPR.Receivers) to High(OPR.Receivers) do begin
|
|
|
|
+ auxObj := jsonArr.GetAsObject(jsonArr.Count);
|
|
|
|
+ auxObj.GetAsVariant('account').Value := OPR.Receivers[i].Account;
|
|
|
|
+ auxObj.GetAsVariant('amount').Value := ToJSONCurrency(OPR.Receivers[i].Amount);
|
|
|
|
+ auxObj.GetAsVariant('payload').Value := TCrypto.ToHexaString(OPR.Receivers[i].Payload);
|
|
|
|
+ end;
|
|
|
|
+ jsonArr := jsonObject.GetAsArray('changers');
|
|
|
|
+ for i:=Low(OPR.Changers) to High(OPR.Changers) do begin
|
|
|
|
+ auxObj := jsonArr.GetAsObject(jsonArr.Count);
|
|
|
|
+ auxObj.GetAsVariant('account').Value := OPR.Changers[i].Account;
|
|
|
|
+ auxObj.GetAsVariant('n_operation').Value := OPR.Changers[i].N_Operation;
|
|
|
|
+ If public_key in OPR.Changers[i].Changes_type then begin
|
|
|
|
+ auxObj.GetAsVariant('new_enc_pubkey').Value := TCrypto.ToHexaString(TAccountComp.AccountKey2RawString(OPR.Changers[i].New_Accountkey));
|
|
|
|
+ end;
|
|
|
|
+ If account_name in OPR.Changers[i].Changes_type then begin
|
|
|
|
+ auxObj.GetAsVariant('new_name').Value := OPR.Changers[i].New_Name;
|
|
|
|
+ end;
|
|
|
|
+ If account_type in OPR.Changers[i].Changes_type then begin
|
|
|
|
+ auxObj.GetAsVariant('new_type').Value := OPR.Changers[i].New_Type;
|
|
|
|
+ end;
|
|
|
|
+ end;
|
|
|
|
+ end;
|
|
|
|
+ jsonObject.GetAsVariant('optxt').Value:=OPR.OperationTxt;
|
|
|
|
+ jsonObject.GetAsVariant('fee').Value:=ToJSONCurrency(OPR.Fee);
|
|
|
|
+ if (Not OPR.isMultiOperation) then begin
|
|
|
|
+ jsonObject.GetAsVariant('amount').Value:=ToJSONCurrency(OPR.Amount);
|
|
|
|
+ if (OPR.Balance>=0) And (OPR.valid) then jsonObject.GetAsVariant('balance').Value:=ToJSONCurrency(OPR.Balance);
|
|
|
|
+ jsonObject.GetAsVariant('payload').Value:=TCrypto.ToHexaString(OPR.OriginalPayload);
|
|
|
|
+ end else begin
|
|
|
|
+ jsonObject.GetAsVariant('totalamount').Value:=ToJSONCurrency(OPR.Amount);
|
|
|
|
+ if (OPR.Balance>=0) And (OPR.valid) then jsonObject.GetAsVariant('balance').Value:=ToJSONCurrency(OPR.Balance);
|
|
|
|
+ end;
|
|
|
|
+ If (OPR.OpType = CT_Op_Transaction) then begin
|
|
|
|
+ If OPR.SignerAccount>=0 then begin
|
|
|
|
+ jsonObject.GetAsVariant('sender_account').Value:=OPR.SignerAccount;
|
|
|
|
+ end;
|
|
|
|
+ If OPR.DestAccount>=0 then begin
|
|
|
|
+ jsonObject.GetAsVariant('dest_account').Value:=OPR.DestAccount;
|
|
|
|
+ end;
|
|
|
|
+ end;
|
|
|
|
+ If OPR.newKey.EC_OpenSSL_NID>0 then begin
|
|
|
|
+ jsonObject.GetAsVariant('enc_pubkey').Value := TCrypto.ToHexaString(TAccountComp.AccountKey2RawString(OPR.newKey));
|
|
|
|
+ end;
|
|
|
|
+ if (OPR.valid) And (OPR.OperationHash<>'') then begin
|
|
|
|
+ jsonObject.GetAsVariant('ophash').Value := TCrypto.ToHexaString(OPR.OperationHash);
|
|
|
|
+ if (OPR.Block<CT_Protocol_Upgrade_v2_MinBlock) then begin
|
|
|
|
+ jsonObject.GetAsVariant('old_ophash').Value := TCrypto.ToHexaString(OPR.OperationHash_OLD);
|
|
|
|
+ end;
|
|
|
|
+ end;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+class procedure TPascalCoinJSONComp.FillAccountObject(const account: TAccount; jsonObj: TPCJSONObject);
|
|
|
|
+Begin
|
|
|
|
+ jsonObj.GetAsVariant('account').Value:=account.account;
|
|
|
|
+ jsonObj.GetAsVariant('enc_pubkey').Value := TCrypto.ToHexaString(TAccountComp.AccountKey2RawString(account.accountInfo.accountKey));
|
|
|
|
+ jsonObj.GetAsVariant('balance').Value:=ToJSONCurrency(account.balance);
|
|
|
|
+ jsonObj.GetAsVariant('n_operation').Value:=account.n_operation;
|
|
|
|
+ jsonObj.GetAsVariant('updated_b').Value:=account.updated_block;
|
|
|
|
+ case account.accountInfo.state of
|
|
|
|
+ as_Normal : jsonObj.GetAsVariant('state').Value:='normal';
|
|
|
|
+ as_ForSale : begin
|
|
|
|
+ jsonObj.GetAsVariant('state').Value:='listed';
|
|
|
|
+ jsonObj.GetAsVariant('locked_until_block').Value:=account.accountInfo.locked_until_block;
|
|
|
|
+ jsonObj.GetAsVariant('price').Value:=account.accountInfo.price;
|
|
|
|
+ jsonObj.GetAsVariant('seller_account').Value:=account.accountInfo.account_to_pay;
|
|
|
|
+ jsonObj.GetAsVariant('private_sale').Value:= (account.accountInfo.new_publicKey.EC_OpenSSL_NID<>0);
|
|
|
|
+ if not (account.accountInfo.new_publicKey.EC_OpenSSL_NID<>0) then begin
|
|
|
|
+ jsonObj.GetAsVariant('new_enc_pubkey').Value := TCrypto.ToHexaString(TAccountComp.AccountKey2RawString(account.accountInfo.new_publicKey));
|
|
|
|
+ end;
|
|
|
|
+ end
|
|
|
|
+ else raise Exception.Create('ERROR DEV 20170425-1');
|
|
|
|
+ end;
|
|
|
|
+ jsonObj.GetAsVariant('name').Value := account.name;
|
|
|
|
+ jsonObj.GetAsVariant('type').Value := account.account_type;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+class procedure TPascalCoinJSONComp.FillOperationsHashTreeObject(const OperationsHashTree: TOperationsHashTree; jsonObject: TPCJSONObject);
|
|
|
|
+begin
|
|
|
|
+ jsonObject.GetAsVariant('operations').Value:=OperationsHashTree.OperationsCount;
|
|
|
|
+ jsonObject.GetAsVariant('amount').Value:=ToJSONCurrency(OperationsHashTree.TotalAmount);
|
|
|
|
+ jsonObject.GetAsVariant('fee').Value:=ToJSONCurrency(OperationsHashTree.TotalFee);
|
|
|
|
+ jsonObject.GetAsVariant('rawoperations').Value:=OperationsHashTreeToHexaString(OperationsHashTree);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+class procedure TPascalCoinJSONComp.FillPublicKeyObject(const PubKey: TAccountKey; jsonObj: TPCJSONObject);
|
|
|
|
+begin
|
|
|
|
+ jsonObj.GetAsVariant('ec_nid').Value := PubKey.EC_OpenSSL_NID;
|
|
|
|
+ jsonObj.GetAsVariant('x').Value := TCrypto.ToHexaString(PubKey.x);
|
|
|
|
+ jsonObj.GetAsVariant('y').Value := TCrypto.ToHexaString(PubKey.y);
|
|
|
|
+ jsonObj.GetAsVariant('enc_pubkey').Value := TCrypto.ToHexaString(TAccountComp.AccountKey2RawString(PubKey));
|
|
|
|
+ jsonObj.GetAsVariant('b58_pubkey').Value := TAccountComp.AccountPublicKeyExport(PubKey);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+class function TPascalCoinJSONComp.OperationsHashTreeToHexaString(const OperationsHashTree: TOperationsHashTree): AnsiString;
|
|
|
|
+var ms : TMemoryStream;
|
|
|
|
+ raw : TRawBytes;
|
|
|
|
+Begin
|
|
|
|
+ ms := TMemoryStream.Create;
|
|
|
|
+ Try
|
|
|
|
+ OperationsHashTree.SaveOperationsHashTreeToStream(ms,false);
|
|
|
|
+ ms.Position := 0;
|
|
|
|
+ SetLength(raw,ms.Size);
|
|
|
|
+ ms.ReadBuffer(raw[1],ms.Size);
|
|
|
|
+ Result := TCrypto.ToHexaString(raw);
|
|
|
|
+ Finally
|
|
|
|
+ ms.Free;
|
|
|
|
+ End;
|
|
|
|
+end;
|
|
|
|
+
|
|
{ TRPCServer }
|
|
{ TRPCServer }
|
|
|
|
|
|
Procedure TRPCServer.AddRPCLog(Const Sender : String; Const Message : String);
|
|
Procedure TRPCServer.AddRPCLog(Const Sender : String; Const Message : String);
|
|
@@ -446,155 +646,23 @@ function TRPCProcess.ProcessMethod(const method: String; params: TPCJSONObject;
|
|
End;
|
|
End;
|
|
End;
|
|
End;
|
|
|
|
|
|
- Function OperationsHashTreeToHexaString(Const OperationsHashTree : TOperationsHashTree) : AnsiString;
|
|
|
|
- var ms : TMemoryStream;
|
|
|
|
- raw : TRawBytes;
|
|
|
|
- Begin
|
|
|
|
- ms := TMemoryStream.Create;
|
|
|
|
- Try
|
|
|
|
- OperationsHashTree.SaveOperationsHashTreeToStream(ms,false);
|
|
|
|
- ms.Position := 0;
|
|
|
|
- SetLength(raw,ms.Size);
|
|
|
|
- ms.ReadBuffer(raw[1],ms.Size);
|
|
|
|
- Result := TCrypto.ToHexaString(raw);
|
|
|
|
- Finally
|
|
|
|
- ms.Free;
|
|
|
|
- End;
|
|
|
|
- End;
|
|
|
|
-
|
|
|
|
Function GetBlock(nBlock : Cardinal; jsonObject : TPCJSONObject) : Boolean;
|
|
Function GetBlock(nBlock : Cardinal; jsonObject : TPCJSONObject) : Boolean;
|
|
- var pcops : TPCOperationsComp;
|
|
|
|
- ob : TOperationBlock;
|
|
|
|
begin
|
|
begin
|
|
- pcops := TPCOperationsComp.Create(Nil);
|
|
|
|
- try
|
|
|
|
- If FNode.Bank.BlocksCount<=nBlock then begin
|
|
|
|
- ErrorNum := CT_RPC_ErrNum_InvalidBlock;
|
|
|
|
- ErrorDesc := 'Cannot load Block: '+IntToStr(nBlock);
|
|
|
|
- Result := False;
|
|
|
|
- Exit;
|
|
|
|
- end;
|
|
|
|
- ob := FNode.Bank.SafeBox.Block(nBlock).blockchainInfo;
|
|
|
|
-
|
|
|
|
- jsonObject.GetAsVariant('block').Value:=ob.block;
|
|
|
|
- jsonObject.GetAsVariant('enc_pubkey').Value := TCrypto.ToHexaString(TAccountComp.AccountKey2RawString(ob.account_key));
|
|
|
|
- jsonObject.GetAsVariant('reward').Value:=ToJSONCurrency(ob.reward);
|
|
|
|
- jsonObject.GetAsVariant('fee').Value:=ToJSONCurrency(ob.fee);
|
|
|
|
- jsonObject.GetAsVariant('ver').Value:=ob.protocol_version;
|
|
|
|
- jsonObject.GetAsVariant('ver_a').Value:=ob.protocol_available;
|
|
|
|
- jsonObject.GetAsVariant('timestamp').Value:=Int64(ob.timestamp);
|
|
|
|
- jsonObject.GetAsVariant('target').Value:=Int64(ob.compact_target);
|
|
|
|
- jsonObject.GetAsVariant('nonce').Value:=Int64(ob.nonce);
|
|
|
|
- jsonObject.GetAsVariant('payload').Value:=ob.block_payload;
|
|
|
|
- jsonObject.GetAsVariant('sbh').Value:=TCrypto.ToHexaString(ob.initial_safe_box_hash);
|
|
|
|
- jsonObject.GetAsVariant('oph').Value:=TCrypto.ToHexaString(ob.operations_hash);
|
|
|
|
- jsonObject.GetAsVariant('pow').Value:=TCrypto.ToHexaString(ob.proof_of_work);
|
|
|
|
- jsonObject.GetAsVariant('hashratekhs').Value := FNode.Bank.SafeBox.CalcBlockHashRateInKhs(ob.Block,50);
|
|
|
|
- jsonObject.GetAsVariant('maturation').Value := FNode.Bank.BlocksCount - ob.block - 1;
|
|
|
|
- If FNode.Bank.LoadOperations(pcops,nBlock) then begin
|
|
|
|
- jsonObject.GetAsVariant('operations').Value:=pcops.Count;
|
|
|
|
- end;
|
|
|
|
- Result := True;
|
|
|
|
- finally
|
|
|
|
- pcops.Free;
|
|
|
|
|
|
+ If FNode.Bank.BlocksCount<=nBlock then begin
|
|
|
|
+ ErrorNum := CT_RPC_ErrNum_InvalidBlock;
|
|
|
|
+ ErrorDesc := 'Cannot load Block: '+IntToStr(nBlock);
|
|
|
|
+ Result := False;
|
|
|
|
+ Exit;
|
|
end;
|
|
end;
|
|
|
|
+ TPascalCoinJSONComp.FillBlockObject(nBlock,FNode,jsonObject);
|
|
|
|
+ Result := True;
|
|
end;
|
|
end;
|
|
|
|
|
|
Procedure FillOperationResumeToJSONObject(Const OPR : TOperationResume; jsonObject : TPCJSONObject);
|
|
Procedure FillOperationResumeToJSONObject(Const OPR : TOperationResume; jsonObject : TPCJSONObject);
|
|
- Var i : Integer;
|
|
|
|
- jsonArr : TPCJSONArray;
|
|
|
|
- auxObj : TPCJSONObject;
|
|
|
|
Begin
|
|
Begin
|
|
- if Not OPR.valid then begin
|
|
|
|
- jsonObject.GetAsVariant('valid').Value := OPR.valid;
|
|
|
|
- end;
|
|
|
|
- if (OPR.errors<>'') And (Not OPR.valid) then begin
|
|
|
|
- jsonObject.GetAsVariant('errors').Value := OPR.errors;
|
|
|
|
- end;
|
|
|
|
- if OPR.valid then begin
|
|
|
|
- jsonObject.GetAsVariant('block').Value:=OPR.Block;
|
|
|
|
- jsonObject.GetAsVariant('time').Value:=OPR.time;
|
|
|
|
- jsonObject.GetAsVariant('opblock').Value:=OPR.NOpInsideBlock;
|
|
|
|
- if (OPR.Block>0) And (OPR.Block<FNode.Bank.BlocksCount) then
|
|
|
|
- jsonObject.GetAsVariant('maturation').Value := FNode.Bank.BlocksCount - OPR.Block - 1
|
|
|
|
- else jsonObject.GetAsVariant('maturation').Value := null;
|
|
|
|
- end;
|
|
|
|
- jsonObject.GetAsVariant('optype').Value:=OPR.OpType;
|
|
|
|
- jsonObject.GetAsVariant('subtype').Value:=OPR.OpSubtype;
|
|
|
|
- If (Not OPR.isMultiOperation) then Begin
|
|
|
|
- jsonObject.GetAsVariant('account').Value:=OPR.AffectedAccount;
|
|
|
|
- jsonObject.GetAsVariant('signer_account').Value:=OPR.SignerAccount;
|
|
|
|
- jsonObject.GetAsVariant('n_operation').Value:=OPR.n_operation;
|
|
|
|
- end else begin
|
|
|
|
- jsonArr := jsonObject.GetAsArray('senders');
|
|
|
|
- for i:=Low(OPR.senders) to High(OPR.Senders) do begin
|
|
|
|
- auxObj := jsonArr.GetAsObject(jsonArr.Count);
|
|
|
|
- auxObj.GetAsVariant('account').Value := OPR.Senders[i].Account;
|
|
|
|
- auxObj.GetAsVariant('n_operation').Value := OPR.Senders[i].N_Operation;
|
|
|
|
- auxObj.GetAsVariant('amount').Value := ToJSONCurrency(OPR.Senders[i].Amount * (-1));
|
|
|
|
- auxObj.GetAsVariant('payload').Value := TCrypto.ToHexaString(OPR.Senders[i].Payload);
|
|
|
|
- end;
|
|
|
|
- //
|
|
|
|
- jsonArr := jsonObject.GetAsArray('receivers');
|
|
|
|
- for i:=Low(OPR.Receivers) to High(OPR.Receivers) do begin
|
|
|
|
- auxObj := jsonArr.GetAsObject(jsonArr.Count);
|
|
|
|
- auxObj.GetAsVariant('account').Value := OPR.Receivers[i].Account;
|
|
|
|
- auxObj.GetAsVariant('amount').Value := ToJSONCurrency(OPR.Receivers[i].Amount);
|
|
|
|
- auxObj.GetAsVariant('payload').Value := TCrypto.ToHexaString(OPR.Receivers[i].Payload);
|
|
|
|
- end;
|
|
|
|
- jsonArr := jsonObject.GetAsArray('changers');
|
|
|
|
- for i:=Low(OPR.Changers) to High(OPR.Changers) do begin
|
|
|
|
- auxObj := jsonArr.GetAsObject(jsonArr.Count);
|
|
|
|
- auxObj.GetAsVariant('account').Value := OPR.Changers[i].Account;
|
|
|
|
- auxObj.GetAsVariant('n_operation').Value := OPR.Changers[i].N_Operation;
|
|
|
|
- If public_key in OPR.Changers[i].Changes_type then begin
|
|
|
|
- auxObj.GetAsVariant('new_enc_pubkey').Value := TCrypto.ToHexaString(TAccountComp.AccountKey2RawString(OPR.Changers[i].New_Accountkey));
|
|
|
|
- end;
|
|
|
|
- If account_name in OPR.Changers[i].Changes_type then begin
|
|
|
|
- auxObj.GetAsVariant('new_name').Value := OPR.Changers[i].New_Name;
|
|
|
|
- end;
|
|
|
|
- If account_type in OPR.Changers[i].Changes_type then begin
|
|
|
|
- auxObj.GetAsVariant('new_type').Value := OPR.Changers[i].New_Type;
|
|
|
|
- end;
|
|
|
|
- end;
|
|
|
|
- end;
|
|
|
|
- jsonObject.GetAsVariant('optxt').Value:=OPR.OperationTxt;
|
|
|
|
- jsonObject.GetAsVariant('fee').Value:=ToJSONCurrency(OPR.Fee);
|
|
|
|
- if (Not OPR.isMultiOperation) then begin
|
|
|
|
- jsonObject.GetAsVariant('amount').Value:=ToJSONCurrency(OPR.Amount);
|
|
|
|
- if (OPR.Balance>=0) And (OPR.valid) then jsonObject.GetAsVariant('balance').Value:=ToJSONCurrency(OPR.Balance);
|
|
|
|
- jsonObject.GetAsVariant('payload').Value:=TCrypto.ToHexaString(OPR.OriginalPayload);
|
|
|
|
- end else begin
|
|
|
|
- jsonObject.GetAsVariant('totalamount').Value:=ToJSONCurrency(OPR.Amount);
|
|
|
|
- if (OPR.Balance>=0) And (OPR.valid) then jsonObject.GetAsVariant('balance').Value:=ToJSONCurrency(OPR.Balance);
|
|
|
|
- end;
|
|
|
|
- If (OPR.OpType = CT_Op_Transaction) then begin
|
|
|
|
- If OPR.SignerAccount>=0 then begin
|
|
|
|
- jsonObject.GetAsVariant('sender_account').Value:=OPR.SignerAccount;
|
|
|
|
- end;
|
|
|
|
- If OPR.DestAccount>=0 then begin
|
|
|
|
- jsonObject.GetAsVariant('dest_account').Value:=OPR.DestAccount;
|
|
|
|
- end;
|
|
|
|
- end;
|
|
|
|
- If OPR.newKey.EC_OpenSSL_NID>0 then begin
|
|
|
|
- jsonObject.GetAsVariant('enc_pubkey').Value := TCrypto.ToHexaString(TAccountComp.AccountKey2RawString(OPR.newKey));
|
|
|
|
- end;
|
|
|
|
- if (OPR.valid) And (OPR.OperationHash<>'') then begin
|
|
|
|
- jsonObject.GetAsVariant('ophash').Value := TCrypto.ToHexaString(OPR.OperationHash);
|
|
|
|
- if (OPR.Block<CT_Protocol_Upgrade_v2_MinBlock) then begin
|
|
|
|
- jsonObject.GetAsVariant('old_ophash').Value := TCrypto.ToHexaString(OPR.OperationHash_OLD);
|
|
|
|
- end;
|
|
|
|
- end;
|
|
|
|
|
|
+ TPascalCoinJSONComp.FillOperationObject(OPR,FNode.Bank.BlocksCount,jsonObject);
|
|
end;
|
|
end;
|
|
|
|
|
|
- Procedure FillOperationsHashTreeToJSONObject(Const OperationsHashTree : TOperationsHashTree; jsonObject : TPCJSONObject);
|
|
|
|
- Begin
|
|
|
|
- jsonObject.GetAsVariant('operations').Value:=OperationsHashTree.OperationsCount;
|
|
|
|
- jsonObject.GetAsVariant('amount').Value:=ToJSONCurrency(OperationsHashTree.TotalAmount);
|
|
|
|
- jsonObject.GetAsVariant('fee').Value:=ToJSONCurrency(OperationsHashTree.TotalFee);
|
|
|
|
- jsonObject.GetAsVariant('rawoperations').Value:=OperationsHashTreeToHexaString(OperationsHashTree);
|
|
|
|
- End;
|
|
|
|
-
|
|
|
|
Function GetAccountOperations(accountNumber : Cardinal; jsonArray : TPCJSONArray; maxBlocksDepth, startReg, maxReg: Integer; forceStartBlock : Cardinal) : Boolean;
|
|
Function GetAccountOperations(accountNumber : Cardinal; jsonArray : TPCJSONArray; maxBlocksDepth, startReg, maxReg: Integer; forceStartBlock : Cardinal) : Boolean;
|
|
var list : TList;
|
|
var list : TList;
|
|
Op : TPCOperation;
|
|
Op : TPCOperation;
|
|
@@ -620,7 +688,7 @@ function TRPCProcess.ProcessMethod(const method: String; params: TPCJSONObject;
|
|
FNode.Operations.OperationsHashTree.GetOperationsAffectingAccount(accountNumber,list);
|
|
FNode.Operations.OperationsHashTree.GetOperationsAffectingAccount(accountNumber,list);
|
|
for i := list.Count - 1 downto 0 do begin
|
|
for i := list.Count - 1 downto 0 do begin
|
|
Op := FNode.Operations.OperationsHashTree.GetOperation(PtrInt(list[i]));
|
|
Op := FNode.Operations.OperationsHashTree.GetOperation(PtrInt(list[i]));
|
|
- If TPCOperation.OperationToOperationResume(0,Op,accountNumber,OPR) then begin
|
|
|
|
|
|
+ If TPCOperation.OperationToOperationResume(0,Op,False,accountNumber,OPR) then begin
|
|
OPR.NOpInsideBlock := i;
|
|
OPR.NOpInsideBlock := i;
|
|
OPR.Block := FNode.Operations.OperationBlock.block;
|
|
OPR.Block := FNode.Operations.OperationBlock.block;
|
|
OPR.Balance := FNode.Operations.SafeBoxTransaction.Account(accountNumber).balance;
|
|
OPR.Balance := FNode.Operations.SafeBoxTransaction.Account(accountNumber).balance;
|
|
@@ -760,7 +828,7 @@ function TRPCProcess.ProcessMethod(const method: String; params: TPCJSONObject;
|
|
ErrorNum := CT_RPC_ErrNum_InvalidOperation;
|
|
ErrorNum := CT_RPC_ErrNum_InvalidOperation;
|
|
Exit;
|
|
Exit;
|
|
end;
|
|
end;
|
|
- TPCOperation.OperationToOperationResume(0,opt,sender,opr);
|
|
|
|
|
|
+ TPCOperation.OperationToOperationResume(0,opt,False,sender,opr);
|
|
FillOperationResumeToJSONObject(opr,GetResultObject);
|
|
FillOperationResumeToJSONObject(opr,GetResultObject);
|
|
Result := true;
|
|
Result := true;
|
|
finally
|
|
finally
|
|
@@ -791,7 +859,7 @@ function TRPCProcess.ProcessMethod(const method: String; params: TPCJSONObject;
|
|
if opt=nil then exit;
|
|
if opt=nil then exit;
|
|
try
|
|
try
|
|
OperationsHashTree.AddOperationToHashTree(opt);
|
|
OperationsHashTree.AddOperationToHashTree(opt);
|
|
- FillOperationsHashTreeToJSONObject(OperationsHashTree,GetResultObject);
|
|
|
|
|
|
+ TPascalCoinJSONComp.FillOperationsHashTreeObject(OperationsHashTree,GetResultObject);
|
|
Result := true;
|
|
Result := true;
|
|
finally
|
|
finally
|
|
opt.Free;
|
|
opt.Free;
|
|
@@ -879,7 +947,7 @@ function TRPCProcess.ProcessMethod(const method: String; params: TPCJSONObject;
|
|
ErrorNum := CT_RPC_ErrNum_InvalidOperation;
|
|
ErrorNum := CT_RPC_ErrNum_InvalidOperation;
|
|
Exit;
|
|
Exit;
|
|
end;
|
|
end;
|
|
- TPCOperation.OperationToOperationResume(0,opck,account_signer,opr);
|
|
|
|
|
|
+ TPCOperation.OperationToOperationResume(0,opck,False,account_signer,opr);
|
|
FillOperationResumeToJSONObject(opr,GetResultObject);
|
|
FillOperationResumeToJSONObject(opr,GetResultObject);
|
|
Result := true;
|
|
Result := true;
|
|
finally
|
|
finally
|
|
@@ -1174,7 +1242,7 @@ function TRPCProcess.ProcessMethod(const method: String; params: TPCJSONObject;
|
|
if opck=nil then exit;
|
|
if opck=nil then exit;
|
|
try
|
|
try
|
|
OperationsHashTree.AddOperationToHashTree(opck);
|
|
OperationsHashTree.AddOperationToHashTree(opck);
|
|
- FillOperationsHashTreeToJSONObject(OperationsHashTree,GetResultObject);
|
|
|
|
|
|
+ TPascalCoinJSONComp.FillOperationsHashTreeObject(OperationsHashTree,GetResultObject);
|
|
Result := true;
|
|
Result := true;
|
|
finally
|
|
finally
|
|
opck.Free;
|
|
opck.Free;
|
|
@@ -1202,7 +1270,7 @@ function TRPCProcess.ProcessMethod(const method: String; params: TPCJSONObject;
|
|
for i := 0 to OperationsHashTree.OperationsCount - 1 do begin
|
|
for i := 0 to OperationsHashTree.OperationsCount - 1 do begin
|
|
Op := OperationsHashTree.GetOperation(i);
|
|
Op := OperationsHashTree.GetOperation(i);
|
|
Obj := jsonArray.GetAsObject(i);
|
|
Obj := jsonArray.GetAsObject(i);
|
|
- If TPCOperation.OperationToOperationResume(0,Op,Op.SignerAccount,OPR) then begin
|
|
|
|
|
|
+ If TPCOperation.OperationToOperationResume(0,Op,True,Op.SignerAccount,OPR) then begin
|
|
OPR.NOpInsideBlock := i;
|
|
OPR.NOpInsideBlock := i;
|
|
OPR.Balance := -1;
|
|
OPR.Balance := -1;
|
|
end else OPR := CT_TOperationResume_NUL;
|
|
end else OPR := CT_TOperationResume_NUL;
|
|
@@ -1248,40 +1316,6 @@ function TRPCProcess.ProcessMethod(const method: String; params: TPCJSONObject;
|
|
End;
|
|
End;
|
|
End;
|
|
End;
|
|
|
|
|
|
- Procedure FillAccountObject(Const account : TAccount; jsonObj : TPCJSONObject);
|
|
|
|
- Begin
|
|
|
|
- jsonObj.GetAsVariant('account').Value:=account.account;
|
|
|
|
- jsonObj.GetAsVariant('enc_pubkey').Value := TCrypto.ToHexaString(TAccountComp.AccountKey2RawString(account.accountInfo.accountKey));
|
|
|
|
- jsonObj.GetAsVariant('balance').Value:=ToJSONCurrency(account.balance);
|
|
|
|
- jsonObj.GetAsVariant('n_operation').Value:=account.n_operation;
|
|
|
|
- jsonObj.GetAsVariant('updated_b').Value:=account.updated_block;
|
|
|
|
- case account.accountInfo.state of
|
|
|
|
- as_Normal : jsonObj.GetAsVariant('state').Value:='normal';
|
|
|
|
- as_ForSale : begin
|
|
|
|
- jsonObj.GetAsVariant('state').Value:='listed';
|
|
|
|
- jsonObj.GetAsVariant('locked_until_block').Value:=account.accountInfo.locked_until_block;
|
|
|
|
- jsonObj.GetAsVariant('price').Value:=account.accountInfo.price;
|
|
|
|
- jsonObj.GetAsVariant('seller_account').Value:=account.accountInfo.account_to_pay;
|
|
|
|
- jsonObj.GetAsVariant('private_sale').Value:= (account.accountInfo.new_publicKey.EC_OpenSSL_NID<>0);
|
|
|
|
- if not (account.accountInfo.new_publicKey.EC_OpenSSL_NID<>0) then begin
|
|
|
|
- jsonObj.GetAsVariant('new_enc_pubkey').Value := TCrypto.ToHexaString(TAccountComp.AccountKey2RawString(account.accountInfo.new_publicKey));
|
|
|
|
- end;
|
|
|
|
- end
|
|
|
|
- else raise Exception.Create('ERROR DEV 20170425-1');
|
|
|
|
- end;
|
|
|
|
- jsonObj.GetAsVariant('name').Value := account.name;
|
|
|
|
- jsonObj.GetAsVariant('type').Value := account.account_type;
|
|
|
|
- end;
|
|
|
|
-
|
|
|
|
- Procedure FillPublicKeyObject(const PubKey : TAccountKey; jsonObj : TPCJSONObject);
|
|
|
|
- Begin
|
|
|
|
- jsonObj.GetAsVariant('ec_nid').Value := PubKey.EC_OpenSSL_NID;
|
|
|
|
- jsonObj.GetAsVariant('x').Value := TCrypto.ToHexaString(PubKey.x);
|
|
|
|
- jsonObj.GetAsVariant('y').Value := TCrypto.ToHexaString(PubKey.y);
|
|
|
|
- jsonObj.GetAsVariant('enc_pubkey').Value := TCrypto.ToHexaString(TAccountComp.AccountKey2RawString(PubKey));
|
|
|
|
- jsonObj.GetAsVariant('b58_pubkey').Value := TAccountComp.AccountPublicKeyExport(PubKey);
|
|
|
|
- End;
|
|
|
|
-
|
|
|
|
Function DoEncrypt(RawPayload : TRawBytes; pub_key : TAccountKey; Const Payload_method, EncodePwd : AnsiString) : Boolean;
|
|
Function DoEncrypt(RawPayload : TRawBytes; pub_key : TAccountKey; Const Payload_method, EncodePwd : AnsiString) : Boolean;
|
|
Var f_raw : TRawBytes;
|
|
Var f_raw : TRawBytes;
|
|
begin
|
|
begin
|
|
@@ -1473,7 +1507,7 @@ function TRPCProcess.ProcessMethod(const method: String; params: TPCJSONObject;
|
|
last_n_operation := params.AsCardinal('last_n_operation',0);
|
|
last_n_operation := params.AsCardinal('last_n_operation',0);
|
|
If not SignListAccountForSaleEx(params,OperationsHashTree,accountpubkey,last_n_operation) then Exit
|
|
If not SignListAccountForSaleEx(params,OperationsHashTree,accountpubkey,last_n_operation) then Exit
|
|
else Result := True;
|
|
else Result := True;
|
|
- FillOperationsHashTreeToJSONObject(OperationsHashTree,GetResultObject);
|
|
|
|
|
|
+ TPascalCoinJSONComp.FillOperationsHashTreeObject(OperationsHashTree,GetResultObject);
|
|
finally
|
|
finally
|
|
OperationsHashTree.Free;
|
|
OperationsHashTree.Free;
|
|
end;
|
|
end;
|
|
@@ -1682,7 +1716,7 @@ function TRPCProcess.ProcessMethod(const method: String; params: TPCJSONObject;
|
|
last_n_operation := params.AsCardinal('last_n_operation',0);
|
|
last_n_operation := params.AsCardinal('last_n_operation',0);
|
|
If not SignChangeAccountInfoEx(params,OperationsHashTree,accountpubkey,last_n_operation) then Exit
|
|
If not SignChangeAccountInfoEx(params,OperationsHashTree,accountpubkey,last_n_operation) then Exit
|
|
else Result := True;
|
|
else Result := True;
|
|
- FillOperationsHashTreeToJSONObject(OperationsHashTree,GetResultObject);
|
|
|
|
|
|
+ TPascalCoinJSONComp.FillOperationsHashTreeObject(OperationsHashTree,GetResultObject);
|
|
finally
|
|
finally
|
|
OperationsHashTree.Free;
|
|
OperationsHashTree.Free;
|
|
end;
|
|
end;
|
|
@@ -1709,7 +1743,7 @@ function TRPCProcess.ProcessMethod(const method: String; params: TPCJSONObject;
|
|
last_n_operation := params.AsCardinal('last_n_operation',0);
|
|
last_n_operation := params.AsCardinal('last_n_operation',0);
|
|
If not SignDelistAccountForSaleEx(params,OperationsHashTree,accountpubkey,last_n_operation) then Exit
|
|
If not SignDelistAccountForSaleEx(params,OperationsHashTree,accountpubkey,last_n_operation) then Exit
|
|
else Result := True;
|
|
else Result := True;
|
|
- FillOperationsHashTreeToJSONObject(OperationsHashTree,GetResultObject);
|
|
|
|
|
|
+ TPascalCoinJSONComp.FillOperationsHashTreeObject(OperationsHashTree,GetResultObject);
|
|
finally
|
|
finally
|
|
OperationsHashTree.Free;
|
|
OperationsHashTree.Free;
|
|
end;
|
|
end;
|
|
@@ -1805,7 +1839,7 @@ function TRPCProcess.ProcessMethod(const method: String; params: TPCJSONObject;
|
|
last_n_operation := params.AsCardinal('last_n_operation',0);
|
|
last_n_operation := params.AsCardinal('last_n_operation',0);
|
|
If not SignBuyAccountEx(params,OperationsHashTree,accountpubkey,last_n_operation) then Exit
|
|
If not SignBuyAccountEx(params,OperationsHashTree,accountpubkey,last_n_operation) then Exit
|
|
else Result := True;
|
|
else Result := True;
|
|
- FillOperationsHashTreeToJSONObject(OperationsHashTree,GetResultObject);
|
|
|
|
|
|
+ TPascalCoinJSONComp.FillOperationsHashTreeObject(OperationsHashTree,GetResultObject);
|
|
finally
|
|
finally
|
|
OperationsHashTree.Free;
|
|
OperationsHashTree.Free;
|
|
end;
|
|
end;
|
|
@@ -1860,7 +1894,7 @@ function TRPCProcess.ProcessMethod(const method: String; params: TPCJSONObject;
|
|
ErrorDesc := errors;
|
|
ErrorDesc := errors;
|
|
Exit;
|
|
Exit;
|
|
end else Result := True;
|
|
end else Result := True;
|
|
- TPCOperation.OperationToOperationResume(0,opt,c_account,opr);
|
|
|
|
|
|
+ TPCOperation.OperationToOperationResume(0,opt,False,c_account,opr);
|
|
FillOperationResumeToJSONObject(opr,GetResultObject);
|
|
FillOperationResumeToJSONObject(opr,GetResultObject);
|
|
finally
|
|
finally
|
|
OperationsHashTree.Free;
|
|
OperationsHashTree.Free;
|
|
@@ -1919,7 +1953,7 @@ function TRPCProcess.ProcessMethod(const method: String; params: TPCJSONObject;
|
|
ErrorDesc := errors;
|
|
ErrorDesc := errors;
|
|
Exit;
|
|
Exit;
|
|
end else Result := True;
|
|
end else Result := True;
|
|
- TPCOperation.OperationToOperationResume(0,opt,c_account,opr);
|
|
|
|
|
|
+ TPCOperation.OperationToOperationResume(0,opt,False,c_account,opr);
|
|
FillOperationResumeToJSONObject(opr,GetResultObject);
|
|
FillOperationResumeToJSONObject(opr,GetResultObject);
|
|
finally
|
|
finally
|
|
OperationsHashTree.Free;
|
|
OperationsHashTree.Free;
|
|
@@ -1961,7 +1995,7 @@ function TRPCProcess.ProcessMethod(const method: String; params: TPCJSONObject;
|
|
ErrorDesc := errors;
|
|
ErrorDesc := errors;
|
|
Exit;
|
|
Exit;
|
|
end else Result := True;
|
|
end else Result := True;
|
|
- TPCOperation.OperationToOperationResume(0,opt,c_account,opr);
|
|
|
|
|
|
+ TPCOperation.OperationToOperationResume(0,opt,False,c_account,opr);
|
|
FillOperationResumeToJSONObject(opr,GetResultObject);
|
|
FillOperationResumeToJSONObject(opr,GetResultObject);
|
|
finally
|
|
finally
|
|
OperationsHashTree.Free;
|
|
OperationsHashTree.Free;
|
|
@@ -2020,7 +2054,7 @@ function TRPCProcess.ProcessMethod(const method: String; params: TPCJSONObject;
|
|
ErrorDesc := errors;
|
|
ErrorDesc := errors;
|
|
Exit;
|
|
Exit;
|
|
end else Result := True;
|
|
end else Result := True;
|
|
- TPCOperation.OperationToOperationResume(0,opt,c_account,opr);
|
|
|
|
|
|
+ TPCOperation.OperationToOperationResume(0,opt,False,c_account,opr);
|
|
FillOperationResumeToJSONObject(opr,GetResultObject);
|
|
FillOperationResumeToJSONObject(opr,GetResultObject);
|
|
finally
|
|
finally
|
|
OperationsHashTree.Free;
|
|
OperationsHashTree.Free;
|
|
@@ -2071,7 +2105,7 @@ function TRPCProcess.ProcessMethod(const method: String; params: TPCJSONObject;
|
|
if accountNumber >= 0 then begin
|
|
if accountNumber >= 0 then begin
|
|
account := FNode.Operations.SafeBoxTransaction.Account(accountNumber);
|
|
account := FNode.Operations.SafeBoxTransaction.Account(accountNumber);
|
|
if (accountType = -1) OR (Integer(account.account_type) = accountType) then
|
|
if (accountType = -1) OR (Integer(account.account_type) = accountType) then
|
|
- FillAccountObject(account,output.GetAsObject(output.Count));
|
|
|
|
|
|
+ TPascalCoinJSONComp.FillAccountObject(account,output.GetAsObject(output.Count));
|
|
end;
|
|
end;
|
|
end else begin
|
|
end else begin
|
|
// Search by type
|
|
// Search by type
|
|
@@ -2079,7 +2113,7 @@ function TRPCProcess.ProcessMethod(const method: String; params: TPCJSONObject;
|
|
account := FNode.Operations.SafeBoxTransaction.Account(i);
|
|
account := FNode.Operations.SafeBoxTransaction.Account(i);
|
|
if (accountType = -1) OR (Integer(account.account_type) = accountType) then begin
|
|
if (accountType = -1) OR (Integer(account.account_type) = accountType) then begin
|
|
// Found a match
|
|
// Found a match
|
|
- FillAccountObject(account,output.GetAsObject(output.Count));
|
|
|
|
|
|
+ TPascalCoinJSONComp.FillAccountObject(account,output.GetAsObject(output.Count));
|
|
if output.Count>=max then break;
|
|
if output.Count>=max then break;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
@@ -2167,7 +2201,7 @@ begin
|
|
c := params.GetAsVariant('account').AsCardinal(CT_MaxAccount);
|
|
c := params.GetAsVariant('account').AsCardinal(CT_MaxAccount);
|
|
if (c>=0) And (c<FNode.Bank.AccountsCount) then begin
|
|
if (c>=0) And (c<FNode.Bank.AccountsCount) then begin
|
|
account := FNode.Operations.SafeBoxTransaction.Account(c);
|
|
account := FNode.Operations.SafeBoxTransaction.Account(c);
|
|
- FillAccountObject(account,GetResultObject);
|
|
|
|
|
|
+ TPascalCoinJSONComp.FillAccountObject(account,GetResultObject);
|
|
Result := True;
|
|
Result := True;
|
|
end else begin
|
|
end else begin
|
|
ErrorNum := CT_RPC_ErrNum_InvalidAccount;
|
|
ErrorNum := CT_RPC_ErrNum_InvalidAccount;
|
|
@@ -2196,7 +2230,7 @@ begin
|
|
for j := 0 to ocl.Count - 1 do begin
|
|
for j := 0 to ocl.Count - 1 do begin
|
|
if (j>=l) then begin
|
|
if (j>=l) then begin
|
|
account := FNode.Operations.SafeBoxTransaction.Account(ocl.Get(j));
|
|
account := FNode.Operations.SafeBoxTransaction.Account(ocl.Get(j));
|
|
- FillAccountObject(account,jsonarr.GetAsObject(jsonarr.Count));
|
|
|
|
|
|
+ TPascalCoinJSONComp.FillAccountObject(account,jsonarr.GetAsObject(jsonarr.Count));
|
|
end;
|
|
end;
|
|
if (k>0) And ((j+1)>=(k+l)) then break;
|
|
if (k>0) And ((j+1)>=(k+l)) then break;
|
|
end;
|
|
end;
|
|
@@ -2210,7 +2244,7 @@ begin
|
|
for j := 0 to ocl.Count - 1 do begin
|
|
for j := 0 to ocl.Count - 1 do begin
|
|
if (c>=l) then begin
|
|
if (c>=l) then begin
|
|
account := FNode.Operations.SafeBoxTransaction.Account(ocl.Get(j));
|
|
account := FNode.Operations.SafeBoxTransaction.Account(ocl.Get(j));
|
|
- FillAccountObject(account,jsonarr.GetAsObject(jsonarr.Count));
|
|
|
|
|
|
+ TPascalCoinJSONComp.FillAccountObject(account,jsonarr.GetAsObject(jsonarr.Count));
|
|
end;
|
|
end;
|
|
inc(c);
|
|
inc(c);
|
|
if (k>0) And (c>=(k+l)) then break;
|
|
if (k>0) And (c>=(k+l)) then break;
|
|
@@ -2288,7 +2322,7 @@ begin
|
|
jso := jsonarr.GetAsObject(jsonarr.count);
|
|
jso := jsonarr.GetAsObject(jsonarr.count);
|
|
jso.GetAsVariant('name').Value := _RPCServer.WalletKeys.Key[i].Name;
|
|
jso.GetAsVariant('name').Value := _RPCServer.WalletKeys.Key[i].Name;
|
|
jso.GetAsVariant('can_use').Value := (_RPCServer.WalletKeys.Key[i].CryptedKey<>'');
|
|
jso.GetAsVariant('can_use').Value := (_RPCServer.WalletKeys.Key[i].CryptedKey<>'');
|
|
- FillPublicKeyObject(_RPCServer.WalletKeys.Key[i].AccountKey,jso);
|
|
|
|
|
|
+ TPascalCoinJSONComp.FillPublicKeyObject(_RPCServer.WalletKeys.Key[i].AccountKey,jso);
|
|
end;
|
|
end;
|
|
if (k>0) And ((i+1)>=(j+k)) then break;
|
|
if (k>0) And ((i+1)>=(j+k)) then break;
|
|
end;
|
|
end;
|
|
@@ -2304,7 +2338,7 @@ begin
|
|
ErrorDesc := 'Public key not found in wallet';
|
|
ErrorDesc := 'Public key not found in wallet';
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
- FillPublicKeyObject(_RPCServer.WalletKeys.AccountsKeyList.AccountKey[i],GetResultObject);
|
|
|
|
|
|
+ TPascalCoinJSONComp.FillPublicKeyObject(_RPCServer.WalletKeys.AccountsKeyList.AccountKey[i],GetResultObject);
|
|
Result := true;
|
|
Result := true;
|
|
end else if (method='getblock') then begin
|
|
end else if (method='getblock') then begin
|
|
// Param "block" contains block number (0..getblockcount-1)
|
|
// Param "block" contains block number (0..getblockcount-1)
|
|
@@ -2373,7 +2407,7 @@ begin
|
|
ErrorDesc := 'Block/Operation not found: '+IntToStr(c)+'/'+IntToStr(i)+' BlockOperations:'+IntToStr(pcops.Count);
|
|
ErrorDesc := 'Block/Operation not found: '+IntToStr(c)+'/'+IntToStr(i)+' BlockOperations:'+IntToStr(pcops.Count);
|
|
Exit;
|
|
Exit;
|
|
end;
|
|
end;
|
|
- If TPCOperation.OperationToOperationResume(c,pcops.Operation[i],pcops.Operation[i].SignerAccount,opr) then begin
|
|
|
|
|
|
+ If TPCOperation.OperationToOperationResume(c,pcops.Operation[i],True,pcops.Operation[i].SignerAccount,opr) then begin
|
|
opr.NOpInsideBlock:=i;
|
|
opr.NOpInsideBlock:=i;
|
|
opr.time:=pcops.OperationBlock.timestamp;
|
|
opr.time:=pcops.OperationBlock.timestamp;
|
|
opr.Balance := -1;
|
|
opr.Balance := -1;
|
|
@@ -2405,7 +2439,7 @@ begin
|
|
j := params.AsInteger('start',0);
|
|
j := params.AsInteger('start',0);
|
|
for i := 0 to pcops.Count - 1 do begin
|
|
for i := 0 to pcops.Count - 1 do begin
|
|
if (i>=j) then begin
|
|
if (i>=j) then begin
|
|
- If TPCOperation.OperationToOperationResume(c,pcops.Operation[i],pcops.Operation[i].SignerAccount,opr) then begin
|
|
|
|
|
|
+ If TPCOperation.OperationToOperationResume(c,pcops.Operation[i],True,pcops.Operation[i].SignerAccount,opr) then begin
|
|
opr.NOpInsideBlock:=i;
|
|
opr.NOpInsideBlock:=i;
|
|
opr.time:=pcops.OperationBlock.timestamp;
|
|
opr.time:=pcops.OperationBlock.timestamp;
|
|
opr.Balance := -1; // Don't include!
|
|
opr.Balance := -1; // Don't include!
|
|
@@ -2445,7 +2479,7 @@ begin
|
|
// Create result
|
|
// Create result
|
|
GetResultArray;
|
|
GetResultArray;
|
|
for i:=FNode.Operations.Count-1 downto 0 do begin
|
|
for i:=FNode.Operations.Count-1 downto 0 do begin
|
|
- if not TPCOperation.OperationToOperationResume(0,FNode.Operations.Operation[i],FNode.Operations.Operation[i].SignerAccount,opr) then begin
|
|
|
|
|
|
+ if not TPCOperation.OperationToOperationResume(0,FNode.Operations.Operation[i],True,FNode.Operations.Operation[i].SignerAccount,opr) then begin
|
|
ErrorNum := CT_RPC_ErrNum_InternalError;
|
|
ErrorNum := CT_RPC_ErrNum_InternalError;
|
|
ErrorDesc := 'Error converting data';
|
|
ErrorDesc := 'Error converting data';
|
|
exit;
|
|
exit;
|
|
@@ -2497,7 +2531,7 @@ begin
|
|
end;
|
|
end;
|
|
else Raise Exception.Create('ERROR DEV 20171120-4');
|
|
else Raise Exception.Create('ERROR DEV 20171120-4');
|
|
end;
|
|
end;
|
|
- If not TPCOperation.OperationToOperationResume(c,pcops.Operation[i],pcops.Operation[i].SignerAccount,opr) then begin
|
|
|
|
|
|
+ If not TPCOperation.OperationToOperationResume(c,pcops.Operation[i],True,pcops.Operation[i].SignerAccount,opr) then begin
|
|
ErrorNum := CT_RPC_ErrNum_InternalError;
|
|
ErrorNum := CT_RPC_ErrNum_InternalError;
|
|
ErrorDesc := 'Error 20161026-1';
|
|
ErrorDesc := 'Error 20161026-1';
|
|
end;
|
|
end;
|
|
@@ -2775,7 +2809,7 @@ begin
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
if (TAccountComp.IsValidAccountKey(account.accountInfo.accountKey,ansistr)) then begin
|
|
if (TAccountComp.IsValidAccountKey(account.accountInfo.accountKey,ansistr)) then begin
|
|
- FillPublicKeyObject(account.accountInfo.accountKey,GetResultObject);
|
|
|
|
|
|
+ TPascalCoinJSONComp.FillPublicKeyObject(account.accountInfo.accountKey,GetResultObject);
|
|
Result := True;
|
|
Result := True;
|
|
end else begin
|
|
end else begin
|
|
ErrorDesc:= ansistr;
|
|
ErrorDesc:= ansistr;
|
|
@@ -2832,7 +2866,7 @@ begin
|
|
try
|
|
try
|
|
ecpkey.GenerateRandomPrivateKey(params.AsInteger('ec_nid',CT_Default_EC_OpenSSL_NID));
|
|
ecpkey.GenerateRandomPrivateKey(params.AsInteger('ec_nid',CT_Default_EC_OpenSSL_NID));
|
|
_RPCServer.FWalletKeys.AddPrivateKey(params.AsString('name',DateTimeToStr(now)),ecpkey);
|
|
_RPCServer.FWalletKeys.AddPrivateKey(params.AsString('name',DateTimeToStr(now)),ecpkey);
|
|
- FillPublicKeyObject(ecpkey.PublicKey,GetResultObject);
|
|
|
|
|
|
+ TPascalCoinJSONComp.FillPublicKeyObject(ecpkey.PublicKey,GetResultObject);
|
|
Result := true;
|
|
Result := true;
|
|
finally
|
|
finally
|
|
ecpkey.Free;
|
|
ecpkey.Free;
|