Skip to content

Commit

Permalink
Increment to version 4.0.22
Browse files Browse the repository at this point in the history
  • Loading branch information
angelix committed Dec 21, 2023
1 parent 095e060 commit 2a8ecfa
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 24 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [4.0.22] - 2023-12-19

### Changed
- Add a NoCountly no-op class to FDroid build
- Updated project dependencies
- Bump Breez to version 0.2.12

### Fixed
- Fix emergency recovery phrase restore
- Fix Account Overview crash

## [4.0.21] - 2023-12-06

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,8 @@ class GdkSession constructor(
_multisigBitcoinWatchOnly.value = null
_multisigLiquidWatchOnly.value = null

_accountEmptiedEvent = null
// Clear HW derived lightning mnemonic
_derivedHwLightningMnemonic = null

// Clear Cache
_twoFactorConfigCache = mutableMapOf()
Expand All @@ -726,6 +727,7 @@ class GdkSession constructor(
_tempAllowedServers.clear()

_walletActiveEventInvalidated = true
_accountEmptiedEvent = null

val gaSessionToBeDestroyed = gdkSessions.values.toList()

Expand Down Expand Up @@ -894,6 +896,10 @@ class GdkSession constructor(
}

private fun initLightningSdk(lightningMnemonic: String?) {
if(isHardwareWallet){
_derivedHwLightningMnemonic = lightningMnemonic
}

val lightningLoginData = getWalletIdentifier(
network = defaultNetwork,
loginCredentialsParams = lightningMnemonic?.let { LoginCredentialsParams(mnemonic = it) },
Expand Down Expand Up @@ -1614,9 +1620,10 @@ class GdkSession constructor(
return authHandler(network, gdk.getCredentials(gdkSession(network), params)).result()
}

private var _derivedHwLightningMnemonic: String? = null
fun deriveLightningMnemonic(credentials: Credentials? = null): String {
if (isHardwareWallet && credentials == null) {
throw Exception("HWW can't derive lightning mnemonic")
return _derivedHwLightningMnemonic ?: throw Exception("HWW can't derive lightning mnemonic")
}

return (credentials ?: getCredentials()).let{
Expand Down Expand Up @@ -1864,9 +1871,11 @@ class GdkSession constructor(
lightningSdkOrNull?.sync()
}

private fun getLightningTransactions() = Transactions(transactions = lightningSdk.getTransactions()?.map {
private fun getLightningTransactions() = lightningSdkOrNull?.getTransactions()?.map {
Transaction.fromPayment(it)
} ?: listOf(Transaction.LoadingTransaction))
}.let {
Transactions(transactions = it ?: listOf(Transaction.LoadingTransaction))
}

private val accountsAndBalancesMutex = Mutex()
fun updateAccountsAndBalances(
Expand Down Expand Up @@ -2117,7 +2126,7 @@ class GdkSession constructor(

fun getBalance(account: Account, confirmations: Int = 0, cacheAssets: Boolean = false): Assets {
val assets: LinkedHashMap<String, Long>? = if(account.isLightning) {
lightningSdk.balance()?.let { linkedMapOf(BTC_POLICY_ASSET to it) }
lightningSdkOrNull?.balance()?.let { linkedMapOf(BTC_POLICY_ASSET to it) }
} else {
authHandler(
account.network, gdk.getBalance(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.IO
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.channels.BufferOverflow
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asSharedFlow
Expand Down Expand Up @@ -87,7 +86,7 @@ class SessionManager constructor(

private var timeoutTimers = mutableListOf<Timer>()

val pendingUri: Channel<String?> = Channel(capacity = 1, onBufferOverflow = BufferOverflow.DROP_OLDEST)
val pendingUri: MutableStateFlow<String?> = MutableStateFlow(null)

private val _connectionChangeEvent = MutableSharedFlow<Unit>(replay = 1, onBufferOverflow = BufferOverflow.DROP_OLDEST).also {
// Set initial value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ fun initKoinIos(

}

override fun recordFeedback(rating: Int, email: String?, comment: String) {

}

}
}
single {
Expand Down
8 changes: 4 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ androidTargetSdk = "34"
androidMinSdk = "23"
buildTools = "34.0.0"
breez = "0.2.12"
activity-ktx = "1.8.1"
activity-ktx = "1.8.2"
androidx-junit = "1.1.5"
annotation = "1.7.0"
annotation = "1.7.1"
biometric = "1.2.0-alpha05"
browser = "1.7.0"
constraintlayout = "2.1.4"
Expand Down Expand Up @@ -43,7 +43,7 @@ sqldelight = "2.0.1"
material = "1.10.0"
mockito-kotlin = "5.0.0"
mockk = "1.13.7"
navigation = "2.7.5"
navigation = "2.7.6"
preference-ktx = "1.2.1"
protobuf-java = "3.4.0"
recyclerview = "1.3.2"
Expand Down Expand Up @@ -74,7 +74,7 @@ kmp-nativecoroutines = "1.0.0-ALPHA-22"
compose-bom = "2023.10.01"
compose-material3 = "1.1.2"
compose-compiler = "1.5.6"
activity-compose = "1.8.1"
activity-compose = "1.8.2"

[libraries]
androidx-lifecycle-viewmodel-compose = { module = "androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "lifecycle" }
Expand Down
4 changes: 2 additions & 2 deletions green/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ android {
defaultConfig {
minSdk = libs.versions.androidMinSdk.get().toInt()
targetSdk = libs.versions.androidTargetSdk.get().toInt()
versionCode = 421
versionName = "4.0.21"
versionCode = 422
versionName = "4.0.22"

setProperty("archivesBaseName", "BlockstreamGreen-v$versionName")
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
Expand Down
2 changes: 1 addition & 1 deletion green/src/main/java/com/blockstream/green/data/Countly.kt
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class Countly constructor(
}

override fun showFeedbackWidget(supportFragmentManager: FragmentManager) {
(feedbackWidget as? CountlyFeedbackWidget)?.type.also { type ->
feedbackWidget?.type.also { type ->
if(type == ModuleFeedback.FeedbackWidgetType.nps){
CountlyNpsDialogFragment.show(supportFragmentManager)
}else if(type == ModuleFeedback.FeedbackWidgetType.survey){
Expand Down
5 changes: 2 additions & 3 deletions green/src/main/java/com/blockstream/green/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -436,16 +436,15 @@ class MainActivity : AppActivity() {
private fun handleIntent(intent: Intent?) {
// Handle Uri (BIP-21 or lightning)
intent?.data?.let {

sessionManager.pendingUri.trySend(it.toString())
sessionManager.pendingUri.value = it.toString()

if(navController.currentDestination?.id == R.id.homeFragment) {
Snackbar.make(
binding.root,
R.string.id_you_have_clicked_a_payment_uri,
Snackbar.LENGTH_LONG
).setAction(R.string.id_cancel) {
sessionManager.pendingUri.trySend(null)
sessionManager.pendingUri.value = null
}.show()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ class LightningNodeBottomSheetFragment :

val fastAdapter = FastAdapter.with(itemAdapter)

fastAdapter.addClickListener<ListItemActionBinding, GenericItem>({ binding -> binding.button }) { button, _, _, item ->
fastAdapter.addClickListener<ListItemActionBinding, GenericItem>({ binding -> binding.button }) { _, _, _, _ ->
(parentFragment as? AccountOverviewFragment)?.showLightningRecoveryPhrase()
dismiss()
}

fastAdapter.addClickListener<ListItemActionBinding, GenericItem>({ binding -> binding.buttonOutline }) { button, _, _, item ->
fastAdapter.addClickListener<ListItemActionBinding, GenericItem>({ binding -> binding.buttonOutline }) { button, _, _, _ ->
(parentFragment as? AccountOverviewFragment)?.viewModel?.closeChannel()
(button as? Button)?.isEnabled = false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.merge
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.receiveAsFlow
import kotlinx.coroutines.launch
import org.koin.android.ext.android.inject
import org.koin.androidx.viewmodel.ext.android.viewModel
Expand Down Expand Up @@ -152,8 +153,9 @@ class WalletOverviewFragment : AbstractWalletFragment<WalletOverviewFragmentBind
}

// Handle pending URI (BIP-21 or lightning)
sessionManager.pendingUri.consumeAsFlow().filterNotNull().onEach {
sessionManager.pendingUri.filterNotNull().onEach {
handleUserInput(it, false)
sessionManager.pendingUri.value = null
}.launchIn(lifecycleScope)

binding.vm = viewModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import kotlinx.coroutines.flow.consumeAsFlow
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.receiveAsFlow
import kotlinx.coroutines.launch
import kotlinx.serialization.json.Json
import org.koin.androidx.viewmodel.ext.android.viewModel
Expand Down Expand Up @@ -137,8 +138,9 @@ class SendFragment : AbstractAssetWalletFragment<SendFragmentBinding>(
}

// Handle pending URI (BIP-21 or lightning)
sessionManager.pendingUri.consumeAsFlow().filterNotNull().onEach {
sessionManager.pendingUri.filterNotNull().onEach {
viewModel.setUri(it)
sessionManager.pendingUri.value = null
snackbar(R.string.id_address_was_filled_by_a_payment)
}.launchIn(lifecycleScope)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class SendViewModel constructor(

// Set initial fee slider value
if(feeSlider.value == null){
feeSlider.value = SliderHighIndex.toFloat()
feeSlider.value = SliderLowIndex.toFloat()
}

session.getSettings(network)?.let {
Expand Down Expand Up @@ -206,7 +206,7 @@ class SendViewModel constructor(
// skip if custom fee is selected
if (feeSlider.value?.toInt() != SliderCustomIndex) {
// update based on current slider selection
feeRate = feeEstimation?.getOrNull(FeeBlockTarget[3 - (feeSlider.value ?: SliderHighIndex).toInt()])
feeRate = feeEstimation?.getOrNull(FeeBlockTarget[3 - (feeSlider.value ?: SliderLowIndex).toInt()])

// Update fee
checkTransaction()
Expand Down Expand Up @@ -612,7 +612,7 @@ class SendViewModel constructor(

companion object : KLogging() {
const val SliderCustomIndex = 0
const val SliderHighIndex = 3
const val SliderLowIndex = 1
}

suspend fun getAmountToConvert(): String{
Expand Down

0 comments on commit 2a8ecfa

Please sign in to comment.