From a0b7b38d30807a9cd529b9191c413584b1335c75 Mon Sep 17 00:00:00 2001 From: Adam Gibson Date: Wed, 16 Feb 2022 12:39:48 +0000 Subject: [PATCH] Return TransactionFailed when insufficient funds Fixes #1170. Prior to this commit, an attempt to spend using the direct-send endpoint in the RPC API would cause a backend crash because the NoFundsException was not being caught. This is now fixed. --- jmclient/jmclient/wallet_rpc.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jmclient/jmclient/wallet_rpc.py b/jmclient/jmclient/wallet_rpc.py index fd815c7..119c467 100644 --- a/jmclient/jmclient/wallet_rpc.py +++ b/jmclient/jmclient/wallet_rpc.py @@ -20,7 +20,7 @@ from jmclient import Taker, jm_single, \ create_wallet, get_max_cj_fee_values, \ StorageError, StoragePasswordError, JmwalletdWebSocketServerFactory, \ JmwalletdWebSocketServerProtocol, RetryableStorageError, \ - SegwitWalletFidelityBonds, wallet_gettimelockaddress + SegwitWalletFidelityBonds, wallet_gettimelockaddress, NotEnoughFundsException from jmbase.support import get_log, utxostr_to_utxo jlog = get_log() @@ -546,6 +546,8 @@ class JMWalletDaemon(Service): return_transaction=True, answeryes=True) except AssertionError: raise InvalidRequestFormat() + except NotEnoughFundsException as e: + raise TransactionFailed(repr(e)) if not tx: # this should not really happen; not a coinjoin # so tx should go through.