Merge branch 'master' of github.com:jedmccaleb/NewCoin

This commit is contained in:
Arthur Britto
2012-12-03 20:01:31 -08:00
3 changed files with 27 additions and 9 deletions

View File

@@ -483,12 +483,19 @@ Amount.prototype.to_text = function(allow_nan) {
*
* @param opts Options for formatter.
* @param opts.precision {Number} Max. number of digits after decimal point.
* @param opts.group_sep {Boolean|String} Whether to show a separator every n
* digits, if a string, that value will be used as the separator. Default: ","
* @param opts.group_width {Number} How many numbers will be grouped together,
* default: 3.
* @param opts.signed {Boolean|String} Whether negative numbers will have a
* prefix. If String, that string will be used as the prefix. Default: "-"
*/
Amount.prototype.to_human = function (opts)
{
opts = opts || {};
// Default options
if ("undefined" === typeof opts.signed) opts.signed = true;
if ("undefined" === typeof opts.group_sep) opts.group_sep = true;
opts.group_width = opts.group_width || 3;
@@ -513,7 +520,12 @@ Amount.prototype.to_human = function (opts)
}
var formatted = '';
if (opts.signed && this._is_negative) formatted += "- ";
if (opts.signed && this._is_negative) {
if ("string" !== typeof opts.signed) {
opts.signed = '-';
}
formatted += opts.signed;
}
formatted += int_part.length ? int_part : '0';
formatted += fraction_part.length ? '.'+fraction_part : '';

View File

@@ -551,7 +551,7 @@ Remote.prototype.request_server_info = function () {
// XXX This is a bad command. Some varients don't scale.
// XXX Require the server to be trusted.
Remote.prototype.request_ledger = function (ledger, full) {
//assert(this.trusted);
//utils.assert(this.trusted);
var request = new Request(this, 'ledger');
@@ -566,7 +566,7 @@ Remote.prototype.request_ledger = function (ledger, full) {
// Only for unit testing.
Remote.prototype.request_ledger_hash = function () {
//assert(this.trusted); // If not trusted, need to check proof.
//utils.assert(this.trusted); // If not trusted, need to check proof.
return new Request(this, 'ledger_closed');
};
@@ -588,7 +588,7 @@ Remote.prototype.request_ledger_current = function () {
// .ledger_index()
// .offer_id()
Remote.prototype.request_ledger_entry = function (type) {
//assert(this.trusted); // If not trusted, need to check proof, maybe talk packet protocol.
//utils.assert(this.trusted); // If not trusted, need to check proof, maybe talk packet protocol.
var self = this;
var request = new Request(this, 'ledger_entry');
@@ -692,7 +692,7 @@ Remote.prototype.request_unsubscribe = function (streams) {
};
Remote.prototype.request_transaction_entry = function (hash) {
//assert(this.trusted); // If not trusted, need to check proof, maybe talk packet protocol.
//utils.assert(this.trusted); // If not trusted, need to check proof, maybe talk packet protocol.
return (new Request(this, 'transaction_entry'))
.tx_hash(hash);
@@ -700,7 +700,7 @@ Remote.prototype.request_transaction_entry = function (hash) {
Remote.prototype.request_ripple_lines_get = function (accountID, index) {
// XXX Does this require the server to be trusted?
//assert(this.trusted);
//utils.assert(this.trusted);
var request = new Request(this, 'ripple_lines_get');
@@ -713,7 +713,7 @@ Remote.prototype.request_ripple_lines_get = function (accountID, index) {
};
Remote.prototype.request_wallet_accounts = function (seed) {
assert(this.trusted); // Don't send secrets.
utils.assert(this.trusted); // Don't send secrets.
var request = new Request(this, 'wallet_accounts');
@@ -724,7 +724,7 @@ Remote.prototype.request_wallet_accounts = function (seed) {
Remote.prototype.request_account_tx = function (accountID, ledger_min, ledger_max) {
// XXX Does this require the server to be trusted?
//assert(this.trusted);
//utils.assert(this.trusted);
var request = new Request(this, 'account_tx');

View File

@@ -87,13 +87,19 @@ var logObject = function (msg, obj) {
console.log(msg, JSON.stringify(obj, undefined, 2));
};
var assert = function (assertion, msg) {
if (!assertion) {
throw new Error("Assertion failed" + (msg ? ": "+msg : "."));
}
};
exports.trace = trace;
exports.arraySet = arraySet;
exports.hexToString = hexToString;
exports.stringToArray = stringToArray;
exports.stringToHex = stringToHex;
exports.logObject = logObject;
exports.chunkString = chunkString;
exports.logObject = logObject;
exports.assert = assert;
// vim:sw=2:sts=2:ts=8:et