Browse Source

Merge upstream

Herman Schoenfeld 7 years ago
parent
commit
39e67773b0
4 changed files with 64 additions and 13 deletions
  1. 4 1
      README.md
  2. 6 3
      src/core/UBlockChain.pas
  3. 41 5
      src/core/UOpTransaction.pas
  4. 13 4
      src/core/URPC.pas

+ 4 - 1
README.md

@@ -68,9 +68,12 @@ Also, consider a donation at PascalCoin development account: "0-10"
     - "changers" : ARRAY of objects - When accounts changed state
     - "changers" : ARRAY of objects - When accounts changed state
       - "account" : changing Account 
       - "account" : changing Account 
       - "n_operation"
       - "n_operation"
-      - "new_enc_pubkey" : If public key is changed
+      - "new_enc_pubkey" : If public key is changed or when is listed for a private sale
       - "new_name" : If name is changed
       - "new_name" : If name is changed
       - "new_type" : If type is changed
       - "new_type" : If type is changed
+      - "seller_account" : If is listed for sale (public or private) will show seller account
+      - "account_price"	: PASCURRENCY - If is listed for sale (public or private) will show account price
+      - "locked_until_block" : If is listed for private sale will show block locked
       - "fee" : PASCURRENCY - In negative value, due it's outgoing from "account"
       - "fee" : PASCURRENCY - In negative value, due it's outgoing from "account"
     Modified fields / DEPRECATED FIELDS
     Modified fields / DEPRECATED FIELDS
     Caused by multioperation introduction, search in "senders"/"receivers"/"changers" instead
     Caused by multioperation introduction, search in "senders"/"receivers"/"changers" instead

+ 6 - 3
src/core/UBlockChain.pas

@@ -107,7 +107,7 @@ uses
 
 
 Type
 Type
   // Moved from UOpTransaction to here
   // Moved from UOpTransaction to here
-  TOpChangeAccountInfoType = (public_key,account_name,account_type);
+  TOpChangeAccountInfoType = (public_key,account_name,account_type,list_for_public_sale,list_for_private_sale,delist);
   TOpChangeAccountInfoTypes = Set of TOpChangeAccountInfoType;
   TOpChangeAccountInfoTypes = Set of TOpChangeAccountInfoType;
 
 
   // MultiOp... will allow a MultiOperation
   // MultiOp... will allow a MultiOperation
@@ -132,6 +132,9 @@ Type
     New_Accountkey: TAccountKey;  // If (changes_mask and $0001)=$0001 then change account key
     New_Accountkey: TAccountKey;  // If (changes_mask and $0001)=$0001 then change account key
     New_Name: TRawBytes;          // If (changes_mask and $0002)=$0002 then change name
     New_Name: TRawBytes;          // If (changes_mask and $0002)=$0002 then change name
     New_Type: Word;               // If (changes_mask and $0004)=$0004 then change type
     New_Type: Word;               // If (changes_mask and $0004)=$0004 then change type
+    Seller_Account : Int64;
+    Account_Price : Int64;
+    Locked_Until_Block : Cardinal;
     Fee: Int64;
     Fee: Int64;
     Signature: TECDSA_SIG;
     Signature: TECDSA_SIG;
   end;
   end;
@@ -472,8 +475,8 @@ Const
   CT_TOperationResume_NUL : TOperationResume = (valid:false;Block:0;NOpInsideBlock:-1;OpType:0;OpSubtype:0;time:0;AffectedAccount:0;SignerAccount:-1;n_operation:0;DestAccount:-1;SellerAccount:-1;newKey:(EC_OpenSSL_NID:0;x:'';y:'');OperationTxt:'';Amount:0;Fee:0;Balance:0;OriginalPayload:'';PrintablePayload:'';OperationHash:'';OperationHash_OLD:'';errors:'';isMultiOperation:False;Senders:Nil;Receivers:Nil;changers:Nil);
   CT_TOperationResume_NUL : TOperationResume = (valid:false;Block:0;NOpInsideBlock:-1;OpType:0;OpSubtype:0;time:0;AffectedAccount:0;SignerAccount:-1;n_operation:0;DestAccount:-1;SellerAccount:-1;newKey:(EC_OpenSSL_NID:0;x:'';y:'');OperationTxt:'';Amount:0;Fee:0;Balance:0;OriginalPayload:'';PrintablePayload:'';OperationHash:'';OperationHash_OLD:'';errors:'';isMultiOperation:False;Senders:Nil;Receivers:Nil;changers:Nil);
   CT_TMultiOpSender_NUL : TMultiOpSender =  (Account:0;Amount:0;N_Operation:0;Payload:'';Signature:(r:'';s:''));
   CT_TMultiOpSender_NUL : TMultiOpSender =  (Account:0;Amount:0;N_Operation:0;Payload:'';Signature:(r:'';s:''));
   CT_TMultiOpReceiver_NUL : TMultiOpReceiver = (Account:0;Amount:0;Payload:'');
   CT_TMultiOpReceiver_NUL : TMultiOpReceiver = (Account:0;Amount:0;Payload:'');
