Browse Source

JSON-RPC minor changes

PascalCoin 7 years ago
parent
commit
0561ddea97
2 changed files with 35 additions and 32 deletions
  1. 25 25
      README.md
  2. 10 7
      src/core/URPC.pas

+ 25 - 25
README.md

@@ -55,36 +55,36 @@ Also, consider a donation at PascalCoin development account: "0-10"
 - JSON-RPC changes:
 - JSON-RPC changes:
   - Added param "startblock" to "getaccountoperations" in order to start searching backwards on a specific block. Note: Balance will not be returned on each operation due cannot be calculated. Default value "0" means start searching on current block as usual
   - Added param "startblock" to "getaccountoperations" in order to start searching backwards on a specific block. Note: Balance will not be returned on each operation due cannot be calculated. Default value "0" means start searching on current block as usual
   - Operation Object changes:
   - Operation Object changes:
+    New fields:
+    - "senders" : ARRAY of objects - When is a transaction, this array contains each sender
+      - "account" : Sending Account 
+      - "n_operation"
+      - "amount" : PASCURRENCY - In negative value, due it's outgoing from "account"
+      - "payload" : HEXASTRING
+    - "receivers" : ARRAY of objects - When is a transaction, this array contains each receiver
+      - "account" : Receiving Account 
+      - "amount" : PASCURRENCY - In positive value, due it's incoming from a sender to "account"
+      - "payload" : HEXASTRING
+    - "changers" : ARRAY of objects - When accounts changed state
+      - "account" : changing Account 
+      - "n_operation"
+      - "new_enc_pubkey" : If public key is changed
+      - "new_name" : If name is changed
+      - "new_type" : If type is changed
+      - "fee" : PASCURRENCY - In negative value, due it's outgoing from "account"
+    Modified fields / DEPRECATED FIELDS
+    Caused by multioperation introduction, search in "senders"/"receivers"/"changers" instead
     - "balance" will not be included when is not possible to calc previous balance of account searching at the past
     - "balance" will not be included when is not possible to calc previous balance of account searching at the past
-    - Fields not included when in Multioperation:
-      - "account" will not be included in Multioperations
-      - "signer_account" will not be included in Multioperations
-      - "n_operation" will not be included in Multioperations
-      - "amount" will not be included in Multioperations, need search on each field
-      - "payload" will not be included in Multioperations, need search on each field
-    - On Multioperations, will include those new fields:
-      - "totalamount" will be the total amount equal to SUM each "receivers"."amount" field
-      - "senders" : Will return an Array with Objects
-        - "account" : Sending Account 
-        - "n_operation"
-        - "amount" : In negative value, due it's outgoing form "account"
-        - "payload"
-      - "receivers"
-        - "account" : Receiving Account 
-        - "amount" : In positive value, due it's incoming from a sender to "account"
-        - "payload"
-      - "changers" : Will return an Array with Objects
-        - "account" : changing Account 
-        - "n_operation"
-        - "new_enc_pubkey" : If public key is changed
-        - "new_name" : If name is changed
-        - "new_type" : If type is changed
+    - "signer_account" will not be included in Multioperations
+    - "account" : will not be included in Multioperations, use fields in "senders"/"receivers"/"changers" instead    
+    - "n_operation" will not be included in Multioperations, use fields in "senders"/"receivers"/"changers" instead
+    - "payload" will not be included in Multioperations, use fields in "senders"/"receivers"/"changers" instead
   - New object "MultiOperation Object" : Will return info about a MultiOperation
   - New object "MultiOperation Object" : Will return info about a MultiOperation
     - "rawoperations" : HEXASTRING with this single MultiOperation in RAW format
     - "rawoperations" : HEXASTRING with this single MultiOperation in RAW format
     - "senders" : Will return an Array with Objects
     - "senders" : Will return an Array with Objects
       - "account" : Sending Account 
       - "account" : Sending Account 
       - "n_operation"
       - "n_operation"
-      - "amount" : In negative value, due it's outgoing form "account"
+      - "amount" : In negative value, due it's outgoing from "account"
       - "payload"
       - "payload"
     - "receivers"
     - "receivers"
       - "account" : Receiving Account 
       - "account" : Receiving Account 
@@ -98,7 +98,7 @@ Also, consider a donation at PascalCoin development account: "0-10"
       - "new_type" : If type is changed
       - "new_type" : If type is changed
     - "amount" : PASCURRENCY Amount received by receivers
     - "amount" : PASCURRENCY Amount received by receivers
     - "fee" : PASCURRENCY Equal to "total send" - "total received"
     - "fee" : PASCURRENCY Equal to "total send" - "total received"
