{"size": 411, "ext": "js", "max_stars_repo_path": "lib/frontend/hooks/before-withdrawals-check-for-wallet-lock.js", "max_stars_repo_name": "1Blackdiamondsc/safewallet", "max_stars_repo_stars_event_min_datetime": "2015-05-07T06:54:32.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-27T06:57:23.000Z", "max_issues_repo_path": "lib/frontend/hooks/before-withdrawals-check-for-wallet-lock.js", "max_issues_repo_name": "mmalecki/safewallet", "max_issues_repo_issues_event_min_datetime": "2015-02-23T13:56:44.000Z", "max_issues_repo_issues_event_max_datetime": "2017-04-20T06:48:25.000Z", "max_forks_repo_path": "lib/frontend/hooks/before-withdrawals-check-for-wallet-lock.js", "max_forks_repo_name": "mmalecki/safewallet", "max_forks_repo_forks_event_min_datetime": "2015-01-19T14:51:18.000Z", "max_forks_repo_forks_event_max_datetime": "2021-02-19T06:49:24.000Z"}
{"max_stars_count": 34, "max_issues_count": 3, "max_forks_count": 18, "avg_line_length": 24.1764705882, "max_line_length": 48, "alphanum_fraction": 0.5936739659}
var wallet = require('../../resources/wallet');

wallet.before('withdraw', function (data, next){
  // make sure wallet isnt locked
  wallet.get(data.id, function (err, _wallet){
    if (err) {
      return next(err);
    }
    // can't withdraw from a locked wallet
    if (_wallet.status === "locked") {
      return next(new Error('failure'));
    }
    data.id = _wallet.id;
    next(null, data);
  });
});
