@@ -203,49 +203,72 @@ class AppContext : Application(), DefaultLifecycleObserver {
203203 notifications.postValue(inAppNotifs)
204204
205205 // -- trampoline settings
206- val trampolineArray = json.getJSONObject(" trampoline" ).getJSONObject(" v2" ).getJSONArray(" attempts" )
207- val trampolineSettingsList = ArrayList <TrampolineFeeSetting >()
208- for (i in 0 until trampolineArray.length()) {
209- val setting: JSONObject = trampolineArray.get(i) as JSONObject
210- trampolineSettingsList + = TrampolineFeeSetting (
211- feeBase = Satoshi (setting.getLong(" fee_base_sat" )),
212- feeProportionalMillionths = setting.getLong(" fee_per_millionths" ),
213- cltvExpiry = CltvExpiryDelta (setting.getInt(" cltv_expiry" )))
206+ val remoteTrampolineSettings = try {
207+ val trampolineArray = json.getJSONObject(" trampoline" ).getJSONObject(" v2" ).getJSONArray(" attempts" )
208+ val trampolineSettingsList = ArrayList <TrampolineFeeSetting >()
209+ for (i in 0 until trampolineArray.length()) {
210+ val setting: JSONObject = trampolineArray.get(i) as JSONObject
211+ trampolineSettingsList + = TrampolineFeeSetting (
212+ feeBase = Satoshi (setting.getLong(" fee_base_sat" )),
213+ feeProportionalMillionths = setting.getLong(" fee_per_millionths" ),
214+ cltvExpiry = CltvExpiryDelta (setting.getInt(" cltv_expiry" )))
215+ }
216+ trampolineSettingsList.sortedWith(compareBy({ it.feeProportionalMillionths }, { it.feeBase }))
217+ trampolineSettingsList
218+ } catch (e: Exception ) {
219+ log.warn(" failed to read trampoline settings: " , e)
220+ Constants .DEFAULT_TRAMPOLINE_SETTINGS
214221 }
215- trampolineSettingsList.sortedWith(compareBy({ it.feeProportionalMillionths }, { it.feeBase }))
216- trampolineFeeSettings.postValue(trampolineSettingsList)
217- log.info(" trampoline settings=$trampolineSettingsList " )
222+ trampolineFeeSettings.postValue(remoteTrampolineSettings)
223+ log.info(" trampoline settings=$remoteTrampolineSettings " )
218224
219225 // -- swap-out settings
220- val remoteSwapOutSettings = json.getJSONObject(" swap_out" ).getJSONObject(" v1" ).run {
221- SwapOutSettings (
222- minFeerateSatByte = getLong(" min_feerate_sat_byte" ).coerceAtLeast(0 ),
223- status = ServiceStatus .valueOf(optInt(" status" ))
224- )
226+ val remoteSwapOutSettings = try {
227+ json.getJSONObject(" swap_out" ).getJSONObject(" v1" ).run {
228+ SwapOutSettings (
229+ minFeerateSatByte = getLong(" min_feerate_sat_byte" ).coerceAtLeast(0 ),
230+ minAmount = Satoshi (getLong(" min_amount_sat" )),
231+ maxAmount = Satoshi (getLong(" max_amount_sat" )),
232+ status = ServiceStatus .valueOf(optInt(" status" ))
233+ )
234+ }
235+ } catch (e: Exception ) {
236+ log.warn(" failed to read swap-out settings: " , e)
237+ Constants .DEFAULT_SWAP_OUT_SETTINGS
225238 }
226239 swapOutSettings.postValue(remoteSwapOutSettings)
227240 log.info(" swap-out settings=$remoteSwapOutSettings " )
228241
229242 // -- swap-in settings
230- val remoteSwapInSettings = json.getJSONObject(" swap_in" ).getJSONObject(" v1" ).run {
231- SwapInSettings (
232- minFunding = Satoshi (getLong(" min_funding_sat" ).coerceAtLeast(0 )),
233- minFee = Satoshi (getLong(" min_fee_sat" ).coerceAtLeast(0 )),
234- feePercent = getDouble(" fee_percent" ),
235- status = ServiceStatus .valueOf(optInt(" status" ))
236- )
243+ val remoteSwapInSettings = try {
244+ json.getJSONObject(" swap_in" ).getJSONObject(" v1" ).run {
245+ SwapInSettings (
246+ minFunding = Satoshi (getLong(" min_funding_sat" ).coerceAtLeast(0 )),
247+ minFee = Satoshi (getLong(" min_fee_sat" ).coerceAtLeast(0 )),
248+ feePercent = getDouble(" fee_percent" ),
249+ status = ServiceStatus .valueOf(optInt(" status" ))
250+ )
251+ }
252+ } catch (e: Exception ) {
253+ log.warn(" failed to read swap-in settings: " , e)
254+ null
237255 }
238256 swapInSettings.postValue(remoteSwapInSettings)
239257 log.info(" swap-in settings=$remoteSwapInSettings " )
240258
241259 // -- pay-to-open settings
242- val remotePayToOpenSettings = json.getJSONObject(" pay_to_open" ).getJSONObject(" v1" ).run {
243- PayToOpenSettings (
244- minFunding = Satoshi (getLong(" min_funding_sat" ).coerceAtLeast(0 )),
245- minFee = Satoshi (getLong(" min_fee_sat" ).coerceAtLeast(0 )),
246- feePercent = getDouble(" fee_percent" ),
247- status = ServiceStatus .valueOf(optInt(" status" ))
248- )
260+ val remotePayToOpenSettings = try {
261+ json.getJSONObject(" pay_to_open" ).getJSONObject(" v1" ).run {
262+ PayToOpenSettings (
263+ minFunding = Satoshi (getLong(" min_funding_sat" ).coerceAtLeast(0 )),
264+ minFee = Satoshi (getLong(" min_fee_sat" ).coerceAtLeast(0 )),
265+ feePercent = getDouble(" fee_percent" ),
266+ status = ServiceStatus .valueOf(optInt(" status" ))
267+ )
268+ }
269+ } catch (e: Exception ) {
270+ log.warn(" failed to read pay-to-open settings: " , e)
271+ null
249272 }
250273 payToOpenSettings.postValue(remotePayToOpenSettings)
251274 log.info(" pay-to-open settings=$remotePayToOpenSettings " )
@@ -352,7 +375,7 @@ data class TrampolineFeeSetting(val feeBase: Satoshi, val feeProportionalMillion
352375}
353376
354377data class SwapInSettings (val minFunding : Satoshi , val minFee : Satoshi , val feePercent : Double , val status : ServiceStatus )
355- data class SwapOutSettings (val minFeerateSatByte : Long , val status : ServiceStatus )
378+ data class SwapOutSettings (val minFeerateSatByte : Long , val minAmount : Satoshi , val maxAmount : Satoshi , val status : ServiceStatus )
356379data class MempoolContext (val highUsageWarning : Boolean )
357380data class PayToOpenSettings (val minFunding : Satoshi , val minFee : Satoshi , val feePercent : Double , val status : ServiceStatus )
358381data class Balance (val channelsCount : Int , val sendable : MilliSatoshi , val receivable : MilliSatoshi )
0 commit comments