Better error when fees are high

Stephen Paul Weber created

Change summary

lib/simple_swap.rb | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

Detailed changes

lib/simple_swap.rb 🔗

@@ -39,7 +39,7 @@ class SimpleSwap
 				fixed: false,
 				currency_from: currency,
 				currency_to: "btc",
-				amount: 10,
+				amount: currency == "xmr" ? 0.1 : 0.01,
 				address_to: target
 			}.to_json
 		).then(&method(:parse))
@@ -48,7 +48,11 @@ class SimpleSwap
 	def parse(req)
 		return req.response["address_from"] if req.response["address_from"]
 
-		raise req.response["message"] || "Error creating address"
+		if req.response["error"].to_s =~ /does not fall within the range/
+			raise "Network fees are too high, try again later."
+		end
+
+		raise req.response["message"] || req.response["error"] || "Error"
 	end
 
 	def req(m, path, query: {}, body: nil)