-	- "signed_count" : Integer with info about how many accounts are signed 
+	- "signed_count" : Integer with info about how many accounts are signed. Does not check if signature is valid for a multioperation not included in blockchain 
 	- "not_signed_count" : Integer with info about how many accounts are pending to be signed
 	- "not_signed_count" : Integer with info about how many accounts are pending to be signed
     - "signed_can_execute"	: Boolean. True if everybody signed. Does not check if MultiOperation is well formed or can be added to Network because is an offline call
     - "signed_can_execute"	: Boolean. True if everybody signed. Does not check if MultiOperation is well formed or can be added to Network because is an offline call
   - New method "signmessage": Signs a digest message using a public key
   - New method "signmessage": Signs a digest message using a public key

+ 10 - 7
src/core/URPC.pas

@@ -190,7 +190,8 @@ Begin
     jsonObject.GetAsVariant('account').Value:=OPR.AffectedAccount;
     jsonObject.GetAsVariant('account').Value:=OPR.AffectedAccount;
     jsonObject.GetAsVariant('signer_account').Value:=OPR.SignerAccount;
     jsonObject.GetAsVariant('signer_account').Value:=OPR.SignerAccount;
     jsonObject.GetAsVariant('n_operation').Value:=OPR.n_operation;
     jsonObject.GetAsVariant('n_operation').Value:=OPR.n_operation;
-  end else begin
+  end;
+  // New V3: Will include senders[], receivers[] and changers[]
     jsonArr := jsonObject.GetAsArray('senders');
     jsonArr := jsonObject.GetAsArray('senders');
     for i:=Low(OPR.senders) to High(OPR.Senders) do begin
     for i:=Low(OPR.senders) to High(OPR.Senders) do begin
       auxObj := jsonArr.GetAsObject(jsonArr.Count);
       auxObj := jsonArr.GetAsObject(jsonArr.Count);
@@ -221,18 +222,17 @@ Begin
       If account_type in OPR.Changers[i].Changes_type then begin
       If account_type in OPR.Changers[i].Changes_type then begin
         auxObj.GetAsVariant('new_type').Value := OPR.Changers[i].New_Type;
         auxObj.GetAsVariant('new_type').Value := OPR.Changers[i].New_Type;
       end;
       end;
+      if (OPR.Changers[i].Fee<>0) then begin
+        auxObj.GetAsVariant('fee').Value := ToJSONCurrency(OPR.Changers[i].Fee * (-1));
+      end;
     end;
     end;
-  end;
   jsonObject.GetAsVariant('optxt').Value:=OPR.OperationTxt;
   jsonObject.GetAsVariant('optxt').Value:=OPR.OperationTxt;
   jsonObject.GetAsVariant('fee').Value:=ToJSONCurrency(OPR.Fee);
   jsonObject.GetAsVariant('fee').Value:=ToJSONCurrency(OPR.Fee);
+  jsonObject.GetAsVariant('amount').Value:=ToJSONCurrency(OPR.Amount);
   if (Not OPR.isMultiOperation) then begin
   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);
     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;
   end;
+  if (OPR.Balance>=0) And (OPR.valid) then jsonObject.GetAsVariant('balance').Value:=ToJSONCurrency(OPR.Balance);
   If (OPR.OpType = CT_Op_Transaction) then begin
   If (OPR.OpType = CT_Op_Transaction) then begin
     If OPR.SignerAccount>=0 then begin
     If OPR.SignerAccount>=0 then begin
       jsonObject.GetAsVariant('sender_account').Value:=OPR.SignerAccount;
       jsonObject.GetAsVariant('sender_account').Value:=OPR.SignerAccount;
@@ -3383,6 +3383,9 @@ begin
     TNetData.NetData.NetConnectionsActive:=true;
     TNetData.NetData.NetConnectionsActive:=true;
     jsonresponse.GetAsVariant('result').Value := true;
     jsonresponse.GetAsVariant('result').Value := true;
     Result := true;
     Result := true;
+  end else if (method='cleanblacklist') then begin
+    jsonresponse.GetAsVariant('result').Value := TNetData.NetData.NodeServersAddresses.CleanBlackList(True);
+    Result := True;
   end else begin
   end else begin
     ErrorNum := CT_RPC_ErrNum_MethodNotFound;
     ErrorNum := CT_RPC_ErrNum_MethodNotFound;
     ErrorDesc := 'Method not found: "'+method+'"';
     ErrorDesc := 'Method not found: "'+method+'"';