rpc: prioritisetransaction.
This commit is contained in:
parent
a0d109f52d
commit
e59fe9bf6d
@ -1550,7 +1550,57 @@ RPC.prototype.getnetworkhashps = function getnetworkhashps(args, callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
RPC.prototype.prioritisetransaction = function prioritisetransaction(args, callback) {
|
RPC.prototype.prioritisetransaction = function prioritisetransaction(args, callback) {
|
||||||
callback(new RPCError('Not implemented.'));
|
var self = this;
|
||||||
|
var hash, pri, fee;
|
||||||
|
|
||||||
|
if (args.help || args.length !== 3) {
|
||||||
|
return callback(new RPCError('prioritisetransaction'
|
||||||
|
+ ' <txid> <priority delta> <fee delta>'));
|
||||||
|
}
|
||||||
|
|
||||||
|
hash = args[0];
|
||||||
|
pri = args[1];
|
||||||
|
fee = args[2];
|
||||||
|
|
||||||
|
if (!utils.isHex(hash) || hash.length !== 64)
|
||||||
|
return callback(new RPCError('Invalid parameter'));
|
||||||
|
|
||||||
|
if (!utils.isNumber(pri) || !utils.isNumber(fee))
|
||||||
|
return callback(new RPCError('Invalid parameter'));
|
||||||
|
|
||||||
|
hash = utils.revHex(hash);
|
||||||
|
|
||||||
|
this.mempool.getEntry(hash, function(err, entry) {
|
||||||
|
if (err)
|
||||||
|
return callback(err);
|
||||||
|
|
||||||
|
if (!entry)
|
||||||
|
return callback(new RPCError('Transaction not in mempool.'));
|
||||||
|
|
||||||
|
entry.priority += pri;
|
||||||
|
entry.fees += fee;
|
||||||
|
|
||||||
|
if (entry.priority < 0)
|
||||||
|
entry.priority = 0;
|
||||||
|
|
||||||
|
if (entry.fees < 0)
|
||||||
|
entry.fees = 0;
|
||||||
|
|
||||||
|
this.mempool.fillAllCoins(entry.tx, function(err) {
|
||||||
|
if (err)
|
||||||
|
return callback(err);
|
||||||
|
|
||||||
|
if (!entry.tx.hasCoins())
|
||||||
|
return callback(new RPCError('Transaction not in mempool.'));
|
||||||
|
|
||||||
|
self.mempool.addUnchecked(entry, function(err) {
|
||||||
|
if (err)
|
||||||
|
return callback(err);
|
||||||
|
|
||||||
|
callback(null, true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
RPC.prototype.submitblock = function submitblock(args, callback) {
|
RPC.prototype.submitblock = function submitblock(args, callback) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user