rpc: sort txs and coins.
This commit is contained in:
parent
80aa8f8c4c
commit
80b6968318
@ -2381,7 +2381,7 @@ RPC.prototype._createRedeem = co(function* _createRedeem(args) {
|
|||||||
if (!hash)
|
if (!hash)
|
||||||
throw new RPCError('Invalid key.');
|
throw new RPCError('Invalid key.');
|
||||||
|
|
||||||
ring = yield this.node.wallet.getKey(hash);
|
ring = yield this.wallet.getKey(hash);
|
||||||
|
|
||||||
if (!ring)
|
if (!ring)
|
||||||
throw new RPCError('Invalid key.');
|
throw new RPCError('Invalid key.');
|
||||||
@ -2468,14 +2468,14 @@ RPC.prototype.validateaddress = co(function* validateaddress(args) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
path = yield this.wallet.getPath(address.getHash('hex'));
|
path = yield this.wallet.getPath(address);
|
||||||
|
|
||||||
json = {
|
json = {
|
||||||
isvalid: true,
|
isvalid: true,
|
||||||
address: address.toBase58(this.network),
|
address: address.toBase58(this.network),
|
||||||
scriptPubKey: address.toScript().toJSON(),
|
scriptPubKey: address.toScript().toJSON(),
|
||||||
ismine: path ? true : false,
|
ismine: path ? true : false,
|
||||||
iswatchonly: false
|
iswatchonly: path ? this.wallet.watchOnly : false
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!path)
|
if (!path)
|
||||||
@ -3408,7 +3408,7 @@ RPC.prototype._listReceived = co(function* _listReceived(minconf, empty, account
|
|||||||
for (i = 0; i < paths.length; i++) {
|
for (i = 0; i < paths.length; i++) {
|
||||||
path = paths[i];
|
path = paths[i];
|
||||||
map[path.hash] = {
|
map[path.hash] = {
|
||||||
involvesWatchonly: false,
|
involvesWatchonly: this.wallet.watchOnly,
|
||||||
address: path.toAddress().toBase58(this.network),
|
address: path.toAddress().toBase58(this.network),
|
||||||
account: path.name,
|
account: path.name,
|
||||||
amount: 0,
|
amount: 0,
|
||||||
@ -3646,6 +3646,8 @@ RPC.prototype.listtransactions = co(function* listtransactions(args) {
|
|||||||
|
|
||||||
txs = yield this.wallet.getHistory();
|
txs = yield this.wallet.getHistory();
|
||||||
|
|
||||||
|
sortTX(txs);
|
||||||
|
|
||||||
for (i = 0; i < txs.length; i++) {
|
for (i = 0; i < txs.length; i++) {
|
||||||
tx = txs[i];
|
tx = txs[i];
|
||||||
json = yield this._toListTX(tx);
|
json = yield this._toListTX(tx);
|
||||||
@ -3693,6 +3695,8 @@ RPC.prototype.listunspent = co(function* listunspent(args) {
|
|||||||
|
|
||||||
coins = yield this.wallet.getCoins();
|
coins = yield this.wallet.getCoins();
|
||||||
|
|
||||||
|
sortCoins(coins);
|
||||||
|
|
||||||
for (i = 0; i < coins.length; i++ ) {
|
for (i = 0; i < coins.length; i++ ) {
|
||||||
coin = coins[i];
|
coin = coins[i];
|
||||||
|
|
||||||
@ -4185,6 +4189,20 @@ function readFile(file, enc) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sortTX(txs) {
|
||||||
|
return txs.sort(function(a, b) {
|
||||||
|
return a.ps - b.ps;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function sortCoins(coins) {
|
||||||
|
return coins.sort(function(a, b) {
|
||||||
|
a = a.height === -1 ? 0x7fffffff : a.height;
|
||||||
|
b = b.height === -1 ? 0x7fffffff : b.height;
|
||||||
|
return a - b;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Expose
|
* Expose
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user