From 66c4fd8a77a250afb774bcac5950f2dbd6b73a9c Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Wed, 15 Mar 2017 06:55:00 -0700 Subject: [PATCH] rpc: better funding errors. --- lib/http/rpcbase.js | 3 +++ lib/wallet/rpc.js | 6 +----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/http/rpcbase.js b/lib/http/rpcbase.js index f53f460d..6a9d4ff4 100644 --- a/lib/http/rpcbase.js +++ b/lib/http/rpcbase.js @@ -195,6 +195,9 @@ RPCBase.prototype.call = co(function* call(body, query) { case 'EncodingError': code = RPCBase.errors.DESERIALIZATION_ERROR; break; + case 'FundingError': + code = RPCBase.errors.WALLET_INSUFFICIENT_FUNDS; + break; default: code = RPCBase.errors.INTERNAL_ERROR; this.logger.error('RPC internal error.'); diff --git a/lib/wallet/rpc.js b/lib/wallet/rpc.js index 88e679f7..d07bc363 100644 --- a/lib/wallet/rpc.js +++ b/lib/wallet/rpc.js @@ -171,11 +171,7 @@ RPC.prototype.fundRawTransaction = co(function* fundRawTransaction(args, help) { changeAddress: change }; - try { - yield wallet.fund(tx, options); - } catch (e) { - throw new RPCError(errs.WALLET_INSUFFICIENT_FUNDS, e.message); - } + yield wallet.fund(tx, options); return { hex: tx.toRaw().toString('hex'),