@@ -1091,6 +1091,7 @@ class AppViewModel @Inject constructor(
10911091 )
10921092 return
10931093 }
1094+ val maxSendOnchain = walletRepo.balanceState.value.maxSendOnchainSats
10941095
10951096 val lnInvoice = extractViableLightningInvoice(invoice.params)
10961097 _sendUiState .update {
@@ -1099,7 +1100,7 @@ class AppViewModel @Inject constructor(
10991100 addressInput = scanResult,
11001101 isAddressInputValid = true ,
11011102 amount = invoice.amountSatoshis,
1102- isUnified = lnInvoice != null ,
1103+ isUnified = lnInvoice != null && invoice.amountSatoshis <= maxSendOnchain && maxSendOnchain > 0u ,
11031104 decodedInvoice = lnInvoice,
11041105 payMethod = lnInvoice?.let { SendMethod .LIGHTNING } ? : SendMethod .ONCHAIN ,
11051106 )
@@ -1125,8 +1126,7 @@ class AppViewModel @Inject constructor(
11251126 }
11261127
11271128 // Check on-chain balance before proceeding to amount screen
1128- val maxSendOnchain = walletRepo.balanceState.value.maxSendOnchainSats
1129- if (maxSendOnchain == 0uL ) {
1129+ if (maxSendOnchain == 0uL && _sendUiState .value.payMethod == SendMethod .ONCHAIN ) {
11301130 toast(
11311131 type = Toast .ToastType .ERROR ,
11321132 title = context.getString(R .string.other__pay_insufficient_savings),
@@ -1137,7 +1137,11 @@ class AppViewModel @Inject constructor(
11371137 }
11381138
11391139 // Check if on-chain invoice amount exceeds available balance
1140- if (invoice.amountSatoshis > 0uL && invoice.amountSatoshis > maxSendOnchain) {
1140+ if (
1141+ invoice.amountSatoshis > 0uL &&
1142+ invoice.amountSatoshis > maxSendOnchain &&
1143+ _sendUiState .value.payMethod == SendMethod .ONCHAIN
1144+ ) {
11411145 val shortfall = invoice.amountSatoshis - maxSendOnchain
11421146 toast(
11431147 type = Toast .ToastType .ERROR ,
0 commit comments