|
@@ -122,7 +122,7 @@ type
|
|
class function ExecuteChangeKey(const ASelectedAccounts: TArray<TAccount>; const ASignerAccount: TAccount; APublicKey: TAccountKey; AFee: int64; const APayloadEncryptionMode: TPayloadEncryptionMode; const APayloadContent, APayloadEncryptionPassword: string; var AErrorMessage: string): boolean; static;
|
|
class function ExecuteChangeKey(const ASelectedAccounts: TArray<TAccount>; const ASignerAccount: TAccount; APublicKey: TAccountKey; AFee: int64; const APayloadEncryptionMode: TPayloadEncryptionMode; const APayloadContent, APayloadEncryptionPassword: string; var AErrorMessage: string): boolean; static;
|
|
class function ExecuteEnlistAccountForSale(const ASelectedAccounts: TArray<TAccount>; const ASignerAccount, ASellerAccount: TAccount; const APublicKey: TAccountKey; AFee, ASalePrice: int64; ALockedUntilBlock: UInt32; const AAccountSaleMode: TAccountSaleMode; const APayloadEncryptionMode: TPayloadEncryptionMode; const APayloadContent, APayloadEncryptionPassword: string; var AErrorMessage: string): boolean; static;
|
|
class function ExecuteEnlistAccountForSale(const ASelectedAccounts: TArray<TAccount>; const ASignerAccount, ASellerAccount: TAccount; const APublicKey: TAccountKey; AFee, ASalePrice: int64; ALockedUntilBlock: UInt32; const AAccountSaleMode: TAccountSaleMode; const APayloadEncryptionMode: TPayloadEncryptionMode; const APayloadContent, APayloadEncryptionPassword: string; var AErrorMessage: string): boolean; static;
|
|
class function ExecuteDelistAccountFromSale(const ASelectedAccounts: TArray<TAccount>; const ASignerAccount: TAccount; AFee: int64; const APayloadEncryptionMode: TPayloadEncryptionMode; const APayloadContent, APayloadEncryptionPassword: string; var AErrorMessage: string): boolean; static;
|
|
class function ExecuteDelistAccountFromSale(const ASelectedAccounts: TArray<TAccount>; const ASignerAccount: TAccount; AFee: int64; const APayloadEncryptionMode: TPayloadEncryptionMode; const APayloadContent, APayloadEncryptionPassword: string; var AErrorMessage: string): boolean; static;
|
|
- class function ExecuteChangeAccountInfo(const ASelectedAccounts, ASignerAccounts: TArray<TAccount>; AFee: int64; const APayloadEncryptionMode: TPayloadEncryptionMode; const APayloadContent, APayloadEncryptionPassword: string; const ANewName: string; const ANewType: word; var AErrorMessage: string): boolean; static;
|
|
|
|
|
|
+ class function ExecuteChangeAccountInfo(const ASelectedAccounts, ASignerAccounts: TArray<TAccount>; AFee: int64; const APayloadEncryptionMode: TPayloadEncryptionMode; const APayloadContent, APayloadEncryptionPassword: string; const ANewName: TRawBytes; const ANewType: word; var AErrorMessage: string): boolean; static;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -546,9 +546,9 @@ end;
|
|
|
|
|
|
class function TAccountKeyComparer.DoCompare(constref ALeft, ARight: TAccountKey): integer;
|
|
class function TAccountKeyComparer.DoCompare(constref ALeft, ARight: TAccountKey): integer;
|
|
begin
|
|
begin
|
|
- Result := BinStrComp(ALeft.x, ARight.x);
|
|
|
|
|
|
+ Result := BytesCompare(ALeft.x, ARight.x);
|
|
if Result = 0 then
|
|
if Result = 0 then
|
|
- Result := BinStrComp(ALeft.y, ARight.y);
|
|
|
|
|
|
+ Result := BytesCompare(ALeft.y, ARight.y);
|
|
end;
|
|
end;
|
|
|
|
|
|
{ TAccountKeyEqualityComparer }
|
|
{ TAccountKeyEqualityComparer }
|
|
@@ -570,7 +570,7 @@ end;
|
|
|
|
|
|
class function TAccountKeyEqualityComparer.CalcHashCode(constref AValue: TAccountKey): UInt32;
|
|
class function TAccountKeyEqualityComparer.CalcHashCode(constref AValue: TAccountKey): UInt32;
|
|
begin
|
|
begin
|
|
- Result := TEqualityComparer<ansistring>.Default.GetHashCode(IntToStr(AValue.EC_OpenSSL_NID) + AValue.x + AValue.y);
|
|
|
|
|
|
+ Result := TEqualityComparer<ansistring>.Default.GetHashCode(IntToStr(AValue.EC_OpenSSL_NID) + AValue.x.ToString + AValue.y.ToString);
|
|
end;
|
|
end;
|
|
|
|
|
|
{ TAccountHelper }
|
|
{ TAccountHelper }
|
|
@@ -583,8 +583,8 @@ end;
|
|
function TAccountHelper.GetDisplayString: ansistring;
|
|
function TAccountHelper.GetDisplayString: ansistring;
|
|
begin
|
|
begin
|
|
Result := GetAccountString;
|
|
Result := GetAccountString;
|
|
- if Self.Name <> '' then
|
|
|
|
- Result := Result + ': ' + Self.Name;
|
|
|
|
|
|
+ if Self.Name <> Nil then
|
|
|
|
+ Result := Result + ': ' + Self.Name.ToString;
|
|
end;
|
|
end;
|
|
|
|
|
|
function TAccountHelper.GetInfoText(const ABank: TPCBank): utf8string;
|
|
function TAccountHelper.GetInfoText(const ABank: TPCBank): utf8string;
|
|
@@ -593,7 +593,7 @@ var
|
|
GC: TDisposables;
|
|
GC: TDisposables;
|
|
begin
|
|
begin
|
|
builder := GC.AddObject(TStringList.Create) as TStrings;
|
|
builder := GC.AddObject(TStringList.Create) as TStrings;
|
|
- builder.Append(Format('Account: %s %s Type:%d', [TAccountComp.AccountNumberToAccountTxtNumber(self.account), IIF(Self.Name <> '', 'Name: ' + Self.Name, ''), Self.account_type]));
|
|
|
|
|
|
+ builder.Append(Format('Account: %s %s Type:%d', [TAccountComp.AccountNumberToAccountTxtNumber(self.account), IIF(Self.Name <> Nil, 'Name: ' + Self.Name.ToString, ''), Self.account_type]));
|
|
builder.Append('');
|
|
builder.Append('');
|
|
builder.Append(Format('Current balance: %s', [TAccountComp.FormatMoney(Self.balance)]));
|
|
builder.Append(Format('Current balance: %s', [TAccountComp.FormatMoney(Self.balance)]));
|
|
builder.Append('');
|
|
builder.Append('');
|
|
@@ -650,9 +650,9 @@ begin
|
|
builder.Add(Format('%s', [Self.OperationTxt]));
|
|
builder.Add(Format('%s', [Self.OperationTxt]));
|
|
builder.Add(Format('OpType:%d Subtype:%d', [Self.OpType, Self.OpSubtype]));
|
|
builder.Add(Format('OpType:%d Subtype:%d', [Self.OpType, Self.OpSubtype]));
|
|
builder.Add(Format('Operation Hash (ophash): %s', [TCrypto.ToHexaString(Self.OperationHash)]));
|
|
builder.Add(Format('Operation Hash (ophash): %s', [TCrypto.ToHexaString(Self.OperationHash)]));
|
|
- if (Self.OperationHash_OLD <> '') then
|
|
|
|
|
|
+ if (Self.OperationHash_OLD <> Nil) then
|
|
builder.Add(Format('Old Operation Hash (old_ophash): %s', [TCrypto.ToHexaString(Self.OperationHash_OLD)]));
|
|
builder.Add(Format('Old Operation Hash (old_ophash): %s', [TCrypto.ToHexaString(Self.OperationHash_OLD)]));
|
|
- if (Self.OriginalPayload <> '') then
|
|
|
|
|
|
+ if (Self.OriginalPayload <> Nil) then
|
|
begin
|
|
begin
|
|
builder.Add(Format('Payload length:%d', [length(Self.OriginalPayload)]));
|
|
builder.Add(Format('Payload length:%d', [length(Self.OriginalPayload)]));
|
|
if Self.PrintablePayload <> '' then
|
|
if Self.PrintablePayload <> '' then
|
|
@@ -789,15 +789,15 @@ begin
|
|
pemEncryptWithSender:
|
|
pemEncryptWithSender:
|
|
begin
|
|
begin
|
|
// Use sender public key
|
|
// Use sender public key
|
|
- AEncodedPayloadBytes := ECIESEncrypt(ASenderPublicKey, APayloadContent);
|
|
|
|
- LValid := AEncodedPayloadBytes <> '';
|
|
|
|
|
|
+ AEncodedPayloadBytes := ECIESEncrypt(ASenderPublicKey, TEncoding.ANSI.GetBytes(APayloadContent));
|
|
|
|
+ LValid := AEncodedPayloadBytes <> Nil;
|
|
end;
|
|
end;
|
|
|
|
|
|
pemEncryptWithRecipient:
|
|
pemEncryptWithRecipient:
|
|
begin
|
|
begin
|
|
// With destination public key
|
|
// With destination public key
|
|
- AEncodedPayloadBytes := ECIESEncrypt(ADestinationPublicKey, APayloadContent);
|
|
|
|
- LValid := AEncodedPayloadBytes <> '';
|
|
|
|
|
|
+ AEncodedPayloadBytes := ECIESEncrypt(ADestinationPublicKey, TEncoding.ANSI.GetBytes(APayloadContent));
|
|
|
|
+ LValid := AEncodedPayloadBytes <> Nil;
|
|
end;
|
|
end;
|
|
|
|
|
|
pemEncryptWithPassword:
|
|
pemEncryptWithPassword:
|
|
@@ -809,14 +809,14 @@ begin
|
|
Exit(False);
|
|
Exit(False);
|
|
end;
|
|
end;
|
|
AEncodedPayloadBytes := TAESComp.EVP_Encrypt_AES256(
|
|
AEncodedPayloadBytes := TAESComp.EVP_Encrypt_AES256(
|
|
- APayloadContent, APayloadEncryptionPassword);
|
|
|
|
- LValid := AEncodedPayloadBytes <> '';
|
|
|
|
|
|
+ TEncoding.ANSI.GetBytes(APayloadContent), TEncoding.ANSI.GetBytes(APayloadEncryptionPassword));
|
|
|
|
+ LValid := AEncodedPayloadBytes <> Nil;
|
|
end;
|
|
end;
|
|
|
|
|
|
pemNotEncrypt:
|
|
pemNotEncrypt:
|
|
begin
|
|
begin
|
|
// no encryption
|
|
// no encryption
|
|
- AEncodedPayloadBytes := APayloadContent;
|
|
|
|
|
|
+ AEncodedPayloadBytes := TEncoding.ANSI.GetBytes(APayloadContent);
|
|
LValid := True;
|
|
LValid := True;
|
|
end
|
|
end
|
|
|
|
|
|
@@ -1391,7 +1391,7 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-class function TWIZOperationsHelper.ExecuteChangeAccountInfo(const ASelectedAccounts, ASignerAccounts: TArray<TAccount>; AFee: int64; const APayloadEncryptionMode: TPayloadEncryptionMode; const APayloadContent, APayloadEncryptionPassword: string; const ANewName: string; const ANewType: word; var AErrorMessage: string): boolean;
|
|
|
|
|
|
+class function TWIZOperationsHelper.ExecuteChangeAccountInfo(const ASelectedAccounts, ASignerAccounts: TArray<TAccount>; AFee: int64; const APayloadEncryptionMode: TPayloadEncryptionMode; const APayloadContent, APayloadEncryptionPassword: string; const ANewName: TRawBytes; const ANewType: word; var AErrorMessage: string): boolean;
|
|
var
|
|
var
|
|
LWalletKey: TWalletKey;
|
|
LWalletKey: TWalletKey;
|
|
LWalletKeys: TWalletKeys;
|
|
LWalletKeys: TWalletKeys;
|
|
@@ -1399,10 +1399,10 @@ var
|
|
LPCOperation: TPCOperation;
|
|
LPCOperation: TPCOperation;
|
|
LOperationsHashTree: TOperationsHashTree;
|
|
LOperationsHashTree: TOperationsHashTree;
|
|
LTotalSignerFee, LFee: int64;
|
|
LTotalSignerFee, LFee: int64;
|
|
- LOperationsTxt, LOperationToString, LTemp, LNewName: string;
|
|
|
|
|
|
+ LOperationsTxt, LOperationToString, LTemp: string;
|
|
LAccountIdx, LNoOfOperations, LAccNumberIndex: integer;
|
|
LAccountIdx, LNoOfOperations, LAccNumberIndex: integer;
|
|
LCurrentAccount, LSignerAccount: TAccount;
|
|
LCurrentAccount, LSignerAccount: TAccount;
|
|
- LPayloadEncodedBytes: TRawBytes;
|
|
|
|
|
|
+ LPayloadEncodedBytes, LNewName: TRawBytes;
|
|
LChangeType, LChangeName: boolean;
|
|
LChangeType, LChangeName: boolean;
|
|
begin
|
|
begin
|
|
|
|
|
|
@@ -1430,28 +1430,28 @@ begin
|
|
begin
|
|
begin
|
|
LSignerAccount := ASignerAccounts[0];
|
|
LSignerAccount := ASignerAccounts[0];
|
|
|
|
|
|
- LNewName := LowerCase(Trim(ANewName));
|
|
|
|
|
|
+ LNewName := ANewName;
|
|
|
|
|
|
- if LNewName <> LCurrentAccount.Name then
|
|
|
|
|
|
+ If not TBaseType.Equals(LNewName,LCurrentAccount.name) then
|
|
begin
|
|
begin
|
|
LChangeName := True;
|
|
LChangeName := True;
|
|
- if LNewName <> '' then
|
|
|
|
|
|
+ if LNewName <> Nil then
|
|
begin
|
|
begin
|
|
if (not TPCSafeBox.ValidAccountName(LNewName, AErrorMessage)) then
|
|
if (not TPCSafeBox.ValidAccountName(LNewName, AErrorMessage)) then
|
|
begin
|
|
begin
|
|
- AErrorMessage := Format('New name "%s" is not a valid name: %s ', [LNewName, AErrorMessage]);
|
|
|
|
|
|
+ AErrorMessage := Format('New name "%s" is not a valid name: %s ', [LNewName.ToPrintable, AErrorMessage]);
|
|
Exit(False);
|
|
Exit(False);
|
|
end;
|
|
end;
|
|
LAccNumberIndex := (TNode.Node.Bank.SafeBox.FindAccountByName(LNewName));
|
|
LAccNumberIndex := (TNode.Node.Bank.SafeBox.FindAccountByName(LNewName));
|
|
if (LAccNumberIndex >= 0) then
|
|
if (LAccNumberIndex >= 0) then
|
|
begin
|
|
begin
|
|
- AErrorMessage := Format('Name "%s" is used by account %s ', [LNewName, TAccountComp.AccountNumberToAccountTxtNumber(LAccNumberIndex)]);
|
|
|
|
|
|
+ AErrorMessage := Format('Name "%s" is used by account %s ', [LNewName.ToPrintable, TAccountComp.AccountNumberToAccountTxtNumber(LAccNumberIndex)]);
|
|
Exit(False);
|
|
Exit(False);
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
- if (LNewName = LCurrentAccount.Name) and (ANewType = LCurrentAccount.account_type) then
|
|
|
|
|
|
+ if (TBaseType.Equals(LNewName, LCurrentAccount.Name)) and (ANewType = LCurrentAccount.account_type) then
|
|
begin
|
|
begin
|
|
AErrorMessage := 'New account name and type are same as former.';
|
|
AErrorMessage := 'New account name and type are same as former.';
|
|
Exit(False);
|
|
Exit(False);
|
|
@@ -1511,11 +1511,11 @@ begin
|
|
try
|
|
try
|
|
if (LChangeName) and (LChangeType) then
|
|
if (LChangeName) and (LChangeType) then
|
|
begin
|
|
begin
|
|
- LTemp := Format('%d. Change Account %s Name and Type from [%s, %d] To [%s, %d] %s', [LNoOfOperations + 1, LCurrentAccount.DisplayString, LCurrentAccount.Name, LCurrentAccount.account_type, LNewName, ANewType, sLineBreak]);
|
|
|
|
|
|
+ LTemp := Format('%d. Change Account %s Name and Type from [%s, %d] To [%s, %d] %s', [LNoOfOperations + 1, LCurrentAccount.DisplayString, LCurrentAccount.Name.ToPrintable, LCurrentAccount.account_type, LNewName.ToPrintable, ANewType, sLineBreak]);
|
|
end
|
|
end
|
|
else if LChangeName then
|
|
else if LChangeName then
|
|
begin
|
|
begin
|
|
- LTemp := Format('%d. Change Account %s Name from [%s] To [%s] %s', [LNoOfOperations + 1, LCurrentAccount.DisplayString, LCurrentAccount.Name, LNewName, sLineBreak]);
|
|
|
|
|
|
+ LTemp := Format('%d. Change Account %s Name from [%s] To [%s] %s', [LNoOfOperations + 1, LCurrentAccount.DisplayString, LCurrentAccount.Name.ToPrintable, LNewName.ToPrintable, sLineBreak]);
|
|
end
|
|
end
|
|
else if LChangeType then
|
|
else if LChangeType then
|
|
begin
|
|
begin
|