-
Notifications
You must be signed in to change notification settings - Fork 3
feat: bump core to 0.3.9 and hw reliability #1062
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
piotr-iohk
wants to merge
16
commits into
master
Choose a base branch
from
feat/wallet-scoped-core-0.3.9
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
493eee4
feat: bump bitkit-core to 0.3.9
piotr-iohk ee98278
fix: improve hw transfer ble reconnect
piotr-iohk 44a42ae
fix: suppress toast on trezor cancel
piotr-iohk c3a41d2
fix: serialize hw reconnect and scope warm-up
piotr-iohk 5ae87c0
fix: hw watcher merge, wallet id, ble cancel
piotr-iohk 25c3a79
fix: align hw wallet id derivation
piotr-iohk 32dbef7
fix: legacy backup wallet id restore
piotr-iohk 1ba128d
fix: scope hw watchers to native segwit
piotr-iohk 3dfbc32
test: fix stale hw watcher stop assertion
piotr-iohk 2e5fba0
Merge branch 'master' into feat/wallet-scoped-core-0.3.9
piotr-iohk f572fb0
chore: remove unused imports
piotr-iohk 91690eb
refactor: address pr review on trezor repo
piotr-iohk 2dfefc6
refactor: drop backup restore compat layer
piotr-iohk 292327c
Merge branch 'master' into feat/wallet-scoped-core-0.3.9
piotr-iohk 96b3c63
fix: sort hw wallet activities descending
piotr-iohk d6db3df
refactor: address review feedback on hw wallet scoping
coreyphillips File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| package to.bitkit.ext | ||
|
|
||
| import kotlinx.serialization.json.JsonArray | ||
| import kotlinx.serialization.json.JsonElement | ||
| import kotlinx.serialization.json.JsonObject | ||
| import kotlinx.serialization.json.JsonPrimitive | ||
| import kotlinx.serialization.json.jsonArray | ||
Check warningCode scanning / detekt Detects unused imports Warning
Unused import
|
||
| import kotlinx.serialization.json.jsonObject | ||
Check warningCode scanning / detekt Detects unused imports Warning
Unused import
|
||
| import to.bitkit.di.json | ||
| import to.bitkit.models.ActivityBackupV1 | ||
| import to.bitkit.models.MetadataBackupV1 | ||
| import to.bitkit.models.WalletScope | ||
|
|
||
| fun String.decodeActivityBackupV1Compat(): ActivityBackupV1 = | ||
| json.decodeFromString(normalizeLegacyWalletIdsInBackupJson(this)) | ||
|
|
||
| fun String.decodeMetadataBackupV1Compat(): MetadataBackupV1 = | ||
| json.decodeFromString(normalizeLegacyWalletIdsInBackupJson(this)) | ||
|
|
||
| private fun normalizeLegacyWalletIdsInBackupJson( | ||
| raw: String, | ||
| walletId: String = WalletScope.default, | ||
| ): String { | ||
| val normalized = json.parseToJsonElement(raw).normalizeLegacyWalletIds(walletId) | ||
| return json.encodeToString(normalized) | ||
| } | ||
|
|
||
| private fun JsonElement.normalizeLegacyWalletIds(walletId: String): JsonElement = when (this) { | ||
| is JsonObject -> { | ||
| val patched = if (needsLegacyWalletId() && "walletId" !in this) { | ||
| this + ("walletId" to JsonPrimitive(walletId)) | ||
| } else { | ||
| this | ||
| } | ||
| JsonObject(patched.mapValues { (_, value) -> value.normalizeLegacyWalletIds(walletId) }) | ||
| } | ||
| is JsonArray -> JsonArray(map { it.normalizeLegacyWalletIds(walletId) }) | ||
| else -> this | ||
| } | ||
|
|
||
| private fun JsonObject.needsLegacyWalletId(): Boolean = when { | ||
| "paymentId" in this && "tags" in this && "isReceive" in this -> true | ||
| "activityId" in this && "tags" in this && "paymentId" !in this -> true | ||
| "txId" in this && "txType" in this && "value" in this -> true | ||
| "invoice" in this && "status" in this && "txType" in this -> true | ||
| else -> false | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package to.bitkit.ext | ||
|
|
||
| import com.synonym.bitkitcore.TrezorException | ||
|
|
||
| fun Throwable.isTrezorUserCancellation(): Boolean { | ||
| var current: Throwable? = this | ||
| while (current != null) { | ||
| when (current) { | ||
| is TrezorException.UserCancelled, | ||
| is TrezorException.PinCancelled, | ||
| is TrezorException.PassphraseCancelled, | ||
| -> return true | ||
| } | ||
| current = current.cause | ||
| } | ||
| return false | ||
| } | ||
|
jvsena42 marked this conversation as resolved.
Outdated
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package to.bitkit.models | ||
|
|
||
| import com.synonym.bitkitcore.deriveWalletId | ||
|
|
||
| object HwWalletId { | ||
| fun derive(xpubs: Map<String, String>, deviceType: String = "trezor"): String { | ||
| require(xpubs.isNotEmpty()) { "xpubs must not be empty" } | ||
| return deriveWalletId(deviceType = deviceType, xpubs = xpubs.values.toList()) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package to.bitkit.models | ||
|
|
||
| import androidx.annotation.VisibleForTesting | ||
| import com.synonym.bitkitcore.getDefaultWalletId | ||
|
|
||
| object WalletScope { | ||
| @VisibleForTesting | ||
| internal var testOverride: String? = null | ||
|
jvsena42 marked this conversation as resolved.
Outdated
|
||
|
|
||
| val default: String | ||
| get() = testOverride ?: lazyDefault | ||
|
|
||
| private val lazyDefault: String by lazy { getDefaultWalletId() } | ||
|
greptile-apps[bot] marked this conversation as resolved.
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
jvsena42 marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.