-  CT_TMultiOpChangeInfo_NUL : TMultiOpChangeInfo = (Account:0;N_Operation:0;Changes_type:[];New_Accountkey:(EC_OpenSSL_NID:0;x:'';y:'');New_Name:'';New_Type:0;Fee:0;Signature:(r:'';s:''));
-  CT_TOpChangeAccountInfoType_Txt : Array[Low(TOpChangeAccountInfoType)..High(TOpChangeAccountInfoType)] of AnsiString = ('public_key','account_name','account_type');
+  CT_TMultiOpChangeInfo_NUL : TMultiOpChangeInfo = (Account:0;N_Operation:0;Changes_type:[];New_Accountkey:(EC_OpenSSL_NID:0;x:'';y:'');New_Name:'';New_Type:0;Seller_Account:-1;Account_Price:-1;Locked_Until_Block:0;Fee:0;Signature:(r:'';s:''));
+  CT_TOpChangeAccountInfoType_Txt : Array[Low(TOpChangeAccountInfoType)..High(TOpChangeAccountInfoType)] of AnsiString = ('public_key','account_name','account_type','list_for_public_sale','list_for_private_sale','delist');
 
 
 implementation
 implementation
 
 

+ 41 - 5
src/core/UOpTransaction.pas

@@ -977,11 +977,31 @@ begin
   OperationResume.Senders[0].N_Operation:=FData.n_operation;
   OperationResume.Senders[0].N_Operation:=FData.n_operation;
   OperationResume.Senders[0].Payload:=FData.payload;
   OperationResume.Senders[0].Payload:=FData.payload;
   OperationResume.Senders[0].Signature:=FData.sign;
   OperationResume.Senders[0].Signature:=FData.sign;
-  SetLength(OperationResume.Receivers,1);
-  OperationResume.Receivers[0] := CT_TMultiOpReceiver_NUL;
-  OperationResume.Receivers[0].Account:=FData.target;
-  OperationResume.Receivers[0].Amount:=FData.amount;
-  OperationResume.Receivers[0].Payload:=FData.payload;
+  case FData.opTransactionStyle of
+    transaction : begin
+      SetLength(OperationResume.Receivers,1);
+      OperationResume.Receivers[0] := CT_TMultiOpReceiver_NUL;
+      OperationResume.Receivers[0].Account:=FData.target;
+      OperationResume.Receivers[0].Amount:=FData.amount;
+      OperationResume.Receivers[0].Payload:=FData.payload;
+    end;
+    buy_account,transaction_with_auto_buy_account : begin
+      SetLength(OperationResume.Receivers,2);
+      OperationResume.Receivers[0] := CT_TMultiOpReceiver_NUL;
+      OperationResume.Receivers[0].Account:=FData.target;
+      OperationResume.Receivers[0].Amount:= (FData.amount - FData.AccountPrice);
+      OperationResume.Receivers[0].Payload:=FData.payload;
+      OperationResume.Receivers[1] := CT_TMultiOpReceiver_NUL;
+      OperationResume.Receivers[1].Account:=FData.SellerAccount;
+      OperationResume.Receivers[1].Amount:= FData.AccountPrice;
+      OperationResume.Receivers[1].Payload:=FData.payload;
+      SetLength(OperationResume.Changers,1);
+      OperationResume.Changers[0] := CT_TMultiOpChangeInfo_NUL;
+      OperationResume.Changers[0].Account := FData.target;
+      OperationResume.Changers[0].Changes_type := [public_key];
+      OperationResume.Changers[0].New_Accountkey := FData.new_accountkey;
+    end;
+  end;
 end;
 end;
 
 
 function TOpTransaction.OperationAmount: Int64;
 function TOpTransaction.OperationAmount: Int64;
@@ -1804,6 +1824,22 @@ begin
   SetLength(OperationResume.Changers,1);
   SetLength(OperationResume.Changers,1);
   OperationResume.Changers[0] := CT_TMultiOpChangeInfo_NUL;
   OperationResume.Changers[0] := CT_TMultiOpChangeInfo_NUL;
   OperationResume.Changers[0].Account:=FData.account_target;
   OperationResume.Changers[0].Account:=FData.account_target;
