mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-12-06 17:27:59 +00:00
Set tx.finalized before changing state to validated/failed
This commit is contained in:
@@ -80,27 +80,25 @@ function Transaction(remote) {
|
|||||||
this.submittedIDs = [ ]
|
this.submittedIDs = [ ]
|
||||||
|
|
||||||
function finalize(message) {
|
function finalize(message) {
|
||||||
if (!self.finalized) {
|
if (self.result) {
|
||||||
self.finalized = true;
|
self.result.ledger_index = message.ledger_index;
|
||||||
|
self.result.ledger_hash = message.ledger_hash;
|
||||||
if (self.result) {
|
} else {
|
||||||
self.result.ledger_index = message.ledger_index;
|
self.result = message;
|
||||||
self.result.ledger_hash = message.ledger_hash;
|
self.result.tx_json = self.tx_json;
|
||||||
} else {
|
|
||||||
self.result = message;
|
|
||||||
self.result.tx_json = self.tx_json;
|
|
||||||
}
|
|
||||||
|
|
||||||
self.emit('cleanup', message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.emit('cleanup', message);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.once('success', function(message) {
|
this.once('success', function(message) {
|
||||||
|
self.finalized = true;
|
||||||
self.setState('validated');
|
self.setState('validated');
|
||||||
finalize(message);
|
finalize(message);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.once('error', function(message) {
|
this.once('error', function(message) {
|
||||||
|
self.finalized = true;
|
||||||
self.setState('failed');
|
self.setState('failed');
|
||||||
finalize(message);
|
finalize(message);
|
||||||
});
|
});
|
||||||
@@ -260,11 +258,8 @@ Transaction.prototype._getServer = function() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
Transaction.prototype.complete = function() {
|
Transaction.prototype.complete = function() {
|
||||||
// Try to auto-fill the secret
|
// If the Fee hasn't been set, one needs to be computed by
|
||||||
if (!this._secret && !(this._secret = this._account_secret(this.tx_json.Account))) {
|
// an assigned server
|
||||||
return this.emit('error', new RippleError('tejSecretUnknown', 'Missing secret'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.remote && typeof this.tx_json.Fee === 'undefined') {
|
if (this.remote && typeof this.tx_json.Fee === 'undefined') {
|
||||||
if (this.remote.local_fee || !this.remote.trusted) {
|
if (this.remote.local_fee || !this.remote.trusted) {
|
||||||
this._server = this._getServer();
|
this._server = this._getServer();
|
||||||
@@ -273,6 +268,11 @@ Transaction.prototype.complete = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (typeof this.tx_json.SigningPubKey === 'undefined') {
|
if (typeof this.tx_json.SigningPubKey === 'undefined') {
|
||||||
|
// Try to auto-fill the secret
|
||||||
|
if (!this._secret && !(this._secret = this._account_secret(this.tx_json.Account))) {
|
||||||
|
return this.emit('error', new RippleError('tejSecretUnknown', 'Missing secret'));
|
||||||
|
}
|
||||||
|
|
||||||
var seed = Seed.from_json(this._secret);
|
var seed = Seed.from_json(this._secret);
|
||||||
var key = seed.get_key(this.tx_json.Account);
|
var key = seed.get_key(this.tx_json.Account);
|
||||||
this.tx_json.SigningPubKey = key.to_hex_pub();
|
this.tx_json.SigningPubKey = key.to_hex_pub();
|
||||||
|
|||||||
Reference in New Issue
Block a user