Browse Source

parse client version

activeAddress
Ivan Socolsky 10 years ago
parent
commit
df5fdb1f75
  1. 32
      lib/server.js

32
lib/server.js

@ -512,8 +512,38 @@ WalletService.prototype.addAccess = function(opts, cb) {
});
};
WalletService.prototype._parseClientVersion = function() {
function parse(version) {
var v = {};
if (!version) return null;
var x = version.split('-');
if (x.length != 2) {
v.agent = version;
return v;
}
v.agent = _.contains(['bwc', 'bws'], x[0]) ? 'bwc' : x[0];
x = x[1].split('.');
v.major = parseInt(x[0]);
v.minor = parseInt(x[1]);
v.patch = parseInt(x[2]);
return v;
};
if (_.isUndefined(this.parsedClientVersion)) {
this.parsedClientVersion = parse(this.clientVersion);
}
return this.parsedClientVersion;
};
WalletService.prototype._clientSupportsBIP44 = function() {
return !!this.clientVersion && !(/^bw.-0\.[01]\./.test(this.clientVersion));
var version = this._parseClientVersion();
if (!version) return false;
if (version.agent != 'bwc') return true; // Asume 3rd party clients are up-to-date
if (version.major == 0 && version.minor <= 1) return false;
return true;
};
/**

Loading…
Cancel
Save