<commit_before>package scorex

import api.ApiClient
import controller.Controller
import scorex.account.Account
import scorex.block.GenesisBlockParams
import scorex.crypto.Base58
import scorex.database.wallet.SecureWalletDatabase
import scorex.wallet.Wallet
import settings.Settings

import scala.io.StdIn
import scala.util.{Failure, Random, Try}

object Start {

  def main(args: Array[String]) {
    if (!args.contains("-cli")) {
      Try {
        if (args.size > 0) Settings.filename = args(0)
        Controller.init() //STARTING NETWORK/BLOCKCHAIN/RPC
        testingScript()
      } match {
        case Failure(e) =>
          e.printStackTrace()
          println("STARTUP ERROR: " + e.getMessage)
          System.exit(0) // force all threads shutdown
        case _ =>
      }
    } else {
      println("Welcome to the client...")
      Iterator.continually(StdIn.readLine()).takeWhile(!_.equals("quit")).foreach { command =>
        println(s"[$command RESULT] " + ApiClient.executeCommand(command))
      }
    }
  }


  def testingScript(): Unit = {
    Wallet.create(Base58.decode("FQgbSAm6swGbtqA3NE8PttijPhT4N3Ufh4bHFAkyVnQz"), "cookies", 10)
    //require(Wallet.unlock("cookies"))

    require(SecureWalletDatabase.exists())
    require(Wallet.privateKeyAccounts().nonEmpty)

    (1 to Int.MaxValue).foreach { _ =>
      val rndIdx = Random.nextInt(GenesisBlockParams.ipoMembers.size - 1)
      val senderAddress = GenesisBlockParams.ipoMembers(rndIdx)
      val recipientAddress = GenesisBlockParams.ipoMembers(rndIdx + 1)

      val senderAcc = Wallet.privateKeyAccount(senderAddress).get
      val recipientAcc = new Account(recipientAddress)

      val amt = new java.math.BigDecimal(Random.nextInt(100000))
      val fee = new java.math.BigDecimal(1 + Random.nextInt(5))

      val (tx, valRes) = Controller.sendPayment(senderAcc, recipientAcc, amt, fee)
      println(s"Payment created: $tx, validationResult: $valRes")<commit_msg>deleting random accs on start<commit_after>package scorex

import java.util.logging.Logger
import api.ApiClient
import controller.Controller
import scorex.account.Account
import scorex.block.GenesisBlockParams
import scorex.crypto.Base58
import scorex.database.wallet.SecureWalletDatabase
import scorex.wallet.Wallet
import settings.Settings

import scala.io.StdIn
import scala.util.{Failure, Random, Try}

object Start {

  def main(args: Array[String]) {
    if (!args.contains("-cli")) {
      Try {
        if (args.length > 0) Settings.filename = args(0)
        Controller.init() //STARTING NETWORK/BLOCKCHAIN/RPC
        testingScript()
      } match {
        case Failure(e) =>
          e.printStackTrace()
          println("STARTUP ERROR: " + e.getMessage)
          System.exit(0) // force all threads shutdown
        case _ =>
      }
    } else {
      println("Welcome to the client...")
      Iterator.continually(StdIn.readLine()).takeWhile(!_.equals("quit")).foreach { command =>
        println(s"[$command RESULT] " + ApiClient.executeCommand(command))
      }
    }
  }


  def testingScript(): Unit = {
    val NumOfAccounts = 10

    Random.setSeed(System.currentTimeMillis())

    Wallet.create(Base58.decode("FQgbSAm6swGbtqA3NE8PttijPhT4N3Ufh4bHFAkyVnQz"), "cookies", NumOfAccounts)
    Wallet.privateKeyAccounts().flatMap { acc =>
      if (Random.nextBoolean()) Some(acc) else None
    }.map(Wallet.deleteAccount)
    Logger.getGlobal.info("Executing testing scenario with accounts" +
      s"(${Wallet.privateKeyAccounts().size}) : "
      + Wallet.privateKeyAccounts().mkString(" "))

    //require(Wallet.unlock("cookies"))

    require(SecureWalletDatabase.exists())
    require(Wallet.privateKeyAccounts().nonEmpty)

    (1 to Int.MaxValue).foreach { _ =>
      val rndIdx = Random.nextInt(GenesisBlockParams.ipoMembers.size - 1)
      val senderAddress = GenesisBlockParams.ipoMembers(rndIdx)
      val recipientAddress = GenesisBlockParams.ipoMembers(rndIdx + 1)

      val senderAcc = Wallet.privateKeyAccount(senderAddress).get
      val recipientAcc = new Account(recipientAddress)

      val amt = new java.math.BigDecimal(Random.nextInt(100000))
      val fee = new java.math.BigDecimal(1 + Random.nextInt(5))

      val (tx, valRes) = Controller.sendPayment(senderAcc, recipientAcc, amt, fee)
      println(s"Payment created: $tx, validationResult: $valRes")
{'fraction_non_alphanumeric': 0.11865962818453064, 'fraction_numerical': 0.011934817535001148, 'mean_word_length': 3.516062176165803, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6244332', 'n_tokens_mistral': 1385, 'n_tokens_neox': 1337, 'n_words': 254}