From 8e34eb0357dc3957446f071056948501876905ab Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Tue, 18 Oct 2022 17:39:59 -0300 Subject: [PATCH] electrum-related fixes from immortan and use an updated graph. --- app/build.gradle | 6 +++--- app/src/main/scala/SetupActivity.scala | 15 +++++++++++---- app/src/main/scala/WalletApp.scala | 3 ++- app/src/main/scala/utils/LocalBackup.scala | 1 - 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index ac709d2..e271085 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -12,8 +12,8 @@ android { targetSdkVersion 31 minSdkVersion 26 - versionName '0.1.4' - versionCode 5 + versionName '0.1.5' + versionCode 6 } dexOptions { @@ -151,7 +151,7 @@ dependencies { implementation 'org.scala-lang:scala-library:2.13.8' // Related to Immortan - implementation 'com.fiatjaf:immortan_2.13:0.7.8' + implementation 'com.fiatjaf:immortan_2.13:0.7.9-SNAPSHOT' implementation 'fr.acinq.secp256k1:secp256k1-kmp-jni-android:0.6.4' // Built-in Tor diff --git a/app/src/main/scala/SetupActivity.scala b/app/src/main/scala/SetupActivity.scala index abc4b9d..85e5784 100644 --- a/app/src/main/scala/SetupActivity.scala +++ b/app/src/main/scala/SetupActivity.scala @@ -32,13 +32,20 @@ object SetupActivity { val compressedPlainBytes = ByteStreams.toByteArray(host.getAssets open snapshotName) val plainBytes = - compressedByteVecCodec.decode(BitVector.view(compressedPlainBytes)) + compressedByteVecCodec + .decode(BitVector.view(compressedPlainBytes)) + .require + .value LocalBackup.copyPlainDataToDbLocation( host, WalletApp.dbFileNameGraph, - plainBytes.require.value + plainBytes ) - } catch none + System.err.println("[obw][info] channels graph implanted") + } catch { + case err: Throwable => + System.err.println(s"[obw][warn] failed to implant graph: $err") + } WalletApp.putMnemonics(context, mnemonics) WalletApp.makeOperational(mnemonics) @@ -56,7 +63,7 @@ class SetupActivity extends BaseActivity { findViewById(R.id.restoreOptions).asInstanceOf[LinearLayout] private[this] final val FILE_REQUEST_CODE = 112 - private [this] lazy val enforceTor = new SettingsHolder(this) { + private[this] lazy val enforceTor = new SettingsHolder(this) { override def updateView(): Unit = settingsCheck.setChecked(WalletApp.ensureTor) diff --git a/app/src/main/scala/WalletApp.scala b/app/src/main/scala/WalletApp.scala index 299daf9..c224721 100644 --- a/app/src/main/scala/WalletApp.scala +++ b/app/src/main/scala/WalletApp.scala @@ -56,6 +56,8 @@ import scodec.bits.BitVector import castor.Context.Simple.global object WalletApp { + LNParams.chainHash = Block.LivenetGenesisBlock.hash + var chainWalletBag: SQLiteChainWallet = _ var extDataBag: SQLiteDataExtended = _ var lnUrlPayBag: SQLiteLNUrlPay = _ @@ -226,7 +228,6 @@ object WalletApp { LNParams.cm = new ChannelMaster(payBag, chanBag, extDataBag, pf) LNParams.logBag = new SQLiteLog(miscInterface) - LNParams.chainHash = Block.LivenetGenesisBlock.hash LNParams.routerConf = RouterConf(initRouteMaxLength = 10, LNParams.maxCltvExpiryDelta) LNParams.connectionProvider = diff --git a/app/src/main/scala/utils/LocalBackup.scala b/app/src/main/scala/utils/LocalBackup.scala index cd8a0fc..7c0167d 100644 --- a/app/src/main/scala/utils/LocalBackup.scala +++ b/app/src/main/scala/utils/LocalBackup.scala @@ -89,7 +89,6 @@ object LocalBackup { new File(downloadsDir, getGraphResourceName(chainHash)) // Utils - def atomicWrite(file: File, data: ByteVector): Unit = { val atomicFile = new android.util.AtomicFile(file) var fileOutputStream = atomicFile.startWrite