rpc: better funding errors.

This commit is contained in:
Christopher Jeffrey 2017-03-15 06:55:00 -07:00
parent 1458366441
commit 66c4fd8a77
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
2 changed files with 4 additions and 5 deletions

View File

@ -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.');

View File

@ -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'),