anchor.diff:    TRandomGenerateOperation = Class
     private
     public
  +    class function GetRandomOwnDestination(const operationsComp : TPCOperationsComp; const aWalletKeys : TWalletKeysExt; out nAccount : Cardinal) : Boolean;
       class function GetRandomSigner(const operationsComp : TPCOperationsComp; const aWalletKeys : TWalletKeysExt; out iKey : Integer; out nAccount : Cardinal) : Boolean;
  -    class function GenerateOpTransaction(current_protocol : Word; const operationsComp : TPCOperationsComp; const aWalletKeys : TWalletKeysExt) : Boolean;
  +    class function GenerateOpTransactions(current_protocol : Word; Maxtransaction : Integer; const operationsComp : TPCOperationsComp; const aWalletKeys : TWalletKeysExt) : Integer;
       class function GenerateOpMultiOperation(current_protocol : Word; const operationsComp : TPCOperationsComp; const aWalletKeys : TWalletKeysExt) : Boolean;
     end;
   
  
positive.code:         //
          Case Random(30) of
            0..20 : begin
              If TRandomGenerateOperation.GenerateOpTransaction(FSourceNode.Bank.SafeBox.CurrentProtocol,operationsComp,FSourceWalletKeys) then inc(FnOperationsCreated)
              else inc(FnOperationsCreatedFailed);
            end;
            21..25 : begin
              If TRandomGenerateOperation.GenerateOpMultiOperation(FSourceNode.Bank.SafeBox.CurrentProtocol,operationsComp,FSourceWalletKeys) then inc(FnOperationsCreated)
  
negative.code: 
  { TRandomGenerateOperation }
  
  class function TRandomGenerateOperation.GetRandomOwnDestination(const operationsComp: TPCOperationsComp; const aWalletKeys: TWalletKeysExt; out nAccount: Cardinal): Boolean;
  var
    nRounds : Integer;
    iKey, iNAcc : Integer;
  begin
    Result := False; nAccount:=0; nRounds := 0;
    if (aWalletKeys.AccountsKeyList.Count<=0) then Exit;
    iKey := Random( aWalletKeys.AccountsKeyList.Count );
    Repeat
      if (aWalletKeys.AccountsKeyList.AccountKeyList[iKey].Count>0) then begin
        // Destination;
        iNAcc := Random(aWalletKeys.AccountsKeyList.AccountKeyList[iKey].Count);
        nAccount := aWalletKeys.AccountsKeyList.AccountKeyList[iKey].Get( iNAcc );
        Result := True;
      end;
      if (iKey<aWalletKeys.AccountsKeyList.Count-1) then inc(iKey) else begin
        iKey:=0;
        inc(nRounds);
      end;
    until (Result) Or (nRounds>0);
  end;
  
  class function TRandomGenerateOperation.GetRandomSigner(const operationsComp: TPCOperationsComp; const aWalletKeys: TWalletKeysExt; out iKey: Integer; out nAccount: Cardinal): Boolean;
  var
    bRoundsIKey, bRoundsNAccount : Boolean;
    iInt : Integer;
  begin
    Result := False; iKey := -1; nAccount:=0;
    if (aWalletKeys.AccountsKeyList.Count<=0) then Exit;
    iKey := Random( aWalletKeys.AccountsKeyList.Count );
    bRoundsIKey := False;
    Repeat
      if (aWalletKeys.Key[iKey].HasPrivateKey) And (Assigned(aWalletKeys.Key[iKey].PrivateKey)) And (aWalletKeys.AccountsKeyList.AccountKeyList[iKey].Count>0) then begin
        // Sender:
        bRoundsNAccount := False;
        iInt := Random(aWalletKeys.AccountsKeyList.AccountKeyList[iKey].Count);
        Repeat
          nAccount := aWalletKeys.AccountsKeyList.AccountKeyList[iKey].Get( iInt );
          If Not TAccountComp.IsAccountBlockedByProtocol(nAccount,operationsComp.SafeBoxTransaction.FreezedSafeBox.BlocksCount) then begin
            if (operationsComp.OperationsHashTree.CountOperationsBySameSignerWithoutFee(nAccount)<=0) then begin
              Result := True;
              Exit;
            end;
          end;
          if (iInt < aWalletKeys.AccountsKeyList.AccountKeyList[iKey].Count-1) then inc(iInt)
          else begin
            iInt := 0;
            if bRoundsNAccount then Break
            else bRoundsNAccount:=True;
          end;
        until (Result);
      end;
      if (iKey<aWalletKeys.AccountsKeyList.Count-1) then inc(iKey) else begin
        iKey:=0;
        if bRoundsIKey then Break
        else bRoundsIKey:=True;
      end;
    until (Result);
  end;
  
  class function TRandomGenerateOperation.GenerateOpTransactions(current_protocol : Word; Maxtransaction : Integer; const operationsComp: TPCOperationsComp; const aWalletKeys: TWalletKeysExt): Integer;
  var nAccount, nAccountTarget : Cardinal;
    iKey, nRounds : Integer;
    opTx : TOpTransaction;
    senderAcc : TAccount;
    amount,fees : Int64;
    errors : AnsiString;
  begin
    Result := 0;
    If Not GetRandomSigner(operationsComp,aWalletKeys,iKey,nAccount) then Exit;
    if Not GetRandomOwnDestination(operationsComp,aWalletKeys,nAccountTarget) then Exit;
    if (nAccount = nAccountTarget) then Exit;
    nRounds := 0;
    while (nRounds<Maxtransaction) do begin
      senderAcc := operationsComp.SafeBoxTransaction.Account(nAccount);
      amount := 1; // Minimal amount
      if (Random(500)<1) then fees := 0
      else fees := 1; // Minimal fee
      if (senderAcc.balance>2) then begin
        opTx := TOpTransaction.CreateTransaction(current_protocol,senderAcc.account,senderAcc.n_operation+1,nAccountTarget,aWalletKeys.Key[iKey].PrivateKey,amount,fees,'');
        Try
          if operationsComp.AddOperation(True,opTx,errors) then inc(Result);
        finally
          opTx.Free;
        end;
      end;
  
      inc(nRounds);
    end;
  end;
  
  