@@ -63,15 +63,19 @@ class GetReceiveAmountUseCase(
6363 }
6464 }
6565
66- val quote = getQuoteUseCase(
67- session = session,
68- from = flowOf(SwapAsset .Lightning ),
69- to = flowOf(accountAsset.toSwapAsset()),
70- satoshi = balance.map {
71- it?.satoshi ? : 0
72- },
73- quoteMode = flowOf(QuoteMode .SEND )
74- )
66+ val quote = if (accountAsset.account.isLightning) {
67+ flowOf(null )
68+ } else {
69+ getQuoteUseCase(
70+ session = session,
71+ from = flowOf(SwapAsset .Lightning ),
72+ to = flowOf(accountAsset.toSwapAsset()),
73+ satoshi = balance.map {
74+ it?.satoshi ? : 0
75+ },
76+ quoteMode = flowOf(QuoteMode .SEND )
77+ )
78+ }
7579
7680 return combine(
7781 amount,
@@ -138,9 +142,11 @@ class GetReceiveAmountUseCase(
138142 }
139143 }
140144
145+ val minOpenChannel = 25000L
146+
141147 // Use as a workaround for newly created wallets (nodeInfo.maxReceivableSatoshi() == 0L && balance.satoshi >= 5000)
142148 val isValid =
143- balance != null && error == null && (balance.satoshi >= 0 && (balance.satoshi <= nodeInfo.maxReceivableSatoshi() || (nodeInfo.maxReceivableSatoshi() == 0L && balance.satoshi >= 5000 )) && (balance.satoshi <= totalInboundLiquiditySatoshi || (balance.satoshi > (openChannelFee?.feeSatoshi()
149+ balance != null && error == null && (balance.satoshi >= 0 && (balance.satoshi <= nodeInfo.maxReceivableSatoshi() || (nodeInfo.maxReceivableSatoshi() == 0L && balance.satoshi >= minOpenChannel )) && (balance.satoshi <= totalInboundLiquiditySatoshi || (balance.satoshi > (openChannelFee?.feeSatoshi()
144150 ? : 0 ))))
145151
146152 val hint = nodeInfo.maxReceivableSatoshi().toAmountLook(
@@ -196,6 +202,17 @@ class GetReceiveAmountUseCase(
196202 " id_a_funding_fee_of_s_s_is_applied|$channelFee |$channelFeeFiat |$inboundLiquidity |$inboundLiquidityFiat "
197203 }
198204
205+ nodeInfo.maxReceivableSatoshi() == 0L && balance != null && balance.satoshi < minOpenChannel -> {
206+ " id_amount_must_be_at_least_s|${
207+ minOpenChannel.toAmountLook(
208+ session = session,
209+ assetId = accountAsset.account.network.policyAsset,
210+ denomination = denomination.notFiat(),
211+ withUnit = true
212+ )
213+ } "
214+ }
215+
199216 else -> null
200217 }
201218
0 commit comments