Skip to content

Commit 4617834

Browse files
jvsena42claude
andcommitted
fix: show loading on spending tab when node not running
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 46f5327 commit 4617834

3 files changed

Lines changed: 21 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Fixed
1111
- Fix crash when returning app to foreground on Receive screen
12+
- Show loading state on Spending tab when node is not running
1213

1314
[Unreleased]: https://github.com/synonymdev/bitkit-android/compare/v2.1.2...HEAD

app/src/main/java/to/bitkit/ui/screens/wallets/receive/ReceiveInvoiceUtils.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ fun getInvoiceForTab(
3232
}
3333

3434
ReceiveTab.SPENDING -> {
35-
// Lightning only: prefer CJIT > bolt11
35+
// Lightning only: prefer CJIT > bolt11, empty when node is not running
3636
cjitInvoice?.takeIf { it.isNotEmpty() && isNodeRunning }
37-
?: bolt11
37+
?: bolt11.takeIf { isNodeRunning }.orEmpty()
3838
}
3939
}
4040
}

app/src/test/java/to/bitkit/ui/screens/wallets/receive/ReceiveInvoiceUtilsTest.kt

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ class ReceiveInvoiceUtilsTest {
200200
}
201201

202202
@Test
203-
fun `getInvoiceForTab SPENDING returns bolt11 when node not running even with CJIT`() {
203+
fun `getInvoiceForTab SPENDING returns empty when node not running even with CJIT`() {
204204
val bip21 = "bitcoin:$testAddress?lightning=$testBolt11"
205205

206206
val result = getInvoiceForTab(
@@ -212,7 +212,23 @@ class ReceiveInvoiceUtilsTest {
212212
onchainAddress = testAddress
213213
)
214214

215-
assertEquals(testBolt11, result)
215+
assertEquals("", result)
216+
}
217+
218+
@Test
219+
fun `getInvoiceForTab SPENDING returns empty when node not running and no CJIT`() {
220+
val bip21 = "bitcoin:$testAddress?lightning=$testBolt11"
221+
222+
val result = getInvoiceForTab(
223+
tab = ReceiveTab.SPENDING,
224+
bip21 = bip21,
225+
bolt11 = testBolt11,
226+
cjitInvoice = null,
227+
isNodeRunning = false,
228+
onchainAddress = testAddress
229+
)
230+
231+
assertEquals("", result)
216232
}
217233

218234
@Test

0 commit comments

Comments
 (0)