From 780601b3b7b01a1c7c3d4efb1110e62ea8ac217d Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Wed, 10 Aug 2016 19:52:05 -0700 Subject: [PATCH] rpc: abandontransaction. --- lib/bcoin/http/rpc.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/bcoin/http/rpc.js b/lib/bcoin/http/rpc.js index eee09b8f..9a4d3e8e 100644 --- a/lib/bcoin/http/rpc.js +++ b/lib/bcoin/http/rpc.js @@ -2957,7 +2957,27 @@ RPC.prototype.gettransaction = function gettransaction(args, callback) { }; RPC.prototype.abandontransaction = function abandontransaction(args, callback) { - callback(new Error('Not implemented.')); + var hash; + + if (args.help || args.length !== 1) + return callback(new RPCError('abandontransaction "txid"')); + + hash = args[0]; + + if (!utils.isHex(hash) || hash.length !== 64) + return callback(new RPCError('Invalid parameter.')); + + hash = utils.revHex(hash); + + this.walletdb.tx.remove(hash, function(err, result) { + if (err) + return callback(err); + + if (!result) + return callback(new RPCError('Transaction not in wallet.')); + + callback(null, null); + }); }; RPC.prototype.getunconfirmedbalance = function getunconfirmedbalance(args, callback) {