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

This commit is contained in:
JoelKatz
2012-11-19 13:54:13 -08:00
4 changed files with 224 additions and 16 deletions

View File

@@ -353,6 +353,12 @@ Amount.prototype.issuer = function() {
return this._issuer;
};
Amount.prototype.to_number = function(allow_nan) {
var s = this.to_text(allow_nan);
return ('string' === typeof s) ? Number(s) : s;
}
// Convert only value to JSON wire format.
Amount.prototype.to_text = function(allow_nan) {
if (isNaN(this._value)) {

View File

@@ -806,13 +806,15 @@ Remote.prototype.ledger_accept = function () {
// Return a request to refresh the account balance.
Remote.prototype.request_account_balance = function (account, current) {
return (this.request_ledger_entry('account_root'))
var request = this.request_ledger_entry('account_root');
return request
.account_root(account)
.ledger_choose(current)
.on('success', function (message) {
// If the caller also waits for 'success', they might run before this.
request.emit('account_balance', message.node.Balance);
});
// If the caller also waits for 'success', they might run before this.
request.emit('account_balance', Amount.from_json(message.node.Balance));
});
};
// Return the next account sequence if possible.