<commit_before>/**
 * Broadcast updates to client when the model changes
 */

'use strict';

var Wallet = require('./../wallet/wallet.model');
var ripple = require('ripple-lib');

var Remote = ripple.Remote;
var remote = new Remote({
    // see the API Reference for available options
    servers: [ 'ws://localhost:6006' ]
});

remote.connect(function(err, res) {
     console.log('Remote connected');
    });

// TODO Move this
var ROOT_RIPPLE_ACCOUNT = {
  address : 'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh',
  secret  : 'masterpassphrase'
};

function create_wallet(callback) {
  // Wait for randomness to have been added.
  // The entropy of the random generator is increased
  // by random data received from a rippled
  remote.once('random', function(err, info) {
    var wallet = ripple.Wallet.generate();
    callback(wallet);
  }
}

function fund_wallet(ripple_address, amount) {
  var amount = amount || 60;

  // CS Funny story: if rippleD is not running the remote will have
  // status == "offline" and will return an error after a long timeout.
  // Also, it does not automatically connect
  remote.setSecret(ROOT_RIPPLE_ACCOUNT.address , ROOT_RIPPLE_ACCOUNT.secret);

  var options = { account: ROOT_RIPPLE_ACCOUNT.address,
                  destination: ripple_address,
                  amount : amount * 1000000
                };
  var transaction = remote.createTransaction('Payment', options);
  transaction.submit(function (err, res) {
      if (err) {
          console.log('Failed to make initial XRP transfer because: ' +
                        err.message);
      }
      if (res) {
        console.log('Successfully funded wallet ' + wallet.address +<commit_msg>missing );<commit_after>/**
 * Broadcast updates to client when the model changes
 */

'use strict';

var Wallet = require('./../wallet/wallet.model');
var ripple = require('ripple-lib');

var Remote = ripple.Remote;
var remote = new Remote({
    // see the API Reference for available options
    servers: [ 'ws://localhost:6006' ]
});

remote.connect(function(err, res) {
     console.log('Remote connected');
    });

// TODO Move this
var ROOT_RIPPLE_ACCOUNT = {
  address : 'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh',
  secret  : 'masterpassphrase'
};

function create_wallet(callback) {
  // Wait for randomness to have been added.
  // The entropy of the random generator is increased
  // by random data received from a rippled
  remote.once('random', function(err, info) {
    var wallet = ripple.Wallet.generate();
    callback(wallet);
  });
}

function fund_wallet(ripple_address, amount) {
  var amount = amount || 60;

  // CS Funny story: if rippleD is not running the remote will have
  // status == "offline" and will return an error after a long timeout.
  // Also, it does not automatically connect
  remote.setSecret(ROOT_RIPPLE_ACCOUNT.address , ROOT_RIPPLE_ACCOUNT.secret);

  var options = { account: ROOT_RIPPLE_ACCOUNT.address,
                  destination: ripple_address,
                  amount : amount * 1000000
                };
  var transaction = remote.createTransaction('Payment', options);
  transaction.submit(function (err, res) {
      if (err) {
          console.log('Failed to make initial XRP transfer because: ' +
                        err.message);
      }
      if (res) {
        console.log('Successfully funded wallet ' + wallet.address +
{'fraction_non_alphanumeric': 0.11147346575748592, 'fraction_numerical': 0.011858879335902758, 'mean_word_length': 3.007125890736342, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4732918', 'n_tokens_mistral': 1038, 'n_tokens_neox': 997, 'n_words': 295}