Author Topic: Importing Balances  (Read 858 times)

0 Members and 1 Guest are viewing this topic.

Offline barwizi

  • Hero Member
  • *****
  • Posts: 764
  • Noirbits, NoirShares, NoirEx.....lol, noir anyone?
    • View Profile
    • Noirbitstalk.org
Importing Balances
« on: February 14, 2014, 12:16:22 pm »
 am trying to import protoshares balances into a chain. I found the following pieces of code:-


Quote
std::map<std::string,int64> getGenesisBalances(){
   std::map<std::string,int64> genesisBalances;
   // ProtoShares balances, these will only be included if i get the method right
   ifstream myfile ("genesisbalances.txt");
   char * pEnd;
   std::string line;
   if (myfile.is_open()){
      while ( myfile.good() ){
         getline (myfile,line);
         std::vector<std::string> strs;
         boost::split(strs, line, boost::is_any_of(","));
         genesisBalances[strs[0]]=strtoll(strs[1].c_str(),&pEnd,10);
      }
      myfile.close();
   }   
   return genesisBalances;
}


then

Quote
if(pindexBest->nHeight+1==1){
   //Block 1 - add balances for beta testers, protoshares
       std::map<std::string,int64> genesisBalances= getGenesisBalances();
   std::map<std::string,int64>::iterator balit;
   int i=1;
   int64 total=0;
   txNew.vout.resize(genesisBalances.size()+1);
   for(balit=genesisBalances.begin(); balit!=genesisBalances.end(); ++balit){
      //printf("gb:%s,%llu",balit->first.c_str(),balit->second);
      CBitcoinAddress address(balit->first);
      txNew.vout.scriptPubKey.SetDestination( address.Get() );
      txNew.vout.nValue = balit->second;
      total=total+balit->second;
      i++;
   }
   printf("Total ...%llu\n",total); 
   }

now i am trying to figure out the structure of the genesisbalances.txt required


is it meant to be like this

Quote
PZjWgGZQWdk5VHA18d6XE9JX7nbZESY7EV,13999.99500000
PgBqNfhXY6DAWRFKiao3E5ADsnYiQ83wGt,10999.00000000
PgsuLoe9ojRKFGJGVpqqk37gAqNJ4ozboD,10000.00000000
Piev8TMX2fT5mFtgxx2TXJaqXP37weMPuD,10000.00000000
PmrBYp4PzMYaixdaxQeQLEdXXtCVJsb7HQ,9996.93350272
PiR3em7nkSfBCZSALUrVKK7oVHxWXBJekZ,9847.88858195
PeTDLjj1mvH8dHNDrbpf2JegGhHetMdHqH,9823.25546630
PtLiyRBHaxpqNGvRd6m2tVsru6PjCGQca7,8200.00000000
PdSu1KoF7izeTWZmKV9jnKNfpwy3vByT5M,7674.80000000
Payg36hEzjSZxvnnF47sYoUUx4cUjVEs2H,7570.54421844

or with commas at the end like this :-

Quote
PZjWgGZQWdk5VHA18d6XE9JX7nbZESY7EV,13999.99500000,
PgBqNfhXY6DAWRFKiao3E5ADsnYiQ83wGt,10999.00000000,
PgsuLoe9ojRKFGJGVpqqk37gAqNJ4ozboD,10000.00000000,
Piev8TMX2fT5mFtgxx2TXJaqXP37weMPuD,10000.00000000,
PmrBYp4PzMYaixdaxQeQLEdXXtCVJsb7HQ,9996.93350272,
PiR3em7nkSfBCZSALUrVKK7oVHxWXBJekZ,9847.88858195,
PeTDLjj1mvH8dHNDrbpf2JegGhHetMdHqH,9823.25546630,
PtLiyRBHaxpqNGvRd6m2tVsru6PjCGQca7,8200.00000000,
PdSu1KoF7izeTWZmKV9jnKNfpwy3vByT5M,7674.80000000,
Payg36hEzjSZxvnnF47sYoUUx4cUjVEs2H,7570.54421844,

or like this, with no new lines at the end?

Quote
PZjWgGZQWdk5VHA18d6XE9JX7nbZESY7EV,13999.99500000,PgBqNfhXY6DAWRFKiao3E5ADsnYiQ83wGt,10999.00000000,PgsuLoe9ojRKFGJGVpqqk37gAqNJ4ozboD,10000.00000000,Piev8TMX2fT5mFtgxx2TXJaqXP37weMPuD,10000.00000000,PmrBYp4PzMYaixdaxQeQLEdXXtCVJsb7HQ,9996.93350272,PiR3em7nkSfBCZSALUrVKK7oVHxWXBJekZ,9847.88858195,PeTDLjj1mvH8dHNDrbpf2JegGhHetMdHqH,9823.25546630,PtLiyRBHaxpqNGvRd6m2tVsru6PjCGQca7,8200.00000000,PdSu1KoF7izeTWZmKV9jnKNfpwy3vByT5M,7674.80000000,Payg36hEzjSZxvnnF47sYoUUx4cUjVEs2H,7570.54421844,

« Last Edit: February 14, 2014, 02:26:53 pm by barwizi »
--Bar--  PiNEJGUv4AZVZkLuF6hV4xwbYTRp5etWWJ

The magical land of crypto, no freebies people.

Offline NewMine

  • Hero Member
  • *****
  • Posts: 551
    • View Profile
Re: Importing Balances
« Reply #1 on: February 19, 2014, 03:36:32 am »
Shouldn't FreeTrade know the answer to this?

Offline barwizi

  • Hero Member
  • *****
  • Posts: 764
  • Noirbits, NoirShares, NoirEx.....lol, noir anyone?
    • View Profile
    • Noirbitstalk.org
Re: Importing Balances
« Reply #2 on: February 19, 2014, 08:33:54 am »
Shouldn't FreeTrade know the answer to this?

i've sent him a PM, hopefully he'll assist
--Bar--  PiNEJGUv4AZVZkLuF6hV4xwbYTRp5etWWJ

The magical land of crypto, no freebies people.