+  case FData.operation_type of
+    lat_ListForSale : begin
+        if (FData.new_public_key.EC_OpenSSL_NID=CT_TECDSA_Public_Nul.EC_OpenSSL_NID) then begin
+          OperationResume.Changers[0].Changes_type:=[list_for_public_sale];
+        end else begin
+          OperationResume.Changers[0].Changes_type:=[list_for_private_sale];
+          OperationResume.Changers[0].New_Accountkey := FData.new_public_key;
+          OperationResume.Changers[0].Locked_Until_Block := FData.locked_until_block;
+        end;
+        OperationResume.Changers[0].Seller_Account:=FData.account_to_pay;
+        OperationResume.Changers[0].Account_Price:=FData.account_price;
+      end;
+    lat_DelistAccount : begin
+        OperationResume.Changers[0].Changes_type:=[delist];
+      end;
+  end;
   if (FData.account_signer = FData.account_target) then begin
   if (FData.account_signer = FData.account_target) then begin
     OperationResume.Changers[0].Fee:=FData.fee;
     OperationResume.Changers[0].Fee:=FData.fee;
     OperationResume.Changers[0].N_Operation:=FData.n_operation;
     OperationResume.Changers[0].N_Operation:=FData.n_operation;

+ 13 - 4
src/core/URPC.pas

@@ -189,14 +189,14 @@ Begin
   If (Not OPR.isMultiOperation) then Begin
   If (Not OPR.isMultiOperation) then 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;
+    if (OPR.n_operation>0) then jsonObject.GetAsVariant('n_operation').Value:=OPR.n_operation;
   end;
   end;
   // New V3: Will include senders[], receivers[] and changers[]
   // 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);
       auxObj.GetAsVariant('account').Value := OPR.Senders[i].Account;
       auxObj.GetAsVariant('account').Value := OPR.Senders[i].Account;
-      auxObj.GetAsVariant('n_operation').Value := OPR.Senders[i].N_Operation;
+      if (OPR.Senders[i].N_Operation>0) then auxObj.GetAsVariant('n_operation').Value := OPR.Senders[i].N_Operation;
       auxObj.GetAsVariant('amount').Value := ToJSONCurrency(OPR.Senders[i].Amount * (-1));
       auxObj.GetAsVariant('amount').Value := ToJSONCurrency(OPR.Senders[i].Amount * (-1));
       auxObj.GetAsVariant('payload').Value := TCrypto.ToHexaString(OPR.Senders[i].Payload);
       auxObj.GetAsVariant('payload').Value := TCrypto.ToHexaString(OPR.Senders[i].Payload);
     end;
     end;
@@ -212,8 +212,8 @@ Begin
     for i:=Low(OPR.Changers) to High(OPR.Changers) do begin
     for i:=Low(OPR.Changers) to High(OPR.Changers) do begin
       auxObj := jsonArr.GetAsObject(jsonArr.Count);
       auxObj := jsonArr.GetAsObject(jsonArr.Count);
       auxObj.GetAsVariant('account').Value := OPR.Changers[i].Account;
       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
+      if (OPR.Changers[i].N_Operation>0) then 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));
         auxObj.GetAsVariant('new_enc_pubkey').Value := TCrypto.ToHexaString(TAccountComp.AccountKey2RawString(OPR.Changers[i].New_Accountkey));
       end;
       end;
       If account_name in OPR.Changers[i].Changes_type then begin
       If account_name in OPR.Changers[i].Changes_type then begin
@@ -222,6 +222,15 @@ 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 (list_for_public_sale in OPR.Changers[i].Changes_type)
+        Or (list_for_private_sale in OPR.Changers[i].Changes_type) then begin
+        auxObj.GetAsVariant('seller_account').Value := OPR.Changers[i].Seller_Account;
+        auxObj.GetAsVariant('account_price').Value := ToJSONCurrency(OPR.Changers[i].Account_Price);
+      end;
+      if (list_for_private_sale in OPR.Changers[i].Changes_type) then begin
+        auxObj.GetAsVariant('locked_until_block').Value := OPR.Changers[i].Locked_Until_Block;
+        auxObj.GetAsVariant('new_enc_pubkey').Value := TCrypto.ToHexaString(TAccountComp.AccountKey2RawString(OPR.Changers[i].New_Accountkey));
+      end;
       if (OPR.Changers[i].Fee<>0) then begin
       if (OPR.Changers[i].Fee<>0) then begin
         auxObj.GetAsVariant('fee').Value := ToJSONCurrency(OPR.Changers[i].Fee * (-1));
         auxObj.GetAsVariant('fee').Value := ToJSONCurrency(OPR.Changers[i].Fee * (-1));
       end;
       end;