Fix header sync and recovery handling
This commit is contained in:
parent
207657fe13
commit
e0e2a65d1c
4 changed files with 43 additions and 13 deletions
|
|
@ -22,8 +22,8 @@ android {
|
|||
applicationId = "org.vextaproject.wallet"
|
||||
minSdk = 26
|
||||
targetSdk = 36
|
||||
versionCode = 33
|
||||
versionName = "0.6.3"
|
||||
versionCode = 35
|
||||
versionName = "0.6.5"
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
|
|
|
|||
|
|
@ -192,8 +192,13 @@ object HeaderSync {
|
|||
val buffer = ByteBuffer.wrap(payload).order(ByteOrder.LITTLE_ENDIAN)
|
||||
val count = readCompactSize(buffer)
|
||||
|
||||
if (count > 2000) {
|
||||
throw IllegalStateException("too many headers: $count")
|
||||
val maximumPossibleHeaders =
|
||||
buffer.remaining() / 81
|
||||
|
||||
if (count < 0 || count > maximumPossibleHeaders) {
|
||||
throw IllegalStateException(
|
||||
"invalid headers count: $count"
|
||||
)
|
||||
}
|
||||
|
||||
repeat(count) {
|
||||
|
|
|
|||
|
|
@ -148,13 +148,23 @@ class MainActivity : Activity() {
|
|||
|
||||
runOnUiThread {
|
||||
if (intent.getBooleanExtra("sync_only", false)) {
|
||||
setResult(
|
||||
RESULT_OK,
|
||||
android.content.Intent().putExtra(
|
||||
"verified_height",
|
||||
chain.last().height
|
||||
if (chain.last().height > 0) {
|
||||
setResult(
|
||||
RESULT_OK,
|
||||
android.content.Intent().putExtra(
|
||||
"verified_height",
|
||||
chain.last().height
|
||||
)
|
||||
)
|
||||
)
|
||||
} else {
|
||||
setResult(
|
||||
RESULT_CANCELED,
|
||||
android.content.Intent().putExtra(
|
||||
"sync_error",
|
||||
results.joinToString("\n\n")
|
||||
)
|
||||
)
|
||||
}
|
||||
finish()
|
||||
} else {
|
||||
status.text =
|
||||
|
|
@ -317,8 +327,13 @@ class MainActivity : Activity() {
|
|||
val buffer = ByteBuffer.wrap(payload).order(ByteOrder.LITTLE_ENDIAN)
|
||||
val count = readCompactSize(buffer)
|
||||
|
||||
if (count > 2000) {
|
||||
throw IllegalStateException("too many headers: $count")
|
||||
val maximumPossibleHeaders =
|
||||
buffer.remaining() / 81
|
||||
|
||||
if (count < 0 || count > maximumPossibleHeaders) {
|
||||
throw IllegalStateException(
|
||||
"invalid headers count: $count"
|
||||
)
|
||||
}
|
||||
|
||||
repeat(count) {
|
||||
|
|
|
|||
|
|
@ -871,8 +871,18 @@ class WalletActivity : FragmentActivity() {
|
|||
runBlockchainScan()
|
||||
} else {
|
||||
blockchainScanRunning = false
|
||||
|
||||
val syncError = data?.getStringExtra(
|
||||
"sync_error"
|
||||
)?.trim()
|
||||
|
||||
blockchainScanStatus?.text =
|
||||
"Block-header synchronization failed."
|
||||
if (syncError.isNullOrBlank()) {
|
||||
"Block-header synchronization failed."
|
||||
} else {
|
||||
"Block-header synchronization failed:\n" +
|
||||
syncError
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
|
|
|
|||
Loading…
Reference in a new issue