Update ktlint formatting and imports.
This commit is contained in:
parent
bb5931a686
commit
a0837474d0
|
@ -2,11 +2,9 @@ package cash.z.ecc.android.sdk.jni
|
|||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import cash.z.ecc.android.bip39.Mnemonics.MnemonicCode
|
||||
import cash.z.ecc.android.bip39.Mnemonics.WordCount.COUNT_24
|
||||
import cash.z.ecc.android.bip39.toSeed
|
||||
import cash.z.ecc.android.sdk.ext.TroubleshootingTwig
|
||||
import cash.z.ecc.android.sdk.ext.Twig
|
||||
import cash.z.ecc.android.sdk.ext.twig
|
||||
import cash.z.ecc.android.sdk.tool.DerivationTool
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Before
|
||||
|
@ -19,7 +17,6 @@ class TransparentTest {
|
|||
|
||||
@Before
|
||||
fun setup() {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -47,7 +44,6 @@ class TransparentTest {
|
|||
// }
|
||||
// }
|
||||
|
||||
|
||||
companion object {
|
||||
const val PHRASE = "deputy visa gentle among clean scout farm drive comfort patch skin salt ranch cool ramp warrior drink narrow normal lunch behind salt deal person"
|
||||
val MNEMONIC = MnemonicCode(PHRASE)
|
||||
|
@ -63,7 +59,7 @@ class TransparentTest {
|
|||
@BeforeClass
|
||||
@JvmStatic
|
||||
fun startup() {
|
||||
Twig.plant(TroubleshootingTwig(formatter = {"@TWIG $it"}))
|
||||
Twig.plant(TroubleshootingTwig(formatter = { "@TWIG $it" }))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.junit.Test
|
|||
*/
|
||||
class ShieldFundsSample {
|
||||
|
||||
val SEED_PHRASE = "wish puppy smile loan doll curve hole maze file ginger hair nose key relax knife witness cannon grab despair throw review deal slush frame"//\"still champion voice habit trend flight survey between bitter process artefact blind carbon truly provide dizzy crush flush breeze blouse charge solid fish spread\"//\"deputy visa gentle among clean scout farm drive comfort patch skin salt ranch cool ramp warrior drink narrow normal lunch behind salt deal person"//"deputy visa gentle among clean scout farm drive comfort patch skin salt ranch cool ramp warrior drink narrow normal lunch behind salt deal person"
|
||||
val SEED_PHRASE = "wish puppy smile loan doll curve hole maze file ginger hair nose key relax knife witness cannon grab despair throw review deal slush frame" // \"still champion voice habit trend flight survey between bitter process artefact blind carbon truly provide dizzy crush flush breeze blouse charge solid fish spread\"//\"deputy visa gentle among clean scout farm drive comfort patch skin salt ranch cool ramp warrior drink narrow normal lunch behind salt deal person"//"deputy visa gentle among clean scout farm drive comfort patch skin salt ranch cool ramp warrior drink narrow normal lunch behind salt deal person"
|
||||
|
||||
// simple flag to turn off actually spending funds
|
||||
val IS_DRY_RUN = true
|
||||
|
@ -49,7 +49,6 @@ class ShieldFundsSample {
|
|||
Assert.assertEquals(5, wallet.synchronizer.latestBalance.availableZatoshi)
|
||||
}
|
||||
|
||||
|
||||
// when startHeight is null, it will use the latest checkpoint
|
||||
class SimpleWallet(seedPhrase: String, startHeight: Int? = null) {
|
||||
val walletScope = CoroutineScope(
|
||||
|
|
|
@ -3,9 +3,7 @@ package cash.z.ecc.android.sdk.tool
|
|||
import android.content.Context
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import cash.z.ecc.android.sdk.exception.LightWalletException
|
||||
import cash.z.ecc.android.sdk.ext.ZcashSdk
|
||||
import junit.framework.Assert.assertEquals
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
|
@ -26,7 +24,6 @@ class SaplingParamToolTest {
|
|||
SaplingParamTool.clear(cacheDir)
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun testFilesExists() = runBlocking {
|
||||
// Given
|
||||
|
@ -70,14 +67,13 @@ class SaplingParamToolTest {
|
|||
// Given
|
||||
SaplingParamTool.fetchParams(cacheDir)
|
||||
|
||||
Assert.assertFalse("insufficient storage",false)
|
||||
Assert.assertFalse("insufficient storage", false)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testSufficientDeviceStorageForOnlyOneFile() = runBlocking {
|
||||
SaplingParamTool.fetchParams(cacheDir)
|
||||
|
||||
Assert.assertFalse("insufficient storage",false)
|
||||
Assert.assertFalse("insufficient storage", false)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,11 +25,13 @@ import cash.z.ecc.android.sdk.db.entity.PendingTransaction
|
|||
import cash.z.ecc.android.sdk.db.entity.hasRawTransactionId
|
||||
import cash.z.ecc.android.sdk.db.entity.isCancelled
|
||||
import cash.z.ecc.android.sdk.db.entity.isExpired
|
||||
import cash.z.ecc.android.sdk.db.entity.isFailedSubmit
|
||||
import cash.z.ecc.android.sdk.db.entity.isLongExpired
|
||||
import cash.z.ecc.android.sdk.db.entity.isMarkedForDeletion
|
||||
import cash.z.ecc.android.sdk.db.entity.isMined
|
||||
import cash.z.ecc.android.sdk.db.entity.isSafeToDiscard
|
||||
import cash.z.ecc.android.sdk.db.entity.isSubmitSuccess
|
||||
import cash.z.ecc.android.sdk.db.entity.isSubmitted
|
||||
import cash.z.ecc.android.sdk.exception.SynchronizerException
|
||||
import cash.z.ecc.android.sdk.ext.ConsensusBranchId
|
||||
import cash.z.ecc.android.sdk.ext.ZcashSdk
|
||||
|
@ -462,10 +464,12 @@ class SdkSynchronizer internal constructor(
|
|||
}
|
||||
|
||||
// Experimental: cleanup failed transactions
|
||||
allPendingTxs.filter { it.isSubmitted() && it.isFailedSubmit() && !it.isMarkedForDeletion()}.let { failed ->
|
||||
allPendingTxs.filter { it.isSubmitted() && it.isFailedSubmit() && !it.isMarkedForDeletion() }.let { failed ->
|
||||
failed.forEachIndexed { index, pendingTx ->
|
||||
twig("[cleanup] FOUND (${index + 1} of ${failed.size})" +
|
||||
" FAILED pendingTxId: ${pendingTx.id}")
|
||||
twig(
|
||||
"[cleanup] FOUND (${index + 1} of ${failed.size})" +
|
||||
" FAILED pendingTxId: ${pendingTx.id}"
|
||||
)
|
||||
cleanupCancelledTx(pendingTx)
|
||||
}
|
||||
}
|
||||
|
@ -555,7 +559,6 @@ class SdkSynchronizer internal constructor(
|
|||
val tBalance = processor.getUtxoCacheBalance(tAddr)
|
||||
val zAddr = getAddress(0)
|
||||
|
||||
|
||||
// Emit the placeholder transaction, then switch to monitoring the database
|
||||
txManager.initSpend(tBalance.availableZatoshi, zAddr, memo, 0).let { placeHolderTx ->
|
||||
emit(placeHolderTx)
|
||||
|
@ -704,4 +707,4 @@ fun Synchronizer(
|
|||
txManager,
|
||||
processor
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -140,7 +140,6 @@ interface Synchronizer {
|
|||
*/
|
||||
suspend fun getShieldedAddress(accountId: Int = 0): String
|
||||
|
||||
|
||||
/**
|
||||
* Gets the transparent address for the given account and index.
|
||||
*
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
package cash.z.ecc.android.sdk.block // iimport cash.z.ecc.android.sdk.exception.LightWalletException
|
||||
import cash.z.ecc.android.sdk.exception.LightWalletException
|
||||
import cash.z.ecc.android.sdk.ext.tryWarn
|
||||
import cash.z.ecc.android.sdk.service.LightWalletService
|
||||
import cash.z.wallet.sdk.rpc.Service
|
||||
|
|
|
@ -314,7 +314,6 @@ class CompactBlockProcessor(
|
|||
if (!repository.isInitialized()) throw CompactBlockProcessorException.Uninitialized
|
||||
}
|
||||
|
||||
|
||||
internal suspend fun downloadUtxos(tAddress: String, startHeight: Int): Int = withContext(IO) {
|
||||
var skipped = 0
|
||||
twig("Downloading utxos starting at height $startHeight")
|
||||
|
@ -604,7 +603,6 @@ class CompactBlockProcessor(
|
|||
rustBackend.getDownloadedUtxoBalance(address)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Transmits the given state for this processor.
|
||||
*/
|
||||
|
|
|
@ -15,6 +15,7 @@ import cash.z.ecc.android.sdk.db.entity.EncodedTransaction
|
|||
import cash.z.ecc.android.sdk.db.entity.Received
|
||||
import cash.z.ecc.android.sdk.db.entity.Sent
|
||||
import cash.z.ecc.android.sdk.db.entity.TransactionEntity
|
||||
import cash.z.ecc.android.sdk.db.entity.Utxo
|
||||
import cash.z.ecc.android.sdk.ext.twig
|
||||
|
||||
//
|
||||
|
@ -155,7 +156,8 @@ abstract class DerivedDataDb : RoomDatabase() {
|
|||
spent_in_tx INTEGER,
|
||||
FOREIGN KEY (spent_in_tx) REFERENCES transactions(id_tx),
|
||||
CONSTRAINT tx_outpoint UNIQUE (prevout_txid, prevout_idx)
|
||||
); """.trimIndent()
|
||||
);
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,22 +3,23 @@ package cash.z.ecc.android.sdk.db.entity
|
|||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.ForeignKey
|
||||
import androidx.room.PrimaryKey
|
||||
import org.jetbrains.annotations.NotNull
|
||||
|
||||
@Entity(tableName = "utxos",
|
||||
@Entity(
|
||||
tableName = "utxos",
|
||||
primaryKeys = ["id_utxo"],
|
||||
foreignKeys = [ForeignKey(
|
||||
entity = TransactionEntity::class,
|
||||
parentColumns = ["id_tx"],
|
||||
childColumns = ["spent_in_tx"]
|
||||
)]
|
||||
foreignKeys = [
|
||||
ForeignKey(
|
||||
entity = TransactionEntity::class,
|
||||
parentColumns = ["id_tx"],
|
||||
childColumns = ["spent_in_tx"]
|
||||
)
|
||||
]
|
||||
)
|
||||
data class Utxo(
|
||||
@ColumnInfo(name = "id_utxo")
|
||||
val id: Long? = 0L,
|
||||
|
||||
val address: String ="",
|
||||
val address: String = "",
|
||||
|
||||
@ColumnInfo(name = "prevout_txid", typeAffinity = ColumnInfo.BLOB)
|
||||
val txid: ByteArray = byteArrayOf(),
|
||||
|
@ -67,6 +68,4 @@ data class Utxo(
|
|||
result = 31 * result + (spent ?: 0)
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -124,8 +124,8 @@ class RustBackend private constructor() : RustBackendWelding {
|
|||
extsk,
|
||||
tsk,
|
||||
memo ?: ByteArray(0),
|
||||
"${pathParamsDir}/$SPEND_PARAM_FILE_NAME",
|
||||
"${pathParamsDir}/$OUTPUT_PARAM_FILE_NAME"
|
||||
"$pathParamsDir/$SPEND_PARAM_FILE_NAME",
|
||||
"$pathParamsDir/$OUTPUT_PARAM_FILE_NAME"
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -137,6 +137,5 @@ class DerivationTool {
|
|||
|
||||
@JvmStatic
|
||||
private external fun deriveTransparentSecretKeyFromSeed(seed: ByteArray, account: Int, index: Int): String
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.squareup.okhttp.OkHttpClient
|
|||
import com.squareup.okhttp.Request
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import okio.Okio
|
||||
import java.io.File
|
||||
|
||||
class SaplingParamTool {
|
||||
|
|
|
@ -154,7 +154,7 @@ class WalletTransactionEncoder(
|
|||
)
|
||||
} catch (t: Throwable) {
|
||||
// TODO: if this error matches: Insufficient balance (have 0, need 1000 including fee)
|
||||
// then consider custom error that says no UTXOs existed to shield
|
||||
// then consider custom error that says no UTXOs existed to shield
|
||||
twig("Shield failed due to: ${t.message}")
|
||||
throw t
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue